Skip to content

Commit

Permalink
Start verdaccio earlier and keep it alive longer (#8016)
Browse files Browse the repository at this point in the history
* Start verdaccio earlier and keep it alive longer

Start the verdaccio server immediately when running publish-npm and keep it
alive until the first OTP is entered. Also, add a tip for how to access the
server from your browser. This makes it easier to verify that all packages will
be published correctly to NPM.

* Fix CI timeout from asking to quit verdaccio
  • Loading branch information
mattsoulanille authored Oct 26, 2023
1 parent 00831de commit a6a1005
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 14 additions & 3 deletions scripts/publish-npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ parser.addArgument(['--auto-publish-local-newer'], {

parser.addArgument(['--ci'], {
action: 'storeTrue',
help: 'Enable CI bazel flags for faster compilation. No effect on results.',
help: 'Enable CI bazel flags for faster compilation and don\'t ask for user '
+ 'input before closing the verdaccio server once tests are done. '
+ 'Has no effect on results.',
});

parser.addArgument(['packages'], {
Expand Down Expand Up @@ -221,6 +223,8 @@ async function publish(pkg: string, registry: string, otp?: string,
async function main() {
const args = parser.parseArgs();

const killVerdaccio = await runVerdaccio();

let releaseUnits: ReleaseUnit[];
if (args.release_this_branch) {
console.log('Releasing current branch');
Expand Down Expand Up @@ -359,19 +363,24 @@ async function main() {
// Build and publish all packages to a local Verdaccio repo for staging.
console.log(
chalk.magenta.bold('~~~ Staging packages locally in Verdaccio ~~~'));
const killVerdaccio = await runVerdaccio();

try {
for (const pkg of packages) {
await publish(pkg, VERDACCIO_REGISTRY);
}
} finally {
} catch (e) {
// Make sure to kill the verdaccio server before exiting even if publish
// throws an error. Otherwise, it blocks the port for the next run.
killVerdaccio();
throw e;
}

if (args.dry) {
console.log('Not publishing packages due to \'--dry\'');
if (!args.ci) {
await question('Press enter to quit verdaccio.');
}
killVerdaccio();
} else {
// Publish all built packages to the selected registry
let otp = '';
Expand All @@ -380,6 +389,8 @@ async function main() {
}
console.log(`Publishing packages to ${args.registry}`);

killVerdaccio();

const toPublish = [...packages];
while (toPublish.length > 0) {
// Using a while loop instead of .map since a stale OTP will require
Expand Down
3 changes: 2 additions & 1 deletion scripts/release-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ export async function runVerdaccio(): Promise<() => void> {
serverProcess.on('message', (msg: {verdaccio_started: boolean}) => {
if (msg.verdaccio_started) {
console.log('Verdaccio Started.');
console.log(chalk.magenta.bold(
`Verdaccio Started. Visit http://localhost:4873 to see packages.`));
clearTimeout(timeout);
resolve();
}
Expand Down

0 comments on commit a6a1005

Please sign in to comment.