1/** 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 * 7 * @format 8 */ 9 10'use strict'; 11 12const {execSync, spawn} = require('child_process'); 13 14function setupVerdaccio( 15 reactNativeRootPath, // Path to React Native root folder 16 verdaccioConfigPath, // Path to Verdaccio config file, which you want to use for bootstrapping Verdaccio 17 verdaccioStoragePath, // Path to Verdaccio storage, where it should keep packages. Optional. Default value will be decided by your Verdaccio config 18) { 19 if (!reactNativeRootPath) { 20 throw new Error( 21 'Path to React Native repo root is not specified. You should provide it as a first argument', 22 ); 23 } 24 25 if (!verdaccioConfigPath) { 26 throw new Error( 27 'Path to Verdaccio config is not specified. You should provide it as a second argument', 28 ); 29 } 30 31 execSync('echo "//localhost:4873/:_authToken=secretToken" > .npmrc', { 32 cwd: reactNativeRootPath, 33 }); 34 35 const verdaccioProcess = spawn( 36 'npx', 37 ['[email protected]', '--config', verdaccioConfigPath], 38 {env: {...process.env, VERDACCIO_STORAGE_PATH: verdaccioStoragePath}}, 39 ); 40 41 const VERDACCIO_PID = verdaccioProcess.pid; 42 43 execSync('npx [email protected] http://localhost:4873'); 44 execSync('npm set registry http://localhost:4873'); 45 46 return VERDACCIO_PID; 47} 48 49module.exports = setupVerdaccio; 50