@bobfrankston/npmglobalize 1.0.62 → 1.0.63
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 +62 -46
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -1740,28 +1740,34 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1740
1740
|
console.log('Installing from local directory...');
|
|
1741
1741
|
}
|
|
1742
1742
|
const pkgName = pkg.name;
|
|
1743
|
-
if (install) {
|
|
1744
|
-
console.log(
|
|
1745
|
-
|
|
1746
|
-
if (localInstallResult.success) {
|
|
1747
|
-
const version = pkg.version;
|
|
1748
|
-
console.log(colors.green(`✓ Installed globally: ${pkgName}@${version}`));
|
|
1749
|
-
}
|
|
1750
|
-
else {
|
|
1751
|
-
console.error(colors.red(`✗ Global install failed`));
|
|
1752
|
-
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
1753
|
-
}
|
|
1743
|
+
if (!pkg.bin && (install || wsl)) {
|
|
1744
|
+
console.log(colors.yellow('Note: This is a library (no bin field), skipping global installation.'));
|
|
1745
|
+
console.log(colors.yellow('To use in projects: npm install ' + pkgName));
|
|
1754
1746
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1747
|
+
else {
|
|
1748
|
+
if (install) {
|
|
1749
|
+
console.log(`Installing ${pkgName} globally from local directory...`);
|
|
1750
|
+
const localInstallResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false });
|
|
1751
|
+
if (localInstallResult.success) {
|
|
1752
|
+
const version = pkg.version;
|
|
1753
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${version}`));
|
|
1754
|
+
}
|
|
1755
|
+
else {
|
|
1756
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
1757
|
+
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
1758
|
+
}
|
|
1761
1759
|
}
|
|
1762
|
-
|
|
1763
|
-
console.
|
|
1764
|
-
|
|
1760
|
+
if (wsl) {
|
|
1761
|
+
console.log(`Installing ${pkgName} in WSL from local directory...`);
|
|
1762
|
+
const wslInstallResult = runCommand('wsl', ['npm', 'install', '-g', '.'], { cwd, silent: false });
|
|
1763
|
+
if (wslInstallResult.success) {
|
|
1764
|
+
const version = pkg.version;
|
|
1765
|
+
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${version}`));
|
|
1766
|
+
}
|
|
1767
|
+
else {
|
|
1768
|
+
console.error(colors.red(`✗ WSL install failed`));
|
|
1769
|
+
console.error(colors.yellow(' Try running manually in WSL: npm install -g .'));
|
|
1770
|
+
}
|
|
1765
1771
|
}
|
|
1766
1772
|
}
|
|
1767
1773
|
}
|
|
@@ -2180,38 +2186,44 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2180
2186
|
const updatedPkg = readPackageJson(cwd); // Re-read to get updated version
|
|
2181
2187
|
const pkgName = updatedPkg.name;
|
|
2182
2188
|
const pkgVersion = updatedPkg.version;
|
|
2183
|
-
if (install) {
|
|
2184
|
-
console.log(
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2189
|
+
if (!updatedPkg.bin && (install || wsl)) {
|
|
2190
|
+
console.log(colors.yellow('Note: This is a library (no bin field), skipping global installation.'));
|
|
2191
|
+
console.log(colors.yellow('To use in projects: npm install ' + pkgName));
|
|
2192
|
+
}
|
|
2193
|
+
else {
|
|
2194
|
+
if (install) {
|
|
2195
|
+
console.log(`Installing globally: ${pkgName}@${pkgVersion}...`);
|
|
2196
|
+
if (!dryRun) {
|
|
2197
|
+
// Install from local directory (faster and works immediately after publish)
|
|
2198
|
+
const installResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false });
|
|
2199
|
+
if (installResult.success) {
|
|
2200
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
2201
|
+
}
|
|
2202
|
+
else {
|
|
2203
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
2204
|
+
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
2205
|
+
}
|
|
2190
2206
|
}
|
|
2191
2207
|
else {
|
|
2192
|
-
console.
|
|
2193
|
-
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
2208
|
+
console.log(` [dry-run] Would run: npm install -g .`);
|
|
2194
2209
|
}
|
|
2195
2210
|
}
|
|
2196
|
-
|
|
2197
|
-
console.log(`
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2211
|
+
if (wsl) {
|
|
2212
|
+
console.log(`Installing in WSL: ${pkgName}@${pkgVersion}...`);
|
|
2213
|
+
if (!dryRun) {
|
|
2214
|
+
// Install from local directory in WSL
|
|
2215
|
+
const wslResult = runCommand('wsl', ['npm', 'install', '-g', '.'], { cwd, silent: false });
|
|
2216
|
+
if (wslResult.success) {
|
|
2217
|
+
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${pkgVersion}`));
|
|
2218
|
+
}
|
|
2219
|
+
else {
|
|
2220
|
+
console.error(colors.yellow('✗ WSL install failed (is npm installed in WSL?)'));
|
|
2221
|
+
}
|
|
2207
2222
|
}
|
|
2208
2223
|
else {
|
|
2209
|
-
console.
|
|
2224
|
+
console.log(` [dry-run] Would run: wsl npm install -g ${pkgName}`);
|
|
2210
2225
|
}
|
|
2211
2226
|
}
|
|
2212
|
-
else {
|
|
2213
|
-
console.log(` [dry-run] Would run: wsl npm install -g ${pkgName}`);
|
|
2214
|
-
}
|
|
2215
2227
|
}
|
|
2216
2228
|
// Finalize - restore file: paths if --files mode (default)
|
|
2217
2229
|
if (files && transformResult.transformed) {
|
|
@@ -2260,8 +2272,12 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2260
2272
|
}
|
|
2261
2273
|
console.log(colors.green('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
2262
2274
|
console.log('');
|
|
2263
|
-
|
|
2264
|
-
|
|
2275
|
+
// Only show "To use run" message if package provides commands (has bin field)
|
|
2276
|
+
if (finalPkg.bin) {
|
|
2277
|
+
const commandName = finalPkg.name.includes('/') ? finalPkg.name.split('/')[1] : finalPkg.name;
|
|
2278
|
+
console.log(`To use run: ${colors.green(commandName)}`);
|
|
2279
|
+
console.log('');
|
|
2280
|
+
}
|
|
2265
2281
|
return true;
|
|
2266
2282
|
}
|
|
2267
2283
|
export default {
|