Skip to content

Commit 73c56c8

Browse files
committed
Add verdaccio
1 parent c34659a commit 73c56c8

File tree

5 files changed

+87
-6
lines changed

5 files changed

+87
-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: 37 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,25 @@ try {
7072

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

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

146167
describe(`Start appium server, ${APPIUM_PID}`);
147-
const appiumProcess = spawn('node', ['./node_modules/.bin/appium']);
168+
const appiumProcess = child_process.spawn('node', [
169+
'./node_modules/.bin/appium',
170+
]);
148171
APPIUM_PID = appiumProcess.pid;
149172

150173
describe('Build the app');
@@ -156,9 +179,13 @@ try {
156179

157180
describe(`Start Metro, ${SERVER_PID}`);
158181
// 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-
});
182+
const packagerProcess = child_process.spawn(
183+
'yarn',
184+
['start', '--max-workers 1'],
185+
{
186+
env: process.env,
187+
},
188+
);
162189
SERVER_PID = packagerProcess.pid;
163190
// wait a bit to allow packager to startup
164191
exec('sleep 15s');
@@ -185,7 +212,7 @@ try {
185212
const packagerEnv = Object.create(process.env);
186213
packagerEnv.REACT_NATIVE_MAX_WORKERS = 1;
187214
describe('Start Metro');
188-
const packagerProcess = spawn('yarn', ['start'], {
215+
const packagerProcess = child_process.spawn('yarn', ['start'], {
189216
stdio: 'inherit',
190217
env: packagerEnv,
191218
});
@@ -288,5 +315,9 @@ try {
288315
echo(`Killing appium ${APPIUM_PID}`);
289316
exec(`kill -9 ${APPIUM_PID}`);
290317
}
318+
if (VERDACCIO_PID) {
319+
echo(`Killing verdaccio ${VERDACCIO_PID}`);
320+
exec(`kill -9 ${VERDACCIO_PID}`);
321+
}
291322
}
292323
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)