Skip to content

Commit 66e98b9

Browse files
build: migrate to NX (#118)
1 parent 76942fb commit 66e98b9

Some content is hidden

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

73 files changed

+1720
-168
lines changed

.circleci/config.yml

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
key: *cache_key
1818
- run:
1919
name: install-dependencies
20-
command: yarn --frozen-lockfile
20+
command: yarn --frozen-lockfile --non-interactive
2121
- save_cache:
2222
key: *cache_key
2323
paths:
@@ -31,43 +31,33 @@ jobs:
3131
key: *cache_key
3232
- run:
3333
name: lint
34-
command: yarn lint
34+
command: yarn affected:lint
3535

36-
test-lib:
36+
build:
3737
<<: *job_defaults
3838
steps:
3939
- checkout
4040
- restore_cache:
4141
key: *cache_key
4242
- run:
43-
name: test
44-
command: yarn test --maxWorkers=1 --ci
45-
46-
build-lib:
47-
<<: *job_defaults
48-
steps:
49-
- checkout
50-
- restore_cache:
51-
key: *cache_key
52-
- run:
53-
name: test
43+
name: build
5444
command: yarn build
5545
- save_cache:
5646
key: *dist_key
5747
paths:
5848
- dist
49+
- store_artifacts:
50+
path: dist
5951

60-
test-app:
52+
test:
6153
<<: *job_defaults
6254
steps:
6355
- checkout
6456
- restore_cache:
6557
key: *cache_key
66-
- restore_cache:
67-
key: *dist_key
6858
- run:
6959
name: test
70-
command: yarn test:app --maxWorkers=1 --ci
60+
command: yarn affected:test --ci --code-coverage
7161

7262
release:
7363
<<: *job_defaults
@@ -101,26 +91,22 @@ workflows:
10191
- lint:
10292
requires:
10393
- install
104-
- test-lib:
105-
requires:
106-
- install
107-
- build-lib:
94+
- build:
10895
requires:
10996
- lint
110-
- test-lib
111-
- test-app:
97+
- test:
11298
requires:
113-
- build-lib
99+
- build
114100
- release:
115101
requires:
116-
- test-app
102+
- test
117103
filters:
118104
branches:
119105
only:
120106
- master
121107
- release-beta:
122108
requires:
123-
- test-app
109+
- test
124110
filters:
125111
branches:
126112
only:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/dist
55
/tmp
66
/out-tsc
7+
**/coverage
78

89
# dependencies
910
/node_modules

angular.json

Lines changed: 80 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
33
"version": 1,
4-
"newProjectRoot": "projects",
4+
"newProjectRoot": "",
55
"projects": {
6-
"testing-library-app": {
6+
"example-app": {
77
"root": "",
8-
"sourceRoot": "src",
8+
"sourceRoot": "apps/example-app",
99
"projectType": "application",
1010
"prefix": "app",
1111
"schematics": {},
@@ -14,13 +14,13 @@
1414
"builder": "@angular-devkit/build-angular:browser",
1515
"options": {
1616
"aot": true,
17-
"outputPath": "dist/testing-library-app",
18-
"index": "src/index.html",
19-
"main": "src/main.ts",
20-
"polyfills": "src/polyfills.ts",
21-
"tsConfig": "src/tsconfig.app.json",
22-
"assets": ["src/favicon.ico", "src/assets"],
23-
"styles": ["src/styles.css"],
17+
"outputPath": "dist/apps/example-app",
18+
"index": "apps/example-app/index.html",
19+
"main": "apps/example-app/main.ts",
20+
"polyfills": "apps/example-app/polyfills.ts",
21+
"tsConfig": "apps/example-app/tsconfig.json",
22+
"assets": ["apps/example-app/favicon.ico", "apps/example-app/assets"],
23+
"styles": ["apps/example-app/styles.css"],
2424
"scripts": []
2525
},
2626
"configurations": {
@@ -33,8 +33,8 @@
3333
],
3434
"fileReplacements": [
3535
{
36-
"replace": "src/environments/environment.ts",
37-
"with": "src/environments/environment.prod.ts"
36+
"replace": "apps/example-app/environments/environment.ts",
37+
"with": "apps/example-app/environments/environment.prod.ts"
3838
}
3939
],
4040
"optimization": true,
@@ -52,26 +52,34 @@
5252
"serve": {
5353
"builder": "@angular-devkit/build-angular:dev-server",
5454
"options": {
55-
"browserTarget": "testing-library-app:build"
55+
"browserTarget": "example-app:build"
5656
},
5757
"configurations": {
5858
"production": {
59-
"browserTarget": "testing-library-app:build:production"
59+
"browserTarget": "example-app:build:production"
6060
}
6161
}
6262
},
6363
"extract-i18n": {
6464
"builder": "@angular-devkit/build-angular:extract-i18n",
6565
"options": {
66-
"browserTarget": "testing-library-app:build"
66+
"browserTarget": "example-app:build"
6767
}
6868
},
6969
"lint": {
7070
"builder": "@angular-devkit/build-angular:tslint",
7171
"options": {
72-
"tsConfig": ["src/tsconfig.app.json", "./tsconfig.spec.json"],
72+
"tsConfig": ["apps/example-app/tsconfig.json", "apps/example-app/tsconfig.spec.json"],
7373
"exclude": ["**/node_modules/**"]
7474
}
75+
},
76+
"test": {
77+
"builder": "@nrwl/jest:jest",
78+
"options": {
79+
"jestConfig": "apps/example-app/jest.config.js",
80+
"tsConfig": "apps/example-app/tsconfig.spec.json",
81+
"setupFile": "apps/example-app/setup-jest.ts"
82+
}
7583
}
7684
}
7785
},
@@ -81,25 +89,53 @@
8189
"projectType": "library",
8290
"prefix": "lib",
8391
"architect": {
84-
"build": {
92+
"build-package": {
8593
"builder": "@angular-devkit/build-ng-packagr:build",
8694
"options": {
8795
"tsConfig": "projects/testing-library/tsconfig.lib.json",
8896
"project": "projects/testing-library/ng-package.json"
8997
},
9098
"configurations": {
9199
"production": {
92-
"project": "projects/testing-library/ng-package.prod.json",
93-
"tsConfig": "projects/testing-library/tsconfig.lib.prod.json"
100+
"project": "projects/testing-library/ng-package.json",
101+
"tsConfig": "projects/testing-library/tsconfig.lib.json"
94102
}
95103
}
96104
},
97105
"lint": {
98106
"builder": "@angular-devkit/build-angular:tslint",
99107
"options": {
100-
"tsConfig": ["projects/testing-library/tsconfig.lib.json", "./tsconfig.spec.json"],
108+
"tsConfig": ["projects/testing-library/tsconfig.lib.json", "projects/testing-library/tsconfig.spec.json"],
101109
"exclude": ["**/node_modules/**"]
102110
}
111+
},
112+
"build": {
113+
"builder": "@nrwl/workspace:run-commands",
114+
"options": {
115+
"parallel": false,
116+
"commands": [
117+
{
118+
"command": "ng run testing-library:build-package"
119+
},
120+
{
121+
"command": "tsc -p ./projects/testing-library/migrations/tsconfig.migrations.json"
122+
},
123+
{
124+
"command": "cpy ./projects/testing-library/migrations/migration.json ./dist/@testing-library/angular/migrations"
125+
},
126+
{
127+
"command": "cpy ./README.md ./dist/@testing-library/angular"
128+
}
129+
]
130+
}
131+
},
132+
"test": {
133+
"builder": "@nrwl/jest:jest",
134+
"options": {
135+
"jestConfig": "projects/testing-library/jest.config.js",
136+
"tsConfig": "projects/testing-library/tsconfig.spec.json",
137+
"setupFile": "projects/testing-library/setup-jest.ts"
138+
}
103139
}
104140
}
105141
},
@@ -109,30 +145,49 @@
109145
"projectType": "library",
110146
"prefix": "lib",
111147
"architect": {
112-
"build": {
148+
"build-package": {
113149
"builder": "@angular-devkit/build-ng-packagr:build",
114150
"options": {
115151
"tsConfig": "projects/jest-utils/tsconfig.lib.json",
116152
"project": "projects/jest-utils/ng-package.json"
117153
},
118154
"configurations": {
119155
"production": {
120-
"project": "projects/jest-utils/ng-package.prod.json",
121-
"tsConfig": "projects/jest-utils/tsconfig.lib.prod.json"
156+
"project": "projects/jest-utils/ng-package.json",
157+
"tsConfig": "projects/jest-utils/tsconfig.lib.json"
122158
}
123159
}
124160
},
125161
"lint": {
126162
"builder": "@angular-devkit/build-angular:tslint",
127163
"options": {
128-
"tsConfig": ["projects/jest-utils/tsconfig.lib.json", "./tsconfig.spec.json"],
164+
"tsConfig": ["projects/jest-utils/tsconfig.lib.json", "projects/jest-utils/tsconfig.spec.json"],
129165
"exclude": ["**/node_modules/**"]
130166
}
167+
},
168+
"build": {
169+
"builder": "@nrwl/workspace:run-commands",
170+
"options": {
171+
"parallel": false,
172+
"commands": [
173+
{
174+
"command": "ng run jest-utils:build-package"
175+
}
176+
]
177+
}
178+
},
179+
"test": {
180+
"builder": "@nrwl/jest:jest",
181+
"options": {
182+
"jestConfig": "projects/jest-utils/jest.config.js",
183+
"tsConfig": "projects/jest-utils/tsconfig.spec.json",
184+
"setupFile": "projects/jest-utils/setup-jest.ts"
185+
}
131186
}
132187
}
133188
}
134189
},
135-
"defaultProject": "testing-library-app",
190+
"defaultProject": "example-app",
136191
"cli": {
137192
"analytics": false
138193
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

apps/example-app/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
name: 'Example App',
3+
displayName: {
4+
name: 'Example',
5+
color: 'blue',
6+
},
7+
preset: '../../jest.config.js',
8+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/tsconfig.app.json renamed to apps/example-app/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.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
55
"types": [],

tsconfig.spec.json renamed to apps/example-app/tsconfig.spec.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.json",
33
"compilerOptions": {
44
"module": "commonjs",
55
"types": ["jest", "node"]

src/tslint.json renamed to apps/example-app/tslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tslint.json",
2+
"extends": "../../tslint.json",
33
"rules": {
44
"directive-selector": [true, "attribute", "app", "camelCase"],
55
"component-selector": [true, "element", "app", "kebab-case"]

jest.base.config.js renamed to jest.config.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
module.exports = {
2-
preset: 'jest-preset-angular',
3-
rootDir: '../',
4-
transformIgnorePatterns: ['node_modules/(?!@ngrx)'],
5-
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'],
69
snapshotSerializers: [
710
'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
811
'jest-preset-angular/build/AngularSnapshotSerializer.js',

nx.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"npmScope": "testing-library",
3+
"implicitDependencies": {
4+
"angular.json": "*",
5+
"package.json": "*",
6+
"tsconfig.json": "*",
7+
"tslint.json": "*",
8+
"nx.json": "*"
9+
},
10+
"tasksRunnerOptions": {
11+
"default": {
12+
"runner": "@nrwl/workspace/tasks-runners/default",
13+
"options": {
14+
"strictlyOrderedTargets": ["build-release"],
15+
"cacheableOperations": ["build", "build-release", "test", "lint"]
16+
}
17+
}
18+
},
19+
"projects": {
20+
"example-app": {
21+
"tags": []
22+
},
23+
"testing-library": {
24+
"tags": []
25+
},
26+
"jest-utils": {
27+
"tags": []
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)