@bobfrankston/npmglobalize 1.0.21 → 1.0.23
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/README.md +280 -0
- package/lib.js +25 -17
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# npmglobalize
|
|
2
|
+
|
|
3
|
+
Transform `file:` dependencies to npm versions for publishing.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`npmglobalize` automates the workflow of publishing npm packages that use local `file:` references during development. It converts those references to proper npm versions, publishes everything in dependency order, and optionally restores the local references afterward.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g @bobfrankston/npmglobalize
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Basic Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd your-package
|
|
19
|
+
npmglobalize # Transform + publish (patch version)
|
|
20
|
+
npmglobalize --minor # Bump minor version
|
|
21
|
+
npmglobalize --major # Bump major version
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Key Features
|
|
25
|
+
|
|
26
|
+
### 🔗 Automatic Dependency Publishing (Default)
|
|
27
|
+
|
|
28
|
+
By default, `npmglobalize` ensures all `file:` dependencies are published **before** converting them:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npmglobalize # Auto-publishes file: deps in correct order
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If you have:
|
|
35
|
+
```
|
|
36
|
+
lxtest
|
|
37
|
+
├── file:../lxlan-node
|
|
38
|
+
│ └── file:../lxland
|
|
39
|
+
└── file:../lxland
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
It automatically:
|
|
43
|
+
1. Publishes `lxland` (root dependency)
|
|
44
|
+
2. Publishes `lxlan-node` (depends on lxland)
|
|
45
|
+
3. Converts and publishes `lxtest`
|
|
46
|
+
|
|
47
|
+
**Skip auto-publishing** (use with caution):
|
|
48
|
+
```bash
|
|
49
|
+
npmglobalize -npd # --no-publish-deps
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Force republish** all file: dependencies even if versions exist:
|
|
53
|
+
```bash
|
|
54
|
+
npmglobalize --force-publish
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 📦 Dependency Updates
|
|
58
|
+
|
|
59
|
+
**Safe updates** (minor/patch only, respects semver):
|
|
60
|
+
```bash
|
|
61
|
+
npmglobalize --update-deps
|
|
62
|
+
```
|
|
63
|
+
- `express ^4.18.0` → `^4.21.0` ✓
|
|
64
|
+
- `lodash ^4.17.0` → `^4.17.21` ✓
|
|
65
|
+
- Won't update to `express ^5.0.0` (breaking change)
|
|
66
|
+
|
|
67
|
+
**Include major updates** (breaking changes):
|
|
68
|
+
```bash
|
|
69
|
+
npmglobalize --update-major
|
|
70
|
+
```
|
|
71
|
+
- Updates to latest including major versions
|
|
72
|
+
- Shows "(MAJOR)" indicator for breaking changes
|
|
73
|
+
|
|
74
|
+
### 🔒 Security Auditing
|
|
75
|
+
|
|
76
|
+
**Check vulnerabilities**:
|
|
77
|
+
```bash
|
|
78
|
+
npmglobalize # Shows audit at end
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Auto-fix vulnerabilities**:
|
|
82
|
+
```bash
|
|
83
|
+
npmglobalize --fix # Runs npm audit fix
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Disable audit**:
|
|
87
|
+
```bash
|
|
88
|
+
npmglobalize --no-fix
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 🔄 File Reference Management
|
|
92
|
+
|
|
93
|
+
**Default behavior** (restore file: references after publish):
|
|
94
|
+
```bash
|
|
95
|
+
npmglobalize # Converts file: → npm, publishes, then restores file:
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Keep npm references** permanently:
|
|
99
|
+
```bash
|
|
100
|
+
npmglobalize --nofiles # Don't restore file: references
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Just transform** without publishing:
|
|
104
|
+
```bash
|
|
105
|
+
npmglobalize -np # --nopublish (formerly --apply)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Restore** from backup:
|
|
109
|
+
```bash
|
|
110
|
+
npmglobalize --cleanup # Restore original file: references
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Command Reference
|
|
114
|
+
|
|
115
|
+
### Release Options
|
|
116
|
+
```
|
|
117
|
+
--patch Bump patch version (default: 1.0.0 → 1.0.1)
|
|
118
|
+
--minor Bump minor version (1.0.0 → 1.1.0)
|
|
119
|
+
--major Bump major version (1.0.0 → 2.0.0)
|
|
120
|
+
--nopublish, -np Just transform, don't publish
|
|
121
|
+
--cleanup Restore file: dependencies from backup
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Dependency Options
|
|
125
|
+
```
|
|
126
|
+
--update-deps Update package.json to latest versions (safe: minor/patch)
|
|
127
|
+
--update-major Allow major version updates (breaking changes)
|
|
128
|
+
--no-publish-deps, -npd Skip auto-publishing file: dependencies
|
|
129
|
+
--force-publish Republish dependencies even if version exists
|
|
130
|
+
--fix Run npm audit fix after transformation
|
|
131
|
+
--no-fix Don't run npm audit
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Install Options
|
|
135
|
+
```
|
|
136
|
+
--install, -i Install globally after publish (Windows)
|
|
137
|
+
--wsl Also install in WSL
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Mode Options
|
|
141
|
+
```
|
|
142
|
+
--files Keep file: paths after publish (default)
|
|
143
|
+
--nofiles Keep npm versions permanently
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Git/npm Visibility
|
|
147
|
+
```
|
|
148
|
+
--git private Make git repo private (default)
|
|
149
|
+
--git public Make git repo public
|
|
150
|
+
--npm private Mark package private (skip publish)
|
|
151
|
+
--npm public Publish to npm (default)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Other Options
|
|
155
|
+
```
|
|
156
|
+
--init Initialize git/npm if needed
|
|
157
|
+
--force Continue despite git errors
|
|
158
|
+
--dry-run Preview what would happen
|
|
159
|
+
--quiet Suppress npm warnings (default)
|
|
160
|
+
--verbose Show detailed output
|
|
161
|
+
--conform Update .gitignore/.npmignore to best practices
|
|
162
|
+
--asis Skip ignore file checks
|
|
163
|
+
--help, -h Show help
|
|
164
|
+
--version, -v Show version
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Configuration File
|
|
168
|
+
|
|
169
|
+
Settings can be saved in `.globalize.json5`:
|
|
170
|
+
|
|
171
|
+
```json5
|
|
172
|
+
{
|
|
173
|
+
// npmglobalize configuration (JSON5 format)
|
|
174
|
+
"bump": "patch", // Version bump type
|
|
175
|
+
"install": true, // Auto-install globally
|
|
176
|
+
"wsl": false, // Also install in WSL
|
|
177
|
+
"fix": true, // Auto-run npm audit fix
|
|
178
|
+
"verbose": false, // Show detailed output
|
|
179
|
+
"gitVisibility": "private",
|
|
180
|
+
"npmVisibility": "public"
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Configuration persists across runs. CLI flags override config file.
|
|
185
|
+
|
|
186
|
+
## Common Workflows
|
|
187
|
+
|
|
188
|
+
### Standard Release
|
|
189
|
+
```bash
|
|
190
|
+
npmglobalize --install # Publish + install globally
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Release with Dependency Chain
|
|
194
|
+
```bash
|
|
195
|
+
cd my-app # Has file: deps
|
|
196
|
+
npmglobalize # Publishes all deps automatically
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Safe Dependency Updates
|
|
200
|
+
```bash
|
|
201
|
+
npmglobalize --update-deps # Update to latest safe versions
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Security Fixes
|
|
205
|
+
```bash
|
|
206
|
+
npmglobalize --fix # Fix vulnerabilities + release
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Force Update Everything
|
|
210
|
+
```bash
|
|
211
|
+
npmglobalize --force-publish --update-major
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Preview Changes
|
|
215
|
+
```bash
|
|
216
|
+
npmglobalize --dry-run # See what would happen
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## How It Works
|
|
220
|
+
|
|
221
|
+
1. **Validates** package.json and git status
|
|
222
|
+
2. **Updates dependencies** (if `--update-deps`)
|
|
223
|
+
3. **Publishes file: dependencies** (if needed)
|
|
224
|
+
4. **Backs up** original file: references to `.dependencies`
|
|
225
|
+
5. **Converts** `file:` → npm version references
|
|
226
|
+
6. **Commits** changes
|
|
227
|
+
7. **Bumps** version (using npm version)
|
|
228
|
+
8. **Publishes** to npm
|
|
229
|
+
9. **Pushes** to git
|
|
230
|
+
10. **Installs** globally (if `--install`)
|
|
231
|
+
11. **Restores** file: references (if `--files`, default)
|
|
232
|
+
12. **Runs audit** (shows security status)
|
|
233
|
+
|
|
234
|
+
## Version Checking
|
|
235
|
+
|
|
236
|
+
When publishing file: dependencies, checks if each version exists on npm:
|
|
237
|
+
- ✅ Exists → Skip, use existing version
|
|
238
|
+
- ❌ Missing → Publish it first
|
|
239
|
+
- 🔄 Force → Use `--force-publish` to republish
|
|
240
|
+
|
|
241
|
+
## Examples
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Basic release
|
|
245
|
+
npmglobalize
|
|
246
|
+
|
|
247
|
+
# Release with updates and security fixes
|
|
248
|
+
npmglobalize --update-deps --fix
|
|
249
|
+
|
|
250
|
+
# Just update package.json, don't publish
|
|
251
|
+
npmglobalize -np --update-deps
|
|
252
|
+
|
|
253
|
+
# Force republish all dependencies
|
|
254
|
+
npmglobalize --force-publish --update-major
|
|
255
|
+
|
|
256
|
+
# Release + install on Windows and WSL
|
|
257
|
+
npmglobalize --install --wsl
|
|
258
|
+
|
|
259
|
+
# Restore original file: references
|
|
260
|
+
npmglobalize --cleanup
|
|
261
|
+
|
|
262
|
+
# Preview what would happen
|
|
263
|
+
npmglobalize --dry-run --verbose
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Authentication
|
|
267
|
+
|
|
268
|
+
Requires npm authentication:
|
|
269
|
+
```bash
|
|
270
|
+
npm login
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Check authentication:
|
|
274
|
+
```bash
|
|
275
|
+
npm whoami
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## License
|
|
279
|
+
|
|
280
|
+
MIT
|
package/lib.js
CHANGED
|
@@ -1308,6 +1308,28 @@ export async function globalize(cwd, options = {}) {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
catch (error) {
|
|
1310
1310
|
console.error(colors.red('ERROR: Version bump failed:'), error.message);
|
|
1311
|
+
// Show additional error details if available
|
|
1312
|
+
if (error.stderr || error.stdout || error.code) {
|
|
1313
|
+
if (error.stderr)
|
|
1314
|
+
console.error(' stderr:', error.stderr);
|
|
1315
|
+
if (error.stdout)
|
|
1316
|
+
console.error(' stdout:', error.stdout);
|
|
1317
|
+
if (error.code)
|
|
1318
|
+
console.error(' exit code:', error.code);
|
|
1319
|
+
}
|
|
1320
|
+
// Show the full error stack in verbose mode
|
|
1321
|
+
if (verbose && error.stack) {
|
|
1322
|
+
console.error(' Stack trace:', error.stack);
|
|
1323
|
+
}
|
|
1324
|
+
// Try to provide more context
|
|
1325
|
+
if (error.message?.includes('unknown git error')) {
|
|
1326
|
+
console.error(colors.yellow('\nPossible causes:'));
|
|
1327
|
+
console.error(' • Git hooks (pre-commit, commit-msg) might be failing');
|
|
1328
|
+
console.error(' • GPG signing might be required but not configured');
|
|
1329
|
+
console.error(' • Git config issues (user.name, user.email)');
|
|
1330
|
+
console.error(' • Disk space or permissions issues');
|
|
1331
|
+
console.error(colors.yellow('\nTry running with --verbose or check git status manually'));
|
|
1332
|
+
}
|
|
1311
1333
|
if (!force) {
|
|
1312
1334
|
return false;
|
|
1313
1335
|
}
|
|
@@ -1430,14 +1452,7 @@ export async function globalize(cwd, options = {}) {
|
|
|
1430
1452
|
// Install from local directory (faster and works immediately after publish)
|
|
1431
1453
|
const installResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false, shell: true });
|
|
1432
1454
|
if (installResult.success) {
|
|
1433
|
-
|
|
1434
|
-
const verifyResult = runCommand('npm', ['list', '-g', '--depth=0', pkgName], { cwd, silent: true });
|
|
1435
|
-
if (verifyResult.success) {
|
|
1436
|
-
console.log(colors.green(`✓ Installed and verified globally: ${pkgName}@${pkgVersion}`));
|
|
1437
|
-
}
|
|
1438
|
-
else {
|
|
1439
|
-
console.log(colors.yellow(`⚠ Install appeared successful but verification failed`));
|
|
1440
|
-
}
|
|
1455
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
1441
1456
|
}
|
|
1442
1457
|
else {
|
|
1443
1458
|
console.error(colors.red(`✗ Global install failed`));
|
|
@@ -1454,17 +1469,10 @@ export async function globalize(cwd, options = {}) {
|
|
|
1454
1469
|
// Install from local directory in WSL
|
|
1455
1470
|
const wslResult = runCommand('wsl', ['npm', 'install', '-g', '.'], { cwd, silent: false });
|
|
1456
1471
|
if (wslResult.success) {
|
|
1457
|
-
|
|
1458
|
-
const verifyResult = runCommand('wsl', ['npm', 'list', '-g', '--depth=0', pkgName], { cwd, silent: true });
|
|
1459
|
-
if (verifyResult.success) {
|
|
1460
|
-
console.log(colors.green(`✓ Installed and verified in WSL: ${pkgName}@${pkgVersion}`));
|
|
1461
|
-
}
|
|
1462
|
-
else {
|
|
1463
|
-
console.log(colors.yellow(`⚠ WSL install appeared successful but verification failed`));
|
|
1464
|
-
}
|
|
1472
|
+
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${pkgVersion}`));
|
|
1465
1473
|
}
|
|
1466
1474
|
else {
|
|
1467
|
-
console.error(colors.yellow('
|
|
1475
|
+
console.error(colors.yellow('✗ WSL install failed (is npm installed in WSL?)'));
|
|
1468
1476
|
}
|
|
1469
1477
|
}
|
|
1470
1478
|
else {
|