@bobfrankston/npmglobalize 1.0.85 → 1.0.86
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/.claude/settings.local.json +10 -1
- package/lib.js +54 -2
- package/package.json +1 -1
|
@@ -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()));
|
|
@@ -1277,6 +1308,27 @@ export async function initGit(cwd, visibility, dryRun) {
|
|
|
1277
1308
|
console.log(` [dry-run] Would run: gh repo create ${repoName} --${visibility} --source=. --push`);
|
|
1278
1309
|
return true;
|
|
1279
1310
|
}
|
|
1311
|
+
// Check for dubious ownership before proceeding
|
|
1312
|
+
const ownerCheck = spawnSync('git', ['rev-parse', '--git-dir'], {
|
|
1313
|
+
encoding: 'utf-8',
|
|
1314
|
+
stdio: 'pipe',
|
|
1315
|
+
cwd
|
|
1316
|
+
});
|
|
1317
|
+
if (ownerCheck.stderr && ownerCheck.stderr.includes('dubious ownership')) {
|
|
1318
|
+
console.log(colors.yellow('Git "dubious ownership" error — directory owner SID differs from current user.'));
|
|
1319
|
+
console.log(colors.yellow('Adding safe.directory \'*\' to global git config...'));
|
|
1320
|
+
const fix = spawnSync('git', ['config', '--global', '--add', 'safe.directory', '*'], {
|
|
1321
|
+
encoding: 'utf-8',
|
|
1322
|
+
stdio: 'pipe',
|
|
1323
|
+
shell: true
|
|
1324
|
+
});
|
|
1325
|
+
if (fix.status === 0) {
|
|
1326
|
+
console.log(colors.green(' ✓ Fixed git safe.directory'));
|
|
1327
|
+
}
|
|
1328
|
+
else {
|
|
1329
|
+
throw new Error('Failed to fix git safe.directory. Run manually: git config --global --add safe.directory \'*\'');
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1280
1332
|
// Ensure .gitignore exists and includes node_modules
|
|
1281
1333
|
ensureGitignore(cwd);
|
|
1282
1334
|
// Ensure .npmignore exists with recommended patterns
|
|
@@ -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 });
|