@bobfrankston/npmglobalize 1.0.20 → 1.0.22
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 +14 -22
- 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
|
@@ -1192,6 +1192,10 @@ export async function globalize(cwd, options = {}) {
|
|
|
1192
1192
|
console.log(' [dry-run] Would run npm audit');
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
|
+
else if (fix && !dryRun) {
|
|
1196
|
+
// Run fix even if no deps changed
|
|
1197
|
+
runNpmAudit(cwd, fix, verbose);
|
|
1198
|
+
}
|
|
1195
1199
|
if (noPublish) {
|
|
1196
1200
|
console.log('Transform complete (--nopublish mode).');
|
|
1197
1201
|
return true;
|
|
@@ -1417,22 +1421,16 @@ export async function globalize(cwd, options = {}) {
|
|
|
1417
1421
|
}
|
|
1418
1422
|
}
|
|
1419
1423
|
// Global install
|
|
1420
|
-
const
|
|
1421
|
-
const
|
|
1424
|
+
const updatedPkg = readPackageJson(cwd); // Re-read to get updated version
|
|
1425
|
+
const pkgName = updatedPkg.name;
|
|
1426
|
+
const pkgVersion = updatedPkg.version;
|
|
1422
1427
|
if (install) {
|
|
1423
1428
|
console.log(`Installing globally: ${pkgName}@${pkgVersion}...`);
|
|
1424
1429
|
if (!dryRun) {
|
|
1425
1430
|
// Install from local directory (faster and works immediately after publish)
|
|
1426
1431
|
const installResult = runCommand('npm', ['install', '-g', '.'], { cwd, silent: false, shell: true });
|
|
1427
1432
|
if (installResult.success) {
|
|
1428
|
-
|
|
1429
|
-
const verifyResult = runCommand('npm', ['list', '-g', '--depth=0', pkgName], { cwd, silent: true });
|
|
1430
|
-
if (verifyResult.success) {
|
|
1431
|
-
console.log(colors.green(`✓ Installed and verified globally: ${pkgName}@${pkgVersion}`));
|
|
1432
|
-
}
|
|
1433
|
-
else {
|
|
1434
|
-
console.log(colors.yellow(`⚠ Install appeared successful but verification failed`));
|
|
1435
|
-
}
|
|
1433
|
+
console.log(colors.green(`✓ Installed globally: ${pkgName}@${pkgVersion}`));
|
|
1436
1434
|
}
|
|
1437
1435
|
else {
|
|
1438
1436
|
console.error(colors.red(`✗ Global install failed`));
|
|
@@ -1449,17 +1447,10 @@ export async function globalize(cwd, options = {}) {
|
|
|
1449
1447
|
// Install from local directory in WSL
|
|
1450
1448
|
const wslResult = runCommand('wsl', ['npm', 'install', '-g', '.'], { cwd, silent: false });
|
|
1451
1449
|
if (wslResult.success) {
|
|
1452
|
-
|
|
1453
|
-
const verifyResult = runCommand('wsl', ['npm', 'list', '-g', '--depth=0', pkgName], { cwd, silent: true });
|
|
1454
|
-
if (verifyResult.success) {
|
|
1455
|
-
console.log(colors.green(`✓ Installed and verified in WSL: ${pkgName}@${pkgVersion}`));
|
|
1456
|
-
}
|
|
1457
|
-
else {
|
|
1458
|
-
console.log(colors.yellow(`⚠ WSL install appeared successful but verification failed`));
|
|
1459
|
-
}
|
|
1450
|
+
console.log(colors.green(`✓ Installed in WSL: ${pkgName}@${pkgVersion}`));
|
|
1460
1451
|
}
|
|
1461
1452
|
else {
|
|
1462
|
-
console.error(colors.yellow('
|
|
1453
|
+
console.error(colors.yellow('✗ WSL install failed (is npm installed in WSL?)'));
|
|
1463
1454
|
}
|
|
1464
1455
|
}
|
|
1465
1456
|
else {
|
|
@@ -1485,9 +1476,10 @@ export async function globalize(cwd, options = {}) {
|
|
|
1485
1476
|
console.log('Keeping npm versions (--nofiles mode).');
|
|
1486
1477
|
}
|
|
1487
1478
|
console.log('Done!');
|
|
1488
|
-
// Run final audit if
|
|
1489
|
-
|
|
1490
|
-
|
|
1479
|
+
// Run final audit report if not already run
|
|
1480
|
+
const auditAlreadyRun = (fix || updateDeps) && (transformResult.transformed || alreadyTransformed || updateDeps);
|
|
1481
|
+
if (!auditAlreadyRun && (fix || updateDeps || transformResult.transformed) && !dryRun) {
|
|
1482
|
+
runNpmAudit(cwd, false, verbose); // Just report, don't fix again
|
|
1491
1483
|
}
|
|
1492
1484
|
// Print summary
|
|
1493
1485
|
console.log('');
|