@bobfrankston/npmglobalize 1.0.71 → 1.0.72

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 (3) hide show
  1. package/lib.d.ts +1 -1
  2. package/lib.js +16 -18
  3. package/package.json +1 -1
package/lib.d.ts CHANGED
@@ -35,7 +35,7 @@ export interface GlobalizeOptions {
35
35
  init?: boolean;
36
36
  /** Git visibility: private (default) or public */
37
37
  gitVisibility?: 'private' | 'public';
38
- /** npm visibility: public (default) or private */
38
+ /** npm visibility: private (default) or public */
39
39
  npmVisibility?: 'private' | 'public';
40
40
  /** Custom commit message */
41
41
  message?: string;
package/lib.js CHANGED
@@ -240,31 +240,29 @@ export function checkNpmAccess(packageName) {
240
240
  try {
241
241
  // For scoped packages, use npm access to check actual access level
242
242
  if (packageName.startsWith('@')) {
243
- const accessResult = spawnSync('npm', ['access', 'list', 'packages', packageName], {
244
- encoding: 'utf-8',
245
- stdio: 'pipe',
246
- shell: true
247
- });
248
- if (accessResult.status === 0 && accessResult.stdout) {
249
- const output = accessResult.stdout.trim();
250
- // Output format: "package-name": "read-write" or "read-only"
251
- // For public packages, this works without auth
252
- if (output.includes('read-write') || output.includes('read-only')) {
253
- return 'public';
254
- }
255
- }
256
- // If npm access fails or returns empty, try npm view as fallback
257
- // If npm view succeeds without auth, package is public
243
+ // First check if the package actually exists on npm
244
+ // npm access returns read-write for unpublished packages in owned scopes
258
245
  const viewResult = spawnSync('npm', ['view', packageName, 'name'], {
259
246
  encoding: 'utf-8',
260
247
  stdio: 'pipe',
261
248
  shell: true
262
249
  });
263
250
  if (viewResult.status === 0 && viewResult.stdout && viewResult.stdout.trim()) {
264
- // Package is viewable without auth = public
265
- return 'public';
251
+ // Package exists - now check access level
252
+ const accessResult = spawnSync('npm', ['access', 'list', 'packages', packageName], {
253
+ encoding: 'utf-8',
254
+ stdio: 'pipe',
255
+ shell: true
256
+ });
257
+ if (accessResult.status === 0 && accessResult.stdout) {
258
+ const output = accessResult.stdout.trim();
259
+ if (output.includes('read-write') || output.includes('read-only')) {
260
+ return 'public';
261
+ }
262
+ }
263
+ return 'restricted'; // Exists but not publicly accessible
266
264
  }
267
- // Package exists but not viewable = restricted, or doesn't exist
265
+ // Package not viewable - check if it's restricted or unpublished
268
266
  const checkResult = spawnSync('npm', ['view', packageName, '--json'], {
269
267
  encoding: 'utf-8',
270
268
  stdio: 'pipe',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",