Skip to content

Commit d393b3a

Browse files
jimsleonLeon ChiAgentEnder
authored
fix: compatibility with nx 12.6+
BREAKING CHANGE: Minimum Nx version is 12.6, if using the dep-graph plugin. Co-authored-by: Leon Chi <leon.chi@serko.com> Co-authored-by: Craigory Coppola <craigorycoppola@gmail.com>
1 parent 8f925f5 commit d393b3a

File tree

21 files changed

+496
-630
lines changed

21 files changed

+496
-630
lines changed

apps/nx-ghpages-e2e/project.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"executor": "@nrwl/nx-plugin:e2e",
88
"options": {
99
"target": "nx-ghpages:build",
10-
"npmPackageName": "@nx-dotnet/nx-ghpages",
11-
"pluginOutputPath": "dist/packages/nx-ghpages",
1210
"jestConfig": "apps/nx-ghpages-e2e/jest.config.js"
1311
}
1412
}

e2e/core-e2e/project.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"executor": "@nrwl/nx-plugin:e2e",
88
"options": {
99
"target": "core:build",
10-
"npmPackageName": "@nx-dotnet/core",
11-
"pluginOutputPath": "dist/packages/core",
1210
"jestConfig": "e2e/core-e2e/jest.config.js"
1311
}
1412
}

e2e/core-e2e/tests/nx-dotnet.spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import { names } from '@nrwl/devkit';
12
import {
23
checkFilesExist,
34
ensureNxProject,
5+
readFile,
46
runNxCommandAsync,
57
uniq,
68
} from '@nrwl/nx-plugin/testing';
79

