Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .yarn/versions/d0edcb62.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
releases:
"@yarnpkg/plugin-npm": minor
"@yarnpkg/plugin-npm-cli": minor

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/cli"
- "@yarnpkg/core"
4 changes: 2 additions & 2 deletions packages/plugin-npm-cli/sources/commands/npm/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default class AuditCommand extends BaseCommand {
dependencies,
};

const registry = npmConfigUtils.getPublishRegistry(workspace.manifest, {
const registry = npmConfigUtils.getAuditRegistry(workspace.manifest, {
configuration,
});

Expand All @@ -106,7 +106,7 @@ export default class AuditCommand extends BaseCommand {
stdout: this.context.stdout,
}, async () => {
result = ((await npmHttpUtils.post(`/-/npm/v1/security/audits/quick`, body, {
authType: npmHttpUtils.AuthType.NO_AUTH,
authType: npmHttpUtils.AuthType.BEST_EFFORT,
configuration,
jsonResponse: true,
registry,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-npm-cli/sources/npmAuditUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export function getReportTree(result: npmAuditTypes.AuditResponse, severity?: np
},
Recommendation: {
label: `Recommendation`,
value: formatUtils.tuple(formatUtils.Type.NO_HINT, advisory.recommendation.replace(/\n/g, ` `)),
value: formatUtils.tuple(formatUtils.Type.NO_HINT, advisory.recommendation?.replace(/\n/g, ` `)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change clipanion will simply print Recommendation: null if a recommendation is not provided.

},
},
};
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-npm/sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const authSettings = {
};

const registrySettings = {
npmAuditRegistry: {
description: `Registry to query for audit reports`,
type: SettingsType.STRING as const,
default: null,
},
npmPublishRegistry: {
description: `Registry to push packages to`,
type: SettingsType.STRING as const,
Expand All @@ -52,6 +57,7 @@ declare module '@yarnpkg/core' {
npmAuthIdent: string | null;
npmAuthToken: string | null;

npmAuditRegistry: string | null;
npmPublishRegistry: string | null;
npmRegistryServer: string;

Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-npm/sources/npmConfigUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Configuration, Manifest, Ident} from '@yarnpkg/core';

export enum RegistryType {
AUDIT_REGISTRY = `npmAuditRegistry`,
FETCH_REGISTRY = `npmRegistryServer`,
PUBLISH_REGISTRY = `npmPublishRegistry`,
}
Expand All @@ -14,8 +15,12 @@ export function normalizeRegistry(registry: string) {
return registry.replace(/\/$/, ``);
}

export function getAuditRegistry(manifest: Manifest, {configuration}: {configuration: Configuration}) {
return getDefaultRegistry({configuration, type: RegistryType.AUDIT_REGISTRY});
}

export function getPublishRegistry(manifest: Manifest, {configuration}: {configuration: Configuration}) {
if (manifest.publishConfig && manifest.publishConfig.registry)
if (manifest.publishConfig?.registry)
return normalizeRegistry(manifest.publishConfig.registry);

if (manifest.name)
Expand Down