Skip to content

Commit

Permalink
chore: simplify some package setup (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Nov 2, 2021
1 parent 53df8f4 commit 55e99c4
Show file tree
Hide file tree
Showing 26 changed files with 304 additions and 3,483 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,16 @@ jobs:
- name: Check code formatting (not distributable)
run: NX_CLOUD_DISTRIBUTED_EXECUTION=false yarn format-check

- name: Build utils upfront to avoid cache race condition (will be addressed in Nx itself soon)
run: npx nx build utils

- name: Run parallel distributed tasks for build, typecheck, check-configs, check-rule-docs, lint and test targets
- name: Run parallel distributed tasks for build, typecheck, check-rule-docs, lint and test targets
uses: jameshenry/parallel-bash-commands@v1
with:
# Note that the typecheck target *also* typechecks tests/tools,
# Note that the typecheck target *also* typechecks tests and tools,
# whereas the build only checks src files
cmd1: yarn typecheck
cmd2: yarn build
cmd3: yarn check-configs
cmd4: yarn check-rule-docs
cmd5: yarn lint
cmd6: yarn test
cmd3: yarn check-rule-docs
cmd4: yarn lint
cmd5: yarn test

- name: Run distributed integration tests with independent local registries
run: npx nx run-many --target=integration-test --all --withRegistry
Expand Down
9 changes: 8 additions & 1 deletion jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const nxPreset = require('@nrwl/jest/preset');

module.exports = { ...nxPreset };
module.exports = {
...nxPreset,
// The jest preset will attempt to transform .js files, but we don't want that here
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.js$',
'[/\\\\]packages[/\\\\].+\\.js$',
],
};
19 changes: 0 additions & 19 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"lint",
"e2e",
"integration-test",
"check-configs",
"check-rule-docs",
"update-rule-docs",
"typecheck"
Expand All @@ -49,24 +48,6 @@
"target": "build",
"projects": "dependencies"
}
],
"test": [
{
"target": "build",
"projects": "dependencies"
}
],
"check-configs": [
{
"target": "build",
"projects": "dependencies"
}
],
"integration-test": [
{
"target": "build",
"projects": "dependencies"
}
]
},
"affected": {
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"integration-tests": "nx clean integration-tests && nx spawn-and-populate-local-registry integration-tests && nx run-many --target=integration-test --all",
"update-integration-tests": "yarn integration-tests -u",
"check-clean-workspace-after-install": "git diff --quiet --exit-code",
"clean": "lerna clean && nx run-many --target=clean --all --parallel",
"clean": "nx reset && lerna clean && nx run-many --target=clean --all --parallel",
"cz": "git-cz",
"postinstall": "tools/scripts/postinstall.sh",
"check-clean-integration-test-fixtures": "tools/scripts/check-clean-integration-test-fixtures.sh",
Expand All @@ -36,7 +36,6 @@
"check-readme-rules-list": "ts-node --transpile-only --project tsconfig.tools.json tools/scripts/check-readme-rules-list.ts",
"update-readme-rules-list": "ts-node --transpile-only --project tsconfig.tools.json tools/scripts/update-readme-rules-list.ts",
"exec-tool": "ts-node --transpile-only --project tsconfig.tools.json tools/scripts/exec-tool.ts",
"check-configs": "nx run-many --target=check-configs --all --parallel",
"update-configs": "ts-node --transpile-only --project tsconfig.tools.json tools/scripts/generate-configs.ts",
"check-rule-docs": "nx run-many --target=check-rule-docs --all --parallel",
"update-rule-docs": "nx run-many --target=update-rule-docs --all --parallel"
Expand All @@ -52,11 +51,8 @@
]
},
"devDependencies": {
"@angular-devkit/architect": "0.1201.1",
"@angular-devkit/build-angular": "12.1.1",
"@angular/cli": "12.1.1",
"@angular/compiler": "12.1.1",
"@angular/compiler-cli": "12.1.1",
"@commitlint/cli": "13.2.1",
"@commitlint/config-conventional": "13.2.0",
"@nrwl/cli": "13.1.2",
Expand Down Expand Up @@ -88,6 +84,7 @@
"rimraf": "3.0.2",
"strip-ansi": "6.0.1",
"terser": "5.9.0",
"tree-kill": "^1.2.2",
"ts-jest": "27.0.5",
"ts-node": "10.4.0",
"typescript": "4.3.5"
Expand Down
3 changes: 0 additions & 3 deletions packages/bundled-angular-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"url": "https://github.com/angular-eslint/angular-eslint.git",
"directory": "packages/bundled-angular-compiler"
},
"devDependencies": {
"@angular/compiler": "12.2.11"
},
"files": [
"dist",
"package.json",
Expand Down
14 changes: 10 additions & 4 deletions packages/eslint-plugin-template/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
'use strict';

module.exports = {
displayName: 'eslint-plugin-template',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testMatch: null,
testRegex: ['./tests/.+\\.test\\.ts$', './tests/.+/spec\\.ts$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/packages/eslint-plugin-template',
};
25 changes: 10 additions & 15 deletions packages/eslint-plugin-template/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
}
},
"test": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["packages/eslint-plugin-template/coverage"],
"dependsOn": [
{
"projects": "dependencies",
"target": "build"
}
],
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/packages/eslint-plugin-template"],
"options": {
"cwd": "packages/eslint-plugin-template",
"parallel": false,
"commands": ["npx nx build template-parser", "npx jest --coverage"]
"jestConfig": "packages/eslint-plugin-template/jest.config.js",
"passWithNoTests": false
}
},
"clean": {
Expand All @@ -40,16 +45,6 @@
"commands": ["npx tsc -p tsconfig.json --noEmit"]
}
},
"check-configs": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"cwd": "packages/eslint-plugin-template",
"parallel": false,
"commands": [
"npx jest tests/configs.test.ts --runTestsByPath --runInBand"
]
}
},
"check-rule-docs": {
"dependsOn": [
{
Expand Down
9 changes: 9 additions & 0 deletions packages/eslint-plugin-template/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/spec.ts", "**/*.d.ts"]
}
16 changes: 11 additions & 5 deletions packages/eslint-plugin/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
'use strict';

module.exports = {
displayName: 'eslint-plugin',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.[tj]sx?$': 'ts-jest',
},
testMatch: null,
testRegex: ['./tests/.+\\.test\\.ts$', './tests/.+/spec\\.ts$'],
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/packages/eslint-plugin',
};
19 changes: 4 additions & 15 deletions packages/eslint-plugin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
}
},
"test": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["packages/eslint-plugin/coverage"],
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/packages/eslint-plugin"],
"options": {
"cwd": "packages/eslint-plugin",
"parallel": false,
"commands": ["npx jest --coverage"]
"jestConfig": "packages/eslint-plugin/jest.config.js",
"passWithNoTests": false
}
},
"clean": {
Expand All @@ -40,16 +39,6 @@
"commands": ["npx tsc -p tsconfig.json --noEmit"]
}
},
"check-configs": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"cwd": "packages/eslint-plugin",
"parallel": false,
"commands": [
"npx jest tests/configs.test.ts --runTestsByPath --runInBand"
]
}
},
"check-rule-docs": {
"dependsOn": [
{
Expand Down
9 changes: 9 additions & 0 deletions packages/eslint-plugin/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/spec.ts", "**/*.d.ts"]
}
2 changes: 1 addition & 1 deletion packages/integration-tests/utils/local-registry-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export async function runNgNew(

console.log(process.cwd());

const subprocess = execa('../node_modules/.bin/ng', [
const subprocess = execa('../../../node_modules/.bin/ng', [
'new',
`--strict=true`,
`--package-manager=npm`,
Expand Down
17 changes: 12 additions & 5 deletions packages/schematics/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
'use strict';

module.exports = {
displayName: 'schematics',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.[tj]sx?$': 'ts-jest',
},
testRegex: './tests/.+\\.test\\.ts$',
collectCoverage: false,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov'],
testMatch: null,
testRegex: ['./tests/.+\\.test\\.ts$'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/packages/schematics',
};
17 changes: 11 additions & 6 deletions packages/schematics/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"npx ncp ../../node_modules/@schematics/angular/application/schema.json src/application/schema.json",
"npx ncp ../../node_modules/@schematics/angular/library/schema.json src/library/schema.json",
"npx rimraf ./dist",
"npx tsc -p tsconfig.json",
"npx tsc -p tsconfig.build.json",
"npx ncp src/collection.json dist/collection.json",
"npx ncp src/migrations.json dist/migrations.json",
"npx ncp src/ng-add/schema.json dist/ng-add/schema.json",
Expand All @@ -25,12 +25,17 @@
}
},
"test": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["packages/schematics/coverage"],
"dependsOn": [
{
"projects": "dependencies",
"target": "build"
}
],
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/packages/schematics"],
"options": {
"cwd": "packages/schematics",
"parallel": false,
"commands": ["npx jest --coverage"]
"jestConfig": "packages/schematics/jest.config.js",
"passWithNoTests": false
}
},
"clean": {
Expand Down
17 changes: 9 additions & 8 deletions packages/schematics/src/convert-tslint-to-eslint/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { join, normalize } from '@angular-devkit/core';
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { chain, noop } from '@angular-devkit/schematics';
import eslintPlugin from '@angular-eslint/eslint-plugin';
import eslintPluginTemplate from '@angular-eslint/eslint-plugin-template';
import type { Linter } from 'eslint';
import type { TSLintRuleOptions } from 'tslint-to-eslint-config';
import {
Expand Down Expand Up @@ -30,15 +28,18 @@ import {
updateObjPropAndRemoveDuplication,
} from './utils';

/* eslint-disable @typescript-eslint/no-explicit-any */
const eslintPluginConfigBaseOriginal: any = eslintPlugin.configs.base;
const eslintPluginConfigNgCliCompatOriginal: any =
// eslint-disable-next-line @typescript-eslint/no-var-requires
const eslintPlugin = require('@angular-eslint/eslint-plugin');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const eslintPluginTemplate = require('@angular-eslint/eslint-plugin-template');

const eslintPluginConfigBaseOriginal = eslintPlugin.configs.base;
const eslintPluginConfigNgCliCompatOriginal =
eslintPlugin.configs['ng-cli-compat'];
const eslintPluginConfigNgCliCompatFormattingAddOnOriginal: any =
const eslintPluginConfigNgCliCompatFormattingAddOnOriginal =
eslintPlugin.configs['ng-cli-compat--formatting-add-on'];
const eslintPluginTemplateConfigRecommendedOriginal: any =
const eslintPluginTemplateConfigRecommendedOriginal =
eslintPluginTemplate.configs.recommended;
/* eslint-enable @typescript-eslint/no-explicit-any */

export default function convert(schema: Schema): Rule {
return (tree: Tree) => {
Expand Down
8 changes: 7 additions & 1 deletion packages/schematics/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"module": "commonjs"
"module": "commonjs",
"paths": {
"@angular-eslint/eslint-plugin": ["../../eslint-plugin/dist/index.js"],
"@angular-eslint/eslint-plugin-template": [
"../../eslint-plugin-template/dist/index.js"
]
}
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion packages/schematics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.build.json",
"include": ["src"]
"include": ["src", "tests"]
}
9 changes: 9 additions & 0 deletions packages/schematics/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.test.ts", "**/*.d.ts"]
}
Loading

0 comments on commit 55e99c4

Please sign in to comment.