create-nx-workspace
Advanced tools
Comparing version 19.6.0-canary.20240724-684d2a9 to 19.6.0-canary.20240725-3890edc
{ | ||
"name": "create-nx-workspace", | ||
"version": "19.6.0-canary.20240724-684d2a9", | ||
"version": "19.6.0-canary.20240725-3890edc", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Smart Monorepos · Fast CI", |
@@ -6,1 +6,2 @@ import { CreateWorkspaceOptions } from './create-workspace-options'; | ||
}>; | ||
export declare function extractConnectUrl(text: string): string | null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createWorkspace = createWorkspace; | ||
exports.extractConnectUrl = extractConnectUrl; | ||
const output_1 = require("./utils/output"); | ||
@@ -28,7 +29,16 @@ const nx_cloud_1 = require("./utils/nx/nx-cloud"); | ||
} | ||
let gitSuccess = false; | ||
if (!skipGit && commit) { | ||
let nxCloudInstallRes; | ||
if (nxCloud !== 'skip') { | ||
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub); | ||
if (nxCloud !== 'yes') { | ||
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0); | ||
} | ||
} | ||
if (!skipGit) { | ||
try { | ||
await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit }); | ||
gitSuccess = true; | ||
let connectUrl; | ||
if (nxCloudInstallRes?.code === 0) { | ||
connectUrl = extractConnectUrl(nxCloudInstallRes?.stdout); | ||
} | ||
await (0, git_1.initializeGitRepo)(directory, { defaultBase, commit, connectUrl }); | ||
} | ||
@@ -47,12 +57,2 @@ catch (e) { | ||
} | ||
let nxCloudInstallRes; | ||
if (nxCloud !== 'skip') { | ||
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub); | ||
if (nxCloud !== 'yes') { | ||
const nxCIsetupRes = await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0); | ||
if (nxCIsetupRes?.code === 0) { | ||
(0, git_1.commitChanges)(directory, `feat(nx): Generated CI workflow`); | ||
} | ||
} | ||
} | ||
return { | ||
@@ -63,1 +63,6 @@ nxCloudInfo: nxCloudInstallRes?.stdout, | ||
} | ||
function extractConnectUrl(text) { | ||
const urlPattern = /(https:\/\/[^\s]+\/connect\/[^\s]+)/g; | ||
const match = text.match(urlPattern); | ||
return match ? match[0] : null; | ||
} |
@@ -9,3 +9,3 @@ export declare function checkGitVersion(): string | null | undefined; | ||
}; | ||
connectUrl?: string | null; | ||
}): Promise<void>; | ||
export declare function commitChanges(directory: string, message: string): void; |
@@ -5,3 +5,2 @@ "use strict"; | ||
exports.initializeGitRepo = initializeGitRepo; | ||
exports.commitChanges = commitChanges; | ||
const child_process_1 = require("child_process"); | ||
@@ -76,21 +75,14 @@ const default_base_1 = require("./default-base"); | ||
if (options.commit) { | ||
const message = options.commit.message || 'initial commit'; | ||
let message = `${options.commit.message}` || 'initial commit'; | ||
if (options.connectUrl) { | ||
message = `${message} | ||
To connect your workspace to Nx Cloud, push your repository | ||
to your git hosting provider and go to the following URL: | ||
${options.connectUrl} | ||
`; | ||
} | ||
await execute(['commit', `-m "${message}"`]); | ||
} | ||
} | ||
function commitChanges(directory, message) { | ||
try { | ||
(0, child_process_1.execSync)('git add -A', { encoding: 'utf8', stdio: 'pipe', cwd: directory }); | ||
(0, child_process_1.execSync)('git commit --no-verify -F -', { | ||
encoding: 'utf8', | ||
stdio: 'pipe', | ||
input: message, | ||
cwd: directory, | ||
}); | ||
} | ||
catch (e) { | ||
console.error(`There was an error committing your Nx Cloud token.\n | ||
Please commit the changes manually and push to your new repository.\n | ||
\n${e}`); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107234
2900