Skip to content

Commit

Permalink
Fix the dependency arrays of publishable packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tobysmith568 committed Nov 28, 2023
1 parent af968a7 commit 40dfbde
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/src-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions e2e/npm-package/test/cli/index.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down Expand Up @@ -36,5 +36,10 @@
},
"files": [
"src"
]
],
"dependencies": {
"webpack": "^5.75.0",
"tslib": "^2.3.0",
"generate-license-file": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
7 changes: 7 additions & 0 deletions src/packages/generate-license-file/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
Expand Down
14 changes: 13 additions & 1 deletion src/packages/generate-license-file/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}
6 changes: 5 additions & 1 deletion src/packages/generate-license-file/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
12 changes: 9 additions & 3 deletions src/tools/scripts/version.mjs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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");

0 comments on commit 40dfbde

Please sign in to comment.