@bobfrankston/npmglobalize 1.0.225 → 1.0.226

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.
Files changed (3) hide show
  1. package/lib.d.ts +2 -1
  2. package/lib.js +33 -14
  3. package/package.json +3 -3
package/lib.d.ts CHANGED
@@ -204,7 +204,8 @@ export declare function getUserConfigDir(): string;
204
204
  export declare function readUserNpmConfig(): UserNpmConfig;
205
205
  /** Write global npm config to %USERPROFILE%\.userconfig\npm.json5 */
206
206
  export declare function writeUserNpmConfig(config: UserNpmConfig): void;
207
- /** Read .globalize.json5 config file */
207
+ /** Read .globalize.json5 config file. A file carrying a renamed key is
208
+ * rewritten on the spot, once. */
208
209
  export declare function readConfig(dir: string): Partial<GlobalizeOptions>;
209
210
  /** Write .globalize.json5 config file */
210
211
  export declare function writeConfig(dir: string, config: Partial<GlobalizeOptions>, explicitKeys?: Set<string>): void;
package/lib.js CHANGED
@@ -304,32 +304,50 @@ export function writeUserNpmConfig(config) {
304
304
  const merged = { ...existing, ...config };
305
305
  writeUserConfig(merged);
306
306
  }
307
- /** Read .globalize.json5 config file */
308
- export function readConfig(dir) {
307
+ /** Parse .globalize.json5 and apply key migrations in memory. Does not touch
308
+ * the file; readConfig does the rewrite so writeConfig can call this without
309
+ * recursing into itself. */
310
+ function parseConfig(dir) {
309
311
  const configPath = path.join(dir, '.globalize.json5');
310
312
  if (!fs.existsSync(configPath)) {
311
- return {};
313
+ return { config: {}, migrated: false };
312
314
  }
313
315
  try {
314
316
  const content = fs.readFileSync(configPath, 'utf-8');
315
317
  const config = JSON5.parse(content);
316
318
  // 2026-09-07 — Claude Code (Fable 5.1), at Bob's direction: the "local" key
317
319
  // was renamed "localInstall" along with the -local → -local-install flag.
318
- // Old files keep working: the value is carried over here, and since
319
- // writeConfig reads the existing config through this same function, the
320
- // next persist writes the new name and drops the old one.
321
- if ('local' in config && !('localInstall' in config)) {
322
- config.localInstall = config.local;
323
- console.log(colors.dim(` (.globalize.json5: "local" is now "localInstall" — rewritten on the next persist)`));
320
+ let migrated = false;
321
+ if ('local' in config) {
322
+ if (!('localInstall' in config))
323
+ config.localInstall = config.local;
324
+ delete config.local;
325
+ migrated = true;
324
326
  }
325
- delete config.local;
326
- return config;
327
+ return { config, migrated };
327
328
  }
328
329
  catch (error) {
329
330
  console.warn(`Warning: Could not parse .globalize.json5 config: ${error.message}`);
330
- return {};
331
+ return { config: {}, migrated: false };
331
332
  }
332
333
  }
334
+ /** Read .globalize.json5 config file. A file carrying a renamed key is
335
+ * rewritten on the spot, once. */
336
+ export function readConfig(dir) {
337
+ const { config, migrated } = parseConfig(dir);
338
+ // 2026-09-08 — Claude Code (Fable 5.1), at Bob's direction. The migration
339
+ // used to be applied in memory only and announced "rewritten on the next
340
+ // persist" -- on every one of the several readConfig calls a package gets
341
+ // during a cascade, so the same line printed twice per dep and the file
342
+ // stayed stale until that package itself published. Now the file is
343
+ // rewritten immediately; the split into parseConfig keeps writeConfig's
344
+ // own read from re-entering this rewrite.
345
+ if (migrated) {
346
+ writeConfig(dir, config, new Set(['localInstall']));
347
+ console.log(colors.dim(` (${path.join(dir, '.globalize.json5')}: renamed "local" to "localInstall")`));
348
+ }
349
+ return config;
350
+ }
333
351
  /** Inline comments for boolean settings in .globalize.json5. Value-aware: a
334
352
  * negated setting must not read as though it still does the thing (a
335
353
  * `"quiet": false` line saying "Suppress npm warnings" describes the
@@ -374,8 +392,9 @@ export function writeConfig(dir, config, explicitKeys) {
374
392
  freeze: false,
375
393
  usePaths: true
376
394
  };
377
- // Read existing config to preserve values
378
- const existing = readConfig(dir);
395
+ // Read existing config to preserve values (parseConfig, not readConfig:
396
+ // readConfig may rewrite the file, which calls back into writeConfig)
397
+ const existing = parseConfig(dir).config;
379
398
  // Filter out temporary flags and default values (unless explicitly set)
380
399
  const filtered = {};
381
400
  // upstream is bookkeeping written by recordUpstream, never a CLI option, so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.225",
3
+ "version": "1.0.226",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  "@bobfrankston/freezepak": "^0.1.9",
35
35
  "@bobfrankston/importgen": "^0.1.43",
36
36
  "@bobfrankston/themecolors": "^0.1.10",
37
- "@bobfrankston/userconfig": "^1.0.12",
37
+ "@bobfrankston/userconfig": "^1.0.13",
38
38
  "@npmcli/package-json": "^7.0.4",
39
39
  "json5": "^2.2.3",
40
40
  "libnpmversion": "^8.0.3",
@@ -62,7 +62,7 @@
62
62
  "@bobfrankston/freezepak": "^0.1.9",
63
63
  "@bobfrankston/importgen": "^0.1.43",
64
64
  "@bobfrankston/themecolors": "^0.1.10",
65
- "@bobfrankston/userconfig": "^1.0.12",
65
+ "@bobfrankston/userconfig": "^1.0.13",
66
66
  "@npmcli/package-json": "^7.0.4",
67
67
  "json5": "^2.2.3",
68
68
  "libnpmversion": "^8.0.3",