2022-09-22 15:02:37 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*
|
|
|
|
* @format
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2022-11-24 00:20:00 +03:00
|
|
|
const {execSync, spawn} = require('child_process');
|
|
|
|
|
|
|
|
function setupVerdaccio(
|
|
|
|
reactNativeRootPath, // Path to React Native root folder
|
|
|
|
verdaccioConfigPath, // Path to Verdaccio config file, which you want to use for bootstrapping Verdaccio
|
|
|
|
verdaccioStoragePath, // Path to Verdaccio storage, where it should keep packages. Optional. Default value will be decided by your Verdaccio config
|
|
|
|
) {
|
|
|
|
if (!reactNativeRootPath) {
|
|
|
|
throw new Error(
|
|
|
|
'Path to React Native repo root is not specified. You should provide it as a first argument',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!verdaccioConfigPath) {
|
|
|
|
throw new Error(
|
|
|
|
'Path to Verdaccio config is not specified. You should provide it as a second argument',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-01-27 22:01:45 +03:00
|
|
|
execSync('echo "//localhost:4873/:_authToken=secretToken" > .npmrc', {
|
|
|
|
cwd: reactNativeRootPath,
|
|
|
|
});
|
|
|
|
|
2022-11-24 00:20:00 +03:00
|
|
|
const verdaccioProcess = spawn(
|
|
|
|
'npx',
|
|
|
|
['verdaccio@5.16.3', '--config', verdaccioConfigPath],
|
|
|
|
{env: {...process.env, VERDACCIO_STORAGE_PATH: verdaccioStoragePath}},
|
|
|
|
);
|
|
|
|
|
2022-09-22 15:02:37 +03:00
|
|
|
const VERDACCIO_PID = verdaccioProcess.pid;
|
2022-11-24 00:20:00 +03:00
|
|
|
|
|
|
|
execSync('npx wait-on@6.0.1 http://localhost:4873');
|
|
|
|
execSync('npm set registry http://localhost:4873');
|
|
|
|
|
2022-09-22 15:02:37 +03:00
|
|
|
return VERDACCIO_PID;
|
|
|
|
}
|
|
|
|
|
2022-11-24 00:20:00 +03:00
|
|
|
module.exports = setupVerdaccio;
|