@code-pushup/nx-plugin 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +23 -0
  2. package/executors.json +9 -0
  3. package/generators.json +14 -0
  4. package/package.json +31 -0
  5. package/src/executors/autorun/README.md +61 -0
  6. package/src/executors/autorun/constants.d.ts +1 -0
  7. package/src/executors/autorun/constants.js +5 -0
  8. package/src/executors/autorun/constants.js.map +1 -0
  9. package/src/executors/autorun/executor.d.ts +15 -0
  10. package/src/executors/autorun/executor.js +44 -0
  11. package/src/executors/autorun/executor.js.map +1 -0
  12. package/src/executors/autorun/schema.d.ts +7 -0
  13. package/src/executors/autorun/schema.js +3 -0
  14. package/src/executors/autorun/schema.js.map +1 -0
  15. package/src/executors/autorun/schema.json +100 -0
  16. package/src/executors/autorun/utils.d.ts +4 -0
  17. package/src/executors/autorun/utils.js +24 -0
  18. package/src/executors/autorun/utils.js.map +1 -0
  19. package/src/executors/internal/cli.d.ts +10 -0
  20. package/src/executors/internal/cli.js +48 -0
  21. package/src/executors/internal/cli.js.map +1 -0
  22. package/src/executors/internal/config.d.ts +5 -0
  23. package/src/executors/internal/config.js +47 -0
  24. package/src/executors/internal/config.js.map +1 -0
  25. package/src/executors/internal/context.d.ts +6 -0
  26. package/src/executors/internal/context.js +13 -0
  27. package/src/executors/internal/context.js.map +1 -0
  28. package/src/executors/internal/env.d.ts +2 -0
  29. package/src/executors/internal/env.js +36 -0
  30. package/src/executors/internal/env.js.map +1 -0
  31. package/src/executors/internal/types.d.ts +39 -0
  32. package/src/executors/internal/types.js +3 -0
  33. package/src/executors/internal/types.js.map +1 -0
  34. package/src/generators/configuration/README.md +27 -0
  35. package/src/generators/configuration/code-pushup-config.d.ts +13 -0
  36. package/src/generators/configuration/code-pushup-config.js +38 -0
  37. package/src/generators/configuration/code-pushup-config.js.map +1 -0
  38. package/src/generators/configuration/files/code-pushup.config.ts.template +9 -0
  39. package/src/generators/configuration/generator.d.ts +6 -0
  40. package/src/generators/configuration/generator.js +46 -0
  41. package/src/generators/configuration/generator.js.map +1 -0
  42. package/src/generators/configuration/schema.d.ts +9 -0
  43. package/src/generators/configuration/schema.json +45 -0
  44. package/src/generators/configuration/types.d.ts +5 -0
  45. package/src/generators/configuration/types.js +3 -0
  46. package/src/generators/configuration/types.js.map +1 -0
  47. package/src/generators/configuration/utils.d.ts +9 -0
  48. package/src/generators/configuration/utils.js +47 -0
  49. package/src/generators/configuration/utils.js.map +1 -0
  50. package/src/generators/init/README.md +24 -0
  51. package/src/generators/init/generator.d.ts +5 -0
  52. package/src/generators/init/generator.js +78 -0
  53. package/src/generators/init/generator.js.map +1 -0
  54. package/src/generators/init/schema.d.ts +5 -0
  55. package/src/generators/init/schema.json +23 -0
  56. package/src/index.d.ts +11 -0
  57. package/src/index.js +22 -0
  58. package/src/index.js.map +1 -0
  59. package/src/internal/constants.d.ts +3 -0
  60. package/src/internal/constants.js +8 -0
  61. package/src/internal/constants.js.map +1 -0
  62. package/src/internal/execute-process.d.ts +123 -0
  63. package/src/internal/execute-process.js +104 -0
  64. package/src/internal/execute-process.js.map +1 -0
  65. package/src/internal/types.d.ts +4 -0
  66. package/src/internal/types.js +3 -0
  67. package/src/internal/types.js.map +1 -0
  68. package/src/internal/versions.d.ts +4 -0
  69. package/src/internal/versions.js +15 -0
  70. package/src/internal/versions.js.map +1 -0
  71. package/src/plugin/constants.d.ts +1 -0
  72. package/src/plugin/constants.js +5 -0
  73. package/src/plugin/constants.js.map +1 -0
  74. package/src/plugin/index.d.ts +2 -0
  75. package/src/plugin/index.js +6 -0
  76. package/src/plugin/index.js.map +1 -0
  77. package/src/plugin/plugin.d.ts +2 -0
  78. package/src/plugin/plugin.js +22 -0
  79. package/src/plugin/plugin.js.map +1 -0
  80. package/src/plugin/target/configuration-target.d.ts +7 -0
  81. package/src/plugin/target/configuration-target.js +18 -0
  82. package/src/plugin/target/configuration-target.js.map +1 -0
  83. package/src/plugin/target/constants.d.ts +1 -0
  84. package/src/plugin/target/constants.js +5 -0
  85. package/src/plugin/target/constants.js.map +1 -0
  86. package/src/plugin/target/executor-target.d.ts +6 -0
  87. package/src/plugin/target/executor-target.js +19 -0
  88. package/src/plugin/target/executor-target.js.map +1 -0
  89. package/src/plugin/target/targets.d.ts +6 -0
  90. package/src/plugin/target/targets.js +26 -0
  91. package/src/plugin/target/targets.js.map +1 -0
  92. package/src/plugin/types.d.ts +13 -0
  93. package/src/plugin/types.js +3 -0
  94. package/src/plugin/types.js.map +1 -0
  95. package/src/plugin/utils.d.ts +3 -0
  96. package/src/plugin/utils.js +27 -0
  97. package/src/plugin/utils.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @code-pushup/nx-plugin
