create-nx-workspace 22.2.0-beta.3 → 22.2.0-beta.4
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.d.ts.map +1 -1
- package/bin/create-nx-workspace.js +20 -0
- package/package.json +1 -1
- package/src/create-workspace.d.ts +4 -0
- package/src/create-workspace.d.ts.map +1 -1
- package/src/create-workspace.js +23 -11
- package/src/utils/nx/nx-cloud.d.ts.map +1 -1
- package/src/utils/nx/nx-cloud.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-nx-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/bin/create-nx-workspace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"create-nx-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/bin/create-nx-workspace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAiB,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAgCnE,UAAU,aAAc,SAAQ,sBAAsB;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC;IAC9D,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,OAAO,CAA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QAAQ,CAAC;IAClC,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC;CAClD;AAED,UAAU,aAAc,SAAQ,aAAa;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,YAAY,GAAG,YAAY,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAC;IAC3D,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,UAAU,qBAAsB,SAAQ,aAAa;IACnD,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,KAAK,SAAS,GACV,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,YAAY,GACZ,aAAa,GACb,qBAAqB,CAAC;AAE1B,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CA8IrB,CAAC;AA8L7B,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAaxD"}
|
|
@@ -149,6 +149,26 @@ process.on('uncaughtException', (error) => {
|
|
|
149
149
|
return;
|
|
150
150
|
throw error;
|
|
151
151
|
});
|
|
152
|
+
// Handle Ctrl+C gracefully - show helpful message if workspace was already created
|
|
153
|
+
process.on('SIGINT', () => {
|
|
154
|
+
const { directory, connectUrl } = (0, create_workspace_1.getInterruptedWorkspaceState)();
|
|
155
|
+
if (directory) {
|
|
156
|
+
console.log(''); // New line after ^C
|
|
157
|
+
output_1.output.log({
|
|
158
|
+
title: 'Workspace creation interrupted',
|
|
159
|
+
bodyLines: [
|
|
160
|
+
`Your workspace was created at: ${directory}`,
|
|
161
|
+
'',
|
|
162
|
+
'To complete the setup:',
|
|
163
|
+
' 1. Ensure your repo is pushed (e.g. https://github.com/new)',
|
|
164
|
+
connectUrl
|
|
165
|
+
? ` 2. Connect to Nx Cloud: ${connectUrl}`
|
|
166
|
+
: ' 2. Connect to Nx Cloud: Run "nx connect"',
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
process.exit(130); // Standard exit code for SIGINT
|
|
171
|
+
});
|
|
152
172
|
let rawArgs;
|
|
153
173
|
async function main(parsedArgs) {
|
|
154
174
|
output_1.output.log({
|
package/package.json
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { CreateWorkspaceOptions } from './create-workspace-options';
|
|
2
2
|
import { VcsPushStatus } from './utils/git/git';
|
|
3
|
+
export declare function getInterruptedWorkspaceState(): {
|
|
4
|
+
directory: string | undefined;
|
|
5
|
+
connectUrl: string | undefined;
|
|
6
|
+
};
|
|
3
7
|
export declare function createWorkspace<T extends CreateWorkspaceOptions>(preset: string, options: T, rawArgs?: T): Promise<{
|
|
4
8
|
nxCloudInfo: string;
|
|
5
9
|
directory: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-workspace.d.ts","sourceRoot":"","sources":["../../../../packages/create-nx-workspace/src/create-workspace.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,iBAAiB,CAAC;AAkBzB,wBAAgB,4BAA4B,IAAI;IAC9C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAEA;AAED,wBAAsB,eAAe,CAAC,CAAC,SAAS,sBAAsB,EACpE,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,CAAC;;;;GAgKZ;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI7D"}
|
package/src/create-workspace.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInterruptedWorkspaceState = getInterruptedWorkspaceState;
|
|
3
4
|
exports.createWorkspace = createWorkspace;
|
|
4
5
|
exports.extractConnectUrl = extractConnectUrl;
|
|
5
6
|
const path_1 = require("path");
|
|
@@ -15,6 +16,12 @@ const get_third_party_preset_1 = require("./utils/preset/get-third-party-preset"
|
|
|
15
16
|
const preset_1 = require("./utils/preset/preset");
|
|
16
17
|
const clone_template_1 = require("./utils/template/clone-template");
|
|
17
18
|
const child_process_utils_1 = require("./utils/child-process-utils");
|
|
19
|
+
// State for SIGINT handler - only set after workspace is fully installed
|
|
20
|
+
let workspaceDirectory;
|
|
21
|
+
let cloudConnectUrl;
|
|
22
|
+
function getInterruptedWorkspaceState() {
|
|
23
|
+
return { directory: workspaceDirectory, connectUrl: cloudConnectUrl };
|
|
24
|
+
}
|
|
18
25
|
async function createWorkspace(preset, options, rawArgs) {
|
|
19
26
|
const { packageManager, name, nxCloud, skipGit = false, defaultBase = 'main', commit, cliName, useGitHub, skipGitHubPush = false, verbose = false, } = options;
|
|
20
27
|
if (cliName) {
|
|
@@ -33,6 +40,8 @@ async function createWorkspace(preset, options, rawArgs) {
|
|
|
33
40
|
await (0, clone_template_1.cloneTemplate)(templateUrl, name);
|
|
34
41
|
// Install dependencies (template flow always uses npm)
|
|
35
42
|
await (0, child_process_utils_1.execAndWait)('npm install --silent --ignore-scripts', directory);
|
|
43
|
+
// Mark workspace as ready for SIGINT handler
|
|
44
|
+
workspaceDirectory = directory;
|
|
36
45
|
workspaceSetupSpinner.succeed(`Successfully created the workspace: ${directory}`);
|
|
37
46
|
}
|
|
38
47
|
catch (e) {
|
|
@@ -54,6 +63,8 @@ async function createWorkspace(preset, options, rawArgs) {
|
|
|
54
63
|
preset,
|
|
55
64
|
workspaceGlobs,
|
|
56
65
|
});
|
|
66
|
+
// Mark workspace as ready for SIGINT handler
|
|
67
|
+
workspaceDirectory = directory;
|
|
57
68
|
// If the preset is a third-party preset, we need to call createPreset to install it
|
|
58
69
|
// For first-party presets, it will be created by createEmptyWorkspace instead.
|
|
59
70
|
// In createEmptyWorkspace, it will call `nx new` -> `@nx/workspace newGenerator` -> `@nx/workspace generatePreset`.
|
|
@@ -63,20 +74,14 @@ async function createWorkspace(preset, options, rawArgs) {
|
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
const isTemplate = !!options.template;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const token = (0, nx_cloud_1.readNxCloudToken)(directory);
|
|
70
|
-
// Only generate CI for preset flow (not template)
|
|
71
|
-
if (!isTemplate && nxCloud !== 'yes') {
|
|
72
|
-
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager);
|
|
73
|
-
}
|
|
74
|
-
connectUrl = await (0, nx_cloud_1.createNxCloudOnboardingUrl)(nxCloud, token, directory, useGitHub);
|
|
77
|
+
// Only generate CI for preset flow (not template)
|
|
78
|
+
if (nxCloud !== 'skip' && !isTemplate && nxCloud !== 'yes') {
|
|
79
|
+
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager);
|
|
75
80
|
}
|
|
76
81
|
let pushedToVcs = git_1.VcsPushStatus.SkippedGit;
|
|
77
82
|
if (!skipGit) {
|
|
78
83
|
try {
|
|
79
|
-
await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit
|
|
84
|
+
await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit });
|
|
80
85
|
// Push to GitHub if commit was made, GitHub push is not skipped, and:
|
|
81
86
|
// - CI provider is GitHub (preset flow), OR
|
|
82
87
|
// - Using template flow with Nx Cloud enabled (yes)
|
|
@@ -103,7 +108,14 @@ async function createWorkspace(preset, options, rawArgs) {
|
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
|
-
|
|
111
|
+
// Create onboarding URL AFTER git operations so getVcsRemoteInfo() can detect the repo
|
|
112
|
+
let connectUrl;
|
|
113
|
+
let nxCloudInfo;
|
|
114
|
+
if (nxCloud !== 'skip') {
|
|
115
|
+
const token = (0, nx_cloud_1.readNxCloudToken)(directory);
|
|
116
|
+
connectUrl = await (0, nx_cloud_1.createNxCloudOnboardingUrl)(nxCloud, token, directory, useGitHub);
|
|
117
|
+
// Store for SIGINT handler
|
|
118
|
+
cloudConnectUrl = connectUrl;
|
|
107
119
|
nxCloudInfo = await (0, nx_cloud_1.getNxCloudInfo)(connectUrl, pushedToVcs, options.completionMessageKey);
|
|
108
120
|
}
|
|
109
121
|
else if (isTemplate && nxCloud === 'skip') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx-cloud.d.ts","sourceRoot":"","sources":["../../../../../../packages/create-nx-workspace/src/utils/nx/nx-cloud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAGL,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAIpB,MAAM,MAAM,OAAO,GACf,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,qBAAqB,GACrB,UAAU,GACV,MAAM,CAAC;AAEX,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8BxB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,UAcjD;AAED,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"nx-cloud.d.ts","sourceRoot":"","sources":["../../../../../../packages/create-nx-workspace/src/utils/nx/nx-cloud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAGL,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAIpB,MAAM,MAAM,OAAO,GACf,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,qBAAqB,GACrB,UAAU,GACV,MAAM,CAAC;AAEX,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA8BxB;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,UAcjD;AAED,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAED,wBAAsB,cAAc,CAClC,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,aAAa,EAC1B,oBAAoB,CAAC,EAAE,oBAAoB,mBAU5C;AAED,wBAAgB,qBAAqB,WAIpC"}
|
package/src/utils/nx/nx-cloud.js
CHANGED
|
@@ -65,7 +65,7 @@ async function createNxCloudOnboardingUrl(nxCloud, token, directory, useGitHub)
|
|
|
65
65
|
const code = promptCode || (nxCloud === 'yes' ? 'remote-cache-visit' : 'ci-setup-visit');
|
|
66
66
|
const meta = `${prefix}-${code}`;
|
|
67
67
|
return createNxCloudOnboardingURL(source, token, meta, false, useGitHub ??
|
|
68
|
-
(nxCloud === 'yes' || nxCloud === 'github' || nxCloud === 'circleci'));
|
|
68
|
+
(nxCloud === 'yes' || nxCloud === 'github' || nxCloud === 'circleci'), directory);
|
|
69
69
|
}
|
|
70
70
|
async function getNxCloudInfo(connectCloudUrl, pushedToVcs, completionMessageKey) {
|
|
71
71
|
const out = new output_1.CLIOutput(false);
|