From 1958dd5355a68b3508dcde144c816a4ff2445836 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 12:05:39 +0100 Subject: [PATCH 01/18] build(deps): update nx 13.2.2 and Angular 13 --- .gitignore | 1 + .prettierignore | 2 + angular.json | 16 +- apps/example-app-karma/src/polyfills.ts | 10 -- apps/example-app-karma/src/test.ts | 4 +- apps/example-app-karma/tsconfig.json | 2 +- apps/example-app/src/polyfills.ts | 10 -- apps/example-app/tsconfig.json | 2 +- apps/example-app/tsconfig.spec.json | 2 +- jest.preset.js | 8 +- migrations.json | 161 ++++++++++++++++++ nx.json | 21 +-- package.json | 76 +++++---- projects/jest-utils/tests/create-mock.spec.ts | 10 +- projects/jest-utils/tsconfig.lib.json | 6 +- projects/jest-utils/tsconfig.spec.json | 4 +- projects/testing-library/tsconfig.lib.json | 6 +- .../testing-library/tsconfig.schematics.json | 2 +- projects/testing-library/tsconfig.spec.json | 4 +- .../vscode-atl-render/.vscode/launch.json | 22 ++- tsconfig.json => tsconfig.base.json | 0 21 files changed, 258 insertions(+), 111 deletions(-) create mode 100644 migrations.json rename tsconfig.json => tsconfig.base.json (100%) diff --git a/.gitignore b/.gitignore index 82985ca5..5f617103 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ !.vscode/extensions.json # misc +/.angular/cache /.sass-cache /connect.lock /coverage diff --git a/.prettierignore b/.prettierignore index 2cbf2c26..9aa8a3df 100644 --- a/.prettierignore +++ b/.prettierignore @@ -35,6 +35,8 @@ CHANGELOG.md !.vscode/extensions.json # misc +.cache +.angular /.sass-cache /connect.lock /coverage diff --git a/angular.json b/angular.json index 50afdec9..01533167 100644 --- a/angular.json +++ b/angular.json @@ -1,9 +1,5 @@ { "version": 1, - "cli": { - "analytics": false - }, - "defaultProject": "example-app", "projects": { "example-app": { "projectType": "application", @@ -92,7 +88,8 @@ }, "outputs": ["coverage/"] } - } + }, + "tags": [] }, "example-app-karma": { "projectType": "application", @@ -180,7 +177,8 @@ "assets": [] } } - } + }, + "tags": [] }, "jest-utils": { "root": "projects/jest-utils", @@ -232,7 +230,8 @@ }, "outputs": ["coverage/projects/jest-utils"] } - } + }, + "tags": [] }, "testing-library": { "root": "projects/testing-library", @@ -290,7 +289,8 @@ }, "outputs": ["coverage/projects/testing-library"] } - } + }, + "tags": [] } } } diff --git a/apps/example-app-karma/src/polyfills.ts b/apps/example-app-karma/src/polyfills.ts index bb20fec0..f84fd8a6 100644 --- a/apps/example-app-karma/src/polyfills.ts +++ b/apps/example-app-karma/src/polyfills.ts @@ -34,22 +34,12 @@ // import 'core-js/es6/weak-map'; // import 'core-js/es6/set'; -/** IE10 and IE11 requires the following for NgClass support on SVG elements */ -// import 'classlist.js'; // Run `npm install --save classlist.js`. - /** IE10 and IE11 requires the following for the Reflect API. */ // import 'core-js/es6/reflect'; /** Evergreen browsers require these. **/ // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. -/** - * Web Animations `@angular/platform-browser/animations` - * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. - * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). - **/ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. - /** * By default, zone.js will patch all possible macroTask and DomEvents * user can disable parts of macroTask/DomEvents patch by setting following flags diff --git a/apps/example-app-karma/src/test.ts b/apps/example-app-karma/src/test.ts index 867baf94..30d9f9e5 100644 --- a/apps/example-app-karma/src/test.ts +++ b/apps/example-app-karma/src/test.ts @@ -11,7 +11,9 @@ beforeAll(() => { declare const require: any; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { + teardown: { destroyAfterEach: false }, +}); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. diff --git a/apps/example-app-karma/tsconfig.json b/apps/example-app-karma/tsconfig.json index e1d5ba47..0cfe7c56 100644 --- a/apps/example-app-karma/tsconfig.json +++ b/apps/example-app-karma/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "files": [], "include": [], "compilerOptions": {}, diff --git a/apps/example-app/src/polyfills.ts b/apps/example-app/src/polyfills.ts index bb20fec0..f84fd8a6 100644 --- a/apps/example-app/src/polyfills.ts +++ b/apps/example-app/src/polyfills.ts @@ -34,22 +34,12 @@ // import 'core-js/es6/weak-map'; // import 'core-js/es6/set'; -/** IE10 and IE11 requires the following for NgClass support on SVG elements */ -// import 'classlist.js'; // Run `npm install --save classlist.js`. - /** IE10 and IE11 requires the following for the Reflect API. */ // import 'core-js/es6/reflect'; /** Evergreen browsers require these. **/ // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. -/** - * Web Animations `@angular/platform-browser/animations` - * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. - * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). - **/ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. - /** * By default, zone.js will patch all possible macroTask and DomEvents * user can disable parts of macroTask/DomEvents patch by setting following flags diff --git a/apps/example-app/tsconfig.json b/apps/example-app/tsconfig.json index de50e310..523f7fc7 100644 --- a/apps/example-app/tsconfig.json +++ b/apps/example-app/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "files": [], "include": [], "compilerOptions": {}, diff --git a/apps/example-app/tsconfig.spec.json b/apps/example-app/tsconfig.spec.json index afe056ed..d8a4c20f 100644 --- a/apps/example-app/tsconfig.spec.json +++ b/apps/example-app/tsconfig.spec.json @@ -6,5 +6,5 @@ "types": ["jest", "node", "@testing-library/jest-dom"] }, "files": ["src/test-setup.ts"], - "include": ["**/*.spec.ts", "**/*.d.ts"] + "include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"] } diff --git a/jest.preset.js b/jest.preset.js index 3f434cfc..c9b13e14 100644 --- a/jest.preset.js +++ b/jest.preset.js @@ -3,8 +3,9 @@ module.exports = { ...nxPreset, testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'], transform: { - '^.+\\.(ts|js|html)$': 'ts-jest', + '^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular', }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], resolver: '@nrwl/jest/plugins/resolver', moduleFileExtensions: ['ts', 'js', 'html'], globals: { @@ -13,4 +14,9 @@ module.exports = { stringifyContentPathRegex: '\\.(html|svg)$', }, }, + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], }; diff --git a/migrations.json b/migrations.json new file mode 100644 index 00000000..d79441e5 --- /dev/null +++ b/migrations.json @@ -0,0 +1,161 @@ +{ + "migrations": [ + { + "version": "13.0.0-beta.1", + "description": "Add default base to nx.json if its not currently set", + "factory": "./src/migrations/update-13-0-0/set-default-base-if-not-set", + "cli": "nx", + "package": "@nrwl/workspace", + "name": "set-default-base-if-not-set" + }, + { + "version": "13.0.0-beta.4", + "description": "Move global settings into nx.json, and project specific settings into workspace.json", + "cli": "nx", + "implementation": "./src/migrations/update-13-0-0/config-locations/config-locations", + "package": "@nrwl/workspace", + "name": "13-0-0-config-locations" + }, + { + "version": "13.2.0", + "description": "Set --parallel=1 for existing repos to preserve the existing behavior", + "cli": "nx", + "implementation": "./src/migrations/update-13-2-0/set-parallel-default", + "package": "@nrwl/workspace", + "name": "set-parallel-default" + }, + { + "cli": "nx", + "version": "13.0.0-beta.10", + "description": "Adds postcss packages needed for Tailwind support if ng-packagr is already installed.", + "factory": "./src/migrations/update-13-0-0/add-postcss-packages", + "package": "@nrwl/angular", + "name": "add-postcss-packages" + }, + { + "cli": "nx", + "version": "13.2.0-beta.1", + "description": "Remove deprecated options from webpack-server and webpack-browser.", + "factory": "./src/migrations/update-13-2-0/update-angular-config", + "package": "@nrwl/angular", + "name": "update-angular-config" + }, + { + "cli": "nx", + "version": "13.2.0-beta.1", + "description": "Remove enableIvy and add compilationMode to library tsconfig and remove deprecated ng-packagr options.", + "factory": "./src/migrations/update-13-2-0/update-libraries", + "package": "@nrwl/angular", + "name": "update-libraries" + }, + { + "cli": "nx", + "version": "13.2.0-beta.1", + "description": "Update jest config to support jest-preset-angular", + "factory": "./src/migrations/update-13-2-0/update-angular-jest-config", + "package": "@nrwl/angular", + "name": "update-angular-jest-config" + }, + { + "cli": "nx", + "version": "13.2.0-beta.1", + "description": "Move some imports from @nrwl/angular/testing to jasmine-marbles", + "factory": "./src/migrations/update-13-2-0/update-testing-imports", + "package": "@nrwl/angular", + "name": "update-testing-imports" + }, + { + "description": "The road to v13 beta", + "version": "13-beta", + "factory": "./13_0_0-beta/index", + "package": "@ngrx/store", + "name": "ngrx-store-migration-13-beta" + }, + { + "description": "The road to v13 RC", + "version": "13-rc.1", + "factory": "./13_0_0-rc/index", + "package": "@ngrx/store", + "name": "ngrx-store-migration-13-rc" + }, + { + "version": "13.0.0", + "factory": "./update-13/schematic-options", + "description": "Remove no longer valid Angular schematic options from `angular.json`.", + "package": "@angular/cli", + "name": "schematic-options-13" + }, + { + "version": "13.0.0", + "factory": "./update-13/update-angular-config", + "description": "Remove deprecated options from 'angular.json' that are no longer present in v13.", + "package": "@angular/cli", + "name": "update-angular-config-v13" + }, + { + "version": "13.0.0", + "factory": "./update-13/update-libraries", + "description": "Update library projects to be published in partial mode and removed deprecated options from ng-packagr configuration.", + "package": "@angular/cli", + "name": "update-libraries-v13" + }, + { + "version": "13.0.0", + "factory": "./update-13/drop-ie-polyfills", + "description": "Remove polyfills required only for Internet Explorer which is no longer supported.", + "package": "@angular/cli", + "name": "drop-ie-polyfills" + }, + { + "version": "13.0.0", + "factory": "./update-13/update-gitignore", + "description": "Updating '.gitignore' to include '.angular/cache'.", + "package": "@angular/cli", + "name": "update-gitignore" + }, + { + "version": "13.0.0-beta", + "description": "Migrates `[routerLink]=\"\"` in templates to `[routerLink]=\"[]\"` because these links are likely intended to route to the current page with updated fragment/query params.", + "factory": "./migrations/router-link-empty-expression/index", + "package": "@angular/core", + "name": "migration-v13-router-link-empty-expression" + }, + { + "version": "13.0.0-beta", + "description": "In Angular version 13, the `teardown` flag in `TestBed` will be enabled by default. This migration automatically opts out existing apps from the new teardown behavior.", + "factory": "./migrations/testbed-teardown/index", + "package": "@angular/core", + "name": "migration-v13-testbed-teardown" + }, + { + "version": "13.0.0-0", + "description": "Updates Angular Material to v13", + "factory": "./ng-update/index#updateToV13", + "package": "@angular/material", + "name": "migration-v13" + }, + { + "version": "13.0.0-0", + "description": "Updates the Angular CDK to v13", + "factory": "./ng-update/index#updateToV13", + "package": "@angular/cdk", + "name": "migration-v13" + }, + { + "version": "13.1.2-beta.0", + "cli": "nx", + "description": "Support .test. file names in tsconfigs", + "factory": "./src/migrations/update-13-1-2/update-tsconfigs-for-tests", + "package": "@nrwl/jest", + "name": "update-ts-config-for-test-filenames" + }, + { + "cli": "nx", + "version": "13.0.0-beta.1", + "description": "Remove packages installed by Nx 12's `@nrwl/node:webpack5` generator.", + "factory": "./src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0", + "package": "@nrwl/node", + "name": "remove-webpack-5-packages" + } + ] +} diff --git a/nx.json b/nx.json index c9020cab..82421f14 100644 --- a/nx.json +++ b/nx.json @@ -20,22 +20,13 @@ "accessToken": "M2Q4YjlkNjMtMzY1NC00ZjkwLTk1ZjgtZjg5Y2VkMzFjM2FifHJlYWQtd3JpdGU=", "cacheableOperations": ["build", "test", "lint", "e2e"], "canTrackAnalytics": false, - "showUsageWarnings": true + "showUsageWarnings": true, + "parallel": 1 } } }, - "projects": { - "example-app": { - "tags": [] - }, - "example-app-karma": { - "tags": [] - }, - "jest-utils": { - "tags": [] - }, - "testing-library": { - "tags": [] - } - } + "cli": { + "analytics": false + }, + "defaultProject": "example-app" } diff --git a/package.json b/package.json index bf69d070..62edacca 100644 --- a/package.json +++ b/package.json @@ -28,19 +28,19 @@ "prepare": "husky install" }, "dependencies": { - "@angular/animations": "12.2.0", - "@angular/cdk": "12.2.0", - "@angular/common": "12.2.0", - "@angular/compiler": "12.2.0", - "@angular/core": "12.2.0", - "@angular/forms": "12.2.0", - "@angular/material": "12.2.0", - "@angular/platform-browser": "12.2.0", - "@angular/platform-browser-dynamic": "12.2.0", - "@angular/router": "12.2.0", - "@ngrx/store": "12.4.0", - "@nrwl/angular": "12.9.0", - "@nrwl/nx-cloud": "12.3.12", + "@angular/animations": "13.0.2", + "@angular/cdk": "13.0.2", + "@angular/common": "13.0.2", + "@angular/compiler": "13.0.2", + "@angular/core": "13.0.2", + "@angular/forms": "13.0.2", + "@angular/material": "13.0.2", + "@angular/platform-browser": "13.0.2", + "@angular/platform-browser-dynamic": "13.0.2", + "@angular/router": "13.0.2", + "@ngrx/store": "13.0.1", + "@nrwl/angular": "13.2.2", + "@nrwl/nx-cloud": "12.5.4", "@testing-library/dom": "^8.0.0", "@testing-library/user-event": "^13.1.9", "core-js": "^3.6.5", @@ -49,29 +49,29 @@ "zone.js": "0.11.4" }, "devDependencies": { - "@angular-devkit/build-angular": "12.2.7", - "@angular-eslint/eslint-plugin": "12.3.1", - "@angular-eslint/eslint-plugin-template": "12.3.1", - "@angular-eslint/template-parser": "12.3.1", - "@angular/cli": "12.2.7", - "@angular/compiler-cli": "12.2.0", - "@angular/language-service": "12.2.0", - "@nrwl/cli": "12.9.0", - "@nrwl/eslint-plugin-nx": "12.9.0", - "@nrwl/jest": "12.9.0", - "@nrwl/linter": "12.9.0", - "@nrwl/node": "12.9.0", - "@nrwl/nx-plugin": "12.9.0", - "@nrwl/workspace": "12.9.0", + "@angular-devkit/build-angular": "13.0.3", + "@angular-eslint/eslint-plugin": "12.6.1", + "@angular-eslint/eslint-plugin-template": "12.6.1", + "@angular-eslint/template-parser": "12.6.1", + "@angular/cli": "13.0.3", + "@angular/compiler-cli": "13.0.2", + "@angular/language-service": "13.0.2", + "@nrwl/cli": "13.2.2", + "@nrwl/eslint-plugin-nx": "13.2.2", + "@nrwl/jest": "13.2.2", + "@nrwl/linter": "13.2.2", + "@nrwl/node": "13.2.2", + "@nrwl/nx-plugin": "13.2.2", + "@nrwl/workspace": "13.2.2", "@testing-library/jasmine-dom": "^1.2.0", "@testing-library/jest-dom": "^5.11.10", "@types/jasmine": "^3.5.0", - "@types/jest": "^27.0.2", + "@types/jest": "27.0.2", "@types/node": "14.14.37", - "@typescript-eslint/eslint-plugin": "4.28.5", - "@typescript-eslint/parser": "4.28.5", + "@typescript-eslint/eslint-plugin": "4.33.0", + "@typescript-eslint/parser": "4.33.0", "cpy-cli": "^3.1.1", - "eslint": "^7.25.0", + "eslint": "7.32.0", "eslint-config-prettier": "8.3.0", "eslint-plugin-import": "2.23.4", "eslint-plugin-jasmine": "^4.1.2", @@ -81,19 +81,23 @@ "husky": "^6.0.0", "jasmine-core": "^3.7.0", "jasmine-spec-reporter": "^5.0.0", - "jest": "^27.0.6", - "jest-preset-angular": "9.0.7", + "jest": "27.2.3", + "jest-preset-angular": "11.0.0", "karma": "^6.3.4", "karma-chrome-launcher": "^3.1.0", "karma-jasmine": "^4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "lint-staged": "^10.2.11", - "ng-packagr": "12.2.2", + "ng-packagr": "13.0.6", + "postcss": "^8.3.9", + "postcss-import": "^14.0.2", + "postcss-preset-env": "^6.7.0", + "postcss-url": "^10.1.1", "prettier": "^2.3.0", "rimraf": "^3.0.2", "semantic-release": "^17.1.1", - "ts-jest": "^27.0.3", + "ts-jest": "27.0.5", "ts-node": "9.1.1", - "typescript": "4.3.5" + "typescript": "4.4.4" } } diff --git a/projects/jest-utils/tests/create-mock.spec.ts b/projects/jest-utils/tests/create-mock.spec.ts index ded7ab1c..2393fe30 100644 --- a/projects/jest-utils/tests/create-mock.spec.ts +++ b/projects/jest-utils/tests/create-mock.spec.ts @@ -45,10 +45,12 @@ test('provides a mock service', async () => { test('provides a mock service with values', async () => { await render(FixtureComponent, { - providers: [provideMockWithValues(FixtureService, { - bar: 'value', - concat: jest.fn(() => 'a concatenated value') - })], + providers: [ + provideMockWithValues(FixtureService, { + bar: 'value', + concat: jest.fn(() => 'a concatenated value'), + }), + ], }); const service = TestBed.inject(FixtureService); diff --git a/projects/jest-utils/tsconfig.lib.json b/projects/jest-utils/tsconfig.lib.json index 7a6179a2..3d8b1a71 100644 --- a/projects/jest-utils/tsconfig.lib.json +++ b/projects/jest-utils/tsconfig.lib.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "../../out-tsc/lib", "target": "es2015", @@ -17,7 +17,7 @@ "lib": ["dom", "es2018"] }, "angularCompilerOptions": { - "enableIvy": false, + "compilationMode": "partial", "skipTemplateCodegen": true, "strictMetadataEmit": true, "fullTemplateTypeCheck": true, @@ -25,5 +25,5 @@ "flatModuleId": "AUTOGENERATED", "flatModuleOutFile": "AUTOGENERATED" }, - "exclude": ["src/test.ts", "**/*.spec.ts"] + "exclude": ["src/test.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/projects/jest-utils/tsconfig.spec.json b/projects/jest-utils/tsconfig.spec.json index 091c5cf3..99ee9666 100644 --- a/projects/jest-utils/tsconfig.spec.json +++ b/projects/jest-utils/tsconfig.spec.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "types": ["node", "jest", "@testing-library/jest-dom"] }, "files": ["test-setup.ts"], - "include": ["**/*.spec.ts", "**/*.d.ts"] + "include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"] } diff --git a/projects/testing-library/tsconfig.lib.json b/projects/testing-library/tsconfig.lib.json index 8506c888..bc6bb8b7 100644 --- a/projects/testing-library/tsconfig.lib.json +++ b/projects/testing-library/tsconfig.lib.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "../../out-tsc/lib", "declarationMap": false, @@ -16,7 +16,7 @@ "lib": ["dom", "es2018"] }, "angularCompilerOptions": { - "enableIvy": false, + "compilationMode": "partial", "skipTemplateCodegen": true, "strictMetadataEmit": true, "fullTemplateTypeCheck": true, @@ -24,5 +24,5 @@ "flatModuleId": "AUTOGENERATED", "flatModuleOutFile": "AUTOGENERATED" }, - "exclude": ["src/test.ts", "**/*.spec.ts"] + "exclude": ["src/test.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/projects/testing-library/tsconfig.schematics.json b/projects/testing-library/tsconfig.schematics.json index 91de9574..0573a52a 100644 --- a/projects/testing-library/tsconfig.schematics.json +++ b/projects/testing-library/tsconfig.schematics.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "strict": true, "target": "es6", diff --git a/projects/testing-library/tsconfig.spec.json b/projects/testing-library/tsconfig.spec.json index 091c5cf3..99ee9666 100644 --- a/projects/testing-library/tsconfig.spec.json +++ b/projects/testing-library/tsconfig.spec.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "module": "commonjs", "types": ["node", "jest", "@testing-library/jest-dom"] }, "files": ["test-setup.ts"], - "include": ["**/*.spec.ts", "**/*.d.ts"] + "include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"] } diff --git a/projects/vscode-atl-render/.vscode/launch.json b/projects/vscode-atl-render/.vscode/launch.json index 0e191b59..4058e694 100644 --- a/projects/vscode-atl-render/.vscode/launch.json +++ b/projects/vscode-atl-render/.vscode/launch.json @@ -3,15 +3,13 @@ // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 { - "version": "0.2.0", - "configurations": [ - { - "name": "Extension", - "type": "extensionHost", - "request": "launch", - "args": [ - "--extensionDevelopmentPath=${workspaceFolder}" - ] - } - ] -} \ No newline at end of file + "version": "0.2.0", + "configurations": [ + { + "name": "Extension", + "type": "extensionHost", + "request": "launch", + "args": ["--extensionDevelopmentPath=${workspaceFolder}"] + } + ] +} diff --git a/tsconfig.json b/tsconfig.base.json similarity index 100% rename from tsconfig.json rename to tsconfig.base.json From 21b4d59f6b582dfbdfd0ead3fc86a0a8eb729888 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 12:29:41 +0100 Subject: [PATCH 02/18] build(deps): update test libraries - jasmine - jest - testing-library --- package.json | 24 +++++++++---------- projects/testing-library/tests/render.spec.ts | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 62edacca..bb8272c9 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "@ngrx/store": "13.0.1", "@nrwl/angular": "13.2.2", "@nrwl/nx-cloud": "12.5.4", - "@testing-library/dom": "^8.0.0", - "@testing-library/user-event": "^13.1.9", + "@testing-library/dom": "^8.11.1", + "@testing-library/user-event": "^13.5.0", "core-js": "^3.6.5", "rxjs": "^6.5.5", "tslib": "^2.0.0", @@ -64,9 +64,9 @@ "@nrwl/nx-plugin": "13.2.2", "@nrwl/workspace": "13.2.2", "@testing-library/jasmine-dom": "^1.2.0", - "@testing-library/jest-dom": "^5.11.10", - "@types/jasmine": "^3.5.0", - "@types/jest": "27.0.2", + "@testing-library/jest-dom": "^5.15.0", + "@types/jasmine": "^3.10.2", + "@types/jest": "27.0.3", "@types/node": "14.14.37", "@typescript-eslint/eslint-plugin": "4.33.0", "@typescript-eslint/parser": "4.33.0", @@ -79,14 +79,14 @@ "eslint-plugin-jest-dom": "3.9.0", "eslint-plugin-testing-library": "4.9.0", "husky": "^6.0.0", - "jasmine-core": "^3.7.0", - "jasmine-spec-reporter": "^5.0.0", - "jest": "27.2.3", - "jest-preset-angular": "11.0.0", - "karma": "^6.3.4", + "jasmine-core": "^3.10.1", + "jasmine-spec-reporter": "^7.0.0", + "jest": "27.3.1", + "jest-preset-angular": "11.0.1", + "karma": "^6.3.9", "karma-chrome-launcher": "^3.1.0", - "karma-jasmine": "^4.0.0", - "karma-jasmine-html-reporter": "^1.5.0", + "karma-jasmine": "^4.0.1", + "karma-jasmine-html-reporter": "^1.7.0", "lint-staged": "^10.2.11", "ng-packagr": "13.0.6", "postcss": "^8.3.9", diff --git a/projects/testing-library/tests/render.spec.ts b/projects/testing-library/tests/render.spec.ts index 678da79c..8312bd4a 100644 --- a/projects/testing-library/tests/render.spec.ts +++ b/projects/testing-library/tests/render.spec.ts @@ -10,7 +10,7 @@ import { } from '@angular/core'; import { NoopAnimationsModule, BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { TestBed } from '@angular/core/testing'; -import { render, fireEvent, screen } from '../src/public_api'; +import { render, fireEvent } from '../src/public_api'; @Component({ selector: 'atl-fixture', From c90402d81d7ad9231e1bb7599c07d5144d99c248 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 12:50:15 +0100 Subject: [PATCH 03/18] build(deps): update to rxjs 7 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bb8272c9..a77228d6 100644 --- a/package.json +++ b/package.json @@ -44,9 +44,9 @@ "@testing-library/dom": "^8.11.1", "@testing-library/user-event": "^13.5.0", "core-js": "^3.6.5", - "rxjs": "^6.5.5", - "tslib": "^2.0.0", - "zone.js": "0.11.4" + "rxjs": "^7.4.0", + "tslib": "~2.3.1", + "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "13.0.3", From dfc80da5e725373dc9d30e4880a0e63333b67c60 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 12:55:04 +0100 Subject: [PATCH 04/18] build(deps): update husky and lint-staged --- .husky/.gitignore | 1 - package.json | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 .husky/.gitignore diff --git a/.husky/.gitignore b/.husky/.gitignore deleted file mode 100644 index 31354ec1..00000000 --- a/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ diff --git a/package.json b/package.json index a77228d6..31832262 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "eslint-plugin-jest": "24.3.6", "eslint-plugin-jest-dom": "3.9.0", "eslint-plugin-testing-library": "4.9.0", - "husky": "^6.0.0", + "husky": "^7.0.0", "jasmine-core": "^3.10.1", "jasmine-spec-reporter": "^7.0.0", "jest": "27.3.1", @@ -87,17 +87,17 @@ "karma-chrome-launcher": "^3.1.0", "karma-jasmine": "^4.0.1", "karma-jasmine-html-reporter": "^1.7.0", - "lint-staged": "^10.2.11", + "lint-staged": "^12.1.2", "ng-packagr": "13.0.6", - "postcss": "^8.3.9", + "postcss": "^8.3.11", "postcss-import": "^14.0.2", - "postcss-preset-env": "^6.7.0", - "postcss-url": "^10.1.1", - "prettier": "^2.3.0", + "postcss-preset-env": "^7.0.1", + "postcss-url": "^10.1.3", + "prettier": "^2.4.1", "rimraf": "^3.0.2", "semantic-release": "^17.1.1", - "ts-jest": "27.0.5", - "ts-node": "9.1.1", + "ts-jest": "27.0.7", + "ts-node": "~10.4.0", "typescript": "4.4.4" } } From 561d195241fbbc99a7ec804cc7d2fb7bf697366c Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 12:59:11 +0100 Subject: [PATCH 05/18] build(deps): remove core-js Does not seem to be used. (is no longer needed by angular) --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 31832262..20f8d9f7 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "@nrwl/nx-cloud": "12.5.4", "@testing-library/dom": "^8.11.1", "@testing-library/user-event": "^13.5.0", - "core-js": "^3.6.5", "rxjs": "^7.4.0", "tslib": "~2.3.1", "zone.js": "~0.11.4" From 4a44c9f33325ecb7e4429680f694cda170254c0b Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 13:00:47 +0100 Subject: [PATCH 06/18] build(deps): update semantic-release https://github.com/semantic-release/semantic-release/releases/tag/v18.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 20f8d9f7..a6386d24 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "postcss-url": "^10.1.3", "prettier": "^2.4.1", "rimraf": "^3.0.2", - "semantic-release": "^17.1.1", + "semantic-release": "^18.0.0", "ts-jest": "27.0.7", "ts-node": "~10.4.0", "typescript": "4.4.4" From dab86f7f92ed4785beca042cbd420e9cb0c68390 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 13:12:55 +0100 Subject: [PATCH 07/18] build(gitignore): add cache folders to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5f617103..2fe0d557 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,8 @@ !.vscode/extensions.json # misc -/.angular/cache +.angular +.cache /.sass-cache /connect.lock /coverage From c123ad120b5e2e3a654c380f8f2d60f490672369 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 13:13:11 +0100 Subject: [PATCH 08/18] build(nx): add workspaceLayout --- nx.json | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/nx.json b/nx.json index 82421f14..d16184fb 100644 --- a/nx.json +++ b/nx.json @@ -1,4 +1,9 @@ { + "npmScope": "testing-library", + "workspaceLayout": { + "appsDir": "apps", + "libsDir": "projects" + }, "implicitDependencies": { "angular.json": "*", "package.json": { @@ -12,7 +17,6 @@ "affected": { "defaultBase": "main" }, - "npmScope": "testing-library", "tasksRunnerOptions": { "default": { "runner": "@nrwl/nx-cloud", @@ -26,7 +30,50 @@ } }, "cli": { - "analytics": false + "analytics": false, + "cache": { + "enabled": true, + "path": "./.cache/angular", + "environment": "all" + } + }, + "generators": { + "@nrlw/workspace:library": { + "linter": "eslint", + "unitTestRunner": "jest", + "strict": true, + "standaloneConfig": true, + "buildable": true + }, + "@nrwl/angular:application": { + "style": "scss", + "linter": "eslint", + "unitTestRunner": "jest", + "e2eTestRunner": "cypress", + "strict": true, + "standaloneConfig": true, + "tags": ["type:app"] + }, + "@nrwl/angular:library": { + "style": "scss", + "linter": "eslint", + "unitTestRunner": "jest", + "strict": true, + "standaloneConfig": true, + "publishable": true + }, + "@nrwl/angular:component": { + "style": "scss", + "displayBlock": true, + "changeDetection": "OnPush" + }, + "@schematics/angular": { + "component": { + "style": "scss", + "displayBlock": true, + "changeDetection": "OnPush" + } + } }, "defaultProject": "example-app" } From 3dc278cde9a7a3d21405c34b27340fea72d32f5a Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 13:42:22 +0100 Subject: [PATCH 09/18] build(tsc): improve tsconfig settings --- apps/example-app-karma/tsconfig.app.json | 4 ++- apps/example-app/src/app/examples/03-forms.ts | 3 ++ .../app/examples/04-forms-with-material.ts | 3 ++ apps/example-app/tsconfig.app.json | 4 ++- projects/jest-utils/src/lib/create-mock.ts | 2 +- projects/jest-utils/tsconfig.json | 29 +++++++++++++++++++ projects/jest-utils/tsconfig.lib.json | 22 +++----------- projects/jest-utils/tsconfig.lib.prod.json | 9 ++++++ projects/jest-utils/tsconfig.spec.json | 2 +- projects/testing-library/tsconfig.json | 24 +++++++++++++++ projects/testing-library/tsconfig.lib.json | 21 +++----------- projects/testing-library/tsconfig.spec.json | 2 +- tsconfig.base.json | 16 ++++++---- 13 files changed, 95 insertions(+), 46 deletions(-) create mode 100644 projects/jest-utils/tsconfig.json create mode 100644 projects/jest-utils/tsconfig.lib.prod.json create mode 100644 projects/testing-library/tsconfig.json diff --git a/apps/example-app-karma/tsconfig.app.json b/apps/example-app-karma/tsconfig.app.json index 629fd434..4de7101b 100644 --- a/apps/example-app-karma/tsconfig.app.json +++ b/apps/example-app-karma/tsconfig.app.json @@ -5,5 +5,7 @@ "types": [], "allowJs": true }, - "files": ["src/main.ts", "src/polyfills.ts"] + "files": ["src/main.ts", "src/polyfills.ts"], + "include": ["src/**/*.d.ts"], + "exclude": ["**/*.test.ts", "**/*.spec.ts"] } diff --git a/apps/example-app/src/app/examples/03-forms.ts b/apps/example-app/src/app/examples/03-forms.ts index 03fa74f3..bc035a14 100644 --- a/apps/example-app/src/app/examples/03-forms.ts +++ b/apps/example-app/src/app/examples/03-forms.ts @@ -57,9 +57,12 @@ export class FormsComponent { return `${formKey} must be greater than ${error.min}`; case 'max': return `${formKey} must be lesser than ${error.max}`; + default: + return `${formKey} is invalid`; } }); } + return []; }) .reduce((errors, value) => errors.concat(value), []) .filter(Boolean); diff --git a/apps/example-app/src/app/examples/04-forms-with-material.ts b/apps/example-app/src/app/examples/04-forms-with-material.ts index e9a026ce..2718e389 100644 --- a/apps/example-app/src/app/examples/04-forms-with-material.ts +++ b/apps/example-app/src/app/examples/04-forms-with-material.ts @@ -79,9 +79,12 @@ export class MaterialFormsComponent { return `${formKey} must be greater than ${error.min}`; case 'max': return `${formKey} must be lesser than ${error.max}`; + default: + return `${formKey} is invalid`; } }); } + return []; }) .reduce((errors, value) => errors.concat(value), []) .filter(Boolean); diff --git a/apps/example-app/tsconfig.app.json b/apps/example-app/tsconfig.app.json index 629fd434..4de7101b 100644 --- a/apps/example-app/tsconfig.app.json +++ b/apps/example-app/tsconfig.app.json @@ -5,5 +5,7 @@ "types": [], "allowJs": true }, - "files": ["src/main.ts", "src/polyfills.ts"] + "files": ["src/main.ts", "src/polyfills.ts"], + "include": ["src/**/*.d.ts"], + "exclude": ["**/*.test.ts", "**/*.spec.ts"] } diff --git a/projects/jest-utils/src/lib/create-mock.ts b/projects/jest-utils/src/lib/create-mock.ts index 2796d972..73cbf406 100644 --- a/projects/jest-utils/src/lib/create-mock.ts +++ b/projects/jest-utils/src/lib/create-mock.ts @@ -16,7 +16,7 @@ export function createMock(type: Type): Mock { } const descriptor = Object.getOwnPropertyDescriptor(proto, prop); - if (typeof descriptor.value === 'function') { + if (typeof descriptor?.value === 'function') { mock[prop] = jest.fn(); } } diff --git a/projects/jest-utils/tsconfig.json b/projects/jest-utils/tsconfig.json new file mode 100644 index 00000000..64dba532 --- /dev/null +++ b/projects/jest-utils/tsconfig.json @@ -0,0 +1,29 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.lib.prod.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": { + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "angularCompilerOptions": { + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true, + "flatModuleId": "AUTOGENERATED", + "flatModuleOutFile": "AUTOGENERATED" + } +} diff --git a/projects/jest-utils/tsconfig.lib.json b/projects/jest-utils/tsconfig.lib.json index 3d8b1a71..b3428d33 100644 --- a/projects/jest-utils/tsconfig.lib.json +++ b/projects/jest-utils/tsconfig.lib.json @@ -1,29 +1,15 @@ { - "extends": "../../tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/lib", - "target": "es2015", - "declarationMap": false, - "module": "es2015", - "moduleResolution": "node", "declaration": true, - "sourceMap": true, + "declarationMap": false, "inlineSources": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": true, - "allowSyntheticDefaultImports": true, - "types": ["jest"], - "lib": ["dom", "es2018"] + "types": ["jest"] }, "angularCompilerOptions": { - "compilationMode": "partial", "skipTemplateCodegen": true, - "strictMetadataEmit": true, - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true, - "flatModuleId": "AUTOGENERATED", - "flatModuleOutFile": "AUTOGENERATED" + "strictMetadataEmit": true }, "exclude": ["src/test.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/projects/jest-utils/tsconfig.lib.prod.json b/projects/jest-utils/tsconfig.lib.prod.json new file mode 100644 index 00000000..2a2faa88 --- /dev/null +++ b/projects/jest-utils/tsconfig.lib.prod.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} diff --git a/projects/jest-utils/tsconfig.spec.json b/projects/jest-utils/tsconfig.spec.json index 99ee9666..73461f35 100644 --- a/projects/jest-utils/tsconfig.spec.json +++ b/projects/jest-utils/tsconfig.spec.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", "types": ["node", "jest", "@testing-library/jest-dom"] diff --git a/projects/testing-library/tsconfig.json b/projects/testing-library/tsconfig.json new file mode 100644 index 00000000..24663f6f --- /dev/null +++ b/projects/testing-library/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.lib.prod.json" + }, + { + "path": "./tsconfig.spec.json" + } + ], + "compilerOptions": {}, + "angularCompilerOptions": { + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true, + "flatModuleId": "AUTOGENERATED", + "flatModuleOutFile": "AUTOGENERATED" + } +} diff --git a/projects/testing-library/tsconfig.lib.json b/projects/testing-library/tsconfig.lib.json index bc6bb8b7..8eed53ea 100644 --- a/projects/testing-library/tsconfig.lib.json +++ b/projects/testing-library/tsconfig.lib.json @@ -1,28 +1,15 @@ { - "extends": "../../tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/lib", - "declarationMap": false, - "target": "es2015", - "module": "ES2015", - "moduleResolution": "node", "declaration": true, - "sourceMap": true, + "declarationMap": false, "inlineSources": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "importHelpers": false, - "types": ["node", "jest"], - "lib": ["dom", "es2018"] + "types": ["node", "jest"] }, "angularCompilerOptions": { - "compilationMode": "partial", "skipTemplateCodegen": true, - "strictMetadataEmit": true, - "fullTemplateTypeCheck": true, - "strictInjectionParameters": true, - "flatModuleId": "AUTOGENERATED", - "flatModuleOutFile": "AUTOGENERATED" + "strictMetadataEmit": true }, "exclude": ["src/test.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/projects/testing-library/tsconfig.spec.json b/projects/testing-library/tsconfig.spec.json index 99ee9666..73461f35 100644 --- a/projects/testing-library/tsconfig.spec.json +++ b/projects/testing-library/tsconfig.spec.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.base.json", + "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", "types": ["node", "jest", "@testing-library/jest-dom"] diff --git a/tsconfig.base.json b/tsconfig.base.json index 69eb7ed5..0ad01d03 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -2,20 +2,24 @@ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, "importHelpers": true, + "lib": ["es2018", "dom"], "module": "esnext", + "moduleResolution": "node", "outDir": "./dist/out-tsc", "sourceMap": true, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, "target": "es2015", "typeRoots": ["node_modules/@types"], - "lib": ["es2017", "dom"], + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, "paths": { "@testing-library/angular": ["projects/testing-library"], "@testing-library/angular/jest-utils": ["projects/jest-utils"] } - } + }, + "exclude": ["node_modules", "tmp"] } From cbc8f77ec812f5f5794cd3bce7938877816918d4 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 14:54:12 +0100 Subject: [PATCH 10/18] build(nx): move to per project configuration > Independent project configurations provide more flexibility for projects and less possibility of merge > conflicts for larger workspaces see: - https://nx.dev/l/a/workspace/convert-to-nx-project-generator - https://blog.nrwl.io/per-project-configuration-storybook-support-for-angular-12-auto-refresh-for-dependency-graph-and-bcd2d1e06658 --- .gitignore | 1 + .nxignore | 1 + angular.json | 296 ------------------ apps/example-app-karma/project.json | 89 ++++++ .../src/environments/environment.ts | 2 +- apps/example-app/project.json | 90 ++++++ nx.json | 35 ++- package.json | 10 +- projects/jest-utils/project.json | 51 +++ projects/jest-utils/tsconfig.json | 7 +- projects/testing-library/project.json | 59 ++++ projects/testing-library/tsconfig.json | 4 +- workspace.json | 9 + 13 files changed, 330 insertions(+), 324 deletions(-) create mode 100644 .nxignore delete mode 100644 angular.json create mode 100644 apps/example-app-karma/project.json create mode 100644 apps/example-app/project.json create mode 100644 projects/jest-utils/project.json create mode 100644 projects/testing-library/project.json create mode 100644 workspace.json diff --git a/.gitignore b/.gitignore index 2fe0d557..b1a42cd6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ !.vscode/extensions.json # misc +/.angular/cache .angular .cache /.sass-cache diff --git a/.nxignore b/.nxignore new file mode 100644 index 00000000..aeb6b7f1 --- /dev/null +++ b/.nxignore @@ -0,0 +1 @@ +/projects/vscode-atl-render diff --git a/angular.json b/angular.json deleted file mode 100644 index 01533167..00000000 --- a/angular.json +++ /dev/null @@ -1,296 +0,0 @@ -{ - "version": 1, - "projects": { - "example-app": { - "projectType": "application", - "root": "apps/example-app", - "sourceRoot": "apps/example-app/src", - "prefix": "app", - "schematics": {}, - "architect": { - "build": { - "builder": "@angular-devkit/build-angular:browser", - "options": { - "outputPath": "dist/apps/example-app", - "index": "apps/example-app/src/index.html", - "main": "apps/example-app/src/main.ts", - "polyfills": "apps/example-app/src/polyfills.ts", - "tsConfig": "apps/example-app/tsconfig.app.json", - "assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"], - "styles": ["apps/example-app/src/styles.css"], - "scripts": [], - "vendorChunk": true, - "extractLicenses": false, - "buildOptimizer": false, - "sourceMap": true, - "optimization": false, - "namedChunks": true - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "fileReplacements": [ - { - "replace": "apps/example-app/src/environments/environment.ts", - "with": "apps/example-app/src/environments/environment.prod.ts" - } - ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "namedChunks": false, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true - } - }, - "outputs": ["{options.outputPath}"] - }, - "serve": { - "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "example-app:build" - }, - "configurations": { - "production": { - "browserTarget": "example-app:build:production" - } - } - }, - "extract-i18n": { - "builder": "@angular-devkit/build-angular:extract-i18n", - "options": { - "browserTarget": "example-app:build" - } - }, - "lint": { - "builder": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": [ - "apps/example-app/**/*.ts", - "apps/example-app/**/*.html", - "apps/example-app/src/**/*.html", - "apps/example-app/src/**/*.html", - "apps/example-app/src/**/*.html" - ] - }, - "outputs": ["{options.outputFile}"] - }, - "test": { - "builder": "@nrwl/jest:jest", - "options": { - "jestConfig": "apps/example-app/jest.config.js" - }, - "outputs": ["coverage/"] - } - }, - "tags": [] - }, - "example-app-karma": { - "projectType": "application", - "root": "apps/example-app-karma", - "sourceRoot": "apps/example-app-karma/src", - "prefix": "app", - "schematics": {}, - "architect": { - "build": { - "builder": "@angular-devkit/build-angular:browser", - "options": { - "outputPath": "dist/apps/example-app-karma", - "index": "apps/example-app-karma/src/index.html", - "main": "apps/example-app-karma/src/main.ts", - "polyfills": "apps/example-app-karma/src/polyfills.ts", - "tsConfig": "apps/example-app-karma/tsconfig.app.json", - "assets": ["apps/example-app-karma/src/favicon.ico", "apps/example-app-karma/src/assets"], - "styles": [], - "scripts": [], - "vendorChunk": true, - "extractLicenses": false, - "buildOptimizer": false, - "sourceMap": true, - "optimization": false, - "namedChunks": true - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "fileReplacements": [ - { - "replace": "apps/example-app-karma/src/environments/environment.ts", - "with": "apps/example-app-karma/src/environments/environment.prod.ts" - } - ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "namedChunks": false, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true - } - }, - "outputs": ["{options.outputPath}"] - }, - "serve": { - "builder": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "example-app-karma:build" - }, - "configurations": { - "production": { - "browserTarget": "example-app-karma:build:production" - } - } - }, - "lint": { - "builder": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": [ - "apps/example-app-karma/**/*.ts", - "apps/example-app-karma/**/*.html", - "apps/example-app-karma/src/**/*.html", - "apps/example-app-karma/src/**/*.html", - "apps/example-app-karma/src/**/*.html" - ] - }, - "outputs": ["{options.outputFile}"] - }, - "test": { - "builder": "@angular-devkit/build-angular:karma", - "options": { - "main": "apps/example-app-karma/src/test.ts", - "tsConfig": "apps/example-app-karma/tsconfig.spec.json", - "polyfills": "apps/example-app-karma/src/polyfills.ts", - "karmaConfig": "apps/example-app-karma/karma.conf.js", - "styles": [], - "scripts": [], - "assets": [] - } - } - }, - "tags": [] - }, - "jest-utils": { - "root": "projects/jest-utils", - "sourceRoot": "projects/jest-utils/src", - "projectType": "library", - "prefix": "lib", - "architect": { - "build-package": { - "builder": "@angular-devkit/build-angular:ng-packagr", - "options": { - "tsConfig": "projects/jest-utils/tsconfig.lib.json", - "project": "projects/jest-utils/ng-package.json" - }, - "configurations": { - "production": { - "project": "projects/jest-utils/ng-package.json", - "tsConfig": "projects/jest-utils/tsconfig.lib.json" - } - } - }, - "lint": { - "builder": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": [ - "projects/jest-utils/**/*.ts", - "projects/jest-utils/**/*.html", - "projects/jest-utils/src/**/*.html", - "projects/jest-utils/src/**/*.html", - "projects/jest-utils/src/**/*.html" - ] - }, - "outputs": ["{options.outputFile}"] - }, - "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" - }, - "outputs": ["coverage/projects/jest-utils"] - } - }, - "tags": [] - }, - "testing-library": { - "root": "projects/testing-library", - "sourceRoot": "projects/testing-library/src", - "projectType": "library", - "prefix": "lib", - "architect": { - "build-package": { - "builder": "@angular-devkit/build-angular:ng-packagr", - "options": { - "tsConfig": "projects/testing-library/tsconfig.lib.json", - "project": "projects/testing-library/ng-package.json" - }, - "configurations": { - "production": { - "project": "projects/testing-library/ng-package.json", - "tsConfig": "projects/testing-library/tsconfig.lib.json" - } - } - }, - "lint": { - "builder": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": [ - "projects/testing-library/**/*.ts", - "projects/testing-library/**/*.html", - "projects/testing-library/src/**/*.html", - "projects/testing-library/src/**/*.html", - "projects/testing-library/src/**/*.html" - ] - }, - "outputs": ["{options.outputFile}"] - }, - "build": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "parallel": false, - "commands": [ - { - "command": "ng run testing-library:build-package" - }, - { - "command": "npm run build:schematics" - }, - { - "command": "cpy ./README.md ./dist/@testing-library/angular" - } - ] - } - }, - "test": { - "builder": "@nrwl/jest:jest", - "options": { - "jestConfig": "projects/testing-library/jest.config.js" - }, - "outputs": ["coverage/projects/testing-library"] - } - }, - "tags": [] - } - } -} diff --git a/apps/example-app-karma/project.json b/apps/example-app-karma/project.json new file mode 100644 index 00000000..df522d48 --- /dev/null +++ b/apps/example-app-karma/project.json @@ -0,0 +1,89 @@ +{ + "projectType": "application", + "root": "apps/example-app-karma", + "sourceRoot": "apps/example-app-karma/src", + "prefix": "app", + "generators": {}, + "targets": { + "build": { + "executor": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/apps/example-app-karma", + "index": "apps/example-app-karma/src/index.html", + "main": "apps/example-app-karma/src/main.ts", + "polyfills": "apps/example-app-karma/src/polyfills.ts", + "tsConfig": "apps/example-app-karma/tsconfig.app.json", + "assets": ["apps/example-app-karma/src/favicon.ico", "apps/example-app-karma/src/assets"], + "styles": [], + "scripts": [], + "vendorChunk": true, + "extractLicenses": false, + "buildOptimizer": false, + "sourceMap": true, + "optimization": false, + "namedChunks": true + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" + } + ], + "fileReplacements": [ + { + "replace": "apps/example-app-karma/src/environments/environment.ts", + "with": "apps/example-app-karma/src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true + } + }, + "outputs": ["{options.outputPath}"] + }, + "serve": { + "executor": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "example-app-karma:build" + }, + "configurations": { + "production": { + "browserTarget": "example-app-karma:build:production" + } + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": [ + "apps/example-app-karma/**/*.ts", + "apps/example-app-karma/**/*.html", + "apps/example-app-karma/src/**/*.html", + "apps/example-app-karma/src/**/*.html", + "apps/example-app-karma/src/**/*.html" + ] + }, + "outputs": ["{options.outputFile}"] + }, + "test": { + "executor": "@angular-devkit/build-angular:karma", + "options": { + "main": "apps/example-app-karma/src/test.ts", + "tsConfig": "apps/example-app-karma/tsconfig.spec.json", + "polyfills": "apps/example-app-karma/src/polyfills.ts", + "karmaConfig": "apps/example-app-karma/karma.conf.js", + "styles": [], + "scripts": [], + "assets": [] + } + } + }, + "tags": [] +} diff --git a/apps/example-app-karma/src/environments/environment.ts b/apps/example-app-karma/src/environments/environment.ts index 85db3caf..64c3e6c7 100644 --- a/apps/example-app-karma/src/environments/environment.ts +++ b/apps/example-app-karma/src/environments/environment.ts @@ -1,6 +1,6 @@ // This file can be replaced during build by using the `fileReplacements` array. // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. -// The list of file replacements can be found in `angular.json`. +// The list of file replacements can be found in `workspace.json`. export const environment = { production: false, diff --git a/apps/example-app/project.json b/apps/example-app/project.json new file mode 100644 index 00000000..d70d3c19 --- /dev/null +++ b/apps/example-app/project.json @@ -0,0 +1,90 @@ +{ + "projectType": "application", + "root": "apps/example-app", + "sourceRoot": "apps/example-app/src", + "prefix": "app", + "generators": {}, + "targets": { + "build": { + "executor": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/apps/example-app", + "index": "apps/example-app/src/index.html", + "main": "apps/example-app/src/main.ts", + "polyfills": "apps/example-app/src/polyfills.ts", + "tsConfig": "apps/example-app/tsconfig.app.json", + "assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"], + "styles": ["apps/example-app/src/styles.css"], + "scripts": [], + "vendorChunk": true, + "extractLicenses": false, + "buildOptimizer": false, + "sourceMap": true, + "optimization": false, + "namedChunks": true + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" + } + ], + "fileReplacements": [ + { + "replace": "apps/example-app/src/environments/environment.ts", + "with": "apps/example-app/src/environments/environment.prod.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "namedChunks": false, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true + } + }, + "outputs": ["{options.outputPath}"] + }, + "serve": { + "executor": "@angular-devkit/build-angular:dev-server", + "options": { + "browserTarget": "example-app:build" + }, + "configurations": { + "production": { + "browserTarget": "example-app:build:production" + } + } + }, + "extract-i18n": { + "executor": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "example-app:build" + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": [ + "apps/example-app/**/*.ts", + "apps/example-app/**/*.html", + "apps/example-app/src/**/*.html", + "apps/example-app/src/**/*.html", + "apps/example-app/src/**/*.html" + ] + }, + "outputs": ["{options.outputFile}"] + }, + "test": { + "executor": "@nrwl/jest:jest", + "options": { + "jestConfig": "apps/example-app/jest.config.js" + }, + "outputs": ["coverage/"] + } + }, + "tags": [] +} diff --git a/nx.json b/nx.json index d16184fb..d8e87c08 100644 --- a/nx.json +++ b/nx.json @@ -1,21 +1,26 @@ { "npmScope": "testing-library", + "affected": { + "defaultBase": "main" + }, "workspaceLayout": { "appsDir": "apps", "libsDir": "projects" }, + "cli": { + "analytics": false, + "cache": { + "enabled": true, + "path": "./.cache/angular", + "environment": "all" + } + }, "implicitDependencies": { - "angular.json": "*", "package.json": { "dependencies": "*", "devDependencies": "*" }, - "tsconfig.base.json": "*", - ".eslintrc.json": "*", - "nx.json": "*" - }, - "affected": { - "defaultBase": "main" + ".eslintrc.json": "*" }, "tasksRunnerOptions": { "default": { @@ -25,17 +30,17 @@ "cacheableOperations": ["build", "test", "lint", "e2e"], "canTrackAnalytics": false, "showUsageWarnings": true, - "parallel": 1 + "parallel": 3 } } }, - "cli": { - "analytics": false, - "cache": { - "enabled": true, - "path": "./.cache/angular", - "environment": "all" - } + "targetDependencies": { + "build": [ + { + "target": "build", + "projects": "dependencies" + } + ] }, "generators": { "@nrlw/workspace:library": { diff --git a/package.json b/package.json index a6386d24..b0668363 100644 --- a/package.json +++ b/package.json @@ -2,16 +2,16 @@ "name": "@testing-library/angular-app", "version": "0.0.0-semantically-released", "scripts": { - "ng": "ng", + "ng": "nx", "nx": "nx", - "postinstall": "ngcc", - "start": "ng serve", + "postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main", + "start": "nx serve", "prebuild": "rimraf dist", "build": "nx run-many --target=build --projects=testing-library,jest-utils", "build:schematics": "tsc -p ./projects/testing-library/tsconfig.schematics.json", "test": "nx run-many --target=test --all", - "lint": "nx workspace-lint && ng lint", - "e2e": "ng e2e", + "lint": "nx workspace-lint && nx lint", + "e2e": "nx e2e", "affected:apps": "nx affected:apps", "affected:libs": "nx affected:libs", "affected:build": "nx affected:build", diff --git a/projects/jest-utils/project.json b/projects/jest-utils/project.json new file mode 100644 index 00000000..4127a045 --- /dev/null +++ b/projects/jest-utils/project.json @@ -0,0 +1,51 @@ +{ + "root": "projects/jest-utils", + "sourceRoot": "projects/jest-utils/src", + "projectType": "library", + "prefix": "lib", + "targets": { + "build-package": { + "executor": "@angular-devkit/build-angular:ng-packagr", + "options": { + "tsConfig": "projects/jest-utils/tsconfig.lib.json", + "project": "projects/jest-utils/ng-package.json" + }, + "configurations": { + "production": { + "project": "projects/jest-utils/ng-package.json", + "tsConfig": "projects/jest-utils/tsconfig.lib.json" + } + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": [ + "projects/jest-utils/**/*.ts", + "projects/jest-utils/**/*.html", + "projects/jest-utils/src/**/*.html" + ] + }, + "outputs": ["{options.outputFile}"] + }, + "build": { + "executor": "@nrwl/workspace:run-commands", + "options": { + "parallel": false, + "commands": [ + { + "command": "nx run jest-utils:build-package" + } + ] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "options": { + "jestConfig": "projects/jest-utils/jest.config.js" + }, + "outputs": ["coverage/projects/jest-utils"] + } + }, + "tags": [] +} diff --git a/projects/jest-utils/tsconfig.json b/projects/jest-utils/tsconfig.json index 64dba532..24663f6f 100644 --- a/projects/jest-utils/tsconfig.json +++ b/projects/jest-utils/tsconfig.json @@ -13,12 +13,7 @@ "path": "./tsconfig.spec.json" } ], - "compilerOptions": { - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, + "compilerOptions": {}, "angularCompilerOptions": { "strictInjectionParameters": true, "strictInputAccessModifiers": true, diff --git a/projects/testing-library/project.json b/projects/testing-library/project.json new file mode 100644 index 00000000..64c8680a --- /dev/null +++ b/projects/testing-library/project.json @@ -0,0 +1,59 @@ +{ + "root": "projects/testing-library", + "sourceRoot": "projects/testing-library/src", + "projectType": "library", + "prefix": "lib", + "targets": { + "build-package": { + "executor": "@angular-devkit/build-angular:ng-packagr", + "options": { + "tsConfig": "projects/testing-library/tsconfig.lib.json", + "project": "projects/testing-library/ng-package.json" + }, + "configurations": { + "production": { + "project": "projects/testing-library/ng-package.json", + "tsConfig": "projects/testing-library/tsconfig.lib.json" + } + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": [ + "projects/testing-library/**/*.ts", + "projects/testing-library/**/*.html", + "projects/testing-library/src/**/*.html", + "projects/testing-library/src/**/*.html", + "projects/testing-library/src/**/*.html" + ] + }, + "outputs": ["{options.outputFile}"] + }, + "build": { + "executor": "@nrwl/workspace:run-commands", + "options": { + "parallel": false, + "commands": [ + { + "command": "nx run testing-library:build-package" + }, + { + "command": "npm run build:schematics" + }, + { + "command": "cpy ./README.md ./dist/@testing-library/angular" + } + ] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "options": { + "jestConfig": "projects/testing-library/jest.config.js" + }, + "outputs": ["coverage/projects/testing-library"] + } + }, + "tags": [] +} diff --git a/projects/testing-library/tsconfig.json b/projects/testing-library/tsconfig.json index 24663f6f..c7e97944 100644 --- a/projects/testing-library/tsconfig.json +++ b/projects/testing-library/tsconfig.json @@ -13,7 +13,9 @@ "path": "./tsconfig.spec.json" } ], - "compilerOptions": {}, + "compilerOptions": { + "strict": false + }, "angularCompilerOptions": { "strictInjectionParameters": true, "strictInputAccessModifiers": true, diff --git a/workspace.json b/workspace.json new file mode 100644 index 00000000..dfd6bcf1 --- /dev/null +++ b/workspace.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "projects": { + "example-app": "apps/example-app", + "example-app-karma": "apps/example-app-karma", + "jest-utils": "projects/jest-utils", + "testing-library": "projects/testing-library" + } +} From c864c018fdcd44c927c6edae38e3f53b9f9d7c5f Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 15:04:59 +0100 Subject: [PATCH 11/18] build(deps): update dependencies --- decorate-angular-cli.js | 69 +++++++++++++++++++++++++++++++++++++++++ package.json | 4 +-- 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 decorate-angular-cli.js diff --git a/decorate-angular-cli.js b/decorate-angular-cli.js new file mode 100644 index 00000000..bc81a837 --- /dev/null +++ b/decorate-angular-cli.js @@ -0,0 +1,69 @@ +/** + * This file decorates the Angular CLI with the Nx CLI to enable features such as computation caching + * and faster execution of tasks. + * + * It does this by: + * + * - Patching the Angular CLI to warn you in case you accidentally use the undecorated ng command. + * - Symlinking the ng to nx command, so all commands run through the Nx CLI + * - Updating the package.json postinstall script to give you control over this script + * + * The Nx CLI decorates the Angular CLI, so the Nx CLI is fully compatible with it. + * Every command you run should work the same when using the Nx CLI, except faster. + * + * Because of symlinking you can still type `ng build/test/lint` in the terminal. The ng command, in this case, + * will point to nx, which will perform optimizations before invoking ng. So the Angular CLI is always invoked. + * The Nx CLI simply does some optimizations before invoking the Angular CLI. + * + * To opt out of this patch: + * - Replace occurrences of nx with ng in your package.json + * - Remove the script from your postinstall script in your package.json + * - Delete and reinstall your node_modules + */ + +const fs = require('fs'); +const os = require('os'); +const cp = require('child_process'); +const isWindows = os.platform() === 'win32'; +let output; +try { + output = require('@nrwl/workspace').output; +} catch (e) { + console.warn('Angular CLI could not be decorated to enable computation caching. Please ensure @nrwl/workspace is installed.'); + process.exit(0); +} + +/** + * Symlink of ng to nx, so you can keep using `ng build/test/lint` and still + * invoke the Nx CLI and get the benefits of computation caching. + */ +function symlinkNgCLItoNxCLI() { + try { + const ngPath = './node_modules/.bin/ng'; + const nxPath = './node_modules/.bin/nx'; + if (isWindows) { + /** + * This is the most reliable way to create symlink-like behavior on Windows. + * Such that it works in all shells and works with npx. + */ + ['', '.cmd', '.ps1'].forEach(ext => { + if (fs.existsSync(nxPath + ext)) fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext)); + }); + } else { + // If unix-based, symlink + cp.execSync(`ln -sf ./nx ${ngPath}`); + } + } + catch(e) { + output.error({ title: 'Unable to create a symlink from the Angular CLI to the Nx CLI:' + e.message }); + throw e; + } +} + +try { + symlinkNgCLItoNxCLI(); + require('@nrwl/cli/lib/decorate-cli').decorateCli(); + output.log({ title: 'Angular CLI has been decorated to enable computation caching.' }); +} catch(e) { + output.error({ title: 'Decoration of the Angular CLI did not complete successfully' }); +} diff --git a/package.json b/package.json index b0668363..3c7c74ec 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "@nrwl/nx-plugin": "13.2.2", "@nrwl/workspace": "13.2.2", "@testing-library/jasmine-dom": "^1.2.0", - "@testing-library/jest-dom": "^5.15.0", + "@testing-library/jest-dom": "^5.15.1", "@types/jasmine": "^3.10.2", "@types/jest": "27.0.3", "@types/node": "14.14.37", @@ -87,7 +87,7 @@ "karma-jasmine": "^4.0.1", "karma-jasmine-html-reporter": "^1.7.0", "lint-staged": "^12.1.2", - "ng-packagr": "13.0.6", + "ng-packagr": "~13.0.7", "postcss": "^8.3.11", "postcss-import": "^14.0.2", "postcss-preset-env": "^7.0.1", From aaa072520dcd84dff769b92d7b2de2c6b42f4f01 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 15:12:19 +0100 Subject: [PATCH 12/18] build(example-app): remove double config --- apps/example-app/project.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/example-app/project.json b/apps/example-app/project.json index d70d3c19..14eb3bae 100644 --- a/apps/example-app/project.json +++ b/apps/example-app/project.json @@ -68,13 +68,7 @@ "lint": { "executor": "@nrwl/linter:eslint", "options": { - "lintFilePatterns": [ - "apps/example-app/**/*.ts", - "apps/example-app/**/*.html", - "apps/example-app/src/**/*.html", - "apps/example-app/src/**/*.html", - "apps/example-app/src/**/*.html" - ] + "lintFilePatterns": ["apps/example-app/**/*.ts", "apps/example-app/**/*.html", "apps/example-app/src/**/*.html"] }, "outputs": ["{options.outputFile}"] }, From b90dab201b9564bffeba0ee100ad865f73435fe0 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 15:13:00 +0100 Subject: [PATCH 13/18] build(testing-library): remove double lint settings --- projects/testing-library/project.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/testing-library/project.json b/projects/testing-library/project.json index 64c8680a..842df5fe 100644 --- a/projects/testing-library/project.json +++ b/projects/testing-library/project.json @@ -23,8 +23,6 @@ "lintFilePatterns": [ "projects/testing-library/**/*.ts", "projects/testing-library/**/*.html", - "projects/testing-library/src/**/*.html", - "projects/testing-library/src/**/*.html", "projects/testing-library/src/**/*.html" ] }, From 6f1399572d6d72aec1ecb8c2b84364134236d782 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 15:14:08 +0100 Subject: [PATCH 14/18] build(nx): do not check migration.json in git --- migrations.json | 161 ------------------------------------------------ 1 file changed, 161 deletions(-) delete mode 100644 migrations.json diff --git a/migrations.json b/migrations.json deleted file mode 100644 index d79441e5..00000000 --- a/migrations.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "migrations": [ - { - "version": "13.0.0-beta.1", - "description": "Add default base to nx.json if its not currently set", - "factory": "./src/migrations/update-13-0-0/set-default-base-if-not-set", - "cli": "nx", - "package": "@nrwl/workspace", - "name": "set-default-base-if-not-set" - }, - { - "version": "13.0.0-beta.4", - "description": "Move global settings into nx.json, and project specific settings into workspace.json", - "cli": "nx", - "implementation": "./src/migrations/update-13-0-0/config-locations/config-locations", - "package": "@nrwl/workspace", - "name": "13-0-0-config-locations" - }, - { - "version": "13.2.0", - "description": "Set --parallel=1 for existing repos to preserve the existing behavior", - "cli": "nx", - "implementation": "./src/migrations/update-13-2-0/set-parallel-default", - "package": "@nrwl/workspace", - "name": "set-parallel-default" - }, - { - "cli": "nx", - "version": "13.0.0-beta.10", - "description": "Adds postcss packages needed for Tailwind support if ng-packagr is already installed.", - "factory": "./src/migrations/update-13-0-0/add-postcss-packages", - "package": "@nrwl/angular", - "name": "add-postcss-packages" - }, - { - "cli": "nx", - "version": "13.2.0-beta.1", - "description": "Remove deprecated options from webpack-server and webpack-browser.", - "factory": "./src/migrations/update-13-2-0/update-angular-config", - "package": "@nrwl/angular", - "name": "update-angular-config" - }, - { - "cli": "nx", - "version": "13.2.0-beta.1", - "description": "Remove enableIvy and add compilationMode to library tsconfig and remove deprecated ng-packagr options.", - "factory": "./src/migrations/update-13-2-0/update-libraries", - "package": "@nrwl/angular", - "name": "update-libraries" - }, - { - "cli": "nx", - "version": "13.2.0-beta.1", - "description": "Update jest config to support jest-preset-angular", - "factory": "./src/migrations/update-13-2-0/update-angular-jest-config", - "package": "@nrwl/angular", - "name": "update-angular-jest-config" - }, - { - "cli": "nx", - "version": "13.2.0-beta.1", - "description": "Move some imports from @nrwl/angular/testing to jasmine-marbles", - "factory": "./src/migrations/update-13-2-0/update-testing-imports", - "package": "@nrwl/angular", - "name": "update-testing-imports" - }, - { - "description": "The road to v13 beta", - "version": "13-beta", - "factory": "./13_0_0-beta/index", - "package": "@ngrx/store", - "name": "ngrx-store-migration-13-beta" - }, - { - "description": "The road to v13 RC", - "version": "13-rc.1", - "factory": "./13_0_0-rc/index", - "package": "@ngrx/store", - "name": "ngrx-store-migration-13-rc" - }, - { - "version": "13.0.0", - "factory": "./update-13/schematic-options", - "description": "Remove no longer valid Angular schematic options from `angular.json`.", - "package": "@angular/cli", - "name": "schematic-options-13" - }, - { - "version": "13.0.0", - "factory": "./update-13/update-angular-config", - "description": "Remove deprecated options from 'angular.json' that are no longer present in v13.", - "package": "@angular/cli", - "name": "update-angular-config-v13" - }, - { - "version": "13.0.0", - "factory": "./update-13/update-libraries", - "description": "Update library projects to be published in partial mode and removed deprecated options from ng-packagr configuration.", - "package": "@angular/cli", - "name": "update-libraries-v13" - }, - { - "version": "13.0.0", - "factory": "./update-13/drop-ie-polyfills", - "description": "Remove polyfills required only for Internet Explorer which is no longer supported.", - "package": "@angular/cli", - "name": "drop-ie-polyfills" - }, - { - "version": "13.0.0", - "factory": "./update-13/update-gitignore", - "description": "Updating '.gitignore' to include '.angular/cache'.", - "package": "@angular/cli", - "name": "update-gitignore" - }, - { - "version": "13.0.0-beta", - "description": "Migrates `[routerLink]=\"\"` in templates to `[routerLink]=\"[]\"` because these links are likely intended to route to the current page with updated fragment/query params.", - "factory": "./migrations/router-link-empty-expression/index", - "package": "@angular/core", - "name": "migration-v13-router-link-empty-expression" - }, - { - "version": "13.0.0-beta", - "description": "In Angular version 13, the `teardown` flag in `TestBed` will be enabled by default. This migration automatically opts out existing apps from the new teardown behavior.", - "factory": "./migrations/testbed-teardown/index", - "package": "@angular/core", - "name": "migration-v13-testbed-teardown" - }, - { - "version": "13.0.0-0", - "description": "Updates Angular Material to v13", - "factory": "./ng-update/index#updateToV13", - "package": "@angular/material", - "name": "migration-v13" - }, - { - "version": "13.0.0-0", - "description": "Updates the Angular CDK to v13", - "factory": "./ng-update/index#updateToV13", - "package": "@angular/cdk", - "name": "migration-v13" - }, - { - "version": "13.1.2-beta.0", - "cli": "nx", - "description": "Support .test. file names in tsconfigs", - "factory": "./src/migrations/update-13-1-2/update-tsconfigs-for-tests", - "package": "@nrwl/jest", - "name": "update-ts-config-for-test-filenames" - }, - { - "cli": "nx", - "version": "13.0.0-beta.1", - "description": "Remove packages installed by Nx 12's `@nrwl/node:webpack5` generator.", - "factory": "./src/migrations/update-13-0-0/remove-webpack-5-packages-13-0-0", - "package": "@nrwl/node", - "name": "remove-webpack-5-packages" - } - ] -} From 7c5cbfc81566e2acafbf65b6ffe77be80c29bb45 Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 15:24:28 +0100 Subject: [PATCH 15/18] feat(testing-library): update peerDependencies to angular 13 BREAKING CHANGE: Update peerDependencies to Angular 13 --- projects/jest-utils/package.json | 2 +- projects/testing-library/package.json | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/jest-utils/package.json b/projects/jest-utils/package.json index 09dc20bf..4462dc31 100644 --- a/projects/jest-utils/package.json +++ b/projects/jest-utils/package.json @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/testing-library/angular-testing-library#readme", "peerDependencies": { - "jest": ">=23.4.0" + "jest": ">=27.0.0" }, "publishConfig": { "access": "public" diff --git a/projects/testing-library/package.json b/projects/testing-library/package.json index f1922ae6..e41389cf 100644 --- a/projects/testing-library/package.json +++ b/projects/testing-library/package.json @@ -29,11 +29,11 @@ "migrations": "./schematics/migrations/migration.json" }, "peerDependencies": { - "@angular/common": ">= 10.0.0", - "@angular/platform-browser": ">= 10.0.0", - "@angular/animations": ">= 10.0.0", - "@angular/router": ">= 10.0.0", - "@angular/core": ">= 10.0.0" + "@angular/common": ">= 13.0.0", + "@angular/platform-browser": ">= 13.0.0", + "@angular/animations": ">= 13.0.0", + "@angular/router": ">= 13.0.0", + "@angular/core": ">= 13.0.0" }, "dependencies": { "@testing-library/dom": "^8.0.0", From 562dedf93891a8f468cc09dbc3c719dcac76aa8f Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 15:39:50 +0100 Subject: [PATCH 16/18] build(nx): use @nrwl/angular:package Use @nrwl/angular:package instead of @angular-devkit/build-angular:ng-packagr --- projects/jest-utils/project.json | 13 ++++++++----- projects/jest-utils/tsconfig.lib.json | 6 +----- projects/testing-library/project.json | 13 ++++++++----- projects/testing-library/tsconfig.json | 4 +--- projects/testing-library/tsconfig.lib.json | 6 +----- projects/testing-library/tsconfig.lib.prod.json | 9 +++++++++ 6 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 projects/testing-library/tsconfig.lib.prod.json diff --git a/projects/jest-utils/project.json b/projects/jest-utils/project.json index 4127a045..8c4976f6 100644 --- a/projects/jest-utils/project.json +++ b/projects/jest-utils/project.json @@ -1,21 +1,24 @@ { + "projectType": "library", "root": "projects/jest-utils", "sourceRoot": "projects/jest-utils/src", - "projectType": "library", "prefix": "lib", "targets": { "build-package": { - "executor": "@angular-devkit/build-angular:ng-packagr", + "executor": "@nrwl/angular:package", + "outputs": ["dist/@testing-library/angular/jest-utils"], "options": { - "tsConfig": "projects/jest-utils/tsconfig.lib.json", "project": "projects/jest-utils/ng-package.json" }, "configurations": { "production": { - "project": "projects/jest-utils/ng-package.json", + "tsConfig": "projects/jest-utils/tsconfig.lib.prod.json" + }, + "development": { "tsConfig": "projects/jest-utils/tsconfig.lib.json" } - } + }, + "defaultConfiguration": "production" }, "lint": { "executor": "@nrwl/linter:eslint", diff --git a/projects/jest-utils/tsconfig.lib.json b/projects/jest-utils/tsconfig.lib.json index b3428d33..22fef254 100644 --- a/projects/jest-utils/tsconfig.lib.json +++ b/projects/jest-utils/tsconfig.lib.json @@ -3,13 +3,9 @@ "compilerOptions": { "outDir": "../../out-tsc/lib", "declaration": true, - "declarationMap": false, + "declarationMap": true, "inlineSources": true, "types": ["jest"] }, - "angularCompilerOptions": { - "skipTemplateCodegen": true, - "strictMetadataEmit": true - }, "exclude": ["src/test.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/projects/testing-library/project.json b/projects/testing-library/project.json index 842df5fe..fe6d0834 100644 --- a/projects/testing-library/project.json +++ b/projects/testing-library/project.json @@ -1,21 +1,24 @@ { + "projectType": "library", "root": "projects/testing-library", "sourceRoot": "projects/testing-library/src", - "projectType": "library", "prefix": "lib", "targets": { "build-package": { - "executor": "@angular-devkit/build-angular:ng-packagr", + "executor": "@nrwl/angular:package", + "outputs": ["dist/@testing-library/angular"], "options": { - "tsConfig": "projects/testing-library/tsconfig.lib.json", "project": "projects/testing-library/ng-package.json" }, "configurations": { "production": { - "project": "projects/testing-library/ng-package.json", + "tsConfig": "projects/testing-library/tsconfig.lib.prod.json" + }, + "development": { "tsConfig": "projects/testing-library/tsconfig.lib.json" } - } + }, + "defaultConfiguration": "production" }, "lint": { "executor": "@nrwl/linter:eslint", diff --git a/projects/testing-library/tsconfig.json b/projects/testing-library/tsconfig.json index c7e97944..24663f6f 100644 --- a/projects/testing-library/tsconfig.json +++ b/projects/testing-library/tsconfig.json @@ -13,9 +13,7 @@ "path": "./tsconfig.spec.json" } ], - "compilerOptions": { - "strict": false - }, + "compilerOptions": {}, "angularCompilerOptions": { "strictInjectionParameters": true, "strictInputAccessModifiers": true, diff --git a/projects/testing-library/tsconfig.lib.json b/projects/testing-library/tsconfig.lib.json index 8eed53ea..f7b1b9ca 100644 --- a/projects/testing-library/tsconfig.lib.json +++ b/projects/testing-library/tsconfig.lib.json @@ -3,13 +3,9 @@ "compilerOptions": { "outDir": "../../out-tsc/lib", "declaration": true, - "declarationMap": false, + "declarationMap": true, "inlineSources": true, "types": ["node", "jest"] }, - "angularCompilerOptions": { - "skipTemplateCodegen": true, - "strictMetadataEmit": true - }, "exclude": ["src/test.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/projects/testing-library/tsconfig.lib.prod.json b/projects/testing-library/tsconfig.lib.prod.json new file mode 100644 index 00000000..2a2faa88 --- /dev/null +++ b/projects/testing-library/tsconfig.lib.prod.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": { + "compilationMode": "partial" + } +} From 7a08254b95710627e812ccca7cbd54f51707ebad Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 15:49:49 +0100 Subject: [PATCH 17/18] build(apps): improve app build targets --- apps/example-app-karma/project.json | 43 ++++++++++++----------------- apps/example-app/project.json | 36 ++++++++++++------------ 2 files changed, 35 insertions(+), 44 deletions(-) diff --git a/apps/example-app-karma/project.json b/apps/example-app-karma/project.json index df522d48..94b4a463 100644 --- a/apps/example-app-karma/project.json +++ b/apps/example-app-karma/project.json @@ -7,6 +7,7 @@ "targets": { "build": { "executor": "@angular-devkit/build-angular:browser", + "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/apps/example-app-karma", "index": "apps/example-app-karma/src/index.html", @@ -15,13 +16,7 @@ "tsConfig": "apps/example-app-karma/tsconfig.app.json", "assets": ["apps/example-app-karma/src/favicon.ico", "apps/example-app-karma/src/assets"], "styles": [], - "scripts": [], - "vendorChunk": true, - "extractLicenses": false, - "buildOptimizer": false, - "sourceMap": true, - "optimization": false, - "namedChunks": true + "scripts": [] }, "configurations": { "production": { @@ -37,27 +32,30 @@ "with": "apps/example-app-karma/src/environments/environment.prod.ts" } ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "namedChunks": false, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true + "outputHashing": "all" + }, + "development": { + "buildOptimizer": false, + "optimization": false, + "vendorChunk": true, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true } }, - "outputs": ["{options.outputPath}"] + "defaultConfiguration": "production" }, "serve": { "executor": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "example-app-karma:build" - }, "configurations": { "production": { "browserTarget": "example-app-karma:build:production" + }, + "development": { + "browserTarget": "example-app-karma:build:development" } - } + }, + "defaultConfiguration": "development" }, "lint": { "executor": "@nrwl/linter:eslint", @@ -65,8 +63,6 @@ "lintFilePatterns": [ "apps/example-app-karma/**/*.ts", "apps/example-app-karma/**/*.html", - "apps/example-app-karma/src/**/*.html", - "apps/example-app-karma/src/**/*.html", "apps/example-app-karma/src/**/*.html" ] }, @@ -78,10 +74,7 @@ "main": "apps/example-app-karma/src/test.ts", "tsConfig": "apps/example-app-karma/tsconfig.spec.json", "polyfills": "apps/example-app-karma/src/polyfills.ts", - "karmaConfig": "apps/example-app-karma/karma.conf.js", - "styles": [], - "scripts": [], - "assets": [] + "karmaConfig": "apps/example-app-karma/karma.conf.js" } } }, diff --git a/apps/example-app/project.json b/apps/example-app/project.json index 14eb3bae..ebab97cb 100644 --- a/apps/example-app/project.json +++ b/apps/example-app/project.json @@ -7,6 +7,7 @@ "targets": { "build": { "executor": "@angular-devkit/build-angular:browser", + "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/apps/example-app", "index": "apps/example-app/src/index.html", @@ -15,13 +16,7 @@ "tsConfig": "apps/example-app/tsconfig.app.json", "assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"], "styles": ["apps/example-app/src/styles.css"], - "scripts": [], - "vendorChunk": true, - "extractLicenses": false, - "buildOptimizer": false, - "sourceMap": true, - "optimization": false, - "namedChunks": true + "scripts": [] }, "configurations": { "production": { @@ -37,27 +32,30 @@ "with": "apps/example-app/src/environments/environment.prod.ts" } ], - "optimization": true, - "outputHashing": "all", - "sourceMap": false, - "namedChunks": false, - "extractLicenses": true, - "vendorChunk": false, - "buildOptimizer": true + "outputHashing": "all" + }, + "development": { + "buildOptimizer": false, + "optimization": false, + "vendorChunk": true, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true } }, - "outputs": ["{options.outputPath}"] + "defaultConfiguration": "production" }, "serve": { "executor": "@angular-devkit/build-angular:dev-server", - "options": { - "browserTarget": "example-app:build" - }, "configurations": { "production": { "browserTarget": "example-app:build:production" + }, + "development": { + "browserTarget": "example-app:build:development" } - } + }, + "defaultConfiguration": "development" }, "extract-i18n": { "executor": "@angular-devkit/build-angular:extract-i18n", From d7523bd7e3362ea39a3cc8febed5c65ca43f44ea Mon Sep 17 00:00:00 2001 From: Arjen Date: Tue, 23 Nov 2021 16:06:09 +0100 Subject: [PATCH 18/18] build(karma): set test teardown to default --- apps/example-app-karma/src/test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/example-app-karma/src/test.ts b/apps/example-app-karma/src/test.ts index 30d9f9e5..0a45adb5 100644 --- a/apps/example-app-karma/src/test.ts +++ b/apps/example-app-karma/src/test.ts @@ -11,9 +11,7 @@ beforeAll(() => { declare const require: any; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { - teardown: { destroyAfterEach: false }, -}); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {}); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules.