@@ -12,6 +12,7 @@ import { PACKS_DIRECTORY } from './utils/constants';
12
12
13
13
import { maxConcurrentTasks } from './utils/concurrency' ;
14
14
import { getWorkspaces } from './utils/workspace' ;
15
+ import { execa , execaSync } from 'execa' ;
15
16
16
17
program
17
18
. option ( '-O, --open' , 'keep process open' )
@@ -21,6 +22,8 @@ program.parse(process.argv);
21
22
22
23
const logger = console ;
23
24
25
+ const root = path . resolve ( __dirname , '..' ) ;
26
+
24
27
const startVerdaccio = async ( ) => {
25
28
let resolved = false ;
26
29
return Promise . race ( [
@@ -108,19 +111,6 @@ const publish = async (packages: { name: string; location: string }[], url: stri
108
111
) ;
109
112
} ;
110
113
111
- const addUser = ( url : string ) =>
112
- new Promise < void > ( ( res , rej ) => {
113
- logger . log ( `👤 add temp user to verdaccio` ) ;
114
-
115
- exec ( `npx npm-cli-adduser -r "${ url } " -a -u user -p password -e [email protected] ` , ( e ) => {
116
- if ( e ) {
117
- rej ( e ) ;
118
- } else {
119
- res ( ) ;
120
- }
121
- } ) ;
122
- } ) ;
123
-
124
114
const run = async ( ) => {
125
115
const verdaccioUrl = `http://localhost:6001` ;
126
116
@@ -146,25 +136,31 @@ const run = async () => {
146
136
147
137
logger . log ( `🌿 verdaccio running on ${ verdaccioUrl } ` ) ;
148
138
149
- // in some environments you need to add a dummy user. always try to add & catch on failure
150
- try {
151
- await addUser ( verdaccioUrl ) ;
152
- } catch ( e ) {
153
- //
154
- }
139
+ logger . log ( `👤 add temp user to verdaccio` ) ;
140
+ await execa (
141
+ 'npx' ,
142
+ // creates a .npmrc file in the root directory of the project
143
+ [ 'npm-auth-to-token' , '-u' , 'foo' , '-p' , 's3cret' , '-e' , '[email protected] ' , '-r' , verdaccioUrl ] ,
144
+ {
145
+ cwd : root ,
146
+ }
147
+ ) ;
155
148
156
149
logger . log ( `📦 found ${ packages . length } storybook packages at version ${ chalk . blue ( version ) } ` ) ;
157
150
158
151
if ( program . publish ) {
159
152
await publish ( packages , verdaccioUrl ) ;
160
153
}
161
154
155
+ await execa ( 'npx' , [ 'rimraf' , '.npmrc' ] , { cwd : root } ) ;
156
+
162
157
if ( ! program . open ) {
163
158
verdaccioServer . close ( ) ;
164
159
}
165
160
} ;
166
161
167
162
run ( ) . catch ( ( e ) => {
168
163
logger . error ( e ) ;
164
+ execaSync ( 'npx' , [ 'rimraf' , '.npmrc' ] , { cwd : root } ) ;
169
165
process . exit ( 1 ) ;
170
166
} ) ;
0 commit comments