Skip to content

Commit 8c39911

Browse files
committed
chore: added base NX
1 parent 93e2928 commit 8c39911

File tree

13 files changed

+806
-60
lines changed

13 files changed

+806
-60
lines changed

.nxignore

Whitespace-only changes.

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.idea/**/*
2+
/dist/**/*
3+
/node_modules/**/*
4+
/coverage/**/*
5+
/tmp/**/*‚‚

.stylelintignore

Whitespace-only changes.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
[![dependency status][david-img]][david-url]
33

44
# Angular Starter [![The MIT License][license-img]][license-url]
5-
Angular starter project
65

6+
# Generate Containers
7+
8+
```bash
9+
nx g component containers/license --project=management-feature-control-center
10+
```
711

812

913
[david-url]: https://david-dm.org/positive-js/angular-starter

apps/mc-mocks-server/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"module": "commonjs",
55
"types": [

apps/mc-web/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {}
44
}

decorate-angular-cli.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* This file decorates the Angular CLI with the Nx CLI to enable features such as computation caching
3+
* and faster execution of tasks.
4+
*
5+
* It does this by:
6+
*
7+
* - Patching the Angular CLI to warn you in case you accidentally use the undecorated ng command.
8+
* - Symlinking the ng to nx command, so all commands run through the Nx CLI
9+
* - Updating the package.json postinstall script to give you control over this script
10+
*
11+
* The Nx CLI decorates the Angular CLI, so the Nx CLI is fully compatible with it.
12+
* Every command you run should work the same when using the Nx CLI, except faster.
13+
*
14+
* Because of symlinking you can still type `ng build/test/lint` in the terminal. The ng command, in this case,
15+
* will point to nx, which will perform optimizations before invoking ng. So the Angular CLI is always invoked.
16+
* The Nx CLI simply does some optimizations before invoking the Angular CLI.
17+
*
18+
* To opt out of this patch:
19+
* - Replace occurrences of nx with ng in your package.json
20+
* - Remove the script from your postinstall script in your package.json
21+
* - Delete and reinstall your node_modules
22+
*/
23+
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);
34+
}
35+
36+
/**
37+
* Symlink of ng to nx, so you can keep using `ng build/test/lint` and still
38+
* invoke the Nx CLI and get the benefits of computation caching.
39+
*/
40+
function symlinkNgCLItoNxCLI() {
41+
try {
42+
const ngPath = './node_modules/.bin/ng';
43+
const nxPath = './node_modules/.bin/nx';
44+
if (isWindows) {
45+
/**
46+
* This is the most reliable way to create symlink-like behavior on Windows.
47+
* Such that it works in all shells and works with npx.
48+
*/
49+
['', '.cmd', '.ps1'].forEach(ext => {
50+
if (fs.existsSync(nxPath + ext)) fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext));
51+
});
52+
} else {
53+
// If unix-based, symlink
54+
cp.execSync(`ln -sf ./nx ${ngPath}`);
55+
}
56+
}
57+
catch(e) {
58+
output.error({ title: 'Unable to create a symlink from the Angular CLI to the Nx CLI:' + e.message });
59+
throw e;
60+
}
61+
}
62+
63+
try {
64+
symlinkNgCLItoNxCLI();
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' });
69+
}

nx.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"npmScope": "pt-starter",
3+
"affected": {
4+
"defaultBase": "master"
5+
},
6+
"implicitDependencies": {
7+
"angular.json": "*",
8+
"package.json": "*",
9+
"tslint.json": "*",
10+
"nx.json": "*",
11+
"tsconfig.base.json": "*",
12+
".eslintrc.json": "*"
13+
},
14+
"projects": {
15+
"mc-web": {
16+
"tags": ["domain:app", "type:app"]
17+
}
18+
}
19+
}

