Skip to content

Commit

Permalink
Add verdaccio
Browse files Browse the repository at this point in the history
  • Loading branch information
fortmarek committed Sep 12, 2022
1 parent b0aba1b commit 6dd7298
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .circleci/verdaccio/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.yarnpkg.com/
max_fails: 40
maxage: 30m
timeout: 60s
fail_timeout: 10m
cache: false
agent_options:
keepAlive: true
maxSockets: 40
maxFreeSockets: 10
packages:
'@*/*':
access: $all
publish: $all
proxy: npmjs
'**':
access: $all
publish: $all
proxy: npmjs
logs:
- {type: file, path: verdaccio.log, format: pretty, level: debug}
49 changes: 46 additions & 3 deletions scripts/run-ci-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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) {
Expand Down Expand Up @@ -70,6 +71,46 @@ 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/config.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');

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 => {
const yarnInfo = exec(`yarn info ${packageName} --json`);
if (yarnInfo.stderr !== '') {
return true;
}
const versions = JSON.parse(
exec(`yarn info ${packageName} --json`).stdout.trim(),
).data.versions;
const currentVersion = require(`${process.cwd()}/${
packages[packageName].location
}/package.json`).version;
return !versions.includes(currentVersion);
})
.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);
Expand Down Expand Up @@ -156,9 +197,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');
Expand Down Expand Up @@ -288,5 +327,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);

0 comments on commit 6dd7298

Please sign in to comment.