@nx/workspace 0.0.0-pr-29993-91cbae3 → 0.0.0-pr-3-6728683
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/package.json +3 -5
- package/src/generators/ci-workflow/ci-workflow.js +0 -3
- package/src/generators/ci-workflow/files/azure/azure-pipelines.yml__tmpl__ +1 -1
- package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__ +2 -2
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml__tmpl__ +1 -1
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__ +1 -1
- package/src/generators/ci-workflow/files/gitlab/.gitlab-ci.yml__tmpl__ +1 -1
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js +2 -8
- package/src/generators/move/lib/normalize-schema.js +38 -32
- package/src/generators/move/move.d.ts +2 -2
- package/src/generators/move/move.js +1 -19
- package/src/generators/move/schema.d.ts +0 -1
- package/src/generators/npm-package/npm-package.js +4 -4
- package/src/generators/preset/preset.js +0 -10
- package/src/utilities/typescript/ts-solution-setup.d.ts +0 -1
- package/src/utilities/typescript/ts-solution-setup.js +0 -48
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/utilities/package-manager-workspaces.d.ts +0 -5
- package/src/utilities/package-manager-workspaces.js +0 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-3-6728683",
|
|
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,14 +38,12 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@nx/devkit": "0.0.0-pr-
|
|
42
|
-
"@zkochan/js-yaml": "0.0.7",
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-3-6728683",
|
|
43
42
|
"chalk": "^4.1.0",
|
|
44
43
|
"enquirer": "~2.3.6",
|
|
45
|
-
"picomatch": "4.0.2",
|
|
46
44
|
"tslib": "^2.3.0",
|
|
47
45
|
"yargs-parser": "21.1.1",
|
|
48
|
-
"nx": "0.0.0-pr-
|
|
46
|
+
"nx": "0.0.0-pr-3-6728683"
|
|
49
47
|
},
|
|
50
48
|
"publishConfig": {
|
|
51
49
|
"access": "public"
|
|
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const default_base_1 = require("../../utilities/default-base");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const nx_cloud_utils_1 = require("nx/src/utils/nx-cloud-utils");
|
|
8
|
-
const ts_solution_setup_1 = require("../../utilities/typescript/ts-solution-setup");
|
|
9
8
|
async function ciWorkflowGenerator(tree, schema) {
|
|
10
9
|
const ci = schema.ci;
|
|
11
10
|
const options = normalizeOptions(schema, tree);
|
|
@@ -36,7 +35,6 @@ function normalizeOptions(options, tree) {
|
|
|
36
35
|
const hasCypress = allDependencies['@nx/cypress'];
|
|
37
36
|
const hasPlaywright = allDependencies['@nx/playwright'];
|
|
38
37
|
const hasE2E = hasCypress || hasPlaywright;
|
|
39
|
-
const hasTypecheck = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
40
38
|
const connectedToCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, devkit_1.readJson)(tree, 'nx.json'));
|
|
41
39
|
return {
|
|
42
40
|
workflowName,
|
|
@@ -49,7 +47,6 @@ function normalizeOptions(options, tree) {
|
|
|
49
47
|
hasCypress,
|
|
50
48
|
hasE2E,
|
|
51
49
|
hasPlaywright,
|
|
52
|
-
hasTypecheck,
|
|
53
50
|
nxCloudHost,
|
|
54
51
|
tmpl: '',
|
|
55
52
|
connectedToCloud,
|
|
@@ -68,4 +68,4 @@ jobs:
|
|
|
68
68
|
# - script: <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
|
69
69
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
|
70
70
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
|
71
|
-
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) lint test build<% if(
|
|
71
|
+
- script: <%= packageManagerPrefix %> nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) lint test build<% if(hasE2E){ %> e2e<% } %>
|
package/src/generators/ci-workflow/files/bitbucket-pipelines/bitbucket-pipelines.yml__tmpl__
CHANGED
|
@@ -33,7 +33,7 @@ pipelines:
|
|
|
33
33
|
# <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
|
34
34
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
|
35
35
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
|
36
|
-
- <%= packageManagerPrefix %> nx affected --base=origin/<%= mainBranch %> -t lint test build<% if(
|
|
36
|
+
- <%= packageManagerPrefix %> nx affected --base=origin/<%= mainBranch %> -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
|
37
37
|
|
|
38
38
|
branches:
|
|
39
39
|
main:
|
|
@@ -59,4 +59,4 @@ pipelines:
|
|
|
59
59
|
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
|
|
60
60
|
# - <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
|
61
61
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
|
|
62
|
-
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(
|
|
62
|
+
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e-ci<% } %> --base=HEAD~1
|
|
@@ -37,7 +37,7 @@ jobs:
|
|
|
37
37
|
# - run: <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
|
38
38
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
|
39
39
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
|
40
|
-
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(
|
|
40
|
+
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
|
41
41
|
|
|
42
42
|
workflows:
|
|
43
43
|
version: 2
|
package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml__tmpl__
CHANGED
|
@@ -50,4 +50,4 @@ jobs:
|
|
|
50
50
|
# - run: <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
|
51
51
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
|
52
52
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
|
53
|
-
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(
|
|
53
|
+
- run: <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
|
@@ -31,4 +31,4 @@ variables:
|
|
|
31
31
|
# - <%= packageManagerPrefix %> nx-cloud record -- echo Hello World
|
|
32
32
|
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected<% if(hasE2E){ %>
|
|
33
33
|
# When you enable task distribution, run the e2e-ci task instead of e2e<% } %>
|
|
34
|
-
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(
|
|
34
|
+
- <%= packageManagerPrefix %> nx affected -t lint test build<% if(hasE2E){ %> e2e<% } %>
|
|
@@ -48,12 +48,6 @@ function createProjectConfigurationInNewDestination(tree, schema, projectConfig)
|
|
|
48
48
|
if (isRootProject && projectConfig.sourceRoot) {
|
|
49
49
|
newProject.sourceRoot = (0, devkit_1.joinPathFragments)(schema.relativeToRootDestination, projectConfig.sourceRoot);
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(0, devkit_1.updateProjectConfiguration)(tree, schema.newProjectName, newProject);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// Create a new project with the root replaced
|
|
57
|
-
(0, devkit_1.addProjectConfiguration)(tree, schema.newProjectName, newProject);
|
|
58
|
-
}
|
|
51
|
+
// Create a new project with the root replaced
|
|
52
|
+
(0, devkit_1.addProjectConfiguration)(tree, schema.newProjectName, newProject);
|
|
59
53
|
}
|
|
@@ -1,53 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeSchema = normalizeSchema;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const get_import_path_1 = require("../../../utilities/get-import-path");
|
|
6
5
|
const utils_1 = require("./utils");
|
|
7
6
|
const ts_solution_setup_1 = require("../../../utils/ts-solution-setup");
|
|
8
7
|
async function normalizeSchema(tree, schema, projectConfiguration) {
|
|
9
8
|
const { destination, newProjectName, importPath } = await determineProjectNameAndRootOptions(tree, schema, projectConfiguration);
|
|
10
|
-
const isNxConfiguredInPackageJson = !tree.exists((0, devkit_1.joinPathFragments)(projectConfiguration.root, 'project.json'));
|
|
11
9
|
return {
|
|
12
10
|
...schema,
|
|
13
11
|
destination: (0, utils_1.normalizePathSlashes)(schema.destination),
|
|
14
12
|
importPath,
|
|
15
13
|
newProjectName,
|
|
16
14
|
relativeToRootDestination: destination,
|
|
17
|
-
isNxConfiguredInPackageJson,
|
|
18
15
|
};
|
|
19
16
|
}
|
|
20
17
|
async function determineProjectNameAndRootOptions(tree, options, projectConfiguration) {
|
|
21
18
|
validateName(tree, options.newProjectName, projectConfiguration);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
options.newProjectName.includes('/') &&
|
|
25
|
-
!options.newProjectName.startsWith('@')) {
|
|
26
|
-
throw new Error(`You can't specify a new project name with a directory path (${options.newProjectName}). ` +
|
|
27
|
-
`Please provide a valid name without path segments and the full destination with the "--destination" option.`);
|
|
28
|
-
}
|
|
29
|
-
const newProjectName = options.newProjectName ?? options.projectName;
|
|
30
|
-
if (projectConfiguration.projectType !== 'library') {
|
|
31
|
-
return { destination, newProjectName };
|
|
32
|
-
}
|
|
33
|
-
let importPath = options.importPath;
|
|
34
|
-
if (importPath) {
|
|
35
|
-
return { destination, newProjectName, importPath };
|
|
36
|
-
}
|
|
37
|
-
if (options.newProjectName?.startsWith('@')) {
|
|
38
|
-
// keep the existing import path if the name didn't change
|
|
39
|
-
importPath =
|
|
40
|
-
options.newProjectName && options.projectName !== options.newProjectName
|
|
41
|
-
? newProjectName
|
|
42
|
-
: undefined;
|
|
43
|
-
}
|
|
44
|
-
else if (options.newProjectName) {
|
|
45
|
-
const npmScope = (0, get_import_path_1.getNpmScope)(tree);
|
|
46
|
-
importPath = npmScope
|
|
47
|
-
? `${npmScope === '@' ? '' : '@'}${npmScope}/${newProjectName}`
|
|
48
|
-
: newProjectName;
|
|
49
|
-
}
|
|
50
|
-
return { destination, newProjectName, importPath };
|
|
19
|
+
const projectNameAndRootOptions = getProjectNameAndRootOptions(tree, options, projectConfiguration);
|
|
20
|
+
return projectNameAndRootOptions;
|
|
51
21
|
}
|
|
52
22
|
function validateName(tree, name, projectConfiguration) {
|
|
53
23
|
if (!name) {
|
|
@@ -79,3 +49,39 @@ function validateName(tree, name, projectConfiguration) {
|
|
|
79
49
|
}
|
|
80
50
|
}
|
|
81
51
|
}
|
|
52
|
+
function getProjectNameAndRootOptions(tree, options, projectConfiguration) {
|
|
53
|
+
let destination = (0, utils_1.normalizePathSlashes)(options.destination);
|
|
54
|
+
if (options.newProjectName &&
|
|
55
|
+
options.newProjectName.includes('/') &&
|
|
56
|
+
!options.newProjectName.startsWith('@')) {
|
|
57
|
+
throw new Error(`You can't specify a new project name with a directory path (${options.newProjectName}). ` +
|
|
58
|
+
`Please provide a valid name without path segments and the full destination with the "--destination" option.`);
|
|
59
|
+
}
|
|
60
|
+
const asProvidedOptions = getAsProvidedOptions(tree, { ...options, destination }, projectConfiguration);
|
|
61
|
+
return asProvidedOptions;
|
|
62
|
+
}
|
|
63
|
+
function getAsProvidedOptions(tree, options, projectConfiguration) {
|
|
64
|
+
const newProjectName = options.newProjectName ?? options.projectName;
|
|
65
|
+
const destination = options.destination;
|
|
66
|
+
if (projectConfiguration.projectType !== 'library') {
|
|
67
|
+
return { destination, newProjectName };
|
|
68
|
+
}
|
|
69
|
+
let importPath = options.importPath;
|
|
70
|
+
if (importPath) {
|
|
71
|
+
return { destination, newProjectName, importPath };
|
|
72
|
+
}
|
|
73
|
+
if (options.newProjectName?.startsWith('@')) {
|
|
74
|
+
// keep the existing import path if the name didn't change
|
|
75
|
+
importPath =
|
|
76
|
+
options.newProjectName && options.projectName !== options.newProjectName
|
|
77
|
+
? newProjectName
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
80
|
+
else if (options.newProjectName) {
|
|
81
|
+
const npmScope = (0, get_import_path_1.getNpmScope)(tree);
|
|
82
|
+
importPath = npmScope
|
|
83
|
+
? `${npmScope === '@' ? '' : '@'}${npmScope}/${newProjectName}`
|
|
84
|
+
: newProjectName;
|
|
85
|
+
}
|
|
86
|
+
return { destination, newProjectName, importPath };
|
|
87
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
|
-
export declare function moveGenerator(tree: Tree, rawSchema: Schema): Promise<
|
|
3
|
+
export declare function moveGenerator(tree: Tree, rawSchema: Schema): Promise<void>;
|
|
4
4
|
export default moveGenerator;
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.moveGenerator = moveGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const package_manager_workspaces_1 = require("../../utilities/package-manager-workspaces");
|
|
6
|
-
const ts_solution_setup_1 = require("../../utilities/typescript/ts-solution-setup");
|
|
7
5
|
const check_destination_1 = require("./lib/check-destination");
|
|
8
6
|
const create_project_configuration_in_new_destination_1 = require("./lib/create-project-configuration-in-new-destination");
|
|
9
|
-
const extract_base_configs_1 = require("./lib/extract-base-configs");
|
|
10
7
|
const move_project_files_1 = require("./lib/move-project-files");
|
|
11
8
|
const normalize_schema_1 = require("./lib/normalize-schema");
|
|
12
9
|
const run_angular_plugin_1 = require("./lib/run-angular-plugin");
|
|
@@ -21,9 +18,9 @@ const update_package_json_1 = require("./lib/update-package-json");
|
|
|
21
18
|
const update_project_root_files_1 = require("./lib/update-project-root-files");
|
|
22
19
|
const update_readme_1 = require("./lib/update-readme");
|
|
23
20
|
const update_storybook_config_1 = require("./lib/update-storybook-config");
|
|
21
|
+
const extract_base_configs_1 = require("./lib/extract-base-configs");
|
|
24
22
|
async function moveGenerator(tree, rawSchema) {
|
|
25
23
|
let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, rawSchema.projectName);
|
|
26
|
-
const wasIncludedInWorkspaces = (0, package_manager_workspaces_1.isProjectIncludedInPackageManagerWorkspaces)(tree, projectConfig.root);
|
|
27
24
|
const schema = await (0, normalize_schema_1.normalizeSchema)(tree, rawSchema, projectConfig);
|
|
28
25
|
(0, check_destination_1.checkDestination)(tree, schema, rawSchema.destination);
|
|
29
26
|
if (projectConfig.root === '.') {
|
|
@@ -51,23 +48,8 @@ async function moveGenerator(tree, rawSchema) {
|
|
|
51
48
|
(0, extract_base_configs_1.maybeMigrateEslintConfigIfRootProject)(tree, projectConfig);
|
|
52
49
|
}
|
|
53
50
|
await (0, run_angular_plugin_1.runAngularPlugin)(tree, schema);
|
|
54
|
-
let task;
|
|
55
|
-
if (wasIncludedInWorkspaces) {
|
|
56
|
-
// check if the new destination is included in the package manager workspaces
|
|
57
|
-
const isIncludedInWorkspaces = (0, package_manager_workspaces_1.isProjectIncludedInPackageManagerWorkspaces)(tree, schema.destination);
|
|
58
|
-
if (!isIncludedInWorkspaces) {
|
|
59
|
-
// the new destination is not included in the package manager workspaces
|
|
60
|
-
// so we need to add it and run a package install to ensure the symlink
|
|
61
|
-
// is created
|
|
62
|
-
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, schema.destination);
|
|
63
|
-
task = () => (0, devkit_1.installPackagesTask)(tree, true);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
51
|
if (!schema.skipFormat) {
|
|
67
52
|
await (0, devkit_1.formatFiles)(tree);
|
|
68
53
|
}
|
|
69
|
-
if (task) {
|
|
70
|
-
return task;
|
|
71
|
-
}
|
|
72
54
|
}
|
|
73
55
|
exports.default = moveGenerator;
|
|
@@ -4,9 +4,10 @@ exports.npmPackageGenerator = npmPackageGenerator;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
+
const get_import_path_1 = require("../../utilities/get-import-path");
|
|
7
8
|
async function normalizeOptions(tree, options) {
|
|
8
|
-
await (0, project_name_and_root_utils_1.
|
|
9
|
-
const { projectName, projectRoot
|
|
9
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'library');
|
|
10
|
+
const { projectName, projectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
10
11
|
name: options.name,
|
|
11
12
|
projectType: 'library',
|
|
12
13
|
directory: options.directory,
|
|
@@ -15,13 +16,12 @@ async function normalizeOptions(tree, options) {
|
|
|
15
16
|
...options,
|
|
16
17
|
name: projectName,
|
|
17
18
|
projectRoot,
|
|
18
|
-
importPath,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
function addFiles(projectRoot, tree, options) {
|
|
22
22
|
const packageJsonPath = (0, path_1.join)(projectRoot, 'package.json');
|
|
23
23
|
(0, devkit_1.writeJson)(tree, packageJsonPath, {
|
|
24
|
-
name: options.
|
|
24
|
+
name: (0, get_import_path_1.getImportPath)(tree, options.name),
|
|
25
25
|
version: '0.0.0',
|
|
26
26
|
scripts: {
|
|
27
27
|
test: 'node index.js',
|
|
@@ -73,7 +73,6 @@ async function createPreset(tree, options) {
|
|
|
73
73
|
nxCloudToken: options.nxCloudToken,
|
|
74
74
|
useTsSolution: options.workspaces,
|
|
75
75
|
formatter: options.formatter,
|
|
76
|
-
useProjectJson: !options.workspaces,
|
|
77
76
|
});
|
|
78
77
|
}
|
|
79
78
|
else if (options.preset === presets_1.Preset.ReactStandalone) {
|
|
@@ -107,7 +106,6 @@ async function createPreset(tree, options) {
|
|
|
107
106
|
nxCloudToken: options.nxCloudToken,
|
|
108
107
|
useTsSolution: options.workspaces,
|
|
109
108
|
formatter: options.formatter,
|
|
110
|
-
useProjectJson: !options.workspaces,
|
|
111
109
|
});
|
|
112
110
|
}
|
|
113
111
|
else if (options.preset === presets_1.Preset.RemixStandalone) {
|
|
@@ -139,7 +137,6 @@ async function createPreset(tree, options) {
|
|
|
139
137
|
nxCloudToken: options.nxCloudToken,
|
|
140
138
|
useTsSolution: options.workspaces,
|
|
141
139
|
formatter: options.formatter,
|
|
142
|
-
useProjectJson: !options.workspaces,
|
|
143
140
|
});
|
|
144
141
|
}
|
|
145
142
|
else if (options.preset === presets_1.Preset.VueStandalone) {
|
|
@@ -171,7 +168,6 @@ async function createPreset(tree, options) {
|
|
|
171
168
|
nxCloudToken: options.nxCloudToken,
|
|
172
169
|
useTsSolution: options.workspaces,
|
|
173
170
|
formatter: options.formatter,
|
|
174
|
-
useProjectJson: !options.workspaces,
|
|
175
171
|
});
|
|
176
172
|
}
|
|
177
173
|
else if (options.preset === presets_1.Preset.NuxtStandalone) {
|
|
@@ -204,7 +200,6 @@ async function createPreset(tree, options) {
|
|
|
204
200
|
addPlugin,
|
|
205
201
|
useTsSolution: options.workspaces,
|
|
206
202
|
formatter: options.formatter,
|
|
207
|
-
useProjectJson: !options.workspaces,
|
|
208
203
|
});
|
|
209
204
|
}
|
|
210
205
|
else if (options.preset === presets_1.Preset.NextJsStandalone) {
|
|
@@ -250,7 +245,6 @@ async function createPreset(tree, options) {
|
|
|
250
245
|
addPlugin,
|
|
251
246
|
useTsSolution: options.workspaces,
|
|
252
247
|
formatter: options.formatter,
|
|
253
|
-
useProjectJson: !options.workspaces,
|
|
254
248
|
});
|
|
255
249
|
}
|
|
256
250
|
else if (options.preset === presets_1.Preset.Express) {
|
|
@@ -264,7 +258,6 @@ async function createPreset(tree, options) {
|
|
|
264
258
|
addPlugin,
|
|
265
259
|
useTsSolution: options.workspaces,
|
|
266
260
|
formatter: options.formatter,
|
|
267
|
-
useProjectJson: !options.workspaces,
|
|
268
261
|
});
|
|
269
262
|
}
|
|
270
263
|
else if (options.preset === presets_1.Preset.ReactNative) {
|
|
@@ -281,7 +274,6 @@ async function createPreset(tree, options) {
|
|
|
281
274
|
bundler: options.bundler ?? 'webpack',
|
|
282
275
|
useTsSolution: options.workspaces,
|
|
283
276
|
formatter: options.formatter,
|
|
284
|
-
useProjectJson: !options.workspaces,
|
|
285
277
|
});
|
|
286
278
|
}
|
|
287
279
|
else if (options.preset === presets_1.Preset.Expo) {
|
|
@@ -296,7 +288,6 @@ async function createPreset(tree, options) {
|
|
|
296
288
|
nxCloudToken: options.nxCloudToken,
|
|
297
289
|
useTsSolution: options.workspaces,
|
|
298
290
|
formatter: options.formatter,
|
|
299
|
-
useProjectJson: !options.workspaces,
|
|
300
291
|
});
|
|
301
292
|
}
|
|
302
293
|
else if (options.preset === presets_1.Preset.TS) {
|
|
@@ -355,7 +346,6 @@ async function createPreset(tree, options) {
|
|
|
355
346
|
addPlugin,
|
|
356
347
|
useTsSolution: options.workspaces,
|
|
357
348
|
formatter: options.formatter,
|
|
358
|
-
useProjectJson: !options.workspaces,
|
|
359
349
|
});
|
|
360
350
|
}
|
|
361
351
|
else {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isUsingTsSolutionSetup = isUsingTsSolutionSetup;
|
|
4
|
-
exports.addProjectToTsSolutionWorkspace = addProjectToTsSolutionWorkspace;
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const posix_1 = require("node:path/posix");
|
|
7
5
|
const tree_1 = require("nx/src/generators/tree");
|
|
8
|
-
const package_manager_workspaces_1 = require("../package-manager-workspaces");
|
|
9
6
|
function isUsingPackageManagerWorkspaces(tree) {
|
|
10
7
|
return isWorkspacesEnabled(tree);
|
|
11
8
|
}
|
|
@@ -58,48 +55,3 @@ function isUsingTsSolutionSetup(tree) {
|
|
|
58
55
|
return (isUsingPackageManagerWorkspaces(tree) &&
|
|
59
56
|
isWorkspaceSetupWithTsSolution(tree));
|
|
60
57
|
}
|
|
61
|
-
async function addProjectToTsSolutionWorkspace(tree, projectDir) {
|
|
62
|
-
const isIncluded = (0, package_manager_workspaces_1.isProjectIncludedInPackageManagerWorkspaces)(tree, projectDir);
|
|
63
|
-
if (isIncluded) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
// If dir is "libs/foo", we try to use "libs/*" but we only do it if it's
|
|
67
|
-
// safe to do so. So, we first check if adding that pattern doesn't result
|
|
68
|
-
// in extra projects being matched. If extra projects are matched, or the
|
|
69
|
-
// dir is just "foo" then we add it as is.
|
|
70
|
-
const baseDir = (0, posix_1.dirname)(projectDir);
|
|
71
|
-
let pattern = projectDir;
|
|
72
|
-
if (baseDir !== '.') {
|
|
73
|
-
const patterns = (0, package_manager_workspaces_1.getPackageManagerWorkspacesPatterns)(tree);
|
|
74
|
-
const projectsBefore = await (0, devkit_1.globAsync)(tree, patterns);
|
|
75
|
-
patterns.push(`${baseDir}/*/package.json`);
|
|
76
|
-
const projectsAfter = await (0, devkit_1.globAsync)(tree, patterns);
|
|
77
|
-
if (projectsBefore.length + 1 === projectsAfter.length) {
|
|
78
|
-
// Adding the pattern to the parent directory only results in one extra
|
|
79
|
-
// project being matched, which is the project we're adding. It's safe
|
|
80
|
-
// to add the pattern to the parent directory.
|
|
81
|
-
pattern = `${baseDir}/*`;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (tree.exists('pnpm-workspace.yaml')) {
|
|
85
|
-
const { load, dump } = require('@zkochan/js-yaml');
|
|
86
|
-
const workspaceFile = tree.read('pnpm-workspace.yaml', 'utf-8');
|
|
87
|
-
const yamlData = load(workspaceFile) ?? {};
|
|
88
|
-
yamlData.packages ??= [];
|
|
89
|
-
if (!yamlData.packages.includes(pattern)) {
|
|
90
|
-
yamlData.packages.push(pattern);
|
|
91
|
-
tree.write('pnpm-workspace.yaml', dump(yamlData, { indent: 2, quotingType: '"', forceQuotes: true }));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
// Update package.json
|
|
96
|
-
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
97
|
-
if (!packageJson.workspaces) {
|
|
98
|
-
packageJson.workspaces = [];
|
|
99
|
-
}
|
|
100
|
-
if (!packageJson.workspaces.includes(pattern)) {
|
|
101
|
-
packageJson.workspaces.push(pattern);
|
|
102
|
-
tree.write('package.json', JSON.stringify(packageJson, null, 2));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
package/src/utils/versions.d.ts
CHANGED
package/src/utils/versions.js
CHANGED
|
@@ -5,4 +5,4 @@ exports.nxVersion = require('../../package.json').version;
|
|
|
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';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type Tree } from '@nx/devkit';
|
|
2
|
-
export declare function isProjectIncludedInPackageManagerWorkspaces(tree: Tree, projectRoot: string): boolean;
|
|
3
|
-
export declare function getPackageManagerWorkspacesPatterns(tree: Tree): string[];
|
|
4
|
-
export declare function isUsingPackageManagerWorkspaces(tree: Tree): boolean;
|
|
5
|
-
export declare function isWorkspacesEnabled(tree: Tree): boolean;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isProjectIncludedInPackageManagerWorkspaces = isProjectIncludedInPackageManagerWorkspaces;
|
|
4
|
-
exports.getPackageManagerWorkspacesPatterns = getPackageManagerWorkspacesPatterns;
|
|
5
|
-
exports.isUsingPackageManagerWorkspaces = isUsingPackageManagerWorkspaces;
|
|
6
|
-
exports.isWorkspacesEnabled = isWorkspacesEnabled;
|
|
7
|
-
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const posix_1 = require("node:path/posix");
|
|
9
|
-
const package_json_1 = require("nx/src/plugins/package-json");
|
|
10
|
-
const picomatch = require("picomatch");
|
|
11
|
-
function isProjectIncludedInPackageManagerWorkspaces(tree, projectRoot) {
|
|
12
|
-
if (!isUsingPackageManagerWorkspaces(tree)) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const patterns = getPackageManagerWorkspacesPatterns(tree);
|
|
16
|
-
return patterns.some((p) => picomatch(p)((0, posix_1.join)(projectRoot, 'package.json')));
|
|
17
|
-
}
|
|
18
|
-
function getPackageManagerWorkspacesPatterns(tree) {
|
|
19
|
-
return (0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (path) => (0, devkit_1.readJson)(tree, path, { expectComments: true }), (path) => {
|
|
20
|
-
const content = tree.read(path, 'utf-8');
|
|
21
|
-
const { load } = require('@zkochan/js-yaml');
|
|
22
|
-
return load(content, { filename: path });
|
|
23
|
-
}, (path) => tree.exists(path));
|
|
24
|
-
}
|
|
25
|
-
function isUsingPackageManagerWorkspaces(tree) {
|
|
26
|
-
return isWorkspacesEnabled(tree);
|
|
27
|
-
}
|
|
28
|
-
function isWorkspacesEnabled(tree) {
|
|
29
|
-
const packageManager = (0, devkit_1.detectPackageManager)(tree.root);
|
|
30
|
-
if (packageManager === 'pnpm') {
|
|
31
|
-
return tree.exists('pnpm-workspace.yaml');
|
|
32
|
-
}
|
|
33
|
-
// yarn and npm both use the same 'workspaces' property in package.json
|
|
34
|
-
if (tree.exists('package.json')) {
|
|
35
|
-
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
36
|
-
return !!packageJson?.workspaces;
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
}
|