@bobfrankston/npmglobalize 1.0.33 → 1.0.34
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 +35 -0
- package/cli.js +18 -16
- package/lib.d.ts +2 -0
- package/lib.js +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,39 @@ It automatically:
|
|
|
47
47
|
2. Publishes `lxlan-node` (depends on lxlan)
|
|
48
48
|
3. Converts and publishes `lxtest`
|
|
49
49
|
|
|
50
|
+
**Settings Propagation (Default Behavior):**
|
|
51
|
+
When publishing `file:` dependencies, these settings are **automatically inherited**:
|
|
52
|
+
- `--update-deps` / `--update-major` (update dependencies)
|
|
53
|
+
- `--fix` (run npm audit fix)
|
|
54
|
+
- `--verbose` / `--quiet`
|
|
55
|
+
- `--force` / `--files`
|
|
56
|
+
|
|
57
|
+
**⚠️ Visibility Settings (Smart Inheritance):**
|
|
58
|
+
- `--npmVisibility` is **only inherited by NEW repositories** (never published to npm before)
|
|
59
|
+
- **Existing repositories** keep their current npm visibility (public/private) unchanged
|
|
60
|
+
- `--gitVisibility` is inherited by all dependencies
|
|
61
|
+
|
|
62
|
+
This ensures you can safely set `--npmVisibility private` as a default for new packages without accidentally changing the visibility of your existing published packages.
|
|
63
|
+
|
|
64
|
+
**Why This Matters:**
|
|
65
|
+
Once a package is published to npm (public or private), changing its visibility later requires careful consideration. This smart inheritance protects your existing packages while making new ones default to safe settings.
|
|
66
|
+
|
|
67
|
+
Example - safely publish with new packages private by default:
|
|
68
|
+
```bash
|
|
69
|
+
npmglobalize --npmVisibility private
|
|
70
|
+
# ✓ Existing npm packages: keep their current visibility
|
|
71
|
+
# ✓ New packages (never published): default to private (safe!)
|
|
72
|
+
# ✓ Regular npm dependencies (express, etc.): unchanged
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Example with configuration file (recommended):
|
|
76
|
+
```bash
|
|
77
|
+
# In main package: create .globalize.json5 with "npmVisibility": "private"
|
|
78
|
+
npmglobalize
|
|
79
|
+
# ✓ Existing repos: publish with their current npm visibility
|
|
80
|
+
# ✓ Brand new repos: inherit private setting
|
|
81
|
+
```
|
|
82
|
+
|
|
50
83
|
**Skip auto-publishing** (use with caution):
|
|
51
84
|
```bash
|
|
52
85
|
npmglobalize -npd # --no-publish-deps
|
|
@@ -74,6 +107,8 @@ npmglobalize --update-major
|
|
|
74
107
|
- Updates to latest including major versions
|
|
75
108
|
- Shows "(MAJOR)" indicator for breaking changes
|
|
76
109
|
|
|
110
|
+
**Note:** The `--update-deps` flag propagates to all file: dependencies, so one command updates your entire dependency tree.
|
|
111
|
+
|
|
77
112
|
### 🔒 Security Auditing
|
|
78
113
|
|
|
79
114
|
**Check vulnerabilities**:
|
package/cli.js
CHANGED
|
@@ -16,22 +16,23 @@ Arguments:
|
|
|
16
16
|
path Path to the project directory (default: current directory)
|
|
17
17
|
|
|
18
18
|
Release Options:
|
|
19
|
-
--patch
|
|
20
|
-
--minor
|
|
21
|
-
--major
|
|
22
|
-
--nopublish, -np
|
|
23
|
-
--cleanup
|
|
19
|
+
--patch Bump patch version (default)
|
|
20
|
+
--minor Bump minor version
|
|
21
|
+
--major Bump major version
|
|
22
|
+
--nopublish, -np Just transform, don't publish
|
|
23
|
+
--cleanup Restore from .dependencies
|
|
24
|
+
-m, --message <msg> Custom commit message (forces release even without changes)
|
|
24
25
|
|
|
25
26
|
Dependency Options:
|
|
26
|
-
--update-deps
|
|
27
|
-
--update-major
|
|
28
|
-
--no-publish-deps, -npd
|
|
29
|
-
--force-publish
|
|
30
|
-
--fix
|
|
27
|
+
--update-deps, -ud Update package.json to latest (minor/patch only, safe)
|
|
28
|
+
--update-major Allow major version updates (breaking changes)
|
|
29
|
+
--no-publish-deps, -npd Don't auto-publish file: dependencies (use with caution)
|
|
30
|
+
--force-publish Republish dependencies even if version exists
|
|
31
|
+
--fix Run npm audit fix after transformation
|
|
31
32
|
|
|
32
33
|
Install Options:
|
|
33
|
-
--install
|
|
34
|
-
--wsl
|
|
34
|
+
--install, -i Global install after publish (Windows)
|
|
35
|
+
--wsl Also install globally in WSL
|
|
35
36
|
|
|
36
37
|
Mode Options:
|
|
37
38
|
--files Keep file: paths after publish (default)
|
|
@@ -46,15 +47,15 @@ Git/npm Visibility:
|
|
|
46
47
|
Other Options:
|
|
47
48
|
--init Initialize git/npm if needed
|
|
48
49
|
--force Continue despite git errors
|
|
49
|
-
--dry-run
|
|
50
|
+
--dry-run Preview what would happen
|
|
50
51
|
--quiet Suppress npm warnings (default)
|
|
51
52
|
--verbose Show detailed output
|
|
52
53
|
--conform Update .gitignore/.npmignore to best practices
|
|
53
54
|
--asis Skip ignore file checks (or set "asis": true in .globalize.json5)
|
|
54
|
-
--fix-tags Automatically fix version/tag mismatches
|
|
55
55
|
--rebase Automatically rebase if local is behind remote
|
|
56
|
-
--
|
|
57
|
-
|
|
56
|
+
--show Show package.json dependency changes
|
|
57
|
+
-h, --help Show this help
|
|
58
|
+
-v, --version Show version number
|
|
58
59
|
|
|
59
60
|
Examples:
|
|
60
61
|
npmglobalize Transform + publish (auto-publishes file: deps)
|
|
@@ -190,6 +191,7 @@ function parseArgs(args) {
|
|
|
190
191
|
options.show = true;
|
|
191
192
|
break;
|
|
192
193
|
case '--update-deps':
|
|
194
|
+
case '-ud':
|
|
193
195
|
options.updateDeps = true;
|
|
194
196
|
break;
|
|
195
197
|
case '--update-major':
|
package/lib.d.ts
CHANGED
|
@@ -68,6 +68,8 @@ export declare function isFileRef(value: string): boolean;
|
|
|
68
68
|
export declare function getLatestVersion(packageName: string): string | null;
|
|
69
69
|
/** Check if a specific version of a package exists on npm */
|
|
70
70
|
export declare function checkVersionExists(packageName: string, version: string): boolean;
|
|
71
|
+
/** Check if a package exists on npm (any version) */
|
|
72
|
+
export declare function checkPackageExists(packageName: string): boolean;
|
|
71
73
|
/** Update existing npm dependencies to latest versions */
|
|
72
74
|
export declare function updateNpmDeps(pkg: any, verbose?: boolean, allowMajor?: boolean): {
|
|
73
75
|
updated: boolean;
|
package/lib.js
CHANGED
|
@@ -169,6 +169,20 @@ export function checkVersionExists(packageName, version) {
|
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
/** Check if a package exists on npm (any version) */
|
|
173
|
+
export function checkPackageExists(packageName) {
|
|
174
|
+
try {
|
|
175
|
+
const result = spawnSync('npm', ['view', packageName, 'version'], {
|
|
176
|
+
encoding: 'utf-8',
|
|
177
|
+
stdio: 'pipe',
|
|
178
|
+
shell: true
|
|
179
|
+
});
|
|
180
|
+
return result.status === 0 && result.stdout.trim().length > 0;
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
172
186
|
/** Parse semver version string to major.minor.patch */
|
|
173
187
|
function parseSemver(version) {
|
|
174
188
|
const clean = version.replace(/^[^\d]*/, ''); // Remove ^, ~, etc.
|
|
@@ -1382,7 +1396,10 @@ export async function globalize(cwd, options = {}) {
|
|
|
1382
1396
|
console.log('');
|
|
1383
1397
|
console.log(colors.yellow(`━━━ Publishing ${name}@${version} ━━━`));
|
|
1384
1398
|
if (!dryRun) {
|
|
1399
|
+
// Check if package has EVER been published to npm (any version)
|
|
1400
|
+
const hasBeenPublished = checkPackageExists(name);
|
|
1385
1401
|
// Recursively call globalize on the dependency
|
|
1402
|
+
// Only pass npmVisibility to truly NEW packages (never published before)
|
|
1386
1403
|
const depSuccess = await globalize(path, {
|
|
1387
1404
|
bump: 'patch', // Use existing version, don't bump
|
|
1388
1405
|
verbose,
|
|
@@ -1390,7 +1407,10 @@ export async function globalize(cwd, options = {}) {
|
|
|
1390
1407
|
force,
|
|
1391
1408
|
files,
|
|
1392
1409
|
gitVisibility,
|
|
1393
|
-
npmVisibility
|
|
1410
|
+
npmVisibility: hasBeenPublished ? undefined : npmVisibility, // Only for new packages
|
|
1411
|
+
updateDeps,
|
|
1412
|
+
updateMajor,
|
|
1413
|
+
fix
|
|
1394
1414
|
});
|
|
1395
1415
|
if (!depSuccess) {
|
|
1396
1416
|
console.error(colors.red(`Failed to publish ${name}`));
|