@bobfrankston/npmglobalize 1.0.102 → 1.0.104

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.
@@ -38,7 +38,8 @@
38
38
  "Bash(globalize:*)",
39
39
  "Bash(wztest:*)",
40
40
  "Bash(xargs grep:*)",
41
- "Bash(cmd.exe:*)"
41
+ "Bash(cmd.exe:*)",
42
+ "Bash(cd y:/dev/utils/npmglobalize && npx npmglobalize)"
42
43
  ]
43
44
  }
44
45
  }
package/lib.js CHANGED
@@ -752,6 +752,47 @@ export function transformDeps(pkg, baseDir, verbose = false, forcePublish = fals
752
752
  }
753
753
  return { transformed, unpublished };
754
754
  }
755
+ /** Build and print a dependency tree of file: references.
756
+ * Recursively walks file: deps showing the full hierarchy with indentation. */
757
+ function printDepTree(baseDir, indent = 0, visited = new Set()) {
758
+ const realDir = fs.realpathSync(baseDir);
759
+ if (visited.has(realDir))
760
+ return;
761
+ visited.add(realDir);
762
+ let pkg;
763
+ try {
764
+ pkg = readPackageJson(baseDir);
765
+ }
766
+ catch {
767
+ return;
768
+ }
769
+ for (const key of DEP_KEYS) {
770
+ if (!pkg[key])
771
+ continue;
772
+ // Use the backup (.dependencies) if present — it has the original file: refs
773
+ const deps = pkg['.' + key] || pkg[key];
774
+ for (const [name, value] of Object.entries(deps)) {
775
+ if (!isFileRef(value))
776
+ continue;
777
+ const prefix = ' '.repeat(indent * 2);
778
+ let targetPath;
779
+ let version = '?';
780
+ try {
781
+ targetPath = resolveFilePath(value, baseDir);
782
+ const targetPkg = readPackageJson(targetPath);
783
+ version = targetPkg.version || '?';
784
+ }
785
+ catch {
786
+ console.log(`${prefix} ${name} → ${value} ${colors.red('(unresolvable)')}`);
787
+ continue;
788
+ }
789
+ const exists = checkVersionExists(name, version);
790
+ const marker = exists ? colors.green('✓') : colors.red('✗');
791
+ console.log(`${prefix} ${marker} ${name}@${version} → ${value}`);
792
+ printDepTree(targetPath, indent + 1, visited);
793
+ }
794
+ }
795
+ }
755
796
  /** Restore file: dependencies from .dependencies */
756
797
  export function restoreDeps(pkg, verbose = false) {
757
798
  let restored = false;
@@ -2508,13 +2549,16 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2508
2549
  console.log('');
2509
2550
  }
2510
2551
  // Check if target packages need to be published
