@bobfrankston/npmglobalize 1.0.99 → 1.0.100
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/lib.js +59 -6
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -116,6 +116,27 @@ function repairGitIndex(cwd) {
|
|
|
116
116
|
return false;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
/** Parse file paths from git add "Permission denied" / "unable to index file" errors.
|
|
120
|
+
* Matches lines like: error: open("data/PingDB.mdf"): Permission denied
|
|
121
|
+
* and: error: unable to index file 'data/PingDB.mdf' */
|
|
122
|
+
function parseDeniedFiles(errText) {
|
|
123
|
+
const files = [];
|
|
124
|
+
for (const line of errText.split('\n')) {
|
|
125
|
+
// error: open("path"): Permission denied
|
|
126
|
+
let m = line.match(/error:\s*open\(["'](.+?)["']\):\s*Permission denied/i);
|
|
127
|
+
if (m) {
|
|
128
|
+
files.push(m[1]);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// error: unable to index file 'path'
|
|
132
|
+
m = line.match(/error:\s*unable to index file\s+['"](.+?)['"]/i);
|
|
133
|
+
if (m) {
|
|
134
|
+
files.push(m[1]);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return files;
|
|
139
|
+
}
|
|
119
140
|
/** Get npm command for current platform (npm.cmd on Windows, npm elsewhere) */
|
|
120
141
|
function getNpmCommand() {
|
|
121
142
|
return process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
@@ -1275,7 +1296,10 @@ const RECOMMENDED_GITIGNORE = [
|
|
|
1275
1296
|
'.globalize.json5',
|
|
1276
1297
|
'*.log',
|
|
1277
1298
|
'.DS_Store',
|
|
1278
|
-
'Thumbs.db'
|
|
1299
|
+
'Thumbs.db',
|
|
1300
|
+
'*.mdf',
|
|
1301
|
+
'*.ldf',
|
|
1302
|
+
'*.ndf'
|
|
1279
1303
|
];
|
|
1280
1304
|
/** Recommended .npmignore patterns */
|
|
1281
1305
|
const RECOMMENDED_NPMIGNORE = [
|
|
@@ -2588,13 +2612,42 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2588
2612
|
if (nulCount > 0 && verbose) {
|
|
2589
2613
|
console.log(` Removed ${nulCount} 'nul' file(s) (Windows reserved name)`);
|
|
2590
2614
|
}
|
|
2591
|
-
|
|
2615
|
+
let addResult = runCommand('git', ['add', '-A'], { cwd, silent: true });
|
|
2592
2616
|
if (!addResult.success) {
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2617
|
+
const errText = addResult.stderr + addResult.output;
|
|
2618
|
+
const deniedFiles = parseDeniedFiles(errText);
|
|
2619
|
+
if (deniedFiles.length > 0) {
|
|
2620
|
+
console.error(colors.red(`git add failed — ${deniedFiles.length} file(s) locked/permission denied:`));
|
|
2621
|
+
for (const f of deniedFiles) {
|
|
2622
|
+
console.error(colors.red(` ${f}`));
|
|
2623
|
+
}
|
|
2624
|
+
const ok = await confirm('Add these files to .gitignore and retry?', true);
|
|
2625
|
+
if (ok) {
|
|
2626
|
+
const gitignorePath = path.join(cwd, '.gitignore');
|
|
2627
|
+
let gitignoreContent = fs.existsSync(gitignorePath) ? fs.readFileSync(gitignorePath, 'utf-8') : '';
|
|
2628
|
+
if (gitignoreContent && !gitignoreContent.endsWith('\n'))
|
|
2629
|
+
gitignoreContent += '\n';
|
|
2630
|
+
for (const f of deniedFiles) {
|
|
2631
|
+
gitignoreContent += f + '\n';
|
|
2632
|
+
}
|
|
2633
|
+
fs.writeFileSync(gitignorePath, gitignoreContent);
|
|
2634
|
+
console.log(colors.green('✓ Updated .gitignore'));
|
|
2635
|
+
addResult = runCommand('git', ['add', '-A'], { cwd, silent: true });
|
|
2636
|
+
if (addResult.success) {
|
|
2637
|
+
console.log(colors.green('✓ git add succeeded after updating .gitignore'));
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
if (!addResult.success) {
|
|
2641
|
+
return false;
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
else {
|
|
2645
|
+
console.error(colors.red('ERROR: Failed to add files to git:'), errText);
|
|
2646
|
+
if (!force) {
|
|
2647
|
+
return false;
|
|
2648
|
+
}
|
|
2649
|
+
console.log(colors.yellow('Continuing with --force...'));
|
|
2596
2650
|
}
|
|
2597
|
-
console.log(colors.yellow('Continuing with --force...'));
|
|
2598
2651
|
}
|
|
2599
2652
|
let commitResult = runCommand('git', ['commit', '-m', commitMsg], { cwd });
|
|
2600
2653
|
if (!commitResult.success) {
|