feat(js): create @nrwl/js package and move @nrwl/workspace:tsc to it (#7604)
This commit is contained in:
parent
18f2e703dd
commit
d28f571874
@ -21,6 +21,7 @@ module.exports = {
|
|||||||
{ name: 'gatsby', description: 'anything Gatsby specific' },
|
{ name: 'gatsby', description: 'anything Gatsby specific' },
|
||||||
{ name: 'nest', description: 'anything Nest specific' },
|
{ name: 'nest', description: 'anything Nest specific' },
|
||||||
{ name: 'node', description: 'anything Node specific' },
|
{ name: 'node', description: 'anything Node specific' },
|
||||||
|
{ name: 'js', description: 'anything TS->JS specific' },
|
||||||
{ name: 'express', description: 'anything Express specific' },
|
{ name: 'express', description: 'anything Express specific' },
|
||||||
{ name: 'nx-plugin', description: 'anything Nx Plugin specific' },
|
{ name: 'nx-plugin', description: 'anything Nx Plugin specific' },
|
||||||
{ name: 'react', description: 'anything React specific' },
|
{ name: 'react', description: 'anything React specific' },
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# @nrwl/workspace:tsc
|
# @nrwl/js:tsc
|
||||||
|
|
||||||
Build a project using TypeScript.
|
Build a project using TypeScript.
|
||||||
|
|
||||||
@ -4,6 +4,7 @@
|
|||||||
"detox",
|
"detox",
|
||||||
"gatsby",
|
"gatsby",
|
||||||
"jest",
|
"jest",
|
||||||
|
"js",
|
||||||
"linter",
|
"linter",
|
||||||
"next",
|
"next",
|
||||||
"node",
|
"node",
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
"express",
|
"express",
|
||||||
"gatsby",
|
"gatsby",
|
||||||
"jest",
|
"jest",
|
||||||
|
"js",
|
||||||
"linter",
|
"linter",
|
||||||
"nest",
|
"nest",
|
||||||
"next",
|
"next",
|
||||||
|
|||||||
@ -7,5 +7,6 @@
|
|||||||
"node",
|
"node",
|
||||||
"storybook",
|
"storybook",
|
||||||
"web",
|
"web",
|
||||||
"workspace"
|
"workspace",
|
||||||
|
"js"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -352,11 +352,17 @@
|
|||||||
"name": "run-script executor",
|
"name": "run-script executor",
|
||||||
"id": "run-script",
|
"id": "run-script",
|
||||||
"file": "angular/api-workspace/executors/run-script"
|
"file": "angular/api-workspace/executors/run-script"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "js",
|
||||||
|
"id": "js",
|
||||||
|
"itemList": [
|
||||||
{
|
{
|
||||||
"name": "tsc executor",
|
"name": "tsc executor",
|
||||||
"id": "tsc",
|
"id": "tsc",
|
||||||
"file": "angular/api-workspace/executors/tsc"
|
"file": "angular/api-js/executors/tsc"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1660,11 +1666,17 @@
|
|||||||
"name": "run-script executor",
|
"name": "run-script executor",
|
||||||
"id": "run-script",
|
"id": "run-script",
|
||||||
"file": "react/api-workspace/executors/run-script"
|
"file": "react/api-workspace/executors/run-script"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "js",
|
||||||
|
"id": "js",
|
||||||
|
"itemList": [
|
||||||
{
|
{
|
||||||
"name": "tsc executor",
|
"name": "tsc executor",
|
||||||
"id": "tsc",
|
"id": "tsc",
|
||||||
"file": "react/api-workspace/executors/tsc"
|
"file": "react/api-js/executors/tsc"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -2932,11 +2944,17 @@
|
|||||||
"name": "run-script executor",
|
"name": "run-script executor",
|
||||||
"id": "run-script",
|
"id": "run-script",
|
||||||
"file": "node/api-workspace/executors/run-script"
|
"file": "node/api-workspace/executors/run-script"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "js",
|
||||||
|
"id": "js",
|
||||||
|
"itemList": [
|
||||||
{
|
{
|
||||||
"name": "tsc executor",
|
"name": "tsc executor",
|
||||||
"id": "tsc",
|
"id": "tsc",
|
||||||
"file": "node/api-workspace/executors/tsc"
|
"file": "node/api-js/executors/tsc"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# @nrwl/workspace:tsc
|
# @nrwl/js:tsc
|
||||||
|
|
||||||
Build a project using TypeScript.
|
Build a project using TypeScript.
|
||||||
|
|
||||||
@ -4,6 +4,7 @@
|
|||||||
"detox",
|
"detox",
|
||||||
"gatsby",
|
"gatsby",
|
||||||
"jest",
|
"jest",
|
||||||
|
"js",
|
||||||
"linter",
|
"linter",
|
||||||
"next",
|
"next",
|
||||||
"node",
|
"node",
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
"express",
|
"express",
|
||||||
"gatsby",
|
"gatsby",
|
||||||
"jest",
|
"jest",
|
||||||
|
"js",
|
||||||
"linter",
|
"linter",
|
||||||
"nest",
|
"nest",
|
||||||
"next",
|
"next",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# @nrwl/workspace:tsc
|
# @nrwl/js:tsc
|
||||||
|
|
||||||
Build a project using TypeScript.
|
Build a project using TypeScript.
|
||||||
|
|
||||||
@ -4,6 +4,7 @@
|
|||||||
"detox",
|
"detox",
|
||||||
"gatsby",
|
"gatsby",
|
||||||
"jest",
|
"jest",
|
||||||
|
"js",
|
||||||
"linter",
|
"linter",
|
||||||
"next",
|
"next",
|
||||||
"node",
|
"node",
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
"express",
|
"express",
|
||||||
"gatsby",
|
"gatsby",
|
||||||
"jest",
|
"jest",
|
||||||
|
"js",
|
||||||
"linter",
|
"linter",
|
||||||
"nest",
|
"nest",
|
||||||
"next",
|
"next",
|
||||||
|
|||||||
10
e2e/js/jest.config.js
Normal file
10
e2e/js/jest.config.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: '../../jest.preset.js',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
|
},
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
|
maxWorkers: 1,
|
||||||
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
|
displayName: 'e2e-js',
|
||||||
|
};
|
||||||
34
e2e/js/project.json
Normal file
34
e2e/js/project.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"root": "e2e/js",
|
||||||
|
"sourceRoot": "e2e/js",
|
||||||
|
"projectType": "application",
|
||||||
|
"targets": {
|
||||||
|
"e2e": {
|
||||||
|
"executor": "@nrwl/workspace:run-commands",
|
||||||
|
"options": {
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"command": "yarn e2e-start-local-registry"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "yarn e2e-build-package-publish"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "nx run-e2e-tests e2e-jest"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parallel": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"run-e2e-tests": {
|
||||||
|
"executor": "@nrwl/jest:jest",
|
||||||
|
"options": {
|
||||||
|
"jestConfig": "e2e/js/jest.config.js",
|
||||||
|
"passWithNoTests": true,
|
||||||
|
"runInBand": true
|
||||||
|
},
|
||||||
|
"outputs": ["coverage/e2e/js"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"implicitDependencies": ["jest"]
|
||||||
|
}
|
||||||
42
e2e/js/src/js.spec.ts
Normal file
42
e2e/js/src/js.spec.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import {
|
||||||
|
checkFilesExist,
|
||||||
|
ensureNxProject,
|
||||||
|
readJson,
|
||||||
|
runNxCommandAsync,
|
||||||
|
uniq,
|
||||||
|
} from '@nrwl/nx-plugin/testing';
|
||||||
|
describe('js e2e', () => {
|
||||||
|
it('should create js', async () => {
|
||||||
|
const plugin = uniq('js');
|
||||||
|
ensureNxProject('@nrwl/js', 'dist//js');
|
||||||
|
await runNxCommandAsync(`generate @nrwl/js:js ${plugin}`);
|
||||||
|
|
||||||
|
const result = await runNxCommandAsync(`build ${plugin}`);
|
||||||
|
expect(result.stdout).toContain('Executor ran');
|
||||||
|
}, 120000);
|
||||||
|
|
||||||
|
describe('--directory', () => {
|
||||||
|
it('should create src in the specified directory', async () => {
|
||||||
|
const plugin = uniq('js');
|
||||||
|
ensureNxProject('@nrwl/js', 'dist//js');
|
||||||
|
await runNxCommandAsync(
|
||||||
|
`generate @nrwl/js:js ${plugin} --directory subdir`
|
||||||
|
);
|
||||||
|
expect(() =>
|
||||||
|
checkFilesExist(`libs/subdir/${plugin}/src/index.ts`)
|
||||||
|
).not.toThrow();
|
||||||
|
}, 120000);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('--tags', () => {
|
||||||
|
it('should add tags to the project', async () => {
|
||||||
|
const plugin = uniq('js');
|
||||||
|
ensureNxProject('@nrwl/js', 'dist//js');
|
||||||
|
await runNxCommandAsync(
|
||||||
|
`generate @nrwl/js:js ${plugin} --tags e2etag,e2ePackage`
|
||||||
|
);
|
||||||
|
const project = readJson(`libs/${plugin}/project.json`);
|
||||||
|
expect(project.tags).toEqual(['e2etag', 'e2ePackage']);
|
||||||
|
}, 120000);
|
||||||
|
});
|
||||||
|
});
|
||||||
13
e2e/js/tsconfig.json
Normal file
13
e2e/js/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"types": ["node", "jest"]
|
||||||
|
},
|
||||||
|
"include": [],
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.spec.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
16
e2e/js/tsconfig.spec.json
Normal file
16
e2e/js/tsconfig.spec.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../../dist/out-tsc",
|
||||||
|
"module": "commonjs",
|
||||||
|
"types": ["jest", "node"]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"**/*.test.ts",
|
||||||
|
"**/*.spec.ts",
|
||||||
|
"**/*.spec.tsx",
|
||||||
|
"**/*.spec.js",
|
||||||
|
"**/*.spec.jsx",
|
||||||
|
"**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -207,6 +207,7 @@ export function newProject({ name = uniq('proj') } = {}): string {
|
|||||||
`@nrwl/express`,
|
`@nrwl/express`,
|
||||||
`@nrwl/gatsby`,
|
`@nrwl/gatsby`,
|
||||||
`@nrwl/jest`,
|
`@nrwl/jest`,
|
||||||
|
`@nrwl/js`,
|
||||||
`@nrwl/linter`,
|
`@nrwl/linter`,
|
||||||
`@nrwl/nest`,
|
`@nrwl/nest`,
|
||||||
`@nrwl/next`,
|
`@nrwl/next`,
|
||||||
|
|||||||
3
packages/js/.babelrc
Normal file
3
packages/js/.babelrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]]
|
||||||
|
}
|
||||||
18
packages/js/.eslintrc.json
Normal file
18
packages/js/.eslintrc.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"extends": ["../../.eslintrc.json"],
|
||||||
|
"ignorePatterns": ["!**/*"],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||||
|
"rules": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.tsx"],
|
||||||
|
"rules": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.js", "*.jsx"],
|
||||||
|
"rules": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
7
packages/js/README.md
Normal file
7
packages/js/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# js
|
||||||
|
|
||||||
|
This library was generated with [Nx](https://nx.dev).
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
Run `nx test js` to execute the unit tests via [Jest](https://jestjs.io).
|
||||||
17
packages/js/executors.json
Normal file
17
packages/js/executors.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/schema",
|
||||||
|
"executors": {
|
||||||
|
"tsc": {
|
||||||
|
"implementation": "./src/executors/tsc/tsc.impl",
|
||||||
|
"schema": "./src/executors/tsc/schema.json",
|
||||||
|
"description": "Build a project using TypeScript."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"builders": {
|
||||||
|
"tsc": {
|
||||||
|
"implementation": "./src/executors/tsc/compat",
|
||||||
|
"schema": "./src/executors/tsc/schema.json",
|
||||||
|
"description": "Build a project using TypeScript."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
6
packages/js/generators.json
Normal file
6
packages/js/generators.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/schema",
|
||||||
|
"name": "js",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"generators": {}
|
||||||
|
}
|
||||||
10
packages/js/jest.config.js
Normal file
10
packages/js/jest.config.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: '../../jest.preset.js',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.[tj]sx?$': 'ts-jest',
|
||||||
|
},
|
||||||
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
|
||||||
|
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.spec.json' } },
|
||||||
|
displayName: 'jest',
|
||||||
|
testEnvironment: 'node',
|
||||||
|
};
|
||||||
4
packages/js/migrations.json
Normal file
4
packages/js/migrations.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"generators": {},
|
||||||
|
"packageJsonUpdates": {}
|
||||||
|
}
|
||||||
12
packages/js/migrations.spec.ts
Normal file
12
packages/js/migrations.spec.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import path = require('path');
|
||||||
|
import json = require('./migrations.json');
|
||||||
|
|
||||||
|
describe('JS migrations', () => {
|
||||||
|
it('should have valid paths', () => {
|
||||||
|
Object.values(json.generators).forEach((m: any) => {
|
||||||
|
expect(() =>
|
||||||
|
require.resolve(path.join(__dirname, `${m.factory}.ts`))
|
||||||
|
).not.toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
11
packages/js/package.json
Normal file
11
packages/js/package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "@nrwl/js",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"main": "src/index.js",
|
||||||
|
"generators": "./generators.json",
|
||||||
|
"executors": "./executors.json",
|
||||||
|
"dependencies": {
|
||||||
|
"@nrwl/workspace": "*",
|
||||||
|
"@nrwl/devkit": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
70
packages/js/project.json
Normal file
70
packages/js/project.json
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
{
|
||||||
|
"root": "packages/js",
|
||||||
|
"sourceRoot": "packages/js/src",
|
||||||
|
"projectType": "library",
|
||||||
|
"targets": {
|
||||||
|
"lint": {
|
||||||
|
"executor": "@nrwl/linter:eslint",
|
||||||
|
"outputs": ["{options.outputFile}"],
|
||||||
|
"options": {
|
||||||
|
"lintFilePatterns": ["packages/js/**/*.ts"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"executor": "@nrwl/jest:jest",
|
||||||
|
"outputs": ["coverage/js"],
|
||||||
|
"options": {
|
||||||
|
"jestConfig": "packages/js/jest.config.js",
|
||||||
|
"passWithNoTests": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"build-base": {
|
||||||
|
"executor": "@nrwl/node:package",
|
||||||
|
"options": {
|
||||||
|
"outputPath": "build/packages/js",
|
||||||
|
"tsConfig": "packages/js/tsconfig.lib.json",
|
||||||
|
"packageJson": "packages/js/package.json",
|
||||||
|
"main": "packages/js/src/index.ts",
|
||||||
|
"updateBuildableProjectDepsInPackageJson": false,
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"input": "packages/js",
|
||||||
|
"glob": "**/files/**",
|
||||||
|
"output": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": "packages/js",
|
||||||
|
"glob": "**/files/**/.gitkeep",
|
||||||
|
"output": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": "packages/js",
|
||||||
|
"glob": "**/*.json",
|
||||||
|
"ignore": ["**/tsconfig*.json", "project.json"],
|
||||||
|
"output": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": "packages/js",
|
||||||
|
"glob": "**/*.js",
|
||||||
|
"output": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": "packages/js",
|
||||||
|
"glob": "**/*.d.ts",
|
||||||
|
"output": "/"
|
||||||
|
},
|
||||||
|
"LICENSE"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"outputs": ["{options.outputPath}"]
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"executor": "@nrwl/workspace:run-commands",
|
||||||
|
"outputs": ["build/packages/js"],
|
||||||
|
"options": {
|
||||||
|
"command": "node ./scripts/copy-readme.js js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
}
|
||||||
@ -1,19 +1,19 @@
|
|||||||
jest.mock('../../core/project-graph');
|
jest.mock('@nrwl/workspace/src/core/project-graph');
|
||||||
jest.mock('../../utilities/assets');
|
jest.mock('@nrwl/workspace/src/utilities/assets');
|
||||||
jest.mock('../../utilities/buildable-libs-utils');
|
jest.mock('@nrwl/workspace/src/utilities/buildable-libs-utils');
|
||||||
jest.mock('../../utilities/fileutils');
|
jest.mock('@nrwl/tao/src/utils/fileutils');
|
||||||
jest.mock('../../utilities/typescript/compilation');
|
jest.mock('@nrwl/workspace/src/utilities/typescript/compilation');
|
||||||
|
|
||||||
import { ExecutorContext } from '@nrwl/devkit';
|
import { ExecutorContext } from '@nrwl/devkit';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { copyAssets } from '../../utilities/assets';
|
import { copyAssets } from '@nrwl/workspace/src/utilities/assets';
|
||||||
import {
|
import {
|
||||||
calculateProjectDependencies,
|
calculateProjectDependencies,
|
||||||
checkDependentProjectsHaveBeenBuilt,
|
checkDependentProjectsHaveBeenBuilt,
|
||||||
createTmpTsConfig,
|
createTmpTsConfig,
|
||||||
} from '../../utilities/buildable-libs-utils';
|
} from '@nrwl/workspace/src/utilities/buildable-libs-utils';
|
||||||
import { readJsonFile, writeJsonFile } from '../../utilities/fileutils';
|
import { readJsonFile, writeJsonFile } from '@nrwl/tao/src/utils/fileutils';
|
||||||
import { compileTypeScript } from '../../utilities/typescript/compilation';
|
import { compileTypeScript } from '@nrwl/workspace/src/utilities/typescript/compilation';
|
||||||
import { TypeScriptExecutorOptions } from './schema';
|
import { TypeScriptExecutorOptions } from './schema';
|
||||||
import { tscExecutor } from './tsc.impl';
|
import { tscExecutor } from './tsc.impl';
|
||||||
|
|
||||||
@ -1,14 +1,19 @@
|
|||||||
import { ExecutorContext, normalizePath } from '@nrwl/devkit';
|
import {
|
||||||
import { basename, dirname, join, relative } from 'path';
|
ExecutorContext,
|
||||||
import { readCachedProjectGraph } from '../../core/project-graph';
|
normalizePath,
|
||||||
import { copyAssets } from '../../utilities/assets';
|
readJsonFile,
|
||||||
|
writeJsonFile,
|
||||||
|
} from '@nrwl/devkit';
|
||||||
|
import { readCachedProjectGraph } from '@nrwl/workspace/src/core/project-graph';
|
||||||
|
import { copyAssets } from '@nrwl/workspace/src/utilities/assets';
|
||||||
import {
|
import {
|
||||||
calculateProjectDependencies,
|
calculateProjectDependencies,
|
||||||
checkDependentProjectsHaveBeenBuilt,
|
checkDependentProjectsHaveBeenBuilt,
|
||||||
createTmpTsConfig,
|
createTmpTsConfig,
|
||||||
} from '../../utilities/buildable-libs-utils';
|
} from '@nrwl/workspace/src/utilities/buildable-libs-utils';
|
||||||
import { readJsonFile, writeJsonFile } from '../../utilities/fileutils';
|
import { compileTypeScript } from '@nrwl/workspace/src/utilities/typescript/compilation';
|
||||||
import { compileTypeScript } from '../../utilities/typescript/compilation';
|
import { basename, dirname, join, relative } from 'path';
|
||||||
|
|
||||||
import { TypeScriptExecutorOptions } from './schema';
|
import { TypeScriptExecutorOptions } from './schema';
|
||||||
|
|
||||||
export async function tscExecutor(
|
export async function tscExecutor(
|
||||||
0
packages/js/src/generators/.gitkeep
Normal file
0
packages/js/src/generators/.gitkeep
Normal file
0
packages/js/src/index.ts
Normal file
0
packages/js/src/index.ts
Normal file
13
packages/js/tsconfig.json
Normal file
13
packages/js/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"files": [],
|
||||||
|
"include": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.lib.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.spec.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
11
packages/js/tsconfig.lib.json
Normal file
11
packages/js/tsconfig.lib.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"outDir": "../../dist/out-tsc",
|
||||||
|
"declaration": true,
|
||||||
|
"types": ["node"]
|
||||||
|
},
|
||||||
|
"exclude": ["**/*.spec.ts"],
|
||||||
|
"include": ["**/*.ts"]
|
||||||
|
}
|
||||||
15
packages/js/tsconfig.spec.json
Normal file
15
packages/js/tsconfig.spec.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../dist/out-tsc",
|
||||||
|
"module": "commonjs",
|
||||||
|
"types": ["jest", "node"]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"**/*.spec.ts",
|
||||||
|
"**/*.spec.tsx",
|
||||||
|
"**/*.spec.js",
|
||||||
|
"**/*.spec.jsx",
|
||||||
|
"**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -5,11 +5,6 @@
|
|||||||
"schema": "./src/executors/run-commands/schema.json",
|
"schema": "./src/executors/run-commands/schema.json",
|
||||||
"description": "Run any custom commands with Nx"
|
"description": "Run any custom commands with Nx"
|
||||||
},
|
},
|
||||||
"tsc": {
|
|
||||||
"implementation": "./src/executors/tsc/compat",
|
|
||||||
"schema": "./src/executors/tsc/schema.json",
|
|
||||||
"description": "Build a project using TypeScript."
|
|
||||||
},
|
|
||||||
"run-script": {
|
"run-script": {
|
||||||
"implementation": "./src/executors/run-script/compat",
|
"implementation": "./src/executors/run-script/compat",
|
||||||
"schema": "./src/executors/run-script/schema.json",
|
"schema": "./src/executors/run-script/schema.json",
|
||||||
@ -22,11 +17,6 @@
|
|||||||
"schema": "./src/executors/run-commands/schema.json",
|
"schema": "./src/executors/run-commands/schema.json",
|
||||||
"description": "Run any custom commands with Nx"
|
"description": "Run any custom commands with Nx"
|
||||||
},
|
},
|
||||||
"tsc": {
|
|
||||||
"implementation": "./src/executors/tsc/tsc.impl",
|
|
||||||
"schema": "./src/executors/tsc/schema.json",
|
|
||||||
"description": "Build a project using TypeScript."
|
|
||||||
},
|
|
||||||
"counter": {
|
"counter": {
|
||||||
"implementation": "./src/executors/counter/counter.impl",
|
"implementation": "./src/executors/counter/counter.impl",
|
||||||
"batchImplementation": "./src/executors/counter/counter.impl#batchCounter",
|
"batchImplementation": "./src/executors/counter/counter.impl#batchCounter",
|
||||||
|
|||||||
@ -193,6 +193,12 @@
|
|||||||
"description": "Set --parallel=1 for existing repos to preserve the existing behavior",
|
"description": "Set --parallel=1 for existing repos to preserve the existing behavior",
|
||||||
"cli": "nx",
|
"cli": "nx",
|
||||||
"implementation": "./src/migrations/update-13-2-0/set-parallel-default"
|
"implementation": "./src/migrations/update-13-2-0/set-parallel-default"
|
||||||
|
},
|
||||||
|
"13-3-0-tsc-location": {
|
||||||
|
"version": "13.3.0-beta.0",
|
||||||
|
"description": "@nrwl/workspace:tsc is now @nrwl/js:tsc",
|
||||||
|
"cli": "nx",
|
||||||
|
"implementation": "./src/migrations/update-13-3-0/update-tsc-executor-location"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageJsonUpdates": {
|
"packageJsonUpdates": {
|
||||||
|
|||||||
@ -850,7 +850,7 @@ describe('lib', () => {
|
|||||||
expect(workspaceJson.projects['my-lib'].root).toEqual('libs/my-lib');
|
expect(workspaceJson.projects['my-lib'].root).toEqual('libs/my-lib');
|
||||||
expect(workspaceJson.projects['my-lib'].architect.build).toBeTruthy();
|
expect(workspaceJson.projects['my-lib'].architect.build).toBeTruthy();
|
||||||
expect(workspaceJson.projects['my-lib'].architect.build.builder).toBe(
|
expect(workspaceJson.projects['my-lib'].architect.build.builder).toBe(
|
||||||
'@nrwl/workspace:tsc'
|
'@nrwl/js:tsc'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -12,9 +12,11 @@ import {
|
|||||||
GeneratorCallback,
|
GeneratorCallback,
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
ProjectConfiguration,
|
ProjectConfiguration,
|
||||||
|
addDependenciesToPackageJson,
|
||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { runTasksInSerial } from '../../utilities/run-tasks-in-serial';
|
import { runTasksInSerial } from '../../utilities/run-tasks-in-serial';
|
||||||
|
import { nxVersion } from '../../utils/versions';
|
||||||
import { Schema } from './schema';
|
import { Schema } from './schema';
|
||||||
|
|
||||||
// nx-ignore-next-line
|
// nx-ignore-next-line
|
||||||
@ -42,8 +44,9 @@ function addProject(tree: Tree, options: NormalizedSchema) {
|
|||||||
|
|
||||||
if (options.buildable) {
|
if (options.buildable) {
|
||||||
const { libsDir } = getWorkspaceLayout(tree);
|
const { libsDir } = getWorkspaceLayout(tree);
|
||||||
|
addDependenciesToPackageJson(tree, {}, { '@nrwl/js': nxVersion });
|
||||||
projectConfiguration.targets.build = {
|
projectConfiguration.targets.build = {
|
||||||
executor: '@nrwl/workspace:tsc',
|
executor: '@nrwl/js:tsc',
|
||||||
outputs: ['{options.outputPath}'],
|
outputs: ['{options.outputPath}'],
|
||||||
options: {
|
options: {
|
||||||
outputPath: `dist/${libsDir}/${options.projectDirectory}`,
|
outputPath: `dist/${libsDir}/${options.projectDirectory}`,
|
||||||
|
|||||||
@ -0,0 +1,85 @@
|
|||||||
|
import {
|
||||||
|
Tree,
|
||||||
|
writeJson,
|
||||||
|
readWorkspaceConfiguration,
|
||||||
|
addProjectConfiguration,
|
||||||
|
getProjects,
|
||||||
|
readJson,
|
||||||
|
} from '@nrwl/devkit';
|
||||||
|
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||||
|
import { updateTscExecutorLocation } from './update-tsc-executor-location';
|
||||||
|
|
||||||
|
describe('add `defaultBase` in nx.json', () => {
|
||||||
|
let tree: Tree;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
tree = createTreeWithEmptyWorkspace(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update @nrwl/workspace:tsc -> @nrwl/js:tsc', async () => {
|
||||||
|
addProjectConfiguration(tree, 'tsc-project', {
|
||||||
|
root: 'projects/tsc-project',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/workspace:tsc',
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
executor: '@nrwl/jest:jest',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
addProjectConfiguration(tree, 'other-project', {
|
||||||
|
root: 'projects/other-project',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/react:build',
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
executor: '@nrwl/jest:jest',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await updateTscExecutorLocation(tree);
|
||||||
|
const projects = Object.fromEntries(getProjects(tree).entries());
|
||||||
|
expect(projects).toEqual({
|
||||||
|
'tsc-project': {
|
||||||
|
root: 'projects/tsc-project',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/js:tsc',
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
executor: '@nrwl/jest:jest',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'other-project': {
|
||||||
|
root: 'projects/other-project',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/react:build',
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
executor: '@nrwl/jest:jest',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add @nrwl/js dependency', async () => {
|
||||||
|
addProjectConfiguration(tree, 'tsc-project', {
|
||||||
|
root: 'projects/tsc-project',
|
||||||
|
targets: {
|
||||||
|
build: {
|
||||||
|
executor: '@nrwl/workspace:tsc',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await updateTscExecutorLocation(tree);
|
||||||
|
const packageJson = readJson(tree, 'package.json');
|
||||||
|
expect(packageJson.devDependencies).toMatchObject({
|
||||||
|
'@nrwl/js': expect.anything(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
import {
|
||||||
|
addDependenciesToPackageJson,
|
||||||
|
formatFiles,
|
||||||
|
GeneratorCallback,
|
||||||
|
getProjects,
|
||||||
|
installPackagesTask,
|
||||||
|
Tree,
|
||||||
|
updateProjectConfiguration,
|
||||||
|
} from '@nrwl/devkit';
|
||||||
|
import { addDepsToPackageJson } from '@nrwl/workspace';
|
||||||
|
import { nxVersion } from '../../utils/versions';
|
||||||
|
|
||||||
|
export async function updateTscExecutorLocation(
|
||||||
|
host: Tree
|
||||||
|
): Promise<GeneratorCallback> {
|
||||||
|
const projects = getProjects(host);
|
||||||
|
let used = false;
|
||||||
|
for (const [project, projectConfig] of projects.entries()) {
|
||||||
|
for (const [target, targetConfig] of Object.entries(
|
||||||
|
projectConfig.targets
|
||||||
|
)) {
|
||||||
|
if (targetConfig.executor === '@nrwl/workspace:tsc') {
|
||||||
|
projectConfig.targets[target].executor = '@nrwl/js:tsc';
|
||||||
|
updateProjectConfiguration(host, project, projectConfig);
|
||||||
|
used = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (used) {
|
||||||
|
addDependenciesToPackageJson(
|
||||||
|
host,
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
'@nrwl/js': nxVersion,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await formatFiles(host);
|
||||||
|
return () => installPackagesTask(host);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default updateTscExecutorLocation;
|
||||||
@ -35,9 +35,11 @@ function generateSchematicList(
|
|||||||
config: Configuration,
|
config: Configuration,
|
||||||
flattener: SchemaFlattener
|
flattener: SchemaFlattener
|
||||||
): Promise<FileSystemSchematicJsonDescription>[] {
|
): Promise<FileSystemSchematicJsonDescription>[] {
|
||||||
const schematicCollectionFile = path.join(config.root, 'generators.json');
|
const schematicCollectionFilePath = path.join(config.root, 'generators.json');
|
||||||
|
const schematicCollectionFile = readJsonSync(schematicCollectionFilePath);
|
||||||
removeSync(config.schematicOutput);
|
removeSync(config.schematicOutput);
|
||||||
const schematicCollection = readJsonSync(schematicCollectionFile).schematics;
|
const schematicCollection =
|
||||||
|
schematicCollectionFile.schematics || schematicCollectionFile.generators;
|
||||||
return Object.keys(schematicCollection).map((schematicName) => {
|
return Object.keys(schematicCollection).map((schematicName) => {
|
||||||
const schematic = {
|
const schematic = {
|
||||||
name: schematicName,
|
name: schematicName,
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
"@nrwl/gatsby": ["./packages/gatsby"],
|
"@nrwl/gatsby": ["./packages/gatsby"],
|
||||||
"@nrwl/jest": ["./packages/jest"],
|
"@nrwl/jest": ["./packages/jest"],
|
||||||
"@nrwl/jest/*": ["./packages/jest/*"],
|
"@nrwl/jest/*": ["./packages/jest/*"],
|
||||||
|
"@nrwl/js": ["./packages/js/src"],
|
||||||
"@nrwl/linter": ["./packages/linter"],
|
"@nrwl/linter": ["./packages/linter"],
|
||||||
"@nrwl/nest": ["./packages/nest"],
|
"@nrwl/nest": ["./packages/nest"],
|
||||||
"@nrwl/next": ["./packages/next"],
|
"@nrwl/next": ["./packages/next"],
|
||||||
|
|||||||
@ -34,6 +34,8 @@
|
|||||||
"express": "packages/express",
|
"express": "packages/express",
|
||||||
"gatsby": "packages/gatsby",
|
"gatsby": "packages/gatsby",
|
||||||
"jest": "packages/jest",
|
"jest": "packages/jest",
|
||||||
|
"js": "packages/js",
|
||||||
|
"e2e-js": "e2e/js",
|
||||||
"linter": "packages/linter",
|
"linter": "packages/linter",
|
||||||
"nest": "packages/nest",
|
"nest": "packages/nest",
|
||||||
"next": "packages/next",
|
"next": "packages/next",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user