@@ -204,7 +204,7 @@ describe('#update', () => {
204204 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
205205 fs . writeFileSync ( fromConfigPath , `registry=https://us-west1-npm.pkg.dev/my-project/my-repo/` ) ;
206206 fs . writeFileSync ( toConfigPath , `` ) ;
207- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
207+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
208208
209209 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
210210 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -217,7 +217,7 @@ describe('#update', () => {
217217 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
218218 fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/` ) ;
219219 fs . writeFileSync ( toConfigPath , `` ) ;
220- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
220+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
221221
222222 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
223223 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -231,7 +231,7 @@ describe('#update', () => {
231231 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
232232 fs . writeFileSync ( fromConfigPath , `@my.scope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/` ) ;
233233 fs . writeFileSync ( toConfigPath , `` ) ;
234- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
234+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
235235
236236 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
237237 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -244,7 +244,7 @@ describe('#update', () => {
244244 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
245245 fs . writeFileSync ( fromConfigPath , `@~myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/` ) ;
246246 fs . writeFileSync ( toConfigPath , `` ) ;
247- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
247+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
248248
249249 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
250250 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -256,7 +256,7 @@ describe('#update', () => {
256256 fromConfigPath = getConfigPath ( `${ this . test . title } -from` ) ;
257257 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
258258 fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/` ) ;
259- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
259+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
260260
261261 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
262262 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -269,7 +269,7 @@ describe('#update', () => {
269269 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
270270 fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/` ) ;
271271 fs . writeFileSync ( toConfigPath , `//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=oldToken` ) ;
272- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
272+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
273273
274274 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
275275 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -282,7 +282,7 @@ describe('#update', () => {
282282 toConfigPath = fromConfigPath ;
283283 fs . writeFileSync ( fromConfigPath , `registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
284284 @cba:registry=https://asia-npm.pkg.dev/my-project/my-other-repo/` ) ;
285- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
285+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
286286
287287 const got = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
288288 assert . equal ( got , `registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
@@ -296,7 +296,7 @@ describe('#update', () => {
296296 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
297297 fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/` ) ;
298298 fs . writeFileSync ( toConfigPath , `//us-west1-npm.pkg.dev/my-project/my-repo/:_password=mypassword` ) ;
299- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
299+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
300300
301301 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
302302 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -310,7 +310,7 @@ describe('#update', () => {
310310 fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
311311//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=oldToken` ) ;
312312 fs . writeFileSync ( toConfigPath , `//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=oldToken` ) ;
313- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
313+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
314314
315315 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
316316 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -323,7 +323,7 @@ describe('#update', () => {
323323 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
324324 fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
325325//us-west1-npm.pkg.dev/my-project/my-repo/:_password=mypassword` ) ;
326- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
326+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
327327
328328 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
329329 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -337,7 +337,7 @@ describe('#update', () => {
337337 fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
338338//us-west1-npm.pkg.dev/my-project/my-repo/:_password="YWJjZA=="
339339//us-west1-npm.pkg.dev/my-project/my-repo/:username=oauth2accesstoken` ) ;
340- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
340+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
341341
342342 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
343343 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -352,7 +352,7 @@ describe('#update', () => {
352352@anotherscope:registry=https://us-west1-npm.pkg.dev/another-proj/another-repo/
353353myregistry.myproperty=myvalue` ) ;
354354 fs . writeFileSync ( toConfigPath , `myregistry.myproperty=myvalue` ) ;
355- await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds ) ;
355+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
356356
357357 const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
358358 const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
@@ -364,6 +364,44 @@ myregistry.myproperty=myvalue`);
364364//us-west1-npm.pkg.dev/another-proj/another-repo/:_authToken=abcd` ) ;
365365 } ) ;
366366
367+ it ( 'only allow AR domain' , async function ( ) {
368+ fromConfigPath = getConfigPath ( `${ this . test . title } -from` ) ;
369+ toConfigPath = getConfigPath ( `${ this . test . title } -to` )
370+ fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
371+ @anotherscope:registry=https://random-npm.com/another-proj/another-repo/
372+ myregistry.myproperty=myvalue` ) ;
373+ fs . writeFileSync ( toConfigPath , `myregistry.myproperty=myvalue` ) ;
374+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , false ) ;
375+
376+ const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
377+ const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
378+ assert . equal ( gotFrom , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
379+ @anotherscope:registry=https://random-npm.com/another-proj/another-repo/
380+ myregistry.myproperty=myvalue` ) ;
381+ assert . equal ( gotTo , `myregistry.myproperty=myvalue
382+ //us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=abcd` ) ;
383+ } ) ;
384+
385+ it ( 'allow all domains' , async function ( ) {
386+ fromConfigPath = getConfigPath ( `${ this . test . title } -from` ) ;
387+ toConfigPath = getConfigPath ( `${ this . test . title } -to` )
388+ fs . writeFileSync ( fromConfigPath , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
389+ @anotherscope:registry=https://random-npm.com/another-proj/another-repo/
390+ myregistry.myproperty=myvalue` ) ;
391+ fs . writeFileSync ( toConfigPath , `myregistry.myproperty=myvalue` ) ;
392+ await update . updateConfigFiles ( fromConfigPath , toConfigPath , creds , true ) ;
393+
394+ const gotFrom = fs . readFileSync ( fromConfigPath , 'utf8' ) ;
395+ const gotTo = fs . readFileSync ( toConfigPath , 'utf8' ) ;
396+ assert . equal ( gotFrom , `@myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/
397+ @anotherscope:registry=https://random-npm.com/another-proj/another-repo/
398+ myregistry.myproperty=myvalue` ) ;
399+ assert . equal ( gotTo , `myregistry.myproperty=myvalue
400+ //us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=abcd
401+ //random-npm.com/another-proj/another-repo/:_authToken=abcd` ) ;
402+ } ) ;
403+
404+
367405 it ( 'rejects if input does not exist' , async function ( ) {
368406 fromConfigPath = getConfigPath ( `${ this . test . title } -from` ) ;
369407 toConfigPath = getConfigPath ( `${ this . test . title } -to` )
0 commit comments