Commit e9130210 by Dominik Prokop Committed by GitHub

Build: Fix final prompt for @grafana/ui npm publish confirmation

Fixes issue of the final confirmation prompt (the one to confirm the actual npm publish) being invisible, making it impossible to release by anyone but me.

Also, before the release is created I'm assuring previous release bundle is remove (otherwise tests and checks would fail)
parent c31aaa1a
...@@ -7,7 +7,7 @@ import { Task, TaskRunner } from './task'; ...@@ -7,7 +7,7 @@ import { Task, TaskRunner } from './task';
let distDir, cwd; let distDir, cwd;
const clean = useSpinner<void>('Cleaning', async () => await execa('npm', ['run', 'clean'])); export const clean = useSpinner<void>('Cleaning', async () => await execa('npm', ['run', 'clean']));
const compile = useSpinner<void>('Compiling sources', () => execa('tsc', ['-p', './tsconfig.build.json'])); const compile = useSpinner<void>('Compiling sources', () => execa('tsc', ['-p', './tsconfig.build.json']));
......
import execa from 'execa'; import execa from 'execa';
import { execTask } from '../utils/execTask'; import { execTask } from '../utils/execTask';
import { changeCwdToGrafanaUiDist, changeCwdToGrafanaUi } from '../utils/cwd'; import { changeCwdToGrafanaUiDist, changeCwdToGrafanaUi, restoreCwd } from '../utils/cwd';
import semver from 'semver'; import semver from 'semver';
import inquirer from 'inquirer'; import inquirer from 'inquirer';
import chalk from 'chalk'; import chalk from 'chalk';
import { useSpinner } from '../utils/useSpinner'; import { useSpinner } from '../utils/useSpinner';
import { savePackage, buildTask } from './grafanaui.build'; import { savePackage, buildTask, clean } from './grafanaui.build';
import { TaskRunner, Task } from './task'; import { TaskRunner, Task } from './task';
type VersionBumpType = 'prerelease' | 'patch' | 'minor' | 'major'; type VersionBumpType = 'prerelease' | 'patch' | 'minor' | 'major';
...@@ -81,12 +81,6 @@ const bumpVersion = (version: string) => ...@@ -81,12 +81,6 @@ const bumpVersion = (version: string) =>
const publishPackage = (name: string, version: string) => const publishPackage = (name: string, version: string) =>
useSpinner<void>(`Publishing ${name} @ ${version} to npm registry...`, async () => { useSpinner<void>(`Publishing ${name} @ ${version} to npm registry...`, async () => {
changeCwdToGrafanaUiDist(); changeCwdToGrafanaUiDist();
console.log(chalk.yellowBright.bold(`\nReview dist package.json before proceeding!\n`));
const { confirmed } = await promptConfirm('Are you ready to publish to npm?');
if (!confirmed) {
process.exit();
}
await execa('npm', ['publish', '--access', 'public']); await execa('npm', ['publish', '--access', 'public']);
})(); })();
...@@ -111,13 +105,18 @@ const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({ ...@@ -111,13 +105,18 @@ const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({
usePackageJsonVersion, usePackageJsonVersion,
createVersionCommit, createVersionCommit,
}) => { }) => {
await runChecksAndTests(); changeCwdToGrafanaUi();
await clean(); // Clean previous build if exists
restoreCwd();
if (publishToNpm) { if (publishToNpm) {
// TODO: Ensure release branch // TODO: Ensure release branch
// When need to update this when we star keeping @grafana/ui releases in sync with core // When need to update this when we star keeping @grafana/ui releases in sync with core
await ensureMasterBranch(); await ensureMasterBranch();
} }
runChecksAndTests();
await execTask(buildTask)(); await execTask(buildTask)();
let releaseConfirmed = false; let releaseConfirmed = false;
...@@ -169,6 +168,13 @@ const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({ ...@@ -169,6 +168,13 @@ const releaseTaskRunner: TaskRunner<ReleaseTaskOptions> = async ({
} }
if (publishToNpm) { if (publishToNpm) {
console.log(chalk.yellowBright.bold(`\nReview dist package.json before proceeding!\n`));
const { confirmed } = await promptConfirm('Are you ready to publish to npm?');
if (!confirmed) {
process.exit();
}
await publishPackage(pkg.name, nextVersion); await publishPackage(pkg.name, nextVersion);
console.log(chalk.green(`\nVersion ${nextVersion} of ${pkg.name} succesfully released!`)); console.log(chalk.green(`\nVersion ${nextVersion} of ${pkg.name} succesfully released!`));
console.log(chalk.yellow(`\nUpdated @grafana/ui/package.json with version bump created.`)); console.log(chalk.yellow(`\nUpdated @grafana/ui/package.json with version bump created.`));
......
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