10+
import { readFileSync } from 'fs';
11+
import { join } from 'path';
12+
import { XmlDocument } from 'xmldoc';
13+
14+
import { findProjectFileInPathSync } from '@nx-dotnet/utils';
15+
816
describe('nx-dotnet e2e', () => {
917
it('should create apps, libs, and project references', async () => {
1018
const testApp = uniq('app');
@@ -58,6 +66,45 @@ describe('nx-dotnet e2e', () => {
5866

5967
expect(exists).toBeTruthy();
6068
});
69+
70+
it('should update output paths', async () => {
71+
const app = uniq('app');
72+
await runNxCommandAsync(
73+
`generate @nx-dotnet/core:app ${app} --language="C#" --template="webapi"`,
74+
);
75+
const configFilePath = findProjectFileInPathSync(
76+
join('tmp/nx-e2e/proj/apps', app),
77+
);
78+
const config = readFileSync(configFilePath).toString();
79+
const projectXml = new XmlDocument(config);
80+
const outputPath = projectXml
81+
.childNamed('PropertyGroup')
82+
?.childNamed('OutputPath')?.val as string;
83+
expect(outputPath).toBeTruthy();
84+
});
85+
});
86+
87+
describe('nx g test', () => {
88+
xit('should add a reference to the target project', async () => {
89+
const app = uniq('app');
90+
await runNxCommandAsync(
91+
`generate @nx-dotnet/core:app ${app} --language="C#" --template="webapi" --test-template="none"`,
92+
);
93+
const testProject = `${app}.Test`;
94+
await runNxCommandAsync(
95+
`generate @nx-dotnet/core:test ${app} --language="C#" --template="nunit"`,
96+
);
97+
98+
const config = readFile(
99+
join('apps', app, `Proj.${names(testProject).className}.csproj`),
100+
);
101+
const projectXml = new XmlDocument(config);
102+
const projectReference = projectXml
103+
.childrenNamed('ItemGroup')[1]
104+
?.childNamed('ProjectReference');
105+
106+
expect(projectReference).toBeDefined();
107+
});
61108
});
62109

63110
describe('nx g lib', () => {

e2e/nxdoc-e2e/project.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"executor": "@nrwl/nx-plugin:e2e",
88
"options": {
99
"target": "nxdoc:build",
10-
"npmPackageName": "@nx-dotnet/nxdoc",
11-
"pluginOutputPath": "dist/packages/nxdoc",
1210
"jestConfig": "e2e/nxdoc-e2e/jest.config.js"
1311
}
1412
}

e2e/typescript-e2e/project.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"executor": "@nrwl/nx-plugin:e2e",
88
"options": {
99
"target": "typescript:build",
10-
"npmPackageName": "@nx-dotnet/typescript",
11-
"pluginOutputPath": "dist/packages/typescript",
1210
"jestConfig": "e2e/typescript-e2e/jest.config.js"
1311
}
1412
}

e2e/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { detectPackageManager } from '@nrwl/tao/src/shared/package-manager';
2+
23
import { ChildProcess, exec, execSync } from 'child_process';
34
import {
45
copySync,
@@ -12,10 +13,10 @@ import {
1213
statSync,
1314
writeFileSync,
1415
} from 'fs-extra';
15-
import isCI = require('is-ci');
1616
import * as path from 'path';
1717
import { dirSync } from 'tmp';
1818

19+
import isCI = require('is-ci');
1920
interface RunCmdOpts {
2021
silenceError?: boolean;
2122
env?: Record<string, string> | NodeJS.ProcessEnv;

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"publish-local": "cp .npmrc.local .npmrc && run-p \"rimraf tmp\" e2e-registry \"ts-node ./tools/scripts/publish-all 99.99.99 local\"",
3232
"semantic-release": "semantic-release",
3333
"ts-node": "ts-node",
34-
"rimraf": "rimraf"
34+
"rimraf": "rimraf",
35+
"preinstall": "node ./tools/scripts/hooks/preinstall.js"
3536
},
3637
"private": false,
3738
"dependencies": {
@@ -56,16 +57,16 @@
5657
"@commitlint/cli": "^12.1.1",
5758
"@commitlint/config-conventional": "^12.1.1",
5859
"@commitlint/types": "^12.1.1",
59-
"@nrwl/cli": "12.5.7",
60-
"@nrwl/devkit": "12.5.7",
61-
"@nrwl/eslint-plugin-nx": "12.5.7",
62-
"@nrwl/jest": "12.5.7",
63-
"@nrwl/linter": "12.5.7",
64-
"@nrwl/node": "12.5.7",
65-
"@nrwl/nx-cloud": "12.2.7",
66-
"@nrwl/nx-plugin": "12.5.7",
67-
"@nrwl/tao": "12.5.7",
68-
"@nrwl/workspace": "12.5.7",
60+
"@nrwl/cli": "12.6.2",
61+
"@nrwl/devkit": "12.6.2",
62+
"@nrwl/eslint-plugin-nx": "12.6.2",
63+
"@nrwl/jest": "12.6.2",
64+
"@nrwl/linter": "12.6.2",
65+
"@nrwl/node": "12.6.2",
66+
"@nrwl/nx-cloud": "12.3.5",
67+
"@nrwl/nx-plugin": "12.6.2",
68+
"@nrwl/tao": "12.6.2",
69+
"@nrwl/workspace": "12.6.2",
6970
"@nx-dotnet/nxdoc": "latest",
7071
"@nx-plus/docusaurus": "^12.0.0",
7172
"@semantic-release/changelog": "^5.0.1",
@@ -108,5 +109,5 @@
108109
"type": "git",
109110
"url": "https://github.com/nx-dotnet/nx-dotnet.git"
110111
},
111-
"version": "0.15.0"
112+
"version": "99.99.99"
112113
}

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"email": "craigorycoppola+nxdotnet@gmail.com"
1212
},
1313
"license": "MIT",
14-
"version": "0.15.0",
14+
"version": "99.99.99",
1515
"keywords": [
1616
"Nx",
1717
".NET",

packages/core/src/generators/test/schema.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
"description": "Generate a .NET test project for an existing application or library",
77
"type": "object",
88
"properties": {
9-
"project": {
9+
"name": {
1010
"type": "string",
1111
"description": "The existing project to generate tests for",
1212
"$default": {
1313
"$source": "argv",
1414
"index": 0
15-
}
15+
},
16+
"alias": ["project"]
1617
},
1718
"testTemplate": {
1819
"type": "string",

packages/core/src/generators/utils/generate-project.spec.ts

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import { readProjectConfiguration, Tree, writeJson } from '@nrwl/devkit';
22
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
33

4-
import { readFileSync } from 'fs';
54
import { resolve } from 'path';
6-
import { XmlDocument } from 'xmldoc';
75

8-
import {
9-
DotNetClient,
10-
dotnetFactory,
11-
dotnetNewOptions,
12-
mockDotnetFactory,
13-
} from '@nx-dotnet/dotnet';
14-
import { findProjectFileInPath, NXDOTNET_TAG, rimraf } from '@nx-dotnet/utils';
6+
import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet';
7+
import { NXDOTNET_TAG, rimraf } from '@nx-dotnet/utils';
158

169
import { NxDotnetProjectGeneratorSchema } from '../../models';
1710
import { GenerateProject } from './generate-project';
1811

12+
// eslint-disable-next-line @typescript-eslint/no-empty-function
13+
jest.spyOn(console, 'log').mockImplementation(() => {});
14+
1915
describe('nx-dotnet project generator', () => {
2016
let appTree: Tree;
2117
let dotnetClient: DotNetClient;
@@ -39,7 +35,7 @@ describe('nx-dotnet project generator', () => {
3935
});
4036

4137
afterEach(async () => {
42-
await Promise.all([rimraf('apps'), rimraf('libs'), rimraf('.config')]);
38+
// await Promise.all([rimraf('apps'), rimraf('libs'), rimraf('.config')]);
4339
});
4440

4541
it('should run successfully for libraries', async () => {
@@ -105,33 +101,4 @@ describe('nx-dotnet project generator', () => {
105101
const nameFlag = dotnetOptions?.find((flag) => flag.flag === 'name');
106102
expect(nameFlag?.value).toBe('Proj.SubDir.Test');
107103
});
108-
109-
/**
110-
* This test requires a live dotnet client.
111-
*/
112-
it('should update output paths in project file', async () => {
113-
await GenerateProject(
114-
appTree,
115-
{
116-
...options,
117-
skipOutputPathManipulation: false,
118-
},
119-
new DotNetClient(dotnetFactory()),
120-
'library',
121-
);
122-
const config = readProjectConfiguration(appTree, 'test');
123-
const projectFilePath = await findProjectFileInPath(config.root);
124-
const projectXml = new XmlDocument(
125-
readFileSync(projectFilePath).toString(),
126-
);
127-
const outputPath = projectXml
128-
.childNamed('PropertyGroup')
129-
?.childNamed('OutputPath')?.val as string;
130-
expect(outputPath).toBeTruthy();
131-
132-
const absoluteDistPath = resolve(config.root, outputPath);
133-
const expectedDistPath = resolve('./dist/libs/test');
134-
135-
expect(absoluteDistPath).toEqual(expectedDistPath);
136-
});
137104
});

0 commit comments

Comments
 (0)