zshy 0.0.4 → 0.0.6

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/out/index.cjs CHANGED
@@ -37,24 +37,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- const globby_1 = require("globby");
41
- const table_1 = require("table");
42
40
  const fs = __importStar(require("node:fs"));
43
41
  const path = __importStar(require("node:path/posix"));
44
- const ts = __importStar(require("typescript"));
45
42
  const arg_1 = __importDefault(require("arg"));
46
- const utils_ts_1 = require("./utils.js");
43
+ const globby_1 = require("globby");
44
+ const table_1 = require("table");
45
+ const ts = __importStar(require("typescript"));
46
+ const utils_1 = require("./utils.cjs");
47
47
  function isSourceFile(filePath) {
48
- return (filePath.endsWith(".ts") ||
49
- filePath.endsWith(".mts") ||
50
- filePath.endsWith(".cts") ||
51
- filePath.endsWith(".tsx"));
48
+ return (filePath.endsWith(".ts") || filePath.endsWith(".mts") || filePath.endsWith(".cts") || filePath.endsWith(".tsx"));
52
49
  }
53
50
  function removeExtension(filePath) {
54
51
  return filePath.split(".").slice(0, -1).join(".") || filePath;
55
52
  }
56
53
  async function main() {
57
- console.log("💎 Starting zshy build...");
58
54
  ///////////////////////////////////
59
55
  /// parse command line args ///
60
56
  ///////////////////////////////////
@@ -63,8 +59,12 @@ async function main() {
63
59
  try {
64
60
  args = (0, arg_1.default)({
65
61
  "--help": Boolean,
62
+ "--verbose": Boolean,
63
+ "--project": String,
64
+ "--dry-run": Boolean,
66
65
  // Aliases
67
66
  "-h": "--help",
67
+ "-p": "--project",
68
68
  });
69
69
  }
70
70
  catch (error) {
@@ -81,12 +81,27 @@ Usage: zshy [options]
81
81
 
82
82
  Options:
83
83
  -h, --help Show this help message
84
+ -p, --project <path> Path to tsconfig.json file
85
+ --verbose Enable verbose output
86
+ --dry-run Don't write any files, just log what would be done
84
87
 
85
88
  Examples:
86
- zshy # Use ./tsconfig.json or package.json#zshy.tsconfig
89
+ zshy # Run build
90
+ zshy --project ./tsconfig.build.json # Use specific tsconfig file (defaults to tsconfig.json)
91
+ zshy --verbose # Enable verbose logging
92
+ zshy --dry-run # Preview changes without writing files
87
93
  `);
88
94
  process.exit(0);
89
95
  }
96
+ console.log("💎 Starting zshy build...");
97
+ const isVerbose = args["--verbose"];
98
+ const isDryRun = args["--dry-run"];
99
+ if (isVerbose) {
100
+ console.log("🗣️ Verbose mode enabled");
101
+ }
102
+ if (isDryRun) {
103
+ console.log("🔍 Dry run mode enabled - no files will be written");
104
+ }
90
105
  ///////////////////////////////////
91
106
  /// find and read pkg json ///
92
107
  ///////////////////////////////////
@@ -133,13 +148,26 @@ Examples:
133
148
  config.exports = { ".": config.exports };
134
149
  }
135
150
  else if (typeof config.exports === "undefined") {
136
- console.error(`❌ Missing "exports" key in package.json#${CONFIG_KEY}`);
151
+ console.error(`❌ Missing "exports" key in package.json#/${CONFIG_KEY}`);
137
152
  process.exit(1);
138
153
  }
139
154
  else if (typeof config.exports !== "object") {
140
- console.error(`❌ Invalid "exports" key in package.json#${CONFIG_KEY}`);
155
+ console.error(`❌ Invalid "exports" key in package.json#/${CONFIG_KEY}`);
141
156
  process.exit(1);
142
157
  }
158
+ // Validate bin field if present
159
+ if (config.bin !== undefined) {
160
+ if (typeof config.bin === "string") {
161
+ // Keep string format - we'll handle this in entry point extraction
162
+ }
163
+ else if (typeof config.bin === "object" && config.bin !== null) {
164
+ // Object format is valid
165
+ }
166
+ else {
167
+ console.error(`❌ Invalid "bin" key in package.json#/${CONFIG_KEY}, expected string or object`);
168
+ process.exit(1);
169
+ }
170
+ }
143
171
  // {
144
172
  // exports: { ".": pkgJson[CONFIG_KEY].exports },
145
173
  // };
@@ -152,13 +180,34 @@ Examples:
152
180
  console.error(`❌ Invalid "${CONFIG_KEY}" key in package.json, expected string or object`);
153
181
  process.exit(1);
154
182
  }
183
+ if (isVerbose) {
184
+ console.log("🔧 Parsed zshy config:", (0, utils_1.formatForLog)(config));
185
+ }
155
186
  ///////////////////////////
156
187
  /// read tsconfig ///
157
188
  ///////////////////////////
158
189
  // Determine tsconfig.json path
159
190
  let tsconfigPath;
160
- if (config.tsconfig) {
161
- // Resolve the provided tsconfig path against package.json directory
191
+ if (args["--project"]) {
192
+ // CLI flag takes priority
193
+ const resolvedProjectPath = path.resolve(process.cwd(), args["--project"]);
194
+ if (fs.existsSync(resolvedProjectPath)) {
195
+ if (fs.statSync(resolvedProjectPath).isDirectory()) {
196
+ console.error(`❌ --project must point to a tsconfig.json file, not a directory: ${resolvedProjectPath}`);
197
+ process.exit(1);
198
+ }
199
+ else {
200
+ // Use the file directly
201
+ tsconfigPath = resolvedProjectPath;
202
+ }
203
+ }
204
+ else {
205
+ console.error(`❌ tsconfig.json file not found: ${resolvedProjectPath}`);
206
+ process.exit(1);
207
+ }
208
+ }
209
+ else if (config.tsconfig) {
210
+ // Fallback to package.json config
162
211
  const resolvedProjectPath = path.resolve(pkgJsonDir, config.tsconfig);
163
212
  if (fs.existsSync(resolvedProjectPath)) {
164
213
  if (fs.statSync(resolvedProjectPath).isDirectory()) {
@@ -179,7 +228,7 @@ Examples:
179
228
  // Default to tsconfig.json in the package.json directory
180
229
  tsconfigPath = path.join(pkgJsonDir, "tsconfig.json");
181
230
  }
182
- const _parsedConfig = (0, utils_ts_1.readTsconfig)(tsconfigPath);
231
+ const _parsedConfig = (0, utils_1.readTsconfig)(tsconfigPath);
183
232
  if (!fs.existsSync(tsconfigPath)) {
184
233
  // Check if tsconfig.json exists
185
234
  console.error(`❌ tsconfig.json not found at ${path.resolve(tsconfigPath)}`);
@@ -204,6 +253,34 @@ Examples:
204
253
  const relOutDir = path.relative(pkgJsonDir, outDir);
205
254
  const declarationDir = path.resolve(pkgJsonDir, _parsedConfig?.declarationDir || relOutDir);
206
255
  const relDeclarationDir = path.relative(pkgJsonDir, declarationDir);
256
+ // clean up outDir and declarationDir
257
+ if (relOutDir !== "") {
258
+ console.log(`🗑️ Cleaning up outDir...`);
259
+ fs.rmSync(outDir, { recursive: true, force: true });
260
+ // // print success mesage in verbose mode
261
+ if (isVerbose) {
262
+ if (fs.existsSync(outDir)) {
263
+ console.error(`❌ Failed to clean up outDir: ${relOutDir}. Directory still exists.`);
264
+ }
265
+ }
266
+ }
267
+ else {
268
+ console.log(`🗑️ Skipping cleanup of outDir as it contains source files`);
269
+ }
270
+ if (relDeclarationDir !== relOutDir && relDeclarationDir !== "") {
271
+ console.log(`🗑️ Cleaning up declarationDir...`);
272
+ fs.rmSync(declarationDir, { recursive: true, force: true });
273
+ // // print success mesage in verbose mode
274
+ if (isVerbose) {
275
+ if (fs.existsSync(declarationDir)) {
276
+ console.error(`❌ Failed to clean up declarationDir: ${relDeclarationDir}. Directory still exists.`);
277
+ }
278
+ }
279
+ }
280
+ else {
281
+ if (isVerbose)
282
+ console.log(`🗑️ Skipping cleanup of declarationDir as it contains source files`);
283
+ }
207
284
  const tsconfigJson = {
208
285
  ..._parsedConfig,
209
286
  outDir,
@@ -218,14 +295,7 @@ Examples:
218
295
  if (relOutDir === "") {
219
296
  if (!pkgJson.files) {
220
297
  console.log('⚠️ You\'re building your code to the project root. This means your compiled files will be generated alongside your source files.\n ➜ Setting "files" in package.json to exclude TypeScript source from the published package.');
221
- pkgJson.files = [
222
- "**/*.js",
223
- "**/*.mjs",
224
- "**/*.cjs",
225
- "**/*.d.ts",
226
- "**/*.d.mts",
227
- "**/*.d.cts",
228
- ];
298
+ pkgJson.files = ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.d.ts", "**/*.d.mts", "**/*.d.cts"];
229
299
  }
230
300
  else {
231
301
  console.warn(`⚠️ You're building your code to the project root. This means your compiled files will be generated alongside your source files.
@@ -278,10 +348,7 @@ Examples:
278
348
  deep: 1,
279
349
  });
280
350
  entryPatterns.push(...wildcardFiles);
281
- rows.push([
282
- `"${cleanExportPath}"`,
283
- `${sourcePath} (${wildcardFiles.length} matches)`,
284
- ]);
351
+ rows.push([`"${cleanExportPath}"`, `${sourcePath} (${wildcardFiles.length} matches)`]);
285
352
  }
286
353
  else if (isSourceFile(sourcePath)) {
287
354
  entryPatterns.push(sourcePath);
@@ -289,19 +356,49 @@ Examples:
289
356
  }
290
357
  }
291
358
  }
292
- console.log(" " + (0, table_1.table)(rows).split("\n").join("\n ").trim());
359
+ // Extract bin entry points from zshy bin config
360
+ if (config.bin) {
361
+ if (typeof config.bin === "string") {
362
+ // Single bin entry
363
+ if (isSourceFile(config.bin)) {
364
+ entryPatterns.push(config.bin);
365
+ rows.push([`bin:${pkgJson.name}`, config.bin]);
366
+ }
367
+ }
368
+ else {
369
+ // Multiple bin entries
370
+ for (const [binName, sourcePath] of Object.entries(config.bin)) {
371
+ if (typeof sourcePath === "string" && isSourceFile(sourcePath)) {
372
+ entryPatterns.push(sourcePath);
373
+ rows.push([`bin:${binName}`, sourcePath]);
374
+ }
375
+ }
376
+ }
377
+ }
378
+ console.log(" " +
379
+ (0, table_1.table)(rows, {
380
+ drawHorizontalLine: (lineIndex, rowCount) => {
381
+ return (lineIndex === 0 ||
382
+ lineIndex === 1 ||
383
+ // lineIndex === rowCount - 1 ||
384
+ lineIndex === rowCount);
385
+ },
386
+ })
387
+ .split("\n")
388
+ .join("\n ")
389
+ .trim());
293
390
  ///////////////////////////////
294
391
  /// compute entry points ///
295
392
  ///////////////////////////////
296
393
  // compute entry points
297
- const entryPoints = await (0, utils_ts_1.getEntryPoints)(entryPatterns);
394
+ const entryPoints = await (0, utils_1.getEntryPoints)(entryPatterns);
298
395
  // disallow .mts and .cts files
299
396
  if (entryPoints.some((ep) => ep.endsWith(".mts") || ep.endsWith(".cts"))) {
300
397
  console.error("❌ Source files with .mts or .cts extensions are not supported. Please use regular .ts files.");
301
398
  process.exit(1);
302
399
  }
303
400
  if (entryPoints.length === 0) {
304
- console.error("❌ No entry points found matching the specified patterns in package.json#zshy exports");
401
+ console.error("❌ No entry points found matching the specified patterns in package.json#/zshy exports");
305
402
  process.exit(1);
306
403
  }
307
404
  ///////////////////////////////
@@ -323,37 +420,60 @@ Examples:
323
420
  const entryParts = entryDir.split(path.sep);
324
421
  const commonParts = commonDir.split(path.sep);
325
422
  let i = 0;
326
- while (i < entryParts.length &&
327
- i < commonParts.length &&
328
- entryParts[i] === commonParts[i]) {
423
+ while (i < entryParts.length && i < commonParts.length && entryParts[i] === commonParts[i]) {
329
424
  i++;
330
425
  }
331
426
  return commonParts.slice(0, i).join(path.sep) || path.sep;
332
427
  }, path.dirname(path.resolve(entryPoints[0])))
333
428
  : process.cwd();
334
429
  }
335
- // console.dir(_commonAncestor, { depth: null });
336
430
  const relRootDir = path.relative(pkgJsonDir, rootDir);
337
- console.log(`📂 Transpiling ${relRootDir ? `./${relRootDir}` : "."} (rootDir) to ${relOutDir ? `./${relOutDir}` : "."} (outDir)`);
431
+ // Display resolved paths table
432
+ console.log("🔧 Resolved build paths:");
433
+ const pathRows = [["Location", "Resolved path"]];
434
+ // pathRows.push([
435
+ // "package.json",
436
+ // `./${path.relative(pkgJsonDir, packageJsonPath)}`,
437
+ // ]);
438
+ // pathRows.push(["tsconfig", `./${path.relative(pkgJsonDir, tsconfigPath)}`]);
439
+ pathRows.push(["rootDir", relRootDir ? `./${relRootDir}` : "."]);
440
+ pathRows.push(["outDir", relOutDir ? `./${relOutDir}` : "."]);
338
441
  if (relDeclarationDir !== relOutDir) {
339
- console.log(`📂 Writing declaration files to ${relDeclarationDir ? `./${relDeclarationDir}` : "."} (declarationDir)`);
442
+ pathRows.push(["declarationDir", relDeclarationDir ? `./${relDeclarationDir}` : "."]);
340
443
  }
444
+ console.log(" " +
445
+ (0, table_1.table)(pathRows, {
446
+ drawHorizontalLine: (lineIndex, rowCount) => {
447
+ return (lineIndex === 0 ||
448
+ lineIndex === 1 ||
449
+ // lineIndex === rowCount - 1 ||
450
+ lineIndex === rowCount);
451
+ },
452
+ })
453
+ .split("\n")
454
+ .join("\n ")
455
+ .trim());
341
456
  const isTypeModule = pkgJson.type === "module";
342
457
  if (isTypeModule) {
343
- console.log(`🟨 Package is an ES module (package.json#type is \"module\")`);
458
+ console.log(`🟨 Package is an ES module (package.json#/type is \"module\")`);
344
459
  }
345
460
  else {
346
- console.log(`🐢 Package is a CommonJS module (${pkgJson.type === "commonjs" ? 'package.json#type is "commonjs"' : 'package.json#type not set to "module"'})`);
461
+ console.log(`🐢 Package is a CommonJS module (${pkgJson.type === "commonjs" ? 'package.json#/type is "commonjs"' : 'package.json#/type not set to "module"'})`);
347
462
  }
348
463
  ///////////////////////////////
349
464
  /// compile tsc ///
350
465
  ///////////////////////////////
351
466
  try {
467
+ // Track all written files
468
+ const allWrittenFiles = [];
352
469
  // CJS
353
470
  console.log(`🧱 Building CJS...${isTypeModule ? ` (rewriting .ts -> .cjs/.d.cts)` : ``}`);
354
- await (0, utils_ts_1.compileProject)({
471
+ const cjsFiles = await (0, utils_1.compileProject)({
355
472
  configPath: tsconfigPath,
356
473
  mode: isTypeModule ? "cts" : "ts",
474
+ verbose: isVerbose,
475
+ dryRun: isDryRun,
476
+ packageRoot: pkgJsonDir,
357
477
  compilerOptions: {
358
478
  ...tsconfigJson,
359
479
  module: ts.ModuleKind.CommonJS,
@@ -361,11 +481,15 @@ Examples:
361
481
  outDir,
362
482
  },
363
483
  }, entryPoints);
484
+ allWrittenFiles.push(...cjsFiles);
364
485
  // ESM
365
486
  console.log(`🧱 Building ESM...${isTypeModule ? `` : ` (rewriting .ts -> .mjs/.d.mts)`}`);
366
- await (0, utils_ts_1.compileProject)({
487
+ const esmFiles = await (0, utils_1.compileProject)({
367
488
  configPath: tsconfigPath,
368
489
  mode: isTypeModule ? "ts" : "mts",
490
+ verbose: isVerbose,
491
+ dryRun: isDryRun,
492
+ packageRoot: pkgJsonDir,
369
493
  compilerOptions: {
370
494
  ...tsconfigJson,
371
495
  module: ts.ModuleKind.ESNext,
@@ -373,11 +497,27 @@ Examples:
373
497
  outDir,
374
498
  },
375
499
  }, entryPoints);
500
+ allWrittenFiles.push(...esmFiles);
501
+ ///////////////////////////////////
502
+ /// display written files ///
503
+ ///////////////////////////////////
504
+ // Display files that were written or would be written (only in verbose mode)
505
+ if (isVerbose && allWrittenFiles.length > 0) {
506
+ console.log(`📜 ${isDryRun ? "[dryrun] " : ""}Writing files... (${allWrittenFiles.length} total):`);
507
+ // Sort files by relative path for consistent display
508
+ const sortedFiles = [...allWrittenFiles]
509
+ .map((file) => path.relative(pkgJsonDir, file))
510
+ .sort()
511
+ .map((relPath) => (relPath.startsWith(".") ? relPath : `./${relPath}`));
512
+ sortedFiles.forEach((file) => {
513
+ console.log(` ${file}`);
514
+ });
515
+ }
376
516
  ///////////////////////////////
377
517
  /// generate exports ///
378
518
  ///////////////////////////////
379
519
  // generate package.json exports
380
- console.log("📦 Updating package.json exports...");
520
+ console.log("📦 Updating package.json#/exports...");
381
521
  // Generate exports based on zshy config
382
522
  const newExports = {};
383
523
  const sourceDialects = config.sourceDialects || [];
@@ -386,15 +526,26 @@ Examples:
386
526
  newExports[exportPath] = sourcePath;
387
527
  continue;
388
528
  }
529
+ const absSourcePath = path.resolve(pkgJsonDir, sourcePath);
530
+ const relSourcePath = path.relative(rootDir, absSourcePath);
531
+ const absJsPath = path.resolve(outDir, relSourcePath);
532
+ const absDtsPath = path.resolve(declarationDir, relSourcePath);
533
+ const relJsPath = "./" + path.relative(pkgJsonDir, absJsPath);
534
+ const relDtsPath = "./" + path.relative(pkgJsonDir, absDtsPath);
389
535
  if (typeof sourcePath === "string") {
390
536
  if (sourcePath.endsWith("/*")) {
391
537
  // Handle wildcard exports
392
- const relSourcePath = "./" +
393
- path.relative(pkgJsonDir, path.resolve(outDir, sourcePath.slice(0, -2))) +
394
- "/*";
538
+ // const relSourcePath =
539
+ // "./" +
540
+ // path.relative(
541
+ // pkgJsonDir,
542
+ // path.resolve(outDir, sourcePath.slice(0, -2)),
543
+ // ) +
544
+ // "/*";
395
545
  newExports[exportPath] = {
396
- import: relSourcePath,
397
- require: relSourcePath,
546
+ types: relDtsPath,
547
+ import: relJsPath,
548
+ require: relJsPath,
398
549
  };
399
550
  for (const sd of sourceDialects) {
400
551
  newExports[exportPath] = {
@@ -404,44 +555,18 @@ Examples:
404
555
  }
405
556
  }
406
557
  else if (isSourceFile(sourcePath)) {
407
- // Handle regular TypeScript entry points
408
- // const basePath = sourcePath.slice(0, -3); // ./v4/index.ts
409
- const absSourcePath = path.resolve(pkgJsonDir, sourcePath); // /path/to/v4/index.ts
410
- const sourcePathRelativeToRootDir = path.relative(rootDir, absSourcePath); // index.ts
411
- const outPath = path.resolve(pkgJsonDir, outDir, sourcePathRelativeToRootDir); // /path/to/dist/index.ts
412
- const outPathNoExt = removeExtension(outPath); // /path/to/dist/index
413
- // For declaration files, use declarationDir if it's different from outDir
414
- const declarationPath = path.resolve(pkgJsonDir, declarationDir, sourcePathRelativeToRootDir); // /path/to/types/index.ts
415
- const declarationPathNoExt = removeExtension(declarationPath); // /path/to/types/index
416
- const esmFile = isTypeModule
417
- ? `${outPathNoExt}.js`
418
- : `${outPathNoExt}.mjs`; // ./v4/index.js or ./v4/index.mjs
419
- const cjsFile = isTypeModule
420
- ? `${outPathNoExt}.cjs`
421
- : `${outPathNoExt}.js`;
422
- const dtsFile = isTypeModule
423
- ? `${declarationPathNoExt}.d.cts`
424
- : `${declarationPathNoExt}.d.ts`;
425
- const relEsmFile = "./" + path.relative(pkgJsonDir, esmFile);
426
- const relCjsFile = "./" + path.relative(pkgJsonDir, cjsFile);
427
- const relDtsFile = "./" + path.relative(pkgJsonDir, dtsFile);
558
+ const esmPath = removeExtension(relJsPath) + (isTypeModule ? `.js` : `.mjs`); // ./v4/index.js or ./v4/index.mjs
559
+ const cjsPath = removeExtension(relJsPath) + (isTypeModule ? `.cjs` : `.js`);
560
+ const dtsPath = removeExtension(relDtsPath) + (isTypeModule ? `.d.cts` : `.d.ts`); // ./
428
561
  newExports[exportPath] = {
429
- types: relDtsFile,
430
- import: relEsmFile,
431
- require: relCjsFile,
432
- // import: {
433
- // types: relDtsFile,
434
- // default: relEsmFile,
435
- // },
436
- // require: {
437
- // types: relDtsFile,
438
- // default: relCjsFile,
439
- // },
562
+ types: dtsPath,
563
+ import: esmPath,
564
+ require: cjsPath,
440
565
  };
441
566
  if (exportPath === ".") {
442
- pkgJson.main = relCjsFile;
443
- pkgJson.module = relEsmFile;
444
- pkgJson.types = relDtsFile;
567
+ pkgJson.main = cjsPath;
568
+ pkgJson.module = esmPath;
569
+ pkgJson.types = dtsPath;
445
570
  }
446
571
  for (const sd of sourceDialects) {
447
572
  newExports[exportPath] = {
@@ -450,6 +575,45 @@ Examples:
450
575
  };
451
576
  }
452
577
  }
578
+ else {
579
+ console.error(`❌ Invalid entrypoint: ${sourcePath}`);
580
+ process.exit();
581
+ }
582
+ }
583
+ }
584
+ ///////////////////////////////
585
+ /// generate bin ///
586
+ ///////////////////////////////
587
+ // Generate bin field based on zshy bin config
588
+ if (config.bin) {
589
+ console.log("📦 Updating package.json#/bin...");
590
+ const newBin = {};
591
+ // Convert config.bin to object format for processing
592
+ const binEntries = typeof config.bin === "string" ? [[pkgJson.name, config.bin]] : Object.entries(config.bin);
593
+ for (const [binName, sourcePath] of binEntries) {
594
+ if (typeof sourcePath === "string" && isSourceFile(sourcePath)) {
595
+ const absSourcePath = path.resolve(pkgJsonDir, sourcePath);
596
+ const relSourcePath = path.relative(rootDir, absSourcePath);
597
+ const absJsPath = path.resolve(outDir, relSourcePath);
598
+ const relJsPath = "./" + path.relative(pkgJsonDir, absJsPath);
599
+ // Use CommonJS entrypoint for bin
600
+ const binPath = removeExtension(relJsPath) + (isTypeModule ? `.cjs` : `.js`);
601
+ newBin[binName] = binPath;
602
+ }
603
+ }
604
+ // If original config.bin was a string, output as string
605
+ if (typeof config.bin === "string") {
606
+ pkgJson.bin = Object.values(newBin)[0];
607
+ if (isVerbose) {
608
+ console.log(`🗣️ Updated package.json#/bin: "${Object.values(newBin)[0]}"`);
609
+ }
610
+ }
611
+ else {
612
+ // Output as object
613
+ pkgJson.bin = newBin;
614
+ if (isVerbose) {
615
+ console.log("🗣️ Updated package.json#/bin: " + (0, utils_1.formatForLog)(newBin));
616
+ }
453
617
  }
454
618
  }
455
619
  ///////////////////////////////
@@ -457,9 +621,16 @@ Examples:
457
621
  ///////////////////////////////
458
622
  // Update package.json with new exports
459
623
  pkgJson.exports = newExports;
460
- fs.writeFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
461
- // console.log("✅ Updating package.json#exports");
462
- console.log(" " + JSON.stringify(newExports, null, 2).split("\n").join("\n "));
624
+ if (isDryRun) {
625
+ console.log("🔍 Skipping package.json modification (dry-run)");
626
+ }
627
+ else {
628
+ fs.writeFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
629
+ }
630
+ // console.log("✅ Updating package.json#/exports");
631
+ if (isVerbose) {
632
+ console.log(`🗣️ Updated package.json#/exports: ${(0, utils_1.formatForLog)(newExports)}`);
633
+ }
463
634
  // // run `@arethetypeswrong/cli --pack .` to check types
464
635
  // console.log("🔍 Checking types with @arethetypeswrong/cli...");
465
636
  // const { execSync } = await import("node:child_process");