@bobfrankston/npmglobalize 1.0.141 → 1.0.142
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 +19 -1
- package/lib.d.ts +12 -0
- package/lib.js +27 -0
- 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, readUserNpmConfig, writeConfig, writePackageJson, confirm } from './lib.js';
|
|
5
|
+
import { globalize, globalizeWorkspace, readConfig, readPackageJson, readUserNpmConfig, writeConfig, writePackageJson, confirm, getBuildIssues, clearBuildIssues } from './lib.js';
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { styleText } from 'util';
|
|
@@ -328,6 +328,20 @@ function parseArgs(args) {
|
|
|
328
328
|
}
|
|
329
329
|
return options;
|
|
330
330
|
}
|
|
331
|
+
/** Print accumulated build issues in warning color */
|
|
332
|
+
function printBuildSummary() {
|
|
333
|
+
const issues = getBuildIssues();
|
|
334
|
+
if (issues.length === 0)
|
|
335
|
+
return;
|
|
336
|
+
console.log('');
|
|
337
|
+
console.log(styleText('yellow', '━━━ Issues Summary ━━━━━━━━━━━━━━━━━━━━'));
|
|
338
|
+
for (const issue of issues) {
|
|
339
|
+
const icon = issue.severity === 'error' ? '✗' : '⚠';
|
|
340
|
+
console.log(styleText('yellow', ` ${icon} ${issue.module}: ${issue.message}`));
|
|
341
|
+
}
|
|
342
|
+
console.log(styleText('yellow', '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
343
|
+
console.log('');
|
|
344
|
+
}
|
|
331
345
|
export async function main() {
|
|
332
346
|
// Show version at the very start
|
|
333
347
|
const ownPkgPath = path.join(__dirname, 'package.json');
|
|
@@ -444,6 +458,7 @@ export async function main() {
|
|
|
444
458
|
}
|
|
445
459
|
writeConfig(cwd, persistable, cliOptions.explicitKeys);
|
|
446
460
|
}
|
|
461
|
+
clearBuildIssues();
|
|
447
462
|
try {
|
|
448
463
|
// Auto-detect workspace root: private package with workspaces[] field
|
|
449
464
|
if (!options.noWorkspace) {
|
|
@@ -452,12 +467,14 @@ export async function main() {
|
|
|
452
467
|
const rootPkg = readPackageJson(cwd);
|
|
453
468
|
if (rootPkg.private && Array.isArray(rootPkg.workspaces)) {
|
|
454
469
|
const result = await globalizeWorkspace(cwd, options, configOptions);
|
|
470
|
+
printBuildSummary();
|
|
455
471
|
process.exit(result.success ? 0 : 1);
|
|
456
472
|
}
|
|
457
473
|
}
|
|
458
474
|
}
|
|
459
475
|
options._fromCli = true;
|
|
460
476
|
const success = await globalize(cwd, options, configOptions);
|
|
477
|
+
printBuildSummary();
|
|
461
478
|
process.exit(success ? 0 : 1);
|
|
462
479
|
}
|
|
463
480
|
catch (error) {
|
|
@@ -465,6 +482,7 @@ export async function main() {
|
|
|
465
482
|
if (options.verbose) {
|
|
466
483
|
console.error(error.stack);
|
|
467
484
|
}
|
|
485
|
+
printBuildSummary();
|
|
468
486
|
process.exit(1);
|
|
469
487
|
}
|
|
470
488
|
}
|
package/lib.d.ts
CHANGED
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
* Consider library-based approach if async operations or cross-platform issues arise.
|
|
11
11
|
*/
|
|
12
12
|
import { type NpmCommonConfig } from '@bobfrankston/userconfig';
|
|
13
|
+
/** Issue recorded during a build/publish run for end-of-run summary */
|
|
14
|
+
export interface BuildIssue {
|
|
15
|
+
module: string;
|
|
16
|
+
severity: 'error' | 'warning';
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
/** Record an issue for the end-of-run summary */
|
|
20
|
+
export declare function recordBuildIssue(module: string, severity: 'error' | 'warning', message: string): void;
|
|
21
|
+
/** Get all accumulated build issues */
|
|
22
|
+
export declare function getBuildIssues(): readonly BuildIssue[];
|
|
23
|
+
/** Clear accumulated issues (call at start of run) */
|
|
24
|
+
export declare function clearBuildIssues(): void;
|
|
13
25
|
/** Options for the globalize operation */
|
|
14
26
|
export interface GlobalizeOptions {
|
|
15
27
|
/** Bump type: patch (default), minor, major */
|
package/lib.js
CHANGED
|
@@ -33,6 +33,19 @@ import { fileURLToPath } from 'url';
|
|
|
33
33
|
import { themeColors } from '@bobfrankston/themecolors';
|
|
34
34
|
/** Semantic color functions — adapts to terminal light/dark theme */
|
|
35
35
|
const colors = themeColors();
|
|
36
|
+
const _buildIssues = [];
|
|
37
|
+
/** Record an issue for the end-of-run summary */
|
|
38
|
+
export function recordBuildIssue(module, severity, message) {
|
|
39
|
+
_buildIssues.push({ module, severity, message });
|
|
40
|
+
}
|
|
41
|
+
/** Get all accumulated build issues */
|
|
42
|
+
export function getBuildIssues() {
|
|
43
|
+
return _buildIssues;
|
|
44
|
+
}
|
|
45
|
+
/** Clear accumulated issues (call at start of run) */
|
|
46
|
+
export function clearBuildIssues() {
|
|
47
|
+
_buildIssues.length = 0;
|
|
48
|
+
}
|
|
36
49
|
/**
|
|
37
50
|
* Remove 'nul' files from a directory tree (Windows reserved name issue).
|
|
38
51
|
* These files break git and npm on Windows. Uses \\?\ prefix to bypass name validation.
|
|
@@ -2737,6 +2750,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2737
2750
|
if (!buildResult.success) {
|
|
2738
2751
|
console.error(colors.red('ERROR: Build failed:'), buildResult.stderr || buildResult.output);
|
|
2739
2752
|
diagnoseBuildFailure(buildResult.stderr || buildResult.output || '', cwd);
|
|
2753
|
+
recordBuildIssue(pkg.name || path.basename(cwd), 'error', 'Build failed');
|
|
2740
2754
|
if (!force) {
|
|
2741
2755
|
return false;
|
|
2742
2756
|
}
|
|
@@ -3143,6 +3157,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3143
3157
|
});
|
|
3144
3158
|
if (!depSuccess) {
|
|
3145
3159
|
console.error(colors.red(`Failed to publish ${name}`));
|
|
3160
|
+
recordBuildIssue(pkg.name || cwd, 'error', `Dependency failed: ${name}`);
|
|
3146
3161
|
if (!force) {
|
|
3147
3162
|
return false;
|
|
3148
3163
|
}
|
|
@@ -3871,6 +3886,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3871
3886
|
}
|
|
3872
3887
|
console.error(colors.yellow('Consumers will get E404 when installing this package.'));
|
|
3873
3888
|
console.error(colors.yellow('Fix: publish those deps as public, or make this package private.'));
|
|
3889
|
+
recordBuildIssue(pkg.name || path.basename(cwd), 'warning', `Public pkg depends on private: ${privateDeps.join(', ')}`);
|
|
3874
3890
|
console.log('');
|
|
3875
3891
|
}
|
|
3876
3892
|
}
|
|
@@ -3882,6 +3898,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3882
3898
|
const authStatus = checkNpmAuth();
|
|
3883
3899
|
if (!authStatus.authenticated) {
|
|
3884
3900
|
console.error(colors.red(`Not authenticated to npm (${authStatus.error}) — run: npm login`));
|
|
3901
|
+
recordBuildIssue(pkg.name || path.basename(cwd), 'error', `npm auth: ${authStatus.error}`);
|
|
3885
3902
|
return false;
|
|
3886
3903
|
}
|
|
3887
3904
|
if (verbose) {
|
|
@@ -3893,6 +3910,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3893
3910
|
console.error(colors.red('ERROR: Failed to create package tarball'));
|
|
3894
3911
|
console.error(colors.yellow('Output:'), packResult.output);
|
|
3895
3912
|
console.error(colors.yellow('Error:'), packResult.stderr);
|
|
3913
|
+
recordBuildIssue(pkg.name || path.basename(cwd), 'error', 'npm pack failed');
|
|
3896
3914
|
return false;
|
|
3897
3915
|
}
|
|
3898
3916
|
// Get the tarball filename from npm pack output
|
|
@@ -3925,6 +3943,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3925
3943
|
}
|
|
3926
3944
|
}
|
|
3927
3945
|
console.error(colors.yellow(' Check .npmignore — you may need to exclude large files or directories.'));
|
|
3946
|
+
recordBuildIssue(pkg.name || path.basename(cwd), 'error', `Tarball too large (${sizeMB.toFixed(0)}MB)`);
|
|
3928
3947
|
// Clean up and abort
|
|
3929
3948
|
try {
|
|
3930
3949
|
fs.unlinkSync(tarballPath);
|
|
@@ -3985,6 +4004,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
3985
4004
|
}
|
|
3986
4005
|
if (!publishResult.success) {
|
|
3987
4006
|
console.error(colors.red('\nERROR: npm publish failed\n'));
|
|
4007
|
+
recordBuildIssue(pkg.name || path.basename(cwd), 'error', 'npm publish failed');
|
|
3988
4008
|
// Check for specific error types
|
|
3989
4009
|
const output = (publishResult.output + '\n' + publishResult.stderr).toLowerCase();
|
|
3990
4010
|
if (output.includes('err_string_too_long') || output.includes('string longer than')) {
|
|
@@ -4086,6 +4106,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
4086
4106
|
else {
|
|
4087
4107
|
console.error(colors.red(`✗ Global link install failed`));
|
|
4088
4108
|
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
4109
|
+
recordBuildIssue(pkgName, 'warning', 'Global link install failed');
|
|
4089
4110
|
}
|
|
4090
4111
|
}
|
|
4091
4112
|
else {
|
|
@@ -4105,6 +4126,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
4105
4126
|
else {
|
|
4106
4127
|
console.error(colors.red(`✗ Global install failed`));
|
|
4107
4128
|
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
4129
|
+
recordBuildIssue(pkgName, 'warning', 'Global install failed');
|
|
4108
4130
|
}
|
|
4109
4131
|
}
|
|
4110
4132
|
else {
|
|
@@ -4123,6 +4145,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
4123
4145
|
else {
|
|
4124
4146
|
console.error(colors.red(`✗ Global install failed`));
|
|
4125
4147
|
console.error(colors.yellow(` Try running manually: npm install -g ${pkgName}@${pkgVersion}`));
|
|
4148
|
+
recordBuildIssue(pkgName, 'warning', 'Global install failed');
|
|
4126
4149
|
}
|
|
4127
4150
|
}
|
|
4128
4151
|
else {
|
|
@@ -4144,6 +4167,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
4144
4167
|
}
|
|
4145
4168
|
else {
|
|
4146
4169
|
console.error(colors.yellow('✗ WSL install failed (is npm installed in WSL?)'));
|
|
4170
|
+
recordBuildIssue(pkgName, 'warning', 'WSL install failed');
|
|
4147
4171
|
}
|
|
4148
4172
|
}
|
|
4149
4173
|
else {
|
|
@@ -4371,6 +4395,7 @@ export async function globalizeWorkspace(rootDir, options = {}, configOptions =
|
|
|
4371
4395
|
success: false,
|
|
4372
4396
|
error: error.message,
|
|
4373
4397
|
});
|
|
4398
|
+
recordBuildIssue(pkgName, 'error', error.message);
|
|
4374
4399
|
console.error(colors.red(`\nError processing ${pkgName}: ${error.message}`));
|
|
4375
4400
|
if (!options.continueOnError) {
|
|
4376
4401
|
console.error(colors.red('Use --continue-on-error to continue with remaining packages.'));
|
|
@@ -4453,6 +4478,7 @@ export async function globalizeWorkspace(rootDir, options = {}, configOptions =
|
|
|
4453
4478
|
else {
|
|
4454
4479
|
console.error(colors.red(`✗ Global install failed`));
|
|
4455
4480
|
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
4481
|
+
recordBuildIssue(pkgName, 'warning', 'Global install failed');
|
|
4456
4482
|
}
|
|
4457
4483
|
}
|
|
4458
4484
|
else {
|
|
@@ -4468,6 +4494,7 @@ export async function globalizeWorkspace(rootDir, options = {}, configOptions =
|
|
|
4468
4494
|
}
|
|
4469
4495
|
else {
|
|
4470
4496
|
console.error(colors.yellow('✗ WSL install failed (is npm installed in WSL?)'));
|
|
4497
|
+
recordBuildIssue(pkgName, 'warning', 'WSL install failed');
|
|
4471
4498
|
}
|
|
4472
4499
|
}
|
|
4473
4500
|
else {
|