mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
8d5f8804d8
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35991 Changelog: [Internal] While cherry-picking all this logic to `0.71-stable` branch, we've discovered several issues where some packages were failing to be published on Verdaccio proxy This was failing only on node v16+, after some research, I've noticed that there might be a race-condition and npm unable to grab this token before first `npm publish` executes Although this still work well on `main` branch, I am backporting it to keep aligned with `0.71-stable` Reviewed By: christophpurrer, cortinico Differential Revision: D42806081 fbshipit-source-id: af244d26ea529e6085ed5b2d731623dfaf78a14d
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
/**
|
|
* 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';
|
|
|
|
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',
|
|
);
|
|
}
|
|
|
|
execSync('echo "//localhost:4873/:_authToken=secretToken" > .npmrc', {
|
|
cwd: reactNativeRootPath,
|
|
});
|
|
|
|
const verdaccioProcess = spawn(
|
|
'npx',
|
|
['verdaccio@5.16.3', '--config', verdaccioConfigPath],
|
|
{env: {...process.env, VERDACCIO_STORAGE_PATH: verdaccioStoragePath}},
|
|
);
|
|
|
|
const VERDACCIO_PID = verdaccioProcess.pid;
|
|
|
|
execSync('npx wait-on@6.0.1 http://localhost:4873');
|
|
execSync('npm set registry http://localhost:4873');
|
|
|
|
return VERDACCIO_PID;
|
|
}
|
|
|
|
module.exports = setupVerdaccio;
|