Skip to content

Commit d0cbc35

Browse files
committed
feat(repo): build nx with nx
1 parent 2a3116f commit d0cbc35

File tree

147 files changed

+7447
-7587
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+7447
-7587
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- setup
8080
- run:
8181
name: Run Unit Tests
82-
command: yarn test:all
82+
command: yarn test
8383
- run:
8484
name: Check Documentation
8585
command: yarn documentation

.eslintrc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2018,
6+
"sourceType": "module",
7+
"project": "./tsconfig.json"
8+
},
9+
"ignorePatterns": ["**/*"],
10+
"plugins": ["@typescript-eslint", "@nrwl/nx"],
11+
"extends": [
12+
"eslint:recommended",
13+
"plugin:@typescript-eslint/eslint-recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"prettier",
16+
"prettier/@typescript-eslint"
17+
],
18+
"rules": {
19+
"@typescript-eslint/explicit-member-accessibility": "off",
20+
"@typescript-eslint/explicit-function-return-type": "off",
21+
"@typescript-eslint/no-parameter-properties": "off",
22+
"@nrwl/nx/enforce-module-boundaries": [
23+
"error",
24+
{
25+
"enforceBuildableLibDependency": true,
26+
"allow": [],
27+
"depConstraints": [
28+
{ "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
29+
]
30+
}
31+
]
32+
},
33+
"overrides": [
34+
{
35+
"files": ["*.tsx"],
36+
"rules": {
37+
"@typescript-eslint/no-unused-vars": "off"
38+
}
39+
}
40+
]
41+
}

e2e/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515

