mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Fix caching issue with Verdaccio
This commit is contained in:
parent
ea5690ee25
commit
230331f289
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,6 +14,7 @@ test-results
|
||||
/bench
|
||||
.verdaccio-cache
|
||||
.next
|
||||
/.npmrc
|
||||
|
||||
# Yarn stuff
|
||||
/**/.yarn/*
|
||||
|
@ -12,6 +12,7 @@ import { PACKS_DIRECTORY } from './utils/constants';
|
||||
|
||||
import { maxConcurrentTasks } from './utils/concurrency';
|
||||
import { getWorkspaces } from './utils/workspace';
|
||||
import { execa, execaSync } from 'execa';
|
||||
|
||||
program
|
||||
.option('-O, --open', 'keep process open')
|
||||
@ -21,6 +22,8 @@ program.parse(process.argv);
|
||||
|
||||
const logger = console;
|
||||
|
||||
const root = path.resolve(__dirname, '..');
|
||||
|
||||
const startVerdaccio = async () => {
|
||||
let resolved = false;
|
||||
return Promise.race([
|
||||
@ -108,19 +111,6 @@ const publish = async (packages: { name: string; location: string }[], url: stri
|
||||
);
|
||||
};
|
||||
|
||||
const addUser = (url: string) =>
|
||||
new Promise<void>((res, rej) => {
|
||||
logger.log(`👤 add temp user to verdaccio`);
|
||||
|
||||
exec(`npx npm-cli-adduser -r "${url}" -a -u user -p password -e user@example.com`, (e) => {
|
||||
if (e) {
|
||||
rej(e);
|
||||
} else {
|
||||
res();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const run = async () => {
|
||||
const verdaccioUrl = `http://localhost:6001`;
|
||||
|
||||
@ -146,12 +136,15 @@ const run = async () => {
|
||||
|
||||
logger.log(`🌿 verdaccio running on ${verdaccioUrl}`);
|
||||
|
||||
// in some environments you need to add a dummy user. always try to add & catch on failure
|
||||
try {
|
||||
await addUser(verdaccioUrl);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
logger.log(`👤 add temp user to verdaccio`);
|
||||
await execa(
|
||||
'npx',
|
||||
// creates a .npmrc file in the root directory of the project
|
||||
['npm-auth-to-token', '-u', 'foo', '-p', 's3cret', '-e', 'test@test.com', '-r', verdaccioUrl],
|
||||
{
|
||||
cwd: root,
|
||||
}
|
||||
);
|
||||
|
||||
logger.log(`📦 found ${packages.length} storybook packages at version ${chalk.blue(version)}`);
|
||||
|
||||
@ -159,6 +152,8 @@ const run = async () => {
|
||||
await publish(packages, verdaccioUrl);
|
||||
}
|
||||
|
||||
await execa('npx', ['rimraf', '.npmrc'], { cwd: root });
|
||||
|
||||
if (!program.open) {
|
||||
verdaccioServer.close();
|
||||
}
|
||||
@ -166,5 +161,6 @@ const run = async () => {
|
||||
|
||||
run().catch((e) => {
|
||||
logger.error(e);
|
||||
execaSync('npx', ['rimraf', '.npmrc'], { cwd: root });
|
||||
process.exit(1);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user