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: diff --git a/CHANGELOG.md b/CHANGELOG.md index faf42059..89912576 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## TSProjectGenerator [Unreleased] -[Show differences](https://github.com/manuth/TSProjectGenerator/compare/v3.0.11...dev) +[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...v3.0.12) ## TSProjectGenerator v3.0.11 ### Fixed diff --git a/package-lock.json b/package-lock.json index b7e592ed..b7cb7c6f 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", @@ -22599,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", @@ -22613,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", @@ -22643,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", @@ -22675,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", @@ -22717,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", @@ -24230,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", @@ -24270,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", @@ -24411,7 +24412,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", 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/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-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) 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; - } - }); - })); - }); }); }); } 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", "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", 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 diff --git a/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts b/packages/generator-ts-project/src/Project/VSCode/TSProjectLaunchSettingsProcessor.ts index 9966dab6..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 (debugConfig.program ?? "").includes(this.GetWorkspaceFolderDirective("TSProjectGenerator")) && + 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"))); } diff --git a/packages/generator-ts-project/src/tests/Project/FileMappings/NPMPackaging/TSProjectPackageFileMapping.test.ts b/packages/generator-ts-project/src/tests/Project/FileMappings/NPMPackaging/TSProjectPackageFileMapping.test.ts index a59d679b..0a30192c 100644 --- a/packages/generator-ts-project/src/tests/Project/FileMappings/NPMPackaging/TSProjectPackageFileMapping.test.ts +++ b/packages/generator-ts-project/src/tests/Project/FileMappings/NPMPackaging/TSProjectPackageFileMapping.test.ts @@ -162,7 +162,7 @@ export function TSProjectPackageFileMappingTests(context: TestContext !script.includes("tsd")); await tester.AssertScript( "prepare", 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 { + 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"), [