create-nx-workspace
Advanced tools
Comparing version 0.0.0-pr-3-0b96150 to 0.0.0-pr-3-16b3273
@@ -324,3 +324,3 @@ "use strict"; | ||
} | ||
async function determineFormatterOptions(args) { | ||
async function determineFormatterOptions(args, opts) { | ||
if (args.formatter) | ||
@@ -341,3 +341,3 @@ return args.formatter; | ||
], | ||
initial: 1, | ||
initial: opts?.preferPrettier ? 0 : 1, | ||
skip: !args.interactive || (0, is_ci_1.isCI)(), | ||
@@ -348,3 +348,3 @@ }, | ||
} | ||
async function determineLinterOptions(args) { | ||
async function determineLinterOptions(args, opts) { | ||
const reply = await enquirer.prompt([ | ||
@@ -363,3 +363,3 @@ { | ||
], | ||
initial: 1, | ||
initial: opts?.preferEslint ? 0 : 1, | ||
skip: !args.interactive || (0, is_ci_1.isCI)(), | ||
@@ -572,4 +572,6 @@ }, | ||
if (workspaces) { | ||
linter = await determineLinterOptions(parsedArgs); | ||
formatter = await determineFormatterOptions(parsedArgs); | ||
linter = await determineLinterOptions(parsedArgs, { preferEslint: true }); | ||
formatter = await determineFormatterOptions(parsedArgs, { | ||
preferPrettier: true, | ||
}); | ||
} | ||
@@ -678,4 +680,6 @@ else { | ||
if (workspaces) { | ||
linter = await determineLinterOptions(parsedArgs); | ||
formatter = await determineFormatterOptions(parsedArgs); | ||
linter = await determineLinterOptions(parsedArgs, { preferEslint: true }); | ||
formatter = await determineFormatterOptions(parsedArgs, { | ||
preferPrettier: true, | ||
}); | ||
} | ||
@@ -916,4 +920,6 @@ else { | ||
if (workspaces) { | ||
linter = await determineLinterOptions(parsedArgs); | ||
formatter = await determineFormatterOptions(parsedArgs); | ||
linter = await determineLinterOptions(parsedArgs, { preferEslint: true }); | ||
formatter = await determineFormatterOptions(parsedArgs, { | ||
preferPrettier: true, | ||
}); | ||
} | ||
@@ -1208,5 +1214,5 @@ else { | ||
if (a.name === 'none') | ||
return 1; | ||
if (b.name === 'none') | ||
return -1; | ||
if (b.name === 'none') | ||
return 1; | ||
if (options?.preferVitest && a.name === 'vitest') | ||
@@ -1218,3 +1224,3 @@ return -1; | ||
}), | ||
initial: 0, | ||
initial: 0, // This should be either vite or jest | ||
}, | ||
@@ -1221,0 +1227,0 @@ ]); |
{ | ||
"name": "create-nx-workspace", | ||
"version": "0.0.0-pr-3-0b96150", | ||
"version": "0.0.0-pr-3-16b3273", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Smart Monorepos · Fast CI", |
@@ -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
114679
3133
3
20