Skip to content

Commit 78aa8f6

Browse files
committed
update nx
1 parent f1efdea commit 78aa8f6

File tree

6 files changed

+28682
-1220
lines changed

6 files changed

+28682
-1220
lines changed

.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"nrwl.angular-console",
4+
"ms-vscode.vscode-typescript-tslint-plugin",
5+
"esbenp.prettier-vscode",
6+
"angular.ng-template"
7+
]
8+
9+
}

angular.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"builder": "@nrwl/angular:package",
1212
"options": {
1313
"tsConfig": "libs/gridjs-angular/tsconfig.lib.json",
14-
"project": "libs/gridjs-angular/ng-package.json"
14+
"project": "libs/gridjs-angular/ng-package.json",
15+
"buildableProjectDepsInPackageJsonType": "dependencies"
1516
},
1617
"configurations": {
1718
"production": {
@@ -39,7 +40,10 @@
3940
"tsConfig": "libs/gridjs-angular/tsconfig.spec.json",
4041
"passWithNoTests": true,
4142
"setupFile": "libs/gridjs-angular/src/test-setup.ts"
42-
}
43+
},
44+
"outputs": [
45+
"coverage/libs/gridjs-angular"
46+
]
4347
},
4448
"storybook": {
4549
"builder": "@nrwl/storybook:storybook",
@@ -69,7 +73,10 @@
6973
"ci": {
7074
"quiet": true
7175
}
72-
}
76+
},
77+
"outputs": [
78+
"{options.outputPath}"
79+
]
7380
}
7481
},
7582
"schematics": {

decorate-angular-cli.js

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,16 @@
2121
* - Delete and reinstall your node_modules
2222
*/
2323

24-
const fs = require("fs");
25-
const os = require("os");
26-
const cp = require("child_process");
27-
const isWindows = os.platform() === "win32";
28-
const { output } = require("@nrwl/workspace");
29-
30-
/**
31-
* Paths to files being patched
32-
*/
33-
const angularCLIInitPath = "node_modules/@angular/cli/lib/cli/index.js";
34-
35-
/**
36-
* Patch index.js to warn you if you invoke the undecorated Angular CLI.
37-
*/
38-
function patchAngularCLI(initPath) {
39-
const angularCLIInit = fs.readFileSync(initPath, "utf-8").toString();
40-
41-
if (!angularCLIInit.includes("NX_CLI_SET")) {
42-
fs.writeFileSync(
43-
initPath,
44-
`
45-
if (!process.env['NX_CLI_SET']) {
46-
const { output } = require('@nrwl/workspace');
47-
output.warn({ title: 'The Angular CLI was invoked instead of the Nx CLI. Use "npx ng [command]" or "nx [command]" instead.' });
48-
}
49-
${angularCLIInit}
50-
`
51-
);
52-
}
24+
const fs = require('fs');
25+
const os = require('os');
26+
const cp = require('child_process');
27+
const isWindows = os.platform() === 'win32';
28+
let output;
29+
try {
30+
output = require('@nrwl/workspace').output;
31+
} catch (e) {
32+
console.warn('Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.');
33+
process.exit(0);
5334
}
5435

5536
/**
@@ -58,39 +39,31 @@ ${angularCLIInit}
5839
*/
5940
function symlinkNgCLItoNxCLI() {
6041
try {
61-
const ngPath = "./node_modules/.bin/ng";
62-
const nxPath = "./node_modules/.bin/nx";
42+
const ngPath = './node_modules/.bin/ng';
43+
const nxPath = './node_modules/.bin/nx';
6344
if (isWindows) {
6445
/**
6546
* This is the most reliable way to create symlink-like behavior on Windows.
6647
* Such that it works in all shells and works with npx.
6748
*/
68-
["", ".cmd", ".ps1"].forEach((ext) => {
69-
if (fs.existsSync(nxPath + ext))
70-
fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext));
49+
['', '.cmd', '.ps1'].forEach(ext => {
50+
if (fs.existsSync(nxPath + ext)) fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext));
7151
});
7252
} else {
7353
// If unix-based, symlink
7454
cp.execSync(`ln -sf ./nx ${ngPath}`);
7555
}
76-
} catch (e) {
77-
output.error({
78-
title:
79-
"Unable to create a symlink from the Angular CLI to the Nx CLI:" +
80-
e.message,
81-
});
56+
}
57+
catch(e) {
58+
output.error({ title: 'Unable to create a symlink from the Angular CLI to the Nx CLI:' + e.message });
8259
throw e;
8360
}
8461
}
8562

8663
try {
8764
symlinkNgCLItoNxCLI();
88-
patchAngularCLI(angularCLIInitPath);
89-
output.log({
90-
title: "Angular CLI has been decorated to enable computation caching.",
91-
});
92-
} catch (e) {
93-
output.error({
94-
title: "Decoration of the Angular CLI did not complete successfully",
95-
});
65+
require('@nrwl/cli/lib/decorate-cli').decorateCli();
66+
output.log({ title: 'Angular CLI has been decorated to enable computation caching.' });
67+
} catch(e) {
68+
output.error({ title: 'Decoration of the Angular CLI did not complete successfully' });
9669
}

0 commit comments

Comments
 (0)