chore(testing): change e2e setup to use @nx/js (#17679)
This commit is contained in:
parent
19ec1de5d9
commit
c3e08b3809
@ -38,4 +38,7 @@ packages:
|
||||
logs:
|
||||
type: stdout
|
||||
format: pretty
|
||||
level: http
|
||||
level: warn
|
||||
|
||||
publish:
|
||||
allow_offline: true # set offline to true to allow publish offline
|
||||
|
||||
@ -161,7 +161,6 @@ pnpm-lock.yaml @nrwl/nx-pipelines-reviewers
|
||||
# Scripts
|
||||
/scripts/depcheck @FrozenPandaz @vsavkin @jaysoo
|
||||
/scripts/documentation @nrwl/nx-docs-reviewers
|
||||
/scripts/local-registry @FrozenPandaz @vsavkin
|
||||
/scripts/angular-support-upgrades @nrwl/nx-angular-reviewers
|
||||
|
||||
# CI
|
||||
|
||||
@ -1,57 +1,23 @@
|
||||
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
|
||||
import { join } from 'path';
|
||||
import { ChildProcess, exec, fork } from 'child_process';
|
||||
import { exec } from 'child_process';
|
||||
import { tmpdir } from 'tmp';
|
||||
import { existsSync } from 'fs-extra';
|
||||
import { Config } from '@jest/types';
|
||||
|
||||
export default async function (globalConfig: Config.ConfigGlobals) {
|
||||
const isVerbose =
|
||||
process.env.NX_VERBOSE_LOGGING === 'true' || globalConfig.verbose;
|
||||
const isVerbose: boolean =
|
||||
process.env.NX_VERBOSE_LOGGING === 'true' || !!globalConfig.verbose;
|
||||
const storageLocation = join(
|
||||
tmpdir,
|
||||
'local-registry/storage',
|
||||
process.env.NX_TASK_TARGET_PROJECT ?? ''
|
||||
);
|
||||
global.nxLocalRegistryProcess = await new Promise<ChildProcess>(
|
||||
(resolve, reject) => {
|
||||
const childProcess = fork(
|
||||
require.resolve(`nx`),
|
||||
`local-registry @nx/nx-source --config scripts/local-registry/config.yml --location none --storage ${storageLocation} --clear ${
|
||||
process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true'
|
||||
}`.split(' '),
|
||||
{ stdio: 'pipe' }
|
||||
);
|
||||
|
||||
const listener = (data) => {
|
||||
if (data.toString().includes('http://localhost:')) {
|
||||
const port = parseInt(
|
||||
data.toString().match(/localhost:(?<port>\d+)/)?.groups?.port
|
||||
);
|
||||
console.log('Local registry started on port ' + port);
|
||||
|
||||
const registry = `http://localhost:${port}`;
|
||||
process.env.npm_config_registry = registry;
|
||||
process.env.YARN_REGISTRY = registry;
|
||||
console.log('Set npm and yarn config registry to ' + registry);
|
||||
|
||||
resolve(childProcess);
|
||||
childProcess.stdout?.off('data', listener);
|
||||
}
|
||||
};
|
||||
childProcess?.stdout?.on('data', listener);
|
||||
childProcess?.stderr?.on('data', (data) => {
|
||||
process.stderr.write(data);
|
||||
});
|
||||
childProcess.on('error', (err) => {
|
||||
console.log('local registry error', err);
|
||||
reject(err);
|
||||
});
|
||||
childProcess.on('exit', (code) => {
|
||||
console.log('local registry exit', code);
|
||||
reject(code);
|
||||
});
|
||||
}
|
||||
);
|
||||
global.e2eTeardown = await startLocalRegistry({
|
||||
localRegistryTarget: '@nx/nx-source:local-registry',
|
||||
verbose: isVerbose,
|
||||
storage: storageLocation,
|
||||
});
|
||||
|
||||
if (
|
||||
process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true' ||
|
||||
@ -59,7 +25,9 @@ export default async function (globalConfig: Config.ConfigGlobals) {
|
||||
) {
|
||||
console.log('Publishing packages to local registry');
|
||||
await new Promise<void>((res, rej) => {
|
||||
const publishProcess = exec('pnpm nx-release --local major');
|
||||
const publishProcess = exec('pnpm nx-release --local major', {
|
||||
env: process.env,
|
||||
});
|
||||
let logs = Buffer.from('');
|
||||
if (isVerbose) {
|
||||
publishProcess?.stdout?.pipe(process.stdout);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export default function () {
|
||||
if (global.nxLocalRegistryProcess) {
|
||||
global.nxLocalRegistryProcess.kill();
|
||||
if (global.e2eTeardown) {
|
||||
global.e2eTeardown();
|
||||
console.log('Killed local registry process');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
# path to a directory with all packages
|
||||
storage: ../../tmp/local-registry/storage
|
||||
|
||||
listen: 127.0.0.1:4872 # change to 127.0.0.1 to avoid IPv6 issue
|
||||
|
||||
# a list of other known repositories we can talk to
|
||||
uplinks:
|
||||
npmjs:
|
||||
url: https://registry.npmjs.org/
|
||||
max_fails: 100
|
||||
maxage: 30m
|
||||
fail_timeout: 10m
|
||||
timeout: 600s
|
||||
cache: false
|
||||
|
||||
packages:
|
||||
'@nrwl/*':
|
||||
access: $all
|
||||
publish: $all
|
||||
|
||||
'**':
|
||||
access: $all
|
||||
publish: $all
|
||||
unpublish: $all
|
||||
proxy: npmjs
|
||||
|
||||
# log settings
|
||||
logs:
|
||||
type: stdout
|
||||
format: pretty
|
||||
level: warn
|
||||
|
||||
publish:
|
||||
allow_offline: true # set offline to true to allow publish offline
|
||||
Loading…
x
Reference in New Issue
Block a user