@nx/dotnet 22.7.0-rc.2 → 23.0.0-beta.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.
@@ -0,0 +1,18 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export type Command = {
3
+ command?: string;
4
+ comments?: string[];
5
+ alwaysRun?: boolean;
6
+ };
7
+ export interface Schema {
8
+ name: string;
9
+ ci: 'github' | 'circleci';
10
+ /**
11
+ * Custom commands to run in the CI workflow.
12
+ * If not provided, default commands will be generated based on the CI provider.
13
+ */
14
+ commands?: Command[];
15
+ }
16
+ export declare function ciWorkflowGenerator(tree: Tree, schema: Schema): Promise<void>;
17
+ export default ciWorkflowGenerator;
18
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/ci-workflow/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EACL,MAAM,YAAY,CAAC;AA0CpB,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAMnE;AAsCD,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ciWorkflowGenerator = ciWorkflowGenerator;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const nx_cloud_utils_1 = require("nx/src/utils/nx-cloud-utils");
7
+ const default_base_1 = require("nx/src/utils/default-base");
8
+ const NX_AFFECTED_COMMENT = `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`;
9
+ function getCiCommands(ci) {
10
+ switch (ci) {
11
+ case 'circleci': {
12
+ return [
13
+ {
14
+ comments: [NX_AFFECTED_COMMENT],
15
+ },
16
+ {
17
+ command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t build`,
18
+ },
19
+ getNxCloudFixCiCommand(),
20
+ ];
21
+ }
22
+ default: {
23
+ return [
24
+ {
25
+ comments: [NX_AFFECTED_COMMENT],
26
+ command: `./nx affected -t build`,
27
+ },
28
+ getNxCloudFixCiCommand(),
29
+ ];
30
+ }
31
+ }
32
+ }
33
+ function getNxCloudFixCiCommand() {
34
+ return {
35
+ comments: [
36
+ `Nx Cloud recommends fixes for failures to help you get CI green faster. Learn more: https://nx.dev/ci/features/self-healing-ci`,
37
+ ],
38
+ command: `./nx fix-ci`,
39
+ alwaysRun: true,
40
+ };
41
+ }
42
+ async function ciWorkflowGenerator(tree, schema) {
43
+ const ci = schema.ci;
44
+ const options = getTemplateData(tree, schema);
45
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', ci), '', options);
46
+ await (0, devkit_1.formatFiles)(tree);
47
+ }
48
+ function getTemplateData(tree, options) {
49
+ const { name: workflowName, fileName: workflowFileName } = (0, devkit_1.names)(options.name);
50
+ let nxCloudHost = 'nx.app';
51
+ try {
52
+ const nxCloudUrl = (0, nx_cloud_utils_1.getNxCloudUrl)((0, devkit_1.readNxJson)(tree));
53
+ nxCloudHost = new URL(nxCloudUrl).host;
54
+ }
55
+ catch { }
56
+ const mainBranch = (0, default_base_1.deduceDefaultBase)();
57
+ const commands = options.commands ?? getCiCommands(options.ci);
58
+ const connectedToCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, devkit_1.readNxJson)(tree));
59
+ return {
60
+ workflowName,
61
+ workflowFileName,
62
+ commands,
63
+ mainBranch,
64
+ nxCloudHost,
65
+ connectedToCloud,
66
+ };
67
+ }
68
+ exports.default = ciWorkflowGenerator;
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxDotnetCiWorkflowSchema",
4
+ "title": ".NET CI Workflow Generator",
5
+ "description": "Setup a CI Workflow to run Nx in CI.",
6
+ "type": "object",
7
+ "properties": {
8
+ "ci": {
9
+ "type": "string",
10
+ "description": "CI provider.",
11
+ "enum": ["github", "circleci"],
12
+ "x-prompt": {
13
+ "message": "What is your target CI provider?",
14
+ "type": "list",
15
+ "items": [
16
+ {
17
+ "value": "github",
18
+ "label": "GitHub Actions"
19
+ },
20
+ {
21
+ "value": "circleci",
22
+ "label": "Circle CI"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ "name": {
28
+ "type": "string",
29
+ "description": "Workflow name.",
30
+ "$default": {
31
+ "$source": "argv",
32
+ "index": 0
33
+ },
34
+ "default": "CI",
35
+ "x-prompt": "How should we name your workflow?",
36
+ "pattern": "^[a-zA-Z].*$"
37
+ }
38
+ },
39
+ "required": ["ci", "name"]
40
+ }
Binary file
Binary file
package/generators.json CHANGED
@@ -5,6 +5,11 @@
5
5
  "implementation": "./dist/generators/init/init",
6
6
  "schema": "./dist/generators/init/schema.json",
7
7
  "description": "Initialize .NET support in an Nx workspace"
8
+ },
9
+ "ci-workflow": {
10
+ "implementation": "./dist/generators/ci-workflow/generator",
11
+ "schema": "./dist/generators/ci-workflow/schema.json",
12
+ "description": "Setup a CI Workflow to run Nx in CI"
8
13
  }
9
14
  }
10
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/dotnet",
3
- "version": "22.7.0-rc.2",
3
+ "version": "23.0.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for .NET containing graph support for working with .NET projects in an Nx workspace.",
6
6
  "keywords": [
@@ -50,7 +50,7 @@
50
50
  "!dist/tsconfig.lib.tsbuildinfo"
51
51
  ],
52
52
  "dependencies": {
53
- "@nx/devkit": "22.7.0-rc.2",
53
+ "@nx/devkit": "23.0.0-beta.0",
54
54
  "tslib": "^2.3.0",
55
55
  "ignore": "^7.0.5"
56
56
  },
@@ -59,7 +59,7 @@
59
59
  "@types/node": "^20.19.10",
60
60
  "jest": "^30.0.2",
61
61
  "memfs": "^4.9.2",
62
- "nx": "22.7.0-rc.2",
62
+ "nx": "23.0.0-beta.0",
63
63
  "ts-jest": "^29.4.0",
64
64
  "typescript": "~5.9.2"
65
65
  },