@bobfrankston/npmglobalize 1.0.94 → 1.0.96
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 +2 -1
- package/lib.js +20 -16
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -1595,26 +1595,24 @@ export function getToolVersion() {
|
|
|
1595
1595
|
return 'unknown';
|
|
1596
1596
|
}
|
|
1597
1597
|
}
|
|
1598
|
-
/** Offer to add a bin field if missing — returns true if bin was added
|
|
1598
|
+
/** Offer to add a bin field if missing — returns true if bin was added, false to skip/abort */
|
|
1599
1599
|
async function offerAddBin(cwd, pkg) {
|
|
1600
1600
|
if (pkg.bin)
|
|
1601
1601
|
return true;
|
|
1602
1602
|
// Determine likely entry point
|
|
1603
1603
|
const mainFile = pkg.main || 'index.js';
|
|
1604
1604
|
const cmdName = (pkg.name || path.basename(cwd)).replace(/^@[^/]+\//, '');
|
|
1605
|
-
console.log(colors.yellow('No bin field — this
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1605
|
+
console.log(colors.yellow('No bin field — this is a library, not a CLI tool.'));
|
|
1606
|
+
console.log(colors.yellow('Libraries should not be installed globally. Use npm install <name> in projects instead.'));
|
|
1607
|
+
const choice = await promptChoice(`Add bin field to make it a CLI tool?\n 1) Yes, use "${cmdName}" → "${mainFile}"\n 2) Skip global install (default)\nChoice:`, ['1', '2', '']);
|
|
1608
|
+
if (choice === '1') {
|
|
1609
|
+
pkg.bin = { [cmdName]: mainFile };
|
|
1610
|
+
writePackageJson(cwd, pkg);
|
|
1611
|
+
console.log(colors.green(`✓ Added bin: { "${cmdName}": "${mainFile}" }`));
|
|
1611
1612
|
return true;
|
|
1612
1613
|
}
|
|
1613
|
-
// choice is '
|
|
1614
|
-
|
|
1615
|
-
writePackageJson(cwd, pkg);
|
|
1616
|
-
console.log(colors.green(`✓ Added bin: { "${cmdName}": "${mainFile}" }`));
|
|
1617
|
-
return true;
|
|
1614
|
+
// choice is '2' or '' (default) — skip
|
|
1615
|
+
return false;
|
|
1618
1616
|
}
|
|
1619
1617
|
/** Perform local-only install (npm install -g .) — extracted for reuse from git-init prompts */
|
|
1620
1618
|
async function doLocalInstall(cwd, options) {
|
|
@@ -1626,8 +1624,11 @@ async function doLocalInstall(cwd, options) {
|
|
|
1626
1624
|
console.log(colors.dim('Skipping transform/publish — installing with file: deps as-is'));
|
|
1627
1625
|
if (!pkg.bin) {
|
|
1628
1626
|
const proceed = await offerAddBin(cwd, pkg);
|
|
1629
|
-
if (!proceed)
|
|
1630
|
-
|
|
1627
|
+
if (!proceed) {
|
|
1628
|
+
console.log(colors.yellow('Skipping global install — library packages should not be installed globally.'));
|
|
1629
|
+
console.log(colors.yellow(`To use in projects: npm install ${pkgName}`));
|
|
1630
|
+
return true;
|
|
1631
|
+
}
|
|
1631
1632
|
}
|
|
1632
1633
|
if (dryRun) {
|
|
1633
1634
|
console.log(' [dry-run] Would run: npm install -g .');
|
|
@@ -1729,8 +1730,11 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1729
1730
|
console.log(colors.dim('Skipping transform/publish — installing with file: deps as-is'));
|
|
1730
1731
|
if (!pkg.bin) {
|
|
1731
1732
|
const proceed = await offerAddBin(cwd, pkg);
|
|
1732
|
-
if (!proceed)
|
|
1733
|
-
|
|
1733
|
+
if (!proceed) {
|
|
1734
|
+
console.log(colors.yellow('Skipping global install — library packages should not be installed globally.'));
|
|
1735
|
+
console.log(colors.yellow(`To use in projects: npm install ${pkgName}`));
|
|
1736
|
+
return true;
|
|
1737
|
+
}
|
|
1734
1738
|
}
|
|
1735
1739
|
if (dryRun) {
|
|
1736
1740
|
console.log(' [dry-run] Would run: npm install -g .');
|