1616
forEachCli('nx', () => {
1717
describe('Help', () => {
18-
it('should show help', async () => {
18+
fit('should show help', async () => {
1919
ensureProject();
2020
const myapp = uniq('myapp');
2121
runCLI(`generate @nrwl/web:app ${myapp}`);

e2e/jest-config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
const pkg = require('../../package.json');
2-
31
module.exports = {
4-
...pkg.jest,
52
globalSetup: '<rootDir>/local-registry/setup.js',
63
globalTeardown: '<rootDir>/local-registry/teardown.js',
74
};

e2e/ng-add.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
readJson,
55
runCLI,
66
runCommand,
7-
runNew,
7+
runNgNew,
88
updateFile,
99
forEachCli,
1010
runNgAdd,
@@ -16,7 +16,7 @@ forEachCli('angular', () => {
1616
afterAll(cleanup);
1717

1818
it('should generate a workspace', () => {
19-
runNew('', false, false);
19+
runNgNew();
2020

2121
// update package.json
2222
const packageJson = readJson('package.json');
@@ -246,7 +246,7 @@ forEachCli('angular', () => {
246246

247247
it('should generate a workspace and not change dependencies, devDependencies, or vscode extensions if they already exist', () => {
248248
// create a new AngularCLI app
249-
runNew();
249+
runNgNew();
250250
const nxVersion = '0.0.0';
251251
const schematicsVersion = '0.0.0';
252252
const ngrxVersion = '0.0.0';
@@ -295,7 +295,7 @@ forEachCli('angular', () => {
295295

296296
it('should handle different types of errors', () => {
297297
// create a new AngularCLI app
298-
runNew();
298+
runNgNew();
299299

300300
// Only remove e2e directory
301301
runCommand('mv e2e e2e-bak');
@@ -339,7 +339,7 @@ forEachCli('angular', () => {
339339
});
340340

341341
it('should support preserveAngularCLILayout', () => {
342-
runNew('', false, false);
342+
runNgNew();
343343
runNgAdd('add @nrwl/workspace --preserveAngularCLILayout');
344344

345345
const updatedAngularCLIJson = readJson('angular.json');

e2e/node.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
readJson,
1515
runCLI,
1616
runCLIAsync,
17-
runNew,
17+
runNgNew,
1818
runNgAdd,
1919
tmpProjPath,
2020
uniq,
@@ -160,7 +160,7 @@ forEachCli((currentCLIName) => {
160160
// described in the docs) the tsconfig file could miss required options if Angular removes
161161
// them from their config files as happened with emitDecoratorMetadata.
162162
cleanup();
163-
runNew('', false, false);
163+
runNgNew();
164164
runNgAdd('add @nrwl/workspace --npmScope projscope');
165165
yarnAdd('@nrwl/nest');
166166
} else {

e2e/tsconfig.e2e.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": "../build/e2e-out",
5+
"module": "commonjs",
6+
"types": ["jest", "node"]
7+
},
8+
"include": ["**/*.ts"]
9+
}

e2e/utils.ts

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -108,54 +108,11 @@ export const getDirectories = (source) =>
108108
.filter((dirent) => dirent.isDirectory())
109109
.map((dirent) => dirent.name);
110110

111-
export function runNgcc(silent: boolean = true, async: boolean = true) {
112-
const install = execSync(
113-
'node ./node_modules/@angular/compiler-cli/ngcc/main-ngcc.js' +
114-
(!async ? ' --async=false' : ''),
115-
{
116-
cwd: tmpProjPath(),
117-
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
118-
env: process.env,
119-
}
120-
);
121-
return install ? install.toString() : '';
122-
}
123-
124-
/**
125-
* Run the `new` command for the currently selected CLI
126-
*
127-
* @param args Extra arguments to pass to the `new` command
128-
* @param silent Run in silent mode (no output)
129-
* @param addWorkspace Include `@nrwl/workspace` when patching the `package.json` paths
130-
*/
131-
export function runNew(
132-
args?: string,
133-
silent?: boolean,
134-
addWorkspace = true
135-
): string {
136-
let gen;
137-
if (cli === 'angular') {
138-
gen = execSync(
139-
`../../node_modules/.bin/ng new proj --no-interactive ${args || ''}`,
140-
{
141-
cwd: `./tmp/${cli}`,
142-
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
143-
env: process.env,
144-
}
145-
);
146-
} else {
147-
gen = execSync(
148-
`node ../../node_modules/@nrwl/tao/index.js new proj --no-interactive ${
149-
args || ''
150-
}`,
151-
{
152-
cwd: `./tmp/${cli}`,
153-
...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
154-
env: process.env,
155-
}
156-
);
157-
}
158-
return silent ? null : `${gen ? gen.toString() : ''}`;
111+
export function runNgNew(): string {
112+
return execSync(`../../node_modules/.bin/ng new proj --no-interactive`, {
113+
cwd: `./tmp/${cli}`,
114+
env: process.env,
115+
}).toString();
159116
}
160117

161118
/**
@@ -165,7 +122,7 @@ export function runNew(
165122
export function newProject(): void {
166123
cleanup();
167124
if (!directoryExists(tmpBackupProjPath())) {
168-
runNew('--collection=@nrwl/workspace --npmScope=proj', true);
125+
runCreateWorkspace('proj', { preset: 'empty' });
169126
const packages = [
170127
`@nrwl/angular`,
171128
`@nrwl/express`,
@@ -174,14 +131,14 @@ export function newProject(): void {
174131
`@nrwl/react`,
175132
`@nrwl/storybook`,
176133
`@nrwl/nx-plugin`,
134+
`@nrwl/eslint-plugin-nx`,
177135
];
178-
yarnAdd([`@nrwl/eslint-plugin-nx`].concat(packages).join(` `));
136+
yarnAdd(packages.join(` `));
179137
packages
180-
.filter((f) => f != '@nrwl/nx-plugin')
138+
.filter((f) => f !== '@nrwl/nx-plugin' && f !== `@nrwl/eslint-plugin-nx`)
181139
.forEach((p) => {
182140
runCLI(`g ${p}:init`);
183141
});
184-
185142
execSync(`mv ${tmpProjPath()} ${tmpBackupProjPath()}`);
186143
}
187144
execSync(`cp -a ${tmpBackupProjPath()} ${tmpProjPath()}`);
@@ -414,10 +371,6 @@ export function rmDist() {
414371
execSync(`rm -rf ${tmpProjPath()}/dist`);
415372
}
416373

417-
export function getCwd(): string {
418-
return process.cwd();
419-
}
420-
421374
export function directoryExists(filePath: string): boolean {
422375
try {
423376
return statSync(filePath).isDirectory();

jest.config.js

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

nx.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"npmScope": "nrwl",
3+
"implicitDependencies": {
4+
"workspace.json": "*",
5+
"package.json": {
6+
"dependencies": "*",
7+
"devDependencies": "*"
8+
},
9+
"tsconfig.json": "*",
10+
"tslint.json": "*",
11+
"nx.json": "*"
12+
},
13+
"tasksRunnerOptions": {
14+
"default": {
15+
"runner": "@nrwl/workspace/tasks-runners/default",
16+
"options": {
17+
"cacheableOperations": ["build", "lint", "test", "e2e"]
18+
}
19+
}
20+
},
21+
"workspaceLayout": {
22+
"libsDir": "packages"
23+
},
24+
"projects": {
25+
"tao": {
26+
"tags": []
27+
},
28+
"workspace": {
29+
"tags": []
30+
},
31+
"web": {
32+
"tags": [],
33+
"implicitDependencies": ["cypress"]
34+
},
35+
"cypress": {
36+
"tags": []
37+
},
38+
"jest": {
39+
"tags": []
40+
},
41+
"react": {
42+
"tags": []
43+
},
44+
"storybook": {
45+
"tags": [],
46+
"implicitDependencies": ["cypress"]
47+
},
48+
"nx-plugin": {
49+
"tags": []
50+
},
51+
"node": {
52+
"tags": []
53+
},
54+
"next": {
55+
"tags": [],
56+
"implicitDependencies": ["cypress"]
57+
},
58+
"nest": {
59+
"tags": []
60+
},
61+
"linter": {
62+
"tags": []
63+
},
64+
"express": {
65+
"tags": []
66+
},
67+
"eslint-plugin-nx": {
68+
"tags": []
69+
},
70+
"create-nx-workspace": {
71+
"tags": []
72+
},
73+
"create-nx-plugin": {
74+
"tags": []
75+
},
76+
"cli": {
77+
"tags": []
78+
},
79+
"bazel": {
80+
"tags": []
81+
},
82+
"angular": {
83+
"tags": []
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)