@nx/workspace 20.4.0-beta.0 → 20.4.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/migrations.json +13 -0
- package/package.json +3 -3
- package/src/generators/convert-to-monorepo/convert-to-monorepo.js +6 -3
- package/src/generators/move/lib/normalize-schema.js +6 -4
- package/src/generators/move/lib/update-eslint-config.js +3 -1
- package/src/generators/move/lib/utils.d.ts +0 -16
- package/src/generators/move/lib/utils.js +0 -31
- package/src/generators/preset/schema.d.ts +1 -1
- package/src/generators/preset/schema.json +1 -1
- package/src/utils/ts-solution-setup.d.ts +2 -0
- package/src/utils/ts-solution-setup.js +21 -0
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
package/migrations.json
CHANGED
@@ -63,6 +63,19 @@
|
|
63
63
|
"alwaysAddToPackageJson": false
|
64
64
|
}
|
65
65
|
}
|
66
|
+
},
|
67
|
+
"20.4.0": {
|
68
|
+
"version": "20.4.0-beta.1",
|
69
|
+
"x-prompt": "Do you want to update to TypeScript v5.7?",
|
70
|
+
"requires": {
|
71
|
+
"typescript": ">=5.6.0 <5.7.0"
|
72
|
+
},
|
73
|
+
"packages": {
|
74
|
+
"typescript": {
|
75
|
+
"version": "~5.7.2",
|
76
|
+
"alwaysAddToPackageJson": false
|
77
|
+
}
|
78
|
+
}
|
66
79
|
}
|
67
80
|
}
|
68
81
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/workspace",
|
3
|
-
"version": "20.4.0-beta.
|
3
|
+
"version": "20.4.0-beta.2",
|
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": {
|
@@ -38,12 +38,12 @@
|
|
38
38
|
}
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@nx/devkit": "20.4.0-beta.
|
41
|
+
"@nx/devkit": "20.4.0-beta.2",
|
42
42
|
"chalk": "^4.1.0",
|
43
43
|
"enquirer": "~2.3.6",
|
44
44
|
"tslib": "^2.3.0",
|
45
45
|
"yargs-parser": "21.1.1",
|
46
|
-
"nx": "20.4.0-beta.
|
46
|
+
"nx": "20.4.0-beta.2"
|
47
47
|
},
|
48
48
|
"publishConfig": {
|
49
49
|
"access": "public"
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.monorepoGenerator = monorepoGenerator;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const move_1 = require("../move/move");
|
6
|
+
const ts_solution_setup_1 = require("../../utils/ts-solution-setup");
|
6
7
|
async function monorepoGenerator(tree, options) {
|
7
8
|
const projects = (0, devkit_1.getProjects)(tree);
|
8
9
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
@@ -22,7 +23,8 @@ async function monorepoGenerator(tree, options) {
|
|
22
23
|
// Currently, Nx only handles apps+libs or packages. You cannot mix and match them.
|
23
24
|
// If the standalone project is an app (React, Angular, etc), then use apps+libs.
|
24
25
|
// Otherwise, for TS standalone (lib), use packages.
|
25
|
-
const isRootProjectApp = rootProject.projectType ===
|
26
|
+
const isRootProjectApp = (0, ts_solution_setup_1.getProjectType)(tree, rootProject.root, rootProject.projectType) ===
|
27
|
+
'application';
|
26
28
|
const appsDir = isRootProjectApp ? 'apps' : 'packages';
|
27
29
|
const libsDir = isRootProjectApp ? 'libs' : 'packages';
|
28
30
|
if (rootProject) {
|
@@ -38,13 +40,14 @@ async function monorepoGenerator(tree, options) {
|
|
38
40
|
});
|
39
41
|
}
|
40
42
|
for (const project of projectsToMove) {
|
43
|
+
const projectType = (0, ts_solution_setup_1.getProjectType)(tree, project.root, project.projectType);
|
41
44
|
await (0, move_1.moveGenerator)(tree, {
|
42
45
|
projectName: project.name,
|
43
46
|
newProjectName: project.name,
|
44
|
-
destination:
|
47
|
+
destination: projectType === 'application'
|
45
48
|
? (0, devkit_1.joinPathFragments)(appsDir, project.root === '.' ? project.name : project.root)
|
46
49
|
: (0, devkit_1.joinPathFragments)(libsDir, project.root === '.' ? project.name : project.root),
|
47
|
-
updateImportPath:
|
50
|
+
updateImportPath: projectType === 'library',
|
48
51
|
});
|
49
52
|
}
|
50
53
|
}
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeSchema = normalizeSchema;
|
4
4
|
const get_import_path_1 = require("../../../utilities/get-import-path");
|
5
5
|
const utils_1 = require("./utils");
|
6
|
+
const ts_solution_setup_1 = require("../../../utils/ts-solution-setup");
|
6
7
|
async function normalizeSchema(tree, schema, projectConfiguration) {
|
7
8
|
const { destination, newProjectName, importPath } = await determineProjectNameAndRootOptions(tree, schema, projectConfiguration);
|
8
9
|
return {
|
@@ -14,11 +15,11 @@ async function normalizeSchema(tree, schema, projectConfiguration) {
|
|
14
15
|
};
|
15
16
|
}
|
16
17
|
async function determineProjectNameAndRootOptions(tree, options, projectConfiguration) {
|
17
|
-
validateName(options.newProjectName, projectConfiguration);
|
18
|
+
validateName(tree, options.newProjectName, projectConfiguration);
|
18
19
|
const projectNameAndRootOptions = getProjectNameAndRootOptions(tree, options, projectConfiguration);
|
19
20
|
return projectNameAndRootOptions;
|
20
21
|
}
|
21
|
-
function validateName(name, projectConfiguration) {
|
22
|
+
function validateName(tree, name, projectConfiguration) {
|
22
23
|
if (!name) {
|
23
24
|
return;
|
24
25
|
}
|
@@ -34,13 +35,14 @@ function validateName(name, projectConfiguration) {
|
|
34
35
|
*/
|
35
36
|
const libraryPattern = '(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$';
|
36
37
|
const appPattern = '^[a-zA-Z][^:]*$';
|
37
|
-
|
38
|
+
const projectType = (0, ts_solution_setup_1.getProjectType)(tree, projectConfiguration.root, projectConfiguration.projectType);
|
39
|
+
if (projectType === 'application') {
|
38
40
|
const validationRegex = new RegExp(appPattern);
|
39
41
|
if (!validationRegex.test(name)) {
|
40
42
|
throw new Error(`The new project name should match the pattern "${appPattern}". The provided value "${name}" does not match.`);
|
41
43
|
}
|
42
44
|
}
|
43
|
-
else if (projectConfiguration.projectType === 'library') {
|
45
|
+
else if ((0, ts_solution_setup_1.getProjectType)(tree, projectConfiguration.root, projectConfiguration.projectType) === 'library') {
|
44
46
|
const validationRegex = new RegExp(libraryPattern);
|
45
47
|
if (!validationRegex.test(name)) {
|
46
48
|
throw new Error(`The new project name should match the pattern "${libraryPattern}". The provided value "${name}" does not match.`);
|
@@ -12,9 +12,11 @@ function updateEslintConfig(tree, schema, project) {
|
|
12
12
|
if (!tree.exists('.eslintrc.json') &&
|
13
13
|
!tree.exists('eslint.config.js') &&
|
14
14
|
!tree.exists('eslint.config.cjs') &&
|
15
|
+
!tree.exists('eslint.config.mjs') &&
|
15
16
|
!tree.exists('.eslintrc.base.json') &&
|
16
17
|
!tree.exists('eslint.base.config.js') &&
|
17
|
-
!tree.exists('eslint.base.config.cjs')
|
18
|
+
!tree.exists('eslint.base.config.cjs') &&
|
19
|
+
!tree.exists('eslint.base.config.mjs')) {
|
18
20
|
return;
|
19
21
|
}
|
20
22
|
try {
|
@@ -1,19 +1,3 @@
|
|
1
|
-
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
2
|
-
import { Schema } from '../schema';
|
3
|
-
/**
|
4
|
-
* This helper function ensures that we don't move libs or apps
|
5
|
-
* outside of the folders they should be in.
|
6
|
-
*
|
7
|
-
* This will break if someone isn't using the default libs/apps
|
8
|
-
* folders. In that case, they're on their own :/
|
9
|
-
*/
|
10
|
-
export declare function getDestination(host: Tree, schema: Schema, project: ProjectConfiguration): string;
|
11
|
-
/**
|
12
|
-
* Joins path segments replacing slashes with dashes
|
13
|
-
*
|
14
|
-
* @param path
|
15
|
-
*/
|
16
|
-
export declare function getNewProjectName(path: string): string;
|
17
1
|
/**
|
18
2
|
* Normalizes slashes (removes duplicates)
|
19
3
|
*
|
@@ -1,38 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getDestination = getDestination;
|
4
|
-
exports.getNewProjectName = getNewProjectName;
|
5
3
|
exports.normalizePathSlashes = normalizePathSlashes;
|
6
4
|
const devkit_1 = require("@nx/devkit");
|
7
|
-
/**
|
8
|
-
* This helper function ensures that we don't move libs or apps
|
9
|
-
* outside of the folders they should be in.
|
10
|
-
*
|
11
|
-
* This will break if someone isn't using the default libs/apps
|
12
|
-
* folders. In that case, they're on their own :/
|
13
|
-
*/
|
14
|
-
function getDestination(host, schema, project) {
|
15
|
-
const projectType = project.projectType;
|
16
|
-
const workspaceLayout = (0, devkit_1.getWorkspaceLayout)(host);
|
17
|
-
let rootFolder = workspaceLayout.libsDir;
|
18
|
-
if (projectType === 'application') {
|
19
|
-
rootFolder = workspaceLayout.appsDir;
|
20
|
-
}
|
21
|
-
return (0, devkit_1.joinPathFragments)(rootFolder, schema.destination);
|
22
|
-
}
|
23
|
-
/**
|
24
|
-
* Joins path segments replacing slashes with dashes
|
25
|
-
*
|
26
|
-
* @param path
|
27
|
-
*/
|
28
|
-
function getNewProjectName(path) {
|
29
|
-
// strip leading '/' or './' or '../' and trailing '/' and replaces '/' with '-'
|
30
|
-
return (0, devkit_1.normalizePath)(path)
|
31
|
-
.replace(/(^\.{0,2}\/|\.{1,2}\/|\/$)/g, '')
|
32
|
-
.split('/')
|
33
|
-
.filter((x) => !!x)
|
34
|
-
.join('-');
|
35
|
-
}
|
36
5
|
/**
|
37
6
|
* Normalizes slashes (removes duplicates)
|
38
7
|
*
|
@@ -11,7 +11,7 @@ export interface Schema {
|
|
11
11
|
standaloneConfig?: boolean;
|
12
12
|
framework?: string;
|
13
13
|
packageManager?: PackageManager;
|
14
|
-
bundler?: 'vite' | 'webpack' | 'rspack' | 'esbuild';
|
14
|
+
bundler?: 'vite' | 'rsbuild' | 'webpack' | 'rspack' | 'esbuild';
|
15
15
|
docker?: boolean;
|
16
16
|
nextAppDir?: boolean;
|
17
17
|
nextSrcDir?: boolean;
|
@@ -72,7 +72,7 @@
|
|
72
72
|
"bundler": {
|
73
73
|
"description": "The bundler to use for building the application.",
|
74
74
|
"type": "string",
|
75
|
-
"enum": ["
|
75
|
+
"enum": ["vite", "rspack", "rsbuild", "esbuild", "webpack"],
|
76
76
|
"default": "vite"
|
77
77
|
},
|
78
78
|
"docker": {
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getProjectType = getProjectType;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
5
|
+
// This is copied from `@nx/js` to avoid circular dependencies.
|
6
|
+
function getProjectType(tree, projectRoot, projectType) {
|
7
|
+
if (projectType)
|
8
|
+
return projectType;
|
9
|
+
if ((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.lib.json'))
|
10
|
+
return 'library';
|
11
|
+
if ((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.app.json'))
|
12
|
+
return 'application';
|
13
|
+
// If there are no exports, assume it is an application since both buildable and non-buildable libraries have exports.
|
14
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(projectRoot, 'package.json');
|
15
|
+
const packageJson = tree.exists(packageJsonPath)
|
16
|
+
? (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))
|
17
|
+
: null;
|
18
|
+
if (!packageJson?.exports)
|
19
|
+
return 'application';
|
20
|
+
return 'library';
|
21
|
+
}
|
package/src/utils/versions.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
export declare const nxVersion: any;
|
2
|
-
export declare const typescriptVersion = "~5.
|
3
|
-
export declare const angularCliVersion = "~19.
|
2
|
+
export declare const typescriptVersion = "~5.7.2";
|
3
|
+
export declare const angularCliVersion = "~19.1.0";
|
package/src/utils/versions.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.angularCliVersion = exports.typescriptVersion = exports.nxVersion = void 0;
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
5
|
-
exports.typescriptVersion = '~5.
|
5
|
+
exports.typescriptVersion = '~5.7.2';
|
6
6
|
// TODO: remove when preset generation is reworked and
|
7
7
|
// deps are not installed from workspace
|
8
|
-
exports.angularCliVersion = '~19.
|
8
|
+
exports.angularCliVersion = '~19.1.0';
|