From d82ef3217a3bc5a2b3228b4cb7e7c70b1bfc0339 Mon Sep 17 00:00:00 2001 From: fortmarek Date: Wed, 21 Sep 2022 22:15:40 +0200 Subject: [PATCH] Address PR comments --- .circleci/verdaccio.yml | 2 +- scripts/run-ci-e2e-tests.js | 17 +++-------------- scripts/setup-verdaccio.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 scripts/setup-verdaccio.js diff --git a/.circleci/verdaccio.yml b/.circleci/verdaccio.yml index 74321150f91672..37e5d23b380227 100644 --- a/.circleci/verdaccio.yml +++ b/.circleci/verdaccio.yml @@ -4,7 +4,7 @@ auth: file: ./htpasswd uplinks: npmjs: - url: https://registry.yarnpkg.com/ + url: https://registry.npmjs.org/ max_fails: 40 maxage: 30m timeout: 60s diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index 1a99201669004c..6fb5348771a328 100644 --- a/scripts/run-ci-e2e-tests.js +++ b/scripts/run-ci-e2e-tests.js @@ -23,6 +23,7 @@ const {cd, cp, echo, exec, exit, mv, rm} = require('shelljs'); const spawn = require('child_process').spawn; const argv = require('yargs').argv; const path = require('path'); +const {setupVerdaccio} = require('./setup-verdaccio'); const SCRIPTS = __dirname; const ROOT = path.normalize(path.join(__dirname, '..')); @@ -72,26 +73,14 @@ try { const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz'); describe('Set up Verdaccio'); - const verdaccioProcess = spawn('npx', [ - 'verdaccio@5.15.3', - '--config', - '.circleci/verdaccio.yml', - ]); - VERDACCIO_PID = verdaccioProcess.pid; - exec('npx wait-on@6.0.1 http://localhost:4873'); - exec('npm set registry http://localhost:4873'); - exec('echo "//localhost:4873/:_authToken=secretToken" > .npmrc'); + VERDACCIO_PID = setupVerdaccio(); describe('Publish packages'); const packages = JSON.parse( JSON.parse(exec('yarn --json workspaces info').stdout).data, ); Object.keys(packages) - .filter( - packageName => - packageName !== '@react-native/tester' && - packageName !== '@react-native/repo-config', - ) + .filter(packageName => packageName !== '@react-native/repo-config') .forEach(packageName => { exec( `cd ${packages[packageName].location} && npm publish --registry http://localhost:4873 --yes --access public`, diff --git a/scripts/setup-verdaccio.js b/scripts/setup-verdaccio.js new file mode 100644 index 00000000000000..49c7645860ac05 --- /dev/null +++ b/scripts/setup-verdaccio.js @@ -0,0 +1,30 @@ +/** + * 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'; + +function setupVerdaccio() { + const {exec} = require('shelljs'); + const spawn = require('child_process').spawn; + + const verdaccioProcess = spawn('npx', [ + 'verdaccio@5.15.3', + '--config', + '.circleci/verdaccio.yml', + ]); + const VERDACCIO_PID = verdaccioProcess.pid; + exec('npx wait-on@6.0.1 http://localhost:4873'); + exec('npm set registry http://localhost:4873'); + exec('echo "//localhost:4873/:_authToken=secretToken" > .npmrc'); + return VERDACCIO_PID; +} + +module.exports = { + setupVerdaccio: setupVerdaccio, +};