Skip to content

Commit 83a5efe

Browse files
committed
Add verdaccio
1 parent c34659a commit 83a5efe

File tree

5 files changed

+89
-6
lines changed

5 files changed

+89
-6
lines changed

.circleci/verdaccio/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/storage

.circleci/verdaccio/config.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
storage: ./storage
2+
auth:
3+
htpasswd:
4+
file: ./htpasswd
5+
uplinks:
6+
npmjs:
7+
url: https://registry.npmjs.org/
8+
max_fails: 40
9+
maxage: 30m
10+
timeout: 60s
11+
fail_timeout: 10m
12+
cache: false
13+
agent_options:
14+
keepAlive: true
15+
maxSockets: 40
16+
maxFreeSockets: 10
17+
packages:
18+
'@*/*':
19+
access: $all
20+
publish: $all
21+
proxy: npmjs
22+
'**':
23+
access: $all
24+
publish: $all
25+
proxy: npmjs
26+
logs:
27+
- {type: file, path: verdaccio.log, format: pretty, level: debug}

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//localhost:4873/:_authToken="secretToken"

scripts/run-ci-e2e-tests.js

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
*/
2121

2222
const {cd, cp, echo, exec, exit, mv, rm} = require('shelljs');
23-
const spawn = require('child_process').spawn;
23+
const child_process = require('child_process');
2424
const argv = require('yargs').argv;
2525
const path = require('path');
26+
const fs = require('fs');
2627

2728
const SCRIPTS = __dirname;
2829
const ROOT = path.normalize(path.join(__dirname, '..'));
@@ -35,6 +36,7 @@ const REACT_NATIVE_APP_DIR = `${REACT_NATIVE_TEMP_DIR}/template`;
3536
const numberOfRetries = argv.retries || 1;
3637
let SERVER_PID;
3738
let APPIUM_PID;
39+
let VERDACCIO_PID;
3840
let exitCode;
3941

4042
function describe(message) {
@@ -70,6 +72,27 @@ try {
7072

7173
const REACT_NATIVE_PACKAGE = path.join(ROOT, 'react-native-*.tgz');
7274

75+
describe('Verdaccio');
76+
const verdaccioProcess = child_process.spawn(
77+
'npx',
78+
['verdaccio', '--config', './.circleci/verdaccio/config.yml'],
79+
{
80+
stdio: 'inherit',
81+
},
82+
);
83+
VERDACCIO_PID = verdaccioProcess.pid;
84+
exec('npm set registry http://localhost:4873');
85+
86+
exec('node ./scripts/wait-for-verdaccio.js');
87+
88+
echo('Publish packages');
89+
const packages = fs.readdirSync('packages');
90+
packages.forEach(current_package => {
91+
exec(
92+
`cd packages/${current_package} && npm publish --registry http://localhost:4873 --yes --access public`,
93+
);
94+
});
95+
7396
describe('Scaffold a basic React Native app from template');
7497
exec(`rsync -a ${ROOT}/template ${REACT_NATIVE_TEMP_DIR}`);
7598
cd(REACT_NATIVE_APP_DIR);
@@ -144,7 +167,9 @@ try {
144167
}
145168

146169
describe(`Start appium server, ${APPIUM_PID}`);
147-
const appiumProcess = spawn('node', ['./node_modules/.bin/appium']);
170+
const appiumProcess = child_process.spawn('node', [
171+
'./node_modules/.bin/appium',
172+
]);
148173
APPIUM_PID = appiumProcess.pid;
149174

150175
describe('Build the app');
@@ -156,9 +181,13 @@ try {
156181

157182
describe(`Start Metro, ${SERVER_PID}`);
158183
// shelljs exec('', {async: true}) does not emit stdout events, so we rely on good old spawn
159-
const packagerProcess = spawn('yarn', ['start', '--max-workers 1'], {
160-
env: process.env,
161-
});
184+
const packagerProcess = child_process.spawn(
185+
'yarn',
186+
['start', '--max-workers 1'],
187+
{
188+
env: process.env,
189+
},
190+
);
162191
SERVER_PID = packagerProcess.pid;
163192
// wait a bit to allow packager to startup
164193
exec('sleep 15s');
@@ -185,7 +214,7 @@ try {
185214
const packagerEnv = Object.create(process.env);
186215
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
187216
describe('Start Metro');
188-
const packagerProcess = spawn('yarn', ['start'], {
217+
const packagerProcess = child_process.spawn('yarn', ['start'], {
189218
stdio: 'inherit',
190219
env: packagerEnv,
191220
});
@@ -288,5 +317,9 @@ try {
288317
echo(`Killing appium ${APPIUM_PID}`);
289318
exec(`kill -9 ${APPIUM_PID}`);
290319
}
320+
if (VERDACCIO_PID) {
321+
echo(`Killing verdaccio ${VERDACCIO_PID}`);
322+
exec(`kill -9 ${VERDACCIO_PID}`);
323+
}
291324
}
292325
exit(exitCode);

scripts/wait-for-verdaccio.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
// @ts-check
3+
4+
const http = require('http');
5+
6+
function queryForServerStatus() {
7+
8+
http.get('http://localhost:4873', res => {
9+
console.log(`Server status: ${res.statusCode}`);
10+
if (res.statusCode !== 200) {
11+
setTimeout(queryForServerStatus, 2000);
12+
}
13+
}).on('error', err => {
14+
console.log(err.name, err.stack, err.message);
15+
setTimeout(queryForServerStatus, 2000);
16+
});
17+
}
18+
19+
console.log('Waiting for verdaccio instance to respond...');
20+
21+
queryForServerStatus();

0 commit comments

Comments
 (0)