Change slogan and refactor project info naming

The project's slagon has been updated back to "Privacy is sexy" from
"Now you have the choice" for enhanced brand clarity and memorability.

This change also reflects the community's preference and aligns with the
project's established identity.

This commit also refactors naming and structure of project information
(metadata) struct to enhance clarity and maintainability in relation to
changing the slogan.

Key changes include:

- Update UI components to display the revised slogan.
- Remove period from project slogan in code area for consistency with a
  explanatory comment for future maintainability.
- Refactor header container and class names for clarity.
- Standardize project metadata usage in `TheCodeArea.vue` to ensure
  consistency.
- Improve code clarity by renaming `IProjectInformation` to
  `ProjectDetails` and `ProjectInformation` to `GitHubProjectDetails`.
- Organize `ProjectDetails` under a dedicated `Project` directory within
  the domain layer for better structure.

These changes are expected to improve the project's appeal and
streamline future maintenance and development efforts.
This commit is contained in:
undergroundwires
2024-02-10 18:50:56 +01:00
parent b9c89b701f
commit a54e16488c
38 changed files with 273 additions and 256 deletions

View File

@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import type { CollectionData } from '@/application/collections/';
import { parseProjectInformation } from '@/application/Parser/ProjectInformationParser';
import { parseProjectDetails } from '@/application/Parser/ProjectDetailsParser';
import { CategoryCollectionParserType, parseApplication } from '@/application/Parser/ApplicationParser';
import { IAppMetadata } from '@/infrastructure/EnvironmentVariables/IAppMetadata';
import WindowsData from '@/application/collections/windows.yaml';
@@ -13,8 +13,8 @@ import { getAbsentCollectionTestCases } from '@tests/unit/shared/TestCases/Absen
import { AppMetadataStub } from '@tests/unit/shared/Stubs/AppMetadataStub';
import { EnvironmentVariablesFactory } from '@/infrastructure/EnvironmentVariables/EnvironmentVariablesFactory';
import { CategoryCollectionParserStub } from '@tests/unit/shared/Stubs/CategoryCollectionParserStub';
import { ProjectInformationParserStub } from '@tests/unit/shared/Stubs/ProjectInformationParserStub';
import { ProjectInformationStub } from '@tests/unit/shared/Stubs/ProjectInformationStub';
import { ProjectDetailsParserStub } from '@tests/unit/shared/Stubs/ProjectDetailsParserStub';
import { ProjectDetailsStub } from '@tests/unit/shared/Stubs/ProjectDetailsStub';
describe('ApplicationParser', () => {
describe('parseApplication', () => {
@@ -38,63 +38,65 @@ describe('ApplicationParser', () => {
expect(expected).to.equal(actual);
});
});
describe('project information', () => {
it('informationParser is used to create application info', () => {
describe('projectDetails', () => {
it('projectDetailsParser is used to create the instance', () => {
// arrange
const expectedInformation = new ProjectInformationStub();
const informationParserStub = new ProjectInformationParserStub()
.withReturnValue(expectedInformation);
const expectedProjectDetails = new ProjectDetailsStub();
const projectDetailsParserStub = new ProjectDetailsParserStub()
.withReturnValue(expectedProjectDetails);
const sut = new ApplicationParserBuilder()
.withProjectInformationParser(informationParserStub.getStub());
.withProjectDetailsParser(projectDetailsParserStub.getStub());
// act
const app = sut.parseApplication();
// assert
const actualInformation = app.info;
expect(expectedInformation).to.deep.equal(actualInformation);
const actualProjectDetails = app.projectDetails;
expect(expectedProjectDetails).to.deep.equal(actualProjectDetails);
});
it('informationParser is used to parse collection info', () => {
it('projectDetailsParser is used to parse collection', () => {
// arrange
const expectedInformation = new ProjectInformationStub();
const informationParserStub = new ProjectInformationParserStub()
.withReturnValue(expectedInformation);
const expectedProjectDetails = new ProjectDetailsStub();
const projectDetailsParserStub = new ProjectDetailsParserStub()
.withReturnValue(expectedProjectDetails);
const collectionParserStub = new CategoryCollectionParserStub();
const sut = new ApplicationParserBuilder()
.withProjectInformationParser(informationParserStub.getStub())
.withProjectDetailsParser(projectDetailsParserStub.getStub())
.withCategoryCollectionParser(collectionParserStub.getStub());
// act
sut.parseApplication();
// assert
expect(collectionParserStub.arguments).to.have.length.above(0);
const actuallyUsedInfos = collectionParserStub.arguments.map((arg) => arg.info);
expect(actuallyUsedInfos.every((info) => info === expectedInformation));
const actuallyUsedInfos = collectionParserStub.arguments.map((arg) => arg.projectDetails);
expect(actuallyUsedInfos.every(
(actualProjectDetails) => actualProjectDetails === expectedProjectDetails,
)).to.equal(true);
});
});
describe('metadata', () => {
it('used to parse expected metadata', () => {
// arrange
const expectedMetadata = new AppMetadataStub();
const infoParserStub = new ProjectInformationParserStub();
const projectDetailsParser = new ProjectDetailsParserStub();
// act
new ApplicationParserBuilder()
.withMetadata(expectedMetadata)
.withProjectInformationParser(infoParserStub.getStub())
.withProjectDetailsParser(projectDetailsParser.getStub())
.parseApplication();
// assert
expect(infoParserStub.arguments).to.have.lengthOf(1);
expect(infoParserStub.arguments[0]).to.equal(expectedMetadata);
expect(projectDetailsParser.arguments).to.have.lengthOf(1);
expect(projectDetailsParser.arguments[0]).to.equal(expectedMetadata);
});
it('defaults to metadata from factory', () => {
// arrange
const expectedMetadata: IAppMetadata = EnvironmentVariablesFactory.Current.instance;
const infoParserStub = new ProjectInformationParserStub();
const projectDetailsParser = new ProjectDetailsParserStub();
// act
new ApplicationParserBuilder()
.withMetadata(undefined) // force using default
.withProjectInformationParser(infoParserStub.getStub())
.withProjectDetailsParser(projectDetailsParser.getStub())
.parseApplication();
// assert
expect(infoParserStub.arguments).to.have.lengthOf(1);
expect(infoParserStub.arguments[0]).to.equal(expectedMetadata);
expect(projectDetailsParser.arguments).to.have.lengthOf(1);
expect(projectDetailsParser.arguments[0]).to.equal(expectedMetadata);
});
});
describe('collectionsData', () => {
@@ -182,8 +184,8 @@ class ApplicationParserBuilder {
private categoryCollectionParser
: CategoryCollectionParserType = new CategoryCollectionParserStub().getStub();
private projectInformationParser
: typeof parseProjectInformation = new ProjectInformationParserStub().getStub();
private projectDetailsParser
: typeof parseProjectDetails = new ProjectDetailsParserStub().getStub();
private metadata: IAppMetadata | undefined = new AppMetadataStub();
@@ -196,10 +198,10 @@ class ApplicationParserBuilder {
return this;
}
public withProjectInformationParser(
projectInformationParser: typeof parseProjectInformation,
public withProjectDetailsParser(
projectDetailsParser: typeof parseProjectDetails,
): this {
this.projectInformationParser = projectInformationParser;
this.projectDetailsParser = projectDetailsParser;
return this;
}
@@ -218,7 +220,7 @@ class ApplicationParserBuilder {
public parseApplication(): ReturnType<typeof parseApplication> {
return parseApplication(
this.categoryCollectionParser,
this.projectInformationParser,
this.projectDetailsParser,
this.metadata,
this.collectionsData,
);

View File

@@ -6,7 +6,7 @@ import { OperatingSystem } from '@/domain/OperatingSystem';
import { RecommendationLevel } from '@/domain/RecommendationLevel';
import { ScriptingDefinitionParser } from '@/application/Parser/ScriptingDefinition/ScriptingDefinitionParser';
import { EnumParserStub } from '@tests/unit/shared/Stubs/EnumParserStub';
import { ProjectInformationStub } from '@tests/unit/shared/Stubs/ProjectInformationStub';
import { ProjectDetailsStub } from '@tests/unit/shared/Stubs/ProjectDetailsStub';
import { getCategoryStub, CollectionDataStub } from '@tests/unit/shared/Stubs/CollectionDataStub';
import { CategoryCollectionParseContextStub } from '@tests/unit/shared/Stubs/CategoryCollectionParseContextStub';
import { CategoryDataStub } from '@tests/unit/shared/Stubs/CategoryDataStub';
@@ -25,9 +25,9 @@ describe('CategoryCollectionParser', () => {
const expectedError = 'content does not define any action';
const collection = new CollectionDataStub()
.withActions(absentValue);
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
// act
const act = () => parseCategoryCollection(collection, info);
const act = () => parseCategoryCollection(collection, projectDetails);
// assert
expect(act).to.throw(expectedError);
}, { excludeUndefined: true, excludeNull: true });
@@ -39,9 +39,9 @@ describe('CategoryCollectionParser', () => {
const expected = [parseCategory(actions[0], context), parseCategory(actions[1], context)];
const collection = new CollectionDataStub()
.withActions(actions);
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
// act
const actual = parseCategoryCollection(collection, info).actions;
const actual = parseCategoryCollection(collection, projectDetails).actions;
// assert
expect(excludingId(actual)).to.be.deep.equal(excludingId(expected));
function excludingId<TId>(array: ReadonlyArray<IEntity<TId>>) {
@@ -57,11 +57,11 @@ describe('CategoryCollectionParser', () => {
it('parses scripting definition as expected', () => {
// arrange
const collection = new CollectionDataStub();
const information = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
const expected = new ScriptingDefinitionParser()
.parse(collection.scripting, information);
.parse(collection.scripting, projectDetails);
// act
const actual = parseCategoryCollection(collection, information).scripting;
const actual = parseCategoryCollection(collection, projectDetails).scripting;
// assert
expect(expected).to.deep.equal(actual);
});
@@ -76,9 +76,9 @@ describe('CategoryCollectionParser', () => {
.withOs(osText);
const parserMock = new EnumParserStub<OperatingSystem>()
.setup(expectedName, osText, expectedOs);
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
// act
const actual = parseCategoryCollection(collection, info, parserMock);
const actual = parseCategoryCollection(collection, projectDetails, parserMock);
// assert
expect(actual.os).to.equal(expectedOs);
});
@@ -106,9 +106,9 @@ describe('CategoryCollectionParser', () => {
const collection = new CollectionDataStub()
.withActions([category])
.withFunctions([func]);
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
// act
const actual = parseCategoryCollection(collection, info);
const actual = parseCategoryCollection(collection, projectDetails);
// assert
const actualScript = actual.getScript(scriptName);
const actualCode = actualScript.code.execute;

View File

@@ -1,85 +1,87 @@
import { describe, it, expect } from 'vitest';
import { parseProjectInformation, ProjectInformationFactory } from '@/application/Parser/ProjectInformationParser';
import { parseProjectDetails, ProjectDetailsFactory } from '@/application/Parser/ProjectDetailsParser';
import { AppMetadataStub } from '@tests/unit/shared/Stubs/AppMetadataStub';
import { PropertyKeys } from '@/TypeHelpers';
import { ProjectInformationStub } from '@tests/unit/shared/Stubs/ProjectInformationStub';
import { ProjectDetailsStub } from '@tests/unit/shared/Stubs/ProjectDetailsStub';
import { Version } from '@/domain/Version';
describe('ProjectInformationParser', () => {
describe('parseProjectInformation', () => {
it('returns expected information', () => {
describe('ProjectDetailsParser', () => {
describe('parseProjectDetails', () => {
it('returns expected instance', () => {
// arrange
const expectedInformation = new ProjectInformationStub();
const expectedInformation = new ProjectDetailsStub();
const factoryMock = () => expectedInformation;
// act
const actualInformation = parseProjectInformation(new AppMetadataStub(), factoryMock);
const actualInformation = parseProjectDetails(new AppMetadataStub(), factoryMock);
// assert
expect(expectedInformation).to.equal(actualInformation);
});
describe('default behavior does not throw', () => {
it('without metadataFactory', () => {
it('without metadata', () => {
// arrange
const metadataFactory = undefined;
const informationFactory = new ProjectInformationFactoryStub().getStub();
const projectDetailsFactory = new ProjectDetailsFactoryStub().getStub();
// act
const act = () => parseProjectInformation(metadataFactory, informationFactory);
const act = () => parseProjectDetails(metadataFactory, projectDetailsFactory);
// expectS
expect(act).to.not.throw();
});
it('without projectInformationFactory', () => {
it('without projectDetailsFactory', () => {
// arrange
const metadataFactory = new AppMetadataStub();
const informationFactory = undefined;
const projectDetailsFactory = undefined;
// act
const act = () => parseProjectInformation(metadataFactory, informationFactory);
const act = () => parseProjectDetails(metadataFactory, projectDetailsFactory);
// expect
expect(act).to.not.throw();
});
});
describe('parses metadata to project information', () => {
interface IMetadataTestCase {
describe('parses metadata correctly', () => {
interface MetadataTestScenario {
readonly setMetadata: (appMetadataStub: AppMetadataStub, value: string) => AppMetadataStub;
readonly expectedValue: string;
readonly getActualValue: (info: ProjectInformationFactoryStub) => string;
readonly getActualValue: (projectDetailsFactory: ProjectDetailsFactoryStub) => string;
}
const testCases: { [K in PropertyKeys<ProjectInformationFactoryStub>]: IMetadataTestCase } = {
const testScenarios: {
[K in PropertyKeys<ProjectDetailsFactoryStub>]: MetadataTestScenario
} = {
name: {
setMetadata: (metadata, value) => metadata.witName(value),
expectedValue: 'expected-app-name',
getActualValue: (info) => info.name,
getActualValue: (projectDetailsFactory) => projectDetailsFactory.name,
},
version: {
setMetadata: (metadata, value) => metadata.withVersion(value),
expectedValue: '0.11.3',
getActualValue: (info) => info.version.toString(),
getActualValue: (projectDetailsFactory) => projectDetailsFactory.version.toString(),
},
slogan: {
setMetadata: (metadata, value) => metadata.withSlogan(value),
expectedValue: 'expected-slogan',
getActualValue: (info) => info.slogan,
getActualValue: (projectDetailsFactory) => projectDetailsFactory.slogan,
},
repositoryUrl: {
setMetadata: (metadata, value) => metadata.withRepositoryUrl(value),
expectedValue: 'https://expected-repository.url',
getActualValue: (info) => info.repositoryUrl,
getActualValue: (projectDetailsFactory) => projectDetailsFactory.repositoryUrl,
},
homepage: {
setMetadata: (metadata, value) => metadata.withHomepageUrl(value),
expectedValue: 'https://expected.sexy',
getActualValue: (info) => info.homepage,
getActualValue: (projectDetailsFactory) => projectDetailsFactory.homepage,
},
};
Object.entries(testCases).forEach(([propertyName, {
Object.entries(testScenarios).forEach(([propertyName, {
expectedValue, setMetadata, getActualValue,
}]) => {
it(propertyName, () => {
// act
const metadata = setMetadata(new AppMetadataStub(), expectedValue);
const factoryStub = new ProjectInformationFactoryStub();
const projectDetailsFactoryStub = new ProjectDetailsFactoryStub();
// act
parseProjectInformation(metadata, factoryStub.getStub());
parseProjectDetails(metadata, projectDetailsFactoryStub.getStub());
// assert
const actual = getActualValue(factoryStub);
const actual = getActualValue(projectDetailsFactoryStub);
expect(actual).to.be.equal(expectedValue);
});
});
@@ -87,7 +89,7 @@ describe('ProjectInformationParser', () => {
});
});
class ProjectInformationFactoryStub {
class ProjectDetailsFactoryStub {
public name: string;
public version: Version;
@@ -98,14 +100,14 @@ class ProjectInformationFactoryStub {
public homepage: string;
public getStub(): ProjectInformationFactory {
public getStub(): ProjectDetailsFactory {
return (name, version, slogan, repositoryUrl, homepage) => {
this.name = name;
this.version = version;
this.slogan = slogan;
this.repositoryUrl = repositoryUrl;
this.homepage = homepage;
return new ProjectInformationStub();
return new ProjectDetailsStub();
};
}
}

View File

@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest';
import { CodeSubstituter } from '@/application/Parser/ScriptingDefinition/CodeSubstituter';
import { IExpressionsCompiler } from '@/application/Parser/Script/Compiler/Expressions/IExpressionsCompiler';
import { ProjectInformationStub } from '@tests/unit/shared/Stubs/ProjectInformationStub';
import { ProjectDetailsStub } from '@tests/unit/shared/Stubs/ProjectDetailsStub';
import { ExpressionsCompilerStub } from '@tests/unit/shared/Stubs/ExpressionsCompilerStub';
import { itEachAbsentStringValue } from '@tests/unit/shared/TestCases/AbsentTests';
@@ -11,26 +11,26 @@ describe('CodeSubstituter', () => {
// arrange
const expectedError = 'missing code';
const code = emptyCode;
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
const sut = new CodeSubstituterBuilder().build();
// act
const act = () => sut.substitute(code, info);
const act = () => sut.substitute(code, projectDetails);
// assert
expect(act).to.throw(expectedError);
}, { excludeNull: true, excludeUndefined: true });
});
describe('substitutes parameters as expected values', () => {
// arrange
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
const date = new Date();
const testCases: Array<{ parameter: string, argument: string }> = [
{
parameter: 'homepage',
argument: info.homepage,
argument: projectDetails.homepage,
},
{
parameter: 'version',
argument: info.version.toString(),
argument: projectDetails.version.toString(),
},
{
parameter: 'date',
@@ -45,7 +45,7 @@ describe('CodeSubstituter', () => {
.withDate(date)
.build();
// act
sut.substitute('non empty code', info);
sut.substitute('non empty code', projectDetails);
// assert
expect(compilerStub.callHistory).to.have.lengthOf(1);
const parameters = compilerStub.callHistory[0].args[1];
@@ -63,7 +63,7 @@ describe('CodeSubstituter', () => {
.withCompiler(compilerStub)
.build();
// act
sut.substitute(expected, new ProjectInformationStub());
sut.substitute(expected, new ProjectDetailsStub());
// assert
expect(compilerStub.callHistory).to.have.lengthOf(1);
expect(compilerStub.callHistory[0].args[0]).to.equal(expected);

View File

@@ -4,7 +4,7 @@ import { ScriptingDefinitionParser } from '@/application/Parser/ScriptingDefinit
import { IEnumParser } from '@/application/Common/Enum';
import { ICodeSubstituter } from '@/application/Parser/ScriptingDefinition/ICodeSubstituter';
import { IScriptingDefinition } from '@/domain/IScriptingDefinition';
import { ProjectInformationStub } from '@tests/unit/shared/Stubs/ProjectInformationStub';
import { ProjectDetailsStub } from '@tests/unit/shared/Stubs/ProjectDetailsStub';
import { EnumParserStub } from '@tests/unit/shared/Stubs/EnumParserStub';
import { ScriptingDefinitionDataStub } from '@tests/unit/shared/Stubs/ScriptingDefinitionDataStub';
import { CodeSubstituterStub } from '@tests/unit/shared/Stubs/CodeSubstituterStub';
@@ -17,7 +17,7 @@ describe('ScriptingDefinitionParser', () => {
const expectedLanguage = ScriptingLanguage.batchfile;
const languageText = 'batchfile';
const expectedName = 'language';
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
const definition = new ScriptingDefinitionDataStub()
.withLanguage(languageText);
const parserMock = new EnumParserStub<ScriptingLanguage>()
@@ -26,7 +26,7 @@ describe('ScriptingDefinitionParser', () => {
.withParser(parserMock)
.build();
// act
const actual = sut.parse(definition, info);
const actual = sut.parse(definition, projectDetails);
// assert
expect(actual.language).to.equal(expectedLanguage);
});
@@ -51,14 +51,14 @@ describe('ScriptingDefinitionParser', () => {
];
for (const testCase of testCases) {
it(testCase.name, () => {
const info = new ProjectInformationStub();
const projectDetails = new ProjectDetailsStub();
const substituterMock = new CodeSubstituterStub()
.setup(code, info, expected);
.setup(code, projectDetails, expected);
const sut = new ScriptingDefinitionParserBuilder()
.withSubstituter(substituterMock)
.build();
// act
const definition = sut.parse(testCase.data, info);
const definition = sut.parse(testCase.data, projectDetails);
// assert
const actual = testCase.getActualValue(definition);
expect(actual).to.equal(expected);