X Tutup
Skip to content

Commit 67d966d

Browse files
committed
adding apply git tags on pack option
1 parent 87d9f35 commit 67d966d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

apps/rush-lib/src/cli/actions/PublishAction.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class PublishAction extends BaseRushAction {
4646
private _force: CommandLineFlagParameter;
4747
private _prereleaseToken: PrereleaseToken;
4848
private _versionPolicy: CommandLineStringParameter;
49+
private _applyGitTagsOnPack: CommandLineFlagParameter;
4950

5051
private _releaseFolder: CommandLineStringParameter;
5152
private _pack: CommandLineFlagParameter;
@@ -180,6 +181,12 @@ export class PublishAction extends BaseRushAction {
180181
parameterShortName: undefined,
181182
description: 'If this flag is specified with --publish, packages will be published with --force on npm'
182183
});
184+
this._applyGitTagsOnPack = this.defineFlagParameter({
185+
parameterLongName: '--apply-git-tags-on-pack',
186+
parameterShortName: undefined,
187+
description: `If specified with --publish and --pack, git tags will be applied for packages on pack` +
188+
` as if a publish was being run without --pack.`
189+
});
183190
}
184191

185192
/**
@@ -312,14 +319,23 @@ export class PublishAction extends BaseRushAction {
312319
if (packageConfig.shouldPublish &&
313320
(!this._versionPolicy.value || this._versionPolicy.value === packageConfig.versionPolicyName)
314321
) {
322+
const applyTag: (apply: boolean) => void = (apply: boolean): void => {
323+
if (!apply) {
324+
return;
325+
}
326+
327+
git.addTag(!!this._publish.value && !this._registryUrl.value, packageName, packageConfig.packageJson.version);
328+
updated = true;
329+
};
330+
315331
if (this._pack.value) {
316332
// packs to tarball instead of publishing to NPM repository
317333
this._npmPack(packageName, packageConfig);
334+
applyTag(this._applyGitTagsOnPack.value);
318335
} else if (this._force.value || !this._packageExists(packageConfig)) {
319336
// Publish to npm repository
320337
this._npmPublish(packageName, packageConfig.projectFolder);
321-
git.addTag(!!this._publish.value && !this._registryUrl.value, packageName, packageConfig.packageJson.version);
322-
updated = true;
338+
applyTag(true);
323339
} else {
324340
console.log(`Skip ${packageName}. Not updated.`);
325341
}

apps/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ exports[`CommandLineHelp prints the help for each action: publish 1`] = `
343343
[--release-folder FOLDER] [--include-all]
344344
[--version-policy POLICY] [--prerelease-name NAME]
345345
[--partial-prerelease] [--suffix SUFFIX] [--force]
346+
[--apply-git-tags-on-pack]
346347
347348
348349
Reads and processes package publishing change requests generated by \\"rush
@@ -412,6 +413,10 @@ Optional arguments:
412413
used with --prerelease-name.
413414
--force If this flag is specified with --publish, packages
414415
will be published with --force on npm
416+
--apply-git-tags-on-pack
417+
If specified with --publish and --pack, git tags will
418+
be applied for packages on pack as if a publish was
419+
being run without --pack.
415420
"
416421
`;
417422

0 commit comments

Comments
 (0)
X Tutup