Skip to content

Release Fixes #551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 6, 2018
Merged
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
3 changes: 0 additions & 3 deletions scripts/release/utils/banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@ const readFile = promisify(_readFile);

exports.bannerText = async () => {
let BANNER_TEXT = await readFile(resolve(__dirname, 'banner.txt'), 'utf8');
if (process.platform === 'darwin') {
BANNER_TEXT = BANNER_TEXT.replace(/#/g, '🔥');
}
console.log(BANNER_TEXT);
};
47 changes: 38 additions & 9 deletions scripts/release/utils/inquirer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ exports.packageVersionUpdate = async (package, releaseType) => {
/**
* Check and see if we are trying to publish a prerelease
*/
let isPublished = await (async isStaging => {
if (isStaging) {
let { stdout } = await exec(`npm info ${package}@next version`);
return !!stdout.trim();
} else {
let { stdout } = await exec(`npm info ${package} version`);
return !stdout.includes('canary');
}
})(releaseType === 'Staging');

if (releaseType === 'Staging' && !private) {
let { stdout: nextVersion } = await exec(
`npm info ${package}@next version`
Expand All @@ -42,12 +52,11 @@ exports.packageVersionUpdate = async (package, releaseType) => {
* will break the `semver` module parsing
*/
nextVersion = nextVersion.trim();

/**
* If we are currently in a prerelease cycle, fast-forward the version
* to the prereleased version instead of the current version
*/
if (gt(nextVersion, version)) {
if (isPublished && gt(nextVersion, version)) {
version = nextVersion;
}
}
Expand All @@ -69,20 +78,40 @@ exports.packageVersionUpdate = async (package, releaseType) => {
? prereleaseVersions
: ['patch', 'minor', 'major'];

let choices;

if (isPublished) {
/**
* Will hit this codepath if we are publishing a module that has already been
* published once
*/
choices = increments.map(increment => {
const newVersion = inc(version, increment);
return {
name: chalk`${capitalize(increment)} {gray ${newVersion}}`,
value: newVersion
};
});
} else {
/**
* Will hit this codepath if this is the first prerelease of the component
*/
choices = [
{
name: chalk`Initial Release {gray ${version}}`,
value: version
}
];
}

/**
* Create prompts
*/
return {
type: 'list',
name: `${package}`,
message: `Select semver increment for ${package}`,
choices: increments.map(increment => {
const newVersion = inc(version, increment);
return {
name: chalk`${capitalize(increment)} {gray ${newVersion}}`,
value: newVersion
};
})
choices
};
};

Expand Down