@bobfrankston/npmglobalize 1.0.123 → 1.0.124
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/lib.d.ts +2 -0
- package/lib.js +25 -21
- package/package.json +1 -1
package/lib.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ export interface GlobalizeOptions {
|
|
|
78
78
|
local?: boolean;
|
|
79
79
|
/** Freeze node_modules: replace symlinks/junctions with real copies for network share use */
|
|
80
80
|
freeze?: boolean;
|
|
81
|
+
/** Internal: auto-initialize git repos without prompting (user chose "all") */
|
|
82
|
+
autoInit?: boolean;
|
|
81
83
|
/** Internal: signals this call is from workspace orchestrator */
|
|
82
84
|
_fromWorkspace?: boolean;
|
|
83
85
|
/** Internal: signals this call is from CLI (version already printed) */
|
package/lib.js
CHANGED
|
@@ -2379,8 +2379,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2379
2379
|
if (dryRun) {
|
|
2380
2380
|
console.log(' [dry-run] Would initialize git repository');
|
|
2381
2381
|
}
|
|
2382
|
-
else if (!init) {
|
|
2383
|
-
const choice = await promptChoice('No git repository found. What would you like to do?\n 1) Initialize git repository (default)\n 2) Use local install only (skip git/publish)\n 3) Abort\nChoice:', ['1', '2', '3', '']);
|
|
2382
|
+
else if (!init && !options.autoInit) {
|
|
2383
|
+
const choice = await promptChoice('No git repository found. What would you like to do?\n 1) Initialize git repository (default)\n a) Initialize ALL (don\'t ask again for remaining deps)\n 2) Use local install only (skip git/publish)\n 3) Abort\nChoice:', ['1', 'a', '2', '3', '']);
|
|
2384
2384
|
if (choice === '2') {
|
|
2385
2385
|
console.log(colors.dim('Switching to local-only mode...'));
|
|
2386
2386
|
writeConfig(cwd, { ...configOptions, local: true }, new Set(['local']));
|
|
@@ -2390,7 +2390,10 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2390
2390
|
console.log('Aborted. Run with --init to initialize.');
|
|
2391
2391
|
return false;
|
|
2392
2392
|
}
|
|
2393
|
-
|
|
2393
|
+
if (choice === 'a') {
|
|
2394
|
+
options.autoInit = true;
|
|
2395
|
+
}
|
|
2396
|
+
// choice is '1', 'a', or '' (default)
|
|
2394
2397
|
const success = await initGit(cwd, gitVisibility, dryRun);
|
|
2395
2398
|
if (!success)
|
|
2396
2399
|
return false;
|
|
@@ -2405,8 +2408,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2405
2408
|
}
|
|
2406
2409
|
else if (!gitStatus.hasRemote) {
|
|
2407
2410
|
// Git repo exists but no remote - need to create GitHub repo
|
|
2408
|
-
if (!init) {
|
|
2409
|
-
const choice = await promptChoice('No git remote configured. What would you like to do?\n 1) Create GitHub repository (default)\n 2) Use local install only (skip git/publish)\n 3) Abort\nChoice:', ['1', '2', '3', '']);
|
|
2411
|
+
if (!init && !options.autoInit) {
|
|
2412
|
+
const choice = await promptChoice('No git remote configured. What would you like to do?\n 1) Create GitHub repository (default)\n a) Initialize ALL (don\'t ask again for remaining deps)\n 2) Use local install only (skip git/publish)\n 3) Abort\nChoice:', ['1', 'a', '2', '3', '']);
|
|
2410
2413
|
if (choice === '2') {
|
|
2411
2414
|
console.log(colors.dim('Switching to local-only mode...'));
|
|
2412
2415
|
writeConfig(cwd, { ...configOptions, local: true }, new Set(['local']));
|
|
@@ -2416,6 +2419,9 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2416
2419
|
console.log('Aborted. Run with --init to set up GitHub repository.');
|
|
2417
2420
|
return false;
|
|
2418
2421
|
}
|
|
2422
|
+
if (choice === 'a') {
|
|
2423
|
+
options.autoInit = true;
|
|
2424
|
+
}
|
|
2419
2425
|
}
|
|
2420
2426
|
const success = await initGit(cwd, gitVisibility, dryRun);
|
|
2421
2427
|
if (!success)
|
|
@@ -2959,7 +2965,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2959
2965
|
conform, // Propagate conform to dependencies
|
|
2960
2966
|
publishDeps, // Propagate so transitive deps also get published
|
|
2961
2967
|
forcePublish, // Propagate so transitive deps get force-published too
|
|
2962
|
-
rebase // Propagate so behind-remote deps get rebased automatically
|
|
2968
|
+
rebase, // Propagate so behind-remote deps get rebased automatically
|
|
2969
|
+
autoInit: options.autoInit // Propagate "init all" choice
|
|
2963
2970
|
});
|
|
2964
2971
|
if (!depSuccess) {
|
|
2965
2972
|
console.error(colors.red(`Failed to publish ${name}`));
|
|
@@ -2997,13 +3004,12 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2997
3004
|
else if (!alreadyTransformed && verbose) {
|
|
2998
3005
|
console.log(' No file: dependencies found.');
|
|
2999
3006
|
}
|
|
3000
|
-
// Hoist workspace sub-package deps into root for
|
|
3001
|
-
// npm install -g
|
|
3002
|
-
//
|
|
3003
|
-
//
|
|
3004
|
-
//
|
|
3005
|
-
//
|
|
3006
|
-
// All changes are temporary — restoreDeps removes them via .dependencies backup.
|
|
3007
|
+
// Hoist workspace sub-package third-party deps into root for global install.
|
|
3008
|
+
// npm install -g from local handles workspace linking, but third-party deps
|
|
3009
|
+
// (express, ws, etc.) in sub-packages must also be in root dependencies
|
|
3010
|
+
// so they get installed. Workspace sibling refs are skipped — npm install -g .
|
|
3011
|
+
// handles those via workspace linking.
|
|
3012
|
+
// Changes are temporary — restoreDeps removes them via .dependencies backup.
|
|
3007
3013
|
if (pkg.workspaces) {
|
|
3008
3014
|
const wsPatterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces.packages || [];
|
|
3009
3015
|
// Collect all workspace sub-package dirs
|
|
@@ -3024,8 +3030,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3024
3030
|
wsDirs.push(dir);
|
|
3025
3031
|
}
|
|
3026
3032
|
}
|
|
3027
|
-
// Collect workspace package names
|
|
3028
|
-
const
|
|
3033
|
+
// Collect workspace package names (to skip as siblings)
|
|
3034
|
+
const wsNames = new Set();
|
|
3029
3035
|
for (const dir of wsDirs) {
|
|
3030
3036
|
const pkgJsonPath = path.join(dir, 'package.json');
|
|
3031
3037
|
if (!fs.existsSync(pkgJsonPath))
|
|
@@ -3033,7 +3039,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3033
3039
|
try {
|
|
3034
3040
|
const subPkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
3035
3041
|
if (subPkg.name)
|
|
3036
|
-
|
|
3042
|
+
wsNames.add(subPkg.name);
|
|
3037
3043
|
}
|
|
3038
3044
|
catch { /* skip */ }
|
|
3039
3045
|
}
|
|
@@ -3053,8 +3059,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3053
3059
|
}
|
|
3054
3060
|
const deps = subPkg.dependencies || {};
|
|
3055
3061
|
for (const [dep, ver] of Object.entries(deps)) {
|
|
3056
|
-
if (
|
|
3057
|
-
continue; // sibling workspace — handled
|
|
3062
|
+
if (wsNames.has(dep))
|
|
3063
|
+
continue; // sibling workspace — handled by npm install -g .
|
|
3058
3064
|
if (dep in rootDeps)
|
|
3059
3065
|
continue; // already in root
|
|
3060
3066
|
if (hoisted.some(m => m.dep === dep))
|
|
@@ -3062,8 +3068,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3062
3068
|
hoisted.push({ dep, version: ver, from: subPkg.name || path.basename(dir) });
|
|
3063
3069
|
}
|
|
3064
3070
|
}
|
|
3065
|
-
|
|
3066
|
-
if (needsUpdate) {
|
|
3071
|
+
if (hoisted.length > 0) {
|
|
3067
3072
|
// Ensure .dependencies backup exists so restoreDeps will remove hoisted deps
|
|
3068
3073
|
if (!pkg['.dependencies']) {
|
|
3069
3074
|
pkg['.dependencies'] = { ...(pkg.dependencies || {}) };
|
|
@@ -3071,7 +3076,6 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3071
3076
|
}
|
|
3072
3077
|
if (!pkg.dependencies)
|
|
3073
3078
|
pkg.dependencies = {};
|
|
3074
|
-
// Hoist third-party deps
|
|
3075
3079
|
for (const m of hoisted) {
|
|
3076
3080
|
let version = m.version;
|
|
3077
3081
|
if (typeof version === 'string' && version.startsWith('file:')) {
|