create-nx-workspace 17.3.1 → 18.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/bin/create-nx-workspace.js +0 -4
- package/package.json +2 -2
- package/src/create-workspace.js +1 -1
- package/src/utils/nx/nx-cloud.d.ts +1 -1
- package/src/utils/nx/nx-cloud.js +20 -8
- package/src/utils/nx/show-nx-warning.js +4 -2
- package/src/utils/package-manager.d.ts +1 -0
- package/src/utils/package-manager.js +3 -0
|
@@ -114,10 +114,6 @@ exports.commandsObject = yargs
|
|
|
114
114
|
async function main(parsedArgs) {
|
|
115
115
|
output_1.output.log({
|
|
116
116
|
title: `Creating your v${nx_version_1.nxVersion} workspace.`,
|
|
117
|
-
bodyLines: [
|
|
118
|
-
'To make sure the command works reliably in all environments, and that the preset is applied correctly,',
|
|
119
|
-
`Nx will run "${parsedArgs.packageManager} install" several times. Please wait.`,
|
|
120
|
-
],
|
|
121
117
|
});
|
|
122
118
|
const workspaceInfo = await (0, create_workspace_1.createWorkspace)(parsedArgs.preset, parsedArgs);
|
|
123
119
|
(0, show_nx_warning_1.showNxWarning)(parsedArgs.name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nx-workspace",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Smart Monorepos · Fast CI",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"tmp": "~0.2.1",
|
|
37
37
|
"tslib": "^2.3.0",
|
|
38
38
|
"yargs": "^17.6.2",
|
|
39
|
-
"axios": "^1.
|
|
39
|
+
"axios": "^1.6.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
package/src/create-workspace.js
CHANGED
|
@@ -27,7 +27,7 @@ async function createWorkspace(preset, options) {
|
|
|
27
27
|
}
|
|
28
28
|
let nxCloudInstallRes;
|
|
29
29
|
if (nxCloud !== 'skip') {
|
|
30
|
-
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager);
|
|
30
|
+
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud);
|
|
31
31
|
if (nxCloud !== 'yes') {
|
|
32
32
|
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
|
|
33
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PackageManager } from '../package-manager';
|
|
2
2
|
export type NxCloud = 'yes' | 'github' | 'circleci' | 'skip';
|
|
3
|
-
export declare function setupNxCloud(directory: string, packageManager: PackageManager): Promise<{
|
|
3
|
+
export declare function setupNxCloud(directory: string, packageManager: PackageManager, nxCloud: NxCloud): Promise<{
|
|
4
4
|
code: number;
|
|
5
5
|
stdout: string;
|
|
6
6
|
}>;
|
package/src/utils/nx/nx-cloud.js
CHANGED
|
@@ -6,12 +6,17 @@ const child_process_utils_1 = require("../child-process-utils");
|
|
|
6
6
|
const output_1 = require("../output");
|
|
7
7
|
const package_manager_1 = require("../package-manager");
|
|
8
8
|
const error_utils_1 = require("../error-utils");
|
|
9
|
-
async function setupNxCloud(directory, packageManager) {
|
|
9
|
+
async function setupNxCloud(directory, packageManager, nxCloud) {
|
|
10
10
|
const nxCloudSpinner = ora(`Setting up Nx Cloud`).start();
|
|
11
11
|
try {
|
|
12
12
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
13
13
|
const res = await (0, child_process_utils_1.execAndWait)(`${pmc.exec} nx g nx:connect-to-nx-cloud --no-interactive --quiet`, directory);
|
|
14
|
-
|
|
14
|
+
if (nxCloud !== 'yes') {
|
|
15
|
+
nxCloudSpinner.succeed('CI workflow with Nx Cloud has been generated successfully');
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
nxCloudSpinner.succeed('Nx Cloud has been set up successfully');
|
|
19
|
+
}
|
|
15
20
|
return res;
|
|
16
21
|
}
|
|
17
22
|
catch (e) {
|
|
@@ -33,12 +38,19 @@ async function setupNxCloud(directory, packageManager) {
|
|
|
33
38
|
}
|
|
34
39
|
exports.setupNxCloud = setupNxCloud;
|
|
35
40
|
function printNxCloudSuccessMessage(nxCloudOut) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
// remove leading Nx carret and any new lines
|
|
42
|
+
const logContent = nxCloudOut.split('> NX ')[1];
|
|
43
|
+
const indexOfTitleEnd = logContent.indexOf('\n');
|
|
44
|
+
const title = logContent.slice(0, logContent.indexOf('\n')).trim();
|
|
45
|
+
const bodyLines = logContent
|
|
46
|
+
.slice(indexOfTitleEnd)
|
|
47
|
+
.replace(/^\n*/, '') // remove leading new lines
|
|
48
|
+
.replace(/\n*$/, '') // remove trailing new lines
|
|
49
|
+
.split('\n')
|
|
50
|
+
.map((r) => r.trim());
|
|
51
|
+
output_1.output.warn({
|
|
52
|
+
title,
|
|
53
|
+
bodyLines,
|
|
42
54
|
});
|
|
43
55
|
}
|
|
44
56
|
exports.printNxCloudSuccessMessage = printNxCloudSuccessMessage;
|
|
@@ -4,6 +4,7 @@ exports.showNxWarning = void 0;
|
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const output_1 = require("../output");
|
|
7
|
+
const package_manager_1 = require("../package-manager");
|
|
7
8
|
function showNxWarning(workspaceName) {
|
|
8
9
|
try {
|
|
9
10
|
const pathToRunNxCommand = (0, path_1.resolve)(process.cwd(), workspaceName);
|
|
@@ -14,12 +15,13 @@ function showNxWarning(workspaceName) {
|
|
|
14
15
|
}
|
|
15
16
|
catch (e) {
|
|
16
17
|
// no nx found
|
|
18
|
+
const { exec, globalAdd } = (0, package_manager_1.getPackageManagerCommand)();
|
|
17
19
|
output_1.output.addVerticalSeparator();
|
|
18
20
|
output_1.output.note({
|
|
19
21
|
title: `Nx CLI is not installed globally.`,
|
|
20
22
|
bodyLines: [
|
|
21
|
-
`This means that you
|
|
22
|
-
`Run "
|
|
23
|
+
`This means that you will have to use "${exec} nx" to execute commands in the workspace.`,
|
|
24
|
+
`Run "${globalAdd} nx" to be able to execute command directly.`,
|
|
23
25
|
],
|
|
24
26
|
});
|
|
25
27
|
}
|
|
@@ -17,6 +17,7 @@ export declare function getPackageManagerCommand(packageManager?: PackageManager
|
|
|
17
17
|
install: string;
|
|
18
18
|
exec: string;
|
|
19
19
|
preInstall?: string;
|
|
20
|
+
globalAdd: string;
|
|
20
21
|
};
|
|
21
22
|
export declare function generatePackageManagerFiles(root: string, packageManager?: PackageManager): void;
|
|
22
23
|
export declare function getPackageManagerVersion(packageManager: PackageManager, cwd?: string): string;
|
|
@@ -43,6 +43,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager()) {
|
|
|
43
43
|
: `${installCommand} --ignore-scripts`,
|
|
44
44
|
// using npx is necessary to avoid yarn classic manipulating the version detection when using berry
|
|
45
45
|
exec: useBerry ? 'npx' : 'yarn',
|
|
46
|
+
globalAdd: 'yarn global add',
|
|
46
47
|
};
|
|
47
48
|
case 'pnpm':
|
|
48
49
|
let useExec = false;
|
|
@@ -52,11 +53,13 @@ function getPackageManagerCommand(packageManager = detectPackageManager()) {
|
|
|
52
53
|
return {
|
|
53
54
|
install: 'pnpm install --no-frozen-lockfile --silent --ignore-scripts',
|
|
54
55
|
exec: useExec ? 'pnpm exec' : 'pnpx',
|
|
56
|
+
globalAdd: 'pnpm add -g',
|
|
55
57
|
};
|
|
56
58
|
case 'npm':
|
|
57
59
|
return {
|
|
58
60
|
install: 'npm install --silent --ignore-scripts',
|
|
59
61
|
exec: 'npx',
|
|
62
|
+
globalAdd: 'npm i -g',
|
|
60
63
|
};
|
|
61
64
|
}
|
|
62
65
|
}
|