@bobfrankston/npmglobalize 1.0.35 → 1.0.36
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/README.md +31 -0
- package/lib.js +50 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -184,6 +184,37 @@ git config core.eol lf # Force LF line endings
|
|
|
184
184
|
|
|
185
185
|
This ensures consistent line endings across Windows, macOS, and Linux, preventing "modified file" issues caused by line ending differences.
|
|
186
186
|
|
|
187
|
+
### 🔍 Understanding "Detached HEAD" Error
|
|
188
|
+
|
|
189
|
+
**What is Detached HEAD?**
|
|
190
|
+
Your git repository is not currently on a branch (like `master` or `main`). This happens when you:
|
|
191
|
+
- Check out a specific commit: `git checkout abc123`
|
|
192
|
+
- Check out a tag: `git checkout v1.0.0`
|
|
193
|
+
- Have some git operations leave you in this state
|
|
194
|
+
|
|
195
|
+
**Why does it matter?**
|
|
196
|
+
Publishing requires being on a branch so commits and tags can be properly tracked in your repository history.
|
|
197
|
+
|
|
198
|
+
**Common scenarios:**
|
|
199
|
+
|
|
200
|
+
1. **Just fixing files with `--conform`:**
|
|
201
|
+
```bash
|
|
202
|
+
npmglobalize --conform # ✓ Files get fixed, then exits with helpful message
|
|
203
|
+
```
|
|
204
|
+
The files are already updated! You don't need to run it again.
|
|
205
|
+
|
|
206
|
+
2. **Want to publish:**
|
|
207
|
+
```bash
|
|
208
|
+
git checkout master # Get back on a branch
|
|
209
|
+
npmglobalize # Now works normally
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
3. **Force publish anyway (not recommended):**
|
|
213
|
+
```bash
|
|
214
|
+
npmglobalize --force # Proceeds despite detached HEAD
|
|
215
|
+
```
|
|
216
|
+
Warning: Commits may be hard to track later. Consider merging back to a branch afterward.
|
|
217
|
+
|
|
187
218
|
## Command Reference
|
|
188
219
|
|
|
189
220
|
### Release Options
|
package/lib.js
CHANGED
|
@@ -1276,11 +1276,58 @@ export async function globalize(cwd, options = {}) {
|
|
|
1276
1276
|
return false;
|
|
1277
1277
|
}
|
|
1278
1278
|
if (currentGitStatus.isDetachedHead && !force) {
|
|
1279
|
-
|
|
1280
|
-
|
|
1279
|
+
if (conform && !noPublish) {
|
|
1280
|
+
// Conform already happened earlier, just exit gracefully
|
|
1281
|
+
console.log('');
|
|
1282
|
+
console.log(colors.green('✓ Files have been updated successfully!'));
|
|
1283
|
+
console.log(' • .gitignore updated');
|
|
1284
|
+
console.log(' • .npmignore updated');
|
|
1285
|
+
console.log(' • .gitattributes created/updated (LF line endings)');
|
|
1286
|
+
console.log(' • Git configured: core.autocrlf=false, core.eol=lf');
|
|
1287
|
+
console.log('');
|
|
1288
|
+
console.log(colors.yellow('ℹ What is "Detached HEAD"?'));
|
|
1289
|
+
console.log(' Your git repository is not on a branch (master, main, etc.)');
|
|
1290
|
+
console.log(' This happens after checking out a specific commit or tag.');
|
|
1291
|
+
console.log(' Publishing requires being on a branch so git can track changes.');
|
|
1292
|
+
console.log('');
|
|
1293
|
+
console.log(colors.yellow('✓ Good news: Your files are already fixed!'));
|
|
1294
|
+
console.log(colors.yellow(' You don\'t need to run --conform again.'));
|
|
1295
|
+
console.log('');
|
|
1296
|
+
console.log(colors.yellow('To publish, get back on a branch:'));
|
|
1297
|
+
console.log(' git checkout master \x1b[2m# or whatever your branch is\x1b[0m');
|
|
1298
|
+
console.log(' npmglobalize \x1b[2m# will now work normally\x1b[0m');
|
|
1299
|
+
console.log('');
|
|
1300
|
+
return true; // Success - conform was completed
|
|
1301
|
+
}
|
|
1302
|
+
else if (noPublish) {
|
|
1303
|
+
// Just doing non-publish operations, detached HEAD is fine
|
|
1304
|
+
console.log(colors.yellow('Note: Detached HEAD state (no publishing will occur)'));
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1307
|
+
console.log('');
|
|
1308
|
+
console.error(colors.red('ERROR: Cannot publish from Detached HEAD state'));
|
|
1309
|
+
console.log('');
|
|
1310
|
+
console.log(colors.yellow('ℹ What is "Detached HEAD"?'));
|
|
1311
|
+
console.log(' Your git repository is not on a branch (master, main, etc.)');
|
|
1312
|
+
console.log(' This happens after checking out a specific commit or tag.');
|
|
1313
|
+
console.log(' Publishing requires being on a branch so git can track changes.');
|
|
1314
|
+
console.log('');
|
|
1315
|
+
console.log(colors.yellow('To fix this:'));
|
|
1316
|
+
console.log(' git checkout master \x1b[2m# or whatever your branch is\x1b[0m');
|
|
1317
|
+
console.log(' npmglobalize \x1b[2m# will now work\x1b[0m');
|
|
1318
|
+
console.log('');
|
|
1319
|
+
console.log(colors.yellow('Or to force publish anyway (risky):'));
|
|
1320
|
+
console.log(' npmglobalize --force \x1b[2m# proceeds despite detached HEAD\x1b[0m');
|
|
1321
|
+
console.log('');
|
|
1322
|
+
return false;
|
|
1323
|
+
}
|
|
1281
1324
|
}
|
|
1282
1325
|
if (currentGitStatus.isDetachedHead && force) {
|
|
1283
|
-
console.log(
|
|
1326
|
+
console.log('');
|
|
1327
|
+
console.log(colors.yellow('⚠ Warning: Publishing from Detached HEAD state (--force)'));
|
|
1328
|
+
console.log(' This means you\'re not on a branch. The published commits may be');
|
|
1329
|
+
console.log(' hard to track. Consider: git checkout master && git merge HEAD');
|
|
1330
|
+
console.log('');
|
|
1284
1331
|
}
|
|
1285
1332
|
// Check if local branch is behind remote
|
|
1286
1333
|
if (currentGitStatus.isBehindRemote && !dryRun) {
|