@bobfrankston/npmglobalize 1.0.72 → 1.0.74
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 +11 -2
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -1180,7 +1180,11 @@ export async function initGit(cwd, visibility, dryRun) {
|
|
|
1180
1180
|
runCommandOrThrow('git', ['config', 'core.eol', 'lf'], { cwd });
|
|
1181
1181
|
console.log(' ✓ Configured git for LF line endings');
|
|
1182
1182
|
runCommandOrThrow('git', ['add', '-A'], { cwd });
|
|
1183
|
-
|
|
1183
|
+
// Only commit if there are staged changes (repo may already have commits)
|
|
1184
|
+
const staged = spawnSync('git', ['diff', '--cached', '--quiet'], { cwd });
|
|
1185
|
+
if (staged.status !== 0) {
|
|
1186
|
+
runCommandOrThrow('git', ['commit', '-m', 'Initial commit'], { cwd });
|
|
1187
|
+
}
|
|
1184
1188
|
// Create GitHub repo
|
|
1185
1189
|
const visFlag = visibility === 'private' ? '--private' : '--public';
|
|
1186
1190
|
runCommandOrThrow('gh', ['repo', 'create', repoName, visFlag, '--source=.', '--push'], { cwd });
|
|
@@ -1435,6 +1439,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1435
1439
|
// Check git status
|
|
1436
1440
|
const gitStatus = getGitStatus(cwd);
|
|
1437
1441
|
// Handle init mode
|
|
1442
|
+
let justInitialized = false;
|
|
1438
1443
|
if (!gitStatus.isRepo) {
|
|
1439
1444
|
console.log('No git repository found.');
|
|
1440
1445
|
if (dryRun) {
|
|
@@ -1449,11 +1454,13 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1449
1454
|
const success = await initGit(cwd, gitVisibility, dryRun);
|
|
1450
1455
|
if (!success)
|
|
1451
1456
|
return false;
|
|
1457
|
+
justInitialized = true;
|
|
1452
1458
|
}
|
|
1453
1459
|
else {
|
|
1454
1460
|
const success = await initGit(cwd, gitVisibility, dryRun);
|
|
1455
1461
|
if (!success)
|
|
1456
1462
|
return false;
|
|
1463
|
+
justInitialized = true;
|
|
1457
1464
|
}
|
|
1458
1465
|
}
|
|
1459
1466
|
else if (!gitStatus.hasRemote) {
|
|
@@ -1468,6 +1475,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1468
1475
|
const success = await initGit(cwd, gitVisibility, dryRun);
|
|
1469
1476
|
if (!success)
|
|
1470
1477
|
return false;
|
|
1478
|
+
justInitialized = true;
|
|
1471
1479
|
}
|
|
1472
1480
|
// Re-check git status after potential init
|
|
1473
1481
|
let currentGitStatus = getGitStatus(cwd);
|
|
@@ -1880,7 +1888,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1880
1888
|
// Re-check git status after all transformations and potential commits
|
|
1881
1889
|
currentGitStatus = getGitStatus(cwd);
|
|
1882
1890
|
// Check if there are changes to commit or a custom message
|
|
1883
|
-
|
|
1891
|
+
// justInitialized: first publish after creating repo - proceed even with clean tree
|
|
1892
|
+
if (!currentGitStatus.hasUncommitted && !message && !justInitialized) {
|
|
1884
1893
|
console.log('');
|
|
1885
1894
|
console.log('No changes to commit and no custom message specified.');
|
|
1886
1895
|
// If install flag is set, install from local directory
|