diff --git a/.github/workflows/src-ci.yml b/.github/workflows/src-ci.yml index 3888de1b..c51e26df 100644 --- a/.github/workflows/src-ci.yml +++ b/.github/workflows/src-ci.yml @@ -67,6 +67,10 @@ jobs: working-directory: ${{ env.CWD }} run: npm ci + - name: Build + working-directory: ${{ env.CWD }} + run: npx nx run-many --target build + - name: Log Version shell: pwsh run: Write-Host ${{ inputs.version }} @@ -76,10 +80,6 @@ jobs: working-directory: ${{ env.CWD }} run: npx nx run-many --target version --args="--version=${{ inputs.version }}" - - name: Build - working-directory: ${{ env.CWD }} - run: npx nx run-many --target build - - name: Upload Build uses: actions/upload-artifact@v3 with: diff --git a/e2e/npm-package/test/cli/index.e2e.spec.ts b/e2e/npm-package/test/cli/index.e2e.spec.ts index c489cc67..8e1c70d3 100644 --- a/e2e/npm-package/test/cli/index.e2e.spec.ts +++ b/e2e/npm-package/test/cli/index.e2e.spec.ts @@ -169,17 +169,21 @@ describe("cli", () => { }); it("should return the current version when --version is given", async () => { + const versionInPackageJson = "*"; + const { stdout } = await execAsync( `npx generate-license-file --version` ); - expect(stdout.trim()).toBe("v0.0.0"); + expect(stdout.trim()).toBe(`v${versionInPackageJson}`); }); it("should return the current version when -v is given", async () => { + const versionInPackageJson = "*"; + const { stdout } = await execAsync(`npx generate-license-file -v`); - expect(stdout.trim()).toBe("v0.0.0"); + expect(stdout.trim()).toBe(`v${versionInPackageJson}`); }); }); }); diff --git a/src/packages/generate-license-file-webpack-plugin/.eslintrc.json b/src/packages/generate-license-file-webpack-plugin/.eslintrc.json index 9d9c0db5..6e30a7bc 100644 --- a/src/packages/generate-license-file-webpack-plugin/.eslintrc.json +++ b/src/packages/generate-license-file-webpack-plugin/.eslintrc.json @@ -2,6 +2,13 @@ "extends": ["../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ + { + "files": ["{package,project}.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + }, { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "rules": {} diff --git a/src/packages/generate-license-file-webpack-plugin/package.json b/src/packages/generate-license-file-webpack-plugin/package.json index 84a0ad6a..d542f732 100644 --- a/src/packages/generate-license-file-webpack-plugin/package.json +++ b/src/packages/generate-license-file-webpack-plugin/package.json @@ -1,6 +1,6 @@ { "name": "generate-license-file-webpack-plugin", - "version": "0.0.0", + "version": "*", "main": "src/index.js", "license": "ISC", "description": "Webpack plugin to generate a text file asset containing all of the licenses for your production third-party dependencies.", @@ -36,5 +36,10 @@ }, "files": [ "src" - ] + ], + "dependencies": { + "webpack": "^5.75.0", + "tslib": "^2.3.0", + "generate-license-file": "*" + } } diff --git a/src/packages/generate-license-file-webpack-plugin/project.json b/src/packages/generate-license-file-webpack-plugin/project.json index 797d3354..ddbafe6b 100644 --- a/src/packages/generate-license-file-webpack-plugin/project.json +++ b/src/packages/generate-license-file-webpack-plugin/project.json @@ -31,7 +31,11 @@ "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/generate-license-file-webpack-plugin/**/*.ts"], + "lintFilePatterns": [ + "packages/generate-license-file-webpack-plugin/**/*.ts", + "packages/generate-license-file-webpack-plugin/package.json", + "packages/generate-license-file-webpack-plugin/project.json" + ], "maxWarnings": 0 } }, diff --git a/src/packages/generate-license-file/.eslintrc.json b/src/packages/generate-license-file/.eslintrc.json index 9d9c0db5..6e30a7bc 100644 --- a/src/packages/generate-license-file/.eslintrc.json +++ b/src/packages/generate-license-file/.eslintrc.json @@ -2,6 +2,13 @@ "extends": ["../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ + { + "files": ["{package,project}.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + }, { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], "rules": {} diff --git a/src/packages/generate-license-file/package.json b/src/packages/generate-license-file/package.json index b69e03ca..53f885c6 100644 --- a/src/packages/generate-license-file/package.json +++ b/src/packages/generate-license-file/package.json @@ -1,6 +1,6 @@ { "name": "generate-license-file", - "version": "0.0.0", + "version": "*", "description": "Generates a text file containing all of the licenses for your production dependencies", "main": "src/index.js", "license": "ISC", @@ -40,5 +40,17 @@ "homepage": "https://generate-license-file.js.org", "bin": { "generate-license-file": "bin/generate-license-file" + }, + "dependencies": { + "@commander-js/extra-typings": "^11.0.0", + "@npmcli/arborist": "^7.0.0", + "cli-spinners": "^2.6.0", + "cosmiconfig": "^9.0.0", + "enquirer": "^2.3.6", + "glob": "^10.3.0", + "json5": "^2.2.3", + "ora": "^5.4.1", + "tslib": "^2.3.0", + "zod": "^3.21.4" } } diff --git a/src/packages/generate-license-file/project.json b/src/packages/generate-license-file/project.json index d05b1bde..f45b5138 100644 --- a/src/packages/generate-license-file/project.json +++ b/src/packages/generate-license-file/project.json @@ -40,7 +40,11 @@ "executor": "@nx/eslint:lint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["packages/generate-license-file/**/*.ts"], + "lintFilePatterns": [ + "packages/generate-license-file/**/*.ts", + "packages/generate-license-file/package.json", + "packages/generate-license-file/project.json" + ], "maxWarnings": 0 } }, diff --git a/src/tools/scripts/version.mjs b/src/tools/scripts/version.mjs index 1b7897de..e1787152 100644 --- a/src/tools/scripts/version.mjs +++ b/src/tools/scripts/version.mjs @@ -1,6 +1,7 @@ import devkit from "@nx/devkit"; import chalk from "chalk"; -import { execSync } from "child_process"; +import { join } from "path"; +import fs from "fs/promises"; const { createProjectGraphAsync, readCachedProjectGraph } = devkit; @@ -27,6 +28,11 @@ invariant( `Could not find project "${name}" in the workspace. Is the project.json configured correctly?`, ); -process.chdir(project.data.root); +const distDir = project.data.targets.build.options.outputPath; +const distPackageJson = join(distDir, "package.json"); -execSync("npm --no-git-tag-version --allow-same-version version " + version); +await fs.access(distPackageJson); + +const packageJsonContent = await fs.readFile(distPackageJson, "utf8"); +const updatedPackageJsonContent = packageJsonContent.replace(/"\*"/g, `"${version}"`); +await fs.writeFile(distPackageJson, updatedPackageJsonContent, "utf8");