Commit 3fc24fa9 by Dominik Prokop

Enable @grafana/ui version bump based on package.json contents

parent 358f9cbe
...@@ -30,9 +30,11 @@ program ...@@ -30,9 +30,11 @@ program
.command('gui:release') .command('gui:release')
.description('Prepares @grafana/ui release (and publishes to npm on demand)') .description('Prepares @grafana/ui release (and publishes to npm on demand)')
.option('-p, --publish', 'Publish @grafana/ui to npm registry') .option('-p, --publish', 'Publish @grafana/ui to npm registry')
.option('-u, --usePackageJsonVersion', 'Use version specified in package.json')
.action(async cmd => { .action(async cmd => {
await execTask(releaseTask)({ await execTask(releaseTask)({
publishToNpm: !!cmd.publish, publishToNpm: !!cmd.publish,
usePackageJsonVersion: !!cmd.usePackageJsonVersion,
}); });
}); });
......
...@@ -12,6 +12,7 @@ type VersionBumpType = 'prerelease' | 'patch' | 'minor' | 'major'; ...@@ -12,6 +12,7 @@ type VersionBumpType = 'prerelease' | 'patch' | 'minor' | 'major';
interface ReleaseTaskOptions { interface ReleaseTaskOptions {
publishToNpm: boolean; publishToNpm: boolean;
usePackageJsonVersion: boolean;
} }
const promptBumpType = async () => { const promptBumpType = async () => {
...@@ -93,7 +94,7 @@ const ensureMasterBranch = async () => { ...@@ -93,7 +94,7 @@ const ensureMasterBranch = async () => {
} }
}; };
const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({ publishToNpm }) => { const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({ publishToNpm, usePackageJsonVersion }) => {
if (publishToNpm) { if (publishToNpm) {
await ensureMasterBranch(); await ensureMasterBranch();
} }
...@@ -109,28 +110,40 @@ const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({ publishToNpm ...@@ -109,28 +110,40 @@ const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({ publishToNpm
console.log(`Current version: ${pkg.version}`); console.log(`Current version: ${pkg.version}`);
do { do {
const { type } = await promptBumpType(); if (!usePackageJsonVersion) {
console.log(type); const { type } = await promptBumpType();
if (type === 'prerelease') { console.log(type);
const { id } = await promptPrereleaseId('What kind of prerelease?', false); if (type === 'prerelease') {
nextVersion = semver.inc(pkg.version, type, id); const { id } = await promptPrereleaseId('What kind of prerelease?', false);
} else { nextVersion = semver.inc(pkg.version, type, id);
const { id } = await promptPrereleaseId();
if (id !== 'no') {
nextVersion = semver.inc(pkg.version, `pre${type}`, id);
} else { } else {
nextVersion = semver.inc(pkg.version, type); const { id } = await promptPrereleaseId();
if (id !== 'no') {
nextVersion = semver.inc(pkg.version, `pre${type}`, id);
} else {
nextVersion = semver.inc(pkg.version, type);
}
} }
} else {
nextVersion = pkg.version;
} }
console.log(chalk.yellowBright.bold(`You are going to release a new version of ${pkg.name}`)); console.log(chalk.yellowBright.bold(`You are going to release a new version of ${pkg.name}`));
console.log(chalk.green(`Version bump: ${pkg.version} ->`), chalk.bold.yellowBright(`${nextVersion}`));
if (usePackageJsonVersion) {
console.log(chalk.green(`Version based on package.json: `), chalk.bold.yellowBright(`${nextVersion}`));
} else {
console.log(chalk.green(`Version bump: ${pkg.version} ->`), chalk.bold.yellowBright(`${nextVersion}`));
}
const { confirmed } = await promptConfirm(); const { confirmed } = await promptConfirm();
releaseConfirmed = confirmed; releaseConfirmed = confirmed;
} while (!releaseConfirmed); } while (!releaseConfirmed);
await bumpVersion(nextVersion); if (!usePackageJsonVersion) {
await bumpVersion(nextVersion);
}
if (publishToNpm) { if (publishToNpm) {
await publishPackage(pkg.name, nextVersion); await publishPackage(pkg.name, nextVersion);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment