@nx/workspace 16.8.0-beta.1 → 16.8.0-beta.3
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/generators.json +1 -1
- package/package.json +29 -29
- package/src/generators/ci-workflow/ci-workflow.js +2 -1
- package/src/generators/move/lib/move-project-files.js +1 -0
- package/src/generators/move/lib/{update-eslintrc-json.d.ts → update-eslint-config.d.ts} +1 -1
- package/src/generators/move/lib/update-eslint-config.js +30 -0
- package/src/generators/move/lib/update-project-root-files.js +2 -2
- package/src/generators/move/move.js +2 -2
- package/src/generators/npm-package/npm-package.d.ts +4 -0
- package/src/generators/npm-package/npm-package.js +25 -12
- package/src/generators/npm-package/schema.json +11 -1
- package/src/generators/move/lib/update-eslintrc-json.js +0 -45
package/generators.json
CHANGED
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"description": "Fixes projects configuration"
|
|
89
89
|
},
|
|
90
90
|
"npm-package": {
|
|
91
|
-
"factory": "./src/generators/npm-package/npm-package#
|
|
91
|
+
"factory": "./src/generators/npm-package/npm-package#npmPackageGeneratorInternal",
|
|
92
92
|
"schema": "./src/generators/npm-package/schema.json",
|
|
93
93
|
"description": "Create a minimal NPM package.",
|
|
94
94
|
"x-type": "library"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
|
|
6
6
|
"repository": {
|
|
@@ -33,39 +33,39 @@
|
|
|
33
33
|
"requirements": {},
|
|
34
34
|
"migrations": "./migrations.json",
|
|
35
35
|
"packageGroup": {
|
|
36
|
-
"@nrwl/js": "16.8.0-beta.
|
|
37
|
-
"@nrwl/jest": "16.8.0-beta.
|
|
38
|
-
"@nrwl/linter": "16.8.0-beta.
|
|
39
|
-
"@nrwl/angular": "16.8.0-beta.
|
|
40
|
-
"@nrwl/cypress": "16.8.0-beta.
|
|
41
|
-
"@nrwl/detox": "16.8.0-beta.
|
|
42
|
-
"@nrwl/devkit": "16.8.0-beta.
|
|
43
|
-
"@nrwl/esbuild": "16.8.0-beta.
|
|
44
|
-
"@nrwl/eslint-plugin-nx": "16.8.0-beta.
|
|
45
|
-
"@nrwl/expo": "16.8.0-beta.
|
|
46
|
-
"@nrwl/express": "16.8.0-beta.
|
|
47
|
-
"@nrwl/nest": "16.8.0-beta.
|
|
48
|
-
"@nrwl/next": "16.8.0-beta.
|
|
49
|
-
"@nrwl/node": "16.8.0-beta.
|
|
36
|
+
"@nrwl/js": "16.8.0-beta.3",
|
|
37
|
+
"@nrwl/jest": "16.8.0-beta.3",
|
|
38
|
+
"@nrwl/linter": "16.8.0-beta.3",
|
|
39
|
+
"@nrwl/angular": "16.8.0-beta.3",
|
|
40
|
+
"@nrwl/cypress": "16.8.0-beta.3",
|
|
41
|
+
"@nrwl/detox": "16.8.0-beta.3",
|
|
42
|
+
"@nrwl/devkit": "16.8.0-beta.3",
|
|
43
|
+
"@nrwl/esbuild": "16.8.0-beta.3",
|
|
44
|
+
"@nrwl/eslint-plugin-nx": "16.8.0-beta.3",
|
|
45
|
+
"@nrwl/expo": "16.8.0-beta.3",
|
|
46
|
+
"@nrwl/express": "16.8.0-beta.3",
|
|
47
|
+
"@nrwl/nest": "16.8.0-beta.3",
|
|
48
|
+
"@nrwl/next": "16.8.0-beta.3",
|
|
49
|
+
"@nrwl/node": "16.8.0-beta.3",
|
|
50
50
|
"nx-cloud": "latest",
|
|
51
|
-
"@nrwl/nx-plugin": "16.8.0-beta.
|
|
52
|
-
"@nrwl/react-native": "16.8.0-beta.
|
|
53
|
-
"@nrwl/react": "16.8.0-beta.
|
|
54
|
-
"@nrwl/rollup": "16.8.0-beta.
|
|
55
|
-
"@nrwl/storybook": "16.8.0-beta.
|
|
56
|
-
"@nrwl/tao": "16.8.0-beta.
|
|
57
|
-
"@nrwl/vite": "16.8.0-beta.
|
|
58
|
-
"@nrwl/web": "16.8.0-beta.
|
|
59
|
-
"@nrwl/webpack": "16.8.0-beta.
|
|
60
|
-
"nx": "16.8.0-beta.
|
|
51
|
+
"@nrwl/nx-plugin": "16.8.0-beta.3",
|
|
52
|
+
"@nrwl/react-native": "16.8.0-beta.3",
|
|
53
|
+
"@nrwl/react": "16.8.0-beta.3",
|
|
54
|
+
"@nrwl/rollup": "16.8.0-beta.3",
|
|
55
|
+
"@nrwl/storybook": "16.8.0-beta.3",
|
|
56
|
+
"@nrwl/tao": "16.8.0-beta.3",
|
|
57
|
+
"@nrwl/vite": "16.8.0-beta.3",
|
|
58
|
+
"@nrwl/web": "16.8.0-beta.3",
|
|
59
|
+
"@nrwl/webpack": "16.8.0-beta.3",
|
|
60
|
+
"nx": "16.8.0-beta.3"
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@nrwl/workspace": "16.8.0-beta.
|
|
65
|
-
"@nx/devkit": "16.8.0-beta.
|
|
64
|
+
"@nrwl/workspace": "16.8.0-beta.3",
|
|
65
|
+
"@nx/devkit": "16.8.0-beta.3",
|
|
66
66
|
"chalk": "^4.1.0",
|
|
67
67
|
"ignore": "^5.0.4",
|
|
68
|
-
"nx": "16.8.0-beta.
|
|
68
|
+
"nx": "16.8.0-beta.3",
|
|
69
69
|
"rxjs": "^7.8.0",
|
|
70
70
|
"tslib": "^2.3.0",
|
|
71
71
|
"yargs-parser": "21.1.1"
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
76
|
"type": "commonjs",
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "dcd48165a485bc8db57a1fb02b96a0772de3b7e9"
|
|
78
78
|
}
|
|
@@ -4,6 +4,7 @@ exports.ciWorkflowGenerator = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const default_base_1 = require("../../utilities/default-base");
|
|
7
|
+
const path_1 = require("path");
|
|
7
8
|
function ciWorkflowGenerator(host, schema) {
|
|
8
9
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
10
|
const ci = schema.ci;
|
|
@@ -16,7 +17,7 @@ function ciWorkflowGenerator(host, schema) {
|
|
|
16
17
|
if (ci === 'bitbucket-pipelines' && defaultBranchNeedsOriginPrefix(nxJson)) {
|
|
17
18
|
(0, devkit_1.writeJson)(host, 'nx.json', appendOriginPrefix(nxJson));
|
|
18
19
|
}
|
|
19
|
-
(0, devkit_1.generateFiles)(host, (0,
|
|
20
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files', ci), '', options);
|
|
20
21
|
yield (0, devkit_1.formatFiles)(host);
|
|
21
22
|
});
|
|
22
23
|
}
|
|
@@ -5,4 +5,4 @@ import { NormalizedSchema } from '../schema';
|
|
|
5
5
|
*
|
|
6
6
|
* @param schema The options provided to the schematic
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function updateEslintConfig(tree: Tree, schema: NormalizedSchema, project: ProjectConfiguration): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateEslintConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* Update the .eslintrc file of the project if it exists.
|
|
7
|
+
*
|
|
8
|
+
* @param schema The options provided to the schematic
|
|
9
|
+
*/
|
|
10
|
+
function updateEslintConfig(tree, schema, project) {
|
|
11
|
+
// if there is no suitable eslint config, we don't need to do anything
|
|
12
|
+
if (!tree.exists('.eslintrc.json') && !tree.exists('eslint.config.js')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const { updateRelativePathsInConfig,
|
|
17
|
+
// nx-ignore-next-line
|
|
18
|
+
} = require('@nx/linter/src/generators/utils/eslint-file');
|
|
19
|
+
updateRelativePathsInConfig(tree, project.root, schema.relativeToRootDestination);
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
devkit_1.output.warn({
|
|
23
|
+
title: `Could not update the eslint config file.`,
|
|
24
|
+
bodyLines: [
|
|
25
|
+
'The @nx/linter package could not be loaded. Please update the paths in eslint config manually.',
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.updateEslintConfig = updateEslintConfig;
|
|
@@ -40,7 +40,7 @@ function updateFilesForRootProjects(tree, schema, project) {
|
|
|
40
40
|
if (!allowedExt.includes(ext)) {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
|
-
if (file === '.eslintrc.json') {
|
|
43
|
+
if (file === '.eslintrc.json' || file === 'eslint.config.js') {
|
|
44
44
|
continue;
|
|
45
45
|
}
|
|
46
46
|
const oldContent = tree.read((0, path_1.join)(schema.relativeToRootDestination, file), 'utf-8');
|
|
@@ -73,7 +73,7 @@ function updateFilesForNonRootProjects(tree, schema, project) {
|
|
|
73
73
|
if (!allowedExt.includes(ext)) {
|
|
74
74
|
continue;
|
|
75
75
|
}
|
|
76
|
-
if (file === '.eslintrc.json') {
|
|
76
|
+
if (file === '.eslintrc.json' || file === 'eslint.config.js') {
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
79
|
const oldContent = tree.read((0, path_1.join)(schema.relativeToRootDestination, file), 'utf-8');
|
|
@@ -10,7 +10,7 @@ const normalize_schema_1 = require("./lib/normalize-schema");
|
|
|
10
10
|
const update_build_targets_1 = require("./lib/update-build-targets");
|
|
11
11
|
const update_cypress_config_1 = require("./lib/update-cypress-config");
|
|
12
12
|
const update_default_project_1 = require("./lib/update-default-project");
|
|
13
|
-
const
|
|
13
|
+
const update_eslint_config_1 = require("./lib/update-eslint-config");
|
|
14
14
|
const update_implicit_dependencies_1 = require("./lib/update-implicit-dependencies");
|
|
15
15
|
const update_imports_1 = require("./lib/update-imports");
|
|
16
16
|
const update_jest_config_1 = require("./lib/update-jest-config");
|
|
@@ -39,7 +39,7 @@ function moveGenerator(tree, rawSchema) {
|
|
|
39
39
|
(0, update_cypress_config_1.updateCypressConfig)(tree, schema, projectConfig);
|
|
40
40
|
(0, update_jest_config_1.updateJestConfig)(tree, schema, projectConfig);
|
|
41
41
|
(0, update_storybook_config_1.updateStorybookConfig)(tree, schema, projectConfig);
|
|
42
|
-
(0,
|
|
42
|
+
(0, update_eslint_config_1.updateEslintConfig)(tree, schema, projectConfig);
|
|
43
43
|
(0, update_readme_1.updateReadme)(tree, schema);
|
|
44
44
|
(0, update_package_json_1.updatePackageJson)(tree, schema);
|
|
45
45
|
(0, update_build_targets_1.updateBuildTargets)(tree, schema);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { type ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
3
|
export interface ProjectOptions {
|
|
3
4
|
name: string;
|
|
5
|
+
directory?: string;
|
|
6
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
4
7
|
}
|
|
5
8
|
export declare function npmPackageGenerator(tree: Tree, options: ProjectOptions): Promise<void>;
|
|
9
|
+
export declare function npmPackageGeneratorInternal(tree: Tree, _options: ProjectOptions): Promise<void>;
|
|
6
10
|
export declare const npmPackageSchematic: (generatorOptions: ProjectOptions) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.npmPackageSchematic = exports.npmPackageGenerator = void 0;
|
|
3
|
+
exports.npmPackageSchematic = exports.npmPackageGeneratorInternal = exports.npmPackageGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
7
|
const path_1 = require("path");
|
|
7
8
|
const get_import_path_1 = require("../../utilities/get-import-path");
|
|
8
|
-
function normalizeOptions(options) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function normalizeOptions(tree, options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const { projectName, projectRoot } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
12
|
+
name: options.name,
|
|
13
|
+
projectType: 'library',
|
|
14
|
+
directory: options.directory,
|
|
15
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
16
|
+
callingGenerator: '@nx/workspace:npm-package',
|
|
17
|
+
});
|
|
18
|
+
return Object.assign(Object.assign({}, options), { name: projectName, projectRoot });
|
|
19
|
+
});
|
|
11
20
|
}
|
|
12
21
|
function addFiles(projectRoot, tree, options) {
|
|
13
22
|
const packageJsonPath = (0, path_1.join)(projectRoot, 'package.json');
|
|
@@ -22,20 +31,24 @@ function addFiles(projectRoot, tree, options) {
|
|
|
22
31
|
}
|
|
23
32
|
function npmPackageGenerator(tree, options) {
|
|
24
33
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
return yield npmPackageGeneratorInternal(tree, Object.assign({ projectNameAndRootFormat: 'derived' }, options));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.npmPackageGenerator = npmPackageGenerator;
|
|
38
|
+
function npmPackageGeneratorInternal(tree, _options) {
|
|
39
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const options = yield normalizeOptions(tree, _options);
|
|
28
41
|
(0, devkit_1.addProjectConfiguration)(tree, options.name, {
|
|
29
|
-
root: projectRoot,
|
|
42
|
+
root: options.projectRoot,
|
|
30
43
|
});
|
|
31
|
-
const fileCount = tree.children(projectRoot).length;
|
|
32
|
-
const projectJsonExists = tree.exists((0, path_1.join)(projectRoot, 'project.json'));
|
|
44
|
+
const fileCount = tree.children(options.projectRoot).length;
|
|
45
|
+
const projectJsonExists = tree.exists((0, path_1.join)(options.projectRoot, 'project.json'));
|
|
33
46
|
const isEmpty = fileCount === 0 || (fileCount === 1 && projectJsonExists);
|
|
34
47
|
if (isEmpty) {
|
|
35
|
-
addFiles(projectRoot, tree, options);
|
|
48
|
+
addFiles(options.projectRoot, tree, options);
|
|
36
49
|
}
|
|
37
50
|
yield (0, devkit_1.formatFiles)(tree);
|
|
38
51
|
});
|
|
39
52
|
}
|
|
40
|
-
exports.
|
|
53
|
+
exports.npmPackageGeneratorInternal = npmPackageGeneratorInternal;
|
|
41
54
|
exports.npmPackageSchematic = (0, devkit_1.convertNxGenerator)(npmPackageGenerator);
|
|
@@ -14,7 +14,17 @@
|
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
16
|
"x-prompt": "What name of your npm package?",
|
|
17
|
-
"pattern": "
|
|
17
|
+
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
|
|
18
|
+
},
|
|
19
|
+
"directory": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "A directory where the package is placed.",
|
|
22
|
+
"alias": "dir"
|
|
23
|
+
},
|
|
24
|
+
"projectNameAndRootFormat": {
|
|
25
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["as-provided", "derived"]
|
|
18
28
|
}
|
|
19
29
|
},
|
|
20
30
|
"required": ["name"]
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateEslintrcJson = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
function offsetFilePath(project, pathToFile, offset) {
|
|
7
|
-
if (!pathToFile.startsWith('..')) {
|
|
8
|
-
// not a relative path
|
|
9
|
-
return pathToFile;
|
|
10
|
-
}
|
|
11
|
-
const pathFromRoot = (0, path_1.join)(project.root, pathToFile);
|
|
12
|
-
return (0, devkit_1.joinPathFragments)(offset, pathFromRoot);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Update the .eslintrc file of the project if it exists.
|
|
16
|
-
*
|
|
17
|
-
* @param schema The options provided to the schematic
|
|
18
|
-
*/
|
|
19
|
-
function updateEslintrcJson(tree, schema, project) {
|
|
20
|
-
const eslintRcPath = (0, path_1.join)(schema.relativeToRootDestination, '.eslintrc.json');
|
|
21
|
-
if (!tree.exists(eslintRcPath)) {
|
|
22
|
-
// no .eslintrc found. nothing to do
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const offset = (0, devkit_1.offsetFromRoot)(schema.relativeToRootDestination);
|
|
26
|
-
(0, devkit_1.updateJson)(tree, eslintRcPath, (eslintRcJson) => {
|
|
27
|
-
var _a;
|
|
28
|
-
if (typeof eslintRcJson.extends === 'string') {
|
|
29
|
-
eslintRcJson.extends = offsetFilePath(project, eslintRcJson.extends, offset);
|
|
30
|
-
}
|
|
31
|
-
else if (eslintRcJson.extends) {
|
|
32
|
-
eslintRcJson.extends = eslintRcJson.extends.map((extend) => offsetFilePath(project, extend, offset));
|
|
33
|
-
}
|
|
34
|
-
(_a = eslintRcJson.overrides) === null || _a === void 0 ? void 0 : _a.forEach((o) => {
|
|
35
|
-
var _a;
|
|
36
|
-
if ((_a = o.parserOptions) === null || _a === void 0 ? void 0 : _a.project) {
|
|
37
|
-
o.parserOptions.project = Array.isArray(o.parserOptions.project)
|
|
38
|
-
? o.parserOptions.project.map((p) => p.replace(project.root, schema.relativeToRootDestination))
|
|
39
|
-
: o.parserOptions.project.replace(project.root, schema.relativeToRootDestination);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return eslintRcJson;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.updateEslintrcJson = updateEslintrcJson;
|