-
-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathlocal-registry-process.ts
67 lines (60 loc) · 1.89 KB
/
local-registry-process.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import execa from 'execa';
import { E2E_VERSION } from './start-and-publish-to-local-registry';
// Used to ensure all the time-consuming setup steps for fixtures do not cause jest to time out
export const LONG_TIMEOUT_MS = 600000; // 10 mins
export async function runCommandOnLocalRegistry(
command: string,
args: string[],
): Promise<execa.ExecaChildProcess<string>> {
if (process.env.npm_config_registry?.indexOf('http://localhost') === -1) {
throw Error(`
------------------
💣 ERROR 💣 => $NPM_REGISTRY does not look like a local registry'
------------------
`);
}
console.log(
`\n[e2e debug output] Running command: ${command} ${args.join(' ')}\n`,
);
const subprocess = execa(command, args);
subprocess.stdout!.pipe(process.stdout);
subprocess.stderr!.pipe(process.stderr);
return await subprocess;
}
export async function runNpmInstall(): Promise<
execa.ExecaChildProcess<string>
> {
return await runCommandOnLocalRegistry('npm', ['install']);
}
export async function runNgAdd(): Promise<execa.ExecaChildProcess<string>> {
return await runCommandOnLocalRegistry('npx', [
'ng',
'add',
`@angular-eslint/schematics@${E2E_VERSION}`,
`--skip-confirmation`,
]);
}
export async function runNgNew(
workspaceName: string,
createApplication = true,
): Promise<execa.ExecaChildProcess<string>> {
const ngNewArgs = [
`--strict=true`,
`--package-manager=npm`,
`--interactive=false`,
];
if (!createApplication) {
ngNewArgs.push(`--create-application=false`);
}
return await runCommandOnLocalRegistry('../../node_modules/.bin/ng', [
'new',
...ngNewArgs,
workspaceName,
]);
}
export async function runNgGenerate(
args: string[],
): Promise<execa.ExecaChildProcess<string>> {
return await runCommandOnLocalRegistry('npx', ['ng', 'generate', ...args]);
}