From 25fde18a73c1f73df99139a7f7b1eecf70d989dd Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 18:41:36 +0100 Subject: [PATCH 01/13] Update the `package-lock.json` file --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index b7e592ed..cadbe0fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24411,7 +24411,7 @@ "requires": { "@manuth/extended-yo-generator": "^11.0.6", "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project": "^3.0.10", + "@manuth/generator-ts-project": "^3.0.11", "@manuth/package-json-editor": "^2.2.5", "@manuth/temp-files": "^2.0.8", "@stdlib/utils-escape-regexp-string": "^0.0.7", From 0e2fd93344bd160afb4393207fad88a720ef3f26 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 19:26:36 +0100 Subject: [PATCH 02/13] Remove unnecessary `./`-prefix in `.drone.yml` file --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4950e54c..da130772 100644 --- a/.drone.yml +++ b/.drone.yml @@ -100,7 +100,7 @@ steps: api_key: from_secret: github_publish_token files: - - "./*.tgz" + - "*.tgz" title: .releaseTitle.md note: .releaseNotes.md when: From 00a9c7619b259b94b8b57e4e424b62dac8f95a46 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 20:30:51 +0100 Subject: [PATCH 03/13] Fix broken replacement of `--workspaces` console argument --- packages/generator-my-ts-project/src/DroneFileMapping.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/generator-my-ts-project/src/DroneFileMapping.ts b/packages/generator-my-ts-project/src/DroneFileMapping.ts index d2438cdb..3f34f3ea 100644 --- a/packages/generator-my-ts-project/src/DroneFileMapping.ts +++ b/packages/generator-my-ts-project/src/DroneFileMapping.ts @@ -74,18 +74,13 @@ export class DroneFileMapping Date: Fri, 17 Dec 2021 20:31:46 +0100 Subject: [PATCH 04/13] Refactor tests accordingly --- .../src/tests/DroneFileMapping.test.ts | 42 ++----------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/packages/generator-my-ts-project/src/tests/DroneFileMapping.test.ts b/packages/generator-my-ts-project/src/tests/DroneFileMapping.test.ts index 419d36c3..f5a299ce 100644 --- a/packages/generator-my-ts-project/src/tests/DroneFileMapping.test.ts +++ b/packages/generator-my-ts-project/src/tests/DroneFileMapping.test.ts @@ -82,23 +82,15 @@ export function DroneFileMappingTests(context: TestContext) nameof>((fileMapping) => fileMapping.Transform), () => { - test( - "Checking whether `publish` commands are replaced correctly…", - async function() - { - this.timeout(2 * 1000); - this.slow(1 * 1000); - ok(await AssertCommand((command) => command.startsWith("npm publish"))); - ok(await AssertCommand((command) => !command.startsWith("npx lerna publish"), true)); - }); + let workspaceArg = "--workspaces"; test( - "Checking whether `lerna exec` commands are replaced correctly…", + `Checking whether \`${workspaceArg}\` arguments of commands are stripped away…`, async function() { this.timeout(2 * 1000); this.slow(1 * 1000); - ok(await AssertCommand((command) => !command.startsWith("npx lerna exec"), true)); + ok(await AssertCommand((command) => !command.includes(workspaceArg))); }); test( @@ -131,34 +123,6 @@ export function DroneFileMappingTests(context: TestContext) }); })); }); - - test( - "Checking whether the `test`-step is adjusted correctly…", - async function() - { - this.timeout(2 * 1000); - this.slow(1 * 1000); - - ok( - (await tester.ParseOutput()).every( - (document) => - { - let steps: any[] = document.toJSON().steps; - - return steps.every( - (step) => - { - if (step.name === "test") - { - return !(step.image as string).endsWith(":lts"); - } - else - { - return true; - } - }); - })); - }); }); }); } From d2bff157c99ab21bc7a8b760e293b99124fd7741 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 20:32:11 +0100 Subject: [PATCH 05/13] Remove the `tsd` command from generated `test` scripts --- .../TSProjectPackageFileMapping.ts | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/generator-ts-project/src/Project/FileMappings/NPMPackagning/TSProjectPackageFileMapping.ts b/packages/generator-ts-project/src/Project/FileMappings/NPMPackagning/TSProjectPackageFileMapping.ts index b64d2605..07ab60ae 100644 --- a/packages/generator-ts-project/src/Project/FileMappings/NPMPackagning/TSProjectPackageFileMapping.ts +++ b/packages/generator-ts-project/src/Project/FileMappings/NPMPackagning/TSProjectPackageFileMapping.ts @@ -79,10 +79,30 @@ export class TSProjectPackageFileMapping | string> { + let testScriptName = "test"; let prepareScriptName = "prepare"; return [ - "test", + { + Source: testScriptName, + Destination: testScriptName, + Processor: async (script) => + { + let separator = " && "; + let commands = script.split(separator); + let filtered: string[] = []; + + for (let command of commands) + { + if (command !== "tsd") + { + filtered.push(command); + } + } + + return filtered.join(separator); + } + }, { Source: "initialize", Destination: prepareScriptName From fb559e513387bb2dbd5097b8796236ae14ebd632 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 20:32:58 +0100 Subject: [PATCH 06/13] Fix broken `launch.json` creation --- .../src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts b/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts index 9966dab6..eb2d12a3 100644 --- a/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts +++ b/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts @@ -56,7 +56,7 @@ export class TSProjectLaunchSettingsProcessor { - return (debugConfig.program ?? "").includes(this.GetWorkspaceFolderDirective("TSProjectGenerator")) && + return /\bTSProjectGenerator\b/.test(debugConfig.name ?? "") && !(normalize(debugConfig.program ?? "").toLowerCase().endsWith(join("node_modules", "yo", "lib", "cli.js"))); } From f241e27e35764058c1977c69bf67262b7c18cb7c Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 20:33:05 +0100 Subject: [PATCH 07/13] Refactor tests properly --- .../src/tests/MyTSProjectPackageFileMapping.test.ts | 4 ++-- .../NPMPackaging/TSProjectPackageFileMapping.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/generator-my-ts-project/src/tests/MyTSProjectPackageFileMapping.test.ts b/packages/generator-my-ts-project/src/tests/MyTSProjectPackageFileMapping.test.ts index 6ff27eaf..36d58ed5 100644 --- a/packages/generator-my-ts-project/src/tests/MyTSProjectPackageFileMapping.test.ts +++ b/packages/generator-my-ts-project/src/tests/MyTSProjectPackageFileMapping.test.ts @@ -1,4 +1,4 @@ -import { ok } from "assert"; +import { ok, strictEqual } from "assert"; import { GeneratorOptions } from "@manuth/extended-yo-generator"; import { FileMappingTester, TestContext } from "@manuth/extended-yo-generator-test"; import { ITSProjectSettings, TSProjectPackageFileMapping } from "@manuth/generator-ts-project"; @@ -97,7 +97,7 @@ export function MyTSProjectPackageFileMappingTests(context: TestContext !script.includes("tsd")); await tester.AssertScript( "prepare", From 872aa5de6e8ab262c7198616bffca156593e0eee Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 23:24:27 +0100 Subject: [PATCH 08/13] Refactor the detection of vscode launch tasks --- .../src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts b/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts index eb2d12a3..c8d0cbb6 100644 --- a/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts +++ b/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts @@ -56,7 +56,11 @@ export class TSProjectLaunchSettingsProcessor { - return /\bTSProjectGenerator\b/.test(debugConfig.name ?? "") && + let workspaceDirective = this.GetWorkspaceFolderDirective("TSProjectGenerator"); + + return ( + (debugConfig.args as string[])?.[0]?.includes(workspaceDirective) || + (debugConfig.cwd as string)?.includes(workspaceDirective)) && !(normalize(debugConfig.program ?? "").toLowerCase().endsWith(join("node_modules", "yo", "lib", "cli.js"))); } From 67ee52ba6b0f170ec37ad443e60e7ef9ba5ecde4 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 23:24:36 +0100 Subject: [PATCH 09/13] Refactor tests accordingly --- .../TSProjectLaunchSettingsProcessor.test.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/generator-ts-project/src/tests/Project/VSCode/TSProjectLaunchSettingsProcessor.test.ts b/packages/generator-ts-project/src/tests/Project/VSCode/TSProjectLaunchSettingsProcessor.test.ts index eaab72c2..8b719096 100644 --- a/packages/generator-ts-project/src/tests/Project/VSCode/TSProjectLaunchSettingsProcessor.test.ts +++ b/packages/generator-ts-project/src/tests/Project/VSCode/TSProjectLaunchSettingsProcessor.test.ts @@ -76,6 +76,7 @@ export function TSProjectLaunchSettingsProcessorTests(context: TestContext Date: Fri, 17 Dec 2021 23:26:07 +0100 Subject: [PATCH 10/13] Add changelog entries --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index faf42059..2e9ad89f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## TSProjectGenerator [Unreleased] +### Fixed + - Broken drone pipeline creation + - Incorrect `test` npm script + - Creation of vscode debug settings [Show differences](https://github.com/manuth/TSProjectGenerator/compare/v3.0.11...dev) From 291fd75661e8792f69003b7b6d5353ec02fb82d0 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 17 Dec 2021 23:26:56 +0100 Subject: [PATCH 11/13] Update the changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e9ad89f..89912576 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## TSProjectGenerator [Unreleased] + +[Show differences](https://github.com/manuth/TSProjectGenerator/compare/v3.0.12...dev) + +## TSProjectGenerator v3.0.12 ### Fixed - Broken drone pipeline creation - Incorrect `test` npm script - Creation of vscode debug settings -[Show differences](https://github.com/manuth/TSProjectGenerator/compare/v3.0.11...dev) +[Show differences](https://github.com/manuth/TSProjectGenerator/compare/v3.0.11...v3.0.12) ## TSProjectGenerator v3.0.11 ### Fixed From ac97385e02ceac0dedee68af7c26a2328e8bd633 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 18 Dec 2021 00:01:11 +0100 Subject: [PATCH 12/13] Refactor the script for bumping version numbers --- package-lock.json | 1 + package.json | 1 + scripts/bumpVersion.ts | 63 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/package-lock.json b/package-lock.json index cadbe0fb..632b96d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "name": "ts-project-generator", "devDependencies": { "@manuth/eslint-plugin-typescript": "^3.2.6", + "@manuth/package-json-editor": "^2.2.5", "@tsd/typescript": "npm:nop@^1.0.0", "@types/diff": "^5.0.1", "@types/fs-extra": "^9.0.13", diff --git a/package.json b/package.json index 1b9fe44a..3d0a591a 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "devDependencies": { "@manuth/eslint-plugin-typescript": "^3.2.6", + "@manuth/package-json-editor": "^2.2.5", "@tsd/typescript": "npm:nop@^1.0.0", "@types/diff": "^5.0.1", "@types/fs-extra": "^9.0.13", diff --git a/scripts/bumpVersion.ts b/scripts/bumpVersion.ts index 8f8f047a..2abde9f4 100644 --- a/scripts/bumpVersion.ts +++ b/scripts/bumpVersion.ts @@ -1,10 +1,17 @@ import { spawnSync } from "child_process"; +import { dirname, join } from "path"; +import { Dictionary, Package } from "@manuth/package-json-editor"; +import { pathExists } from "fs-extra"; import GitBranch = require("git-branch"); +import { glob } from "glob"; import npmWhich = require("npm-which"); ( async () => { + let npmPackage = new Package(join(__dirname, "..", Package.FileName)); + let workspacePaths: string[]; + let workspacePackages: Package[] = []; let branchName = await GitBranch(__dirname); let releaseName = branchName.replace(/^release\/(.*)/, "$1"); @@ -20,6 +27,62 @@ import npmWhich = require("npm-which"); "--allow-same-version" ]); + let workspaceSetting: any = npmPackage.AdditionalProperties.Get("workspaces"); + + if (Array.isArray(workspaceSetting)) + { + workspacePaths = workspaceSetting; + } + else + { + workspacePaths = workspaceSetting?.packages; + } + + for (let pattern of workspacePaths ?? []) + { + for (let workspacePath of glob.sync(pattern, { cwd: dirname(npmPackage.FileName) })) + { + let packageFileName = join(workspacePath, Package.FileName); + + if (await pathExists(packageFileName)) + { + workspacePackages.push(new Package(packageFileName)); + } + } + } + + for (let workspacePackage of workspacePackages) + { + for (let dependencyCandidate of workspacePackages) + { + if (dependencyCandidate.Name !== workspacePackage.Name) + { + for (let entry of [ + [workspacePackage.Dependencies, "--save"], + [workspacePackage.DevelopmentDependencies, "--save-dev"], + [workspacePackage.OptionalDependencies, "--save-optional"], + [workspacePackage.PeerDependencies, "--save-peer"] + ] as Array<[Dictionary, string]>) + { + if (entry[0].Has(dependencyCandidate.Name)) + { + spawnSync( + npmWhich(__dirname).sync("npm"), + [ + "install", + "--ignore-scripts", + "--no-audit", + "--workspace", + workspacePackage.Name, + entry[1], + dependencyCandidate.Name + ]); + } + } + } + } + } + spawnSync( npmWhich(__dirname).sync("git"), [ From 10e5a5c28a425eaf5a333c20a44e91465675d6ab Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 18 Dec 2021 00:03:26 +0100 Subject: [PATCH 13/13] Bump the version number to v3.0.12 --- package-lock.json | 20 +++++++++---------- packages/generator-my-ts-project/package.json | 6 +++--- .../generator-ts-project-test/package.json | 4 ++-- packages/generator-ts-project/package.json | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 632b96d5..b7cb7c6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22600,11 +22600,11 @@ }, "packages/generator-my-ts-project": { "name": "@manuth/generator-my-ts-project", - "version": "3.0.11", + "version": "3.0.12", "license": "MIT", "dependencies": { "@manuth/extended-yo-generator": "^11.0.6", - "@manuth/generator-ts-project": "^3.0.11", + "@manuth/generator-ts-project": "^3.0.12", "@manuth/package-json-editor": "2.2.5", "comment-json": "^4.1.1", "detect-newline": "^3.1.0", @@ -22614,7 +22614,7 @@ }, "devDependencies": { "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project-test": "^3.0.11", + "@manuth/generator-ts-project-test": "^3.0.12", "@manuth/temp-files": "^2.0.8", "@types/dedent": "^0.7.0", "@types/fs-extra": "^9.0.13", @@ -22644,7 +22644,7 @@ }, "packages/generator-ts-project": { "name": "@manuth/generator-ts-project", - "version": "3.0.11", + "version": "3.0.12", "license": "MIT", "dependencies": { "@manuth/eslint-plugin-typescript": "^3.2.6", @@ -22676,7 +22676,7 @@ "devDependencies": { "@manuth/eslint-plugin-typescript": "^3.2.6", "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project-test": "^3.0.11", + "@manuth/generator-ts-project-test": "^3.0.12", "@manuth/tsconfig": "^3.0.0", "@types/dedent": "^0.7.0", "@types/diff": "^5.0.1", @@ -22718,12 +22718,12 @@ }, "packages/generator-ts-project-test": { "name": "@manuth/generator-ts-project-test", - "version": "3.0.11", + "version": "3.0.12", "license": "MIT", "dependencies": { "@manuth/extended-yo-generator": "^11.0.6", "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project": "^3.0.11", + "@manuth/generator-ts-project": "^3.0.12", "@manuth/package-json-editor": "^2.2.5", "@manuth/temp-files": "^2.0.8", "@stdlib/utils-escape-regexp-string": "^0.0.7", @@ -24231,8 +24231,8 @@ "requires": { "@manuth/extended-yo-generator": "^11.0.6", "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project": "^3.0.11", - "@manuth/generator-ts-project-test": "^3.0.11", + "@manuth/generator-ts-project": "^3.0.12", + "@manuth/generator-ts-project-test": "^3.0.12", "@manuth/package-json-editor": "2.2.5", "@manuth/temp-files": "^2.0.8", "@types/dedent": "^0.7.0", @@ -24271,7 +24271,7 @@ "@manuth/eslint-plugin-typescript": "^3.2.6", "@manuth/extended-yo-generator": "^11.0.6", "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project-test": "^3.0.11", + "@manuth/generator-ts-project-test": "^3.0.12", "@manuth/package-json-editor": "^2.2.5", "@manuth/temp-files": "^2.0.8", "@manuth/tsconfig": "^3.0.0", diff --git a/packages/generator-my-ts-project/package.json b/packages/generator-my-ts-project/package.json index 95b164b5..a0412682 100644 --- a/packages/generator-my-ts-project/package.json +++ b/packages/generator-my-ts-project/package.json @@ -1,6 +1,6 @@ { "name": "@manuth/generator-my-ts-project", - "version": "3.0.11", + "version": "3.0.12", "description": "Generates TypeScript-Projects with custom additions", "author": "Manuel Thalmann ", "license": "MIT", @@ -35,7 +35,7 @@ }, "dependencies": { "@manuth/extended-yo-generator": "^11.0.6", - "@manuth/generator-ts-project": "^3.0.11", + "@manuth/generator-ts-project": "^3.0.12", "@manuth/package-json-editor": "2.2.5", "comment-json": "^4.1.1", "detect-newline": "^3.1.0", @@ -45,7 +45,7 @@ }, "devDependencies": { "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project-test": "^3.0.11", + "@manuth/generator-ts-project-test": "^3.0.12", "@manuth/temp-files": "^2.0.8", "@types/dedent": "^0.7.0", "@types/fs-extra": "^9.0.13", diff --git a/packages/generator-ts-project-test/package.json b/packages/generator-ts-project-test/package.json index edac22f0..80e8048f 100644 --- a/packages/generator-ts-project-test/package.json +++ b/packages/generator-ts-project-test/package.json @@ -1,6 +1,6 @@ { "name": "@manuth/generator-ts-project-test", - "version": "3.0.11", + "version": "3.0.12", "description": "Provides the functionality to test `TSProjectGenerator`-components", "author": "Manuel Thalmann ", "license": "MIT", @@ -33,7 +33,7 @@ "dependencies": { "@manuth/extended-yo-generator": "^11.0.6", "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project": "^3.0.11", + "@manuth/generator-ts-project": "^3.0.12", "@manuth/package-json-editor": "^2.2.5", "@manuth/temp-files": "^2.0.8", "@stdlib/utils-escape-regexp-string": "^0.0.7", diff --git a/packages/generator-ts-project/package.json b/packages/generator-ts-project/package.json index 33a3b4d6..ccffcc46 100644 --- a/packages/generator-ts-project/package.json +++ b/packages/generator-ts-project/package.json @@ -1,6 +1,6 @@ { "name": "@manuth/generator-ts-project", - "version": "3.0.11", + "version": "3.0.12", "description": "A Set of Generators for Creating Projects Written in TypeScript", "author": "Manuel Thalmann ", "license": "MIT", @@ -70,7 +70,7 @@ "devDependencies": { "@manuth/eslint-plugin-typescript": "^3.2.6", "@manuth/extended-yo-generator-test": "^11.0.6", - "@manuth/generator-ts-project-test": "^3.0.11", + "@manuth/generator-ts-project-test": "^3.0.12", "@manuth/tsconfig": "^3.0.0", "@types/dedent": "^0.7.0", "@types/diff": "^5.0.1",