nx 21.3.8 → 21.3.9
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 +11 -11
- package/src/command-line/init/implementation/utils.js +1 -2
- package/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +4 -4
- package/src/command-line/nx-cloud/connect/view-logs.js +3 -5
- package/src/native/nx.wasi-browser.js +42 -39
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -1
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +5 -3
- package/src/nx-cloud/utilities/onboarding.js +1 -1
- package/src/nx-cloud/utilities/url-shorten.d.ts +1 -2
- package/src/nx-cloud/utilities/url-shorten.js +17 -21
- package/src/utils/ab-testing.d.ts +1 -1
- package/src/utils/ab-testing.js +1 -1
- package/src/utils/git-utils.d.ts +6 -6
- package/src/utils/git-utils.js +75 -50
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.3.
|
3
|
+
"version": "21.3.9",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -83,16 +83,16 @@
|
|
83
83
|
}
|
84
84
|
},
|
85
85
|
"optionalDependencies": {
|
86
|
-
"@nx/nx-darwin-arm64": "21.3.
|
87
|
-
"@nx/nx-darwin-x64": "21.3.
|
88
|
-
"@nx/nx-freebsd-x64": "21.3.
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "21.3.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "21.3.
|
91
|
-
"@nx/nx-linux-arm64-musl": "21.3.
|
92
|
-
"@nx/nx-linux-x64-gnu": "21.3.
|
93
|
-
"@nx/nx-linux-x64-musl": "21.3.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "21.3.
|
95
|
-
"@nx/nx-win32-x64-msvc": "21.3.
|
86
|
+
"@nx/nx-darwin-arm64": "21.3.9",
|
87
|
+
"@nx/nx-darwin-x64": "21.3.9",
|
88
|
+
"@nx/nx-freebsd-x64": "21.3.9",
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "21.3.9",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "21.3.9",
|
91
|
+
"@nx/nx-linux-arm64-musl": "21.3.9",
|
92
|
+
"@nx/nx-linux-x64-gnu": "21.3.9",
|
93
|
+
"@nx/nx-linux-x64-musl": "21.3.9",
|
94
|
+
"@nx/nx-win32-arm64-msvc": "21.3.9",
|
95
|
+
"@nx/nx-win32-x64-msvc": "21.3.9"
|
96
96
|
},
|
97
97
|
"nx-migrations": {
|
98
98
|
"migrations": "./migrations.json",
|
@@ -21,7 +21,6 @@ const path_2 = require("../../../utils/path");
|
|
21
21
|
const versions_1 = require("../../../utils/versions");
|
22
22
|
const fs_1 = require("fs");
|
23
23
|
const connect_to_nx_cloud_1 = require("../../../nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
|
24
|
-
const url_shorten_1 = require("../../../nx-cloud/utilities/url-shorten");
|
25
24
|
const connect_to_nx_cloud_2 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
26
25
|
const deduce_default_base_1 = require("./deduce-default-base");
|
27
26
|
function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scriptOutputs) {
|
@@ -216,7 +215,7 @@ async function initCloud(installationSource) {
|
|
216
215
|
const token = await (0, connect_to_nx_cloud_2.connectWorkspaceToCloud)({
|
217
216
|
installationSource,
|
218
217
|
});
|
219
|
-
await (0, connect_to_nx_cloud_1.printSuccessMessage)(token, installationSource
|
218
|
+
await (0, connect_to_nx_cloud_1.printSuccessMessage)(token, installationSource);
|
220
219
|
}
|
221
220
|
function addVsCodeRecommendedExtensions(repoRoot, extensions) {
|
222
221
|
const vsCodeExtensionsPath = (0, path_1.join)(repoRoot, '.vscode/extensions.json');
|
@@ -16,8 +16,8 @@ const child_process_1 = require("../../../utils/child-process");
|
|
16
16
|
const ab_testing_1 = require("../../../utils/ab-testing");
|
17
17
|
const versions_1 = require("../../../utils/versions");
|
18
18
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
19
|
-
const chalk = require("chalk");
|
20
19
|
const git_utils_1 = require("../../../utils/git-utils");
|
20
|
+
const chalk = require("chalk");
|
21
21
|
const ora = require('ora');
|
22
22
|
const open = require('open');
|
23
23
|
function onlyDefaultRunnerIsUsed(nxJson) {
|
@@ -60,7 +60,7 @@ async function connectToNxCloudCommand(options, command) {
|
|
60
60
|
const installationSource = process.env.NX_CONSOLE
|
61
61
|
? 'nx-console'
|
62
62
|
: 'nx-connect';
|
63
|
-
const hasRemote = !!(0, git_utils_1.
|
63
|
+
const hasRemote = !!(0, git_utils_1.getVcsRemoteInfo)();
|
64
64
|
if (!hasRemote && options.checkRemote) {
|
65
65
|
output_1.output.error({
|
66
66
|
title: 'Missing VCS provider',
|
@@ -78,7 +78,7 @@ async function connectToNxCloudCommand(options, command) {
|
|
78
78
|
if (!token) {
|
79
79
|
throw new Error(`Unable to authenticate. If you are connecting to Nx Cloud locally, set Nx Cloud ID in nx.json. If you are connecting in a CI context, either define accessToken in nx.json or set the NX_CLOUD_ACCESS_TOKEN env variable.`);
|
80
80
|
}
|
81
|
-
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token, options?.generateToken
|
81
|
+
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token, undefined, options?.generateToken === true);
|
82
82
|
output_1.output.log({
|
83
83
|
title: '✔ This workspace already has Nx Cloud set up',
|
84
84
|
bodyLines: [
|
@@ -93,7 +93,7 @@ async function connectToNxCloudCommand(options, command) {
|
|
93
93
|
generateToken: options?.generateToken,
|
94
94
|
installationSource: command ?? installationSource,
|
95
95
|
});
|
96
|
-
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)('nx-connect', token, options?.generateToken
|
96
|
+
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)('nx-connect', token, undefined, options?.generateToken === true);
|
97
97
|
try {
|
98
98
|
const cloudConnectSpinner = ora(`Opening Nx Cloud ${connectCloudUrl} in your browser to connect your workspace.`).start();
|
99
99
|
await sleep(2000);
|
@@ -7,8 +7,6 @@ const nx_cloud_utils_1 = require("../../../utils/nx-cloud-utils");
|
|
7
7
|
const output_1 = require("../../../utils/output");
|
8
8
|
const nx_json_1 = require("../../../config/nx-json");
|
9
9
|
const connect_to_nx_cloud_1 = require("./connect-to-nx-cloud");
|
10
|
-
const connect_to_nx_cloud_2 = require("../../../nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
|
11
|
-
const url_shorten_1 = require("../../../nx-cloud/utilities/url-shorten");
|
12
10
|
async function viewLogs() {
|
13
11
|
const cloudUsed = (0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)());
|
14
12
|
if (cloudUsed) {
|
@@ -28,10 +26,10 @@ async function viewLogs() {
|
|
28
26
|
output_1.output.log({
|
29
27
|
title: 'Connecting to Nx Cloud',
|
30
28
|
});
|
31
|
-
|
29
|
+
await (0, connect_to_nx_cloud_1.connectWorkspaceToCloud)({
|
32
30
|
installationSource: 'view-logs',
|
31
|
+
generateToken: true,
|
33
32
|
});
|
34
|
-
await (0, connect_to_nx_cloud_2.printSuccessMessage)(token, 'view-logs', await (0, url_shorten_1.repoUsesGithub)());
|
35
33
|
}
|
36
34
|
catch (e) {
|
37
35
|
output_1.output.log({
|
@@ -48,7 +46,7 @@ async function viewLogs() {
|
|
48
46
|
if (!cloudUsed) {
|
49
47
|
output_1.output.note({
|
50
48
|
title: 'Your workspace is now connected to Nx Cloud',
|
51
|
-
bodyLines: [`Learn more about Nx Cloud at https://nx.
|
49
|
+
bodyLines: [`Learn more about Nx Cloud at https://nx.dev/nx-cloud`],
|
52
50
|
});
|
53
51
|
}
|
54
52
|
return 0;
|
@@ -64,46 +64,49 @@ function __napi_rs_initialize_modules(__napiInstance) {
|
|
64
64
|
__napiInstance.exports['__napi_register__NxConsolePreferences_struct_10']?.()
|
65
65
|
__napiInstance.exports['__napi_register__NxConsolePreferences_impl_14']?.()
|
66
66
|
__napiInstance.exports['__napi_register__log_debug_15']?.()
|
67
|
-
__napiInstance.exports['
|
68
|
-
__napiInstance.exports['
|
69
|
-
__napiInstance.exports['
|
70
|
-
__napiInstance.exports['
|
71
|
-
__napiInstance.exports['
|
72
|
-
__napiInstance.exports['
|
73
|
-
__napiInstance.exports['
|
74
|
-
__napiInstance.exports['
|
75
|
-
__napiInstance.exports['
|
76
|
-
__napiInstance.exports['
|
77
|
-
__napiInstance.exports['
|
78
|
-
__napiInstance.exports['
|
79
|
-
__napiInstance.exports['
|
80
|
-
__napiInstance.exports['
|
81
|
-
__napiInstance.exports['
|
82
|
-
__napiInstance.exports['
|
83
|
-
__napiInstance.exports['
|
84
|
-
__napiInstance.exports['
|
85
|
-
__napiInstance.exports['
|
86
|
-
__napiInstance.exports['
|
87
|
-
__napiInstance.exports['
|
88
|
-
__napiInstance.exports['
|
89
|
-
__napiInstance.exports['
|
90
|
-
__napiInstance.exports['
|
91
|
-
__napiInstance.exports['
|
92
|
-
__napiInstance.exports['
|
93
|
-
__napiInstance.exports['
|
94
|
-
__napiInstance.exports['
|
95
|
-
__napiInstance.exports['
|
96
|
-
__napiInstance.exports['
|
97
|
-
__napiInstance.exports['
|
98
|
-
__napiInstance.exports['
|
99
|
-
__napiInstance.exports['
|
100
|
-
__napiInstance.exports['
|
101
|
-
__napiInstance.exports['
|
102
|
-
__napiInstance.exports['
|
103
|
-
__napiInstance.exports['
|
104
|
-
__napiInstance.exports['
|
67
|
+
__napiInstance.exports['__napi_register__IS_WASM_16']?.()
|
68
|
+
__napiInstance.exports['__napi_register__get_binary_target_17']?.()
|
69
|
+
__napiInstance.exports['__napi_register__ImportResult_struct_18']?.()
|
70
|
+
__napiInstance.exports['__napi_register__find_imports_19']?.()
|
71
|
+
__napiInstance.exports['__napi_register__transfer_project_graph_20']?.()
|
72
|
+
__napiInstance.exports['__napi_register__ExternalNode_struct_21']?.()
|
73
|
+
__napiInstance.exports['__napi_register__Target_struct_22']?.()
|
74
|
+
__napiInstance.exports['__napi_register__Project_struct_23']?.()
|
75
|
+
__napiInstance.exports['__napi_register__ProjectGraph_struct_24']?.()
|
76
|
+
__napiInstance.exports['__napi_register__HashPlanInspector_struct_25']?.()
|
77
|
+
__napiInstance.exports['__napi_register__HashPlanInspector_impl_28']?.()
|
78
|
+
__napiInstance.exports['__napi_register__HashPlanner_struct_29']?.()
|
79
|
+
__napiInstance.exports['__napi_register__HashPlanner_impl_33']?.()
|
80
|
+
__napiInstance.exports['__napi_register__HashDetails_struct_34']?.()
|
81
|
+
__napiInstance.exports['__napi_register__HasherOptions_struct_35']?.()
|
82
|
+
__napiInstance.exports['__napi_register__TaskHasher_struct_36']?.()
|
83
|
+
__napiInstance.exports['__napi_register__TaskHasher_impl_39']?.()
|
84
|
+
__napiInstance.exports['__napi_register__Task_struct_40']?.()
|
85
|
+
__napiInstance.exports['__napi_register__TaskTarget_struct_41']?.()
|
86
|
+
__napiInstance.exports['__napi_register__TaskResult_struct_42']?.()
|
87
|
+
__napiInstance.exports['__napi_register__TaskGraph_struct_43']?.()
|
88
|
+
__napiInstance.exports['__napi_register__FileData_struct_44']?.()
|
89
|
+
__napiInstance.exports['__napi_register__InputsInput_struct_45']?.()
|
90
|
+
__napiInstance.exports['__napi_register__FileSetInput_struct_46']?.()
|
91
|
+
__napiInstance.exports['__napi_register__RuntimeInput_struct_47']?.()
|
92
|
+
__napiInstance.exports['__napi_register__EnvironmentInput_struct_48']?.()
|
93
|
+
__napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_49']?.()
|
94
|
+
__napiInstance.exports['__napi_register__DepsOutputsInput_struct_50']?.()
|
95
|
+
__napiInstance.exports['__napi_register__NxJson_struct_51']?.()
|
96
|
+
__napiInstance.exports['__napi_register__is_ai_agent_52']?.()
|
97
|
+
__napiInstance.exports['__napi_register__FileLock_struct_53']?.()
|
98
|
+
__napiInstance.exports['__napi_register__FileLock_impl_55']?.()
|
99
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_struct_56']?.()
|
100
|
+
__napiInstance.exports['__napi_register__WorkspaceContext_impl_67']?.()
|
101
|
+
__napiInstance.exports['__napi_register__WorkspaceErrors_68']?.()
|
102
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_69']?.()
|
103
|
+
__napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_70']?.()
|
104
|
+
__napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_71']?.()
|
105
|
+
__napiInstance.exports['__napi_register__FileMap_struct_72']?.()
|
106
|
+
__napiInstance.exports['__napi_register____test_only_transfer_file_map_73']?.()
|
105
107
|
}
|
106
108
|
export const FileLock = __napiModule.exports.FileLock
|
109
|
+
export const HashPlanInspector = __napiModule.exports.HashPlanInspector
|
107
110
|
export const HashPlanner = __napiModule.exports.HashPlanner
|
108
111
|
export const ImportResult = __napiModule.exports.ImportResult
|
109
112
|
export const NxConsolePreferences = __napiModule.exports.NxConsolePreferences
|
@@ -120,8 +123,8 @@ export const hashArray = __napiModule.exports.hashArray
|
|
120
123
|
export const hashFile = __napiModule.exports.hashFile
|
121
124
|
export const installNxConsole = __napiModule.exports.installNxConsole
|
122
125
|
export const IS_WASM = __napiModule.exports.IS_WASM
|
126
|
+
export const isAiAgent = __napiModule.exports.isAiAgent
|
123
127
|
export const logDebug = __napiModule.exports.logDebug
|
124
|
-
export const logError = __napiModule.exports.logError
|
125
128
|
export const remove = __napiModule.exports.remove
|
126
129
|
export const testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
|
127
130
|
export const transferProjectGraph = __napiModule.exports.transferProjectGraph
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Tree } from '../../../generators/tree';
|
2
2
|
import { NxJsonConfiguration } from '../../../config/nx-json';
|
3
|
-
export declare function printSuccessMessage(token: string | undefined, installationSource: string
|
3
|
+
export declare function printSuccessMessage(token: string | undefined, installationSource: string): Promise<string>;
|
4
4
|
export interface ConnectToNxCloudOptions {
|
5
5
|
analytics?: boolean;
|
6
6
|
installationSource?: string;
|
@@ -10,6 +10,7 @@ const format_changed_files_with_prettier_if_available_1 = require("../../../gene
|
|
10
10
|
const url_shorten_1 = require("../../utilities/url-shorten");
|
11
11
|
const get_cloud_options_1 = require("../../utilities/get-cloud-options");
|
12
12
|
const path_1 = require("path");
|
13
|
+
const git_utils_1 = require("../../../utils/git-utils");
|
13
14
|
function printCloudConnectionDisabledMessage() {
|
14
15
|
output_1.output.error({
|
15
16
|
title: `Connections to Nx Cloud are disabled for this workspace`,
|
@@ -66,8 +67,8 @@ async function createNxCloudWorkspaceV2(workspaceName, installationSource, nxIni
|
|
66
67
|
}
|
67
68
|
return response.data;
|
68
69
|
}
|
69
|
-
async function printSuccessMessage(token, installationSource
|
70
|
-
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token,
|
70
|
+
async function printSuccessMessage(token, installationSource) {
|
71
|
+
const connectCloudUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)(installationSource, token, undefined, false);
|
71
72
|
output_1.output.note({
|
72
73
|
title: `Your Self-Healing CI and Remote Caching setup is almost complete`,
|
73
74
|
bodyLines: [
|
@@ -109,7 +110,8 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
|
|
109
110
|
printCloudConnectionDisabledMessage();
|
110
111
|
return null;
|
111
112
|
}
|
112
|
-
const
|
113
|
+
const remoteInfo = await (0, git_utils_1.getVcsRemoteInfo)();
|
114
|
+
const isGitHubDetected = schema.github ?? remoteInfo?.domain === 'github.com';
|
113
115
|
let responseFromCreateNxCloudWorkspaceV1;
|
114
116
|
let responseFromCreateNxCloudWorkspaceV2;
|
115
117
|
/**
|
@@ -18,7 +18,7 @@ async function getNxCloudAppOnBoardingUrl(token) {
|
|
18
18
|
if (!token) {
|
19
19
|
return null;
|
20
20
|
}
|
21
|
-
const onboardingUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)('nx-welcome-app', token);
|
21
|
+
const onboardingUrl = await (0, url_shorten_1.createNxCloudOnboardingURL)('nx-welcome-app', token, undefined, false);
|
22
22
|
return onboardingUrl;
|
23
23
|
}
|
24
24
|
function readNxCloudToken(tree) {
|
@@ -1,6 +1,5 @@
|
|
1
1
|
/**
|
2
2
|
* This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
|
3
3
|
*/
|
4
|
-
export declare function createNxCloudOnboardingURL(onboardingSource: string, accessToken?: string,
|
5
|
-
export declare function repoUsesGithub(github?: boolean, githubSlug?: string, apiUrl?: string): Promise<boolean>;
|
4
|
+
export declare function createNxCloudOnboardingURL(onboardingSource: string, accessToken?: string, meta?: string, forceManual?: boolean, forceGithub?: boolean): Promise<string>;
|
6
5
|
export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string | null, apiUrl: string, source: string, accessToken?: string): string;
|
@@ -1,19 +1,27 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.createNxCloudOnboardingURL = createNxCloudOnboardingURL;
|
4
|
-
exports.repoUsesGithub = repoUsesGithub;
|
5
4
|
exports.getURLifShortenFailed = getURLifShortenFailed;
|
6
5
|
const logger_1 = require("../../utils/logger");
|
7
|
-
const git_utils_1 = require("../../utils/git-utils");
|
8
6
|
const get_cloud_options_1 = require("./get-cloud-options");
|
7
|
+
const git_utils_1 = require("../../utils/git-utils");
|
9
8
|
/**
|
10
9
|
* This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
|
11
10
|
*/
|
12
|
-
async function createNxCloudOnboardingURL(onboardingSource, accessToken,
|
13
|
-
const
|
11
|
+
async function createNxCloudOnboardingURL(onboardingSource, accessToken, meta, forceManual = false, forceGithub = false) {
|
12
|
+
const remoteInfo = (0, git_utils_1.getVcsRemoteInfo)();
|
14
13
|
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
15
|
-
|
16
|
-
|
14
|
+
const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl);
|
15
|
+
let usesGithub = false;
|
16
|
+
if (forceGithub) {
|
17
|
+
usesGithub = installationSupportsGitHub;
|
18
|
+
}
|
19
|
+
else if (forceManual) {
|
20
|
+
usesGithub = false;
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
usesGithub =
|
24
|
+
remoteInfo?.domain === 'github.com' && installationSupportsGitHub;
|
17
25
|
}
|
18
26
|
const source = getSource(onboardingSource);
|
19
27
|
try {
|
@@ -21,7 +29,8 @@ async function createNxCloudOnboardingURL(onboardingSource, accessToken, usesGit
|
|
21
29
|
type: usesGithub ? 'GITHUB' : 'MANUAL',
|
22
30
|
source,
|
23
31
|
accessToken: usesGithub ? null : accessToken,
|
24
|
-
selectedRepositoryName:
|
32
|
+
selectedRepositoryName: remoteInfo?.slug ?? null,
|
33
|
+
repositoryDomain: remoteInfo?.domain ?? null,
|
25
34
|
meta,
|
26
35
|
});
|
27
36
|
if (!response?.data || response.data.message) {
|
@@ -32,21 +41,8 @@ async function createNxCloudOnboardingURL(onboardingSource, accessToken, usesGit
|
|
32
41
|
catch (e) {
|
33
42
|
logger_1.logger.verbose(`Failed to shorten Nx Cloud URL.
|
34
43
|
${e}`);
|
35
|
-
return getURLifShortenFailed(usesGithub,
|
36
|
-
}
|
37
|
-
}
|
38
|
-
async function repoUsesGithub(github, githubSlug, apiUrl) {
|
39
|
-
if (!apiUrl) {
|
40
|
-
apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
44
|
+
return getURLifShortenFailed(usesGithub, usesGithub ? remoteInfo?.slug : null, apiUrl, source, accessToken);
|
41
45
|
}
|
42
|
-
if (!githubSlug) {
|
43
|
-
githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
|
44
|
-
}
|
45
|
-
const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl);
|
46
|
-
return ((!!githubSlug || !!github) &&
|
47
|
-
(apiUrl.includes('cloud.nx.app') ||
|
48
|
-
apiUrl.includes('eu.nx.app') ||
|
49
|
-
installationSupportsGitHub));
|
50
46
|
}
|
51
47
|
function getSource(installationSource) {
|
52
48
|
if (installationSource.includes('nx-init')) {
|
@@ -26,7 +26,7 @@ declare const messageOptions: {
|
|
26
26
|
readonly value: "skip";
|
27
27
|
readonly name: "No";
|
28
28
|
}];
|
29
|
-
readonly footer: "\nRead more about
|
29
|
+
readonly footer: "\nRead more about Nx Cloud at https://nx.dev/nx-cloud";
|
30
30
|
readonly hint: "\n(it's free and can be disabled any time)";
|
31
31
|
}];
|
32
32
|
};
|
package/src/utils/ab-testing.js
CHANGED
@@ -33,7 +33,7 @@ const messageOptions = {
|
|
33
33
|
},
|
34
34
|
{ value: 'skip', name: 'No' },
|
35
35
|
],
|
36
|
-
footer: '\nRead more about
|
36
|
+
footer: '\nRead more about Nx Cloud at https://nx.dev/nx-cloud',
|
37
37
|
hint: `\n(it's free and can be disabled any time)`,
|
38
38
|
},
|
39
39
|
],
|
package/src/utils/git-utils.d.ts
CHANGED
@@ -32,11 +32,11 @@ export declare class GitRepository {
|
|
32
32
|
private quotePath;
|
33
33
|
private quoteArg;
|
34
34
|
}
|
35
|
-
export
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
export declare function
|
40
|
-
export declare function
|
35
|
+
export interface VcsRemoteInfo {
|
36
|
+
domain: string;
|
37
|
+
slug: string;
|
38
|
+
}
|
39
|
+
export declare function parseVcsRemoteUrl(url: string): VcsRemoteInfo | null;
|
40
|
+
export declare function getVcsRemoteInfo(): VcsRemoteInfo | null;
|
41
41
|
export declare function commitChanges(commitMessage: string, directory?: string): string | null;
|
42
42
|
export declare function getLatestCommitSha(directory?: string): string | null;
|
package/src/utils/git-utils.js
CHANGED
@@ -2,9 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.GitRepository = void 0;
|
4
4
|
exports.cloneFromUpstream = cloneFromUpstream;
|
5
|
-
exports.
|
6
|
-
exports.
|
7
|
-
exports.extractUserAndRepoFromGitHubUrl = extractUserAndRepoFromGitHubUrl;
|
5
|
+
exports.parseVcsRemoteUrl = parseVcsRemoteUrl;
|
6
|
+
exports.getVcsRemoteInfo = getVcsRemoteInfo;
|
8
7
|
exports.commitChanges = commitChanges;
|
9
8
|
exports.getLatestCommitSha = getLatestCommitSha;
|
10
9
|
const child_process_1 = require("child_process");
|
@@ -171,61 +170,87 @@ class GitRepository {
|
|
171
170
|
}
|
172
171
|
}
|
173
172
|
exports.GitRepository = GitRepository;
|
174
|
-
function
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
173
|
+
function parseVcsRemoteUrl(url) {
|
174
|
+
// Remove whitespace and handle common URL formats
|
175
|
+
const cleanUrl = url.trim();
|
176
|
+
// SSH format: git@domain:owner/repo.git
|
177
|
+
const sshMatch = cleanUrl.match(/^git@([^:]+):([^\/]+)\/(.+?)(\.git)?$/);
|
178
|
+
if (sshMatch) {
|
179
|
+
const [, domain, owner, repo] = sshMatch;
|
180
|
+
return {
|
181
|
+
domain,
|
182
|
+
slug: `${owner}/${repo}`,
|
183
|
+
};
|
184
|
+
}
|
185
|
+
// HTTPS with authentication: https://user@domain/owner/repo.git
|
186
|
+
const httpsAuthMatch = cleanUrl.match(/^https?:\/\/[^@]+@([^\/]+)\/([^\/]+)\/(.+?)(\.git)?$/);
|
187
|
+
if (httpsAuthMatch) {
|
188
|
+
const [, domain, owner, repo] = httpsAuthMatch;
|
189
|
+
return {
|
190
|
+
domain,
|
191
|
+
slug: `${owner}/${repo}`,
|
192
|
+
};
|
193
|
+
}
|
194
|
+
// HTTPS format: https://domain/owner/repo.git (without authentication)
|
195
|
+
const httpsMatch = cleanUrl.match(/^https?:\/\/([^@\/]+)\/([^\/]+)\/(.+?)(\.git)?$/);
|
196
|
+
if (httpsMatch) {
|
197
|
+
const [, domain, owner, repo] = httpsMatch;
|
198
|
+
return {
|
199
|
+
domain,
|
200
|
+
slug: `${owner}/${repo}`,
|
201
|
+
};
|
202
|
+
}
|
203
|
+
// SSH alternative format: ssh://git@domain/owner/repo.git or ssh://git@domain:port/owner/repo.git
|
204
|
+
const sshAltMatch = cleanUrl.match(/^ssh:\/\/[^@]+@([^:\/]+)(:[0-9]+)?\/([^\/]+)\/(.+?)(\.git)?$/);
|
205
|
+
if (sshAltMatch) {
|
206
|
+
const [, domain, , owner, repo] = sshAltMatch;
|
207
|
+
return {
|
208
|
+
domain,
|
209
|
+
slug: `${owner}/${repo}`,
|
210
|
+
};
|
211
|
+
}
|
212
|
+
return null;
|
182
213
|
}
|
183
|
-
|
184
|
-
* This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
|
185
|
-
*/
|
186
|
-
function getGithubSlugOrNull() {
|
214
|
+
function getVcsRemoteInfo() {
|
187
215
|
try {
|
188
|
-
const gitRemote =
|
189
|
-
|
216
|
+
const gitRemote = (0, child_process_1.execSync)('git remote -v', {
|
217
|
+
stdio: 'pipe',
|
218
|
+
windowsHide: false,
|
219
|
+
})
|
220
|
+
.toString()
|
221
|
+
.trim();
|
190
222
|
if (!gitRemote || gitRemote.length === 0) {
|
191
|
-
return
|
223
|
+
return null;
|
192
224
|
}
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
foundRemotes[remoteName] = url;
|
210
|
-
if (!firstGitHubUrl) {
|
211
|
-
firstGitHubUrl = url;
|
225
|
+
const lines = gitRemote.split('\n').filter((line) => line.trim());
|
226
|
+
const remotesPriority = ['origin', 'upstream', 'base'];
|
227
|
+
const foundRemotes = {};
|
228
|
+
let firstRemote = null;
|
229
|
+
for (const line of lines) {
|
230
|
+
const match = line.trim().match(/^(\w+)\s+(\S+)\s+\((fetch|push)\)$/);
|
231
|
+
if (match) {
|
232
|
+
const [, remoteName, url] = match;
|
233
|
+
const remoteInfo = parseVcsRemoteUrl(url);
|
234
|
+
if (remoteInfo && !foundRemotes[remoteName]) {
|
235
|
+
foundRemotes[remoteName] = remoteInfo;
|
236
|
+
if (!firstRemote) {
|
237
|
+
firstRemote = remoteInfo;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
212
241
|
}
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
242
|
+
// Return high-priority remote if found
|
243
|
+
for (const remote of remotesPriority) {
|
244
|
+
if (foundRemotes[remote]) {
|
245
|
+
return foundRemotes[remote];
|
246
|
+
}
|
217
247
|
}
|
248
|
+
// Return first found remote
|
249
|
+
return firstRemote;
|
218
250
|
}
|
219
|
-
|
220
|
-
|
221
|
-
function parseGitHubUrl(url) {
|
222
|
-
const sshPattern = /git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\.git/;
|
223
|
-
const httpsPattern = /https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\.git/;
|
224
|
-
let match = url.match(sshPattern) || url.match(httpsPattern);
|
225
|
-
if (match) {
|
226
|
-
return `${match[1]}/${match[2]}`;
|
251
|
+
catch (e) {
|
252
|
+
return null;
|
227
253
|
}
|
228
|
-
return null;
|
229
254
|
}
|
230
255
|
function commitChanges(commitMessage, directory) {
|
231
256
|
try {
|