@bobfrankston/npmglobalize 1.0.201 → 1.0.202

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 (2) hide show
  1. package/lib.js +66 -56
  2. package/package.json +1 -1
package/lib.js CHANGED
@@ -219,6 +219,33 @@ export function readConfig(dir) {
219
219
  return {};
220
220
  }
221
221
  }
222
+ /** Inline comments for boolean settings in .globalize.json5. Value-aware: a
223
+ * negated setting must not read as though it still does the thing (a
224
+ * `"quiet": false` line saying "Suppress npm warnings" describes the
225
+ * opposite of what it does). */
226
+ const BOOL_COMMENTS = {
227
+ install: { on: 'Auto-install globally after publish (from registry)', off: 'Do NOT auto-install globally after publish' },
228
+ link: { on: 'Install globally via symlink (npm install -g .)', off: 'Do NOT install globally via symlink' },
229
+ wsl: { on: 'Also install in WSL', off: 'Do NOT install in WSL' },
230
+ files: { on: 'Restore file: paths after publish', off: 'Leave npm versions in package.json after publish' },
231
+ force: { on: 'Continue despite git errors', off: 'Stop on git errors' },
232
+ quiet: { on: 'Suppress npm warnings', off: 'Show npm warnings' },
233
+ verbose: { on: 'Show detailed output', off: 'Normal output detail' },
234
+ fix: { on: 'Auto-run npm audit fix', off: 'Do NOT run npm audit fix' },
235
+ local: { on: 'Local install only (skip transform/publish)', off: 'Normal transform/publish flow' },
236
+ noPublish: { on: 'Transform but don\'t publish', off: 'Publish normally' },
237
+ freeze: { on: 'Freeze node_modules (replace symlinks with real copies)', off: 'Leave node_modules symlinks as-is' },
238
+ usePaths: { on: 'Resolve file: deps from sibling checkouts', off: 'Resolve file: deps from npm, not siblings (standalone package)' },
239
+ allowTs: { on: 'Keep .ts source (and *.map, tsconfig.json) in the published npm tarball', off: 'Strip .ts source from the published npm tarball' },
240
+ importgen: { on: 'Regenerate browser import maps', off: 'Never ask about importgen here' }
241
+ };
242
+ /** Inline comments for settings whose value isn't a plain boolean. */
243
+ const VALUE_COMMENTS = {
244
+ gitVisibility: 'private (default) or public',
245
+ npmVisibility: 'private (default) or public',
246
+ bump: 'patch (default), minor, or major',
247
+ subProjects: 'Sub-dirs with their own tsconfig that build must compile (false = never ask)'
248
+ };
222
249
  /** Write .globalize.json5 config file */
223
250
  export function writeConfig(dir, config, explicitKeys) {
224
251
  const configPath = path.join(dir, '.globalize.json5');
@@ -284,68 +311,51 @@ export function writeConfig(dir, config, explicitKeys) {
284
311
  }
285
312
  const jsonValue = typeof value === 'string' ? `"${value}"` : JSON.stringify(value);
286
313
  const comma = ','; // JSON5 allows trailing commas
287
- // Add inline comment for clarity
314
+ // Add inline comment for clarity, keyed off the actual value so a
315
+ // negated boolean doesn't describe the behaviour it turns off.
288
316
  let comment = '';
289
- if (key === 'install')
290
- comment = ' // Auto-install globally after publish (from registry)';
291
- else if (key === 'link')
292
- comment = ' // Install globally via symlink (npm install -g .)';
293
- else if (key === 'wsl')
294
- comment = ' // Also install in WSL';
295
- else if (key === 'files')
296
- comment = ' // Keep file: paths after publish';
297
- else if (key === 'force')
298
- comment = ' // Continue despite git errors';
299
- else if (key === 'quiet')
300
- comment = ' // Suppress npm warnings';
301
- else if (key === 'verbose')
302
- comment = ' // Show detailed output';
303
- else if (key === 'gitVisibility')
304
- comment = ' // private (default) or public';
305
- else if (key === 'npmVisibility')
306
- comment = ' // private (default) or public';
307
- else if (key === 'bump')
308
- comment = ' // patch (default), minor, or major';
309
- else if (key === 'fix')
310
- comment = ' // Auto-run npm audit fix';
311
- else if (key === 'local')
312
- comment = ' // Local install only (skip transform/publish)';
313
- else if (key === 'noPublish')
314
- comment = ' // Transform but don\'t publish';
315
- else if (key === 'freeze')
316
- comment = ' // Freeze node_modules (replace symlinks with real copies)';
317
- else if (key === 'usePaths')
318
- comment = ' // Resolve file: deps from sibling checkouts (set false for standalone packages)';
319
- else if (key === 'allowTs')
320
- comment = ' // Keep .ts source (and *.map, tsconfig.json) in the published npm tarball';
321
- else if (key === 'importgen')
322
- comment = ' // Regenerate browser import maps (false = never ask about importgen here)';
323
- else if (key === 'subProjects')
324
- comment = ' // Sub-dirs with their own tsconfig that build must compile (false = never ask)';
317
+ const boolComment = BOOL_COMMENTS[key];
318
+ if (boolComment && typeof value === 'boolean') {
319
+ comment = ` // ${value ? boolComment.on : boolComment.off}`;
320
+ }
321
+ else if (VALUE_COMMENTS[key]) {
322
+ comment = ` // ${VALUE_COMMENTS[key]}`;
323
+ }
324
+ else if (boolComment) {
325
+ // Non-boolean value for a normally-boolean key (e.g. subProjects: ["Sw"])
326
+ comment = ` // ${boolComment.on}`;
327
+ }
325
328
  lines.push(` "${key}": ${jsonValue}${comma}${comment}`);
326
329
  });
