create-nx-workspace 19.5.1 → 19.5.3
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 +1 -1
- package/src/create-workspace.d.ts +1 -0
- package/src/create-workspace.js +19 -14
- package/src/utils/git/git.d.ts +1 -1
- package/src/utils/git/git.js +10 -18
package/package.json
CHANGED
package/src/create-workspace.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWorkspace = createWorkspace;
|
|
4
|
+
exports.extractConnectUrl = extractConnectUrl;
|
|
4
5
|
const output_1 = require("./utils/output");
|
|
5
6
|
const nx_cloud_1 = require("./utils/nx/nx-cloud");
|
|
6
7
|
const create_sandbox_1 = require("./create-sandbox");
|
|
@@ -25,11 +26,20 @@ async function createWorkspace(preset, options) {
|
|
|
25
26
|
if (thirdPartyPackageName) {
|
|
26
27
|
await (0, create_preset_1.createPreset)(thirdPartyPackageName, options, packageManager, directory);
|
|
27
28
|
}
|
|
28
|
-
let
|
|
29
|
-
if (
|
|
29
|
+
let nxCloudInstallRes;
|
|
30
|
+
if (nxCloud !== 'skip') {
|
|
31
|
+
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub);
|
|
32
|
+
if (nxCloud !== 'yes') {
|
|
33
|
+
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!skipGit) {
|
|
30
37
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
let connectUrl;
|
|
39
|
+
if (nxCloudInstallRes?.code === 0) {
|
|
40
|
+
connectUrl = extractConnectUrl(nxCloudInstallRes?.stdout);
|
|
41
|
+
}
|
|
42
|
+
await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit, connectUrl });
|
|
33
43
|
}
|
|
34
44
|
catch (e) {
|
|
35
45
|
if (e instanceof Error) {
|
|
@@ -43,18 +53,13 @@ async function createWorkspace(preset, options) {
|
|
|
43
53
|
}
|
|
44
54
|
}
|
|
45
55
|
}
|
|
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
|
-
}
|
|
56
56
|
return {
|
|
57
57
|
nxCloudInfo: nxCloudInstallRes?.stdout,
|
|
58
58
|
directory,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
function extractConnectUrl(text) {
|
|
62
|
+
const urlPattern = /(https:\/\/[^\s]+\/connect\/[^\s]+)/g;
|
|
63
|
+
const match = text.match(urlPattern);
|
|
64
|
+
return match ? match[0] : null;
|
|
65
|
+
}
|
package/src/utils/git/git.d.ts
CHANGED
package/src/utils/git/git.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkGitVersion = checkGitVersion;
|
|
4
4
|
exports.initializeGitRepo = initializeGitRepo;
|
|
5
|
-
exports.commitChanges = commitChanges;
|
|
6
5
|
const child_process_1 = require("child_process");
|
|
7
6
|
const default_base_1 = require("./default-base");
|
|
8
7
|
const output_1 = require("../output");
|
|
@@ -72,23 +71,16 @@ async function initializeGitRepo(directory, options) {
|
|
|
72
71
|
}
|
|
73
72
|
await execute(['add', '.']);
|
|
74
73
|
if (options.commit) {
|
|
75
|
-
|
|
74
|
+
let message = `${options.commit.message}` || 'initial commit';
|
|
75
|
+
if (options.connectUrl) {
|
|
76
|
+
message = `${message}
|
|
77
|
+
|
|
78
|
+
To connect your workspace to Nx Cloud, push your repository
|
|
79
|
+
to your git hosting provider and go to the following URL:
|
|
80
|
+
|
|
81
|
+
${options.connectUrl}
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
76
84
|
await execute(['commit', `-m "${message}"`]);
|
|
77
85
|
}
|
|
78
86
|
}
|
|
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
|
-
}
|