2511
- if (transformResult.unpublished.length > 0) {
2552
+ if (transformResult.unpublished.length > 0 && !noPublish) {
2512
2553
  console.log('');
2513
2554
  console.log(colors.red('⚠ WARNING: Some file: dependencies are not published on npm:'));
2514
2555
  for (const { name, version, path } of transformResult.unpublished) {
2515
2556
  console.log(colors.yellow(` ${name}@${version} (${path})`));
2516
2557
  }
2517
2558
  console.log('');
2559
+ console.log('Dependency tree (✓ = on npm, ✗ = needs publishing):');
2560
+ printDepTree(cwd);
2561
+ console.log('');
2518
2562
  if (publishDeps) {
2519
2563
  const action = forcePublish ? 'Publishing/updating' : 'Publishing';
2520
2564
  console.log(`${action} file: dependencies first (--publish-deps)...`);
@@ -2539,7 +2583,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2539
2583
  fix,
2540
2584
  conform, // Propagate conform to dependencies
2541
2585
  publishDeps, // Propagate so transitive deps also get published
2542
- forcePublish // Propagate so transitive deps get force-published too
2586
+ forcePublish, // Propagate so transitive deps get force-published too
2587
+ rebase // Propagate so behind-remote deps get rebased automatically
2543
2588
  });
2544
2589
  if (!depSuccess) {
2545
2590
  console.error(colors.red(`Failed to publish ${name}`));
@@ -2560,6 +2605,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2560
2605
  console.log(colors.yellow(' 1. Publish them manually first'));
2561
2606
  console.log(colors.yellow(' 2. Use --publish-deps to publish them automatically'));
2562
2607
  console.log(colors.yellow(' 3. Use --force to continue anyway (NOT RECOMMENDED)'));
2608
+ console.log(colors.yellow(' 4. Use -npd (--no-publish-deps) to skip dependency publishing'));
2563
2609
  console.log('');
2564
2610
  if (!force) {
2565
2611
  const shouldContinue = await confirm('Continue with unpublished dependencies?', false);
@@ -2641,10 +2687,13 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2641
2687
  const pkgName = pkg.name;
2642
2688
  const pkgVersion = pkg.version;
2643
2689
  if (!pkg.bin && (install || link || wsl)) {
2644
- console.log(colors.yellow('Note: This is a library (no bin field), skipping global installation.'));
2645
- console.log(colors.yellow('To use in projects: npm install ' + pkgName));
2690
+ const proceed = await offerAddBin(cwd, pkg);
2691
+ if (!proceed) {
2692
+ console.log(colors.yellow('Skipping global install — library packages should not be installed globally.'));
2693
+ console.log(colors.yellow(`To use in projects: npm install ${pkgName}`));
2694
+ }
2646
2695
  }
2647
- else {
2696
+ if (pkg.bin && (install || link || wsl)) {
2648
2697
  if (link) {
2649
2698
  console.log(`Installing ${pkgName} globally from local directory (link)...`);
2650
2699
  const localInstallResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false });
@@ -3110,8 +3159,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
3110
3159
  return false;
3111
3160
  }
3112
3161
  // Determine what was published
3113
- const finalAccess = currentAccess || (isScoped ? 'restricted' : 'public');
3114
- const accessLabel = finalAccess === 'restricted' ? 'PRIVATE' : 'PUBLIC';
3162
+ const finalAccess = effectiveNpmVisibility || currentAccess || (isScoped ? 'restricted' : 'public');
3163
+ const accessLabel = (finalAccess === 'restricted' || finalAccess === 'private') ? 'PRIVATE' : 'PUBLIC';
3115
3164
  console.log(colors.green(`✓ Published to npm as ${accessLabel}`));
3116
3165
  }
3117
3166
  else {
@@ -3135,10 +3184,13 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
3135
3184
  const pkgName = updatedPkg.name;
3136
3185
  const pkgVersion = updatedPkg.version;
3137
3186
  if (!updatedPkg.bin && (install || link || wsl)) {
3138
- console.log(colors.yellow('Note: This is a library (no bin field), skipping global installation.'));
3139
- console.log(colors.yellow('To use in projects: npm install ' + pkgName));
3187
+ const proceed = await offerAddBin(cwd, updatedPkg);
3188
+ if (!proceed) {
3189
+ console.log(colors.yellow('Skipping global install — library packages should not be installed globally.'));
3190
+ console.log(colors.yellow(`To use in projects: npm install ${pkgName}`));
3191
+ }
3140
3192
  }
3141
- else {
3193
+ if (updatedPkg.bin && (install || link || wsl)) {
3142
3194
  if (link) {
3143
3195
  console.log(`Linking globally: ${pkgName}@${pkgVersion}...`);
3144
3196
  if (!dryRun) {
@@ -3221,8 +3273,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
3221
3273
  console.log(colors.green('✓ Release Summary'));
3222
3274
  console.log(colors.green('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
3223
3275
  const finalPkg = readPackageJson(cwd);
3224
- const finalAccess = currentAccess || (isScoped ? 'restricted' : 'public');
3225
- const accessLabel = finalAccess === 'restricted' ? 'PRIVATE' : 'PUBLIC';
3276
+ const finalAccess = effectiveNpmVisibility || currentAccess || (isScoped ? 'restricted' : 'public');
3277
+ const accessLabel = (finalAccess === 'restricted' || finalAccess === 'private') ? 'PRIVATE' : 'PUBLIC';
3226
3278
  console.log(` Package: ${colors.green(finalPkg.name)}`);
3227
3279
  console.log(` Version: ${colors.green('v' + finalPkg.version)}`);
3228
3280
  console.log(` Published: ${colors.green('✓')} (${accessLabel})`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.102",
3
+ "version": "1.0.104",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",