From 09062d21324ea02259d330175c2fb412d19bf089 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Fri, 23 Feb 2024 00:20:23 +0000 Subject: [PATCH 01/18] feat(app): complete Author question class --- src/questions/Author.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/questions/Author.ts b/src/questions/Author.ts index bc10ebd..945be9c 100644 --- a/src/questions/Author.ts +++ b/src/questions/Author.ts @@ -1,16 +1,23 @@ import { PromptQuestion } from "@yeoman/types"; -import { BaseQuestion } from "./index.js"; +import { BaseQuestion } from "./BaseQuestion.js"; import { Answers } from "../@types/index.js"; import AppGenerator from "../app.js"; export class Author extends BaseQuestion { public constructor(generator: AppGenerator) { super(generator); - // this.generator.options.author = this.generator.git.name(); + + if (this.generator.options.author) { + return; + } + + if (this.generator.options.skipPrompts) { + this.generator.options.author = this.getDefault(); + } } private getDefault(): string { - return ""; + return this.generator.user || ""; } public getQuestion(): PromptQuestion { From 466e1e019e96f82fdef70a40a9eae337c9275576 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Fri, 23 Feb 2024 00:22:01 +0000 Subject: [PATCH 02/18] refactor(questions): dont export BaseQuestion class --- src/questions/Git.ts | 2 +- src/questions/PackageManager.ts | 2 +- src/questions/ProjectDescription.ts | 2 +- src/questions/ProjectId.ts | 2 +- src/questions/ProjectName.ts | 4 ++-- src/questions/ProjectType.ts | 2 +- src/questions/index.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/questions/Git.ts b/src/questions/Git.ts index 4257ac3..b33dc2b 100644 --- a/src/questions/Git.ts +++ b/src/questions/Git.ts @@ -1,5 +1,5 @@ import { PromptQuestion } from "@yeoman/types"; -import { BaseQuestion } from "./index.js"; +import { BaseQuestion } from "./BaseQuestion.js"; import { Answers } from "../@types/index.js"; import AppGenerator from "../app.js"; diff --git a/src/questions/PackageManager.ts b/src/questions/PackageManager.ts index cda81c3..eabafb0 100644 --- a/src/questions/PackageManager.ts +++ b/src/questions/PackageManager.ts @@ -1,5 +1,5 @@ import { PromptQuestion } from "@yeoman/types"; -import { BaseQuestion } from "./index.js"; +import { BaseQuestion } from "./BaseQuestion.js"; import { Answers, NodePackageManager } from "../@types/index.js"; import { ConfigHelper } from "../helpers/index.js"; import AppGenerator from "../app.js"; diff --git a/src/questions/ProjectDescription.ts b/src/questions/ProjectDescription.ts index 2dd3ce3..65e9667 100644 --- a/src/questions/ProjectDescription.ts +++ b/src/questions/ProjectDescription.ts @@ -1,6 +1,6 @@ import { PromptQuestion } from "@yeoman/types"; +import { BaseQuestion } from "./BaseQuestion.js"; import { Answers } from "../@types/index.js"; -import { BaseQuestion } from "./index.js"; import AppGenerator from "../app.js"; export class ProjectDescription extends BaseQuestion { diff --git a/src/questions/ProjectId.ts b/src/questions/ProjectId.ts index 9fc407f..289ed84 100644 --- a/src/questions/ProjectId.ts +++ b/src/questions/ProjectId.ts @@ -1,6 +1,6 @@ import { PromptQuestion } from "@yeoman/types"; +import { BaseQuestion } from "./BaseQuestion.js"; import { Answers } from "../@types/index.js"; -import { BaseQuestion } from "./index.js"; import AppGenerator from "../app.js"; export class ProjectId extends BaseQuestion { diff --git a/src/questions/ProjectName.ts b/src/questions/ProjectName.ts index 5efffb9..728ef4e 100644 --- a/src/questions/ProjectName.ts +++ b/src/questions/ProjectName.ts @@ -1,8 +1,8 @@ import path from "node:path"; import { PromptQuestion } from "@yeoman/types"; -import AppGenerator from "../app.js"; +import { BaseQuestion } from "./BaseQuestion.js"; import { Answers } from "../@types/index.js"; -import { BaseQuestion } from "./index.js"; +import AppGenerator from "../app.js"; export class ProjectName extends BaseQuestion { public constructor(generator: AppGenerator) { diff --git a/src/questions/ProjectType.ts b/src/questions/ProjectType.ts index 21c91f3..2888776 100644 --- a/src/questions/ProjectType.ts +++ b/src/questions/ProjectType.ts @@ -1,6 +1,6 @@ import { PromptQuestion } from "@yeoman/types"; +import { BaseQuestion } from "./BaseQuestion.js"; import { Answers, GeneratorSignature } from "../@types/index.js"; -import { BaseQuestion } from "./index.js"; import AppGenerator from "../app.js"; export class ProjectType extends BaseQuestion { diff --git a/src/questions/index.ts b/src/questions/index.ts index 4fa3a32..dc5d9f1 100644 --- a/src/questions/index.ts +++ b/src/questions/index.ts @@ -1,4 +1,4 @@ -export * from "./BaseQuestion.js"; +export * from "./Author.js"; export * from "./Git.js"; export * from "./PackageManager.js"; export * from "./ProjectDescription.js"; From 6986b61600963477115e36bdfc48b525db0d9f02 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Fri, 23 Feb 2024 00:28:59 +0000 Subject: [PATCH 03/18] refactor(helpers): edit all methods on GitHelper to be public --- src/helpers/GitHelper.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helpers/GitHelper.ts b/src/helpers/GitHelper.ts index 049b2fc..9cd1d6b 100644 --- a/src/helpers/GitHelper.ts +++ b/src/helpers/GitHelper.ts @@ -2,17 +2,17 @@ import Generator from "yeoman-generator"; import which from "which"; export class GitHelper { - private static async isGitInstalled(): Promise { + public static async isGitInstalled(): Promise { return await which("git").catch(() => undefined); } - private static async getGitUserName( + public static async getGitUserName( generator: Generator, ): Promise { return await generator.git.name(); } - private static async getGitUserEmail( + public static async getGitUserEmail( generator: Generator, ): Promise { return await generator.git.email(); From ea47cc500d201fcb7b77c83c836b286d31681b87 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Fri, 23 Feb 2024 00:30:09 +0000 Subject: [PATCH 04/18] feat(app): add user field to root generator --- src/app.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app.ts b/src/app.ts index 3b30d6a..ce0a698 100644 --- a/src/app.ts +++ b/src/app.ts @@ -25,6 +25,7 @@ class AppGenerator extends Generator { private generator: GeneratorInterface | undefined = undefined; private readonly choices = GeneratorFactory.getAvailable(); public abort: boolean = false; + public user: string | undefined = undefined; constructor(args: string | Array, options: AppOptions) { super(args, options); @@ -50,6 +51,8 @@ class AppGenerator extends Generator { } public async initializing(): Promise { + this.user = await GitHelper.getGitUserName(this); + this.log( yosay( `Welcome to the\n${chalk.bold.magenta( From 6e3db945c8f7a5aabc5c421e8a40ebe89d53316e Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Fri, 23 Feb 2024 00:50:16 +0000 Subject: [PATCH 05/18] feat(typescript): add author prompt --- src/generators/TypescriptGenerator.ts | 10 +++++++--- templates/typescript/LICENSE | 2 +- templates/typescript/all-contributorsrc.ejs | 2 +- templates/typescript/package.json.ejs | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/generators/TypescriptGenerator.ts b/src/generators/TypescriptGenerator.ts index eb0231b..36747f1 100644 --- a/src/generators/TypescriptGenerator.ts +++ b/src/generators/TypescriptGenerator.ts @@ -10,11 +10,12 @@ import { } from "../@types/index.js"; import AppGenerator from "../app.js"; import { - ProjectName, - ProjectId, - ProjectDescription, + Author, Git, PackageManager, + ProjectDescription, + ProjectId, + ProjectName, } from "../questions/index.js"; import { ConfigHelper } from "../helpers/index.js"; import { NodeEnvironment } from "../environments/index.js"; @@ -39,6 +40,7 @@ export class TypescriptGenerator implements GeneratorInterface { new ProjectName(this.generator).getQuestion(), new ProjectId(this.generator).getQuestion(), new ProjectDescription(this.generator).getQuestion(), + new Author(this.generator).getQuestion(), new Git(this.generator).getQuestion(), new PackageManager(this.generator).getQuestion(), ); @@ -80,6 +82,8 @@ export class TypescriptGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; + this.generator.options.author = + this.generator.options.author || answers.author; // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access diff --git a/templates/typescript/LICENSE b/templates/typescript/LICENSE index 2def622..632413b 100644 --- a/templates/typescript/LICENSE +++ b/templates/typescript/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) <%- new Date().getFullYear() %> Norgate AV Services Limited +Copyright (c) <%- new Date().getFullYear() %> <%- author %> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/templates/typescript/all-contributorsrc.ejs b/templates/typescript/all-contributorsrc.ejs index 59514c6..9e82da5 100644 --- a/templates/typescript/all-contributorsrc.ejs +++ b/templates/typescript/all-contributorsrc.ejs @@ -1,6 +1,6 @@ { "projectName": <%- JSON.stringify(id) %>, - "projectOwner": "", + "projectOwner": <%- JSON.stringify(author) %>, "repoType": "github", "repoHost": "https://github.com", "files": [ diff --git a/templates/typescript/package.json.ejs b/templates/typescript/package.json.ejs index a16cab0..e1671a9 100644 --- a/templates/typescript/package.json.ejs +++ b/templates/typescript/package.json.ejs @@ -4,6 +4,7 @@ "description": <%- JSON.stringify(description) %>, "version": "0.0.0", "license": "MIT", + "author": <%- JSON.stringify(author) %>, "main": "./dist/app.js", "types": "./dist/app.d.ts", "type": "module", From f6003cfeb45b169a3deece40e7c0b660e83fa405 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Fri, 23 Feb 2024 00:50:47 +0000 Subject: [PATCH 06/18] test(typescript): add author assertions to tests --- tests/typescript.test.ts | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/tests/typescript.test.ts b/tests/typescript.test.ts index a12462d..66f2674 100644 --- a/tests/typescript.test.ts +++ b/tests/typescript.test.ts @@ -157,7 +157,7 @@ describe("generator-norgate-av:typescript", () => { assert.equal(result.generator.options.name, name); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -184,6 +184,7 @@ describe("generator-norgate-av:typescript", () => { name: id, displayName: name, description, + author, engines: { node: `>=${engine}`, }, @@ -221,7 +222,7 @@ describe("generator-norgate-av:typescript", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -263,6 +264,11 @@ describe("generator-norgate-av:typescript", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -387,7 +393,7 @@ describe("generator-norgate-av:typescript", () => { assert.equal(result.generator.options.name, destination); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -414,6 +420,7 @@ describe("generator-norgate-av:typescript", () => { name: id, displayName: destination, description, + author, engines: { node: `>=${engine}`, }, @@ -451,7 +458,7 @@ describe("generator-norgate-av:typescript", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -493,6 +500,11 @@ describe("generator-norgate-av:typescript", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -553,10 +565,15 @@ describe("generator-norgate-av:typescript", () => { result?.cleanup(); }); - it("should assign the correct default values", () => { + it("should assign the correct default values", async () => { assert.equal(result.generator.options.id, "test-project"); assert.equal(result.generator.options.description, ""); - assert.equal(result.generator.options.author, ""); + + assert.equal( + result.generator.options.author, + (await result.generator.git.name()) || "", + ); + assert.equal(result.generator.options.git, !process.env.CI); assert.equal(result.generator.options.pkg, "pnpm"); assert.equal( @@ -580,6 +597,7 @@ describe("generator-norgate-av:typescript", () => { name: result.generator.options.id, displayName: destination, description: result.generator.options.description, + author: result.generator.options.author, engines: { node: `>=${engine}`, }, @@ -620,7 +638,7 @@ describe("generator-norgate-av:typescript", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, ); }); @@ -671,6 +689,11 @@ describe("generator-norgate-av:typescript", () => { ".all-contributorsrc", `"projectName": "${result.generator.options.id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${result.generator.options.author}"`, + ); }); it("should create the correct husky git hooks", () => { From e5f78c843d7aadac830465cad0618a673d42ba17 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 01:59:10 +0000 Subject: [PATCH 07/18] test(typescript): add helper functions for common assertions --- tests/helpers.ts | 65 ++++++++++++ tests/typescript.test.ts | 220 ++++++++++----------------------------- 2 files changed, 119 insertions(+), 166 deletions(-) diff --git a/tests/helpers.ts b/tests/helpers.ts index 6b18e97..9409141 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -1,3 +1,15 @@ +import assert from "yeoman-assert"; +import { RunResult } from "yeoman-test"; +import AppGenerator from "../src/app.js"; +import { AppOptions } from "../src/@types/index.js"; + +type AssertionOptions = Partial< + Pick< + AppOptions, + "type" | "id" | "name" | "description" | "author" | "git" | "pkg" + > +>; + export function getNodeDependencyObject( dependencies: Array, store: Record, @@ -15,3 +27,56 @@ export function getNodeDependencyObject( }; }, {}); } + +export function assertReadMe(file: string, { id }: AssertionOptions): void { + assert.fileContent(file, `# ${id}`); + assert.fileContent( + file, + `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, + ); +} + +export function assertLicense( + file: string, + { author }: AssertionOptions, +): void { + assert.fileContent(file, "The MIT License (MIT)"); + assert.fileContent( + file, + `Copyright (c) ${new Date().getFullYear()} ${author}`, + ); +} + +export function assertAllContributorsRc( + file: string, + { id, author }: AssertionOptions, +): void { + assert.fileContent(file, `"projectName": "${id}"`); + assert.fileContent(file, `"projectOwner": "${author}"`); +} + +export function assertChangeLog(file: string, { id }: AssertionOptions): void { + assert.fileContent( + file, + `All notable changes to the "${id}" project will be documented in this file.`, + ); +} + +export function assertOptionValues( + result: RunResult, + { type, name, id, description, author, git, pkg }: AssertionOptions, +): void { + assert.equal(result.generator.options.type, type); + assert.equal(result.generator.options.name, name); + assert.equal(result.generator.options.id, id); + assert.equal(result.generator.options.description, description); + assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.git, process.env.CI ? false : git); + assert.equal(result.generator.options.pkg, pkg); + assert.equal( + // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + result.generator.env.options.nodePackageManager, + pkg, + ); +} diff --git a/tests/typescript.test.ts b/tests/typescript.test.ts index 66f2674..6fa96cb 100644 --- a/tests/typescript.test.ts +++ b/tests/typescript.test.ts @@ -8,7 +8,14 @@ import { NodeEnvironment } from "../src/environments/index.js"; import { ConfigHelper } from "../src/helpers/index.js"; import config from "../config/default.json"; import { UnresolvedConfig, NodePackageManager } from "../src/@types/index.js"; -import { getNodeDependencyObject } from "./helpers.js"; +import { + assertAllContributorsRc, + assertChangeLog, + assertLicense, + assertOptionValues, + assertReadMe, + getNodeDependencyObject, +} from "./helpers.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const generator = path.resolve(__dirname, "../dist/generators/app"); @@ -88,12 +95,6 @@ const files = [ "vitest.config.ts", ]; -// const lock = { -// pnpm: "pnpm-lock.yaml", -// npm: "package-lock.json", -// yarn: "yarn.lock", -// }; - describe("generator-norgate-av:typescript", () => { describe.each([ { @@ -153,22 +154,15 @@ describe("generator-norgate-av:typescript", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.name, name); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${name}' and CD into it`, () => { @@ -207,11 +201,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -219,11 +209,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { @@ -253,22 +239,11 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { @@ -292,44 +267,6 @@ describe("generator-norgate-av:typescript", () => { }, ); - // describe.skip("typescript:install", () => { - // let result: RunResult; - - // const name = "test"; - // const description = "test-description"; - // const pkg = "pnpm"; - - // beforeAll(async () => { - // result = await helpers - // .create(generator) - // .withOptions({ - // skipInstall: false, - // }) - // .withAnswers({ - // type: "typescript", - // name, - // description, - // git: false, - // pkg, - // openWith: "skip", - // }); - - // process.chdir(name); - // }, 200000); - - // afterAll(() => { - // result?.cleanup(); - // }); - - // it("should install packages using the correct package manager", () => { - // assert.file(lock[pkg]); - // }); - - // it("should always pass", () => { - // expect(1).toEqual(1); - // }); - // }); - describe.each([ { destination: "test", @@ -388,23 +325,15 @@ describe("generator-norgate-av:typescript", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.destination, destination); - assert.equal(result.generator.options.name, destination); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name: destination, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -443,11 +372,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -455,11 +380,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { @@ -489,22 +410,11 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { @@ -566,22 +476,15 @@ describe("generator-norgate-av:typescript", () => { }); it("should assign the correct default values", async () => { - assert.equal(result.generator.options.id, "test-project"); - assert.equal(result.generator.options.description, ""); - - assert.equal( - result.generator.options.author, - (await result.generator.git.name()) || "", - ); - - assert.equal(result.generator.options.git, !process.env.CI); - assert.equal(result.generator.options.pkg, "pnpm"); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - "pnpm", - ); + assertOptionValues(result, { + type, + name: destination, + id: "test-project", + description: "", + author: (await result.generator.git.name()) || "", + git: !process.env.CI, + pkg: "pnpm", + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -620,14 +523,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct README.md", () => { - assert.fileContent( - "README.md", - `# ${result.generator.options.id}`, - ); - assert.fileContent( - "README.md", - `This is the README for your project "${result.generator.options.id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id: result.generator.options.id }); }); it("should create the correct .nvmrc", () => { @@ -635,11 +531,9 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, - ); + assertLicense("LICENSE", { + author: result.generator.options.author, + }); }); it("should create the correct CONTRIBUTING.md", () => { @@ -678,22 +572,16 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${result.generator.options.id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { + id: result.generator.options.id, + }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${result.generator.options.id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${result.generator.options.author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { + id: result.generator.options.id, + author: result.generator.options.author, + }); }); it("should create the correct husky git hooks", () => { From e54e5f67b9819191e6ea87ed07fed52d305b43d7 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 02:08:56 +0000 Subject: [PATCH 08/18] test: add author assertions to remaining tests --- tests/c.test.ts | 37 ++++++++++++++++++++++++++++++------- tests/html.test.ts | 37 ++++++++++++++++++++++++++++++------- tests/javascript.test.ts | 37 ++++++++++++++++++++++++++++++------- tests/nodecli.test.ts | 37 ++++++++++++++++++++++++++++++------- tests/python.test.ts | 19 ++++++++++++------- tests/simpl.test.ts | 37 ++++++++++++++++++++++++++++++------- 6 files changed, 162 insertions(+), 42 deletions(-) diff --git a/tests/c.test.ts b/tests/c.test.ts index 42cff2f..8cc4409 100644 --- a/tests/c.test.ts +++ b/tests/c.test.ts @@ -128,7 +128,7 @@ describe("generator-norgate-av:c", () => { assert.equal(result.generator.options.name, name); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -155,6 +155,7 @@ describe("generator-norgate-av:c", () => { name: id, displayName: name, description, + author, engines: { node: `>=${engine}`, }, @@ -184,7 +185,7 @@ describe("generator-norgate-av:c", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -226,6 +227,11 @@ describe("generator-norgate-av:c", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -312,7 +318,7 @@ describe("generator-norgate-av:c", () => { assert.equal(result.generator.options.name, destination); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -339,6 +345,7 @@ describe("generator-norgate-av:c", () => { name: id, displayName: destination, description, + author, engines: { node: `>=${engine}`, }, @@ -368,7 +375,7 @@ describe("generator-norgate-av:c", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -410,6 +417,11 @@ describe("generator-norgate-av:c", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -465,10 +477,15 @@ describe("generator-norgate-av:c", () => { result?.cleanup(); }); - it("should assign the correct default values", () => { + it("should assign the correct default values", async () => { assert.equal(result.generator.options.id, "test-project"); assert.equal(result.generator.options.description, ""); - assert.equal(result.generator.options.author, ""); + + assert.equal( + result.generator.options.author, + (await result.generator.git.name()) || "", + ); + assert.equal(result.generator.options.git, !process.env.CI); assert.equal(result.generator.options.pkg, "pnpm"); assert.equal( @@ -492,6 +509,7 @@ describe("generator-norgate-av:c", () => { name: result.generator.options.id, displayName: destination, description: result.generator.options.description, + author: result.generator.options.author, engines: { node: `>=${engine}`, }, @@ -524,7 +542,7 @@ describe("generator-norgate-av:c", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, ); }); @@ -575,6 +593,11 @@ describe("generator-norgate-av:c", () => { ".all-contributorsrc", `"projectName": "${result.generator.options.id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${result.generator.options.author}"`, + ); }); it("should create the correct husky git hooks", () => { diff --git a/tests/html.test.ts b/tests/html.test.ts index 8451323..9370e2e 100644 --- a/tests/html.test.ts +++ b/tests/html.test.ts @@ -135,7 +135,7 @@ describe("generator-norgate-av:html", () => { assert.equal(result.generator.options.name, name); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -162,6 +162,7 @@ describe("generator-norgate-av:html", () => { name: id, displayName: name, description, + author, engines: { node: `>=${engine}`, }, @@ -195,7 +196,7 @@ describe("generator-norgate-av:html", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -237,6 +238,11 @@ describe("generator-norgate-av:html", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -323,7 +329,7 @@ describe("generator-norgate-av:html", () => { assert.equal(result.generator.options.name, destination); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -350,6 +356,7 @@ describe("generator-norgate-av:html", () => { name: id, displayName: destination, description, + author, engines: { node: `>=${engine}`, }, @@ -379,7 +386,7 @@ describe("generator-norgate-av:html", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -421,6 +428,11 @@ describe("generator-norgate-av:html", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -481,10 +493,15 @@ describe("generator-norgate-av:html", () => { result?.cleanup(); }); - it("should assign the correct default values", () => { + it("should assign the correct default values", async () => { assert.equal(result.generator.options.id, "test-project"); assert.equal(result.generator.options.description, ""); - assert.equal(result.generator.options.author, ""); + + assert.equal( + result.generator.options.author, + (await result.generator.git.name()) || "", + ); + assert.equal(result.generator.options.git, !process.env.CI); assert.equal(result.generator.options.pkg, "pnpm"); assert.equal( @@ -508,6 +525,7 @@ describe("generator-norgate-av:html", () => { name: result.generator.options.id, displayName: destination, description: result.generator.options.description, + author: result.generator.options.author, engines: { node: `>=${engine}`, }, @@ -540,7 +558,7 @@ describe("generator-norgate-av:html", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, ); }); @@ -591,6 +609,11 @@ describe("generator-norgate-av:html", () => { ".all-contributorsrc", `"projectName": "${result.generator.options.id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${result.generator.options.author}"`, + ); }); it("should create the correct husky git hooks", () => { diff --git a/tests/javascript.test.ts b/tests/javascript.test.ts index 8b3c205..734a60e 100644 --- a/tests/javascript.test.ts +++ b/tests/javascript.test.ts @@ -140,7 +140,7 @@ describe("generator-norgate-av:javascript", () => { assert.equal(result.generator.options.name, name); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -167,6 +167,7 @@ describe("generator-norgate-av:javascript", () => { name: id, displayName: name, description, + author, engines: { node: `>=${engine}`, }, @@ -200,7 +201,7 @@ describe("generator-norgate-av:javascript", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -242,6 +243,11 @@ describe("generator-norgate-av:javascript", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -328,7 +334,7 @@ describe("generator-norgate-av:javascript", () => { assert.equal(result.generator.options.name, destination); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -355,6 +361,7 @@ describe("generator-norgate-av:javascript", () => { name: id, displayName: destination, description, + author, engines: { node: `>=${engine}`, }, @@ -388,7 +395,7 @@ describe("generator-norgate-av:javascript", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -430,6 +437,11 @@ describe("generator-norgate-av:javascript", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -490,10 +502,15 @@ describe("generator-norgate-av:javascript", () => { result?.cleanup(); }); - it("should assign the correct default values", () => { + it("should assign the correct default values", async () => { assert.equal(result.generator.options.id, "test-project"); assert.equal(result.generator.options.description, ""); - assert.equal(result.generator.options.author, ""); + + assert.equal( + result.generator.options.author, + (await result.generator.git.name()) || "", + ); + assert.equal(result.generator.options.git, !process.env.CI); assert.equal(result.generator.options.pkg, "pnpm"); assert.equal( @@ -517,6 +534,7 @@ describe("generator-norgate-av:javascript", () => { name: result.generator.options.id, displayName: destination, description: result.generator.options.description, + author: result.generator.options.author, engines: { node: `>=${engine}`, }, @@ -553,7 +571,7 @@ describe("generator-norgate-av:javascript", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, ); }); @@ -604,6 +622,11 @@ describe("generator-norgate-av:javascript", () => { ".all-contributorsrc", `"projectName": "${result.generator.options.id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${result.generator.options.author}"`, + ); }); it("should create the correct husky git hooks", () => { diff --git a/tests/nodecli.test.ts b/tests/nodecli.test.ts index 115fb55..2e0c1d7 100644 --- a/tests/nodecli.test.ts +++ b/tests/nodecli.test.ts @@ -160,7 +160,7 @@ describe("generator-norgate-av:nodecli", () => { assert.equal(result.generator.options.name, name); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -187,6 +187,7 @@ describe("generator-norgate-av:nodecli", () => { name: id, displayName: name, description, + author, bin: { [id]: "src/app.js", }, @@ -223,7 +224,7 @@ describe("generator-norgate-av:nodecli", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -265,6 +266,11 @@ describe("generator-norgate-av:nodecli", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -351,7 +357,7 @@ describe("generator-norgate-av:nodecli", () => { assert.equal(result.generator.options.name, destination); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -378,6 +384,7 @@ describe("generator-norgate-av:nodecli", () => { name: id, displayName: destination, description, + author, bin: { [id]: "src/app.js", }, @@ -414,7 +421,7 @@ describe("generator-norgate-av:nodecli", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -456,6 +463,11 @@ describe("generator-norgate-av:nodecli", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -516,10 +528,15 @@ describe("generator-norgate-av:nodecli", () => { result?.cleanup(); }); - it("should assign the correct default values", () => { + it("should assign the correct default values", async () => { assert.equal(result.generator.options.id, "test-project"); assert.equal(result.generator.options.description, ""); - assert.equal(result.generator.options.author, ""); + + assert.equal( + result.generator.options.author, + (await result.generator.git.name()) || "", + ); + assert.equal(result.generator.options.git, !process.env.CI); assert.equal(result.generator.options.pkg, "pnpm"); assert.equal( @@ -543,6 +560,7 @@ describe("generator-norgate-av:nodecli", () => { name: result.generator.options.id, displayName: destination, description: result.generator.options.description, + author: result.generator.options.author, bin: { [result.generator.options.id!]: "src/app.js", }, @@ -582,7 +600,7 @@ describe("generator-norgate-av:nodecli", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, ); }); @@ -633,6 +651,11 @@ describe("generator-norgate-av:nodecli", () => { ".all-contributorsrc", `"projectName": "${result.generator.options.id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${result.generator.options.author}"`, + ); }); it("should create the correct husky git hooks", () => { diff --git a/tests/python.test.ts b/tests/python.test.ts index 7f5bea0..96e7c1a 100644 --- a/tests/python.test.ts +++ b/tests/python.test.ts @@ -74,7 +74,7 @@ describe("generator-norgate-av:python", () => { assert.equal(result.generator.options.name, name); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -101,7 +101,7 @@ describe("generator-norgate-av:python", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -184,7 +184,7 @@ describe("generator-norgate-av:python", () => { assert.equal(result.generator.options.name, destination); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -211,7 +211,7 @@ describe("generator-norgate-av:python", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -276,10 +276,15 @@ describe("generator-norgate-av:python", () => { result?.cleanup(); }); - it("should assign the correct default values", () => { + it("should assign the correct default values", async () => { assert.equal(result.generator.options.id, "test-project"); assert.equal(result.generator.options.description, ""); - assert.equal(result.generator.options.author, ""); + + assert.equal( + result.generator.options.author, + (await result.generator.git.name()) || "", + ); + assert.equal(result.generator.options.git, !process.env.CI); }); @@ -306,7 +311,7 @@ describe("generator-norgate-av:python", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, ); }); diff --git a/tests/simpl.test.ts b/tests/simpl.test.ts index 61573e4..be13ffc 100644 --- a/tests/simpl.test.ts +++ b/tests/simpl.test.ts @@ -130,7 +130,7 @@ describe("generator-norgate-av:simpl", () => { assert.equal(result.generator.options.name, name); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -157,6 +157,7 @@ describe("generator-norgate-av:simpl", () => { name: id, displayName: name, description, + author, engines: { node: `>=${engine}`, }, @@ -186,7 +187,7 @@ describe("generator-norgate-av:simpl", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -228,6 +229,11 @@ describe("generator-norgate-av:simpl", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -314,7 +320,7 @@ describe("generator-norgate-av:simpl", () => { assert.equal(result.generator.options.name, destination); assert.equal(result.generator.options.id, id); assert.equal(result.generator.options.description, description); - // assert.equal(result.generator.options.author, author); + assert.equal(result.generator.options.author, author); assert.equal( result.generator.options.git, process.env.CI ? false : git, @@ -341,6 +347,7 @@ describe("generator-norgate-av:simpl", () => { name: id, displayName: destination, description, + author, engines: { node: `>=${engine}`, }, @@ -370,7 +377,7 @@ describe("generator-norgate-av:simpl", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${author}`, ); }); @@ -412,6 +419,11 @@ describe("generator-norgate-av:simpl", () => { ".all-contributorsrc", `"projectName": "${id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${author}"`, + ); }); it("should create the correct husky git hooks", () => { @@ -467,10 +479,15 @@ describe("generator-norgate-av:simpl", () => { result?.cleanup(); }); - it("should assign the correct default values", () => { + it("should assign the correct default values", async () => { assert.equal(result.generator.options.id, "test-project"); assert.equal(result.generator.options.description, ""); - assert.equal(result.generator.options.author, ""); + + assert.equal( + result.generator.options.author, + (await result.generator.git.name()) || "", + ); + assert.equal(result.generator.options.git, !process.env.CI); assert.equal(result.generator.options.pkg, "pnpm"); assert.equal( @@ -494,6 +511,7 @@ describe("generator-norgate-av:simpl", () => { name: result.generator.options.id, displayName: destination, description: result.generator.options.description, + author: result.generator.options.author, engines: { node: `>=${engine}`, }, @@ -526,7 +544,7 @@ describe("generator-norgate-av:simpl", () => { assert.fileContent("LICENSE", "The MIT License (MIT)"); assert.fileContent( "LICENSE", - `Copyright (c) ${new Date().getFullYear()}`, + `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, ); }); @@ -577,6 +595,11 @@ describe("generator-norgate-av:simpl", () => { ".all-contributorsrc", `"projectName": "${result.generator.options.id}"`, ); + + assert.fileContent( + ".all-contributorsrc", + `"projectOwner": "${result.generator.options.author}"`, + ); }); it("should create the correct husky git hooks", () => { From 7cdede376a57cc36b9c2c3a199b72f3fae83a644 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:00:21 +0000 Subject: [PATCH 09/18] test: utilize helper assertions in remaining tests --- tests/c.test.ts | 289 +++++++++---------------------------- tests/helpers.ts | 24 ++++ tests/html.test.ts | 300 +++++++++++---------------------------- tests/javascript.test.ts | 289 +++++++++---------------------------- tests/nodecli.test.ts | 289 +++++++++---------------------------- tests/python.test.ts | 146 +++++++------------ tests/simpl.test.ts | 289 +++++++++---------------------------- tests/typescript.test.ts | 113 +++------------ 8 files changed, 457 insertions(+), 1282 deletions(-) diff --git a/tests/c.test.ts b/tests/c.test.ts index 8cc4409..b2b8362 100644 --- a/tests/c.test.ts +++ b/tests/c.test.ts @@ -8,7 +8,16 @@ import { NodeEnvironment } from "../src/environments/index.js"; import { ConfigHelper } from "../src/helpers/index.js"; import config from "../config/default.json"; import { UnresolvedConfig, NodePackageManager } from "../src/@types/index.js"; -import { getNodeDependencyObject } from "./helpers.js"; +import { + assertAllContributorsRc, + assertChangeLog, + assertContributing, + assertHuskyGitHooks, + assertLicense, + assertOptionValues, + assertReadMe, + getNodeDependencyObject, +} from "./helpers.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const generator = path.resolve(__dirname, "../dist/generators/app"); @@ -124,22 +133,15 @@ describe("generator-norgate-av:c", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.name, name); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${name}' and CD into it`, () => { @@ -170,11 +172,7 @@ describe("generator-norgate-av:c", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -182,64 +180,26 @@ describe("generator-norgate-av:c", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -313,23 +273,15 @@ describe("generator-norgate-av:c", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.destination, destination); - assert.equal(result.generator.options.name, destination); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name: destination, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -360,11 +312,7 @@ describe("generator-norgate-av:c", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -372,64 +320,26 @@ describe("generator-norgate-av:c", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -478,22 +388,15 @@ describe("generator-norgate-av:c", () => { }); it("should assign the correct default values", async () => { - assert.equal(result.generator.options.id, "test-project"); - assert.equal(result.generator.options.description, ""); - - assert.equal( - result.generator.options.author, - (await result.generator.git.name()) || "", - ); - - assert.equal(result.generator.options.git, !process.env.CI); - assert.equal(result.generator.options.pkg, "pnpm"); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - "pnpm", - ); + assertOptionValues(result, { + type, + name: destination, + id: "test-project", + description: "", + author: (await result.generator.git.name()) || "", + git: !process.env.CI, + pkg: "pnpm", + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -524,14 +427,7 @@ describe("generator-norgate-av:c", () => { }); it("should create the correct README.md", () => { - assert.fileContent( - "README.md", - `# ${result.generator.options.id}`, - ); - assert.fileContent( - "README.md", - `This is the README for your project "${result.generator.options.id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id: result.generator.options.id }); }); it("should create the correct .nvmrc", () => { @@ -539,76 +435,33 @@ describe("generator-norgate-av:c", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, - ); + assertLicense("LICENSE", { + author: result.generator.options.author, + }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}/issues/new/choose`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}.git`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `cd ${result.generator.options.id}`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} install`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${result.generator.options.pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${result.generator.options.pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${result.generator.options.pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id: result.generator.options.id, + pkg: result.generator.options.pkg, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${result.generator.options.id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { + id: result.generator.options.id, + }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${result.generator.options.id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${result.generator.options.author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { + id: result.generator.options.id, + author: result.generator.options.author, + }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${result.generator.options.pkg} commitlint --edit $1`, - ); - assert.fileContent( - ".husky/pre-commit", - `${result.generator.options.pkg} lint-staged`, - ); + assertHuskyGitHooks({ pkg: result.generator.options.pkg }); }); it.skipIf(process.env.CI)( diff --git a/tests/helpers.ts b/tests/helpers.ts index 9409141..06edc41 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -80,3 +80,27 @@ export function assertOptionValues( pkg, ); } + +export function assertHuskyGitHooks({ pkg }: AssertionOptions): void { + assert.fileContent(".husky/commit-msg", `${pkg} commitlint --edit $1`); + assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); +} + +export function assertContributing( + file: string, + { id, pkg }: AssertionOptions, +): void { + assert.fileContent(file, `/${id}/issues/new/choose`); + assert.fileContent(file, `/${id}.git`); + assert.fileContent(file, `cd ${id}`); + + if (pkg === undefined) { + return; + } + + assert.fileContent(file, `${pkg} install`); + assert.fileContent(file, `If in doubt, you can use the \`${pkg} commit\``); + assert.fileContent(file, `Be sure to run \`${pkg} test\``); + assert.fileContent(file, `Run the \`${pkg} contrib:add\``); + assert.fileContent(file, `${pkg} contrib:add `); +} diff --git a/tests/html.test.ts b/tests/html.test.ts index 9370e2e..ed67d49 100644 --- a/tests/html.test.ts +++ b/tests/html.test.ts @@ -8,7 +8,16 @@ import { NodeEnvironment } from "../src/environments/index.js"; import { ConfigHelper } from "../src/helpers/index.js"; import config from "../config/default.json"; import { UnresolvedConfig, NodePackageManager } from "../src/@types/index.js"; -import { getNodeDependencyObject } from "./helpers.js"; +import { + assertAllContributorsRc, + assertChangeLog, + assertContributing, + assertHuskyGitHooks, + assertLicense, + assertOptionValues, + assertReadMe, + getNodeDependencyObject, +} from "./helpers.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const generator = path.resolve(__dirname, "../dist/generators/app"); @@ -131,22 +140,15 @@ describe("generator-norgate-av:html", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.name, name); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${name}' and CD into it`, () => { @@ -181,11 +183,7 @@ describe("generator-norgate-av:html", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -193,64 +191,26 @@ describe("generator-norgate-av:html", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -324,23 +284,15 @@ describe("generator-norgate-av:html", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.destination, destination); - assert.equal(result.generator.options.name, destination); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name: destination, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -370,12 +322,12 @@ describe("generator-norgate-av:html", () => { }); }); + it("should create the correct index.html", () => { + assert.fileContent("public/index.html", `${id}`); + }); + it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -383,64 +335,26 @@ describe("generator-norgate-av:html", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -494,22 +408,15 @@ describe("generator-norgate-av:html", () => { }); it("should assign the correct default values", async () => { - assert.equal(result.generator.options.id, "test-project"); - assert.equal(result.generator.options.description, ""); - - assert.equal( - result.generator.options.author, - (await result.generator.git.name()) || "", - ); - - assert.equal(result.generator.options.git, !process.env.CI); - assert.equal(result.generator.options.pkg, "pnpm"); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - "pnpm", - ); + assertOptionValues(result, { + type, + name: destination, + id: "test-project", + description: "", + author: (await result.generator.git.name()) || "", + git: !process.env.CI, + pkg: "pnpm", + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -539,92 +446,51 @@ describe("generator-norgate-av:html", () => { }); }); - it("should create the correct README.md", () => { - assert.fileContent( - "README.md", - `# ${result.generator.options.id}`, - ); + it("should create the correct index.html", () => { assert.fileContent( - "README.md", - `This is the README for your project "${result.generator.options.id}". After writing up a brief description, we recommend including the following sections.`, + "public/index.html", + `${result.generator.options.id}`, ); }); + it("should create the correct README.md", () => { + assertReadMe("README.md", { id: result.generator.options.id }); + }); + it("should create the correct .nvmrc", () => { assert.fileContent(".nvmrc", node.getNodeEngine()); }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, - ); + assertLicense("LICENSE", { + author: result.generator.options.author, + }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}/issues/new/choose`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}.git`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `cd ${result.generator.options.id}`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} install`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${result.generator.options.pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${result.generator.options.pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${result.generator.options.pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id: result.generator.options.id, + pkg: result.generator.options.pkg, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${result.generator.options.id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { + id: result.generator.options.id, + }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${result.generator.options.id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${result.generator.options.author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { + id: result.generator.options.id, + author: result.generator.options.author, + }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${result.generator.options.pkg} commitlint --edit $1`, - ); - assert.fileContent( - ".husky/pre-commit", - `${result.generator.options.pkg} lint-staged`, - ); + assertHuskyGitHooks({ + pkg: result.generator.options.pkg, + }); }); it.skipIf(process.env.CI)( diff --git a/tests/javascript.test.ts b/tests/javascript.test.ts index 734a60e..2e049a6 100644 --- a/tests/javascript.test.ts +++ b/tests/javascript.test.ts @@ -8,7 +8,16 @@ import { NodeEnvironment } from "../src/environments/index.js"; import { ConfigHelper } from "../src/helpers/index.js"; import config from "../config/default.json"; import { UnresolvedConfig, NodePackageManager } from "../src/@types/index.js"; -import { getNodeDependencyObject } from "./helpers.js"; +import { + assertAllContributorsRc, + assertChangeLog, + assertContributing, + assertHuskyGitHooks, + assertLicense, + assertOptionValues, + assertReadMe, + getNodeDependencyObject, +} from "./helpers.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const generator = path.resolve(__dirname, "../dist/generators/app"); @@ -136,22 +145,15 @@ describe("generator-norgate-av:javascript", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.name, name); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${name}' and CD into it`, () => { @@ -186,11 +188,7 @@ describe("generator-norgate-av:javascript", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -198,64 +196,26 @@ describe("generator-norgate-av:javascript", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -329,23 +289,15 @@ describe("generator-norgate-av:javascript", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.destination, destination); - assert.equal(result.generator.options.name, destination); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + id, + name: destination, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -380,11 +332,7 @@ describe("generator-norgate-av:javascript", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -392,64 +340,26 @@ describe("generator-norgate-av:javascript", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -503,22 +413,15 @@ describe("generator-norgate-av:javascript", () => { }); it("should assign the correct default values", async () => { - assert.equal(result.generator.options.id, "test-project"); - assert.equal(result.generator.options.description, ""); - - assert.equal( - result.generator.options.author, - (await result.generator.git.name()) || "", - ); - - assert.equal(result.generator.options.git, !process.env.CI); - assert.equal(result.generator.options.pkg, "pnpm"); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - "pnpm", - ); + assertOptionValues(result, { + type, + name: destination, + id: "test-project", + description: "", + author: (await result.generator.git.name()) || "", + git: !process.env.CI, + pkg: "pnpm", + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -553,14 +456,7 @@ describe("generator-norgate-av:javascript", () => { }); it("should create the correct README.md", () => { - assert.fileContent( - "README.md", - `# ${result.generator.options.id}`, - ); - assert.fileContent( - "README.md", - `This is the README for your project "${result.generator.options.id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id: result.generator.options.id }); }); it("should create the correct .nvmrc", () => { @@ -568,76 +464,33 @@ describe("generator-norgate-av:javascript", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, - ); + assertLicense("LICENSE", { + author: result.generator.options.author, + }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}/issues/new/choose`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}.git`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `cd ${result.generator.options.id}`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} install`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${result.generator.options.pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${result.generator.options.pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${result.generator.options.pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id: result.generator.options.id, + pkg: result.generator.options.pkg, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${result.generator.options.id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { + id: result.generator.options.id, + }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${result.generator.options.id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${result.generator.options.author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { + id: result.generator.options.id, + author: result.generator.options.author, + }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${result.generator.options.pkg} commitlint --edit $1`, - ); - assert.fileContent( - ".husky/pre-commit", - `${result.generator.options.pkg} lint-staged`, - ); + assertHuskyGitHooks({ pkg: result.generator.options.pkg }); }); it.skipIf(process.env.CI)( diff --git a/tests/nodecli.test.ts b/tests/nodecli.test.ts index 2e0c1d7..7c747e0 100644 --- a/tests/nodecli.test.ts +++ b/tests/nodecli.test.ts @@ -8,7 +8,16 @@ import { NodeEnvironment } from "../src/environments/index.js"; import { ConfigHelper } from "../src/helpers/index.js"; import config from "../config/default.json"; import { UnresolvedConfig, NodePackageManager } from "../src/@types/index.js"; -import { getNodeDependencyObject } from "./helpers.js"; +import { + assertAllContributorsRc, + assertChangeLog, + assertContributing, + assertHuskyGitHooks, + assertLicense, + assertOptionValues, + assertReadMe, + getNodeDependencyObject, +} from "./helpers.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const generator = path.resolve(__dirname, "../dist/generators/app"); @@ -156,22 +165,15 @@ describe("generator-norgate-av:nodecli", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.name, name); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${name}' and CD into it`, () => { @@ -209,11 +211,7 @@ describe("generator-norgate-av:nodecli", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -221,64 +219,26 @@ describe("generator-norgate-av:nodecli", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -352,23 +312,15 @@ describe("generator-norgate-av:nodecli", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.destination, destination); - assert.equal(result.generator.options.name, destination); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name: destination, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -406,11 +358,7 @@ describe("generator-norgate-av:nodecli", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -418,64 +366,26 @@ describe("generator-norgate-av:nodecli", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -529,22 +439,15 @@ describe("generator-norgate-av:nodecli", () => { }); it("should assign the correct default values", async () => { - assert.equal(result.generator.options.id, "test-project"); - assert.equal(result.generator.options.description, ""); - - assert.equal( - result.generator.options.author, - (await result.generator.git.name()) || "", - ); - - assert.equal(result.generator.options.git, !process.env.CI); - assert.equal(result.generator.options.pkg, "pnpm"); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - "pnpm", - ); + assertOptionValues(result, { + type, + name: destination, + id: "test-project", + description: "", + author: (await result.generator.git.name()) || "", + git: !process.env.CI, + pkg: "pnpm", + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -582,14 +485,7 @@ describe("generator-norgate-av:nodecli", () => { }); it("should create the correct README.md", () => { - assert.fileContent( - "README.md", - `# ${result.generator.options.id}`, - ); - assert.fileContent( - "README.md", - `This is the README for your project "${result.generator.options.id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id: result.generator.options.id }); }); it("should create the correct .nvmrc", () => { @@ -597,76 +493,33 @@ describe("generator-norgate-av:nodecli", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, - ); + assertLicense("LICENSE", { + author: result.generator.options.author, + }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}/issues/new/choose`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}.git`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `cd ${result.generator.options.id}`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} install`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${result.generator.options.pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${result.generator.options.pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${result.generator.options.pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id: result.generator.options.id, + pkg: result.generator.options.pkg, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${result.generator.options.id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { + id: result.generator.options.id, + }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${result.generator.options.id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${result.generator.options.author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { + id: result.generator.options.id, + author: result.generator.options.author, + }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${result.generator.options.pkg} commitlint --edit $1`, - ); - assert.fileContent( - ".husky/pre-commit", - `${result.generator.options.pkg} lint-staged`, - ); + assertHuskyGitHooks({ pkg: result.generator.options.pkg }); }); it.skipIf(process.env.CI)( diff --git a/tests/python.test.ts b/tests/python.test.ts index 96e7c1a..f1d4dfb 100644 --- a/tests/python.test.ts +++ b/tests/python.test.ts @@ -4,6 +4,13 @@ import assert from "yeoman-assert"; import helpers, { RunResult } from "yeoman-test"; import { describe, beforeAll, afterAll, expect, it } from "vitest"; import AppGenerator from "../src/app.js"; +import { + assertChangeLog, + assertContributing, + assertLicense, + assertOptionValues, + assertReadMe, +} from "./helpers.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const generator = path.resolve(__dirname, "../dist/generators/app"); @@ -70,15 +77,14 @@ describe("generator-norgate-av:python", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.name, name); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); + assertOptionValues(result, { + type, + name, + id, + description, + author, + git, + }); }); it(`should create a directory named '${name}' and CD into it`, () => { @@ -90,35 +96,19 @@ describe("generator-norgate-av:python", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); + assertContributing("CONTRIBUTING.md", { id }); }); it.skipIf(process.env.CI)( @@ -179,16 +169,14 @@ describe("generator-norgate-av:python", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.destination, destination); - assert.equal(result.generator.options.name, destination); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); + assertOptionValues(result, { + type, + id, + name: destination, + description, + author, + git, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -200,35 +188,19 @@ describe("generator-norgate-av:python", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); + assertContributing("CONTRIBUTING.md", { id }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it.skipIf(process.env.CI)( @@ -277,15 +249,14 @@ describe("generator-norgate-av:python", () => { }); it("should assign the correct default values", async () => { - assert.equal(result.generator.options.id, "test-project"); - assert.equal(result.generator.options.description, ""); - - assert.equal( - result.generator.options.author, - (await result.generator.git.name()) || "", - ); - - assert.equal(result.generator.options.git, !process.env.CI); + assertOptionValues(result, { + type, + id: "test-project", + name: destination, + description: "", + author: (await result.generator.git.name()) || "", + git: !process.env.CI, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -297,44 +268,25 @@ describe("generator-norgate-av:python", () => { }); it("should create the correct README.md", () => { - assert.fileContent( - "README.md", - `# ${result.generator.options.id}`, - ); - assert.fileContent( - "README.md", - `This is the README for your project "${result.generator.options.id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id: result.generator.options.id }); }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, - ); + assertLicense("LICENSE", { + author: result.generator.options.author, + }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}/issues/new/choose`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}.git`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `cd ${result.generator.options.id}`, - ); + assertContributing("CONTRIBUTING.md", { + id: result.generator.options.id, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${result.generator.options.id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { + id: result.generator.options.id, + }); }); it.skipIf(process.env.CI)( diff --git a/tests/simpl.test.ts b/tests/simpl.test.ts index be13ffc..c747900 100644 --- a/tests/simpl.test.ts +++ b/tests/simpl.test.ts @@ -8,7 +8,16 @@ import { NodeEnvironment } from "../src/environments/index.js"; import { ConfigHelper } from "../src/helpers/index.js"; import config from "../config/default.json"; import { UnresolvedConfig, NodePackageManager } from "../src/@types/index.js"; -import { getNodeDependencyObject } from "./helpers.js"; +import { + assertAllContributorsRc, + assertChangeLog, + assertContributing, + assertHuskyGitHooks, + assertLicense, + assertOptionValues, + assertReadMe, + getNodeDependencyObject, +} from "./helpers.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const generator = path.resolve(__dirname, "../dist/generators/app"); @@ -126,22 +135,15 @@ describe("generator-norgate-av:simpl", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.name, name); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${name}' and CD into it`, () => { @@ -172,11 +174,7 @@ describe("generator-norgate-av:simpl", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -184,64 +182,26 @@ describe("generator-norgate-av:simpl", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -315,23 +275,15 @@ describe("generator-norgate-av:simpl", () => { }); it("should assign the correct values", () => { - assert.equal(result.generator.options.type, type); - assert.equal(result.generator.options.destination, destination); - assert.equal(result.generator.options.name, destination); - assert.equal(result.generator.options.id, id); - assert.equal(result.generator.options.description, description); - assert.equal(result.generator.options.author, author); - assert.equal( - result.generator.options.git, - process.env.CI ? false : git, - ); - assert.equal(result.generator.options.pkg, pkg); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - pkg, - ); + assertOptionValues(result, { + type, + name: destination, + id, + description, + author, + git, + pkg: pkg as NodePackageManager, + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -362,11 +314,7 @@ describe("generator-norgate-av:simpl", () => { }); it("should create the correct README.md", () => { - assert.fileContent("README.md", `# ${id}`); - assert.fileContent( - "README.md", - `This is the README for your project "${id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id }); }); it("should create the correct .nvmrc", () => { @@ -374,64 +322,26 @@ describe("generator-norgate-av:simpl", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${author}`, - ); + assertLicense("LICENSE", { author }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { id }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { id, author }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -480,22 +390,15 @@ describe("generator-norgate-av:simpl", () => { }); it("should assign the correct default values", async () => { - assert.equal(result.generator.options.id, "test-project"); - assert.equal(result.generator.options.description, ""); - - assert.equal( - result.generator.options.author, - (await result.generator.git.name()) || "", - ); - - assert.equal(result.generator.options.git, !process.env.CI); - assert.equal(result.generator.options.pkg, "pnpm"); - assert.equal( - // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - result.generator.env.options.nodePackageManager, - "pnpm", - ); + assertOptionValues(result, { + type, + name: destination, + id: "test-project", + description: "", + author: (await result.generator.git.name()) || "", + git: !process.env.CI, + pkg: "pnpm", + }); }); it(`should create a directory named '${destination}' and CD into it`, () => { @@ -526,14 +429,7 @@ describe("generator-norgate-av:simpl", () => { }); it("should create the correct README.md", () => { - assert.fileContent( - "README.md", - `# ${result.generator.options.id}`, - ); - assert.fileContent( - "README.md", - `This is the README for your project "${result.generator.options.id}". After writing up a brief description, we recommend including the following sections.`, - ); + assertReadMe("README.md", { id: result.generator.options.id }); }); it("should create the correct .nvmrc", () => { @@ -541,76 +437,33 @@ describe("generator-norgate-av:simpl", () => { }); it("should create the correct LICENSE", () => { - assert.fileContent("LICENSE", "The MIT License (MIT)"); - assert.fileContent( - "LICENSE", - `Copyright (c) ${new Date().getFullYear()} ${result.generator.options.author}`, - ); + assertLicense("LICENSE", { + author: result.generator.options.author, + }); }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}/issues/new/choose`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}.git`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `cd ${result.generator.options.id}`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} install`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${result.generator.options.pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${result.generator.options.pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${result.generator.options.pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id: result.generator.options.id, + pkg: result.generator.options.pkg, + }); }); it("should create the correct CHANGELOG.md", () => { - assert.fileContent( - "CHANGELOG.md", - `All notable changes to the "${result.generator.options.id}" project will be documented in this file.`, - ); + assertChangeLog("CHANGELOG.md", { + id: result.generator.options.id, + }); }); it("should create the correct .all-contributorsrc", () => { - assert.fileContent( - ".all-contributorsrc", - `"projectName": "${result.generator.options.id}"`, - ); - - assert.fileContent( - ".all-contributorsrc", - `"projectOwner": "${result.generator.options.author}"`, - ); + assertAllContributorsRc(".all-contributorsrc", { + id: result.generator.options.id, + pkg: result.generator.options.pkg, + }); }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${result.generator.options.pkg} commitlint --edit $1`, - ); - assert.fileContent( - ".husky/pre-commit", - `${result.generator.options.pkg} lint-staged`, - ); + assertHuskyGitHooks({ pkg: result.generator.options.pkg }); }); it.skipIf(process.env.CI)( diff --git a/tests/typescript.test.ts b/tests/typescript.test.ts index 6fa96cb..a046d90 100644 --- a/tests/typescript.test.ts +++ b/tests/typescript.test.ts @@ -11,6 +11,8 @@ import { UnresolvedConfig, NodePackageManager } from "../src/@types/index.js"; import { assertAllContributorsRc, assertChangeLog, + assertContributing, + assertHuskyGitHooks, assertLicense, assertOptionValues, assertReadMe, @@ -213,29 +215,10 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { @@ -247,11 +230,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -384,29 +363,10 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${id}/issues/new/choose`, - ); - assert.fileContent("CONTRIBUTING.md", `/${id}.git`); - assert.fileContent("CONTRIBUTING.md", `cd ${id}`); - assert.fileContent("CONTRIBUTING.md", `${pkg} install`); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id, + pkg: pkg as NodePackageManager, + }); }); it("should create the correct CHANGELOG.md", () => { @@ -418,11 +378,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${pkg} commitlint --edit $1`, - ); - assert.fileContent(".husky/pre-commit", `${pkg} lint-staged`); + assertHuskyGitHooks({ pkg: pkg as NodePackageManager }); }); it.skipIf(process.env.CI)( @@ -537,38 +493,10 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct CONTRIBUTING.md", () => { - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}/issues/new/choose`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `/${result.generator.options.id}.git`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `cd ${result.generator.options.id}`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} install`, - ); - assert.fileContent( - "CONTRIBUTING.md", - `If in doubt, you can use the \`${result.generator.options.pkg} commit\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Be sure to run \`${result.generator.options.pkg} test\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `Run the \`${result.generator.options.pkg} contrib:add\``, - ); - assert.fileContent( - "CONTRIBUTING.md", - `${result.generator.options.pkg} contrib:add `, - ); + assertContributing("CONTRIBUTING.md", { + id: result.generator.options.id, + pkg: result.generator.options.pkg, + }); }); it("should create the correct CHANGELOG.md", () => { @@ -585,14 +513,7 @@ describe("generator-norgate-av:typescript", () => { }); it("should create the correct husky git hooks", () => { - assert.fileContent( - ".husky/commit-msg", - `${result.generator.options.pkg} commitlint --edit $1`, - ); - assert.fileContent( - ".husky/pre-commit", - `${result.generator.options.pkg} lint-staged`, - ); + assertHuskyGitHooks({ pkg: result.generator.options.pkg }); }); it.skipIf(process.env.CI)( From 212083fcb7941b9fcab4f20d72634ff66d8d1132 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:14:30 +0000 Subject: [PATCH 10/18] feat: add author template strings --- templates/c/LICENSE | 2 +- templates/c/all-contributorsrc.ejs | 2 +- templates/c/package.json.ejs | 1 + templates/html/LICENSE | 2 +- templates/html/all-contributorsrc.ejs | 2 +- templates/html/package.json.ejs | 1 + templates/javascript/LICENSE | 2 +- templates/javascript/all-contributorsrc.ejs | 2 +- templates/javascript/package.json.ejs | 1 + templates/nodecli/LICENSE | 2 +- templates/nodecli/all-contributorsrc.ejs | 2 +- templates/nodecli/package.json.ejs | 1 + templates/python/LICENSE | 2 +- templates/simpl/LICENSE | 2 +- templates/simpl/all-contributorsrc.ejs | 2 +- templates/simpl/package.json.ejs | 1 + 16 files changed, 16 insertions(+), 11 deletions(-) diff --git a/templates/c/LICENSE b/templates/c/LICENSE index 2def622..632413b 100644 --- a/templates/c/LICENSE +++ b/templates/c/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) <%- new Date().getFullYear() %> Norgate AV Services Limited +Copyright (c) <%- new Date().getFullYear() %> <%- author %> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/templates/c/all-contributorsrc.ejs b/templates/c/all-contributorsrc.ejs index 59514c6..9e82da5 100644 --- a/templates/c/all-contributorsrc.ejs +++ b/templates/c/all-contributorsrc.ejs @@ -1,6 +1,6 @@ { "projectName": <%- JSON.stringify(id) %>, - "projectOwner": "", + "projectOwner": <%- JSON.stringify(author) %>, "repoType": "github", "repoHost": "https://github.com", "files": [ diff --git a/templates/c/package.json.ejs b/templates/c/package.json.ejs index 2c277ad..dbab277 100644 --- a/templates/c/package.json.ejs +++ b/templates/c/package.json.ejs @@ -4,6 +4,7 @@ "description": <%- JSON.stringify(description) %>, "version": "0.0.0", "license": "MIT", + "author": <%- JSON.stringify(author) %>, "repository": { "type": "git", "url": "" diff --git a/templates/html/LICENSE b/templates/html/LICENSE index 2def622..632413b 100644 --- a/templates/html/LICENSE +++ b/templates/html/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) <%- new Date().getFullYear() %> Norgate AV Services Limited +Copyright (c) <%- new Date().getFullYear() %> <%- author %> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/templates/html/all-contributorsrc.ejs b/templates/html/all-contributorsrc.ejs index 59514c6..9e82da5 100644 --- a/templates/html/all-contributorsrc.ejs +++ b/templates/html/all-contributorsrc.ejs @@ -1,6 +1,6 @@ { "projectName": <%- JSON.stringify(id) %>, - "projectOwner": "", + "projectOwner": <%- JSON.stringify(author) %>, "repoType": "github", "repoHost": "https://github.com", "files": [ diff --git a/templates/html/package.json.ejs b/templates/html/package.json.ejs index 47f9355..309206b 100644 --- a/templates/html/package.json.ejs +++ b/templates/html/package.json.ejs @@ -4,6 +4,7 @@ "description": <%- JSON.stringify(description) %>, "version": "0.0.0", "license": "MIT", + "author": <%- JSON.stringify(author) %>, "main": "assets/js/app.js", "type": "module", "repository": { diff --git a/templates/javascript/LICENSE b/templates/javascript/LICENSE index 2def622..632413b 100644 --- a/templates/javascript/LICENSE +++ b/templates/javascript/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) <%- new Date().getFullYear() %> Norgate AV Services Limited +Copyright (c) <%- new Date().getFullYear() %> <%- author %> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/templates/javascript/all-contributorsrc.ejs b/templates/javascript/all-contributorsrc.ejs index 59514c6..9e82da5 100644 --- a/templates/javascript/all-contributorsrc.ejs +++ b/templates/javascript/all-contributorsrc.ejs @@ -1,6 +1,6 @@ { "projectName": <%- JSON.stringify(id) %>, - "projectOwner": "", + "projectOwner": <%- JSON.stringify(author) %>, "repoType": "github", "repoHost": "https://github.com", "files": [ diff --git a/templates/javascript/package.json.ejs b/templates/javascript/package.json.ejs index 174d91b..1b152a5 100644 --- a/templates/javascript/package.json.ejs +++ b/templates/javascript/package.json.ejs @@ -4,6 +4,7 @@ "description": <%- JSON.stringify(description) %>, "version": "0.0.0", "license": "MIT", + "author": <%- JSON.stringify(author) %>, "main": "src/app.js", "type": "module", "repository": { diff --git a/templates/nodecli/LICENSE b/templates/nodecli/LICENSE index 2def622..632413b 100644 --- a/templates/nodecli/LICENSE +++ b/templates/nodecli/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) <%- new Date().getFullYear() %> Norgate AV Services Limited +Copyright (c) <%- new Date().getFullYear() %> <%- author %> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/templates/nodecli/all-contributorsrc.ejs b/templates/nodecli/all-contributorsrc.ejs index 59514c6..9e82da5 100644 --- a/templates/nodecli/all-contributorsrc.ejs +++ b/templates/nodecli/all-contributorsrc.ejs @@ -1,6 +1,6 @@ { "projectName": <%- JSON.stringify(id) %>, - "projectOwner": "", + "projectOwner": <%- JSON.stringify(author) %>, "repoType": "github", "repoHost": "https://github.com", "files": [ diff --git a/templates/nodecli/package.json.ejs b/templates/nodecli/package.json.ejs index ac935f8..613d109 100644 --- a/templates/nodecli/package.json.ejs +++ b/templates/nodecli/package.json.ejs @@ -4,6 +4,7 @@ "description": <%- JSON.stringify(description) %>, "version": "0.0.0", "license": "MIT", + "author": <%- JSON.stringify(author) %>, "main": "src/app.js", "type": "module", "files": [ diff --git a/templates/python/LICENSE b/templates/python/LICENSE index 2def622..632413b 100644 --- a/templates/python/LICENSE +++ b/templates/python/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) <%- new Date().getFullYear() %> Norgate AV Services Limited +Copyright (c) <%- new Date().getFullYear() %> <%- author %> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/templates/simpl/LICENSE b/templates/simpl/LICENSE index 2def622..632413b 100644 --- a/templates/simpl/LICENSE +++ b/templates/simpl/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) <%- new Date().getFullYear() %> Norgate AV Services Limited +Copyright (c) <%- new Date().getFullYear() %> <%- author %> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/templates/simpl/all-contributorsrc.ejs b/templates/simpl/all-contributorsrc.ejs index 59514c6..9e82da5 100644 --- a/templates/simpl/all-contributorsrc.ejs +++ b/templates/simpl/all-contributorsrc.ejs @@ -1,6 +1,6 @@ { "projectName": <%- JSON.stringify(id) %>, - "projectOwner": "", + "projectOwner": <%- JSON.stringify(author) %>, "repoType": "github", "repoHost": "https://github.com", "files": [ diff --git a/templates/simpl/package.json.ejs b/templates/simpl/package.json.ejs index 4099858..a3981e1 100644 --- a/templates/simpl/package.json.ejs +++ b/templates/simpl/package.json.ejs @@ -4,6 +4,7 @@ "description": <%- JSON.stringify(description) %>, "version": "0.0.0", "license": "MIT", + "author": <%- JSON.stringify(author) %>, "repository": { "type": "git", "url": "" From 53501b78aee4c7757fcaabf9f346619fca14e197 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:15:23 +0000 Subject: [PATCH 11/18] feat: add author prompt to remaining generators --- src/generators/ClangGenerator.ts | 11 ++++++++--- src/generators/CrestronSimplGenerator.ts | 11 ++++++++--- src/generators/HtmlGenerator.ts | 11 ++++++++--- src/generators/JavascriptGenerator.ts | 11 ++++++++--- src/generators/NodeCliGenerator.ts | 11 ++++++++--- src/generators/PythonGenerator.ts | 11 ++++++++--- src/generators/TypescriptGenerator.ts | 1 + 7 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/generators/ClangGenerator.ts b/src/generators/ClangGenerator.ts index 5d0e3fc..40b29b8 100644 --- a/src/generators/ClangGenerator.ts +++ b/src/generators/ClangGenerator.ts @@ -10,11 +10,12 @@ import { } from "../@types/index.js"; import AppGenerator from "../app.js"; import { - ProjectName, - ProjectId, - ProjectDescription, + Author, Git, PackageManager, + ProjectDescription, + ProjectId, + ProjectName, } from "../questions/index.js"; import { ConfigHelper } from "../helpers/index.js"; import { NodeEnvironment } from "../environments/index.js"; @@ -39,6 +40,7 @@ export class ClangGenerator implements GeneratorInterface { new ProjectName(this.generator).getQuestion(), new ProjectId(this.generator).getQuestion(), new ProjectDescription(this.generator).getQuestion(), + new Author(this.generator).getQuestion(), new Git(this.generator).getQuestion(), new PackageManager(this.generator).getQuestion(), ); @@ -81,6 +83,9 @@ export class ClangGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; + this.generator.options.author = + this.generator.options.author || answers.author; + // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access this.generator.env.options.nodePackageManager = diff --git a/src/generators/CrestronSimplGenerator.ts b/src/generators/CrestronSimplGenerator.ts index 45fb3ea..617749b 100644 --- a/src/generators/CrestronSimplGenerator.ts +++ b/src/generators/CrestronSimplGenerator.ts @@ -11,11 +11,12 @@ import { } from "../@types/index.js"; import AppGenerator from "../app.js"; import { - ProjectName, - ProjectId, - ProjectDescription, + Author, Git, PackageManager, + ProjectDescription, + ProjectId, + ProjectName, } from "../questions/index.js"; import { ConfigHelper } from "../helpers/index.js"; import { NodeEnvironment } from "../environments/index.js"; @@ -40,6 +41,7 @@ export class CrestronSimplGenerator implements GeneratorInterface { new ProjectName(this.generator).getQuestion(), new ProjectId(this.generator).getQuestion(), new ProjectDescription(this.generator).getQuestion(), + new Author(this.generator).getQuestion(), new Git(this.generator).getQuestion(), new PackageManager(this.generator).getQuestion(), ); @@ -82,6 +84,9 @@ export class CrestronSimplGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; + this.generator.options.author = + this.generator.options.author || answers.author; + // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access this.generator.env.options.nodePackageManager = diff --git a/src/generators/HtmlGenerator.ts b/src/generators/HtmlGenerator.ts index 2aed6ed..fc7cd51 100644 --- a/src/generators/HtmlGenerator.ts +++ b/src/generators/HtmlGenerator.ts @@ -10,11 +10,12 @@ import { } from "../@types/index.js"; import AppGenerator from "../app.js"; import { - ProjectName, - ProjectId, - ProjectDescription, + Author, Git, PackageManager, + ProjectDescription, + ProjectId, + ProjectName, } from "../questions/index.js"; import { ConfigHelper } from "../helpers/index.js"; import { NodeEnvironment } from "../environments/index.js"; @@ -39,6 +40,7 @@ export class HtmlGenerator implements GeneratorInterface { new ProjectName(this.generator).getQuestion(), new ProjectId(this.generator).getQuestion(), new ProjectDescription(this.generator).getQuestion(), + new Author(this.generator).getQuestion(), new Git(this.generator).getQuestion(), new PackageManager(this.generator).getQuestion(), ); @@ -81,6 +83,9 @@ export class HtmlGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; + this.generator.options.author = + this.generator.options.author || answers.author; + // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access this.generator.env.options.nodePackageManager = diff --git a/src/generators/JavascriptGenerator.ts b/src/generators/JavascriptGenerator.ts index f867e25..d792c04 100644 --- a/src/generators/JavascriptGenerator.ts +++ b/src/generators/JavascriptGenerator.ts @@ -10,11 +10,12 @@ import { } from "../@types/index.js"; import AppGenerator from "../app.js"; import { - ProjectName, - ProjectId, - ProjectDescription, + Author, Git, PackageManager, + ProjectDescription, + ProjectId, + ProjectName, } from "../questions/index.js"; import { ConfigHelper } from "../helpers/index.js"; import { NodeEnvironment } from "../environments/index.js"; @@ -39,6 +40,7 @@ export class JavascriptGenerator implements GeneratorInterface { new ProjectName(this.generator).getQuestion(), new ProjectId(this.generator).getQuestion(), new ProjectDescription(this.generator).getQuestion(), + new Author(this.generator).getQuestion(), new Git(this.generator).getQuestion(), new PackageManager(this.generator).getQuestion(), ); @@ -81,6 +83,9 @@ export class JavascriptGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; + this.generator.options.author = + this.generator.options.author || answers.author; + // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access this.generator.env.options.nodePackageManager = diff --git a/src/generators/NodeCliGenerator.ts b/src/generators/NodeCliGenerator.ts index 2ee9881..4e23fbb 100644 --- a/src/generators/NodeCliGenerator.ts +++ b/src/generators/NodeCliGenerator.ts @@ -10,11 +10,12 @@ import { } from "../@types/index.js"; import AppGenerator from "../app.js"; import { - ProjectName, - ProjectId, - ProjectDescription, + Author, Git, PackageManager, + ProjectDescription, + ProjectId, + ProjectName, } from "../questions/index.js"; import { ConfigHelper } from "../helpers/index.js"; import { NodeEnvironment } from "../environments/index.js"; @@ -39,6 +40,7 @@ export class NodeCliGenerator implements GeneratorInterface { new ProjectName(this.generator).getQuestion(), new ProjectId(this.generator).getQuestion(), new ProjectDescription(this.generator).getQuestion(), + new Author(this.generator).getQuestion(), new Git(this.generator).getQuestion(), new PackageManager(this.generator).getQuestion(), ); @@ -81,6 +83,9 @@ export class NodeCliGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; + this.generator.options.author = + this.generator.options.author || answers.author; + // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access this.generator.env.options.nodePackageManager = diff --git a/src/generators/PythonGenerator.ts b/src/generators/PythonGenerator.ts index 7ff0804..8758eea 100644 --- a/src/generators/PythonGenerator.ts +++ b/src/generators/PythonGenerator.ts @@ -10,10 +10,11 @@ import { } from "../@types/index.js"; import AppGenerator from "../app.js"; import { - ProjectName, - ProjectId, - ProjectDescription, + Author, Git, + ProjectDescription, + ProjectId, + ProjectName, } from "../questions/index.js"; import { ConfigHelper } from "../helpers/index.js"; @@ -36,6 +37,7 @@ export class PythonGenerator implements GeneratorInterface { new ProjectName(this.generator).getQuestion(), new ProjectId(this.generator).getQuestion(), new ProjectDescription(this.generator).getQuestion(), + new Author(this.generator).getQuestion(), new Git(this.generator).getQuestion(), ); } @@ -76,6 +78,9 @@ export class PythonGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; + this.generator.options.author = + this.generator.options.author || answers.author; + this.generator.options.description = this.generator.options.skipPrompts ? this.generator.options.description : answers.description; diff --git a/src/generators/TypescriptGenerator.ts b/src/generators/TypescriptGenerator.ts index 36747f1..1afb74a 100644 --- a/src/generators/TypescriptGenerator.ts +++ b/src/generators/TypescriptGenerator.ts @@ -82,6 +82,7 @@ export class TypescriptGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; + this.generator.options.author = this.generator.options.author || answers.author; From 79ba274eebe1d9a2c31b423c61715c62731deffc Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:15:52 +0000 Subject: [PATCH 12/18] test(simpl): fix incorrect arg passed to assertion helper for all-contributors --- tests/simpl.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/simpl.test.ts b/tests/simpl.test.ts index c747900..42fb816 100644 --- a/tests/simpl.test.ts +++ b/tests/simpl.test.ts @@ -458,7 +458,7 @@ describe("generator-norgate-av:simpl", () => { it("should create the correct .all-contributorsrc", () => { assertAllContributorsRc(".all-contributorsrc", { id: result.generator.options.id, - pkg: result.generator.options.pkg, + author: result.generator.options.author, }); }); From 927b152e0d8ca4173c8e14a6b2a22c3e9cc48b8c Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:18:30 +0000 Subject: [PATCH 13/18] chore(deps): bump deps --- package.json | 8 +- pnpm-lock.yaml | 212 ++++++++++++++++++++++++++----------------------- 2 files changed, 116 insertions(+), 104 deletions(-) diff --git a/package.json b/package.json index 199c209..1253b18 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@commitlint/config-conventional": "^18.6.2", "@semantic-release/changelog": "^6.0.3", "@semantic-release/git": "^10.0.1", - "@types/node": "^20.11.19", + "@types/node": "^20.11.20", "@types/which": "^3.0.3", "@types/yeoman-assert": "^3.1.4", "@types/yosay": "^2.0.3", @@ -63,7 +63,7 @@ "commitizen": "^4.3.0", "cz-conventional-changelog": "3.3.0", "doctoc": "^2.2.1", - "eslint": "^8.56.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", "husky": "^9.0.11", "lint-staged": "^15.2.2", @@ -71,9 +71,9 @@ "prettier": "^3.2.5", "rimraf": "^5.0.5", "semantic-release": "^23.0.2", - "terser": "^5.27.2", + "terser": "^5.28.1", "tsup": "^8.0.2", - "type-fest": "^4.10.2", + "type-fest": "^4.10.3", "typescript": "^5.3.3", "vite-node": "^1.3.1", "vitest": "^0.34.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b4798fe..39d89c9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,7 +33,7 @@ dependencies: devDependencies: "@commitlint/cli": specifier: ^18.6.1 - version: 18.6.1(@types/node@20.11.19)(typescript@5.3.3) + version: 18.6.1(@types/node@20.11.20)(typescript@5.3.3) "@commitlint/config-conventional": specifier: ^18.6.2 version: 18.6.2 @@ -44,8 +44,8 @@ devDependencies: specifier: ^10.0.1 version: 10.0.1(semantic-release@23.0.2) "@types/node": - specifier: ^20.11.19 - version: 20.11.19 + specifier: ^20.11.20 + version: 20.11.20 "@types/which": specifier: ^3.0.3 version: 3.0.3 @@ -57,10 +57,10 @@ devDependencies: version: 2.0.3 "@typescript-eslint/eslint-plugin": specifier: ^7.0.2 - version: 7.0.2(@typescript-eslint/parser@7.0.2)(eslint@8.56.0)(typescript@5.3.3) + version: 7.0.2(@typescript-eslint/parser@7.0.2)(eslint@8.57.0)(typescript@5.3.3) "@typescript-eslint/parser": specifier: ^7.0.2 - version: 7.0.2(eslint@8.56.0)(typescript@5.3.3) + version: 7.0.2(eslint@8.57.0)(typescript@5.3.3) "@yeoman/types": specifier: ^1.1.2 version: 1.1.2(@types/inquirer@9.0.7)(mem-fs@4.0.0) @@ -69,19 +69,19 @@ devDependencies: version: 6.26.1 commitizen: specifier: ^4.3.0 - version: 4.3.0(@types/node@20.11.19)(typescript@5.3.3) + version: 4.3.0(@types/node@20.11.20)(typescript@5.3.3) cz-conventional-changelog: specifier: 3.3.0 - version: 3.3.0(@types/node@20.11.19)(typescript@5.3.3) + version: 3.3.0(@types/node@20.11.20)(typescript@5.3.3) doctoc: specifier: ^2.2.1 version: 2.2.1 eslint: - specifier: ^8.56.0 - version: 8.56.0 + specifier: ^8.57.0 + version: 8.57.0 eslint-config-prettier: specifier: ^9.1.0 - version: 9.1.0(eslint@8.56.0) + version: 9.1.0(eslint@8.57.0) husky: specifier: ^9.0.11 version: 9.0.11 @@ -101,23 +101,23 @@ devDependencies: specifier: ^23.0.2 version: 23.0.2(typescript@5.3.3) terser: - specifier: ^5.27.2 - version: 5.27.2 + specifier: ^5.28.1 + version: 5.28.1 tsup: specifier: ^8.0.2 version: 8.0.2(typescript@5.3.3) type-fest: - specifier: ^4.10.2 - version: 4.10.2 + specifier: ^4.10.3 + version: 4.10.3 typescript: specifier: ^5.3.3 version: 5.3.3 vite-node: specifier: ^1.3.1 - version: 1.3.1(@types/node@20.11.19)(terser@5.27.2) + version: 1.3.1(@types/node@20.11.20)(terser@5.28.1) vitest: specifier: ^0.34.6 - version: 0.34.6(terser@5.27.2) + version: 0.34.6(terser@5.28.1) yeoman-assert: specifier: ^3.1.1 version: 3.1.1 @@ -185,7 +185,7 @@ packages: dev: true optional: true - /@commitlint/cli@18.6.1(@types/node@20.11.19)(typescript@5.3.3): + /@commitlint/cli@18.6.1(@types/node@20.11.20)(typescript@5.3.3): resolution: { integrity: sha512-5IDE0a+lWGdkOvKH892HHAZgbAjcj1mT5QrfA/SVbLJV/BbBMGyKN0W5mhgjekPJJwEQdVNvhl9PwUacY58Usw==, @@ -195,7 +195,7 @@ packages: dependencies: "@commitlint/format": 18.6.1 "@commitlint/lint": 18.6.1 - "@commitlint/load": 18.6.1(@types/node@20.11.19)(typescript@5.3.3) + "@commitlint/load": 18.6.1(@types/node@20.11.20)(typescript@5.3.3) "@commitlint/read": 18.6.1 "@commitlint/types": 18.6.1 execa: 5.1.1 @@ -288,7 +288,7 @@ packages: "@commitlint/types": 18.6.1 dev: true - /@commitlint/load@18.6.1(@types/node@20.11.19)(typescript@5.3.3): + /@commitlint/load@18.6.1(@types/node@20.11.20)(typescript@5.3.3): resolution: { integrity: sha512-p26x8734tSXUHoAw0ERIiHyW4RaI4Bj99D8YgUlVV9SedLf8hlWAfyIFhHRIhfPngLlCe0QYOdRKYFt8gy56TA==, @@ -301,7 +301,7 @@ packages: "@commitlint/types": 18.6.1 chalk: 4.1.2 cosmiconfig: 8.3.6(typescript@5.3.3) - cosmiconfig-typescript-loader: 5.0.0(@types/node@20.11.19)(cosmiconfig@8.3.6)(typescript@5.3.3) + cosmiconfig-typescript-loader: 5.0.0(@types/node@20.11.20)(cosmiconfig@8.3.6)(typescript@5.3.3) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -677,7 +677,7 @@ packages: dev: true optional: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.56.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.57.0): resolution: { integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==, @@ -686,7 +686,7 @@ packages: peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.56.0 + eslint: 8.57.0 eslint-visitor-keys: 3.4.3 dev: true @@ -718,10 +718,10 @@ packages: - supports-color dev: true - /@eslint/js@8.56.0: + /@eslint/js@8.57.0: resolution: { - integrity: sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==, + integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==, } engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } dev: true @@ -797,6 +797,18 @@ packages: "@jridgewell/trace-mapping": 0.3.19 dev: true + /@jridgewell/gen-mapping@0.3.4: + resolution: + { + integrity: sha512-Oud2QPM5dHviZNn4y/WhhYKSXksv+1xLEIsNrAbGcFzUN3ubqWRFT5gwPchNc5NuzILOU4tPBDTZ4VwhL8Y7cw==, + } + engines: { node: ">=6.0.0" } + dependencies: + "@jridgewell/set-array": 1.1.2 + "@jridgewell/sourcemap-codec": 1.4.15 + "@jridgewell/trace-mapping": 0.3.23 + dev: true + /@jridgewell/resolve-uri@3.1.1: resolution: { @@ -827,8 +839,8 @@ packages: integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==, } dependencies: - "@jridgewell/gen-mapping": 0.3.3 - "@jridgewell/trace-mapping": 0.3.22 + "@jridgewell/gen-mapping": 0.3.4 + "@jridgewell/trace-mapping": 0.3.23 dev: true /@jridgewell/sourcemap-codec@1.4.15: @@ -848,10 +860,10 @@ packages: "@jridgewell/sourcemap-codec": 1.4.15 dev: true - /@jridgewell/trace-mapping@0.3.22: + /@jridgewell/trace-mapping@0.3.23: resolution: { - integrity: sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==, + integrity: sha512-9/4foRoUKp8s96tSkh8DlAAc5A0Ty8vLXld+l9gjKKY6ckwI8G15f0hskGmuLZu78ZlGa1vtsfOa+lnB4vG6Jg==, } dependencies: "@jridgewell/resolve-uri": 3.1.2 @@ -908,7 +920,7 @@ packages: engines: { node: ">= 8" } dependencies: "@nodelib/fs.scandir": 2.1.5 - fastq: 1.15.0 + fastq: 1.17.1 /@npmcli/agent@2.2.0: resolution: @@ -2268,24 +2280,24 @@ packages: } dev: true - /@types/node@16.18.82: + /@types/node@16.18.83: resolution: { - integrity: sha512-pcDZtkx9z8XYV+ius2P3Ot2VVrcYOfXffBQUBuiszrlUzKSmoDYqo+mV+IoL8iIiIjjtOMvNSmH1hwJ+Q+f96Q==, + integrity: sha512-TmBqzDY/GeCEmLob/31SunOQnqYE3ZiiuEh1U9o3HqE1E2cqKZQA5RQg4krEguCY3StnkXyDmCny75qyFLx/rA==, } - /@types/node@18.19.17: + /@types/node@18.19.18: resolution: { - integrity: sha512-SzyGKgwPzuWp2SHhlpXKzCX0pIOfcI4V2eF37nNBJOhwlegQ83omtVQ1XxZpDE06V/d6AQvfQdPfnw0tRC//Ng==, + integrity: sha512-80CP7B8y4PzZF0GWx15/gVWRrB5y/bIjNI84NK3cmQJu0WZwvmj2WMA5LcofQFVfLqqCSp545+U2LsrVzX36Zg==, } dependencies: undici-types: 5.26.5 - /@types/node@20.11.19: + /@types/node@20.11.20: resolution: { - integrity: sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==, + integrity: sha512-7/rR21OS+fq8IyHTgtLkDK949uzsa6n8BkziAKtPVpugIkO6D+/ooXMvzXxDnZrmtXVfjb1bKQafYpb8s89LOg==, } dependencies: undici-types: 5.26.5 @@ -2309,7 +2321,7 @@ packages: integrity: sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==, } dependencies: - "@types/node": 20.11.19 + "@types/node": 20.11.20 /@types/unist@2.0.8: resolution: @@ -2325,7 +2337,7 @@ packages: } dependencies: "@types/expect": 1.20.4 - "@types/node": 20.11.19 + "@types/node": 20.11.20 /@types/which@3.0.3: resolution: @@ -2340,7 +2352,7 @@ packages: integrity: sha512-hKiUQ1VVfJW1CFE/trneWj2oTcZ/VPGbiSB6RV/lGOGb6zpue+9jelw5fh0jMA5usEsKllK8LrzlKoPe2tghpw==, } dependencies: - "@types/node": 20.11.19 + "@types/node": 20.11.20 dev: true /@types/yosay@2.0.3: @@ -2350,7 +2362,7 @@ packages: } dev: true - /@typescript-eslint/eslint-plugin@7.0.2(@typescript-eslint/parser@7.0.2)(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/eslint-plugin@7.0.2(@typescript-eslint/parser@7.0.2)(eslint@8.57.0)(typescript@5.3.3): resolution: { integrity: sha512-/XtVZJtbaphtdrWjr+CJclaCVGPtOdBpFEnvtNf/jRV0IiEemRrL0qABex/nEt8isYcnFacm3nPHYQwL+Wb7qg==, @@ -2365,13 +2377,13 @@ packages: optional: true dependencies: "@eslint-community/regexpp": 4.10.0 - "@typescript-eslint/parser": 7.0.2(eslint@8.56.0)(typescript@5.3.3) + "@typescript-eslint/parser": 7.0.2(eslint@8.57.0)(typescript@5.3.3) "@typescript-eslint/scope-manager": 7.0.2 - "@typescript-eslint/type-utils": 7.0.2(eslint@8.56.0)(typescript@5.3.3) - "@typescript-eslint/utils": 7.0.2(eslint@8.56.0)(typescript@5.3.3) + "@typescript-eslint/type-utils": 7.0.2(eslint@8.57.0)(typescript@5.3.3) + "@typescript-eslint/utils": 7.0.2(eslint@8.57.0)(typescript@5.3.3) "@typescript-eslint/visitor-keys": 7.0.2 debug: 4.3.4 - eslint: 8.56.0 + eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.1 natural-compare: 1.4.0 @@ -2382,7 +2394,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@7.0.2(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/parser@7.0.2(eslint@8.57.0)(typescript@5.3.3): resolution: { integrity: sha512-GdwfDglCxSmU+QTS9vhz2Sop46ebNCXpPPvsByK7hu0rFGRHL+AusKQJ7SoN+LbLh6APFpQwHKmDSwN35Z700Q==, @@ -2400,7 +2412,7 @@ packages: "@typescript-eslint/typescript-estree": 7.0.2(typescript@5.3.3) "@typescript-eslint/visitor-keys": 7.0.2 debug: 4.3.4 - eslint: 8.56.0 + eslint: 8.57.0 typescript: 5.3.3 transitivePeerDependencies: - supports-color @@ -2417,7 +2429,7 @@ packages: "@typescript-eslint/visitor-keys": 7.0.2 dev: true - /@typescript-eslint/type-utils@7.0.2(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/type-utils@7.0.2(eslint@8.57.0)(typescript@5.3.3): resolution: { integrity: sha512-IKKDcFsKAYlk8Rs4wiFfEwJTQlHcdn8CLwLaxwd6zb8HNiMcQIFX9sWax2k4Cjj7l7mGS5N1zl7RCHOVwHq2VQ==, @@ -2431,9 +2443,9 @@ packages: optional: true dependencies: "@typescript-eslint/typescript-estree": 7.0.2(typescript@5.3.3) - "@typescript-eslint/utils": 7.0.2(eslint@8.56.0)(typescript@5.3.3) + "@typescript-eslint/utils": 7.0.2(eslint@8.57.0)(typescript@5.3.3) debug: 4.3.4 - eslint: 8.56.0 + eslint: 8.57.0 ts-api-utils: 1.2.1(typescript@5.3.3) typescript: 5.3.3 transitivePeerDependencies: @@ -2473,7 +2485,7 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@7.0.2(eslint@8.56.0)(typescript@5.3.3): + /@typescript-eslint/utils@7.0.2(eslint@8.57.0)(typescript@5.3.3): resolution: { integrity: sha512-PZPIONBIB/X684bhT1XlrkjNZJIEevwkKDsdwfiu1WeqBxYEEdIgVDgm8/bbKHVu+6YOpeRqcfImTdImx/4Bsw==, @@ -2482,13 +2494,13 @@ packages: peerDependencies: eslint: ^8.56.0 dependencies: - "@eslint-community/eslint-utils": 4.4.0(eslint@8.56.0) + "@eslint-community/eslint-utils": 4.4.0(eslint@8.57.0) "@types/json-schema": 7.0.15 "@types/semver": 7.5.7 "@typescript-eslint/scope-manager": 7.0.2 "@typescript-eslint/types": 7.0.2 "@typescript-eslint/typescript-estree": 7.0.2(typescript@5.3.3) - eslint: 8.56.0 + eslint: 8.57.0 semver: 7.6.0 transitivePeerDependencies: - supports-color @@ -2594,7 +2606,7 @@ packages: "@yeoman/types": ^1.0.0 mem-fs: ^4.0.0 dependencies: - "@types/node": 16.18.82 + "@types/node": 16.18.83 "@yeoman/transform": 1.2.0 "@yeoman/types": 1.1.2(@types/inquirer@9.0.7)(mem-fs@4.0.0) binary-extensions: 2.2.0 @@ -2623,7 +2635,7 @@ packages: } engines: { node: ^16.13.0 || >=18.12.0 } dependencies: - "@types/node": 16.18.82 + "@types/node": 16.18.83 minimatch: 9.0.3 readable-stream: 4.5.2 @@ -2647,7 +2659,7 @@ packages: optional: true dependencies: "@types/inquirer": 9.0.7 - "@types/node": 16.18.82 + "@types/node": 16.18.83 mem-fs: 4.0.0 /JSONStream@1.3.5: @@ -3651,7 +3663,7 @@ packages: } engines: { node: ">= 6" } - /commitizen@4.3.0(@types/node@20.11.19)(typescript@5.3.3): + /commitizen@4.3.0(@types/node@20.11.20)(typescript@5.3.3): resolution: { integrity: sha512-H0iNtClNEhT0fotHvGV3E9tDejDeS04sN1veIebsKYGMuGscFaswRoYJKmT3eW85eIJAs0F28bG2+a/9wCOfPw==, @@ -3660,7 +3672,7 @@ packages: hasBin: true dependencies: cachedir: 2.3.0 - cz-conventional-changelog: 3.3.0(@types/node@20.11.19)(typescript@5.3.3) + cz-conventional-changelog: 3.3.0(@types/node@20.11.20)(typescript@5.3.3) dedent: 0.7.0 detect-indent: 6.1.0 find-node-modules: 2.1.3 @@ -3807,7 +3819,7 @@ packages: } dev: true - /cosmiconfig-typescript-loader@5.0.0(@types/node@20.11.19)(cosmiconfig@8.3.6)(typescript@5.3.3): + /cosmiconfig-typescript-loader@5.0.0(@types/node@20.11.20)(cosmiconfig@8.3.6)(typescript@5.3.3): resolution: { integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==, @@ -3818,7 +3830,7 @@ packages: cosmiconfig: ">=8.2" typescript: ">=4" dependencies: - "@types/node": 20.11.19 + "@types/node": 20.11.20 cosmiconfig: 8.3.6(typescript@5.3.3) jiti: 1.21.0 typescript: 5.3.3 @@ -3891,7 +3903,7 @@ packages: engines: { node: ">=4" } hasBin: true - /cz-conventional-changelog@3.3.0(@types/node@20.11.19)(typescript@5.3.3): + /cz-conventional-changelog@3.3.0(@types/node@20.11.20)(typescript@5.3.3): resolution: { integrity: sha512-U466fIzU5U22eES5lTNiNbZ+d8dfcHcssH4o7QsdWaCcRs/feIPCxKYSWkYBNs5mny7MvEfwpTLWjvbm94hecw==, @@ -3899,13 +3911,13 @@ packages: engines: { node: ">= 10" } dependencies: chalk: 2.4.2 - commitizen: 4.3.0(@types/node@20.11.19)(typescript@5.3.3) + commitizen: 4.3.0(@types/node@20.11.20)(typescript@5.3.3) conventional-commit-types: 3.0.0 lodash.map: 4.6.0 longest: 2.0.1 word-wrap: 1.2.5 optionalDependencies: - "@commitlint/load": 18.6.1(@types/node@20.11.19)(typescript@5.3.3) + "@commitlint/load": 18.6.1(@types/node@20.11.20)(typescript@5.3.3) transitivePeerDependencies: - "@types/node" - typescript @@ -4367,7 +4379,7 @@ packages: engines: { node: ">=12" } dev: true - /eslint-config-prettier@9.1.0(eslint@8.56.0): + /eslint-config-prettier@9.1.0(eslint@8.57.0): resolution: { integrity: sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==, @@ -4376,7 +4388,7 @@ packages: peerDependencies: eslint: ">=7.0.0" dependencies: - eslint: 8.56.0 + eslint: 8.57.0 dev: true /eslint-scope@7.2.2: @@ -4398,18 +4410,18 @@ packages: engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } dev: true - /eslint@8.56.0: + /eslint@8.57.0: resolution: { - integrity: sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==, + integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==, } engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } hasBin: true dependencies: - "@eslint-community/eslint-utils": 4.4.0(eslint@8.56.0) + "@eslint-community/eslint-utils": 4.4.0(eslint@8.57.0) "@eslint-community/regexpp": 4.10.0 "@eslint/eslintrc": 2.1.4 - "@eslint/js": 8.56.0 + "@eslint/js": 8.57.0 "@humanwhocodes/config-array": 0.11.14 "@humanwhocodes/module-importer": 1.0.1 "@nodelib/fs.walk": 1.2.8 @@ -4673,10 +4685,10 @@ packages: } dev: false - /fastq@1.15.0: + /fastq@1.17.1: resolution: { - integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==, + integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==, } dependencies: reusify: 1.0.4 @@ -4861,15 +4873,15 @@ packages: } engines: { node: ^10.12.0 || >=12.0.0 } dependencies: - flatted: 3.2.9 + flatted: 3.3.1 keyv: 4.5.4 rimraf: 3.0.2 dev: true - /flatted@3.2.9: + /flatted@3.3.1: resolution: { - integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==, + integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==, } dev: true @@ -6918,7 +6930,7 @@ packages: mem-fs: ^4.0.0 dependencies: "@types/ejs": 3.1.5 - "@types/node": 18.19.17 + "@types/node": 18.19.18 binaryextensions: 4.19.0 commondir: 1.0.1 deep-extend: 0.6.0 @@ -6939,7 +6951,7 @@ packages: } engines: { node: ">=16.13.0" } dependencies: - "@types/node": 18.19.17 + "@types/node": 18.19.18 "@types/vinyl": 2.0.11 vinyl: 3.0.0 vinyl-file: 5.0.0 @@ -6952,7 +6964,7 @@ packages: } engines: { node: ">=18.0.0" } dependencies: - "@types/node": 20.11.19 + "@types/node": 20.11.20 "@types/vinyl": 2.0.11 vinyl: 3.0.0 vinyl-file: 5.0.0 @@ -8023,7 +8035,7 @@ packages: } engines: { node: ">=16.13.0" } dependencies: - "@types/node": 16.18.82 + "@types/node": 16.18.83 p-queue: 7.4.1 readable-stream: 4.5.2 @@ -8160,7 +8172,7 @@ packages: dependencies: "@babel/code-frame": 7.23.5 index-to-position: 0.1.2 - type-fest: 4.10.2 + type-fest: 4.10.3 /parse-passwd@1.0.0: resolution: @@ -8656,7 +8668,7 @@ packages: dependencies: find-up-simple: 1.0.0 read-pkg: 9.0.1 - type-fest: 4.10.2 + type-fest: 4.10.3 /read-pkg-up@11.0.0: resolution: @@ -8668,7 +8680,7 @@ packages: dependencies: find-up-simple: 1.0.0 read-pkg: 9.0.1 - type-fest: 4.10.2 + type-fest: 4.10.3 dev: true /read-pkg-up@7.0.1: @@ -8706,7 +8718,7 @@ packages: "@types/normalize-package-data": 2.4.4 normalize-package-data: 6.0.0 parse-json: 8.1.0 - type-fest: 4.10.2 + type-fest: 4.10.3 unicorn-magic: 0.1.0 /readable-stream@2.3.8: @@ -9899,10 +9911,10 @@ packages: unique-string: 3.0.0 dev: true - /terser@5.27.2: + /terser@5.28.1: resolution: { - integrity: sha512-sHXmLSkImesJ4p5apTeT63DsV4Obe1s37qT8qvwHRmVxKTBH7Rv9Wr26VcAMmLbmk9UliiwK8z+657NyJHHy/w==, + integrity: sha512-wM+bZp54v/E9eRRGXb5ZFDvinrJIOaTapx3WUokyVGZu5ucVCK55zEgGd5Dl2fSr3jUo5sDiERErUWLY6QPFyA==, } engines: { node: ">=10" } hasBin: true @@ -10248,10 +10260,10 @@ packages: engines: { node: ">=14.16" } dev: true - /type-fest@4.10.2: + /type-fest@4.10.3: resolution: { - integrity: sha512-anpAG63wSpdEbLwOqH8L84urkL6PiVIov3EMmgIhhThevh9aiMQov+6Btx0wldNcvm4wV+e2/Rt1QdDwKHFbHw==, + integrity: sha512-JLXyjizi072smKGGcZiAJDCNweT8J+AuRxmPZ1aG7TERg4ijx9REl8CNhbr36RV4qXqL1gO1FF9HL8OkVmmrsA==, } engines: { node: ">=16" } @@ -10502,7 +10514,7 @@ packages: replace-ext: 2.0.0 teex: 1.0.1 - /vite-node@0.34.6(@types/node@20.11.19)(terser@5.27.2): + /vite-node@0.34.6(@types/node@20.11.20)(terser@5.28.1): resolution: { integrity: sha512-nlBMJ9x6n7/Amaz6F3zJ97EBwR2FkzhBRxF5e+jE6LA3yi6Wtc2lyTij1OnDMIr34v5g/tVQtsVAzhT0jc5ygA==, @@ -10515,7 +10527,7 @@ packages: mlly: 1.5.0 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.0.12(@types/node@20.11.19)(terser@5.27.2) + vite: 5.0.12(@types/node@20.11.20)(terser@5.28.1) transitivePeerDependencies: - "@types/node" - less @@ -10527,7 +10539,7 @@ packages: - terser dev: true - /vite-node@1.3.1(@types/node@20.11.19)(terser@5.27.2): + /vite-node@1.3.1(@types/node@20.11.20)(terser@5.28.1): resolution: { integrity: sha512-azbRrqRxlWTJEVbzInZCTchx0X69M/XPTCz4H+TLvlTcR/xH/3hkRqhOakT41fMJCMzXTu4UvegkZiEoJAWvng==, @@ -10539,7 +10551,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.1.3(@types/node@20.11.19)(terser@5.27.2) + vite: 5.1.3(@types/node@20.11.20)(terser@5.28.1) transitivePeerDependencies: - "@types/node" - less @@ -10551,7 +10563,7 @@ packages: - terser dev: true - /vite@5.0.12(@types/node@20.11.19)(terser@5.27.2): + /vite@5.0.12(@types/node@20.11.20)(terser@5.28.1): resolution: { integrity: sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==, @@ -10582,16 +10594,16 @@ packages: terser: optional: true dependencies: - "@types/node": 20.11.19 + "@types/node": 20.11.20 esbuild: 0.19.12 postcss: 8.4.33 rollup: 4.9.6 - terser: 5.27.2 + terser: 5.28.1 optionalDependencies: fsevents: 2.3.3 dev: true - /vite@5.1.3(@types/node@20.11.19)(terser@5.27.2): + /vite@5.1.3(@types/node@20.11.20)(terser@5.28.1): resolution: { integrity: sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==, @@ -10622,16 +10634,16 @@ packages: terser: optional: true dependencies: - "@types/node": 20.11.19 + "@types/node": 20.11.20 esbuild: 0.19.12 postcss: 8.4.35 rollup: 4.12.0 - terser: 5.27.2 + terser: 5.28.1 optionalDependencies: fsevents: 2.3.3 dev: true - /vitest@0.34.6(terser@5.27.2): + /vitest@0.34.6(terser@5.28.1): resolution: { integrity: sha512-+5CALsOvbNKnS+ZHMXtuUC7nL8/7F1F2DnHGjSsszX8zCjWSSviphCb/NuS9Nzf4Q03KyyDRBAXhF/8lffME4Q==, @@ -10667,7 +10679,7 @@ packages: dependencies: "@types/chai": 4.3.11 "@types/chai-subset": 1.3.5 - "@types/node": 20.11.19 + "@types/node": 20.11.20 "@vitest/expect": 0.34.6 "@vitest/runner": 0.34.6 "@vitest/snapshot": 0.34.6 @@ -10686,8 +10698,8 @@ packages: strip-literal: 1.3.0 tinybench: 2.6.0 tinypool: 0.7.0 - vite: 5.0.12(@types/node@20.11.19)(terser@5.27.2) - vite-node: 0.34.6(@types/node@20.11.19)(terser@5.27.2) + vite: 5.0.12(@types/node@20.11.20)(terser@5.28.1) + vite-node: 0.34.6(@types/node@20.11.20)(terser@5.28.1) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -11065,7 +11077,7 @@ packages: optional: true dependencies: "@types/lodash-es": 4.17.12 - "@types/node": 18.19.17 + "@types/node": 18.19.18 "@yeoman/namespace": 1.0.0 "@yeoman/types": 1.1.2(@types/inquirer@9.0.7)(mem-fs@4.0.0) chalk: 5.3.0 @@ -11113,7 +11125,7 @@ packages: mem-fs-editor: 10.0.3 sinon: 16.1.3 temp-dir: 3.0.0 - type-fest: 4.10.2 + type-fest: 4.10.3 yeoman-environment: 4.3.0(@yeoman/types@1.1.2)(mem-fs@4.0.0) yeoman-generator: 7.1.1(@yeoman/types@1.1.2)(mem-fs@4.0.0)(yeoman-environment@4.3.0) dev: true From 1e4280637e5504723c0da198a4079e94c0e5a8fb Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:40:09 +0000 Subject: [PATCH 14/18] fix: ensure user field is an empty string by default --- src/app.ts | 2 +- src/helpers/GitHelper.ts | 12 ++++-------- src/questions/Author.ts | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/app.ts b/src/app.ts index ce0a698..3cf8aeb 100644 --- a/src/app.ts +++ b/src/app.ts @@ -25,7 +25,7 @@ class AppGenerator extends Generator { private generator: GeneratorInterface | undefined = undefined; private readonly choices = GeneratorFactory.getAvailable(); public abort: boolean = false; - public user: string | undefined = undefined; + public user: string = ""; constructor(args: string | Array, options: AppOptions) { super(args, options); diff --git a/src/helpers/GitHelper.ts b/src/helpers/GitHelper.ts index 9cd1d6b..14947f6 100644 --- a/src/helpers/GitHelper.ts +++ b/src/helpers/GitHelper.ts @@ -6,16 +6,12 @@ export class GitHelper { return await which("git").catch(() => undefined); } - public static async getGitUserName( - generator: Generator, - ): Promise { - return await generator.git.name(); + public static async getGitUserName(generator: Generator): Promise { + return (await generator.git.name()) || ""; } - public static async getGitUserEmail( - generator: Generator, - ): Promise { - return await generator.git.email(); + public static async getGitUserEmail(generator: Generator): Promise { + return (await generator.git.email()) || ""; } public static async init(generator: Generator): Promise { diff --git a/src/questions/Author.ts b/src/questions/Author.ts index 945be9c..8dda49c 100644 --- a/src/questions/Author.ts +++ b/src/questions/Author.ts @@ -17,7 +17,7 @@ export class Author extends BaseQuestion { } private getDefault(): string { - return this.generator.user || ""; + return this.generator.user; } public getQuestion(): PromptQuestion { From fff49b443057d1f874910557852172fafef00948 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:48:26 +0000 Subject: [PATCH 15/18] test: pass an empty string to author as default when running in CI --- tests/c.test.ts | 4 +++- tests/html.test.ts | 4 +++- tests/javascript.test.ts | 4 +++- tests/nodecli.test.ts | 4 +++- tests/python.test.ts | 4 +++- tests/simpl.test.ts | 4 +++- tests/typescript.test.ts | 4 +++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/c.test.ts b/tests/c.test.ts index b2b8362..a9f041d 100644 --- a/tests/c.test.ts +++ b/tests/c.test.ts @@ -393,7 +393,9 @@ describe("generator-norgate-av:c", () => { name: destination, id: "test-project", description: "", - author: (await result.generator.git.name()) || "", + author: process.env.CI + ? "" + : (await result.generator.git.name()) || "", git: !process.env.CI, pkg: "pnpm", }); diff --git a/tests/html.test.ts b/tests/html.test.ts index ed67d49..aa600fd 100644 --- a/tests/html.test.ts +++ b/tests/html.test.ts @@ -413,7 +413,9 @@ describe("generator-norgate-av:html", () => { name: destination, id: "test-project", description: "", - author: (await result.generator.git.name()) || "", + author: process.env.CI + ? "" + : (await result.generator.git.name()) || "", git: !process.env.CI, pkg: "pnpm", }); diff --git a/tests/javascript.test.ts b/tests/javascript.test.ts index 2e049a6..037235f 100644 --- a/tests/javascript.test.ts +++ b/tests/javascript.test.ts @@ -418,7 +418,9 @@ describe("generator-norgate-av:javascript", () => { name: destination, id: "test-project", description: "", - author: (await result.generator.git.name()) || "", + author: process.env.CI + ? "" + : (await result.generator.git.name()) || "", git: !process.env.CI, pkg: "pnpm", }); diff --git a/tests/nodecli.test.ts b/tests/nodecli.test.ts index 7c747e0..39b3c31 100644 --- a/tests/nodecli.test.ts +++ b/tests/nodecli.test.ts @@ -444,7 +444,9 @@ describe("generator-norgate-av:nodecli", () => { name: destination, id: "test-project", description: "", - author: (await result.generator.git.name()) || "", + author: process.env.CI + ? "" + : (await result.generator.git.name()) || "", git: !process.env.CI, pkg: "pnpm", }); diff --git a/tests/python.test.ts b/tests/python.test.ts index f1d4dfb..f5b97a0 100644 --- a/tests/python.test.ts +++ b/tests/python.test.ts @@ -254,7 +254,9 @@ describe("generator-norgate-av:python", () => { id: "test-project", name: destination, description: "", - author: (await result.generator.git.name()) || "", + author: process.env.CI + ? "" + : (await result.generator.git.name()) || "", git: !process.env.CI, }); }); diff --git a/tests/simpl.test.ts b/tests/simpl.test.ts index 42fb816..187971f 100644 --- a/tests/simpl.test.ts +++ b/tests/simpl.test.ts @@ -395,7 +395,9 @@ describe("generator-norgate-av:simpl", () => { name: destination, id: "test-project", description: "", - author: (await result.generator.git.name()) || "", + author: process.env.CI + ? "" + : (await result.generator.git.name()) || "", git: !process.env.CI, pkg: "pnpm", }); diff --git a/tests/typescript.test.ts b/tests/typescript.test.ts index a046d90..ce30679 100644 --- a/tests/typescript.test.ts +++ b/tests/typescript.test.ts @@ -437,7 +437,9 @@ describe("generator-norgate-av:typescript", () => { name: destination, id: "test-project", description: "", - author: (await result.generator.git.name()) || "", + author: process.env.CI + ? "" + : (await result.generator.git.name()) || "", git: !process.env.CI, pkg: "pnpm", }); From 57cc550960e463a3054f7432ed7ed2d1485ef602 Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:21:36 +0000 Subject: [PATCH 16/18] fix: dont set the author from answers when skipping prompts --- src/generators/ClangGenerator.ts | 5 +++-- src/generators/CrestronSimplGenerator.ts | 5 +++-- src/generators/HtmlGenerator.ts | 5 +++-- src/generators/JavascriptGenerator.ts | 5 +++-- src/generators/NodeCliGenerator.ts | 5 +++-- src/generators/PythonGenerator.ts | 5 +++-- src/generators/TypescriptGenerator.ts | 5 +++-- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/generators/ClangGenerator.ts b/src/generators/ClangGenerator.ts index 40b29b8..a3f03b2 100644 --- a/src/generators/ClangGenerator.ts +++ b/src/generators/ClangGenerator.ts @@ -83,8 +83,9 @@ export class ClangGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; - this.generator.options.author = - this.generator.options.author || answers.author; + this.generator.options.author = this.generator.options.skipPrompts + ? this.generator.options.author + : answers.author; // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access diff --git a/src/generators/CrestronSimplGenerator.ts b/src/generators/CrestronSimplGenerator.ts index 617749b..9fc5f7a 100644 --- a/src/generators/CrestronSimplGenerator.ts +++ b/src/generators/CrestronSimplGenerator.ts @@ -84,8 +84,9 @@ export class CrestronSimplGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; - this.generator.options.author = - this.generator.options.author || answers.author; + this.generator.options.author = this.generator.options.skipPrompts + ? this.generator.options.author + : answers.author; // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access diff --git a/src/generators/HtmlGenerator.ts b/src/generators/HtmlGenerator.ts index fc7cd51..0f2998e 100644 --- a/src/generators/HtmlGenerator.ts +++ b/src/generators/HtmlGenerator.ts @@ -83,8 +83,9 @@ export class HtmlGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; - this.generator.options.author = - this.generator.options.author || answers.author; + this.generator.options.author = this.generator.options.skipPrompts + ? this.generator.options.author + : answers.author; // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access diff --git a/src/generators/JavascriptGenerator.ts b/src/generators/JavascriptGenerator.ts index d792c04..2d3cff4 100644 --- a/src/generators/JavascriptGenerator.ts +++ b/src/generators/JavascriptGenerator.ts @@ -83,8 +83,9 @@ export class JavascriptGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; - this.generator.options.author = - this.generator.options.author || answers.author; + this.generator.options.author = this.generator.options.skipPrompts + ? this.generator.options.author + : answers.author; // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access diff --git a/src/generators/NodeCliGenerator.ts b/src/generators/NodeCliGenerator.ts index 4e23fbb..303ebd7 100644 --- a/src/generators/NodeCliGenerator.ts +++ b/src/generators/NodeCliGenerator.ts @@ -83,8 +83,9 @@ export class NodeCliGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; - this.generator.options.author = - this.generator.options.author || answers.author; + this.generator.options.author = this.generator.options.skipPrompts + ? this.generator.options.author + : answers.author; // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access diff --git a/src/generators/PythonGenerator.ts b/src/generators/PythonGenerator.ts index 8758eea..61fc174 100644 --- a/src/generators/PythonGenerator.ts +++ b/src/generators/PythonGenerator.ts @@ -78,8 +78,9 @@ export class PythonGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; - this.generator.options.author = - this.generator.options.author || answers.author; + this.generator.options.author = this.generator.options.skipPrompts + ? this.generator.options.author + : answers.author; this.generator.options.description = this.generator.options.skipPrompts ? this.generator.options.description diff --git a/src/generators/TypescriptGenerator.ts b/src/generators/TypescriptGenerator.ts index 1afb74a..b5aba03 100644 --- a/src/generators/TypescriptGenerator.ts +++ b/src/generators/TypescriptGenerator.ts @@ -83,8 +83,9 @@ export class TypescriptGenerator implements GeneratorInterface { this.generator.options.id = this.generator.options.id || answers.id; this.generator.options.pkg = this.generator.options.pkg || answers.pkg; - this.generator.options.author = - this.generator.options.author || answers.author; + this.generator.options.author = this.generator.options.skipPrompts + ? this.generator.options.author + : answers.author; // @ts-expect-error This is necessary as the env 'options' property doesn't seem to be correctly typed on the Environment. // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access From 3e9fd37c9e827f0d39c0680bd96864fcc10cb33e Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:22:55 +0000 Subject: [PATCH 17/18] fix: remove default values from author and description cli options --- src/helpers/CliHelper.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/helpers/CliHelper.ts b/src/helpers/CliHelper.ts index 3592c50..fb029a7 100644 --- a/src/helpers/CliHelper.ts +++ b/src/helpers/CliHelper.ts @@ -48,14 +48,12 @@ export class CliHelper { type: String, alias: "d", description: "Description of the project", - default: "", }, { name: "author", type: String, alias: "a", description: "Author of the project", - default: "", }, { name: "git", From f793524d5cf7feef89a6943ca50f90601372030a Mon Sep 17 00:00:00 2001 From: Damien Butt <22627489+damienbutt@users.noreply.github.com> Date: Sat, 24 Feb 2024 15:23:28 +0000 Subject: [PATCH 18/18] fix: set author to default if undefined --- src/questions/Author.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/questions/Author.ts b/src/questions/Author.ts index 8dda49c..ced8f70 100644 --- a/src/questions/Author.ts +++ b/src/questions/Author.ts @@ -11,7 +11,10 @@ export class Author extends BaseQuestion { return; } - if (this.generator.options.skipPrompts) { + if ( + this.generator.options.author === undefined && + this.generator.options.skipPrompts + ) { this.generator.options.author = this.getDefault(); } }