@bobfrankston/npmglobalize 1.0.53 → 1.0.62
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 +20 -11
- package/lib.d.ts +8 -1
- package/lib.js +95 -124
- package/package.json +9 -3
- package/nul +0 -0
package/cli.js
CHANGED
|
@@ -10,19 +10,28 @@ import { styleText } from 'util';
|
|
|
10
10
|
import JSON5 from 'json5';
|
|
11
11
|
// Check if JS files are up-to-date with TS files
|
|
12
12
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
// Check all .ts files in the directory
|
|
14
|
+
const tsFiles = ['lib.ts', 'cli.ts', 'index.ts'];
|
|
15
|
+
const outOfSync = [];
|
|
16
|
+
for (const tsFile of tsFiles) {
|
|
17
|
+
const tsPath = path.join(__dirname, tsFile);
|
|
18
|
+
const jsPath = path.join(__dirname, tsFile.replace('.ts', '.js'));
|
|
19
|
+
if (fs.existsSync(tsPath) && fs.existsSync(jsPath)) {
|
|
20
|
+
const tsStat = fs.statSync(tsPath);
|
|
21
|
+
const jsStat = fs.statSync(jsPath);
|
|
22
|
+
if (jsStat.mtime < tsStat.mtime) {
|
|
23
|
+
outOfSync.push(tsFile);
|
|
24
|
+
}
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
if (outOfSync.length > 0 && !process.argv.includes('--force')) {
|
|
28
|
+
console.error('\n' + styleText('red', '❌ Build check failed:'));
|
|
29
|
+
console.error(styleText('red', ` ${outOfSync.length} file(s) need compilation:`));
|
|
30
|
+
outOfSync.forEach(f => console.error(styleText('red', ` - ${f}`)));
|
|
31
|
+
console.error('\n' + styleText('yellow', ' Please run: tsc'));
|
|
32
|
+
console.error(styleText('yellow', ' Or use --force to skip this check') + '\n');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
26
35
|
function printHelp() {
|
|
27
36
|
console.log(`
|
|
28
37
|
npmglobalize - Transform file: dependencies to npm versions for publishing
|
package/lib.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* npmglobalize - Transform file: dependencies to npm versions for publishing
|
|
3
|
+
*
|
|
4
|
+
* NOTE: Libraries for future refactoring (currently installed but not used):
|
|
5
|
+
* - simple-git: For git operations instead of execSync
|
|
6
|
+
* - pacote: For npm registry operations instead of spawnSync('npm', ['view', ...])
|
|
7
|
+
* - @types/pacote, @types/npm-package-arg: Type definitions
|
|
8
|
+
*
|
|
9
|
+
* Current approach uses synchronous child_process calls for stability and simplicity.
|
|
10
|
+
* Consider library-based approach if async operations or cross-platform issues arise.
|
|
3
11
|
*/
|
|
4
12
|
/** Options for the globalize operation */
|
|
5
13
|
export interface GlobalizeOptions {
|
|
@@ -119,7 +127,6 @@ export declare function fixVersionTagMismatch(cwd: string, pkg: any, verbose?: b
|
|
|
119
127
|
export declare function runCommand(cmd: string, args: string[], options?: {
|
|
120
128
|
silent?: boolean;
|
|
121
129
|
cwd?: string;
|
|
122
|
-
shell?: boolean;
|
|
123
130
|
}): {
|
|
124
131
|
success: boolean;
|
|
125
132
|
output: string;
|
package/lib.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* npmglobalize - Transform file: dependencies to npm versions for publishing
|
|
3
|
+
*
|
|
4
|
+
* NOTE: Libraries for future refactoring (currently installed but not used):
|
|
5
|
+
* - simple-git: For git operations instead of execSync
|
|
6
|
+
* - pacote: For npm registry operations instead of spawnSync('npm', ['view', ...])
|
|
7
|
+
* - @types/pacote, @types/npm-package-arg: Type definitions
|
|
8
|
+
*
|
|
9
|
+
* Current approach uses synchronous child_process calls for stability and simplicity.
|
|
10
|
+
* Consider library-based approach if async operations or cross-platform issues arise.
|
|
3
11
|
*/
|
|
4
12
|
import fs from 'fs';
|
|
5
13
|
import path from 'path';
|
|
@@ -17,6 +25,10 @@ const colors = {
|
|
|
17
25
|
italic: (text) => styleText('italic', text),
|
|
18
26
|
dim: (text) => styleText('dim', text),
|
|
19
27
|
};
|
|
28
|
+
/** Get npm command for current platform (npm.cmd on Windows, npm elsewhere) */
|
|
29
|
+
function getNpmCommand() {
|
|
30
|
+
return process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
31
|
+
}
|
|
20
32
|
const DEP_KEYS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
|
|
21
33
|
/** Read and parse package.json from a directory */
|
|
22
34
|
export function readPackageJson(dir) {
|
|
@@ -145,8 +157,7 @@ export function getLatestVersion(packageName) {
|
|
|
145
157
|
try {
|
|
146
158
|
const result = spawnSync('npm', ['view', packageName, 'version'], {
|
|
147
159
|
encoding: 'utf-8',
|
|
148
|
-
stdio: 'pipe'
|
|
149
|
-
shell: true
|
|
160
|
+
stdio: 'pipe'
|
|
150
161
|
});
|
|
151
162
|
if (result.status === 0 && result.stdout) {
|
|
152
163
|
return result.stdout.trim();
|
|
@@ -162,8 +173,7 @@ export function checkVersionExists(packageName, version) {
|
|
|
162
173
|
try {
|
|
163
174
|
const result = spawnSync('npm', ['view', `${packageName}@${version}`, 'version'], {
|
|
164
175
|
encoding: 'utf-8',
|
|
165
|
-
stdio: 'pipe'
|
|
166
|
-
shell: true
|
|
176
|
+
stdio: 'pipe'
|
|
167
177
|
});
|
|
168
178
|
return result.status === 0 && result.stdout.trim() === version;
|
|
169
179
|
}
|
|
@@ -176,8 +186,7 @@ export function checkPackageExists(packageName) {
|
|
|
176
186
|
try {
|
|
177
187
|
const result = spawnSync('npm', ['view', packageName, 'version'], {
|
|
178
188
|
encoding: 'utf-8',
|
|
179
|
-
stdio: 'pipe'
|
|
180
|
-
shell: true
|
|
189
|
+
stdio: 'pipe'
|
|
181
190
|
});
|
|
182
191
|
return result.status === 0 && result.stdout.trim().length > 0;
|
|
183
192
|
}
|
|
@@ -190,8 +199,7 @@ export function checkNpmAccess(packageName) {
|
|
|
190
199
|
try {
|
|
191
200
|
const result = spawnSync('npm', ['view', packageName, '--json'], {
|
|
192
201
|
encoding: 'utf-8',
|
|
193
|
-
stdio: 'pipe'
|
|
194
|
-
shell: true
|
|
202
|
+
stdio: 'pipe'
|
|
195
203
|
});
|
|
196
204
|
if (result.status === 0 && result.stdout) {
|
|
197
205
|
const data = JSON.parse(result.stdout);
|
|
@@ -526,13 +534,21 @@ export function fixVersionTagMismatch(cwd, pkg, verbose = false) {
|
|
|
526
534
|
}
|
|
527
535
|
/** Run a command and return success status */
|
|
528
536
|
export function runCommand(cmd, args, options = {}) {
|
|
529
|
-
const { silent = false, cwd
|
|
537
|
+
const { silent = false, cwd } = options;
|
|
530
538
|
try {
|
|
539
|
+
// Only use shell:true for npm commands which need it on Windows
|
|
540
|
+
// Git and other commands work fine without shell
|
|
541
|
+
const needsShell = cmd === 'npm' || cmd === 'npm.cmd';
|
|
542
|
+
// Debug: log the command being executed
|
|
543
|
+
if (!silent) {
|
|
544
|
+
console.log(colors.dim(`[DEBUG] Running: ${cmd} ${args.join(' ')}`));
|
|
545
|
+
}
|
|
531
546
|
const result = spawnSync(cmd, args, {
|
|
532
547
|
encoding: 'utf-8',
|
|
533
548
|
stdio: silent ? 'pipe' : 'inherit',
|
|
534
549
|
cwd,
|
|
535
|
-
|
|
550
|
+
env: process.env, // Always inherit environment variables
|
|
551
|
+
shell: needsShell // Only use shell for npm commands
|
|
536
552
|
});
|
|
537
553
|
// For non-silent commands, we can't capture output when using 'inherit'
|
|
538
554
|
// So we return empty string for output, but the user sees it in the terminal
|
|
@@ -625,7 +641,7 @@ export function getGitStatus(cwd) {
|
|
|
625
641
|
status.hasMergeConflict = fs.existsSync(mergeHead);
|
|
626
642
|
// Get branch info
|
|
627
643
|
try {
|
|
628
|
-
const branch = execSync('git rev-parse --abbrev-ref HEAD
|
|
644
|
+
const branch = execSync('git rev-parse --abbrev-ref HEAD', { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
|
|
629
645
|
status.currentBranch = branch;
|
|
630
646
|
status.isDetachedHead = branch === 'HEAD';
|
|
631
647
|
}
|
|
@@ -634,7 +650,7 @@ export function getGitStatus(cwd) {
|
|
|
634
650
|
}
|
|
635
651
|
// Check for remote
|
|
636
652
|
try {
|
|
637
|
-
const remote = execSync('git remote
|
|
653
|
+
const remote = execSync('git remote', { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
|
|
638
654
|
status.hasRemote = remote.length > 0;
|
|
639
655
|
}
|
|
640
656
|
catch (error) {
|
|
@@ -642,7 +658,7 @@ export function getGitStatus(cwd) {
|
|
|
642
658
|
}
|
|
643
659
|
// Check for uncommitted changes
|
|
644
660
|
try {
|
|
645
|
-
const statusOutput = execSync('git status --porcelain
|
|
661
|
+
const statusOutput = execSync('git status --porcelain', { cwd, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
646
662
|
status.hasUncommitted = statusOutput.trim().length > 0;
|
|
647
663
|
}
|
|
648
664
|
catch (error) {
|
|
@@ -651,7 +667,7 @@ export function getGitStatus(cwd) {
|
|
|
651
667
|
// Check for unpushed commits
|
|
652
668
|
if (status.hasRemote && !status.isDetachedHead && status.currentBranch) {
|
|
653
669
|
try {
|
|
654
|
-
const unpushed = execSync(`git log origin/${status.currentBranch}..HEAD --oneline
|
|
670
|
+
const unpushed = execSync(`git log origin/${status.currentBranch}..HEAD --oneline`, {
|
|
655
671
|
cwd,
|
|
656
672
|
encoding: 'utf-8',
|
|
657
673
|
stdio: ['pipe', 'pipe', 'ignore']
|
|
@@ -663,7 +679,7 @@ export function getGitStatus(cwd) {
|
|
|
663
679
|
}
|
|
664
680
|
// Check if local is behind remote
|
|
665
681
|
try {
|
|
666
|
-
const behind = execSync(`git log HEAD..origin/${status.currentBranch} --oneline
|
|
682
|
+
const behind = execSync(`git log HEAD..origin/${status.currentBranch} --oneline`, {
|
|
667
683
|
cwd,
|
|
668
684
|
encoding: 'utf-8',
|
|
669
685
|
stdio: ['pipe', 'pipe', 'ignore']
|
|
@@ -740,11 +756,13 @@ export async function promptChoice(message, choices) {
|
|
|
740
756
|
/** Check npm authentication status */
|
|
741
757
|
function checkNpmAuth() {
|
|
742
758
|
try {
|
|
743
|
-
//
|
|
759
|
+
// Must use shell:true on Windows to find npm.cmd in PATH
|
|
760
|
+
// Must pass env: process.env to inherit NPM_TOKEN environment variable
|
|
744
761
|
const result = spawnSync('npm', ['whoami'], {
|
|
745
762
|
encoding: 'utf-8',
|
|
746
|
-
|
|
747
|
-
|
|
763
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
764
|
+
env: process.env,
|
|
765
|
+
shell: true
|
|
748
766
|
});
|
|
749
767
|
if (result.status === 0 && result.stdout && result.stdout.trim()) {
|
|
750
768
|
return { authenticated: true, username: result.stdout.trim() };
|
|
@@ -1108,7 +1126,7 @@ export function runNpmAudit(cwd, fix = false, verbose = false) {
|
|
|
1108
1126
|
console.log(colors.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
1109
1127
|
if (fix) {
|
|
1110
1128
|
console.log('Running npm audit fix...');
|
|
1111
|
-
const fixResult = runCommand('npm', ['audit', 'fix'], { cwd, silent: false
|
|
1129
|
+
const fixResult = runCommand('npm', ['audit', 'fix'], { cwd, silent: false });
|
|
1112
1130
|
if (!fixResult.success) {
|
|
1113
1131
|
console.log(colors.yellow('⚠ Some vulnerabilities could not be automatically fixed'));
|
|
1114
1132
|
}
|
|
@@ -1120,8 +1138,7 @@ export function runNpmAudit(cwd, fix = false, verbose = false) {
|
|
|
1120
1138
|
const auditResult = spawnSync('npm', ['audit', '--json'], {
|
|
1121
1139
|
cwd,
|
|
1122
1140
|
encoding: 'utf-8',
|
|
1123
|
-
stdio: 'pipe'
|
|
1124
|
-
shell: true
|
|
1141
|
+
stdio: 'pipe'
|
|
1125
1142
|
});
|
|
1126
1143
|
let hasVulnerabilities = false;
|
|
1127
1144
|
let report = '';
|
|
@@ -1175,7 +1192,7 @@ export function runNpmAudit(cwd, fix = false, verbose = false) {
|
|
|
1175
1192
|
catch (e) {
|
|
1176
1193
|
// Fallback to text output if JSON parsing fails
|
|
1177
1194
|
console.log('Running text audit...');
|
|
1178
|
-
const textResult = runCommand('npm', ['audit'], { cwd, silent: false
|
|
1195
|
+
const textResult = runCommand('npm', ['audit'], { cwd, silent: false });
|
|
1179
1196
|
report = 'Audit completed (see output above)';
|
|
1180
1197
|
}
|
|
1181
1198
|
}
|
|
@@ -1332,39 +1349,6 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1332
1349
|
}
|
|
1333
1350
|
return true;
|
|
1334
1351
|
}
|
|
1335
|
-
// Check npm authentication early (unless dry-run or no-publish)
|
|
1336
|
-
if (!dryRun && !noPublish) {
|
|
1337
|
-
const authStatus = checkNpmAuth();
|
|
1338
|
-
if (!authStatus.authenticated) {
|
|
1339
|
-
console.error(colors.red('\n✗ npm authentication required'));
|
|
1340
|
-
console.error('');
|
|
1341
|
-
if (authStatus.error === 'token expired') {
|
|
1342
|
-
console.error('Your npm access token has expired or been revoked.');
|
|
1343
|
-
console.error('');
|
|
1344
|
-
console.error('To fix this, run:');
|
|
1345
|
-
console.error(colors.yellow(' npm logout'));
|
|
1346
|
-
console.error(colors.yellow(' npm login'));
|
|
1347
|
-
}
|
|
1348
|
-
else if (authStatus.error === 'not logged in') {
|
|
1349
|
-
console.error('You are not logged in to npm.');
|
|
1350
|
-
console.error('');
|
|
1351
|
-
console.error('To fix this, run:');
|
|
1352
|
-
console.error(colors.yellow(' npm login'));
|
|
1353
|
-
}
|
|
1354
|
-
else {
|
|
1355
|
-
console.error(`Authentication error: ${authStatus.error}`);
|
|
1356
|
-
console.error('');
|
|
1357
|
-
console.error('Try running:');
|
|
1358
|
-
console.error(colors.yellow(' npm whoami'));
|
|
1359
|
-
}
|
|
1360
|
-
console.error('');
|
|
1361
|
-
console.error('After logging in, try running this command again.');
|
|
1362
|
-
return false;
|
|
1363
|
-
}
|
|
1364
|
-
if (verbose) {
|
|
1365
|
-
console.log(colors.green(`✓ Authenticated as ${authStatus.username}`));
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
1352
|
// Check git status
|
|
1369
1353
|
const gitStatus = getGitStatus(cwd);
|
|
1370
1354
|
// Handle init mode
|
|
@@ -1396,7 +1380,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1396
1380
|
return false;
|
|
1397
1381
|
}
|
|
1398
1382
|
// Re-check git status after potential init
|
|
1399
|
-
|
|
1383
|
+
let currentGitStatus = getGitStatus(cwd);
|
|
1400
1384
|
// Validate git state
|
|
1401
1385
|
if (currentGitStatus.hasMergeConflict) {
|
|
1402
1386
|
console.error(colors.red('ERROR: Merge conflict detected. Resolve before releasing.'));
|
|
@@ -1743,89 +1727,44 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
1743
1727
|
console.log('Package is private - skipping npm publish.');
|
|
1744
1728
|
return true;
|
|
1745
1729
|
}
|
|
1730
|
+
// Re-check git status after all transformations and potential commits
|
|
1731
|
+
currentGitStatus = getGitStatus(cwd);
|
|
1746
1732
|
// Check if there are changes to commit or a custom message
|
|
1747
1733
|
if (!currentGitStatus.hasUncommitted && !message) {
|
|
1748
1734
|
console.log('');
|
|
1749
1735
|
console.log('No changes to commit and no custom message specified.');
|
|
1750
|
-
// If install flag is set,
|
|
1736
|
+
// If install flag is set, install from local directory
|
|
1751
1737
|
if (install || wsl) {
|
|
1752
1738
|
if (verbose) {
|
|
1753
1739
|
console.log('');
|
|
1754
|
-
console.log('
|
|
1740
|
+
console.log('Installing from local directory...');
|
|
1755
1741
|
}
|
|
1756
1742
|
const pkgName = pkg.name;
|
|
1757
1743
|
if (install) {
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1744
|
+
console.log(`Installing ${pkgName} globally from local directory...`);
|
|
1745
|
+
const localInstallResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false });
|
|
1746
|
+
if (localInstallResult.success) {
|
|
1747
|
+
const version = pkg.version;
|
|
1748
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${version}`));
|
|
1761
1749
|
}
|
|
1762
1750
|
else {
|
|
1763
|
-
console.
|
|
1764
|
-
|
|
1765
|
-
const installResult = runCommand('npm', ['install', '-g', `${pkgName}@latest`], { cwd, silent: false });
|
|
1766
|
-
if (installResult.success) {
|
|
1767
|
-
const reVerify = runCommand('npm', ['list', '-g', '--depth=0', pkgName], { cwd, silent: true });
|
|
1768
|
-
if (reVerify.success) {
|
|
1769
|
-
const version = pkg.version;
|
|
1770
|
-
console.log(colors.green(`✓ Installed and verified globally: ${pkgName}@${version}`));
|
|
1771
|
-
}
|
|
1772
|
-
else {
|
|
1773
|
-
console.log(colors.yellow(`⚠ Install appeared successful but verification failed`));
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
else {
|
|
1777
|
-
// If npm install fails, try installing from local directory
|
|
1778
|
-
console.log(colors.yellow(`Could not install from npm. Trying local installation...`));
|
|
1779
|
-
const localInstallResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false, shell: true });
|
|
1780
|
-
if (localInstallResult.success) {
|
|
1781
|
-
const version = pkg.version;
|
|
1782
|
-
console.log(colors.green(`✓ Installed globally from local: ${pkgName}@${version}`));
|
|
1783
|
-
}
|
|
1784
|
-
else {
|
|
1785
|
-
console.error(colors.red(`✗ Global install failed`));
|
|
1786
|
-
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1751
|
+
console.error(colors.red(`✗ Global install failed`));
|
|
1752
|
+
console.error(colors.yellow(' Try running manually: npm install -g .'));
|
|
1789
1753
|
}
|
|
1790
1754
|
}
|
|
1791
1755
|
if (wsl) {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1756
|
+
console.log(`Installing ${pkgName} in WSL from local directory...`);
|
|
1757
|
+
const wslInstallResult = runCommand('wsl', ['npm', 'install', '-g', '.'], { cwd, silent: false });
|
|
1758
|
+
if (wslInstallResult.success) {
|
|
1759
|
+
const version = pkg.version;
|
|
1760
|
+
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${version}`));
|
|
1795
1761
|
}
|
|
1796
1762
|
else {
|
|
1797
|
-
console.
|
|
1798
|
-
|
|
1799
|
-
const wslInstallResult = runCommand('wsl', ['npm', 'install', '-g', `${pkgName}@latest`], { cwd, silent: false });
|
|
1800
|
-
if (wslInstallResult.success) {
|
|
1801
|
-
const reVerify = runCommand('wsl', ['npm', 'list', '-g', '--depth=0', pkgName], { cwd, silent: true });
|
|
1802
|
-
if (reVerify.success) {
|
|
1803
|
-
const version = pkg.version;
|
|
1804
|
-
console.log(colors.green(`✓ Installed and verified in WSL: ${pkgName}@${version}`));
|
|
1805
|
-
}
|
|
1806
|
-
else {
|
|
1807
|
-
console.log(colors.yellow(`⚠ WSL install appeared successful but verification failed`));
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
else {
|
|
1811
|
-
// If npm install fails, try installing from local directory
|
|
1812
|
-
console.log(colors.yellow(`Could not install from npm. Trying local installation in WSL...`));
|
|
1813
|
-
const localWslInstallResult = runCommand('wsl', ['npm', 'install', '-g', '.'], { cwd, silent: false });
|
|
1814
|
-
if (localWslInstallResult.success) {
|
|
1815
|
-
const version = pkg.version;
|
|
1816
|
-
console.log(colors.green(`✓ Installed in WSL from local: ${pkgName}@${version}`));
|
|
1817
|
-
}
|
|
1818
|
-
else {
|
|
1819
|
-
console.error(colors.yellow('✗ WSL install failed (is npm installed in WSL?)'));
|
|
1820
|
-
console.error(colors.yellow(' Try running manually: wsl npm install -g .'));
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1763
|
+
console.error(colors.red(`✗ WSL install failed`));
|
|
1764
|
+
console.error(colors.yellow(' Try running manually in WSL: npm install -g .'));
|
|
1823
1765
|
}
|
|
1824
1766
|
}
|
|
1825
|
-
console.log('');
|
|
1826
|
-
return true;
|
|
1827
1767
|
}
|
|
1828
|
-
console.log('Nothing to release. Use -m "message" to force a release.');
|
|
1829
1768
|
return true;
|
|
1830
1769
|
}
|
|
1831
1770
|
// Ensure node_modules is in .gitignore before any git operations
|
|
@@ -2018,18 +1957,50 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2018
1957
|
// Publish
|
|
2019
1958
|
console.log('Publishing to npm...');
|
|
2020
1959
|
if (!dryRun) {
|
|
1960
|
+
// Check npm authentication right before publishing
|
|
1961
|
+
const authStatus = checkNpmAuth();
|
|
1962
|
+
if (!authStatus.authenticated) {
|
|
1963
|
+
console.error(colors.red('ERROR: npm authentication required'));
|
|
1964
|
+
console.error('');
|
|
1965
|
+
if (authStatus.error === 'token expired') {
|
|
1966
|
+
console.error('Your npm access token has expired or been revoked.');
|
|
1967
|
+
console.error('');
|
|
1968
|
+
console.error('To fix this, run:');
|
|
1969
|
+
console.error(colors.yellow(' npm logout'));
|
|
1970
|
+
console.error(colors.yellow(' npm login'));
|
|
1971
|
+
}
|
|
1972
|
+
else if (authStatus.error === 'not logged in') {
|
|
1973
|
+
console.error('You are not logged in to npm.');
|
|
1974
|
+
console.error('');
|
|
1975
|
+
console.error('To fix this, run:');
|
|
1976
|
+
console.error(colors.yellow(' npm login'));
|
|
1977
|
+
}
|
|
1978
|
+
else {
|
|
1979
|
+
console.error(`Authentication error: ${authStatus.error}`);
|
|
1980
|
+
console.error('');
|
|
1981
|
+
console.error('Try running:');
|
|
1982
|
+
console.error(colors.yellow(' npm whoami'));
|
|
1983
|
+
}
|
|
1984
|
+
console.error('');
|
|
1985
|
+
console.error('After logging in, try running this command again.');
|
|
1986
|
+
return false;
|
|
1987
|
+
}
|
|
1988
|
+
if (verbose) {
|
|
1989
|
+
console.log(colors.green(`✓ Authenticated as ${authStatus.username}`));
|
|
1990
|
+
}
|
|
2021
1991
|
// Create tarball first
|
|
2022
|
-
const packResult = runCommand('npm', ['pack'], { cwd, silent: true
|
|
1992
|
+
const packResult = runCommand('npm', ['pack'], { cwd, silent: true });
|
|
2023
1993
|
if (!packResult.success) {
|
|
2024
1994
|
console.error(colors.red('ERROR: Failed to create package tarball'));
|
|
2025
|
-
|
|
2026
|
-
|
|
1995
|
+
console.error(colors.yellow('Output:'), packResult.output);
|
|
1996
|
+
console.error(colors.yellow('Error:'), packResult.stderr);
|
|
2027
1997
|
return false;
|
|
2028
1998
|
}
|
|
2029
1999
|
// Get the tarball filename from npm pack output
|
|
2030
2000
|
const tarballName = packResult.output.trim().split('\n').pop()?.trim();
|
|
2031
2001
|
if (!tarballName) {
|
|
2032
2002
|
console.error(colors.red('ERROR: Could not determine tarball filename'));
|
|
2003
|
+
console.error(colors.yellow('npm pack output:'), packResult.output);
|
|
2033
2004
|
return false;
|
|
2034
2005
|
}
|
|
2035
2006
|
const tarballPath = path.join(cwd, tarballName);
|
|
@@ -2068,7 +2039,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2068
2039
|
console.log(colors.yellow(`⏱ Waiting ${retryDelay} seconds before retry (attempt ${attempt + 1}/${maxRetries})...`));
|
|
2069
2040
|
await new Promise(resolve => setTimeout(resolve, retryDelay * 1000));
|
|
2070
2041
|
}
|
|
2071
|
-
publishResult = runCommand('npm', npmArgs, { cwd, silent: true
|
|
2042
|
+
publishResult = runCommand('npm', npmArgs, { cwd, silent: true });
|
|
2072
2043
|
if (publishResult.success) {
|
|
2073
2044
|
break; // Success!
|
|
2074
2045
|
}
|
|
@@ -2213,7 +2184,7 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
|
|
|
2213
2184
|
console.log(`Installing globally: ${pkgName}@${pkgVersion}...`);
|
|
2214
2185
|
if (!dryRun) {
|
|
2215
2186
|
// Install from local directory (faster and works immediately after publish)
|
|
2216
|
-
const installResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false
|
|
2187
|
+
const installResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false });
|
|
2217
2188
|
if (installResult.success) {
|
|
2218
2189
|
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
2219
2190
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/npmglobalize",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.62",
|
|
4
4
|
"description": "Transform file: dependencies to npm versions for publishing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,14 +22,20 @@
|
|
|
22
22
|
"author": "Bob Frankston",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^25.0.9"
|
|
25
|
+
"@types/node": "^25.0.9",
|
|
26
|
+
"@types/npm-package-arg": "^6.1.4",
|
|
27
|
+
"@types/pacote": "^11.1.8"
|
|
26
28
|
},
|
|
27
29
|
"repository": {
|
|
28
30
|
"type": "git",
|
|
29
31
|
"url": "https://github.com/BobFrankston/npmglobalize.git"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
34
|
+
"@npmcli/package-json": "^7.0.4",
|
|
32
35
|
"json5": "^2.2.3",
|
|
33
|
-
"libnpmversion": "^8.0.3"
|
|
36
|
+
"libnpmversion": "^8.0.3",
|
|
37
|
+
"npm-registry-fetch": "^19.1.1",
|
|
38
|
+
"pacote": "^21.0.4",
|
|
39
|
+
"simple-git": "^3.30.0"
|
|
34
40
|
}
|
|
35
41
|
}
|
package/nul
DELETED
|
File without changes
|