package.json

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
{
2-
"name": "positive-starter",
2+
"name": "pt-starter",
33
"version": "1.0.0",
44
"scripts": {
5-
"ng": "ng",
6-
"start": "ng serve",
5+
"ng": "nx",
6+
"nx": "nx",
7+
"start": "nx serve -- --ssl true --proxy-config proxy.conf.json",
78
"start:mock": "ng serve --proxy-config conf/proxy.conf.mock.json",
8-
"build": "ng build",
9-
"build:prod": "ng build mc-web --prod",
9+
"start-es5": "nx serve --configuration es5",
10+
"build": "nx build",
11+
"build:prod": "nx build --prod",
1012
"test": "ng test",
1113
"lint": "ng lint",
1214
"lint:styles": "stylelint \"**/*.scss\"",
13-
"e2e": "ng e2e",
15+
"format": "nx format:write",
16+
"format:write": "nx format:write",
17+
"format:check": "nx format:check",
18+
"update": "nx migrate latest",
19+
"update:check": "ng update",
20+
"dep-graph": "nx dep-graph",
21+
"help": "nx help",
1422
"preinstall": "node ./tools/npm/check-npm.js",
15-
"dep-graph": "rimraf dist/mxdeps.json && ./node_modules/.bin/mx dep-graph",
23+
"postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main",
1624
"mock:server": "ts-node --project apps/mc-mocks-server/tsconfig.json -r tsconfig-paths/register apps/mc-mocks-server/src/main.ts",
1725
"mock:server:debug": "nodemon --config apps/mc-mocks-server/nodemon-debug.json",
18-
"build:tokens-default": "node ./tools/design-tokens/build.js"
26+
"build:tokens-default": "node ./tools/design-tokens/build.js",
27+
"workspace-generator": "nx workspace-generator"
1928
},
2029
"private": true,
2130
"husky": {
@@ -44,11 +53,11 @@
4453
"@ptsecurity/cdk": "^11.3.4",
4554
"@ptsecurity/mosaic": "^11.3.4",
4655
"@ptsecurity/mosaic-icons": "^5.3.0",
47-
"@ptsecurity/mosaic-moment-adapter": "^11.3.4",
4856
"@ptsecurity/mosaic-luxon-adapter": "^11.3.4",
57+
"@ptsecurity/mosaic-moment-adapter": "^11.3.4",
4958
"faker": "^5.5.3",
50-
"messageformat": "^2.2.1",
5159
"luxon": "^1.27.0",
60+
"messageformat": "^2.2.1",
5261
"moment": "^2.24.0",
5362
"rxjs": "^6.6.7",
5463
"sqlite": "^4.0.23",
@@ -66,6 +75,7 @@
6675
"@nestjs/schematics": "^8.0.2",
6776
"@nestjs/testing": "^8.0.6",
6877
"@ngrx/store-devtools": "^11.1.1",
78+
"@nrwl/workspace": "^11.6.3",
6979
"@ptsecurity/commitlint-config": "^1.0.0",
7080
"@ptsecurity/tslint-config": "~0.12.0",
7181
"@types/express": "^4.16.0",
@@ -82,17 +92,17 @@
8292
"karma-coverage-istanbul-reporter": "^3.0.3",
8393
"karma-jasmine": "^4.0.1",
8494
"karma-jasmine-html-reporter": "^1.7.0",
85-
"sass": "^1.32.6",
86-
"style-dictionary": "^3.0.1",
8795
"nodemon": "^2.0.12",
96+
"reflect-metadata": "^0.1.12",
8897
"rimraf": "^3.0.2",
98+
"sass": "^1.32.6",
99+
"style-dictionary": "^3.0.1",
89100
"stylelint": "^13.13.1",
90101
"stylelint-scss": "^3.20.1",
91102
"ts-node": "~10.2.1",
92103
"tsconfig-paths": "^3.10.1",
93104
"tslint": "~5.15.0",
94105
"typescript": "~4.1.6",
95-
"reflect-metadata": "^0.1.12",
96106
"wait-on": "^6.0.0",
97107
"wallaby-webpack": "^3.9.16"
98108
}

prettier.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
endOfLine: 'lf',
3+
printWidth: 120,
4+
singleQuote: true,
5+
tabWidth: 4,
6+
useTabs: false,
7+
overrides: [
8+
{
9+
// Add angular specific parser for all our angular templates
10+
files: [
11+
'libs/**/*.html',
12+
'apps/{pt-nad,pt-nad-e2e}/**/*.html',
13+
],
14+
options: { parser: 'angular' },
15+
}
16+
]
17+
};

0 commit comments

Comments
 (0)