327
330
  lines.push('');
328
331
  }
329
- // Add commented reference for all options
332
+ // Add commented reference for all options. Booleans are phrased "true = ..."
333
+ // so the description reads correctly next to a default of false.
330
334
  lines.push(' // Defaults (omitted above):');
331
- lines.push(' // "bump": "patch" // Version bump: patch, minor, major');
332
- lines.push(' // "install": false // Auto-install globally after publish (from registry)');
333
- lines.push(' // "link": false // Install globally via symlink (npm install -g .)');
334
- lines.push(' // "wsl": false // Also install in WSL');
335
- lines.push(' // "files": true // Keep file: paths after publish');
336
- lines.push(' // "force": false // Continue despite git errors');
337
- lines.push(' // "quiet": true // Suppress npm warnings');
338
- lines.push(' // "verbose": false // Show detailed output');
339
- lines.push(' // "gitVisibility": "private" // Git repo: private or public');
340
- lines.push(' // "npmVisibility": "private" // npm package: private or public');
341
- lines.push(' // "fix": false // Auto-run npm audit fix');
342
- lines.push(' // "local": false // Local install only (skip transform/publish)');
343
- lines.push(' // "noPublish": false // Transform but don\'t publish');
344
- lines.push(' // "freeze": false // Freeze node_modules (replace symlinks with real copies)');
345
- lines.push(' // "usePaths": true // Resolve file: deps from siblings; false = use latest npm version (standalone)');
346
- lines.push(' // "allowTs": false // Include .ts source in npm tarball (auto-true for noEmit projects)');
347
- lines.push(' // "importgen": auto // Detected from .vscode/tasks.json / import map in HTML; false = never ask');
348
- lines.push(' // "subProjects": auto // Sub-dirs with their own tsconfig (e.g. ["Sw"]); detected from .vscode/tasks.json; false = never ask');
335
+ const reference = [
336
+ ['"bump": "patch"', 'Version bump: patch, minor, major'],
337
+ ['"install": false', 'true = auto-install globally after publish (from registry)'],
338
+ ['"link": false', 'true = install globally via symlink (npm install -g .)'],
339
+ ['"wsl": false', 'true = also install in WSL'],
340
+ ['"files": true', 'true = restore file: paths after publish; false = leave npm versions in package.json'],
341
+ ['"force": false', 'true = continue despite git errors'],
342
+ ['"quiet": true', 'true = suppress npm warnings'],
343
+ ['"verbose": false', 'true = show detailed output'],
344
+ ['"gitVisibility": "private"', 'Git repo: private or public'],
345
+ ['"npmVisibility": "private"', 'npm package: private or public'],
346
+ ['"fix": false', 'true = auto-run npm audit fix'],
347
+ ['"local": false', 'true = local install only (skip transform/publish)'],
348
+ ['"noPublish": false', 'true = transform but don\'t publish'],
349
+ ['"freeze": false', 'true = freeze node_modules (replace symlinks with real copies)'],
350
+ ['"usePaths": true', 'true = resolve file: deps from siblings; false = use latest npm version (standalone)'],
351
+ ['"allowTs": false', 'true = include .ts source in npm tarball (auto-true for noEmit projects)'],
352
+ ['"importgen": auto', 'Detected from .vscode/tasks.json / import map in HTML; false = never ask'],
353
+ ['"subProjects": auto', 'Sub-dirs with their own tsconfig (e.g. ["Sw"]); detected from .vscode/tasks.json; false = never ask']
354
+ ];
355
+ const refWidth = Math.max(...reference.map(([decl]) => decl.length));
356
+ for (const [decl, note] of reference) {
357
+ lines.push(` // ${decl.padEnd(refWidth)} // ${note}`);
358
+ }
349
359
  lines.push('}');
350
360
  fs.writeFileSync(configPath, lines.join('\n') + '\n');
351
361
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.201",
3
+ "version": "1.0.202",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",