2
+
3
+ ### Generators
4
+
5
+ #### Init
6
+
7
+ Install JS packages and register plugin.
8
+ See [init docs](./src/generators/init/README.md) for details
9
+
10
+ Examples:
11
+
12
+ - `nx g @code-pushup/nx-plugin:init` - setup code-pushup in the workspace
13
+ - `nx g @code-pushup/nx-plugin:init --skipPackageJson` - skip `package.json` update
14
+
15
+ #### Configuration
16
+
17
+ Adds a `code-pushup` target to your `project.json`.
18
+ See [configuration docs](./src/generators/configuration/README.md) for details
19
+
20
+ Examples:
21
+
22
+ - `nx g @code-pushup/nx-plugin:configuration --project=<project-name>`
23
+ - `nx g @code-pushup/nx-plugin:configuration --project=<project-name> --targetName=cp`
package/executors.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "executors": {
3
+ "autorun": {
4
+ "implementation": "./src/executors/autorun/executor",
5
+ "schema": "./src/executors/autorun/schema.json",
6
+ "description": "CodePushup CLI autorun command executor. Executes the @code-pushup/cli autorun command See: https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#autorun-command"
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "generators": {
3
+ "init": {
4
+ "factory": "./src/generators/init/generator",
5
+ "schema": "./src/generators/init/schema.json",
6
+ "description": "init generator"
7
+ },
8
+ "configuration": {
9
+ "factory": "./src/generators/configuration/generator",
10
+ "schema": "./src/generators/configuration/schema.json",
11
+ "description": "configuration generator"
12
+ }
13
+ }
14
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@code-pushup/nx-plugin",
3
+ "version": "0.51.0",
4
+ "license": "MIT",
5
+ "description": "Nx plugin to integrate the Code PushUp CLI into your workspace 🛠️",
6
+ "homepage": "code-pushup.dev",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/code-pushup/cli/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/code-pushup/cli.git",
16
+ "directory": "packages/nx-plugin"
17
+ },
18
+ "dependencies": {
19
+ "@nx/devkit": "^17.1.3",
20
+ "tslib": "^2.6.2",
21
+ "nx": "^17.1.3",
22
+ "@code-pushup/models": "0.51.0",
23
+ "zod": "^3.22.4",
24
+ "@code-pushup/utils": "0.51.0"
25
+ },
26
+ "type": "commonjs",
27
+ "main": "./src/index.js",
28
+ "typings": "./src/index.d.ts",
29
+ "generators": "./generators.json",
30
+ "executors": "./executors.json"
31
+ }
@@ -0,0 +1,61 @@
1
+ # Autorun Executor
2
+
3
+ This executor is used to run the code-pushup CLI autorun command in a Nx workspace.
4
+ For details on the CLI command read the [CLI autorun documentation](https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#autorun-command).
5
+
6
+ #### @code-pushup/nx-plugin:autorun
7
+
8
+ ## Usage
9
+
10
+ // project.json
11
+
12
+ ```json
13
+ {
14
+ "name": "my-project",
15
+ "targets": {
16
+ "code-pushup": {
17
+ "executor": "@code-pushup/nx-plugin:autorun"
18
+ }
19
+ }
20
+ }
21
+ ```
22
+
23
+ By default, the Nx plugin will derive the options from the executor config.
24
+
25
+ The following things happen:
26
+
27
+ - the output directory defaults to `${workspaceRoot}/.code-pushup/${projectName}`
28
+ - the config file defaults to `${projectRoot}/code-pushup.config.ts`
29
+ - parses terminal arguments and forwards them to the CLI command (they override the executor config)
30
+ - the CLI command is executed
31
+
32
+ ```jsonc
33
+ {
34
+ "name": "my-project",
35
+ "targets": {
36
+ "code-pushup": {
37
+ "executor": "@code-pushup/nx-plugin:autorun",
38
+ "options": {
39
+ "projectPrefix": "cli", // upload.project = cli-my-project
40
+ "verbose": true,
41
+ "progress": false
42
+ // persist and upload options as defined in CoreConfig
43
+ }
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ Show what will be executed without actually executing it:
50
+
51
+ `nx run my-project:code-pushup --dryRun`
52
+
53
+ ## Options
54
+
55
+ | Name | type | description |
56
+ | ----------------- | --------- | ------------------------------------------------------------------ |
57
+ | **projectPrefix** | `string` | prefix for upload.project on non root projects |
58
+ | **dryRun** | `boolean` | To debug the executor, dry run the command without real execution. |
59
+ | **bin** | `string` | Path to Code PushUp CLI |
60
+
61
+ For all other options see the [CLI autorun documentation](../../cli/packages/cli/README.md#autorun-command).
@@ -0,0 +1 @@
1
+ export declare const AUTORUN_COMMAND = "autorun";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AUTORUN_COMMAND = void 0;
4
+ exports.AUTORUN_COMMAND = 'autorun';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/autorun/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,SAAS,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type ExecutorContext } from '@nx/devkit';
2
+ import type { AutorunCommandExecutorOptions } from './schema';
3
+ export type ExecutorOutput = {
4
+ success: boolean;
5
+ command?: string;
6
+ error?: Error;
7
+ };
8
+ export default function runAutorunExecutor(terminalAndExecutorOptions: AutorunCommandExecutorOptions, context: ExecutorContext): Promise<{
9
+ success: boolean;
10
+ command: string;
11
+ error: unknown;
12
+ }> | Promise<{
13
+ success: true;
14
+ command: string;
15
+ }>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ // eslint-disable-next-line n/no-sync
5
+ const node_child_process_1 = require("node:child_process");
6
+ const cli_1 = require("../internal/cli");
7
+ const context_1 = require("../internal/context");
8
+ const constants_1 = require("./constants");
9
+ const utils_1 = require("./utils");
10
+ function runAutorunExecutor(terminalAndExecutorOptions, context) {
11
+ const normalizedContext = (0, context_1.normalizeContext)(context);
12
+ const cliArgumentObject = (0, utils_1.parseAutorunExecutorOptions)(terminalAndExecutorOptions, normalizedContext);
13
+ const { dryRun, verbose } = terminalAndExecutorOptions;
14
+ const command = (0, cli_1.createCliCommand)(constants_1.AUTORUN_COMMAND, cliArgumentObject);
15
+ const commandOptions = context.cwd ? { cwd: context.cwd } : {};
16
+ if (verbose) {
17
+ devkit_1.logger.info(`Run ${constants_1.AUTORUN_COMMAND} executor`);
18
+ devkit_1.logger.info(`Command: ${command}`);
19
+ }
20
+ if (dryRun) {
21
+ devkit_1.logger.warn(`DryRun execution of: ${command}`);
22
+ }
23
+ else {
24
+ try {
25
+ // @TODO use executeProcess instead of execSync -> non blocking, logs #761
26
+ // eslint-disable-next-line n/no-sync
27
+ (0, node_child_process_1.execSync)(command, commandOptions);
28
+ }
29
+ catch (error) {
30
+ devkit_1.logger.error(error);
31
+ return Promise.resolve({
32
+ success: false,
33
+ command,
34
+ error,
35
+ });
36
+ }
37
+ }
38
+ return Promise.resolve({
39
+ success: true,
40
+ command,
41
+ });
42
+ }
43
+ exports.default = runAutorunExecutor;
44
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/autorun/executor.ts"],"names":[],"mappings":";;AAAA,uCAA0D;AAC1D,qCAAqC;AACrC,2DAA8C;AAC9C,yCAAmD;A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0,0 +1,7 @@
1
+ import type { PersistConfig, UploadConfig } from '@code-pushup/models';
2
+ import type { CollectExecutorOnlyOptions, GeneralExecutorOnlyOptions, GlobalExecutorOptions, ProjectExecutorOnlyOptions } from '../internal/types';
3
+ export type AutorunCommandExecutorOnlyOptions = ProjectExecutorOnlyOptions & CollectExecutorOnlyOptions & GeneralExecutorOnlyOptions;
4
+ export type AutorunCommandExecutorOptions = Partial<{
5
+ upload: Partial<UploadConfig>;
6
+ persist: Partial<PersistConfig>;
7
+ } & AutorunCommandExecutorOnlyOptions & GlobalExecutorOptions>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/autorun/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,100 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "AutorunExecutorOptions",
4
+ "title": "CodePushup CLI autorun executor",
5
+ "description": "Executes the @code-pushup/cli autorun command See: https://github.com/code-pushup/cli/blob/main/packages/cli/README.md#autorun-command",
6
+ "type": "object",
7
+ "properties": {
8
+ "project": {
9
+ "type": "string",
10
+ "description": "The name of the project.",
11
+ "x-prompt": "Which project should configure Code Pushup?",
12
+ "x-dropdown": "projects",
13
+ "$default": {
14
+ "$source": "argv",
15
+ "index": 0
16
+ }
17
+ },
18
+ "dryRun": {
19
+ "type": "boolean",
20
+ "description": "Print the commands that would be run, but don't actually run them"
21
+ },
22
+ "bin": {
23
+ "type": "string",
24
+ "description": "Path to Code PushUp CLI"
25
+ },
26
+ "verbose": {
27
+ "type": "boolean",
28
+ "description": "Print additional logs"
29
+ },
30
+ "progress": {
31
+ "type": "boolean",
32
+ "description": "Print additional logs"
33
+ },
34
+ "onlyPlugins": {
35
+ "type": "array",
36
+ "items": {
37
+ "type": "string"
38
+ },
39
+ "description": "Only run the specified plugins"
40
+ },
41
+ "config": {
42
+ "type": "string",
43
+ "description": "Path to the configuration file"
44
+ },
45
+ "projectPrefix": {
46
+ "type": "string",
47
+ "description": "Prefix for project name"
48
+ },
49
+ "persist": {
50
+ "type": "object",
51
+ "properties": {
52
+ "filename": {
53
+ "type": "string",
54
+ "description": "Filename to save the configuration"
55
+ },
56
+ "outputDir": {
57
+ "type": "string",
58
+ "description": "Directory to save the configuration"
59
+ },
60
+ "format": {
61
+ "type": "array",
62
+ "enum": ["json", "md"],
63
+ "description": "Format to save the report in"
64
+ }
65
+ }
66
+ },
67
+ "upload": {
68
+ "type": "object",
69
+ "properties": {
70
+ "server": {
71
+ "type": "string",
72
+ "format": "uri",
73
+ "description": "URL of deployed portal API"
74
+ },
75
+ "apiKey": {
76
+ "type": "string",
77
+ "description": "API key with write access to portal (use `process.env` for security)"
78
+ },
79
+ "organization": {
80
+ "type": "string",
81
+ "pattern": "^[a-z\\d]+(?:-[a-z\\d]+)*$",
82
+ "maxLength": 128,
83
+ "description": "Organization slug from Code PushUp portal"
84
+ },
85
+ "project": {
86
+ "type": "string",
87
+ "pattern": "^[a-z\\d]+(?:-[a-z\\d]+)*$",
88
+ "maxLength": 128,
89
+ "description": "Project slug from Code PushUp portal"
90
+ },
91
+ "timeout": {
92
+ "type": "integer",
93
+ "exclusiveMinimum": 0,
94
+ "description": "Request timeout in minutes"
95
+ }
96
+ }
97
+ }
98
+ },
99
+ "additionalProperties": true
100
+ }
@@ -0,0 +1,4 @@
1
+ import type { NormalizedExecutorContext } from '../internal/context';
2
+ import type { AutorunCommandExecutorOnlyOptions, AutorunCommandExecutorOptions } from './schema';
3
+ export declare function parseAutorunExecutorOnlyOptions(options: Partial<AutorunCommandExecutorOnlyOptions>): AutorunCommandExecutorOnlyOptions;
4
+ export declare function parseAutorunExecutorOptions(options: Partial<AutorunCommandExecutorOptions>, normalizedContext: NormalizedExecutorContext): AutorunCommandExecutorOptions;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseAutorunExecutorOptions = exports.parseAutorunExecutorOnlyOptions = void 0;
4
+ const config_1 = require("../internal/config");
5
+ function parseAutorunExecutorOnlyOptions(options) {
6
+ const { projectPrefix, dryRun, onlyPlugins } = options;
7
+ return {
8
+ ...(projectPrefix && { projectPrefix }),
9
+ ...(dryRun != null && { dryRun }),
10
+ ...(onlyPlugins && { onlyPlugins }),
11
+ };
12
+ }
13
+ exports.parseAutorunExecutorOnlyOptions = parseAutorunExecutorOnlyOptions;
14
+ function parseAutorunExecutorOptions(options, normalizedContext) {
15
+ const { projectPrefix, persist, upload } = options;
16
+ return {
17
+ ...parseAutorunExecutorOnlyOptions(options),
18
+ ...(0, config_1.globalConfig)(options, normalizedContext),
19
+ persist: (0, config_1.persistConfig)({ projectPrefix, ...persist }, normalizedContext),
20
+ upload: (0, config_1.uploadConfig)({ projectPrefix, ...upload }, normalizedContext),
21
+ };
22
+ }
23
+ exports.parseAutorunExecutorOptions = parseAutorunExecutorOptions;
24
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/autorun/utils.ts"],"names":[],"mappings":";;;AAAA,+CAA+E;AAO/E,SAAgB,+BAA+B,CAC7C,OAAmD;IAEnD,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACvD,OAAO;QACL,GAAG,CAAC,aAAa,IAAI,EAAE,aAAa,EAAE,CAAC;QACvC,GAAG,CAAC,MAAM,IAAI,IAAI,IAAI,EAAE,MAAM,EAAE,CAAC;QACjC,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC;AATD,0EASC;AAED,SAAgB,2BAA2B,CACzC,OAA+C,EAC/C,iBAA4C;IAE5C,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACnD,OAAO;QACL,GAAG,+BAA+B,CAAC,OAAO,CAAC;QAC3C,GAAG,IAAA,qBAAY,EAAC,OAAO,EAAE,iBAAiB,CAAC;QAC3C,OAAO,EAAE,IAAA,sBAAa,EAAC,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,EAAE,iBAAiB,CAAC;QACxE,MAAM,EAAE,IAAA,qBAAY,EAAC,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,EAAE,iBAAiB,CAAC;KACtE,CAAC;AACJ,CAAC;AAXD,kEAWC"}
@@ -0,0 +1,10 @@
1
+ export declare function createCliCommand(command: string, args: Record<string, unknown>, options?: {
2
+ bin: string;
3
+ }): string;
4
+ type ArgumentValue = number | string | boolean | string[];
5
+ export type CliArgsObject<T extends object = Record<string, ArgumentValue>> = T extends never ? // eslint-disable-next-line @typescript-eslint/naming-convention
6
+ Record<string, ArgumentValue | undefined> | {
7
+ _: string;
8
+ } : T;
9
+ export declare function objectToCliArgs<T extends object = Record<string, ArgumentValue>>(params?: CliArgsObject<T>): string[];
10
+ export {};
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objectToCliArgs = exports.createCliCommand = void 0;
4
+ function createCliCommand(command, args, options) {
5
+ const { bin = '@code-pushup/cli' } = options ?? {};
6
+ return `npx ${bin} ${command} ${objectToCliArgs(args).join(' ')}`;
7
+ }
8
+ exports.createCliCommand = createCliCommand;
9
+ // @TODO import from @code-pushup/utils => get rid of poppins for cjs support
10
+ // eslint-disable-next-line sonarjs/cognitive-complexity
11
+ function objectToCliArgs(params) {
12
+ if (!params) {
13
+ return [];
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
16
+ return Object.entries(params).flatMap(([key, value]) => {
17
+ // process/file/script
18
+ if (key === '_') {
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
20
+ return Array.isArray(value) ? value : [`${value}`];
21
+ }
22
+ const prefix = key.length === 1 ? '-' : '--';
23
+ // "-*" arguments (shorthands)
24
+ if (Array.isArray(value)) {
25
+ return value.map(v => `${prefix}${key}="${v}"`);
26
+ }
27
+ if (typeof value === 'object') {
28
+ return Object.entries(value).flatMap(
29
+ // transform nested objects to the dot notation `key.subkey`
30
+ ([k, v]) => objectToCliArgs({ [`${key}.${k}`]: v }));
31
+ }
32
+ if (typeof value === 'string') {
33
+ return [`${prefix}${key}="${value}"`];
34
+ }
35
+ if (typeof value === 'number') {
36
+ return [`${prefix}${key}=${value}`];
37
+ }
38
+ if (typeof value === 'boolean') {
39
+ return [`${prefix}${value ? '' : 'no-'}${key}`];
40
+ }
41
+ if (value === undefined) {
42
+ return [];
43
+ }
44
+ throw new Error(`Unsupported type ${typeof value} for key ${key}`);
45
+ });
46
+ }
47
+ exports.objectToCliArgs = objectToCliArgs;
48
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/internal/cli.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gBAAgB,CAC9B,OAAe,EACf,IAA6B,EAC7B,OAEC;IAED,MAAM,EAAE,GAAG,GAAG,kBAAkB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACnD,OAAO,OAAO,GAAG,IAAI,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACpE,CAAC;AATD,4CASC;AAQD,6EAA6E;AAC7E,wDAAwD;AACxD,SAAgB,eAAe,CAE7B,MAAyB;IACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,+DAA+D;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACrD,sBAAsB;QACtB,IAAI,GA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AC;QAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,KAAK,YAAY,GAAG,EAAE,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC;AA9CD,0CA8CC"}
@@ -0,0 +1,5 @@
1
+ import type { PersistConfig, UploadConfig } from '@code-pushup/models';
2
+ import type { BaseNormalizedExecutorContext, GlobalExecutorOptions, ProjectExecutorOnlyOptions } from './types';
3
+ export declare function globalConfig(options: Partial<GlobalExecutorOptions & Record<string, unknown>>, context: BaseNormalizedExecutorContext): GlobalExecutorOptions;
4
+ export declare function persistConfig(options: Partial<PersistConfig & ProjectExecutorOnlyOptions>, context: BaseNormalizedExecutorContext): Partial<PersistConfig>;
5
+ export declare function uploadConfig(options: Partial<UploadConfig & ProjectExecutorOnlyOptions>, context: BaseNormalizedExecutorContext): Partial<UploadConfig>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadConfig = exports.persistConfig = exports.globalConfig = void 0;
4
+ const node_path_1 = require("node:path");
5
+ const env_1 = require("./env");
6
+ function globalConfig(options, context) {
7
+ const { projectConfig } = context;
8
+ const { root: projectRoot = '' } = projectConfig ?? {};
9
+ // For better debugging use `--verbose --no-progress` as default
10
+ const { verbose, progress, config } = options;
11
+ return {
12
+ verbose: !!verbose,
13
+ progress: !!progress,
14
+ config: config ?? (0, node_path_1.join)(projectRoot, 'code-pushup.config.ts'),
15
+ };
16
+ }
17
+ exports.globalConfig = globalConfig;
18
+ function persistConfig(options, context) {
19
+ const { projectConfig, workspaceRoot } = context;
20
+ const { name: projectName = '' } = projectConfig ?? {};
21
+ const { format, outputDir = (0, node_path_1.join)(workspaceRoot, '.code-pushup', projectName), // always in <root>/.code-pushup/<project-name>,
22
+ filename, } = options;
23
+ return {
24
+ outputDir,
25
+ ...(format ? { format } : {}),
26
+ ...(filename ? { filename } : {}),
27
+ };
28
+ }
29
+ exports.persistConfig = persistConfig;
30
+ function uploadConfig(options, context) {
31
+ const { projectConfig, workspaceRoot } = context;
32
+ const { name: projectName } = projectConfig ?? {};
33
+ const { projectPrefix, server, apiKey, organization, project, timeout } = options;
34
+ const applyPrefix = workspaceRoot === '.';
35
+ const prefix = projectPrefix ? `${projectPrefix}-` : '';
36
+ return {
37
+ ...(projectName
38
+ ? {
39
+ project: applyPrefix ? `${prefix}${projectName}` : projectName, // provide correct project
40
+ }
41
+ : {}),
42
+ ...(0, env_1.parseEnv)(process.env),
43
+ ...Object.fromEntries(Object.entries({ server, apiKey, organization, project, timeout }).filter(([_, v]) => v !== undefined)),
44
+ };
45
+ }
46
+ exports.uploadConfig = uploadConfig;
47
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/internal/config.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAEjC,+BAAiC;AAOjC,SAAgB,YAAY,CAC1B,OAAiE,EACjE,OAAsC;IAEtC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,aAAa,IAAI,EAAE,CAAC;IACvD,gEAAgE;IAChE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC9C,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,MAAM,EAAE,MAAM,IAAI,IAAA,gBAAI,EAAC,WAAW,EAAE,uBAAuB,CAAC;KAC7D,CAAC;AACJ,CAAC;AAbD,oCAaC;AAED,SAAgB,aAAa,CAC3B,OAA4D,EAC5D,OAAsC;IAEtC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAEj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M,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CACvE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAC5B,CACF;KACF,CAAC;AACJ,CAAC;AAxBD,oCAwBC"}
@@ -0,0 +1,6 @@
1
+ import type { ExecutorContext } from 'nx/src/config/misc-interfaces';
2
+ import type { BaseNormalizedExecutorContext } from './types';
3
+ export type NormalizedExecutorContext = BaseNormalizedExecutorContext & {
4
+ projectName: string;
5
+ };
6
+ export declare function normalizeContext(context: ExecutorContext): NormalizedExecutorContext;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeContext = void 0;
4
+ function normalizeContext(context) {
5
+ const { projectName = '', root: workspaceRoot, projectsConfigurations, } = context;
6
+ return {
7
+ projectName,
8
+ projectConfig: projectsConfigurations?.projects[projectName],
9
+ workspaceRoot,
10
+ };
11
+ }
12
+ exports.normalizeContext = normalizeContext;
13
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/internal/context.ts"],"names":[],"mappings":";;;AAOA,SAAgB,gBAAgB,CAC9B,OAAwB;IAExB,MAAM,EACJ,WAAW,GAAG,EAAE,EAChB,IAAI,EAAE,aAAa,EACnB,sBAAsB,GACvB,GAAG,OAAO,CAAC;IACZ,OAAO;QACL,WAAW;QACX,aAAa,EAAE,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAAC;QAC5D,aAAa;KACd,CAAC;AACJ,CAAC;AAbD,4CAaC"}
@@ -0,0 +1,2 @@
1
+ import type { UploadConfig } from '@code-pushup/models';
2
+ export declare function parseEnv(env?: unknown): Partial<UploadConfig>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseEnv = void 0;
4
+ const zod_1 = require("zod");
5
+ // load upload configuration from environment
6
+ const envSchema = zod_1.z
7
+ .object({
8
+ CP_SERVER: zod_1.z.string().url().optional(),
9
+ CP_API_KEY: zod_1.z.string().min(1).optional(),
10
+ CP_ORGANIZATION: zod_1.z.string().min(1).optional(),
11
+ CP_PROJECT: zod_1.z.string().min(1).optional(),
12
+ CP_TIMEOUT: zod_1.z.string().regex(/^\d+$/).optional(),
13
+ })
14
+ .partial();
15
+ function parseEnv(env = {}) {
16
+ const upload = envSchema.parse(env);
17
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
18
+ return Object.fromEntries(Object.entries(upload).map(([envKey, value]) => {
19
+ switch (envKey) {
20
+ case 'CP_SERVER':
21
+ return ['server', value];
22
+ case 'CP_API_KEY':
23
+ return ['apiKey', value];
24
+ case 'CP_ORGANIZATION':
25
+ return ['organization', value];
26
+ case 'CP_PROJECT':
27
+ return ['project', value];
28
+ case 'CP_TIMEOUT':
29
+ return Number(value) >= 0 ? ['timeout', Number(value)] : [];
30
+ default:
31
+ return [];
32
+ }
33
+ }));
34
+ }
35
+ exports.parseEnv = parseEnv;
36
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/internal/env.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAGxB,6CAA6C;AAC7C,MAAM,SAAS,GAAG,OAAC;KAChB,MAAM,CAAC;IACN,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACtC,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7C,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACxC,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE;CACjD,CAAC;KACD,OAAO,EAAE,CAAC;AAIb,SAAgB,QAAQ,CAAC,MAAe,EAAE;IACxC,MAAM,MAAM,GAAkB,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnD,+DAA+D;IAC/D,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE;QAC7C,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,WAAW;gBACd,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC3B,KAAK,YAAY;gBACf,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC3B,KAAK,iBAAiB;gBACpB,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YACjC,KAAK,YAAY;gBACf,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC5B,KAAK,YAAY;gBACf,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D;gBACE,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AArBD,4BAqBC"}
@@ -0,0 +1,39 @@
1
+ import type { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json';
2
+ /**
3
+ * Types used in the executor only
4
+ */
5
+ export type GeneralExecutorOnlyOptions = {
6
+ dryRun?: boolean;
7
+ };
8
+ /**
9
+ * executor types that apply for a subset of exector's.
10
+ * In this case the project related options
11
+ *
12
+ */
13
+ export type ProjectExecutorOnlyOptions = {
14
+ projectPrefix?: string;
15
+ };
16
+ /**
17
+ * CLI types that apply globally for all commands.
18
+ */
19
+ export type GlobalExecutorOptions = {
20
+ bin?: string;
21
+ verbose?: boolean;
22
+ progress?: boolean;
23
+ config?: string;
24
+ };
25
+ /**
26
+ * CLI types that apply for a subset of commands.
27
+ * In this case the collection of data (collect, autorun, history)
28
+ */
29
+ export type CollectExecutorOnlyOptions = {
30
+ onlyPlugins?: string[];
31
+ };
32
+ /**
33
+ * context that is normalized for all executor's
34
+ */
35
+ export type BaseNormalizedExecutorContext = {
36
+ projectConfig?: ProjectConfiguration;
37
+ } & {
38
+ workspaceRoot: string;
39
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/executors/internal/types.ts"],"names":[],"mappings":""}