Skip to content

Commit c3e08b3

Browse files
authored
chore(testing): change e2e setup to use @nx/js (nrwl#17679)
1 parent 19ec1de commit c3e08b3

File tree

5 files changed

+18
-82
lines changed

5 files changed

+18
-82
lines changed

.verdaccio/config.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ packages:
3838
logs:
3939
type: stdout
4040
format: pretty
41-
level: http
41+
level: warn
42+
43+
publish:
44+
allow_offline: true # set offline to true to allow publish offline

CODEOWNERS

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ pnpm-lock.yaml @nrwl/nx-pipelines-reviewers
161161
# Scripts
162162
/scripts/depcheck @FrozenPandaz @vsavkin @jaysoo
163163
/scripts/documentation @nrwl/nx-docs-reviewers
164-
/scripts/local-registry @FrozenPandaz @vsavkin
165164
/scripts/angular-support-upgrades @nrwl/nx-angular-reviewers
166165

167166
# CI

e2e/utils/global-setup.ts

+12-44
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,33 @@
1+
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
12
import { join } from 'path';
2-
import { ChildProcess, exec, fork } from 'child_process';
3+
import { exec } from 'child_process';
34
import { tmpdir } from 'tmp';
45
import { existsSync } from 'fs-extra';
56
import { Config } from '@jest/types';
67

78
export default async function (globalConfig: Config.ConfigGlobals) {
8-
const isVerbose =
9-
process.env.NX_VERBOSE_LOGGING === 'true' || globalConfig.verbose;
9+
const isVerbose: boolean =
10+
process.env.NX_VERBOSE_LOGGING === 'true' || !!globalConfig.verbose;
1011
const storageLocation = join(
1112
tmpdir,
1213
'local-registry/storage',
1314
process.env.NX_TASK_TARGET_PROJECT ?? ''
1415
);
15-
global.nxLocalRegistryProcess = await new Promise<ChildProcess>(
16-
(resolve, reject) => {
17-
const childProcess = fork(
18-
require.resolve(`nx`),
19-
`local-registry @nx/nx-source --config scripts/local-registry/config.yml --location none --storage ${storageLocation} --clear ${
20-
process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true'
21-
}`.split(' '),
22-
{ stdio: 'pipe' }
23-
);
24-
25-
const listener = (data) => {
26-
if (data.toString().includes('http://localhost:')) {
27-
const port = parseInt(
28-
data.toString().match(/localhost:(?<port>\d+)/)?.groups?.port
29-
);
30-
console.log('Local registry started on port ' + port);
31-
32-
const registry = `http://localhost:${port}`;
33-
process.env.npm_config_registry = registry;
34-
process.env.YARN_REGISTRY = registry;
35-
console.log('Set npm and yarn config registry to ' + registry);
36-
37-
resolve(childProcess);
38-
childProcess.stdout?.off('data', listener);
39-
}
40-
};
41-
childProcess?.stdout?.on('data', listener);
42-
childProcess?.stderr?.on('data', (data) => {
43-
process.stderr.write(data);
44-
});
45-
childProcess.on('error', (err) => {
46-
console.log('local registry error', err);
47-
reject(err);
48-
});
49-
childProcess.on('exit', (code) => {
50-
console.log('local registry exit', code);
51-
reject(code);
52-
});
53-
}
54-
);
16+
global.e2eTeardown = await startLocalRegistry({
17+
localRegistryTarget: '@nx/nx-source:local-registry',
18+
verbose: isVerbose,
19+
storage: storageLocation,
20+
});
5521

5622
if (
5723
process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true' ||
5824
!existsSync('./build')
5925
) {
6026
console.log('Publishing packages to local registry');
6127
await new Promise<void>((res, rej) => {
62-
const publishProcess = exec('pnpm nx-release --local major');
28+
const publishProcess = exec('pnpm nx-release --local major', {
29+
env: process.env,
30+
});
6331
let logs = Buffer.from('');
6432
if (isVerbose) {
6533
publishProcess?.stdout?.pipe(process.stdout);

e2e/utils/global-teardown.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default function () {
2-
if (global.nxLocalRegistryProcess) {
3-
global.nxLocalRegistryProcess.kill();
2+
if (global.e2eTeardown) {
3+
global.e2eTeardown();
44
console.log('Killed local registry process');
55
}
66
}

scripts/local-registry/config.yml

-34
This file was deleted.

0 commit comments

Comments
 (0)