Skip to content

Commit

Permalink
Merge pull request #1175 from raygesualdo/partial-prereleases
Browse files Browse the repository at this point in the history
[rush] added partial prerelease functionality
  • Loading branch information
octogonz authored Mar 22, 2019
2 parents f41319f + 7d57040 commit 6218332
Show file tree
Hide file tree
Showing 61 changed files with 665 additions and 6 deletions.
12 changes: 11 additions & 1 deletion apps/rush-lib/src/cli/actions/PublishAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class PublishAction extends BaseRushAction {
private _registryUrl: CommandLineStringParameter;
private _targetBranch: CommandLineStringParameter;
private _prereleaseName: CommandLineStringParameter;
private _partialPrerelease: CommandLineFlagParameter;
private _suffix: CommandLineStringParameter;
private _force: CommandLineFlagParameter;
private _prereleaseToken: PrereleaseToken;
Expand Down Expand Up @@ -172,6 +173,11 @@ export class PublishAction extends BaseRushAction {
argumentName: 'NAME',
description: 'Bump up to a prerelease version with the provided prerelease name. Cannot be used with --suffix'
});
this._partialPrerelease = this.defineFlagParameter({
parameterLongName: '--partial-prerelease',
parameterShortName: undefined,
description: 'Used with --prerelease-name. Only bump packages to a prerelease version if they have changes.'
});
this._suffix = this.defineStringParameter({
parameterLongName: '--suffix',
argumentName: 'SUFFIX',
Expand Down Expand Up @@ -204,7 +210,11 @@ export class PublishAction extends BaseRushAction {
if (this._includeAll.value) {
this._publishAll(allPackages);
} else {
this._prereleaseToken = new PrereleaseToken(this._prereleaseName.value, this._suffix.value);
this._prereleaseToken = new PrereleaseToken(
this._prereleaseName.value,
this._suffix.value,
this._partialPrerelease.value
);
this._publishChanges(allPackages);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ exports[`CommandLineHelp prints the help for each action: publish 1`] = `
[-t TAG] [--set-access-level {public,restricted}] [--pack]
[--release-folder FOLDER] [--release-type RELEASE_TYPE]
[--include-all] [--version-policy POLICY]
[--prerelease-name NAME] [--suffix SUFFIX] [--force]
[--prerelease-name NAME] [--partial-prerelease]
[--suffix SUFFIX] [--force]
Reads and processes package publishing change requests generated by \\"rush
Expand Down Expand Up @@ -392,6 +393,8 @@ Optional arguments:
--prerelease-name NAME
Bump up to a prerelease version with the provided
prerelease name. Cannot be used with --suffix
--partial-prerelease Used with --prerelease-name. Only bump packages to a
prerelease version if they have changes.
--suffix SUFFIX Append a suffix to all changed versions. Cannot be
used with --prerelease-name.
--force If this flag is specified with --publish, packages
Expand Down
10 changes: 8 additions & 2 deletions apps/rush-lib/src/logic/PrereleaseToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ export class PrereleaseToken {
private _name: string;
private _prereleaseName: string | undefined;
private _suffixName: string | undefined;
private _partialPrerelease: boolean;

constructor(prereleaseName?: string, suffixName?: string) {
constructor(prereleaseName?: string, suffixName?: string, partialPrerelease: boolean = false) {
if (prereleaseName && suffixName) {
throw new Error('Pre-release name and suffix cannot be provided at the same time.');
}
this._name = prereleaseName! || suffixName!;
this._prereleaseName = prereleaseName;
this._suffixName = suffixName;
this._partialPrerelease = partialPrerelease;
}

public get hasValue(): boolean {
Expand All @@ -27,7 +29,11 @@ export class PrereleaseToken {
return !!this._suffixName;
}

public get isPartialPrerelease(): boolean {
return this.isPrerelease && this._partialPrerelease;
}

public get name(): string {
return this._name;
}
}
}
17 changes: 15 additions & 2 deletions apps/rush-lib/src/logic/PublishUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,15 @@ export class PublishUtilities {
if (!depProject.shouldPublish || projectsToExclude && projectsToExclude.has(depName)) {
// No version change.
return;
} else if (
prereleaseToken &&
prereleaseToken.hasValue &&
prereleaseToken.isPartialPrerelease &&
depChange.changeType! < ChangeType.hotfix
) {
// FOr partial prereleases, do not version bump dependecies with the `prereleaseToken`
// value unless an actual change (hotfix, patch, minor, major) has occured
return;
} else if (depChange && prereleaseToken && prereleaseToken.hasValue) {
// TODO: treat prerelease version the same as non-prerelease version.
// For prelease, the newVersion needs to be appended with prerelease name.
Expand All @@ -413,14 +422,18 @@ export class PublishUtilities {
* Gets the new version from the ChangeInfo.
* The value of newVersion in ChangeInfo remains unchanged when the change type is dependency,
* However, for pre-release build, it won't pick up the updated pre-released dependencies. That is why
* this function should return a pre-released patch for that case.
* this function should return a pre-released patch for that case. The exception to this is when we're
* running a partial pre-release build. In this case, only user-changed packages should update.
*/
private static _getChangeInfoNewVersion(
change: IChangeInfo,
prereleaseToken: PrereleaseToken | undefined
): string {
let newVersion: string = change.newVersion!;
if (prereleaseToken && prereleaseToken.hasValue) {
if (prereleaseToken.isPartialPrerelease && change.changeType! <= ChangeType.hotfix) {
return newVersion;
}
if (prereleaseToken.isPrerelease && change.changeType === ChangeType.dependency) {
newVersion = semver.inc(newVersion, 'patch');
}
Expand Down Expand Up @@ -653,4 +666,4 @@ export class PublishUtilities {
rushConfiguration
);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/api-documenter",
"type": "none"
}
],
"packageName": "@microsoft/api-documenter",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/api-documenter",
"type": "none"
}
],
"packageName": "@microsoft/api-documenter",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/api-extractor-model",
"type": "none"
}
],
"packageName": "@microsoft/api-extractor-model",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/api-extractor-model",
"type": "none"
}
],
"packageName": "@microsoft/api-extractor-model",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/api-extractor",
"type": "none"
}
],
"packageName": "@microsoft/api-extractor",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/api-extractor",
"type": "none"
}
],
"packageName": "@microsoft/api-extractor",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-mocha",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-mocha",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-mocha",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-mocha",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-sass",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-sass",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-sass",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-sass",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-serve",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-serve",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-serve",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-serve",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-typescript",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-typescript",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-typescript",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-typescript",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-webpack",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-webpack",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build-webpack",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build-webpack",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/gulp-core-build",
"type": "none"
}
],
"packageName": "@microsoft/gulp-core-build",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/load-themed-styles",
"type": "none"
}
],
"packageName": "@microsoft/load-themed-styles",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/load-themed-styles",
"type": "none"
}
],
"packageName": "@microsoft/load-themed-styles",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@microsoft/loader-load-themed-styles",
"type": "none"
}
],
"packageName": "@microsoft/loader-load-themed-styles",
"email": "[email protected]"
}
Loading

0 comments on commit 6218332

Please sign in to comment.