Skip to content

Commit 5ee5cf7

Browse files
correctly stringify ident
1 parent a592371 commit 5ee5cf7

File tree

3 files changed

+56
-8
lines changed

3 files changed

+56
-8
lines changed

.yarn/versions/2a82f92f.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/plugin-npm-cli": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-init"
11+
- "@yarnpkg/plugin-interactive-tools"
12+
- "@yarnpkg/plugin-nm"
13+
- "@yarnpkg/plugin-pack"
14+
- "@yarnpkg/plugin-patch"
15+
- "@yarnpkg/plugin-pnp"
16+
- "@yarnpkg/plugin-pnpm"
17+
- "@yarnpkg/plugin-stage"
18+
- "@yarnpkg/plugin-typescript"
19+
- "@yarnpkg/plugin-version"
20+
- "@yarnpkg/plugin-workspace-tools"
21+
- "@yarnpkg/builder"
22+
- "@yarnpkg/core"
23+
- "@yarnpkg/doctor"

packages/acceptance-tests/pkg-tests-specs/sources/commands/publish.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,31 @@ describe(`publish`, () => {
125125
expect(Array.isArray(result.files)).toBe(true);
126126
}));
127127

128+
test(`should correctly log name of scoped workspace`, makeTemporaryEnv({
129+
name: `@scope/json-test`,
130+
version: `1.0.0`,
131+
}, async ({path, run, source}) => {
132+
await run(`install`);
133+
134+
const {stdout} = await run(`npm`, `publish`, `--json`, `--dry-run`, `--tolerate-republish`);
135+
const jsonObjects = misc.parseJsonStream(stdout);
136+
const result = jsonObjects.find((obj: any) => obj.name && obj.version);
137+
138+
expect(result).toBeDefined();
139+
expect(result).toHaveProperty(`name`, `@scope/json-test`);
140+
expect(result).toHaveProperty(`version`, `1.0.0`);
141+
expect(result).toHaveProperty(`dryRun`, true);
142+
expect(result).toHaveProperty(`registry`);
143+
expect(result).toHaveProperty(`published`, false);
144+
expect(result).toHaveProperty(`message`);
145+
146+
expect(result).toHaveProperty(`tag`);
147+
expect(result).toHaveProperty(`provenance`);
148+
149+
expect(result).toHaveProperty(`files`);
150+
expect(Array.isArray(result.files)).toBe(true);
151+
}));
152+
128153
testIf(
129154
() => !!process.env.ACTIONS_ID_TOKEN_REQUEST_URL,
130155
`should publish a package with a valid provenance statement`,

packages/plugin-npm-cli/sources/commands/npm/publish.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {BaseCommand, WorkspaceRequiredError} from '@yarnpkg/cli';
2-
import {Configuration, MessageName, Project, ReportError, StreamReport, scriptUtils, miscUtils} from '@yarnpkg/core';
3-
import {npath} from '@yarnpkg/fslib';
4-
import {npmConfigUtils, npmHttpUtils, npmPublishUtils} from '@yarnpkg/plugin-npm';
5-
import {packUtils} from '@yarnpkg/plugin-pack';
6-
import {Command, Option, Usage, UsageError} from 'clipanion';
1+
import {BaseCommand, WorkspaceRequiredError} from '@yarnpkg/cli';
2+
import {Configuration, MessageName, Project, ReportError, StreamReport, scriptUtils, miscUtils, structUtils} from '@yarnpkg/core';
3+
import {npath} from '@yarnpkg/fslib';
4+
import {npmConfigUtils, npmHttpUtils, npmPublishUtils} from '@yarnpkg/plugin-npm';
5+
import {packUtils} from '@yarnpkg/plugin-pack';
6+
import {Command, Option, Usage, UsageError} from 'clipanion';
77

88
// eslint-disable-next-line arca/no-default-export
99
export default class NpmPublishCommand extends BaseCommand {
@@ -97,7 +97,7 @@ export default class NpmPublishCommand extends BaseCommand {
9797
const warning = `Registry already knows about version ${version}; skipping.`;
9898
report.reportWarning(MessageName.UNNAMED, warning);
9999
report.reportJson({
100-
name: ident.name,
100+
name: structUtils.stringifyIdent(ident),
101101
version,
102102
registry,
103103
warning,
@@ -176,7 +176,7 @@ export default class NpmPublishCommand extends BaseCommand {
176176

177177
report.reportInfo(MessageName.UNNAMED, finalMessage);
178178
report.reportJson({
179-
name: ident.name,
179+
name: structUtils.stringifyIdent(ident),
180180
version,
181181
registry,
182182
tag: this.tag || `latest`,

0 commit comments

Comments
 (0)