-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea5690e
commit 230331f
Showing
2 changed files
with
16 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ test-results | |
/bench | ||
.verdaccio-cache | ||
.next | ||
/.npmrc | ||
|
||
# Yarn stuff | ||
/**/.yarn/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 [email protected]`, (e) => { | ||
if (e) { | ||
rej(e); | ||
} else { | ||
res(); | ||
} | ||
}); | ||
}); | ||
|
||
const run = async () => { | ||
const verdaccioUrl = `http://localhost:6001`; | ||
|
||
|
@@ -146,25 +136,31 @@ 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', '[email protected]', '-r', verdaccioUrl], | ||
{ | ||
cwd: root, | ||
} | ||
); | ||
|
||
logger.log(`📦 found ${packages.length} storybook packages at version ${chalk.blue(version)}`); | ||
|
||
if (program.publish) { | ||
await publish(packages, verdaccioUrl); | ||
} | ||
|
||
await execa('npx', ['rimraf', '.npmrc'], { cwd: root }); | ||
|
||
if (!program.open) { | ||
verdaccioServer.close(); | ||
} | ||
}; | ||
|
||
run().catch((e) => { | ||
logger.error(e); | ||
execaSync('npx', ['rimraf', '.npmrc'], { cwd: root }); | ||
process.exit(1); | ||
}); |