From 473cbc44db2659d81b0d34b156cbf56479dffddf Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 20 Nov 2024 11:43:52 +0100 Subject: [PATCH 1/2] fix: publish --json (#8789) close #8788 --- .changeset/witty-seahorses-cough.md | 6 ++ .../plugin-commands-publishing/src/pack.ts | 57 ++++++++++++------- .../plugin-commands-publishing/src/publish.ts | 4 +- 3 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 .changeset/witty-seahorses-cough.md diff --git a/.changeset/witty-seahorses-cough.md b/.changeset/witty-seahorses-cough.md new file mode 100644 index 00000000000..85a87f80647 --- /dev/null +++ b/.changeset/witty-seahorses-cough.md @@ -0,0 +1,6 @@ +--- +"@pnpm/plugin-commands-publishing": patch +"pnpm": patch +--- + +`pnpm publish --json` should work [#8788](https://github.com/pnpm/pnpm/issues/8788). diff --git a/releasing/plugin-commands-publishing/src/pack.ts b/releasing/plugin-commands-publishing/src/pack.ts index a66be0256df..a6cb31c0c5f 100644 --- a/releasing/plugin-commands-publishing/src/pack.ts +++ b/releasing/plugin-commands-publishing/src/pack.ts @@ -64,17 +64,34 @@ export function help (): string { }) } -export async function handler ( - opts: Pick & Pick & Partial> & { - argv: { - original: string[] - } - engineStrict?: boolean - packDestination?: string - workspaceDir?: string - json?: boolean +export type PackOptions = Pick & Pick & Partial> & { + argv: { + original: string[] + } + engineStrict?: boolean + packDestination?: string + workspaceDir?: string + json?: boolean +} + +export async function handler (opts: PackOptions): Promise { + const { publishedManifest, tarballPath, contents } = await api(opts) + if (opts.json) { + return JSON.stringify({ + name: publishedManifest.name, + version: publishedManifest.version, + filename: tarballPath, + files: contents.map((path) => ({ path })), + }, null, 2) } -): Promise { + return `${chalk.blueBright('Tarball Contents')} +${contents.join('\n')} + +${chalk.blueBright('Tarball Details')} +${tarballPath}` +} + +export async function api (opts: PackOptions): Promise { const { manifest: entryManifest, fileName: manifestFileName } = await readProjectManifest(opts.dir, opts) preventBundledDependenciesWithoutHoistedNodeLinker(opts.nodeLinker, entryManifest) const _runScriptsIfPresent = runScriptsIfPresent.bind(null, { @@ -152,19 +169,17 @@ export async function handler ( packedTarballPath = path.relative(opts.dir, path.join(dir, tarballName)) } const packedContents = files.sort((a, b) => a.localeCompare(b, 'en')) - if (opts.json) { - return JSON.stringify({ - name: publishManifest.name, - version: publishManifest.version, - filename: packedTarballPath, - files: packedContents.map((path) => ({ path })), - }, null, 2) + return { + publishedManifest: publishManifest, + contents: packedContents, + tarballPath: packedTarballPath, } - return `${chalk.blueBright('Tarball Contents')} -${packedContents.join('\n')} +} -${chalk.blueBright('Tarball Details')} -${packedTarballPath}` +export interface PackResult { + publishedManifest: ProjectManifest + contents: string[] + tarballPath: string } function preventBundledDependenciesWithoutHoistedNodeLinker (nodeLinker: Config['nodeLinker'], manifest: ProjectManifest): void { diff --git a/releasing/plugin-commands-publishing/src/publish.ts b/releasing/plugin-commands-publishing/src/publish.ts index 6825cb8a33d..a6a5121cc4e 100644 --- a/releasing/plugin-commands-publishing/src/publish.ts +++ b/releasing/plugin-commands-publishing/src/publish.ts @@ -237,13 +237,13 @@ Do you want to continue?`, // from the current working directory, ignoring the package.json file // that was generated and packed to the tarball. const packDestination = tempy.directory() - const tarballName = await pack.handler({ + const { tarballPath } = await pack.api({ ...opts, dir, packDestination, }) await copyNpmrc({ dir, workspaceDir: opts.workspaceDir, packDestination }) - const { status } = runNpm(opts.npmPath, ['publish', '--ignore-scripts', path.basename(tarballName), ...args], { + const { status } = runNpm(opts.npmPath, ['publish', '--ignore-scripts', path.basename(tarballPath), ...args], { cwd: packDestination, env: getEnvWithTokens(opts), }) From 1f371d1fbe89d95d813c3649f71936cfc663ae8b Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 20 Nov 2024 11:54:57 +0100 Subject: [PATCH 2/2] chore(release): 9.14.2 --- .changeset/witty-seahorses-cough.md | 6 ------ pnpm/CHANGELOG.md | 6 ++++++ pnpm/artifacts/exe/package.json | 2 +- pnpm/artifacts/linux-arm64/package.json | 2 +- pnpm/artifacts/linux-x64/package.json | 2 +- pnpm/artifacts/macos-arm64/package.json | 2 +- pnpm/artifacts/macos-x64/package.json | 2 +- pnpm/artifacts/win-arm64/package.json | 2 +- pnpm/artifacts/win-x64/package.json | 2 +- pnpm/package.json | 2 +- releasing/plugin-commands-publishing/CHANGELOG.md | 6 ++++++ releasing/plugin-commands-publishing/package.json | 2 +- 12 files changed, 21 insertions(+), 15 deletions(-) delete mode 100644 .changeset/witty-seahorses-cough.md diff --git a/.changeset/witty-seahorses-cough.md b/.changeset/witty-seahorses-cough.md deleted file mode 100644 index 85a87f80647..00000000000 --- a/.changeset/witty-seahorses-cough.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@pnpm/plugin-commands-publishing": patch -"pnpm": patch ---- - -`pnpm publish --json` should work [#8788](https://github.com/pnpm/pnpm/issues/8788). diff --git a/pnpm/CHANGELOG.md b/pnpm/CHANGELOG.md index b7d96c5ce02..57d6a38bf9b 100644 --- a/pnpm/CHANGELOG.md +++ b/pnpm/CHANGELOG.md @@ -1,5 +1,11 @@ # pnpm +## 9.14.2 + +### Patch Changes + +- `pnpm publish --json` should work [#8788](https://github.com/pnpm/pnpm/issues/8788). + ## 9.14.1 ### Minor Changes diff --git a/pnpm/artifacts/exe/package.json b/pnpm/artifacts/exe/package.json index 25264b4723b..f7925004bea 100644 --- a/pnpm/artifacts/exe/package.json +++ b/pnpm/artifacts/exe/package.json @@ -1,7 +1,7 @@ { "name": "@pnpm/exe", "description": "Fast, disk space efficient package manager", - "version": "9.14.1", + "version": "9.14.2", "publishConfig": { "tag": "next-9", "bin": { diff --git a/pnpm/artifacts/linux-arm64/package.json b/pnpm/artifacts/linux-arm64/package.json index 758a3cdfa7d..73ae93f40a6 100644 --- a/pnpm/artifacts/linux-arm64/package.json +++ b/pnpm/artifacts/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/linux-arm64", - "version": "9.14.1", + "version": "9.14.2", "license": "MIT", "publishConfig": { "bin": { diff --git a/pnpm/artifacts/linux-x64/package.json b/pnpm/artifacts/linux-x64/package.json index b43d25d555f..0e955350889 100644 --- a/pnpm/artifacts/linux-x64/package.json +++ b/pnpm/artifacts/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/linux-x64", - "version": "9.14.1", + "version": "9.14.2", "license": "MIT", "publishConfig": { "bin": { diff --git a/pnpm/artifacts/macos-arm64/package.json b/pnpm/artifacts/macos-arm64/package.json index 5b140ab5f79..e4c63d994e2 100644 --- a/pnpm/artifacts/macos-arm64/package.json +++ b/pnpm/artifacts/macos-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/macos-arm64", - "version": "9.14.1", + "version": "9.14.2", "license": "MIT", "publishConfig": { "bin": { diff --git a/pnpm/artifacts/macos-x64/package.json b/pnpm/artifacts/macos-x64/package.json index 8e582ce7372..21f104e131c 100644 --- a/pnpm/artifacts/macos-x64/package.json +++ b/pnpm/artifacts/macos-x64/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/macos-x64", - "version": "9.14.1", + "version": "9.14.2", "license": "MIT", "publishConfig": { "bin": { diff --git a/pnpm/artifacts/win-arm64/package.json b/pnpm/artifacts/win-arm64/package.json index 1759bd668ce..c3cc68dbe36 100644 --- a/pnpm/artifacts/win-arm64/package.json +++ b/pnpm/artifacts/win-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/win-arm64", - "version": "9.14.1", + "version": "9.14.2", "license": "MIT", "publishConfig": { "bin": { diff --git a/pnpm/artifacts/win-x64/package.json b/pnpm/artifacts/win-x64/package.json index 71029dae12c..278eb3a8afa 100644 --- a/pnpm/artifacts/win-x64/package.json +++ b/pnpm/artifacts/win-x64/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/win-x64", - "version": "9.14.1", + "version": "9.14.2", "license": "MIT", "publishConfig": { "bin": { diff --git a/pnpm/package.json b/pnpm/package.json index 36f27113a84..c6cb1cf0d3a 100644 --- a/pnpm/package.json +++ b/pnpm/package.json @@ -1,7 +1,7 @@ { "name": "pnpm", "description": "Fast, disk space efficient package manager", - "version": "9.14.1", + "version": "9.14.2", "bin": { "pnpm": "bin/pnpm.cjs", "pnpx": "bin/pnpx.cjs" diff --git a/releasing/plugin-commands-publishing/CHANGELOG.md b/releasing/plugin-commands-publishing/CHANGELOG.md index dd33849f28d..ac1f1c13409 100644 --- a/releasing/plugin-commands-publishing/CHANGELOG.md +++ b/releasing/plugin-commands-publishing/CHANGELOG.md @@ -1,5 +1,11 @@ # @pnpm/plugin-commands-publishing +## 10.1.1 + +### Patch Changes + +- 473cbc4: `pnpm publish --json` should work [#8788](https://github.com/pnpm/pnpm/issues/8788). + ## 10.1.0 ### Minor Changes diff --git a/releasing/plugin-commands-publishing/package.json b/releasing/plugin-commands-publishing/package.json index a2fb2be382f..33cdf900e86 100644 --- a/releasing/plugin-commands-publishing/package.json +++ b/releasing/plugin-commands-publishing/package.json @@ -1,6 +1,6 @@ { "name": "@pnpm/plugin-commands-publishing", - "version": "10.1.0", + "version": "10.1.1", "description": "The pack and publish commands of pnpm", "main": "lib/index.js", "types": "lib/index.d.ts",