@nrwl/nx-plugin 15.9.2 → 16.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/executors.json +4 -4
- package/generators.d.ts +1 -5
- package/generators.js +1 -5
- package/generators.js.map +1 -1
- package/generators.json +2 -64
- package/index.js.map +1 -1
- package/package.json +7 -15
- package/testing.d.ts +1 -1
- package/testing.js +1 -1
- package/testing.js.map +1 -1
- package/README.md +0 -67
- package/migrations.json +0 -34
- package/src/executors/e2e/compat.d.ts +0 -1
- package/src/executors/e2e/compat.js +0 -7
- package/src/executors/e2e/compat.js.map +0 -1
- package/src/executors/e2e/e2e.impl.d.ts +0 -7
- package/src/executors/e2e/e2e.impl.js +0 -81
- package/src/executors/e2e/e2e.impl.js.map +0 -1
- package/src/executors/e2e/schema.d.ts +0 -6
- package/src/executors/e2e/schema.json +0 -219
- package/src/generators/e2e-project/e2e.d.ts +0 -6
- package/src/generators/e2e-project/e2e.js +0 -105
- package/src/generators/e2e-project/e2e.js.map +0 -1
- package/src/generators/e2e-project/files/tests/__pluginName__.spec.ts__tmpl__ +0 -61
- package/src/generators/e2e-project/files/tsconfig.json__tmpl__ +0 -6
- package/src/generators/e2e-project/schema.d.ts +0 -12
- package/src/generators/e2e-project/schema.json +0 -57
- package/src/generators/executor/executor.d.ts +0 -5
- package/src/generators/executor/executor.js +0 -90
- package/src/generators/executor/executor.js.map +0 -1
- package/src/generators/executor/files/executor/__fileName__/executor.spec.ts__tmpl__ +0 -11
- package/src/generators/executor/files/executor/__fileName__/executor.ts__tmpl__ +0 -11
- package/src/generators/executor/files/executor/__fileName__/schema.d.ts__tmpl__ +0 -1
- package/src/generators/executor/files/executor/__fileName__/schema.json__tmpl__ +0 -10
- package/src/generators/executor/files/hasher/__fileName__/hasher.spec.ts__tmpl__ +0 -22
- package/src/generators/executor/files/hasher/__fileName__/hasher.ts__tmpl__ +0 -12
- package/src/generators/executor/schema.d.ts +0 -7
- package/src/generators/executor/schema.json +0 -53
- package/src/generators/generator/files/generator/__fileName__/generator.spec.ts__tmpl__ +0 -20
- package/src/generators/generator/files/generator/__fileName__/generator.ts__tmpl__ +0 -69
- package/src/generators/generator/files/generator/__fileName__/schema.d.ts__tmpl__ +0 -5
- package/src/generators/generator/files/generator/__fileName__/schema.json__tmpl__ +0 -28
- package/src/generators/generator/generator.d.ts +0 -5
- package/src/generators/generator/generator.js +0 -88
- package/src/generators/generator/generator.js.map +0 -1
- package/src/generators/generator/schema.d.ts +0 -6
- package/src/generators/generator/schema.json +0 -49
- package/src/generators/lint-checks/generator.d.ts +0 -7
- package/src/generators/lint-checks/generator.js +0 -168
- package/src/generators/lint-checks/generator.js.map +0 -1
- package/src/generators/lint-checks/schema.d.ts +0 -3
- package/src/generators/lint-checks/schema.json +0 -19
- package/src/generators/migration/files/migration/__name__/__name__.ts__tmpl__ +0 -6
- package/src/generators/migration/migration.d.ts +0 -5
- package/src/generators/migration/migration.js +0 -110
- package/src/generators/migration/migration.js.map +0 -1
- package/src/generators/migration/schema.d.ts +0 -7
- package/src/generators/migration/schema.json +0 -54
- package/src/generators/plugin/files/plugin/executors.json__tmpl__ +0 -4
- package/src/generators/plugin/files/plugin/generators.json__tmpl__ +0 -6
- package/src/generators/plugin/files/plugin/package.json__tmpl__ +0 -7
- package/src/generators/plugin/files/plugin/src/index.ts__tmpl__ +0 -0
- package/src/generators/plugin/plugin.d.ts +0 -5
- package/src/generators/plugin/plugin.js +0 -106
- package/src/generators/plugin/plugin.js.map +0 -1
- package/src/generators/plugin/schema.d.ts +0 -17
- package/src/generators/plugin/schema.json +0 -99
- package/src/generators/plugin/utils/normalize-schema.d.ts +0 -14
- package/src/generators/plugin/utils/normalize-schema.js +0 -27
- package/src/generators/plugin/utils/normalize-schema.js.map +0 -1
- package/src/migrations/update-14-1-9/add-swc-deps-if-needed.d.ts +0 -2
- package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js +0 -14
- package/src/migrations/update-14-1-9/add-swc-deps-if-needed.js.map +0 -1
- package/src/migrations/update-15-0-0/specify-output-capture.d.ts +0 -2
- package/src/migrations/update-15-0-0/specify-output-capture.js +0 -57
- package/src/migrations/update-15-0-0/specify-output-capture.js.map +0 -1
- package/src/migrations/update-15-9-0/jest-29-configs.d.ts +0 -3
- package/src/migrations/update-15-9-0/jest-29-configs.js +0 -154
- package/src/migrations/update-15-9-0/jest-29-configs.js.map +0 -1
- package/src/migrations/update-15-9-0/jest-29-tests.d.ts +0 -5
- package/src/migrations/update-15-9-0/jest-29-tests.js +0 -65
- package/src/migrations/update-15-9-0/jest-29-tests.js.map +0 -1
- package/src/utils/testing-utils/async-commands.d.ts +0 -26
- package/src/utils/testing-utils/async-commands.js +0 -50
- package/src/utils/testing-utils/async-commands.js.map +0 -1
- package/src/utils/testing-utils/commands.d.ts +0 -15
- package/src/utils/testing-utils/commands.js +0 -63
- package/src/utils/testing-utils/commands.js.map +0 -1
- package/src/utils/testing-utils/index.d.ts +0 -5
- package/src/utils/testing-utils/index.js +0 -9
- package/src/utils/testing-utils/index.js.map +0 -1
- package/src/utils/testing-utils/nx-project.d.ts +0 -25
- package/src/utils/testing-utils/nx-project.js +0 -64
- package/src/utils/testing-utils/nx-project.js.map +0 -1
- package/src/utils/testing-utils/paths.d.ts +0 -14
- package/src/utils/testing-utils/paths.js +0 -28
- package/src/utils/testing-utils/paths.js.map +0 -1
- package/src/utils/testing-utils/utils.d.ts +0 -79
- package/src/utils/testing-utils/utils.js +0 -141
- package/src/utils/testing-utils/utils.js.map +0 -1
- package/src/utils/versions.d.ts +0 -3
- package/src/utils/versions.js +0 -7
- package/src/utils/versions.js.map +0 -1
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generatorSchematic = exports.generatorGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const devkit_2 = require("@nrwl/devkit");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
function normalizeOptions(host, options) {
|
|
9
|
-
const { npmScope } = (0, devkit_2.getWorkspaceLayout)(host);
|
|
10
|
-
const { fileName, className } = (0, devkit_2.names)(options.name);
|
|
11
|
-
const { root: projectRoot, sourceRoot: projectSourceRoot } = (0, devkit_2.readProjectConfiguration)(host, options.project);
|
|
12
|
-
const npmPackageName = (0, devkit_2.readJson)(host, path.join(projectRoot, 'package.json')).name;
|
|
13
|
-
let description;
|
|
14
|
-
if (options.description) {
|
|
15
|
-
description = options.description;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
description = `${options.name} generator`;
|
|
19
|
-
}
|
|
20
|
-
return Object.assign(Object.assign({}, options), { fileName,
|
|
21
|
-
className,
|
|
22
|
-
description,
|
|
23
|
-
projectRoot,
|
|
24
|
-
projectSourceRoot,
|
|
25
|
-
npmScope,
|
|
26
|
-
npmPackageName });
|
|
27
|
-
}
|
|
28
|
-
function addFiles(host, options) {
|
|
29
|
-
const indexPath = `${options.projectSourceRoot}/generators/${options.fileName}/files/src/index.ts__template__`;
|
|
30
|
-
if (!host.exists(indexPath)) {
|
|
31
|
-
host.write(indexPath, 'const variable = "<%= projectName %>";');
|
|
32
|
-
}
|
|
33
|
-
(0, devkit_2.generateFiles)(host, path.join(__dirname, './files/generator'), `${options.projectSourceRoot}/generators`, Object.assign(Object.assign({}, options), { tmpl: '' }));
|
|
34
|
-
if (options.unitTestRunner === 'none') {
|
|
35
|
-
host.delete(path.join(options.projectSourceRoot, 'generators', options.fileName, `generator.spec.ts`));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function createGeneratorsJson(host, options) {
|
|
39
|
-
(0, devkit_2.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), (json) => {
|
|
40
|
-
var _a;
|
|
41
|
-
(_a = json.generators) !== null && _a !== void 0 ? _a : (json.generators = 'generators.json');
|
|
42
|
-
return json;
|
|
43
|
-
});
|
|
44
|
-
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'generators.json'), {
|
|
45
|
-
generators: {},
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
function updateGeneratorJson(host, options) {
|
|
49
|
-
var _a;
|
|
50
|
-
const packageJson = (0, devkit_2.readJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'));
|
|
51
|
-
const packageJsonGenerators = (_a = packageJson.generators) !== null && _a !== void 0 ? _a : packageJson.schematics;
|
|
52
|
-
let generatorsPath = packageJsonGenerators
|
|
53
|
-
? (0, devkit_1.joinPathFragments)(options.projectRoot, packageJsonGenerators)
|
|
54
|
-
: null;
|
|
55
|
-
if (!generatorsPath) {
|
|
56
|
-
generatorsPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'generators.json');
|
|
57
|
-
}
|
|
58
|
-
if (!host.exists(generatorsPath)) {
|
|
59
|
-
createGeneratorsJson(host, options);
|
|
60
|
-
}
|
|
61
|
-
return (0, devkit_2.updateJson)(host, generatorsPath, (json) => {
|
|
62
|
-
var _a;
|
|
63
|
-
let generators = (_a = json.generators) !== null && _a !== void 0 ? _a : json.schematics;
|
|
64
|
-
generators = generators || {};
|
|
65
|
-
generators[options.name] = {
|
|
66
|
-
factory: `./src/generators/${options.fileName}/generator`,
|
|
67
|
-
schema: `./src/generators/${options.fileName}/schema.json`,
|
|
68
|
-
description: options.description,
|
|
69
|
-
};
|
|
70
|
-
// @todo(v17): Remove this, prop is defunct.
|
|
71
|
-
if (options.name === 'preset') {
|
|
72
|
-
generators[options.name]['x-use-standalone-layout'] = true;
|
|
73
|
-
}
|
|
74
|
-
json.generators = generators;
|
|
75
|
-
return json;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
function generatorGenerator(host, schema) {
|
|
79
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const options = normalizeOptions(host, schema);
|
|
81
|
-
addFiles(host, options);
|
|
82
|
-
updateGeneratorJson(host, options);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
exports.generatorGenerator = generatorGenerator;
|
|
86
|
-
exports.default = generatorGenerator;
|
|
87
|
-
exports.generatorSchematic = (0, devkit_2.convertNxGenerator)(generatorGenerator);
|
|
88
|
-
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/generators/generator/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAKsB;AACtB,yCAQsB;AAEtB,6BAA6B;AAY7B,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAAe;IACnD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,GACxD,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAElD,MAAM,cAAc,GAAG,IAAA,iBAAQ,EAC7B,IAAI,EACJ,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CACvC,CAAC,IAAI,CAAC;IAEP,IAAI,WAAmB,CAAC;IACxB,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;KACnC;SAAM;QACL,WAAW,GAAG,GAAG,OAAO,CAAC,IAAI,YAAY,CAAC;KAC3C;IAED,uCACK,OAAO,KACV,QAAQ;QACR,SAAS;QACT,WAAW;QACX,WAAW;QACX,iBAAiB;QACjB,QAAQ;QACR,cAAc,IACd;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,OAAyB;IACrD,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,OAAO,CAAC,CAAC;QAExB,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;CAAA;AAND,gDAMC;AAED,kBAAe,kBAAkB,CAAC;AACrB,QAAA,kBAAkB,GAAG,IAAA,2BAAkB,EAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"cli": "nx",
|
|
4
|
-
"$id": "NxPluginGenerator",
|
|
5
|
-
"title": "Create a Generator for an Nx Plugin",
|
|
6
|
-
"description": "Create a Generator for an Nx Plugin.",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"examples": [
|
|
9
|
-
{
|
|
10
|
-
"command": "nx g generator my-generator --project=my-plugin",
|
|
11
|
-
"description": "Generate `libs/my-plugin/src/generators/my-generator`"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"properties": {
|
|
15
|
-
"project": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "The name of the project.",
|
|
18
|
-
"alias": "p",
|
|
19
|
-
"$default": {
|
|
20
|
-
"$source": "projectName"
|
|
21
|
-
},
|
|
22
|
-
"x-prompt": "What is the name of the project for the generator?",
|
|
23
|
-
"x-priority": "important"
|
|
24
|
-
},
|
|
25
|
-
"name": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"description": "Generator name.",
|
|
28
|
-
"$default": {
|
|
29
|
-
"$source": "argv",
|
|
30
|
-
"index": 0
|
|
31
|
-
},
|
|
32
|
-
"x-prompt": "What name would you like to use for the generator?",
|
|
33
|
-
"x-priority": "important"
|
|
34
|
-
},
|
|
35
|
-
"description": {
|
|
36
|
-
"type": "string",
|
|
37
|
-
"description": "Generator description.",
|
|
38
|
-
"alias": "d"
|
|
39
|
-
},
|
|
40
|
-
"unitTestRunner": {
|
|
41
|
-
"type": "string",
|
|
42
|
-
"enum": ["jest", "none"],
|
|
43
|
-
"description": "Test runner to use for unit tests.",
|
|
44
|
-
"default": "jest"
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
"required": ["project", "name"],
|
|
48
|
-
"additionalProperties": false
|
|
49
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ProjectConfiguration, TargetConfiguration, Tree } from '@nrwl/devkit';
|
|
2
|
-
import { Schema as EsLintExecutorOptions } from '@nrwl/linter/src/executors/eslint/schema';
|
|
3
|
-
import { PluginLintChecksGeneratorSchema } from './schema';
|
|
4
|
-
import { PackageJson } from 'nx/src/utils/package-json';
|
|
5
|
-
export default function pluginLintCheckGenerator(host: Tree, options: PluginLintChecksGeneratorSchema): Promise<() => import("@nrwl/devkit").GeneratorCallback>;
|
|
6
|
-
export declare function addMigrationJsonChecks(host: Tree, options: PluginLintChecksGeneratorSchema, packageJson: PackageJson): void;
|
|
7
|
-
export declare function getEsLintOptions(project: ProjectConfiguration): [target: string, configuration: TargetConfiguration<EsLintExecutorOptions>];
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEsLintOptions = exports.addMigrationJsonChecks = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const versions_1 = require("../../utils/versions");
|
|
7
|
-
const logger_1 = require("nx/src/utils/logger");
|
|
8
|
-
const package_json_1 = require("nx/src/utils/package-json");
|
|
9
|
-
function pluginLintCheckGenerator(host, options) {
|
|
10
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
12
|
-
const packageJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(project.root, 'package.json'));
|
|
13
|
-
// This rule is eslint **only**
|
|
14
|
-
if (projectIsEsLintEnabled(project)) {
|
|
15
|
-
updateRootEslintConfig(host);
|
|
16
|
-
updateProjectEslintConfig(host, project, packageJson);
|
|
17
|
-
updateProjectTarget(host, options, packageJson);
|
|
18
|
-
// Project is setup for vscode
|
|
19
|
-
if (host.exists('.vscode')) {
|
|
20
|
-
setupVsCodeLintingForJsonFiles(host);
|
|
21
|
-
}
|
|
22
|
-
// Project contains migrations.json
|
|
23
|
-
const migrationsPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
|
|
24
|
-
if (migrationsPath &&
|
|
25
|
-
host.exists((0, devkit_1.joinPathFragments)(project.root, migrationsPath))) {
|
|
26
|
-
addMigrationJsonChecks(host, options, packageJson);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
devkit_1.logger.error(`${logger_1.NX_PREFIX} plugin lint checks can only be added to plugins which use eslint for linting`);
|
|
31
|
-
}
|
|
32
|
-
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'jsonc-eslint-parser': versions_1.jsoncEslintParserVersion });
|
|
33
|
-
return () => installTask;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
exports.default = pluginLintCheckGenerator;
|
|
37
|
-
function addMigrationJsonChecks(host, options, packageJson) {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
40
|
-
if (!projectIsEsLintEnabled(projectConfiguration)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration);
|
|
44
|
-
const relativeMigrationsJsonPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
|
|
45
|
-
if (!relativeMigrationsJsonPath) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const migrationsJsonPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, relativeMigrationsJsonPath);
|
|
49
|
-
if (eslintTarget &&
|
|
50
|
-
!((_b = (_a = eslintTargetConfiguration.options) === null || _a === void 0 ? void 0 : _a.lintFilePatterns) === null || _b === void 0 ? void 0 : _b.includes(migrationsJsonPath))) {
|
|
51
|
-
// Add to lintFilePatterns
|
|
52
|
-
eslintTargetConfiguration.options.lintFilePatterns.push(migrationsJsonPath);
|
|
53
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
|
|
54
|
-
// Update project level eslintrc
|
|
55
|
-
(0, devkit_1.updateJson)(host, `${projectConfiguration.root}/.eslintrc.json`, (c) => {
|
|
56
|
-
const override = c.overrides.find((o) => { var _a, _b; return (_b = Object.keys((_a = o.rules) !== null && _a !== void 0 ? _a : {})) === null || _b === void 0 ? void 0 : _b.includes('@nrwl/nx/nx-plugin-checks'); });
|
|
57
|
-
if (Array.isArray(override === null || override === void 0 ? void 0 : override.files) &&
|
|
58
|
-
!override.files.includes(relativeMigrationsJsonPath)) {
|
|
59
|
-
override.files.push(relativeMigrationsJsonPath);
|
|
60
|
-
}
|
|
61
|
-
return c;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.addMigrationJsonChecks = addMigrationJsonChecks;
|
|
66
|
-
function updateProjectTarget(host, options, packageJson) {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
69
|
-
if (!project.targets) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
for (const [target, configuration] of Object.entries(project.targets)) {
|
|
73
|
-
if (configuration.executor === '@nrwl/linter:eslint') {
|
|
74
|
-
const opts = (_a = configuration.options) !== null && _a !== void 0 ? _a : {};
|
|
75
|
-
(_b = opts.lintFilePatterns) !== null && _b !== void 0 ? _b : (opts.lintFilePatterns = []);
|
|
76
|
-
if (packageJson.generators) {
|
|
77
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.generators));
|
|
78
|
-
}
|
|
79
|
-
if (packageJson.schematics &&
|
|
80
|
-
packageJson.schematics !== packageJson.generators) {
|
|
81
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.schematics));
|
|
82
|
-
}
|
|
83
|
-
if (packageJson.executors) {
|
|
84
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.executors));
|
|
85
|
-
}
|
|
86
|
-
if (packageJson.builders &&
|
|
87
|
-
packageJson.builders !== packageJson.executors) {
|
|
88
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.builders));
|
|
89
|
-
}
|
|
90
|
-
opts.lintFilePatterns.push(`${project.root}/package.json`);
|
|
91
|
-
opts.lintFilePatterns = [...new Set(opts.lintFilePatterns)];
|
|
92
|
-
project.targets[target].options = opts;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
96
|
-
}
|
|
97
|
-
function updateProjectEslintConfig(host, options, packageJson) {
|
|
98
|
-
var _a;
|
|
99
|
-
// Update the project level lint configuration to specify
|
|
100
|
-
// the plugin schema rule for generated files
|
|
101
|
-
const eslintPath = `${options.root}/.eslintrc.json`;
|
|
102
|
-
const eslintConfig = (0, devkit_1.readJson)(host, eslintPath);
|
|
103
|
-
(_a = eslintConfig.overrides) !== null && _a !== void 0 ? _a : (eslintConfig.overrides = []);
|
|
104
|
-
if (!eslintConfig.overrides.some((x) => { var _a; return Object.keys((_a = x.rules) !== null && _a !== void 0 ? _a : {}).includes('@nrwl/nx/nx-plugin-checks'); })) {
|
|
105
|
-
eslintConfig.overrides.push({
|
|
106
|
-
files: [
|
|
107
|
-
'./package.json',
|
|
108
|
-
packageJson.generators,
|
|
109
|
-
packageJson.executors,
|
|
110
|
-
packageJson.schematics,
|
|
111
|
-
packageJson.builders,
|
|
112
|
-
].filter((f) => !!f),
|
|
113
|
-
parser: 'jsonc-eslint-parser',
|
|
114
|
-
rules: {
|
|
115
|
-
'@nrwl/nx/nx-plugin-checks': 'error',
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
(0, devkit_1.writeJson)(host, eslintPath, eslintConfig);
|
|
120
|
-
}
|
|
121
|
-
// Update the root eslint to specify a parser for json files
|
|
122
|
-
// This is required, otherwise every json file that is not overriden
|
|
123
|
-
// will display false errors in the IDE
|
|
124
|
-
function updateRootEslintConfig(host) {
|
|
125
|
-
var _a;
|
|
126
|
-
const rootESLint = (0, devkit_1.readJson)(host, '.eslintrc.json');
|
|
127
|
-
(_a = rootESLint.overrides) !== null && _a !== void 0 ? _a : (rootESLint.overrides = []);
|
|
128
|
-
if (!eslintConfigContainsJsonOverride(rootESLint)) {
|
|
129
|
-
rootESLint.overrides.push({
|
|
130
|
-
files: '*.json',
|
|
131
|
-
parser: 'jsonc-eslint-parser',
|
|
132
|
-
rules: {},
|
|
133
|
-
});
|
|
134
|
-
(0, devkit_1.writeJson)(host, '.eslintrc.json', rootESLint);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function setupVsCodeLintingForJsonFiles(host) {
|
|
138
|
-
var _a;
|
|
139
|
-
let existing = {};
|
|
140
|
-
if (host.exists('.vscode/settings.json')) {
|
|
141
|
-
existing = (0, devkit_1.readJson)(host, '.vscode/settings.json');
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
devkit_1.logger.info(`${logger_1.NX_PREFIX} We've updated the vscode settings for this repository to ensure that plugin lint checks show up inside your IDE. This created .vscode/settings.json. To read more about this file, check vscode's documentation. It is frequently not commited, so other developers may need to add similar settings if they'd like to see the lint checks in the IDE rather than only during linting.`);
|
|
145
|
-
}
|
|
146
|
-
// setup eslint validation for json files
|
|
147
|
-
const eslintValidate = (_a = existing['eslint.validate']) !== null && _a !== void 0 ? _a : [];
|
|
148
|
-
if (!eslintValidate.includes('json')) {
|
|
149
|
-
existing['eslint.validate'] = [...eslintValidate, 'json'];
|
|
150
|
-
}
|
|
151
|
-
(0, devkit_1.writeJson)(host, '.vscode/settings.json', existing);
|
|
152
|
-
}
|
|
153
|
-
function eslintConfigContainsJsonOverride(eslintConfig) {
|
|
154
|
-
return eslintConfig.overrides.some((x) => {
|
|
155
|
-
if (typeof x.files === 'string' && x.files.includes('.json')) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
return Array.isArray(x.files) && x.files.some((f) => f.includes('.json'));
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function projectIsEsLintEnabled(project) {
|
|
162
|
-
return !!getEsLintOptions(project);
|
|
163
|
-
}
|
|
164
|
-
function getEsLintOptions(project) {
|
|
165
|
-
return Object.entries(project.targets || {}).find(([, x]) => x.executor === '@nrwl/linter:eslint');
|
|
166
|
-
}
|
|
167
|
-
exports.getEsLintOptions = getEsLintOptions;
|
|
168
|
-
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/generators/lint-checks/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAYsB;AAMtB,mDAAgE;AAEhE,gDAAgD;AAChD,4DAA6E;AAE7E,SAA8B,wBAAwB,CACpD,IAAU,EACV,OAAwC;;QAExC,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACpE,MAAM,WAAW,GAAG,IAAA,iBAAQ,EAC1B,IAAI,EACJ,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAChD,CAAC;QAEF,+BAA+B;QAC/B,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE;YACnC,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC7B,yBAAyB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;YACtD,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;YAEhD,8BAA8B;YAC9B,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;g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AAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,OAA6B;IAC3D,OAAO,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,gBAAgB,CAC9B,OAA6B;IAE7B,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAC/C,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,qBAAqB,CAChD,CAAC;AACJ,CAAC;AAND,4CAMC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"cli": "nx",
|
|
4
|
-
"$id": "PluginLint",
|
|
5
|
-
"title": "",
|
|
6
|
-
"type": "object",
|
|
7
|
-
"description": "Adds linting configuration to validate common json files for nx plugins.",
|
|
8
|
-
"properties": {
|
|
9
|
-
"projectName": {
|
|
10
|
-
"type": "string",
|
|
11
|
-
"description": "Which project should be the configuration be added to?",
|
|
12
|
-
"$default": {
|
|
13
|
-
"$source": "projectName"
|
|
14
|
-
},
|
|
15
|
-
"x-priority": "important"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"required": ["projectName"]
|
|
19
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Tree } from '@nrwl/devkit';
|
|
2
|
-
import type { Schema } from './schema';
|
|
3
|
-
export declare function migrationGenerator(host: Tree, schema: Schema): Promise<void>;
|
|
4
|
-
export default migrationGenerator;
|
|
5
|
-
export declare const migrationSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrationSchematic = exports.migrationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const generator_1 = require("../lint-checks/generator");
|
|
8
|
-
const package_json_1 = require("nx/src/utils/package-json");
|
|
9
|
-
function normalizeOptions(host, options) {
|
|
10
|
-
var _a;
|
|
11
|
-
let name;
|
|
12
|
-
if (options.name) {
|
|
13
|
-
name = (0, devkit_1.names)(options.name).fileName;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
name = (0, devkit_1.names)(`update-${options.packageVersion}`).fileName;
|
|
17
|
-
}
|
|
18
|
-
const description = (_a = options.description) !== null && _a !== void 0 ? _a : name;
|
|
19
|
-
const { root: projectRoot, sourceRoot: projectSourceRoot } = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
20
|
-
const normalized = Object.assign(Object.assign({}, options), { name,
|
|
21
|
-
description,
|
|
22
|
-
projectRoot,
|
|
23
|
-
projectSourceRoot });
|
|
24
|
-
return normalized;
|
|
25
|
-
}
|
|
26
|
-
function addFiles(host, options) {
|
|
27
|
-
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files/migration'), `${options.projectSourceRoot}/migrations`, Object.assign(Object.assign({}, options), { tmpl: '' }));
|
|
28
|
-
}
|
|
29
|
-
function updateMigrationsJson(host, options) {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
const configuredMigrationPath = (0, package_json_1.readNxMigrateConfig)((0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'))).migrations;
|
|
32
|
-
const migrationsPath = (0, devkit_1.joinPathFragments)(options.projectRoot, configuredMigrationPath !== null && configuredMigrationPath !== void 0 ? configuredMigrationPath : 'migrations.json');
|
|
33
|
-
const migrations = host.exists(migrationsPath)
|
|
34
|
-
? (0, devkit_1.readJson)(host, migrationsPath)
|
|
35
|
-
: {};
|
|
36
|
-
if (migrations.schematics) {
|
|
37
|
-
migrations.generators = migrations.schematics;
|
|
38
|
-
delete migrations.schematics;
|
|
39
|
-
}
|
|
40
|
-
const generators = (_a = migrations.generators) !== null && _a !== void 0 ? _a : {};
|
|
41
|
-
generators[options.name] = {
|
|
42
|
-
version: options.packageVersion,
|
|
43
|
-
description: options.description,
|
|
44
|
-
cli: 'nx',
|
|
45
|
-
implementation: `./src/migrations/${options.name}/${options.name}`,
|
|
46
|
-
};
|
|
47
|
-
migrations.generators = generators;
|
|
48
|
-
if (options.packageJsonUpdates) {
|
|
49
|
-
const packageJsonUpdatesObj = (_b = migrations.packageJsonUpdates) !== null && _b !== void 0 ? _b : {};
|
|
50
|
-
if (!packageJsonUpdatesObj[options.packageVersion]) {
|
|
51
|
-
packageJsonUpdatesObj[options.packageVersion] = {
|
|
52
|
-
version: options.packageVersion,
|
|
53
|
-
packages: {},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
migrations.packageJsonUpdates = packageJsonUpdatesObj;
|
|
57
|
-
}
|
|
58
|
-
(0, devkit_1.writeJson)(host, migrationsPath, migrations);
|
|
59
|
-
}
|
|
60
|
-
function updatePackageJson(host, options) {
|
|
61
|
-
(0, devkit_1.updateJson)(host, path.join(options.projectRoot, 'package.json'), (json) => {
|
|
62
|
-
if (!json['nx-migrations'] || !json['nx-migrations'].migrations) {
|
|
63
|
-
if (json['nx-migrations']) {
|
|
64
|
-
json['nx-migrations'].migrations = './migrations.json';
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
json['nx-migrations'] = {
|
|
68
|
-
migrations: './migrations.json',
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return json;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function updateWorkspaceJson(host, options) {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
78
|
-
const assets = (_b = (_a = project.targets.build) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.assets;
|
|
79
|
-
if (assets &&
|
|
80
|
-
assets.filter((a) => a.glob === 'migrations.json').length === 0) {
|
|
81
|
-
project.targets.build.options.assets = [
|
|
82
|
-
...assets,
|
|
83
|
-
{
|
|
84
|
-
input: `./${options.projectRoot}`,
|
|
85
|
-
glob: 'migrations.json',
|
|
86
|
-
output: '.',
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.project, project);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function migrationGenerator(host, schema) {
|
|
93
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const options = normalizeOptions(host, schema);
|
|
95
|
-
addFiles(host, options);
|
|
96
|
-
updateMigrationsJson(host, options);
|
|
97
|
-
updateWorkspaceJson(host, options);
|
|
98
|
-
updateMigrationsJson(host, options);
|
|
99
|
-
updatePackageJson(host, options);
|
|
100
|
-
if (!host.exists('migrations.json')) {
|
|
101
|
-
const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
|
|
102
|
-
(0, generator_1.addMigrationJsonChecks)(host, { projectName: schema.project }, (0, devkit_1.readJson)(host, packageJsonPath));
|
|
103
|
-
}
|
|
104
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
exports.migrationGenerator = migrationGenerator;
|
|
108
|
-
exports.default = migrationGenerator;
|
|
109
|
-
exports.migrationSchematic = (0, devkit_1.convertNxGenerator)(migrationGenerator);
|
|
110
|
-
//# sourceMappingURL=migration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/generators/migration/migration.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AAGtB,6BAA6B;AAC7B,wDAAkE;AAElE,4DAA6E;AAM7E,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAAe;;IACnD,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C,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEjC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;YACnC,MAAM,eAAe,GAAG,IAAA,0BAAiB,EACvC,OAAO,CAAC,WAAW,EACnB,cAAc,CACf,CAAC;YACF,IAAA,kCAAsB,EACpB,IAAI,EACJ,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,EAC/B,IAAA,iBAAQ,EAAc,IAAI,EAAE,eAAe,CAAC,CAC7C,CAAC;SACH;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAtBD,gDAsBC;AAED,kBAAe,kBAAkB,CAAC;AACrB,QAAA,kBAAkB,GAAG,IAAA,2BAAkB,EAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"cli": "nx",
|
|
4
|
-
"$id": "NxPluginMigration",
|
|
5
|
-
"title": "Create a Migration for an Nx Plugin",
|
|
6
|
-
"description": "Create a Migration for an Nx Plugin.",
|
|
7
|
-
"type": "object",
|
|
8
|
-
"examples": [
|
|
9
|
-
{
|
|
10
|
-
"command": "nx g migration my-migration --project=my-plugin --version=1.0.0",
|
|
11
|
-
"description": "Generate `libs/my-plugin/src/migrations/my-migration`"
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"properties": {
|
|
15
|
-
"project": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": "The name of the project.",
|
|
18
|
-
"alias": "p",
|
|
19
|
-
"$default": {
|
|
20
|
-
"$source": "projectName"
|
|
21
|
-
},
|
|
22
|
-
"x-prompt": "What is the name of the project for the migration?",
|
|
23
|
-
"x-priority": "important"
|
|
24
|
-
},
|
|
25
|
-
"name": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"description": "Migration name.",
|
|
28
|
-
"$default": {
|
|
29
|
-
"$source": "argv",
|
|
30
|
-
"index": 0
|
|
31
|
-
},
|
|
32
|
-
"x-priority": "important"
|
|
33
|
-
},
|
|
34
|
-
"description": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"description": "Migration description."
|
|
37
|
-
},
|
|
38
|
-
"packageVersion": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"description": "Version to use for the migration.",
|
|
41
|
-
"alias": "v",
|
|
42
|
-
"x-prompt": "What version would you like to use for the migration?",
|
|
43
|
-
"x-priority": "important"
|
|
44
|
-
},
|
|
45
|
-
"packageJsonUpdates": {
|
|
46
|
-
"type": "boolean",
|
|
47
|
-
"description": "Whether or not to include `package.json` updates.",
|
|
48
|
-
"alias": "p",
|
|
49
|
-
"default": false
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"required": ["project", "packageVersion"],
|
|
53
|
-
"additionalProperties": false
|
|
54
|
-
}
|
|
File without changes
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nrwl/devkit';
|
|
2
|
-
import type { Schema } from './schema';
|
|
3
|
-
export declare function pluginGenerator(host: Tree, schema: Schema): Promise<() => void>;
|
|
4
|
-
export default pluginGenerator;
|
|
5
|
-
export declare const pluginSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|