@bobfrankston/npmglobalize 1.0.199 โ†’ 1.0.201

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 CHANGED
@@ -157,6 +157,51 @@ npmglobalize --fix # Runs npm audit fix
157
157
  npmglobalize --no-fix
158
158
  ```
159
159
 
160
+ ### ๐Ÿงฉ Install Scripts (npm `allowScripts`)
161
+
162
+ npm 11.17+ skips install-time lifecycle scripts (`preinstall`/`install`/
163
+ `postinstall`) for packages that aren't on an allowlist. A **global** install
164
+ has no project `package.json` to record approvals in, so without help a
165
+ postinstall you wrote yourself silently never runs while the install still
166
+ exits 0 โ€” e.g. `@bobfrankston/msger`'s postinstall copies its native binary
167
+ into the per-user bin dir its launcher reads from, and skipping it leaves a
168
+ stale exe behind a green checkmark.
169
+
170
+ npmglobalize therefore allowlists **your own packages** on the global install
171
+ it performs โ€” it just built and published them from your source, so they're
172
+ trusted โ€” and leaves third-party packages gated:
173
+
174
+ ```
175
+ > npm install -g @bobfrankston/winpos@2.0.51 --allow-scripts @bobfrankston/winpos,@bobfrankston/msger,@bobfrankston/msgcommon
176
+ ```
177
+
178
+ Anything npm skips is reported rather than buried in the captured output:
179
+
180
+ ```
181
+ ยท Skipped koffi@2.16.3 install script โ€” prebuilt-binary fetcher, the package ships binaries; normally harmless.
182
+ โš  npm skipped install scripts for third-party packages: sharp@0.33.0
183
+ sharp@0.33.0 (install: node install/check)
184
+ These may be broken at runtime โ€” no prebuilt fallback recognized.
185
+ To run them anyway: npm install -g @bobfrankston/winpos@2.0.51 --allow-scripts @bobfrankston/winpos,@bobfrankston/msger,koffi,sharp
186
+ ```
187
+
188
+ Two details worth knowing:
189
+
190
+ - **Prebuilt fetchers are called out separately.** npm names the skipped
191
+ script, so a runner like `cnoke`, `prebuild-install`, `node-gyp-build`,
192
+ `prebuildify` or `napi-postinstall` is recognized as one that only compiles
193
+ when no prebuild matches. Those packages ship working binaries โ€” koffi
194
+ carries `build/koffi/<platform>/koffi.node` for every platform it supports โ€”
195
+ so the skip gets an informational note, not a warning.
196
+ - **The suggested re-run command includes your own packages.** npm takes the
197
+ allowlist from the first source that has one rather than merging sources, so
198
+ a command naming only the third-party package would silently re-gate yours.
199
+ Always run the full list.
200
+
201
+ An own-scope package showing up as skipped is reported louder โ€” that means the
202
+ allowlist missed it, usually a transitive dep not present in the local
203
+ `node_modules` tree.
204
+
160
205
  ### ๐Ÿ”‘ OAuth Credentials Handling
161
206
 
162
207
  `npmglobalize` automatically detects `credentials.json` files and handles them based on OAuth app type:
@@ -534,8 +579,9 @@ is planned.
534
579
 
535
580
  ### `upstream` โ€” who consumes this package
536
581
 
537
- Bookkeeping, not a setting. When a package with `file:` deps publishes,
538
- npmglobalize appends an entry to each **dependency's** `.globalize.json5`:
582
+ **Experimental.** Bookkeeping, not a setting. When a package with `file:` deps
583
+ publishes, npmglobalize appends an entry to each **dependency's**
584
+ `.globalize.json5`:
539
585
 
540
586
  ```json5
