Skip to content

Commit 2f236e3

Browse files
committed
feat(ng-dev): allow for a flag to override the registry used for publish
Allow for the user to override the registry used for publishing with the flag
1 parent 2ff164a commit 2f236e3

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

ng-dev/release/publish/cli.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,28 @@ import {assertValidGithubConfig, getConfig} from '../../utils/config.js';
1212
import {addGithubTokenOption} from '../../utils/git/github-yargs.js';
1313
import {assertValidReleaseConfig} from '../config/index.js';
1414

15-
import {CompletionState, ReleaseTool} from './index.js';
15+
import {CompletionState, ReleaseTool, ReleaseToolFlags} from './index.js';
1616
import {AuthenticatedGitClient} from '../../utils/git/authenticated-git-client.js';
1717
import {green, Log, yellow} from '../../utils/logging.js';
1818

1919
/** Command line options for publishing a release. */
20-
export interface ReleasePublishOptions {}
20+
export interface ReleasePublishOptions extends ReleaseToolFlags {}
2121

2222
/** Yargs command builder for configuring the `ng-dev release publish` command. */
2323
function builder(argv: Argv): Argv<ReleasePublishOptions> {
24-
return addGithubTokenOption(argv);
24+
return addGithubTokenOption(argv).option('publishRegistry', {
25+
type: 'string',
26+
});
2527
}
2628

2729
/** Yargs command handler for staging a release. */
28-
async function handler() {
30+
async function handler(flags: Arguments<ReleasePublishOptions>) {
2931
const git = await AuthenticatedGitClient.get();
3032
const config = await getConfig();
3133
assertValidReleaseConfig(config);
3234
assertValidGithubConfig(config);
3335

34-
const task = new ReleaseTool(git, config.release, config.github, git.baseDir);
36+
const task = new ReleaseTool(git, config.release, config.github, git.baseDir, flags);
3537
const result = await task.run();
3638

3739
switch (result) {

ng-dev/release/publish/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,30 @@ export enum CompletionState {
2929
MANUALLY_ABORTED,
3030
}
3131

32+
/** A set of flags available to be used to override settings at runtime. */
33+
export interface ReleaseToolFlags {
34+
publishRegistry?: string;
35+
}
36+
3237
export class ReleaseTool {
3338
/** The previous git commit to return back to after the release tool runs. */
3439
private previousGitBranchOrRevision = this._git.getCurrentBranchOrRevision();
40+
/** The release configuration for the release tool run. */
41+
protected _config: ReleaseConfig;
3542

3643
constructor(
3744
protected _git: AuthenticatedGitClient,
38-
protected _config: ReleaseConfig,
45+
config: ReleaseConfig,
3946
protected _github: GithubConfig,
4047
protected _projectRoot: string,
41-
) {}
48+
_flags: ReleaseToolFlags,
49+
) {
50+
this._config = {
51+
...config,
52+
// Replace publishRegistry in the config with one provided via flag, if provided
53+
publishRegistry: _flags.publishRegistry ?? config.publishRegistry,
54+
};
55+
}
4256

4357
/** Runs the interactive release tool. */
4458
async run(): Promise<CompletionState> {

0 commit comments

Comments
 (0)