@bobfrankston/npmglobalize 1.0.79 → 1.0.80
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/cli.js +29 -4
- package/lib.d.ts +3 -1
- package/lib.js +62 -28
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* npmglobalize CLI - Transform file: dependencies to npm versions for publishing
|
|
4
4
|
*/
|
|
5
|
-
import { globalize, globalizeWorkspace, readConfig, readPackageJson, writePackageJson } from './lib.js';
|
|
5
|
+
import { globalize, globalizeWorkspace, readConfig, readPackageJson, writeConfig, writePackageJson } from './lib.js';
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { fileURLToPath } from 'url';
|
|
@@ -65,7 +65,8 @@ Dependency Options:
|
|
|
65
65
|
--fix Run npm audit fix after transformation
|
|
66
66
|
|
|
67
67
|
Install Options:
|
|
68
|
-
--install, -i Global install after publish (
|
|
68
|
+
--install, -i Global install after publish (from registry)
|
|
69
|
+
--link Global install via symlink (npm install -g .)
|
|
69
70
|
--wsl Also install globally in WSL
|
|
70
71
|
|
|
71
72
|
Mode Options:
|
|
@@ -108,7 +109,8 @@ Examples:
|
|
|
108
109
|
npmglobalize -npd Skip auto-publishing file: deps (use with caution)
|
|
109
110
|
npmglobalize --force-publish Force republish all file: dependencies
|
|
110
111
|
npmglobalize --fix Fix security vulnerabilities
|
|
111
|
-
npmglobalize --install --wsl Release + install on Windows and WSL
|
|
112
|
+
npmglobalize --install --wsl Release + install on Windows and WSL (from registry)
|
|
113
|
+
npmglobalize --link --wsl Release + link on Windows and WSL (symlink)
|
|
112
114
|
npmglobalize -np Just transform, no publish
|
|
113
115
|
npmglobalize --cleanup Restore original dependencies
|
|
114
116
|
npmglobalize --init Initialize new git repo + release
|
|
@@ -126,7 +128,8 @@ function parseArgs(args) {
|
|
|
126
128
|
const options = {
|
|
127
129
|
help: false,
|
|
128
130
|
version: false,
|
|
129
|
-
error: ''
|
|
131
|
+
error: '',
|
|
132
|
+
explicitKeys: new Set()
|
|
130
133
|
};
|
|
131
134
|
const unrecognized = [];
|
|
132
135
|
const positional = [];
|
|
@@ -161,25 +164,35 @@ function parseArgs(args) {
|
|
|
161
164
|
case '--install':
|
|
162
165
|
case '-i':
|
|
163
166
|
options.install = true;
|
|
167
|
+
options.explicitKeys.add('install');
|
|
164
168
|
break;
|
|
165
169
|
case '--noinstall':
|
|
166
170
|
case '-ni':
|
|
167
171
|
options.install = false;
|
|
172
|
+
options.explicitKeys.add('install');
|
|
173
|
+
break;
|
|
174
|
+
case '--link':
|
|
175
|
+
options.link = true;
|
|
176
|
+
options.explicitKeys.add('link');
|
|
168
177
|
break;
|
|
169
178
|
case '--wsl':
|
|
170
179
|
options.wsl = true;
|
|
180
|
+
options.explicitKeys.add('wsl');
|
|
171
181
|
break;
|
|
172
182
|
case '--nowsl':
|
|
173
183
|
options.wsl = false;
|
|
184
|
+
options.explicitKeys.add('wsl');
|
|
174
185
|
break;
|
|
175
186
|
case '--force':
|
|
176
187
|
options.force = true;
|
|
177
188
|
break;
|
|
178
189
|
case '--files':
|
|
179
190
|
options.files = true;
|
|
191
|
+
options.explicitKeys.add('files');
|
|
180
192
|
break;
|
|
181
193
|
case '--nofiles':
|
|
182
194
|
options.files = false;
|
|
195
|
+
options.explicitKeys.add('files');
|
|
183
196
|
break;
|
|
184
197
|
case '--dry-run':
|
|
185
198
|
options.dryRun = true;
|
|
@@ -198,6 +211,7 @@ function parseArgs(args) {
|
|
|
198
211
|
i++;
|
|
199
212
|
if (args[i] === 'private' || args[i] === 'public') {
|
|
200
213
|
options.gitVisibility = args[i];
|
|
214
|
+
options.explicitKeys.add('gitVisibility');
|
|
201
215
|
}
|
|
202
216
|
else {
|
|
203
217
|
options.error = `--git requires 'private' or 'public', got: ${args[i]}`;
|
|
@@ -207,6 +221,7 @@ function parseArgs(args) {
|
|
|
207
221
|
i++;
|
|
208
222
|
if (args[i] === 'private' || args[i] === 'public') {
|
|
209
223
|
options.npmVisibility = args[i];
|
|
224
|
+
options.explicitKeys.add('npmVisibility');
|
|
210
225
|
}
|
|
211
226
|
else {
|
|
212
227
|
options.error = `--npm requires 'private' or 'public', got: ${args[i]}`;
|
|
@@ -257,9 +272,11 @@ function parseArgs(args) {
|
|
|
257
272
|
break;
|
|
258
273
|
case '--fix':
|
|
259
274
|
options.fix = true;
|
|
275
|
+
options.explicitKeys.add('fix');
|
|
260
276
|
break;
|
|
261
277
|
case '--no-fix':
|
|
262
278
|
options.fix = false;
|
|
279
|
+
options.explicitKeys.add('fix');
|
|
263
280
|
break;
|
|
264
281
|
case '--workspace':
|
|
265
282
|
case '-w':
|
|
@@ -401,6 +418,14 @@ export async function main() {
|
|
|
401
418
|
// Load config file and merge with CLI options (CLI takes precedence)
|
|
402
419
|
const configOptions = readConfig(cwd);
|
|
403
420
|
const options = { ...configOptions, ...cliOptions };
|
|
421
|
+
// Persist explicitly set CLI flags to .globalize.json5
|
|
422
|
+
if (cliOptions.explicitKeys.size > 0) {
|
|
423
|
+
const persistable = { ...configOptions };
|
|
424
|
+
for (const key of cliOptions.explicitKeys) {
|
|
425
|
+
persistable[key] = options[key];
|
|
426
|
+
}
|
|
427
|
+
writeConfig(cwd, persistable, cliOptions.explicitKeys);
|
|
428
|
+
}
|
|
404
429
|
try {
|
|
405
430
|
// Auto-detect workspace root: private package with workspaces[] field
|
|
406
431
|
if (!options.noWorkspace) {
|
package/lib.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ export interface GlobalizeOptions {
|
|
|
17
17
|
noPublish?: boolean;
|
|
18
18
|
/** Restore from .dependencies */
|
|
19
19
|
cleanup?: boolean;
|
|
20
|
-
/** Global install after publish */
|
|
20
|
+
/** Global install after publish (from registry) */
|
|
21
21
|
install?: boolean;
|
|
22
|
+
/** Global install via symlink (npm install -g .) */
|
|
23
|
+
link?: boolean;
|
|
22
24
|
/** Also install in WSL */
|
|
23
25
|
wsl?: boolean;
|
|
24
26
|
/** Continue despite git errors */
|
package/lib.js
CHANGED
|
@@ -138,7 +138,9 @@ export function writeConfig(dir, config, explicitKeys) {
|
|
|
138
138
|
// Add inline comment for clarity
|
|
139
139
|
let comment = '';
|
|
140
140
|
if (key === 'install')
|
|
141
|
-
comment = ' // Auto-install globally after publish';
|
|
141
|
+
comment = ' // Auto-install globally after publish (from registry)';
|
|
142
|
+
else if (key === 'link')
|
|
143
|
+
comment = ' // Install globally via symlink (npm install -g .)';
|
|
142
144
|
else if (key === 'wsl')
|
|
143
145
|
comment = ' // Also install in WSL';
|
|
144
146
|
else if (key === 'files')
|
|
@@ -164,7 +166,8 @@ export function writeConfig(dir, config, explicitKeys) {
|
|
|
164
166
|
// Add commented reference for all options
|
|
165
167
|
lines.push(' // Defaults (omitted above):');
|
|
166
168
|
lines.push(' // "bump": "patch" // Version bump: patch, minor, major');
|
|
167
|
-
lines.push(' // "install": false // Auto-install globally after publish');
|
|
169
|
+
lines.push(' // "install": false // Auto-install globally after publish (from registry)');
|
|
170
|
+
lines.push(' // "link": false // Install globally via symlink (npm install -g .)');
|
|
168
171
|
lines.push(' // "wsl": false // Also install in WSL');
|
|
169
172
|
lines.push(' // "files": true // Keep file: paths after publish');
|
|
170
173
|
lines.push(' // "force": false // Continue despite git errors');
|
|
@@ -1393,7 +1396,7 @@ export function getToolVersion() {
|
|
|
1393
1396
|
}
|
|
1394
1397
|
}
|
|
1395
1398
|
export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
1396
|
-
const { bump = 'patch', noPublish = false, cleanup = false, install = false, wsl = false, force = false, files = true, dryRun = false, quiet = true, verbose = false, init = false, gitVisibility = 'private', npmVisibility = 'private', message, conform = false, asis = false, updateDeps = false, updateMajor = false, publishDeps = true, // Default to publishing deps for safety
|
|
1399
|
+
const { bump = 'patch', noPublish = false, cleanup = false, install = false, link = false, wsl = false, force = false, files = true, dryRun = false, quiet = true, verbose = false, init = false, gitVisibility = 'private', npmVisibility = 'private', message, conform = false, asis = false, updateDeps = false, updateMajor = false, publishDeps = true, // Default to publishing deps for safety
|
|
1397
1400
|
forcePublish = false, fix = false, fixTags = false, rebase = false, show = false } = options;
|
|
1398
1401
|
// Show tool version (skip when called from workspace orchestrator)
|
|
1399
1402
|
const toolVersion = getToolVersion();
|
|
@@ -1405,6 +1408,8 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1405
1408
|
const settings = [];
|
|
1406
1409
|
if (configOptions.install)
|
|
1407
1410
|
settings.push('--install');
|
|
1411
|
+
if (configOptions.link)
|
|
1412
|
+
settings.push('--link');
|
|
1408
1413
|
if (configOptions.npmVisibility)
|
|
1409
1414
|
settings.push(`--npm-visibility ${configOptions.npmVisibility}`);
|
|
1410
1415
|
if (configOptions.gitVisibility)
|
|
@@ -2023,40 +2028,51 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2023
2028
|
if (!currentGitStatus.hasUncommitted && !message && !justInitialized && !isFirstPublish) {
|
|
2024
2029
|
console.log('');
|
|
2025
2030
|
console.log('No changes to commit and no custom message specified.');
|
|
2026
|
-
// If install flag is set, install
|
|
2027
|
-
if (install || wsl) {
|
|
2031
|
+
// If install/link flag is set, install globally
|
|
2032
|
+
if (install || link || wsl) {
|
|
2028
2033
|
if (verbose) {
|
|
2029
2034
|
console.log('');
|
|
2030
|
-
console.log('Installing from local directory...');
|
|
2035
|
+
console.log(link ? 'Installing from local directory (link)...' : 'Installing from registry...');
|
|
2031
2036
|
}
|
|
2032
2037
|
const pkgName = pkg.name;
|
|
2033
|
-
|
|
2038
|
+
const pkgVersion = pkg.version;
|
|
2039
|
+
if (!pkg.bin && (install || link || wsl)) {
|
|
2034
2040
|
console.log(colors.yellow('Note: This is a library (no bin field), skipping global installation.'));
|
|
2035
2041
|
console.log(colors.yellow('To use in projects: npm install ' + pkgName));
|
|
2036
2042
|
}
|
|
2037
2043
|
else {
|
|
2038
|
-
if (
|
|
2039
|
-
console.log(`Installing ${pkgName} globally from local directory...`);
|
|
2044
|
+
if (link) {
|
|
2045
|
+
console.log(`Installing ${pkgName} globally from local directory (link)...`);
|
|
2040
2046
|
const localInstallResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false });
|
|
2041
2047
|
if (localInstallResult.success) {
|
|
2042
|
-
|
|
2043
|
-
console.log(colors.green(`✓ Installed globally: ${pkgName}@${version}`));
|
|
2048
|
+
console.log(colors.green(`✓ Linked globally: ${pkgName}@${pkgVersion}`));
|
|
2044
2049
|
}
|
|
2045
2050
|
else {
|
|
2046
|
-
console.error(colors.red(`✗ Global install failed`));
|
|
2051
|
+
console.error(colors.red(`✗ Global link install failed`));
|
|
2047
2052
|
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
2048
2053
|
}
|
|
2049
2054
|
}
|
|
2055
|
+
else if (install) {
|
|
2056
|
+
console.log(`Installing ${pkgName}@${pkgVersion} globally from registry...`);
|
|
2057
|
+
const registryInstallResult = runCommand('npm', ['install', '-g', `${pkgName}@${pkgVersion}`], { cwd, silent: false });
|
|
2058
|
+
if (registryInstallResult.success) {
|
|
2059
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
2060
|
+
}
|
|
2061
|
+
else {
|
|
2062
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
2063
|
+
console.error(colors.yellow(` Try running manually: npm install -g ${pkgName}@${pkgVersion}`));
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2050
2066
|
if (wsl) {
|
|
2051
|
-
|
|
2052
|
-
|
|
2067
|
+
const wslArgs = link ? ['npm', 'install', '-g', '.'] : ['npm', 'install', '-g', `${pkgName}@${pkgVersion}`];
|
|
2068
|
+
console.log(`Installing ${pkgName} in WSL${link ? ' (link)' : ' from registry'}...`);
|
|
2069
|
+
const wslInstallResult = runCommand('wsl', wslArgs, { cwd, silent: false });
|
|
2053
2070
|
if (wslInstallResult.success) {
|
|
2054
|
-
|
|
2055
|
-
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${version}`));
|
|
2071
|
+
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${pkgVersion}`));
|
|
2056
2072
|
}
|
|
2057
2073
|
else {
|
|
2058
2074
|
console.error(colors.red(`✗ WSL install failed`));
|
|
2059
|
-
console.error(colors.yellow(' Try running manually in WSL: npm install -g .'));
|
|
2075
|
+
console.error(colors.yellow(' Try running manually in WSL: npm install -g ' + (link ? '.' : pkgName)));
|
|
2060
2076
|
}
|
|
2061
2077
|
}
|
|
2062
2078
|
}
|
|
@@ -2470,21 +2486,20 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2470
2486
|
const updatedPkg = readPackageJson(cwd); // Re-read to get updated version
|
|
2471
2487
|
const pkgName = updatedPkg.name;
|
|
2472
2488
|
const pkgVersion = updatedPkg.version;
|
|
2473
|
-
if (!updatedPkg.bin && (install || wsl)) {
|
|
2489
|
+
if (!updatedPkg.bin && (install || link || wsl)) {
|
|
2474
2490
|
console.log(colors.yellow('Note: This is a library (no bin field), skipping global installation.'));
|
|
2475
2491
|
console.log(colors.yellow('To use in projects: npm install ' + pkgName));
|
|
2476
2492
|
}
|
|
2477
2493
|
else {
|
|
2478
|
-
if (
|
|
2479
|
-
console.log(`
|
|
2494
|
+
if (link) {
|
|
2495
|
+
console.log(`Linking globally: ${pkgName}@${pkgVersion}...`);
|
|
2480
2496
|
if (!dryRun) {
|
|
2481
|
-
// Install from local directory (faster and works immediately after publish)
|
|
2482
2497
|
const installResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false });
|
|
2483
2498
|
if (installResult.success) {
|
|
2484
|
-
console.log(colors.green(`✓
|
|
2499
|
+
console.log(colors.green(`✓ Linked globally: ${pkgName}@${pkgVersion}`));
|
|
2485
2500
|
}
|
|
2486
2501
|
else {
|
|
2487
|
-
console.error(colors.red(`✗ Global install failed`));
|
|
2502
|
+
console.error(colors.red(`✗ Global link install failed`));
|
|
2488
2503
|
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
2489
2504
|
}
|
|
2490
2505
|
}
|
|
@@ -2492,11 +2507,27 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2492
2507
|
console.log(` [dry-run] Would run: npm install -g .`);
|
|
2493
2508
|
}
|
|
2494
2509
|
}
|
|
2510
|
+
else if (install) {
|
|
2511
|
+
console.log(`Installing globally from registry: ${pkgName}@${pkgVersion}...`);
|
|
2512
|
+
if (!dryRun) {
|
|
2513
|
+
const installResult = runCommand('npm', ['install', '-g', `${pkgName}@${pkgVersion}`], { cwd, silent: false });
|
|
2514
|
+
if (installResult.success) {
|
|
2515
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
2516
|
+
}
|
|
2517
|
+
else {
|
|
2518
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
2519
|
+
console.error(colors.yellow(` Try running manually: npm install -g ${pkgName}@${pkgVersion}`));
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
else {
|
|
2523
|
+
console.log(` [dry-run] Would run: npm install -g ${pkgName}@${pkgVersion}`);
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2495
2526
|
if (wsl) {
|
|
2496
|
-
|
|
2527
|
+
const wslArgs = link ? ['npm', 'install', '-g', '.'] : ['npm', 'install', '-g', `${pkgName}@${pkgVersion}`];
|
|
2528
|
+
console.log(`Installing in WSL${link ? ' (link)' : ' from registry'}: ${pkgName}@${pkgVersion}...`);
|
|
2497
2529
|
if (!dryRun) {
|
|
2498
|
-
|
|
2499
|
-
const wslResult = runCommand('wsl', ['npm', 'install', '-g', '.'], { cwd, silent: false });
|
|
2530
|
+
const wslResult = runCommand('wsl', wslArgs, { cwd, silent: false });
|
|
2500
2531
|
if (wslResult.success) {
|
|
2501
2532
|
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${pkgVersion}`));
|
|
2502
2533
|
}
|
|
@@ -2505,7 +2536,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2505
2536
|
}
|
|
2506
2537
|
}
|
|
2507
2538
|
else {
|
|
2508
|
-
console.log(` [dry-run] Would run: wsl npm install -g ${pkgName}`);
|
|
2539
|
+
console.log(` [dry-run] Would run: wsl npm install -g ${link ? '.' : pkgName}`);
|
|
2509
2540
|
}
|
|
2510
2541
|
}
|
|
2511
2542
|
}
|
|
@@ -2545,7 +2576,10 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2545
2576
|
console.log(` Version: ${colors.green('v' + finalPkg.version)}`);
|
|
2546
2577
|
console.log(` Published: ${colors.green('✓')} (${accessLabel})`);
|
|
2547
2578
|
console.log(` Git pushed: ${colors.green('✓')}`);
|
|
2548
|
-
if (
|
|
2579
|
+
if (link) {
|
|
2580
|
+
console.log(` Linked globally: ${colors.green('✓')}`);
|
|
2581
|
+
}
|
|
2582
|
+
else if (install) {
|
|
2549
2583
|
console.log(` Installed globally: ${colors.green('✓')}`);
|
|
2550
2584
|
}
|
|
2551
2585
|
if (wsl) {
|