Skip to content

Commit 88c4ab4

Browse files
committed
fix: add initial proper structure for an Nx Plugin
1 parent d56ecc4 commit 88c4ab4

36 files changed

+452
-27
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"root": true,
3+
"ignorePatterns": ["**/*"],
34
"plugins": ["@nrwl/nx"],
45
"overrides": [
56
{

.vscode/extensions.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"recommendations": [
33
"ms-vscode.vscode-typescript-tslint-plugin",
44
"esbenp.prettier-vscode",
5-
"firsttris.vscode-jest-runner"
5+
"firsttris.vscode-jest-runner",
6+
"nrwl.angular-console",
7+
"dbaeumer.vscode-eslint"
68
]
79
}

apps\ddd-e2e/project.json renamed to apps/ddd-e2e/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"projectType": "application",
3-
"root": "apps\\ddd-e2e",
4-
"sourceRoot": "apps\\ddd-e2e/src",
3+
"root": "apps/ddd-e2e",
4+
"sourceRoot": "apps/ddd-e2e/src",
55
"targets": {
66
"e2e": {
77
"executor": "@nrwl/nx-plugin:e2e",

e2e/ddd-e2e/jest.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
displayName: 'ddd-e2e',
3+
preset: '../../jest.preset.js',
4+
globals: {
5+
'ts-jest': {
6+
tsconfig: '<rootDir>/tsconfig.spec.json',
7+
},
8+
},
9+
transform: {
10+
'^.+\\.[tj]s$': 'ts-jest',
11+
},
12+
moduleFileExtensions: ['ts', 'js', 'html'],
13+
coverageDirectory: '../../coverage/e2e/ddd-e2e',
14+
};

e2e/ddd-e2e/project.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"root": "e2e/ddd-e2e",
3+
"projectType": "application",
4+
"sourceRoot": "e2e/ddd-e2e/src",
5+
"targets": {
6+
"e2e": {
7+
"executor": "@nrwl/nx-plugin:e2e",
8+
"options": {
9+
"target": "ddd:build",
10+
"jestConfig": "e2e/ddd-e2e/jest.config.js"
11+
}
12+
}
13+
},
14+
"tags": [],
15+
"implicitDependencies": ["ddd"]
16+
}

e2e/ddd-e2e/tests/ddd.spec.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {
2+
checkFilesExist,
3+
ensureNxProject,
4+
readJson,
5+
runNxCommandAsync,
6+
uniq,
7+
} from '@nrwl/nx-plugin/testing';
8+
describe('ddd e2e', () => {
9+
it('should create ddd', async () => {
10+
const plugin = uniq('ddd');
11+
ensureNxProject('@angular-architects/ddd', 'dist/packages/ddd');
12+
await runNxCommandAsync(`generate @angular-architects/ddd:ddd ${plugin}`);
13+
14+
const result = await runNxCommandAsync(`build ${plugin}`);
15+
expect(result.stdout).toContain('Executor ran');
16+
}, 120000);
17+
18+
describe('--directory', () => {
19+
it('should create src in the specified directory', async () => {
20+
const plugin = uniq('ddd');
21+
ensureNxProject('@angular-architects/ddd', 'dist/packages/ddd');
22+
await runNxCommandAsync(
23+
`generate @angular-architects/ddd:ddd ${plugin} --directory subdir`
24+
);
25+
expect(() =>
26+
checkFilesExist(`libs/subdir/${plugin}/src/index.ts`)
27+
).not.toThrow();
28+
}, 120000);
29+
});
30+
31+
describe('--tags', () => {
32+
it('should add tags to the project', async () => {
33+
const plugin = uniq('ddd');
34+
ensureNxProject('@angular-architects/ddd', 'dist/packages/ddd');
35+
await runNxCommandAsync(
36+
`generate @angular-architects/ddd:ddd ${plugin} --tags e2etag,e2ePackage`
37+
);
38+
const project = readJson(`libs/${plugin}/project.json`);
39+
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);
40+
}, 120000);
41+
});
42+
});

e2e/ddd-e2e/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.e2e.json"
8+
},
9+
{
10+
"path": "./tsconfig.spec.json"
11+
}
12+
]
13+
}

e2e/ddd-e2e/tsconfig.spec.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"module": "commonjs",
6+
"types": ["jest", "node"]
7+
},
8+
"include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
9+
}

jest.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
const { getJestProjects } = require('@nrwl/jest');
22

3-
module.exports = { projects: getJestProjects() };
3+
module.exports = {
4+
projects: getJestProjects(),
5+
};

jest.preset.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
const nxPreset = require('@nrwl/jest/preset');
2-
module.exports = {
3-
...nxPreset,
4-
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
5-
transform: {
6-
'^.+\\.(ts|js|html)$': 'ts-jest',
7-
},
8-
resolver: '@nrwl/jest/plugins/resolver',
9-
moduleFileExtensions: ['ts', 'js', 'html'],
10-
coverageReporters: ['html'],
11-
};
2+
3+
module.exports = { ...nxPreset };

0 commit comments

Comments
 (0)