541
587
  {
@@ -557,19 +603,42 @@ checkout path, its version at the time, and the date.
557
603
 
558
604
  Only **immediate** consumers are recorded. A full consumer tree is a walk, not
559
605
  a copy: follow each entry's path and read that package's own `upstream` list.
560
-
561
- The list is **FYI for now** โ€” it is recorded, preserved across publishes, and
562
- printed in the Release Summary of the package that owns it. Nothing is
563
- rebuilt, republished, or reinstalled on its behalf. An entry is added the
564
- first time a consumer publishes after this feature landed, and refreshed in
565
- place on every publish after that.
566
-
567
- The entry is written into the dependency's own checkout, then committed there
568
- (`Record upstream <consumer>@<version>`) and pushed if that repo has a remote.
569
- Only `.globalize.json5` is staged and committed, by pathspec โ€” anything else
570
- the dependency had staged or modified is left exactly as it was. If the
571
- dependency isn't a git repo, or ignores `.globalize.json5`, the file is still
572
- written and the commit is skipped.
606
+ That keeps each file small and self-maintaining โ€” no package has to know about
607
+ anything beyond its own direct consumers.
608
+
609
+ The list is **FYI** โ€” it is recorded, preserved across publishes, and printed
610
+ in the Release Summary of the package that owns it. Nothing is rebuilt,
611
+ republished, or reinstalled on its behalf. An entry appears the first time a
612
+ consumer publishes, and is refreshed in place on every publish after that.
613
+
614
+ #### Scope and limits
615
+
616
+ **`file:` deps only.** A dependency referenced by npm version (`"^0.1.39"`)
617
+ is never recorded, because npmglobalize has no checkout path for it โ€” it
618
+ consumes the published tarball, not a sibling directory. To have a consumer
619
+ show up in a library's list, that consumer must reference it as
620
+ `file:../<lib>`.
621
+
622
+ **Usually not committed.** The entry is written into the dependency's own
623
+ checkout, and npmglobalize then tries to commit it there
624
+ (`Record upstream <consumer>@<version>`) and push if that repo has a remote.
625
+ In practice that commit is usually skipped: `.globalize.json5` is in the
626
+ standard ignore template, so most repos ignore it and the entry stays as
627
+ untracked local state. That is a reasonable failure mode for an experimental
628
+ mechanism โ€” the list rewrites itself on every publish, so there is nothing to
629
+ merge and nothing to reconcile between machines. It also means the list is
630
+ **per-machine**, not shared history.
631
+
632
+ When the commit does happen (a repo that tracks its `.globalize.json5`, as
633
+ npmglobalize itself does), only that one file is staged and committed by
634
+ pathspec โ€” anything else the dependency had staged or modified is left exactly
635
+ as it was. A dependency that isn't a git repo is written and skipped the same
636
+ way.
637
+
638
+ The alternative would be recording this in `package.json`, which is tracked
639
+ and published โ€” every consumer of a library would then download that library's
640
+ list of local checkout paths in its tarball. Keeping it in `.globalize.json5`
641
+ keeps it out of the package entirely.
573
642
 
574
643
  ## Common Workflows
575
644
 
package/cli.js CHANGED
@@ -112,6 +112,7 @@ Other Options:
112
112
  -force Continue despite git errors
113
113
  -dry-run Preview what would happen
114
114
  -quiet Suppress npm warnings (default)
115
+ -noquiet Show npm warnings (without -verbose's extra detail)
115
116
  -verbose Show detailed output
116
117
  -conform Update .gitignore/.npmignore to best practices
117
118
  (noEmit projects: removes TS ignores from .npmignore)
@@ -268,6 +269,10 @@ function parseArgs(args) {
268
269
  case '-quiet':
269
270
  options.quiet = true;
270
271
  break;
272
+ case '-noquiet':
273
+ options.quiet = false;
274
+ options.explicitKeys.add('quiet');
275
+ break;
271
276
  case '-verbose':
272
277
  options.verbose = true;
273
278
  options.quiet = false;
package/lib.js CHANGED
@@ -5334,9 +5334,9 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
5334
5334
  if (configOptions.link)
5335
5335
  settings.push('--link');
5336
5336
  if (configOptions.npmVisibility)
5337
- settings.push(`--npm-visibility ${configOptions.npmVisibility}`);
5337
+ settings.push(`-npm ${configOptions.npmVisibility}`);
5338
5338
  if (configOptions.gitVisibility)
5339
- settings.push(`--git-visibility ${configOptions.gitVisibility}`);
5339
+ settings.push(`-git ${configOptions.gitVisibility}`);
5340
5340
  if (configOptions.conform)
5341
5341
  settings.push('--conform');
5342
5342
  if (configOptions.asis)
@@ -5358,15 +5358,15 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
5358
5358
  if (configOptions.dryRun)
5359
5359
  settings.push('--dry-run');
5360
5360
  if (configOptions.bump)
5361
- settings.push(`--bump ${configOptions.bump}`);
5361
+ settings.push(`-${configOptions.bump}`);
5362
5362
  if (configOptions.cleanup)
5363
5363
  settings.push('--cleanup');
5364
5364
  if (configOptions.wsl)
5365
5365
  settings.push('--wsl');
5366
5366
  if (configOptions.files === false)
5367
- settings.push('--no-files');
5367
+ settings.push('-nofiles');
5368
5368
  if (configOptions.quiet === false)
5369
- settings.push('--no-quiet');
5369
+ settings.push('-noquiet');
5370
5370
  if (configOptions.publishDeps === false)
5371
5371
  settings.push('--no-publish-deps');
5372
5372
  if (configOptions.forcePublish)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.199",
3
+ "version": "1.0.201",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@bobfrankston/freezepak": "^0.1.9",
35
- "@bobfrankston/importgen": "^0.1.39",
35
+ "@bobfrankston/importgen": "^0.1.40",
36
36
  "@bobfrankston/themecolors": "^0.1.8",
37
37
  "@bobfrankston/userconfig": "^1.0.10",
38
38
  "@npmcli/package-json": "^7.0.4",
@@ -60,7 +60,7 @@
60
60
  ".transformedSnapshot": {
61
61
  "dependencies": {
62
62
  "@bobfrankston/freezepak": "^0.1.9",
63
- "@bobfrankston/importgen": "^0.1.39",
63
+ "@bobfrankston/importgen": "^0.1.40",
64
64
  "@bobfrankston/themecolors": "^0.1.8",
65
65
  "@bobfrankston/userconfig": "^1.0.10",
66
66
  "@npmcli/package-json": "^7.0.4",
package/lib/config.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { type NpmCommonConfig } from '@bobfrankston/userconfig';
2
- import { type GlobalizeOptions } from './types.js';
3
- /** Read and parse package.json from a directory */
4
- export declare function readPackageJson(dir: string): any;
5
- /** Global npm config from %USERPROFILE%\.userconfig\npm.json5 โ€” via @bobfrankston/userconfig */
6
- export type UserNpmConfig = NpmCommonConfig;
7
- /** Get the .userconfig directory path (%USERPROFILE%\.userconfig) */
8
- export declare function getUserConfigDir(): string;
9
- /** Read global npm config from %USERPROFILE%\.userconfig\npm.json5 */
10
- export declare function readUserNpmConfig(): UserNpmConfig;
11
- /** Write global npm config to %USERPROFILE%\.userconfig\npm.json5 */
12
- export declare function writeUserNpmConfig(config: UserNpmConfig): void;
13
- /** Read .globalize.json5 config file */
14
- export declare function readConfig(dir: string): Partial<GlobalizeOptions>;
15
- /** Write .globalize.json5 config file */
16
- export declare function writeConfig(dir: string, config: Partial<GlobalizeOptions>, explicitKeys?: Set<string>): void;
17
- /** Write package.json to a directory */
18
- export declare function writePackageJson(dir: string, pkg: any): void;
19
- /** Resolve a file: path to absolute path */
20
- export declare function resolveFilePath(fileRef: string, baseDir: string): string;
21
- /** Check if a dependency value is a file: reference */
22
- export declare function isFileRef(value: string): boolean;
23
- //# sourceMappingURL=config.d.ts.map
package/lib/config.js DELETED
@@ -1,163 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import JSON5 from 'json5';
4
- import { readConfig as readUserConfig, writeConfig as writeUserConfig, configDir } from '@bobfrankston/userconfig';
5
- /** Read and parse package.json from a directory */
6
- export function readPackageJson(dir) {
7
- const pkgPath = path.join(dir, 'package.json');
8
- if (!fs.existsSync(pkgPath)) {
9
- throw new Error(`package.json not found: ${pkgPath}`);
10
- }
11
- try {
12
- return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
13
- }
14
- catch (error) {
15
- throw new Error(`Failed to parse ${pkgPath}: ${error.message}`);
16
- }
17
- }
18
- /** Get the .userconfig directory path (%USERPROFILE%\.userconfig) */
19
- export function getUserConfigDir() {
20
- return configDir;
21
- }
22
- /** Read global npm config from %USERPROFILE%\.userconfig\npm.json5 */
23
- export function readUserNpmConfig() {
24
- return readUserConfig();
25
- }
26
- /** Write global npm config to %USERPROFILE%\.userconfig\npm.json5 */
27
- export function writeUserNpmConfig(config) {
28
- const existing = readUserConfig();
29
- const merged = { ...existing, ...config };
30
- writeUserConfig(merged);
31
- }
32
- /** Read .globalize.json5 config file */
33
- export function readConfig(dir) {
34
- const configPath = path.join(dir, '.globalize.json5');
35
- if (!fs.existsSync(configPath)) {
36
- return {};
37
- }
38
- try {
39
- const content = fs.readFileSync(configPath, 'utf-8');
40
- return JSON5.parse(content);
41
- }
42
- catch (error) {
43
- console.warn(`Warning: Could not parse .globalize.json5 config: ${error.message}`);
44
- return {};
45
- }
46
- }
47
- /** Write .globalize.json5 config file */
48
- export function writeConfig(dir, config, explicitKeys) {
49
- const configPath = path.join(dir, '.globalize.json5');
50
- // Define defaults to omit
51
- const defaults = {
52
- bump: 'patch',
53
- files: true,
54
- quiet: true,
55
- gitVisibility: 'private',
56
- npmVisibility: 'private',
57
- install: false,
58
- wsl: false,
59
- force: false,
60
- verbose: false,
61
- freeze: false,
62
- usePaths: true
63
- };
64
- // Read existing config to preserve values
65
- const existing = readConfig(dir);
66
- // Filter out temporary flags and default values (unless explicitly set)
67
- const filtered = {};
68
- const omitKeys = new Set(['cleanup', 'init', 'dryRun', 'message', 'conform', 'asis', 'help', 'error', 'updateDeps', 'updateMajor', 'publishDeps', 'publicDeps', 'forcePublish', 'once', 'cleanNestedModules']);
69
- for (const [key, value] of Object.entries(config)) {
70
- if (omitKeys.has(key))
71
- continue;
72
- // Keep if: already in config, explicitly set via CLI, or differs from default
73
- const isExplicit = explicitKeys?.has(key);
74
- const wasInConfig = key in existing;
75
- const differsFromDefault = defaults[key] !== value;
76
- if (isExplicit || wasInConfig || differsFromDefault) {
77
- filtered[key] = value;
78
- }
79
- }
80
- // Build content with comments
81
- const lines = [
82
- '{',
83
- ' // npmglobalize configuration (JSON5 format - trailing commas OK)',
84
- ' // Explicitly set values are preserved here',
85
- ''
86
- ];
87
- // Add configured values
88
- const entries = Object.entries(filtered);
89
- if (entries.length > 0) {
90
- entries.forEach(([key, value]) => {
91
- const jsonValue = typeof value === 'string' ? `"${value}"` : JSON.stringify(value);
92
- const comma = ','; // JSON5 allows trailing commas
93
- // Add inline comment for clarity
94
- let comment = '';
95
- if (key === 'install')
96
- comment = ' // Auto-install globally after publish (from registry)';
97
- else if (key === 'link')
98
- comment = ' // Install globally via symlink (npm install -g .)';
99
- else if (key === 'wsl')
100
- comment = ' // Also install in WSL';
101
- else if (key === 'files')
102
- comment = ' // Keep file: paths after publish';
103
- else if (key === 'force')
104
- comment = ' // Continue despite git errors';
105
- else if (key === 'quiet')
106
- comment = ' // Suppress npm warnings';
107
- else if (key === 'verbose')
108
- comment = ' // Show detailed output';
109
- else if (key === 'gitVisibility')
110
- comment = ' // private (default) or public';
111
- else if (key === 'npmVisibility')
112
- comment = ' // private (default) or public';
113
- else if (key === 'bump')
114
- comment = ' // patch (default), minor, or major';
115
- else if (key === 'fix')
116
- comment = ' // Auto-run npm audit fix';
117
- else if (key === 'local')
118
- comment = ' // Local install only (skip transform/publish)';
119
- else if (key === 'noPublish')
120
- comment = ' // Transform but don\'t publish';
121
- else if (key === 'freeze')
122
- comment = ' // Freeze node_modules (replace symlinks with real copies)';
123
- else if (key === 'usePaths')
124
- comment = ' // Resolve file: deps from sibling checkouts (set false for standalone packages)';
125
- lines.push(` "${key}": ${jsonValue}${comma}${comment}`);
126
- });
127
- lines.push('');
128
- }
129
- // Add commented reference for all options
130
- lines.push(' // Defaults (omitted above):');
131
- lines.push(' // "bump": "patch" // Version bump: patch, minor, major');
132
- lines.push(' // "install": false // Auto-install globally after publish (from registry)');
133
- lines.push(' // "link": false // Install globally via symlink (npm install -g .)');
134
- lines.push(' // "wsl": false // Also install in WSL');
135
- lines.push(' // "files": true // Keep file: paths after publish');
136
- lines.push(' // "force": false // Continue despite git errors');
137
- lines.push(' // "quiet": true // Suppress npm warnings');
138
- lines.push(' // "verbose": false // Show detailed output');
139
- lines.push(' // "gitVisibility": "private" // Git repo: private or public');
140
- lines.push(' // "npmVisibility": "private" // npm package: private or public');
141
- lines.push(' // "fix": false // Auto-run npm audit fix');
142
- lines.push(' // "local": false // Local install only (skip transform/publish)');
143
- lines.push(' // "noPublish": false // Transform but don\'t publish');
144
- lines.push(' // "freeze": false // Freeze node_modules (replace symlinks with real copies)');
145
- lines.push(' // "usePaths": true // Resolve file: deps from siblings; false = use latest npm version (standalone)');
146
- lines.push('}');
147
- fs.writeFileSync(configPath, lines.join('\n') + '\n');
148
- }
149
- /** Write package.json to a directory */
150
- export function writePackageJson(dir, pkg) {
151
- const pkgPath = path.join(dir, 'package.json');
152
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
153
- }
154
- /** Resolve a file: path to absolute path */
155
- export function resolveFilePath(fileRef, baseDir) {
156
- const relativePath = fileRef.replace(/^file:/, '');
157
- return path.resolve(baseDir, relativePath);
158
- }
159
- /** Check if a dependency value is a file: reference */
160
- export function isFileRef(value) {
161
- return typeof value === 'string' && value.startsWith('file:');
162
- }
163
- //# sourceMappingURL=config.js.map
package/lib/deps.d.ts DELETED
@@ -1,42 +0,0 @@
1
- /**
2
- * npmglobalize dependency analysis, transformation, and restoration.
3
- * Handles file: ref discovery, workspace graphs, topological sorting,
4
- * and transforming file: deps to npm versions for publishing.
5
- */
6
- /** Get all file: dependencies from package.json */
7
- export declare function getFileRefs(pkg: any): Map<string, {
8
- key: string;
9
- name: string;
10
- value: string;
11
- }>;
12
- /** Resolve workspace entries to package info. Skips dirs without package.json or with private:true. */
13
- export declare function resolveWorkspacePackages(rootDir: string): Array<{
14
- name: string;
15
- dir: string;
16
- pkg: any;
17
- }>;
18
- /** Build a dependency graph among workspace packages. Returns Map<name, Set<depName>>. */
19
- export declare function buildDependencyGraph(packages: Array<{
20
- name: string;
21
- dir: string;
22
- pkg: any;
23
- }>): Map<string, Set<string>>;
24
- /** Topological sort with cycle detection. Returns package names in dependency order. */
25
- export declare function topologicalSort(graph: Map<string, Set<string>>): string[];
26
- /** Transform file: dependencies to npm versions */
27
- export declare function transformDeps(pkg: any, baseDir: string, verbose?: boolean, forcePublish?: boolean): {
28
- transformed: boolean;
29
- unpublished: Array<{
30
- name: string;
31
- version: string;
32
- path: string;
33
- }>;
34
- };
35
- /** Build and print a dependency tree of file: references.
36
- * Recursively walks file: deps showing the full hierarchy with indentation. */
37
- export declare function printDepTree(baseDir: string, indent?: number, visited?: Set<string>): void;
38
- /** Restore file: dependencies from .dependencies */
39
- export declare function restoreDeps(pkg: any, verbose?: boolean): boolean;
40
- /** Check if .dependencies exist (already transformed) */
41
- export declare function hasBackup(pkg: any): boolean;
42
- //# sourceMappingURL=deps.d.ts.map