From 9c7767eff33d79783984ea7c7aad3631fefaee0a Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Fri, 28 Oct 2022 12:25:03 -0500 Subject: [PATCH 1/5] fix: remove workspace prefix when publishing packages --- commands/publish/index.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/commands/publish/index.js b/commands/publish/index.js index d4643b9b4f..f09b15e922 100644 --- a/commands/publish/index.js +++ b/commands/publish/index.js @@ -240,6 +240,7 @@ class PublishCommand extends Command { } chain = chain.then(() => this.resolveLocalDependencyLinks()); + chain = chain.then(() => this.resolveWorkspaceDependencyLinks()); chain = chain.then(() => this.annotateGitHead()); chain = chain.then(() => this.serializeChanges()); chain = chain.then(() => this.packUpdated()); @@ -551,6 +552,32 @@ class PublishCommand extends Command { }); } + resolveWorkspaceDependencyLinks() { + // resolve relative workspace: links to their actual version range + const updatesWithWorkspaceLinks = this.updates.filter((node) => + Array.from(node.localDependencies.values()).some((resolved) => !!resolved.workspaceSpec) + ); + + return pMap(updatesWithWorkspaceLinks, (node) => { + for (const [depName, resolved] of node.localDependencies) { + let depVersion; + if (resolved.workspaceAlias) { + const exactVersion = + this.updatesVersions.get(depName) || this.packageGraph.get(depName).pkg.version; + depVersion = + resolved.workspaceAlias === "*" ? exactVersion : `${resolved.workspaceAlias}${exactVersion}`; + } else { + depVersion = resolved.workspaceSpec.match(/^(workspace:)(.*)/)[2]; + } + + // it no longer matters if we mutate the shared Package instance + node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix); + } + + // writing changes to disk handled in serializeChanges() + }); + } + annotateGitHead() { try { const gitHead = this.options.gitHead || getCurrentSHA(this.execOpts); From eb3cf31cfcb395fe8ffe16e742bc2790f5fb2551 Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Fri, 28 Oct 2022 15:35:16 -0500 Subject: [PATCH 2/5] fix: retain correct prefix type --- commands/publish/index.js | 13 +++++++------ core/package/index.js | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/commands/publish/index.js b/commands/publish/index.js index f09b15e922..05dfb985be 100644 --- a/commands/publish/index.js +++ b/commands/publish/index.js @@ -561,17 +561,18 @@ class PublishCommand extends Command { return pMap(updatesWithWorkspaceLinks, (node) => { for (const [depName, resolved] of node.localDependencies) { let depVersion; + let savePrefix; if (resolved.workspaceAlias) { - const exactVersion = - this.updatesVersions.get(depName) || this.packageGraph.get(depName).pkg.version; - depVersion = - resolved.workspaceAlias === "*" ? exactVersion : `${resolved.workspaceAlias}${exactVersion}`; + depVersion = this.updatesVersions.get(depName) || this.packageGraph.get(depName).pkg.version; + savePrefix = resolved.workspaceAlias === "*" ? "" : resolved.workspaceAlias; } else { - depVersion = resolved.workspaceSpec.match(/^(workspace:)(.*)/)[2]; + const specMatch = resolved.workspaceSpec.match(/^workspace:([~|^]?)(.*)/); + savePrefix = specMatch[1]; + depVersion = specMatch[2]; } // it no longer matters if we mutate the shared Package instance - node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix); + node.pkg.updateLocalDependency(resolved, depVersion, savePrefix, { retainWorkspacePrefix: false }); } // writing changes to disk handled in serializeChanges() diff --git a/core/package/index.js b/core/package/index.js index a9609436fc..b3d7057e02 100644 --- a/core/package/index.js +++ b/core/package/index.js @@ -254,7 +254,7 @@ class Package { * @param {String} depVersion semver * @param {String} savePrefix npm_config_save_prefix */ - updateLocalDependency(resolved, depVersion, savePrefix) { + updateLocalDependency(resolved, depVersion, savePrefix, options = { retainWorkspacePrefix: true }) { const depName = resolved.name; // first, try runtime dependencies @@ -270,7 +270,7 @@ class Package { depCollection = this.devDependencies; } - if (resolved.workspaceSpec) { + if (resolved.workspaceSpec && options.retainWorkspacePrefix) { // do nothing if there is a workspace alias since they don't specify a version number if (!resolved.workspaceAlias) { const workspacePrefix = resolved.workspaceSpec.match(/^(workspace:[*|~|^]?)/)[0]; From 3e0bdc86f0d70d39c718e228bebcfaddfb91248e Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Fri, 28 Oct 2022 15:36:11 -0500 Subject: [PATCH 3/5] chore: e2e tests for publish with workspace prefixes --- .../lerna-publish-workspace-prefix.spec.ts | 234 ++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts diff --git a/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts b/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts new file mode 100644 index 0000000000..be668cdf76 --- /dev/null +++ b/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts @@ -0,0 +1,234 @@ +import { Fixture } from "../../utils/fixture"; +import { normalizeCommitSHAs, normalizeEnvironment } from "../../utils/snapshot-serializer-utils"; + +const randomInt = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min; +const randomVersion = () => `${randomInt(10, 89)}.${randomInt(10, 89)}.${randomInt(10, 89)}`; + +expect.addSnapshotSerializer({ + serialize(str: string) { + return normalizeCommitSHAs(normalizeEnvironment(str)) + .replaceAll(/integrity:\s*.*/g, "integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") + .replaceAll(/\d*B package\.json/g, "XXXB package.json") + .replaceAll(/size:\s*\d*\s?B/g, "size: XXXB") + .replaceAll(/\d*\.\d*\s?kB/g, "XXX.XXX kb"); + }, + test(val: string) { + return val != null && typeof val === "string"; + }, +}); + +describe("lerna-publish-workspace-prefix", () => { + let fixture: Fixture; + + beforeEach(async () => { + fixture = await Fixture.create({ + name: "lerna-publish-workspace-prefix", + packageManager: "npm", + initializeGit: true, + runLernaInit: true, + installDependencies: true, + }); + }); + afterEach(() => fixture.destroy()); + + describe("from-git", () => { + it("should publish to the remote registry, removing workspace: prefix from dependencies", async () => { + await fixture.lerna("create test-workspace-alias-star -y"); + await fixture.lerna("create test-workspace-alias-tilde -y"); + await fixture.lerna("create test-workspace-alias-caret -y"); + await fixture.lerna("create test-workspace-exact -y"); + await fixture.lerna("create test-workspace-compat -y"); + await fixture.lerna("create test-workspace-approx -y"); + await fixture.lerna("create test-main -y"); + + await fixture.updateJson(`packages/test-main/package.json`, (json) => ({ + ...json, + dependencies: { + ...(json.dependencies as Record), + "test-workspace-alias-star": "workspace:*", + "test-workspace-alias-tilde": "workspace:~", + "test-workspace-alias-caret": "workspace:^", + "test-workspace-exact": `workspace:0.0.0`, + "test-workspace-compat": `workspace:^0.0.0`, + "test-workspace-approx": `workspace:~0.0.0`, + }, + })); + + const version = randomVersion(); + await fixture.createInitialGitCommit(); + await fixture.exec("git push origin test-main"); + + await fixture.lerna(`version ${version} -y`); + + const output = await fixture.lerna( + "publish from-git --registry=http://localhost:4872 -y --concurrency 1" + ); + + const replaceVersion = (str: string) => str.replaceAll(version, "XX.XX.XX"); + + const unpublish = async (packageName: string) => { + const unpublishOutput = await fixture.exec( + `npm unpublish ${packageName}@${version} --force --registry=http://localhost:4872` + ); + expect(replaceVersion(unpublishOutput.combinedOutput)).toContain(`${packageName}@XX.XX.XX`); + }; + + await unpublish("test-workspace-alias-star"); + await unpublish("test-workspace-alias-tilde"); + await unpublish("test-workspace-alias-caret"); + await unpublish("test-workspace-exact"); + await unpublish("test-workspace-compat"); + await unpublish("test-workspace-approx"); + + expect(replaceVersion(output.combinedOutput)).toMatchInlineSnapshot(` + lerna notice cli v999.9.9-e2e.0 + + Found 7 packages to publish: + - test-main => XX.XX.XX + - test-workspace-alias-caret => XX.XX.XX + - test-workspace-alias-star => XX.XX.XX + - test-workspace-alias-tilde => XX.XX.XX + - test-workspace-approx => XX.XX.XX + - test-workspace-compat => XX.XX.XX + - test-workspace-exact => XX.XX.XX + + lerna info auto-confirmed + lerna info publish Publishing packages to npm... + lerna notice Skipping all user and access validation due to third-party registry + lerna notice Make sure you're authenticated properly ¯\\_(ツ)_/¯ + lerna WARN ENOLICENSE Packages test-main, test-workspace-alias-caret, test-workspace-alias-star, test-workspace-alias-tilde, test-workspace-approx, test-workspace-compat, and test-workspace-exact are missing a license. + lerna WARN ENOLICENSE One way to fix this is to add a LICENSE.md file to the root of this repository. + lerna WARN ENOLICENSE See https://choosealicense.com for additional guidance. + lerna success published test-workspace-alias-caret XX.XX.XX + lerna notice + lerna notice 📦 test-workspace-alias-caret@XX.XX.XX + lerna notice === Tarball Contents === + lerna notice 146B lib/test-workspace-alias-caret.js + lerna notice XXXB package.json + lerna notice 168B README.md + lerna notice === Tarball Details === + lerna notice name: test-workspace-alias-caret + lerna notice version: XX.XX.XX + lerna notice filename: test-workspace-alias-caret-XX.XX.XX.tgz + lerna notice package size: XXXB + lerna notice unpacked size: XXX.XXX kb + lerna notice shasum: {FULL_COMMIT_SHA} + lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + lerna notice total files: 3 + lerna notice + lerna success published test-workspace-alias-star XX.XX.XX + lerna notice + lerna notice 📦 test-workspace-alias-star@XX.XX.XX + lerna notice === Tarball Contents === + lerna notice 143B lib/test-workspace-alias-star.js + lerna notice XXXB package.json + lerna notice 165B README.md + lerna notice === Tarball Details === + lerna notice name: test-workspace-alias-star + lerna notice version: XX.XX.XX + lerna notice filename: test-workspace-alias-star-XX.XX.XX.tgz + lerna notice package size: XXXB + lerna notice unpacked size: XXX.XXX kb + lerna notice shasum: {FULL_COMMIT_SHA} + lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + lerna notice total files: 3 + lerna notice + lerna success published test-workspace-alias-tilde XX.XX.XX + lerna notice + lerna notice 📦 test-workspace-alias-tilde@XX.XX.XX + lerna notice === Tarball Contents === + lerna notice 146B lib/test-workspace-alias-tilde.js + lerna notice XXXB package.json + lerna notice 168B README.md + lerna notice === Tarball Details === + lerna notice name: test-workspace-alias-tilde + lerna notice version: XX.XX.XX + lerna notice filename: test-workspace-alias-tilde-XX.XX.XX.tgz + lerna notice package size: XXXB + lerna notice unpacked size: XXX.XXX kb + lerna notice shasum: {FULL_COMMIT_SHA} + lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + lerna notice total files: 3 + lerna notice + lerna success published test-workspace-approx XX.XX.XX + lerna notice + lerna notice 📦 test-workspace-approx@XX.XX.XX + lerna notice === Tarball Contents === + lerna notice 134B lib/test-workspace-approx.js + lerna notice XXXB package.json + lerna notice 154B README.md + lerna notice === Tarball Details === + lerna notice name: test-workspace-approx + lerna notice version: XX.XX.XX + lerna notice filename: test-workspace-approx-XX.XX.XX.tgz + lerna notice package size: XXXB + lerna notice unpacked size: XXX.XXX kb + lerna notice shasum: {FULL_COMMIT_SHA} + lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + lerna notice total files: 3 + lerna notice + lerna success published test-workspace-compat XX.XX.XX + lerna notice + lerna notice 📦 test-workspace-compat@XX.XX.XX + lerna notice === Tarball Contents === + lerna notice 134B lib/test-workspace-compat.js + lerna notice XXXB package.json + lerna notice 154B README.md + lerna notice === Tarball Details === + lerna notice name: test-workspace-compat + lerna notice version: XX.XX.XX + lerna notice filename: test-workspace-compat-XX.XX.XX.tgz + lerna notice package size: XXXB + lerna notice unpacked size: XXX.XXX kb + lerna notice shasum: {FULL_COMMIT_SHA} + lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + lerna notice total files: 3 + lerna notice + lerna success published test-workspace-exact XX.XX.XX + lerna notice + lerna notice 📦 test-workspace-exact@XX.XX.XX + lerna notice === Tarball Contents === + lerna notice 131B lib/test-workspace-exact.js + lerna notice XXXB package.json + lerna notice 151B README.md + lerna notice === Tarball Details === + lerna notice name: test-workspace-exact + lerna notice version: XX.XX.XX + lerna notice filename: test-workspace-exact-XX.XX.XX.tgz + lerna notice package size: XXXB + lerna notice unpacked size: XXX.XXX kb + lerna notice shasum: {FULL_COMMIT_SHA} + lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + lerna notice total files: 3 + lerna notice + lerna success published test-main XX.XX.XX + lerna notice + lerna notice 📦 test-main@XX.XX.XX + lerna notice === Tarball Contents === + lerna notice 101B lib/test-main.js + lerna notice 1.1kXXXB package.json + lerna notice 119B README.md + lerna notice === Tarball Details === + lerna notice name: test-main + lerna notice version: XX.XX.XX + lerna notice filename: test-main-XX.XX.XX.tgz + lerna notice package size: XXXB + lerna notice unpacked size: XXX.XXX kb + lerna notice shasum: {FULL_COMMIT_SHA} + lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + lerna notice total files: 3 + lerna notice + Successfully published: + - test-main@XX.XX.XX + - test-workspace-alias-caret@XX.XX.XX + - test-workspace-alias-star@XX.XX.XX + - test-workspace-alias-tilde@XX.XX.XX + - test-workspace-approx@XX.XX.XX + - test-workspace-compat@XX.XX.XX + - test-workspace-exact@XX.XX.XX + lerna success published 7 packages + + `); + }); + }); +}); From bea92a140d571800760ed19aaa1787daf422195a Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Mon, 31 Oct 2022 10:37:16 -0500 Subject: [PATCH 4/5] chore(e2e): fix size replacement regex chore(e2e): fix package json size mismatch in regex chore(e2e): support larger package.json files --- commands/publish/index.js | 2 +- core/package/index.js | 2 +- .../lerna-publish-workspace-prefix.spec.ts | 93 +++++++++++-------- 3 files changed, 55 insertions(+), 42 deletions(-) diff --git a/commands/publish/index.js b/commands/publish/index.js index 05dfb985be..a9372139c6 100644 --- a/commands/publish/index.js +++ b/commands/publish/index.js @@ -566,7 +566,7 @@ class PublishCommand extends Command { depVersion = this.updatesVersions.get(depName) || this.packageGraph.get(depName).pkg.version; savePrefix = resolved.workspaceAlias === "*" ? "" : resolved.workspaceAlias; } else { - const specMatch = resolved.workspaceSpec.match(/^workspace:([~|^]?)(.*)/); + const specMatch = resolved.workspaceSpec.match(/^workspace:([~^]?)(.*)/); savePrefix = specMatch[1]; depVersion = specMatch[2]; } diff --git a/core/package/index.js b/core/package/index.js index b3d7057e02..0a9ac3e673 100644 --- a/core/package/index.js +++ b/core/package/index.js @@ -273,7 +273,7 @@ class Package { if (resolved.workspaceSpec && options.retainWorkspacePrefix) { // do nothing if there is a workspace alias since they don't specify a version number if (!resolved.workspaceAlias) { - const workspacePrefix = resolved.workspaceSpec.match(/^(workspace:[*|~|^]?)/)[0]; + const workspacePrefix = resolved.workspaceSpec.match(/^(workspace:[*~^]?)/)[0]; depCollection[depName] = `${workspacePrefix}${depVersion}`; } } else if (resolved.registry || resolved.type === "directory") { diff --git a/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts b/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts index be668cdf76..a31a57007b 100644 --- a/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts +++ b/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts @@ -1,3 +1,4 @@ +import { writeJsonFile } from "@nrwl/devkit"; import { Fixture } from "../../utils/fixture"; import { normalizeCommitSHAs, normalizeEnvironment } from "../../utils/snapshot-serializer-utils"; @@ -8,9 +9,7 @@ expect.addSnapshotSerializer({ serialize(str: string) { return normalizeCommitSHAs(normalizeEnvironment(str)) .replaceAll(/integrity:\s*.*/g, "integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") - .replaceAll(/\d*B package\.json/g, "XXXB package.json") - .replaceAll(/size:\s*\d*\s?B/g, "size: XXXB") - .replaceAll(/\d*\.\d*\s?kB/g, "XXX.XXX kb"); + .replaceAll(/\d*\.?\d+\s?[KMGTkmgt]?B/g, "XXXB"); }, test(val: string) { return val != null && typeof val === "string"; @@ -29,7 +28,7 @@ describe("lerna-publish-workspace-prefix", () => { installDependencies: true, }); }); - afterEach(() => fixture.destroy()); + // afterEach(() => fixture.destroy()); describe("from-git", () => { it("should publish to the remote registry, removing workspace: prefix from dependencies", async () => { @@ -73,13 +72,6 @@ describe("lerna-publish-workspace-prefix", () => { expect(replaceVersion(unpublishOutput.combinedOutput)).toContain(`${packageName}@XX.XX.XX`); }; - await unpublish("test-workspace-alias-star"); - await unpublish("test-workspace-alias-tilde"); - await unpublish("test-workspace-alias-caret"); - await unpublish("test-workspace-exact"); - await unpublish("test-workspace-compat"); - await unpublish("test-workspace-approx"); - expect(replaceVersion(output.combinedOutput)).toMatchInlineSnapshot(` lerna notice cli v999.9.9-e2e.0 @@ -103,15 +95,15 @@ describe("lerna-publish-workspace-prefix", () => { lerna notice lerna notice 📦 test-workspace-alias-caret@XX.XX.XX lerna notice === Tarball Contents === - lerna notice 146B lib/test-workspace-alias-caret.js + lerna notice XXXB lib/test-workspace-alias-caret.js lerna notice XXXB package.json - lerna notice 168B README.md + lerna notice XXXB README.md lerna notice === Tarball Details === lerna notice name: test-workspace-alias-caret lerna notice version: XX.XX.XX lerna notice filename: test-workspace-alias-caret-XX.XX.XX.tgz - lerna notice package size: XXXB - lerna notice unpacked size: XXX.XXX kb + lerna notice package size: XXXB + lerna notice unpacked size: XXXB lerna notice shasum: {FULL_COMMIT_SHA} lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX lerna notice total files: 3 @@ -120,15 +112,15 @@ describe("lerna-publish-workspace-prefix", () => { lerna notice lerna notice 📦 test-workspace-alias-star@XX.XX.XX lerna notice === Tarball Contents === - lerna notice 143B lib/test-workspace-alias-star.js + lerna notice XXXB lib/test-workspace-alias-star.js lerna notice XXXB package.json - lerna notice 165B README.md + lerna notice XXXB README.md lerna notice === Tarball Details === lerna notice name: test-workspace-alias-star lerna notice version: XX.XX.XX lerna notice filename: test-workspace-alias-star-XX.XX.XX.tgz - lerna notice package size: XXXB - lerna notice unpacked size: XXX.XXX kb + lerna notice package size: XXXB + lerna notice unpacked size: XXXB lerna notice shasum: {FULL_COMMIT_SHA} lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX lerna notice total files: 3 @@ -137,15 +129,15 @@ describe("lerna-publish-workspace-prefix", () => { lerna notice lerna notice 📦 test-workspace-alias-tilde@XX.XX.XX lerna notice === Tarball Contents === - lerna notice 146B lib/test-workspace-alias-tilde.js + lerna notice XXXB lib/test-workspace-alias-tilde.js lerna notice XXXB package.json - lerna notice 168B README.md + lerna notice XXXB README.md lerna notice === Tarball Details === lerna notice name: test-workspace-alias-tilde lerna notice version: XX.XX.XX lerna notice filename: test-workspace-alias-tilde-XX.XX.XX.tgz - lerna notice package size: XXXB - lerna notice unpacked size: XXX.XXX kb + lerna notice package size: XXXB + lerna notice unpacked size: XXXB lerna notice shasum: {FULL_COMMIT_SHA} lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX lerna notice total files: 3 @@ -154,15 +146,15 @@ describe("lerna-publish-workspace-prefix", () => { lerna notice lerna notice 📦 test-workspace-approx@XX.XX.XX lerna notice === Tarball Contents === - lerna notice 134B lib/test-workspace-approx.js + lerna notice XXXB lib/test-workspace-approx.js lerna notice XXXB package.json - lerna notice 154B README.md + lerna notice XXXB README.md lerna notice === Tarball Details === lerna notice name: test-workspace-approx lerna notice version: XX.XX.XX lerna notice filename: test-workspace-approx-XX.XX.XX.tgz - lerna notice package size: XXXB - lerna notice unpacked size: XXX.XXX kb + lerna notice package size: XXXB + lerna notice unpacked size: XXXB lerna notice shasum: {FULL_COMMIT_SHA} lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX lerna notice total files: 3 @@ -171,15 +163,15 @@ describe("lerna-publish-workspace-prefix", () => { lerna notice lerna notice 📦 test-workspace-compat@XX.XX.XX lerna notice === Tarball Contents === - lerna notice 134B lib/test-workspace-compat.js + lerna notice XXXB lib/test-workspace-compat.js lerna notice XXXB package.json - lerna notice 154B README.md + lerna notice XXXB README.md lerna notice === Tarball Details === lerna notice name: test-workspace-compat lerna notice version: XX.XX.XX lerna notice filename: test-workspace-compat-XX.XX.XX.tgz - lerna notice package size: XXXB - lerna notice unpacked size: XXX.XXX kb + lerna notice package size: XXXB + lerna notice unpacked size: XXXB lerna notice shasum: {FULL_COMMIT_SHA} lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX lerna notice total files: 3 @@ -188,15 +180,15 @@ describe("lerna-publish-workspace-prefix", () => { lerna notice lerna notice 📦 test-workspace-exact@XX.XX.XX lerna notice === Tarball Contents === - lerna notice 131B lib/test-workspace-exact.js + lerna notice XXXB lib/test-workspace-exact.js lerna notice XXXB package.json - lerna notice 151B README.md + lerna notice XXXB README.md lerna notice === Tarball Details === lerna notice name: test-workspace-exact lerna notice version: XX.XX.XX lerna notice filename: test-workspace-exact-XX.XX.XX.tgz - lerna notice package size: XXXB - lerna notice unpacked size: XXX.XXX kb + lerna notice package size: XXXB + lerna notice unpacked size: XXXB lerna notice shasum: {FULL_COMMIT_SHA} lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX lerna notice total files: 3 @@ -205,15 +197,15 @@ describe("lerna-publish-workspace-prefix", () => { lerna notice lerna notice 📦 test-main@XX.XX.XX lerna notice === Tarball Contents === - lerna notice 101B lib/test-main.js - lerna notice 1.1kXXXB package.json - lerna notice 119B README.md + lerna notice XXXB lib/test-main.js + lerna notice XXXB package.json + lerna notice XXXB README.md lerna notice === Tarball Details === lerna notice name: test-main lerna notice version: XX.XX.XX lerna notice filename: test-main-XX.XX.XX.tgz - lerna notice package size: XXXB - lerna notice unpacked size: XXX.XXX kb + lerna notice package size: XXXB + lerna notice unpacked size: XXXB lerna notice shasum: {FULL_COMMIT_SHA} lerna notice integrity: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX lerna notice total files: 3 @@ -229,6 +221,27 @@ describe("lerna-publish-workspace-prefix", () => { lerna success published 7 packages `); + + await fixture.exec("mkdir test-install-published-packages"); + writeJsonFile(fixture.getWorkspacePath("test-install-published-packages/package.json"), { + name: "test-install-published-packages", + dependencies: { + "test-main": version, + }, + }); + + // ensure that the published packages can be installed + // this verifies the validity of the updated package.json file that was published by `lerna publish` + await fixture.exec( + "npm --prefix ./test-install-published-packages install --registry=http://localhost:4872" + ); + + await unpublish("test-workspace-alias-star"); + await unpublish("test-workspace-alias-tilde"); + await unpublish("test-workspace-alias-caret"); + await unpublish("test-workspace-exact"); + await unpublish("test-workspace-compat"); + await unpublish("test-workspace-approx"); }); }); }); From 2dfe55e1b936d5c4bf68e7c3c3ebf68100bb0669 Mon Sep 17 00:00:00 2001 From: Austin Fahsl Date: Mon, 31 Oct 2022 12:35:52 -0500 Subject: [PATCH 5/5] chore(e2e): remove commented out fixture destroy --- ...refix.spec.ts => lerna-publish-npm-workspace-prefix.spec.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename e2e/tests/lerna-publish/{lerna-publish-workspace-prefix.spec.ts => lerna-publish-npm-workspace-prefix.spec.ts} (99%) diff --git a/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts b/e2e/tests/lerna-publish/lerna-publish-npm-workspace-prefix.spec.ts similarity index 99% rename from e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts rename to e2e/tests/lerna-publish/lerna-publish-npm-workspace-prefix.spec.ts index a31a57007b..ae12a83164 100644 --- a/e2e/tests/lerna-publish/lerna-publish-workspace-prefix.spec.ts +++ b/e2e/tests/lerna-publish/lerna-publish-npm-workspace-prefix.spec.ts @@ -28,7 +28,7 @@ describe("lerna-publish-workspace-prefix", () => { installDependencies: true, }); }); - // afterEach(() => fixture.destroy()); + afterEach(() => fixture.destroy()); describe("from-git", () => { it("should publish to the remote registry, removing workspace: prefix from dependencies", async () => {