Skip to content

build: migrate to NX #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 13 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
key: *cache_key
- run:
name: install-dependencies
command: yarn --frozen-lockfile
command: yarn --frozen-lockfile --non-interactive
- save_cache:
key: *cache_key
paths:
Expand All @@ -31,43 +31,33 @@ jobs:
key: *cache_key
- run:
name: lint
command: yarn lint
command: yarn affected:lint

test-lib:
build:
<<: *job_defaults
steps:
- checkout
- restore_cache:
key: *cache_key
- run:
name: test
command: yarn test --maxWorkers=1 --ci

build-lib:
<<: *job_defaults
steps:
- checkout
- restore_cache:
key: *cache_key
- run:
name: test
name: build
command: yarn build
- save_cache:
key: *dist_key
paths:
- dist
- store_artifacts:
path: dist

test-app:
test:
<<: *job_defaults
steps:
- checkout
- restore_cache:
key: *cache_key
- restore_cache:
key: *dist_key
- run:
name: test
command: yarn test:app --maxWorkers=1 --ci
command: yarn affected:test --ci --code-coverage

release:
<<: *job_defaults
Expand Down Expand Up @@ -101,26 +91,22 @@ workflows:
- lint:
requires:
- install
- test-lib:
requires:
- install
- build-lib:
- build:
requires:
- lint
- test-lib
- test-app:
- test:
requires:
- build-lib
- build
- release:
requires:
- test-app
- test
filters:
branches:
only:
- master
- release-beta:
requires:
- test-app
- test
filters:
branches:
only:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/dist
/tmp
/out-tsc
**/coverage

# dependencies
/node_modules
Expand Down
105 changes: 80 additions & 25 deletions angular.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"newProjectRoot": "",
"projects": {
"testing-library-app": {
"example-app": {
"root": "",
"sourceRoot": "src",
"sourceRoot": "apps/example-app",
"projectType": "application",
"prefix": "app",
"schematics": {},
Expand All @@ -14,13 +14,13 @@
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "dist/testing-library-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
"outputPath": "dist/apps/example-app",
"index": "apps/example-app/index.html",
"main": "apps/example-app/main.ts",
"polyfills": "apps/example-app/polyfills.ts",
"tsConfig": "apps/example-app/tsconfig.json",
"assets": ["apps/example-app/favicon.ico", "apps/example-app/assets"],
"styles": ["apps/example-app/styles.css"],
"scripts": []
},
"configurations": {
Expand All @@ -33,8 +33,8 @@
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
"replace": "apps/example-app/environments/environment.ts",
"with": "apps/example-app/environments/environment.prod.ts"
}
],
"optimization": true,
Expand All @@ -52,26 +52,34 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "testing-library-app:build"
"browserTarget": "example-app:build"
},
"configurations": {
"production": {
"browserTarget": "testing-library-app:build:production"
"browserTarget": "example-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "testing-library-app:build"
"browserTarget": "example-app:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "./tsconfig.spec.json"],
"tsConfig": ["apps/example-app/tsconfig.json", "apps/example-app/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "apps/example-app/jest.config.js",
"tsConfig": "apps/example-app/tsconfig.spec.json",
"setupFile": "apps/example-app/setup-jest.ts"
}
}
}
},
Expand All @@ -81,25 +89,53 @@
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {
"build-package": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/testing-library/tsconfig.lib.json",
"project": "projects/testing-library/ng-package.json"
},
"configurations": {
"production": {
"project": "projects/testing-library/ng-package.prod.json",
"tsConfig": "projects/testing-library/tsconfig.lib.prod.json"
"project": "projects/testing-library/ng-package.json",
"tsConfig": "projects/testing-library/tsconfig.lib.json"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["projects/testing-library/tsconfig.lib.json", "./tsconfig.spec.json"],
"tsConfig": ["projects/testing-library/tsconfig.lib.json", "projects/testing-library/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"build": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"parallel": false,
"commands": [
{
"command": "ng run testing-library:build-package"
},
{
"command": "tsc -p ./projects/testing-library/migrations/tsconfig.migrations.json"
},
{
"command": "cpy ./projects/testing-library/migrations/migration.json ./dist/@testing-library/angular/migrations"
},
{
"command": "cpy ./README.md ./dist/@testing-library/angular"
}
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "projects/testing-library/jest.config.js",
"tsConfig": "projects/testing-library/tsconfig.spec.json",
"setupFile": "projects/testing-library/setup-jest.ts"
}
}
}
},
Expand All @@ -109,30 +145,49 @@
"projectType": "library",
"prefix": "lib",
"architect": {
"build": {
"build-package": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/jest-utils/tsconfig.lib.json",
"project": "projects/jest-utils/ng-package.json"
},
"configurations": {
"production": {
"project": "projects/jest-utils/ng-package.prod.json",
"tsConfig": "projects/jest-utils/tsconfig.lib.prod.json"
"project": "projects/jest-utils/ng-package.json",
"tsConfig": "projects/jest-utils/tsconfig.lib.json"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["projects/jest-utils/tsconfig.lib.json", "./tsconfig.spec.json"],
"tsConfig": ["projects/jest-utils/tsconfig.lib.json", "projects/jest-utils/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"build": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"parallel": false,
"commands": [
{
"command": "ng run jest-utils:build-package"
}
]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "projects/jest-utils/jest.config.js",
"tsConfig": "projects/jest-utils/tsconfig.spec.json",
"setupFile": "projects/jest-utils/setup-jest.ts"
}
}
}
}
},
"defaultProject": "testing-library-app",
"defaultProject": "example-app",
"cli": {
"analytics": false
}
Expand Down
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.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions apps/example-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
name: 'Example App',
displayName: {
name: 'Example',
color: 'blue',
},
preset: '../../jest.config.js',
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tsconfig.app.json → apps/example-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": [],
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.spec.json → apps/example-app/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"types": ["jest", "node"]
Expand Down
2 changes: 1 addition & 1 deletion src/tslint.json → apps/example-app/tslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tslint.json",
"extends": "../../tslint.json",
"rules": {
"directive-selector": [true, "attribute", "app", "camelCase"],
"component-selector": [true, "element", "app", "kebab-case"]
Expand Down
11 changes: 7 additions & 4 deletions jest.base.config.js → jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module.exports = {
preset: 'jest-preset-angular',
rootDir: '../',
transformIgnorePatterns: ['node_modules/(?!@ngrx)'],

testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest',
},
resolver: '@nrwl/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageReporters: ['html'],
snapshotSerializers: [
'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
'jest-preset-angular/build/AngularSnapshotSerializer.js',
Expand Down
30 changes: 30 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"npmScope": "testing-library",
"implicitDependencies": {
"angular.json": "*",
"package.json": "*",
"tsconfig.json": "*",
"tslint.json": "*",
"nx.json": "*"
},
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/workspace/tasks-runners/default",
"options": {
"strictlyOrderedTargets": ["build-release"],
"cacheableOperations": ["build", "build-release", "test", "lint"]
}
}
},
"projects": {
"example-app": {
"tags": []
},
"testing-library": {
"tags": []
},
"jest-utils": {
"tags": []
}
}
}
Loading