create-nx-workspace
Advanced tools
Comparing version 0.0.0-pr-29464-c4b160c to 0.0.0-pr-29464-ce11848
@@ -193,3 +193,3 @@ "use strict"; | ||
? undefined | ||
: nxCloud === 'github' || (await (0, prompts_1.determineIfGitHubWillBeUsed)(nxCloud)); | ||
: nxCloud === 'github' || (await (0, prompts_1.determineIfGitHubWillBeUsed)(argv)); | ||
Object.assign(argv, { | ||
@@ -196,0 +196,0 @@ nxCloud, |
{ | ||
"name": "create-nx-workspace", | ||
"version": "0.0.0-pr-29464-c4b160c", | ||
"version": "0.0.0-pr-29464-ce11848", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Smart Monorepos · Fast CI", |
@@ -7,3 +7,6 @@ import * as yargs from 'yargs'; | ||
}>): Promise<NxCloud>; | ||
export declare function determineIfGitHubWillBeUsed(nxCloud: NxCloud): Promise<boolean>; | ||
export declare function determineIfGitHubWillBeUsed(parsedArgs: yargs.Arguments<{ | ||
nxCloud: NxCloud; | ||
useGitHub?: boolean; | ||
}>): Promise<boolean>; | ||
export declare function determineDefaultBase(parsedArgs: yargs.Arguments<{ | ||
@@ -10,0 +13,0 @@ defaultBase?: string; |
@@ -26,4 +26,6 @@ "use strict"; | ||
} | ||
async function determineIfGitHubWillBeUsed(nxCloud) { | ||
if (nxCloud === 'yes' || nxCloud === 'circleci') { | ||
async function determineIfGitHubWillBeUsed(parsedArgs) { | ||
if (parsedArgs.nxCloud === 'yes' || parsedArgs.nxCloud === 'circleci') { | ||
if (parsedArgs?.useGitHub) | ||
return true; | ||
const reply = await enquirer.prompt([ | ||
@@ -30,0 +32,0 @@ { |
export type NxCloud = 'yes' | 'github' | 'gitlab' | 'azure' | 'bitbucket-pipelines' | 'circleci' | 'skip'; | ||
export declare function readNxCloudToken(directory: string): string | undefined; | ||
export declare function getOnboardingInfo(nxCloud: NxCloud, token: string, directory: string, useGithub?: boolean): Promise<{ | ||
export declare function getOnboardingInfo(nxCloud: NxCloud, token: string, directory: string, useGitHub?: boolean): Promise<{ | ||
output: string; | ||
connectCloudUrl: string; | ||
}>; |
@@ -20,3 +20,3 @@ "use strict"; | ||
} | ||
async function getOnboardingInfo(nxCloud, token, directory, useGithub) { | ||
async function getOnboardingInfo(nxCloud, token, directory, useGitHub) { | ||
// nx-ignore-next-line | ||
@@ -32,3 +32,3 @@ const { createNxCloudOnboardingURL } = require(require.resolve('nx/src/nx-cloud/utilities/url-shorten', { | ||
const { code, createMessage } = (0, messages_1.getMessageFactory)(source); | ||
const connectCloudUrl = await createNxCloudOnboardingURL(source, token, useGithub ?? | ||
const connectCloudUrl = await createNxCloudOnboardingURL(source, token, useGitHub ?? | ||
(nxCloud === 'yes' || nxCloud === 'github' || nxCloud === 'circleci'), code); | ||
@@ -35,0 +35,0 @@ const out = new output_1.CLIOutput(false); |
@@ -31,2 +31,3 @@ export declare const packageManagerList: readonly ["pnpm", "yarn", "npm", "bun"]; | ||
* - yarn create returns 'yarn' | ||
* - bunx returns 'bun' | ||
* | ||
@@ -33,0 +34,0 @@ * Default to 'npm' |
@@ -9,5 +9,5 @@ "use strict"; | ||
exports.detectInvokedPackageManager = detectInvokedPackageManager; | ||
const child_process_1 = require("child_process"); | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const node_child_process_1 = require("node:child_process"); | ||
const node_fs_1 = require("node:fs"); | ||
const node_path_1 = require("node:path"); | ||
/* | ||
@@ -19,7 +19,7 @@ * Because we don't want to depend on @nx/workspace (to speed up the workspace creation) | ||
function detectPackageManager(dir = '') { | ||
return (0, fs_1.existsSync)((0, path_1.join)(dir, 'bun.lockb')) | ||
return (0, node_fs_1.existsSync)((0, node_path_1.join)(dir, 'bun.lockb')) || (0, node_fs_1.existsSync)((0, node_path_1.join)(dir, 'bun.lock')) | ||
? 'bun' | ||
: (0, fs_1.existsSync)((0, path_1.join)(dir, 'yarn.lock')) | ||
: (0, node_fs_1.existsSync)((0, node_path_1.join)(dir, 'yarn.lock')) | ||
? 'yarn' | ||
: (0, fs_1.existsSync)((0, path_1.join)(dir, 'pnpm-lock.yaml')) | ||
: (0, node_fs_1.existsSync)((0, node_path_1.join)(dir, 'pnpm-lock.yaml')) | ||
? 'pnpm' | ||
@@ -78,3 +78,3 @@ : 'npm'; | ||
case 'bun': | ||
// bun doesn't current support programatically reading config https://github.com/oven-sh/bun/issues/7140 | ||
// bun doesn't current support programmatically reading config https://github.com/oven-sh/bun/issues/7140 | ||
return { | ||
@@ -92,5 +92,5 @@ install: 'bun install --silent --ignore-scripts', | ||
if (+pmMajor >= 2) { | ||
(0, fs_1.writeFileSync)((0, path_1.join)(root, '.yarnrc.yml'), 'nodeLinker: node-modules\nenableScripts: false'); | ||
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, '.yarnrc.yml'), 'nodeLinker: node-modules\nenableScripts: false'); | ||
// avoids errors when using nested yarn projects | ||
(0, fs_1.writeFileSync)((0, path_1.join)(root, 'yarn.lock'), ''); | ||
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, 'yarn.lock'), ''); | ||
} | ||
@@ -105,3 +105,3 @@ break; | ||
} | ||
const version = (0, child_process_1.execSync)(`${packageManager} --version`, { | ||
const version = (0, node_child_process_1.execSync)(`${packageManager} --version`, { | ||
cwd, | ||
@@ -120,2 +120,3 @@ encoding: 'utf-8', | ||
* - yarn create returns 'yarn' | ||
* - bunx returns 'bun' | ||
* | ||
@@ -125,16 +126,17 @@ * Default to 'npm' | ||
function detectInvokedPackageManager() { | ||
let detectedPackageManager = 'npm'; | ||
// mainModule is deprecated since Node 14, fallback for older versions | ||
const invoker = require.main || process['mainModule']; | ||
// default to `npm` | ||
if (!invoker) { | ||
return detectedPackageManager; | ||
if (process.env.npm_config_user_agent) { | ||
for (const pm of exports.packageManagerList) { | ||
if (process.env.npm_config_user_agent.startsWith(`${pm}/`)) { | ||
return pm; | ||
} | ||
} | ||
} | ||
for (const pkgManager of exports.packageManagerList) { | ||
if (invoker.path.includes(pkgManager)) { | ||
detectedPackageManager = pkgManager; | ||
break; | ||
if (process.env.npm_execpath) { | ||
for (const pm of exports.packageManagerList) { | ||
if (process.env.npm_execpath.split(node_path_1.sep).includes(pm)) { | ||
return pm; | ||
} | ||
} | ||
} | ||
return detectedPackageManager; | ||
return 'npm'; | ||
} |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
114828
3138
3
20