Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"json",
"npmaccess",
"npmtag",
"oidc",
"prerelease",
"sign",
"verify"
Expand Down
4 changes: 4 additions & 0 deletions messages/npm.package.release.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ run yarn install and build on repository

given a github tag, release the version specified in the package.json as is. Useful when you've already done a release and only need npm publish features

# flags.oidc.summary

enable OpenID Connect (OIDC) authentication for secure, token-based package publishing on npm

# flags.prerelease.summary

determine the next version as <version>-<prerelease>.0 if version is not manually set
Expand Down
5 changes: 5 additions & 0 deletions src/commands/npm/package/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export default class Release extends SfCommand<ReleaseResult> {
githubtag: Flags.string({
summary: messages.getMessage('flags.githubtag.summary'),
}),
oidc: Flags.boolean({
default: false,
summary: messages.getMessage('flags.oidc.summary'),
}),
};

public async run(): Promise<ReleaseResult> {
Expand All @@ -82,6 +86,7 @@ export default class Release extends SfCommand<ReleaseResult> {
const pkg = await PackageRepo.create({
ux: new Ux({ jsonEnabled: this.jsonEnabled() }),
useprerelease: flags.prerelease,
useoidc: flags.oidc,
});

await pkg.writeNpmToken();
Expand Down
2 changes: 1 addition & 1 deletion src/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const DEPENDENCIES: Dependency[] = [
{
name: 'NPM_TOKEN',
type: 'env',
condition: (flags): boolean => !flags.dryrun,
condition: (flags): boolean => !flags.dryrun && !flags.oidc,
},
{
name: 'GH_TOKEN',
Expand Down
3 changes: 2 additions & 1 deletion src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type PollFunction = () => boolean;
type RepositoryOptions = {
ux: Ux;
useprerelease?: string;
useoidc?: boolean;
};

abstract class Repository extends AsyncOptionalCreatable<RepositoryOptions> {
Expand Down Expand Up @@ -81,7 +82,7 @@ abstract class Repository extends AsyncOptionalCreatable<RepositoryOptions> {

public async writeNpmToken(): Promise<void> {
const home = this.env.getString('HOME') ?? os.homedir();
await this.registry.setNpmAuth(home);
if (!this.options?.useoidc) await this.registry.setNpmAuth(home);
await this.registry.setNpmRegistry(home);
}

Expand Down