diff --git a/.circleci/verdaccio.yml b/.circleci/verdaccio.yml new file mode 100644 index 00000000000000..37e5d23b380227 --- /dev/null +++ b/.circleci/verdaccio.yml @@ -0,0 +1,44 @@ +storage: ./storage +auth: + htpasswd: + file: ./htpasswd +uplinks: + npmjs: + url: https://registry.npmjs.org/ + max_fails: 40 + maxage: 30m + timeout: 60s + fail_timeout: 10m + cache: false + agent_options: + keepAlive: true + maxSockets: 40 + maxFreeSockets: 10 +packages: + # Group and isolate all local packages, avoid being proxy from outside + '@react-native/*': + access: $all + publish: $all + # The below specific entries can be removed once they are renamed and have the @react-native prefix + '@react-native-community/eslint-config': + access: $all + publish: $all + '@react-native-community/eslint-plugin': + access: $all + publish: $all + 'react-native-codegen': + access: $all + publish: $all + 'react-native-gradle-plugin': + access: $all + publish: $all + '@*/*': + access: $all + publish: $authenticated + proxy: npmjs + '**': + access: $all + publish: $all + proxy: npmjs +logs: + - {type: file, path: verdaccio.log, format: json, level: warn} diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index 177cb102339a72..1c013ba073537c 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, '..')); @@ -35,6 +36,7 @@ const REACT_NATIVE_APP_DIR = `${REACT_NATIVE_TEMP_DIR}/template`; const numberOfRetries = argv.retries || 1; let SERVER_PID; let APPIUM_PID; +let VERDACCIO_PID; let exitCode; function describe(message) { @@ -70,6 +72,19 @@ try { const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz'); + describe('Set up Verdaccio'); + VERDACCIO_PID = setupVerdaccio(); + + describe('Publish packages'); + const packages = JSON.parse( + JSON.parse(exec('yarn --json workspaces info').stdout).data, + ); + Object.keys(packages).forEach(packageName => { + exec( + `cd ${packages[packageName].location} && npm publish --registry http://localhost:4873 --yes --access public`, + ); + }); + describe('Scaffold a basic React Native app from template'); exec(`rsync -a ${ROOT}/template ${REACT_NATIVE_TEMP_DIR}`); cd(REACT_NATIVE_APP_DIR); @@ -156,9 +171,7 @@ try { describe(`Start Metro, ${SERVER_PID}`); // shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn - const packagerProcess = spawn('yarn', ['start', '--max-workers 1'], { - env: process.env, - }); + const packagerProcess = spawn('yarn', ['start', '--max-workers 1']); SERVER_PID = packagerProcess.pid; // wait a bit to allow packager to startup exec('sleep 15s'); @@ -288,5 +301,9 @@ try { echo(`Killing appium ${APPIUM_PID}`); exec(`kill -9 ${APPIUM_PID}`); } + if (VERDACCIO_PID) { + echo(`Killing verdaccio ${VERDACCIO_PID}`); + exec(`kill -9 ${VERDACCIO_PID}`); + } } exit(exitCode); diff --git a/scripts/setup-verdaccio.js b/scripts/setup-verdaccio.js new file mode 100644 index 00000000000000..e62e7918540d2a --- /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'; + +const {exec} = require('shelljs'); +const spawn = require('child_process').spawn; + +function setupVerdaccio() { + 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, +}; diff --git a/template/package.json b/template/package.json index 5300570ea3dcbd..98dd49a0886c1b 100644 --- a/template/package.json +++ b/template/package.json @@ -16,7 +16,7 @@ "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", - "@react-native-community/eslint-config": "^2.0.0", + "@react-native-community/eslint-config": "^3.0.0", "babel-jest": "^26.6.3", "eslint": "^8.19.0", "jest": "^26.6.3",