-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinit.ts
More file actions
55 lines (50 loc) · 1.27 KB
/
init.ts
File metadata and controls
55 lines (50 loc) · 1.27 KB
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
import {
type ProcessConfig,
executeProcess,
isVerbose,
objectToCliArgs,
} from '@code-pushup/utils';
import {
parseNxProcessOutput,
setupNxContext,
teardownNxContext,
} from './utils.js';
export function nxPluginGenerator(
generator: 'init' | 'configuration',
opt: Record<string, unknown> = {},
): ProcessConfig {
return {
command: 'npx',
args: objectToCliArgs({
_: ['nx', 'g', `@code-pushup/nx-plugin:${generator}`],
...opt,
}),
};
}
export async function initCodePushup() {
const setupResult = await setupNxContext();
await executeProcess({
...nxPluginGenerator('init', {
skipNxJson: true,
}),
verbose: isVerbose(),
observer: {
onStdout: data => {
console.info(parseNxProcessOutput(data.toString()));
},
onError: error => {
console.error(parseNxProcessOutput(error.message.toString()));
},
},
});
const { stdout: configStdout, stderr: configStderr } = await executeProcess({
...nxPluginGenerator('configuration', {
skipTarget: true,
project: setupResult.projectName,
}),
verbose: isVerbose(),
});
console.info(parseNxProcessOutput(configStdout));
console.warn(parseNxProcessOutput(configStderr));
await teardownNxContext(setupResult);
}