@bobfrankston/npmglobalize 1.0.85 → 1.0.87

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.
@@ -14,7 +14,16 @@
14
14
  "Bash(dir:*)",
15
15
  "Bash(findstr:*)",
16
16
  "Bash(npm access:*)",
17
- "Bash(gh repo view:*)"
17
+ "Bash(gh repo view:*)",
18
+ "Bash(npmglobalize)",
19
+ "Bash(kill:*)",
20
+ "Bash(test:*)",
21
+ "Bash(cmd.exe /c \"dir y:\\\\dev\\\\homecontrol\\\\utils\\\\addone /a\")",
22
+ "Bash(cmd.exe /c \"dir y:\\\\dev\\\\homecontrol\\\\utils\\\\addone\\\\*.* /a\")",
23
+ "Bash(wsl ls:*)",
24
+ "Bash(cmd.exe /c \"dir y:\\\\dev\\\\homecontrol\\\\utils\\\\addone /a /b\")",
25
+ "Bash(cmd.exe /c \"dir /a /b y:\\\\dev\\\\homecontrol\\\\utils\\\\addone\")",
26
+ "Bash(icacls:*)"
18
27
  ]
19
28
  }
20
29
  }
package/lib.js CHANGED
@@ -816,6 +816,37 @@ export function runCommandOrThrow(cmd, args, options = {}) {
816
816
  const stderr = result.stderr || '';
817
817
  const output = stdout + stderr;
818
818
  if (result.status !== 0) {
819
+ // Detect git safe.directory ownership issue and auto-fix
820
+ if (cmd === 'git' && stderr.includes('dubious ownership')) {
821
+ console.log(colors.yellow('Git "dubious ownership" error — directory owner SID differs from current user.'));
822
+ console.log(colors.yellow('Adding safe.directory \'*\' to global git config...'));
823
+ const fix = spawnSync('git', ['config', '--global', '--add', 'safe.directory', '*'], {
824
+ encoding: 'utf-8',
825
+ stdio: 'pipe',
826
+ shell: true
827
+ });
828
+ if (fix.status === 0) {
829
+ console.log(colors.green('✓ Fixed. Retrying...'));
830
+ // Retry the original command
831
+ const retry = spawnSync(cmd, args, {
832
+ encoding: 'utf-8',
833
+ stdio: 'pipe',
834
+ cwd: options.cwd,
835
+ env: process.env,
836
+ shell: needsShell
837
+ });
838
+ if (retry.status === 0) {
839
+ return (retry.stdout || '') + (retry.stderr || '');
840
+ }
841
+ // Retry also failed
842
+ const retryStderr = retry.stderr || '';
843
+ if (retryStderr.trim()) {
844
+ console.error(colors.red(retryStderr.trim()));
845
+ }
846
+ throw new Error(`Command failed after safe.directory fix: ${cmd} ${args.join(' ')}`);
847
+ }
848
+ throw new Error('Failed to add safe.directory to git config.');
849
+ }
819
850
  // Show the error output
820
851
  if (stderr.trim()) {
821
852
  console.error(colors.red(stderr.trim()));
@@ -1285,6 +1316,27 @@ export async function initGit(cwd, visibility, dryRun) {
1285
1316
  ensureGitattributes(cwd);
1286
1317
  // git init
1287
1318
  runCommandOrThrow('git', ['init'], { cwd });
1319
+ // Check for dubious ownership (git init succeeds but subsequent commands fail)
1320
+ const ownerCheck = spawnSync('git', ['rev-parse', '--git-dir'], {
1321
+ encoding: 'utf-8',
1322
+ stdio: 'pipe',
1323
+ cwd
1324
+ });
1325
+ if (ownerCheck.stderr && ownerCheck.stderr.includes('dubious ownership')) {
1326
+ console.log(colors.yellow('Git "dubious ownership" error — directory owner SID differs from current user.'));
1327
+ console.log(colors.yellow('Adding safe.directory \'*\' to global git config...'));
1328
+ const fix = spawnSync('git', ['config', '--global', '--add', 'safe.directory', '*'], {
1329
+ encoding: 'utf-8',
1330
+ stdio: 'pipe',
1331
+ shell: true
1332
+ });
1333
+ if (fix.status === 0) {
1334
+ console.log(colors.green(' ✓ Fixed git safe.directory'));
1335
+ }
1336
+ else {
1337
+ throw new Error('Failed to fix git safe.directory. Run manually: git config --global --add safe.directory \'*\'');
1338
+ }
1339
+ }
1288
1340
  // Configure git for LF line endings (per programming.md)
1289
1341
  runCommandOrThrow('git', ['config', 'core.autocrlf', 'false'], { cwd });
1290
1342
  runCommandOrThrow('git', ['config', 'core.eol', 'lf'], { cwd });
@@ -1693,8 +1745,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
1693
1745
  }
1694
1746
  // Read package.json
1695
1747
  const pkg = readPackageJson(cwd);
1696
- // Run build step if package.json has a build script
1697
- if (pkg.scripts?.build) {
1748
+ // Run build step if package.json has a build script (skip if CLI already built)
1749
+ if (pkg.scripts?.build && !options._fromCli) {
1698
1750
  console.log('Running build...');
1699
1751
  if (!dryRun) {
1700
1752
  const buildResult = runCommand('npm', ['run', 'build'], { cwd, silent: !verbose });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",