create-nx-workspace 19.4.0-beta.0 → 19.4.0-beta.2
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 +10 -21
- package/package.json +1 -1
- package/src/create-workspace.js +12 -7
- package/src/utils/git/git.d.ts +1 -0
- package/src/utils/git/git.js +18 -1
- package/src/utils/nx/nx-cloud.js +1 -3
|
@@ -172,27 +172,16 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
172
172
|
}
|
|
173
173
|
const packageManager = await (0, prompts_1.determinePackageManager)(argv);
|
|
174
174
|
const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
defaultBase,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
const nxCloud = await (0, prompts_1.determineNxCloud)(argv);
|
|
190
|
-
Object.assign(argv, {
|
|
191
|
-
nxCloud,
|
|
192
|
-
packageManager,
|
|
193
|
-
defaultBase,
|
|
194
|
-
});
|
|
195
|
-
}
|
|
175
|
+
const nxCloud = argv.skipGit === true ? 'skip' : await (0, prompts_1.determineNxCloud)(argv);
|
|
176
|
+
const useGitHub = nxCloud === 'skip'
|
|
177
|
+
? undefined
|
|
178
|
+
: nxCloud === 'github' || (await (0, prompts_1.determineIfGitHubWillBeUsed)(nxCloud));
|
|
179
|
+
Object.assign(argv, {
|
|
180
|
+
nxCloud,
|
|
181
|
+
useGitHub,
|
|
182
|
+
packageManager,
|
|
183
|
+
defaultBase,
|
|
184
|
+
});
|
|
196
185
|
}
|
|
197
186
|
catch (e) {
|
|
198
187
|
console.error(e);
|
package/package.json
CHANGED
package/src/create-workspace.js
CHANGED
|
@@ -25,16 +25,11 @@ async function createWorkspace(preset, options) {
|
|
|
25
25
|
if (thirdPartyPackageName) {
|
|
26
26
|
await (0, create_preset_1.createPreset)(thirdPartyPackageName, options, packageManager, directory);
|
|
27
27
|
}
|
|
28
|
-
let
|
|
29
|
-
if (nxCloud !== 'skip') {
|
|
30
|
-
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub);
|
|
31
|
-
if (nxCloud !== 'yes') {
|
|
32
|
-
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
28
|
+
let gitSuccess = false;
|
|
35
29
|
if (!skipGit && commit) {
|
|
36
30
|
try {
|
|
37
31
|
await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit });
|
|
32
|
+
gitSuccess = true;
|
|
38
33
|
}
|
|
39
34
|
catch (e) {
|
|
40
35
|
if (e instanceof Error) {
|
|
@@ -48,6 +43,16 @@ async function createWorkspace(preset, options) {
|
|
|
48
43
|
}
|
|
49
44
|
}
|
|
50
45
|
}
|
|
46
|
+
let nxCloudInstallRes;
|
|
47
|
+
if (nxCloud !== 'skip') {
|
|
48
|
+
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub);
|
|
49
|
+
if (nxCloud !== 'yes') {
|
|
50
|
+
const nxCIsetupRes = await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
|
|
51
|
+
if (nxCIsetupRes?.code === 0) {
|
|
52
|
+
(0, git_1.commitChanges)(directory, `feat(nx): Generated CI workflow`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
51
56
|
return {
|
|
52
57
|
nxCloudInfo: nxCloudInstallRes?.stdout,
|
|
53
58
|
directory,
|
package/src/utils/git/git.d.ts
CHANGED
package/src/utils/git/git.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initializeGitRepo = exports.checkGitVersion = void 0;
|
|
3
|
+
exports.commitChanges = exports.initializeGitRepo = exports.checkGitVersion = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const default_base_1 = require("./default-base");
|
|
6
6
|
const output_1 = require("../output");
|
|
@@ -76,3 +76,20 @@ async function initializeGitRepo(directory, options) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
exports.initializeGitRepo = initializeGitRepo;
|
|
79
|
+
function commitChanges(directory, message) {
|
|
80
|
+
try {
|
|
81
|
+
(0, child_process_1.execSync)('git add -A', { encoding: 'utf8', stdio: 'pipe', cwd: directory });
|
|
82
|
+
(0, child_process_1.execSync)('git commit --no-verify -F -', {
|
|
83
|
+
encoding: 'utf8',
|
|
84
|
+
stdio: 'pipe',
|
|
85
|
+
input: message,
|
|
86
|
+
cwd: directory,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
console.error(`There was an error committing your Nx Cloud token.\n
|
|
91
|
+
Please commit the changes manually and push to your new repository.\n
|
|
92
|
+
\n${e}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.commitChanges = commitChanges;
|
package/src/utils/nx/nx-cloud.js
CHANGED
|
@@ -10,9 +10,7 @@ async function setupNxCloud(directory, packageManager, nxCloud, useGitHub) {
|
|
|
10
10
|
const nxCloudSpinner = ora(`Setting up Nx Cloud`).start();
|
|
11
11
|
try {
|
|
12
12
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
13
|
-
const res = await (0, child_process_utils_1.execAndWait)(
|
|
14
|
-
? `${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=create-nx-workspace ${useGitHub ? '--github' : ''} --no-interactive`
|
|
15
|
-
: `${pmc.exec} nx g nx:connect-to-nx-cloud --no-interactive --quiet`, directory);
|
|
13
|
+
const res = await (0, child_process_utils_1.execAndWait)(`${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=create-nx-workspace --directory=${directory} ${useGitHub ? '--github' : ''} --no-interactive`, directory);
|
|
16
14
|
if (nxCloud !== 'yes') {
|
|
17
15
|
nxCloudSpinner.succeed('CI workflow with Nx Cloud has been generated successfully');
|
|
18
16
|
}
|