@bobfrankston/npmglobalize 1.0.104 → 1.0.105

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.
Files changed (2) hide show
  1. package/lib.js +88 -13
  2. package/package.json +1 -1
package/lib.js CHANGED
@@ -2349,12 +2349,22 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2349
2349
  }
2350
2350
  }
2351
2351
  if (currentAccess === 'public') {
2352
- console.error(colors.red(`ERROR: Package '${pkg.name}' is currently PUBLIC on npm.`));
2353
- console.error(colors.red(`Cannot change to private. Options:`));
2354
- console.error(colors.yellow(` 1. Deprecate the public package: npm deprecate ${pkg.name} "moved to private"`));
2355
- console.error(colors.yellow(` 2. Continue as public: npmglobalize --npm public`));
2356
- console.error(colors.yellow(` 3. Use a different package name`));
2357
- return false;
2352
+ console.log(colors.yellow(`Package '${pkg.name}' is currently PUBLIC on npm. Converting to private...`));
2353
+ if (!dryRun) {
2354
+ const accessResult = runCommand('npm', ['access', 'set', 'status=restricted', pkg.name], { cwd, silent: false });
2355
+ if (accessResult.success) {
2356
+ console.log(colors.green(`✓ Changed ${pkg.name} to PRIVATE on npm`));
2357
+ currentAccess = 'restricted';
2358
+ }
2359
+ else {
2360
+ console.error(colors.red(`Failed to change access. Try manually: npm access set status=restricted ${pkg.name}`));
2361
+ if (!force)
2362
+ return false;
2363
+ }
2364
+ }
2365
+ else {
2366
+ console.log(colors.dim(` [dry-run] Would run: npm access set status=restricted ${pkg.name}`));
2367
+ }
2358
2368
  }
2359
2369
  // Don't set "private": true in package.json - that blocks all publishing
2360
2370
  console.log(`Package '${pkg.name}' will publish as PRIVATE (restricted access).`);
@@ -2365,12 +2375,22 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2365
2375
  else if (effectiveNpmVisibility === 'public') {
2366
2376
  // User explicitly wants public (or confirmed via prompt)
2367
2377
  if (currentAccess === 'restricted') {
2368
- console.error(colors.red(`ERROR: Package '${pkg.name}' is currently PRIVATE on npm.`));
2369
- console.error(colors.red(`Cannot change to public. Options:`));
2370
- console.error(colors.yellow(` 1. Unpublish and republish: npm unpublish ${pkg.name} --force`));
2371
- console.error(colors.yellow(` 2. Continue as private: npmglobalize --npm private`));
2372
- console.error(colors.yellow(` 3. Use a different package name`));
2373
- return false;
2378
+ console.log(colors.yellow(`Package '${pkg.name}' is currently PRIVATE on npm. Converting to public...`));
2379
+ if (!dryRun) {
2380
+ const accessResult = runCommand('npm', ['access', 'set', 'status=public', pkg.name], { cwd, silent: false });
2381
+ if (accessResult.success) {
2382
+ console.log(colors.green(`✓ Changed ${pkg.name} to PUBLIC on npm`));
2383
+ currentAccess = 'public';
2384
+ }
2385
+ else {
2386
+ console.error(colors.red(`Failed to change access. Try manually: npm access set status=public ${pkg.name}`));
2387
+ if (!force)
2388
+ return false;
2389
+ }
2390
+ }
2391
+ else {
2392
+ console.log(colors.dim(` [dry-run] Would run: npm access set status=public ${pkg.name}`));
2393
+ }
2374
2394
  }
2375
2395
  if (!publicConfirmed) {
2376
2396
  console.log(`Will publish '${pkg.name}' to PUBLIC npm registry.`);
@@ -2677,7 +2697,16 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
2677
2697
  const isFirstPublish = !currentAccess;
2678
2698
  if (!currentGitStatus.hasUncommitted && !message && !justInitialized && !isFirstPublish) {
2679
2699
  console.log('');
2680
- console.log('No changes to commit and no custom message specified.');
2700
+ if (currentAccess === 'public') {
2701
+ console.log(`${pkg.name}@${pkg.version} is already PUBLIC on npm. No changes to publish.`);
2702
+ }
2703
+ else if (currentAccess === 'restricted') {
2704
+ console.log(`${pkg.name}@${pkg.version} is PRIVATE on npm. No changes to publish.`);
2705
+ }
2706
+ else {
2707
+ console.log('No changes to commit and no custom message specified.');
2708
+ }
2709
+ console.log(colors.dim(' Use -m "message" to force a version bump and republish.'));
2681
2710
  // If install/link flag is set, install globally
2682
2711
  if (install || link || wsl) {
2683
2712
  if (verbose) {
@@ -3357,6 +3386,52 @@ export async function globalizeWorkspace(rootDir, options = {}, configOptions =
3357
3386
  console.log(`Filtered to: ${filteredOrder.join(', ')}`);
3358
3387
  console.log('');
3359
3388
  }
3389
+ // Check for visibility mismatches: public packages depending on would-be-private siblings
3390
+ const visibilityMap = new Map();
3391
+ for (const pkgInfo of packages) {
3392
+ const pkgConfig = readConfig(pkgInfo.dir);
3393
+ const vis = pkgConfig.npmVisibility
3394
+ || pkgInfo.pkg.publishConfig?.access
3395
+ || options.npmVisibility; // CLI-level default
3396
+ if (vis === 'public') {
3397
+ visibilityMap.set(pkgInfo.name, 'public');
3398
+ }
3399
+ else if (pkgInfo.pkg.private) {
3400
+ visibilityMap.set(pkgInfo.name, 'private');
3401
+ }
3402
+ else {
3403
+ visibilityMap.set(pkgInfo.name, 'unknown');
3404
+ }
3405
+ }
3406
+ const wsNameSet = new Set(packages.map(p => p.name));
3407
+ for (const pkgInfo of packages) {
3408
+ if (visibilityMap.get(pkgInfo.name) !== 'public')
3409
+ continue;
3410
+ const deps = { ...pkgInfo.pkg.dependencies, ...pkgInfo.pkg.devDependencies };
3411
+ for (const depName of Object.keys(deps || {})) {
3412
+ if (!wsNameSet.has(depName))
3413
+ continue;
3414
+ if (visibilityMap.get(depName) === 'public')
3415
+ continue;
3416
+ const depInfo = packages.find(p => p.name === depName);
3417
+ if (!depInfo)
3418
+ continue;
3419
+ console.log(colors.yellow(`⚠ Public package ${pkgInfo.name} depends on ${depName} which has no public visibility set.`));
3420
+ if (!options.dryRun) {
3421
+ const makePublic = await confirm(`Make ${depName} public too?`, true);
3422
+ if (makePublic) {
3423
+ const depConfig = readConfig(depInfo.dir);
3424
+ depConfig.npmVisibility = 'public';
3425
+ writeConfig(depInfo.dir, depConfig, new Set(['npmVisibility']));
3426
+ visibilityMap.set(depName, 'public');
3427
+ console.log(colors.green(`✓ Set ${depName} to public in .globalize.json5`));
3428
+ }
3429
+ }
3430
+ else {
3431
+ console.log(colors.dim(` [dry-run] Would ask to make ${depName} public`));
3432
+ }
3433
+ }
3434
+ }
3360
3435
  // Process each package in dependency order
3361
3436
  const results = [];
3362
3437
  for (const pkgName of filteredOrder) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.104",
3
+ "version": "1.0.105",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",