@chanom/cli 0.4.2 → 0.4.3

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/dist/index.js +39 -71
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { Cause, Chunk, Data, Effect, Layer, LogLevel, Logger, Option, Stream } f
4
4
  import * as clack from "@clack/prompts";
5
5
  import pc from "picocolors";
6
6
  import { NodeContext, NodeRuntime } from "@effect/platform-node";
7
- //#region ../internal/src/domain/package-manager.ts
7
+ // ../internal/src/domain/package-manager.ts
8
8
  /** How to run a locally installed binary with each package manager. */
9
9
  const PM_EXEC = {
10
10
  pnpm: ["pnpm", "exec"],
@@ -37,8 +37,7 @@ function parsePmUserAgent(agent) {
37
37
  function resolvePm(hints) {
38
38
  return parsePmField(hints.packageManagerField) ?? parsePmUserAgent(hints.userAgent) ?? hints.fallback ?? "pnpm";
39
39
  }
40
- //#endregion
41
- //#region ../internal/src/domain/vscode.ts
40
+ // ../internal/src/domain/vscode.ts
42
41
  /** Keys VS Code reads as a per-language override, e.g. `[typescript]`. */
43
42
  const LANGUAGES = [
44
43
  "markdown",
@@ -109,8 +108,7 @@ function planExtensions(current, wanted) {
109
108
  added
110
109
  };
111
110
  }
112
- //#endregion
113
- //#region ../internal/src/services/command-runner.ts
111
+ // ../internal/src/services/command-runner.ts
114
112
  const collectText = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
115
113
  /**
116
114
  * Low-level process execution. Everything that shells out (git, package
@@ -146,8 +144,7 @@ var CommandRunner = class extends Effect.Service()("internal/CommandRunner", { e
146
144
  execInherit
147
145
  };
148
146
  }) }) {};
149
- //#endregion
150
- //#region ../internal/src/services/git.ts
147
+ // ../internal/src/services/git.ts
151
148
  /** Git operations, built on top of {@link CommandRunner}. */
152
149
  var Git = class extends Effect.Service()("internal/Git", { effect: Effect.gen(function* () {
153
150
  const runner = yield* CommandRunner;
@@ -196,8 +193,7 @@ var Git = class extends Effect.Service()("internal/Git", { effect: Effect.gen(fu
196
193
  readGitignore: (cwd) => fs.readFileString(path.join(cwd, ".gitignore"))
197
194
  };
198
195
  }) }) {};
199
- //#endregion
200
- //#region ../internal/src/services/prompter.ts
196
+ // ../internal/src/services/prompter.ts
201
197
  var Cancelled = class extends Data.TaggedError("Cancelled") {};
202
198
  const guardCancel = (make) => Effect.promise(make).pipe(Effect.filterOrFail((result) => typeof result !== "symbol", () => new Cancelled()));
203
199
  /**
@@ -283,17 +279,15 @@ function skillLink(skill) {
283
279
  target: `../../${SKILLS_ROOT}/${skill.name}`
284
280
  };
285
281
  }
286
- //#endregion
287
- //#region src/bundled-versions.ts
282
+ // src/bundled-versions.ts
288
283
  const bundledVersions = {
289
- oxlint: "1.73.0",
290
- oxlintTsgolint: "0.24.0",
291
- oxfmt: "0.58.0",
284
+ oxlint: "1.89.0",
285
+ oxlintTsgolint: "7.0.2005",
286
+ oxfmt: "0.74.0",
292
287
  knip: "6.26.0",
293
- devConfig: "0.0.4"
288
+ devConfig: "0.0.5"
294
289
  };
295
- //#endregion
296
- //#region src/domain/pkg.ts
290
+ // src/domain/pkg.ts
297
291
  var PkgNotFound = class extends Data.TaggedError("PkgNotFound") {};
298
292
  var PkgInvalid = class extends Data.TaggedError("PkgInvalid") {};
299
293
  function isEsm(pkg) {
@@ -309,8 +303,7 @@ function getMismatchedPackage(pkg, name, version) {
309
303
  const installed = pkg.dependencies?.[name] ?? pkg.devDependencies?.[name];
310
304
  return installed !== void 0 && stripRangePrefix(installed) === version ? void 0 : `${name}@${version}`;
311
305
  }
312
- //#endregion
313
- //#region src/domain/package-manager.ts
306
+ // src/domain/package-manager.ts
314
307
  /**
315
308
  * Extra `add` flags needed when installing at a workspace root: pnpm and yarn
316
309
  * classic refuse root installs without `-w` / `-W`. npm, bun, and yarn berry
@@ -324,8 +317,7 @@ function workspaceRootFlags(pm, hints) {
324
317
  case "bun": return [];
325
318
  }
326
319
  }
327
- //#endregion
328
- //#region src/services/package-installer.ts
320
+ // src/services/package-installer.ts
329
321
  var InstallFailed = class extends Data.TaggedError("InstallFailed") {};
330
322
  /**
331
323
  * Installs npm packages with the detected package manager, adding the
@@ -354,8 +346,7 @@ var PackageInstaller = class extends Effect.Service()("cli/PackageInstaller", {
354
346
  output: [result.stdout, result.stderr].filter(Boolean).join("\n")
355
347
  })), Effect.asVoid) };
356
348
  }) }) {};
357
- //#endregion
358
- //#region src/utils/detect-pm.ts
349
+ // src/utils/detect-pm.ts
359
350
  const detectPm = (cwd, userAgent = process.env["npm_config_user_agent"], fallback = "pnpm") => Effect.gen(function* () {
360
351
  const fs = yield* FileSystem.FileSystem;
361
352
  const pkgPath = (yield* Path.Path).join(cwd, "package.json");
@@ -365,8 +356,7 @@ const detectPm = (cwd, userAgent = process.env["npm_config_user_agent"], fallbac
365
356
  fallback
366
357
  });
367
358
  });
368
- //#endregion
369
- //#region src/utils/pkg-file.ts
359
+ // src/utils/pkg-file.ts
370
360
  const readPkg = (cwd) => Effect.gen(function* () {
371
361
  const fs = yield* FileSystem.FileSystem;
372
362
  const pkgPath = (yield* Path.Path).join(cwd, "package.json");
@@ -383,8 +373,7 @@ const readPkg = (cwd) => Effect.gen(function* () {
383
373
  const writePkg = (pkgPath, pkg) => Effect.gen(function* () {
384
374
  yield* (yield* FileSystem.FileSystem).writeFileString(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
385
375
  });
386
- //#endregion
387
- //#region src/domain/setup.ts
376
+ // src/domain/setup.ts
388
377
  const SETUP_FILE_CANDIDATES = {
389
378
  oxlint: [
390
379
  "oxlint.config.js",
@@ -454,8 +443,7 @@ function configFlag(configFile) {
454
443
  const extension = configFile.slice(configFile.lastIndexOf(".") + 1);
455
444
  return AUTO_DISCOVERED.has(extension) ? "" : ` -c ${configFile}`;
456
445
  }
457
- //#endregion
458
- //#region src/utils/detect-setup.ts
446
+ // src/utils/detect-setup.ts
459
447
  /** Finds an existing config file for the given tool, if any. */
460
448
  const detectSetupFile = (type, cwd) => Effect.gen(function* () {
461
449
  const fs = yield* FileSystem.FileSystem;
@@ -466,8 +454,7 @@ const detectSetupFile = (type, cwd) => Effect.gen(function* () {
466
454
  }
467
455
  return Option.none();
468
456
  });
469
- //#endregion
470
- //#region src/commands/add-commitlint/logic.ts
457
+ // src/commands/add-commitlint/logic.ts
471
458
  function getPackages$5(pkg) {
472
459
  const missing = [];
473
460
  if (!isPackageInstalled(pkg, "@commitlint/cli")) missing.push("@commitlint/cli");
@@ -483,8 +470,7 @@ function commitMsgHook(pm) {
483
470
  "$1"
484
471
  ].join(" ") + "\n";
485
472
  }
486
- //#endregion
487
- //#region src/commands/add-commitlint/index.ts
473
+ // src/commands/add-commitlint/index.ts
488
474
  const apply$7 = Effect.fn("add-commitlint.apply")(function* (cwd, pm) {
489
475
  const fs = yield* FileSystem.FileSystem;
490
476
  const path = yield* Path.Path;
@@ -499,13 +485,11 @@ const apply$7 = Effect.fn("add-commitlint.apply")(function* (cwd, pm) {
499
485
  else yield* fs.writeFileString(hookPath, commitMsgHook(pm));
500
486
  }
501
487
  });
502
- //#endregion
503
- //#region src/commands/add-husky/logic.ts
488
+ // src/commands/add-husky/logic.ts
504
489
  function getPackages$4(pkg) {
505
490
  return isPackageInstalled(pkg, "husky") ? [] : ["husky"];
506
491
  }
507
- //#endregion
508
- //#region src/commands/add-husky/index.ts
492
+ // src/commands/add-husky/index.ts
509
493
  var HuskyInitFailed = class extends Data.TaggedError("HuskyInitFailed") {};
510
494
  const apply$6 = Effect.fn("add-husky.apply")(function* (cwd, pm) {
511
495
  const fs = yield* FileSystem.FileSystem;
@@ -525,8 +509,7 @@ const apply$6 = Effect.fn("add-husky.apply")(function* (cwd, pm) {
525
509
  ], cwd);
526
510
  if (exitCode !== 0) return yield* new HuskyInitFailed({ exitCode });
527
511
  });
528
- //#endregion
529
- //#region src/domain/scripts.ts
512
+ // src/domain/scripts.ts
530
513
  /**
531
514
  * Merges `wanted` scripts into `current` without overwriting anything the user
532
515
  * already has. Returns the merged scripts plus which keys were added or skipped.
@@ -546,8 +529,7 @@ function planScripts(current, wanted) {
546
529
  skipped
547
530
  };
548
531
  }
549
- //#endregion
550
- //#region src/commands/add-knip/logic.ts
532
+ // src/commands/add-knip/logic.ts
551
533
  function getPackages$3(pkg, versions) {
552
534
  return isPackageInstalled(pkg, "knip") ? [] : [`knip@${versions.knip}`, `@chanom/dev-config@${versions.devConfig}`];
553
535
  }
@@ -560,8 +542,7 @@ function configFile$2(esm) {
560
542
  function getScriptPlan$2(scripts) {
561
543
  return planScripts(scripts, { knip: "knip" });
562
544
  }
563
- //#endregion
564
- //#region src/commands/add-knip/index.ts
545
+ // src/commands/add-knip/index.ts
565
546
  /** Returns a copy of `pkg` with missing scripts added; the caller owns writing package.json. */
566
547
  const apply$5 = Effect.fn("add-knip.apply")(function* (cwd, esm, pkg) {
567
548
  const fs = yield* FileSystem.FileSystem;
@@ -580,8 +561,7 @@ const apply$5 = Effect.fn("add-knip.apply")(function* (cwd, esm, pkg) {
580
561
  scripts: plan.scripts
581
562
  };
582
563
  });
583
- //#endregion
584
- //#region src/commands/add-lint-staged/logic.ts
564
+ // src/commands/add-lint-staged/logic.ts
585
565
  function getPackages$2(pkg) {
586
566
  return isPackageInstalled(pkg, "lint-staged") ? [] : ["lint-staged"];
587
567
  }
@@ -598,8 +578,7 @@ function buildConfig(linters, formatters, configFiles) {
598
578
  }
599
579
  return config;
600
580
  }
601
- //#endregion
602
- //#region src/commands/add-lint-staged/index.ts
581
+ // src/commands/add-lint-staged/index.ts
603
582
  /**
604
583
  * Config file each tool will run against: an existing one when `add-oxlint` /
605
584
  * `add-oxfmt` skipped writing, otherwise the name they scaffold. lint-staged
@@ -641,8 +620,7 @@ const apply$4 = Effect.fn("add-lint-staged.apply")(function* (cwd, esm, linters
641
620
  else yield* fs.writeFileString(hookPath, "lint-staged\n");
642
621
  }
643
622
  });
644
- //#endregion
645
- //#region src/commands/add-oxfmt/logic.ts
623
+ // src/commands/add-oxfmt/logic.ts
646
624
  function getPackages$1(pkg, versions) {
647
625
  return [getMismatchedPackage(pkg, "oxfmt", versions.oxfmt), getMismatchedPackage(pkg, "@chanom/dev-config", versions.devConfig)].filter((p) => p !== void 0);
648
626
  }
@@ -659,8 +637,7 @@ function getScriptPlan$1(scripts, configFile) {
659
637
  "format:check": `oxfmt --check${config}`
660
638
  });
661
639
  }
662
- //#endregion
663
- //#region src/commands/add-oxfmt/index.ts
640
+ // src/commands/add-oxfmt/index.ts
664
641
  /** Returns a copy of `pkg` with missing scripts added; the caller owns writing package.json. */
665
642
  const apply$3 = Effect.fn("add-oxfmt.apply")(function* (cwd, esm, pkg) {
666
643
  const fs = yield* FileSystem.FileSystem;
@@ -683,8 +660,7 @@ const apply$3 = Effect.fn("add-oxfmt.apply")(function* (cwd, esm, pkg) {
683
660
  scripts: plan.scripts
684
661
  };
685
662
  });
686
- //#endregion
687
- //#region src/commands/add-oxlint/logic.ts
663
+ // src/commands/add-oxlint/logic.ts
688
664
  function getPackages(pkg, versions) {
689
665
  return [
690
666
  getMismatchedPackage(pkg, "oxlint", versions.oxlint),
@@ -705,8 +681,7 @@ function getScriptPlan(scripts, configFile) {
705
681
  "lint:fix": `oxlint --fix${config}`
706
682
  });
707
683
  }
708
- //#endregion
709
- //#region src/commands/add-oxlint/index.ts
684
+ // src/commands/add-oxlint/index.ts
710
685
  /** Returns a copy of `pkg` with missing scripts added; the caller owns writing package.json. */
711
686
  const apply$2 = Effect.fn("add-oxlint.apply")(function* (cwd, esm, pkg) {
712
687
  const fs = yield* FileSystem.FileSystem;
@@ -729,8 +704,7 @@ const apply$2 = Effect.fn("add-oxlint.apply")(function* (cwd, esm, pkg) {
729
704
  scripts: plan.scripts
730
705
  };
731
706
  });
732
- //#endregion
733
- //#region src/commands/add-skills/logic.ts
707
+ // src/commands/add-skills/logic.ts
734
708
  /**
735
709
  * Splits the skill's files by whether they are already on disk. Existing files
736
710
  * always win: a user who has edited the standards to fit their project keeps
@@ -746,8 +720,7 @@ function planSkillFiles(files, exists) {
746
720
  skipped
747
721
  };
748
722
  }
749
- //#endregion
750
- //#region src/commands/add-skills/index.ts
723
+ // src/commands/add-skills/index.ts
751
724
  /**
752
725
  * Links `.claude/skills/<name>` at the real directory under `.agents/skills/`.
753
726
  * Anything already at the link path - a link the user already has, or a real
@@ -787,8 +760,7 @@ const apply$1 = Effect.fn("add-skills.apply")(function* (cwd) {
787
760
  }
788
761
  for (const skill of SKILLS) yield* linkSkill(cwd, skillLink(skill));
789
762
  });
790
- //#endregion
791
- //#region src/commands/add-vscode/index.ts
763
+ // src/commands/add-vscode/index.ts
792
764
  const writeJson = Effect.fn("add-vscode.writeJson")(function* (filePath, value) {
793
765
  yield* (yield* FileSystem.FileSystem).writeFileString(filePath, JSON.stringify(value, null, 2) + "\n");
794
766
  });
@@ -851,8 +823,7 @@ const apply = Effect.fn("add-vscode.apply")(function* (cwd, oxfmtConfigPath) {
851
823
  yield* applySettings(vscodeDir, oxfmtConfigPath);
852
824
  yield* applyExtensions(vscodeDir);
853
825
  });
854
- //#endregion
855
- //#region src/commands/brew/logic.ts
826
+ // src/commands/brew/logic.ts
856
827
  /** Deduplicated list of packages to install for the chosen toppings and sweetness. */
857
828
  function planPackages(pkg, toppings, sweetness, versions) {
858
829
  const packages = [];
@@ -900,8 +871,7 @@ function selectedLinters(toppings) {
900
871
  function selectedFormatters(toppings) {
901
872
  return toppings.filter((t) => t === "oxfmt");
902
873
  }
903
- //#endregion
904
- //#region src/commands/brew/index.ts
874
+ // src/commands/brew/index.ts
905
875
  var NotAtRepoRoot = class extends Data.TaggedError("NotAtRepoRoot") {};
906
876
  const ensureGitRepo = Effect.fn("brew.ensureGitRepo")(function* (cwd) {
907
877
  const git = yield* Git;
@@ -1065,13 +1035,13 @@ const brew = (cwd = process.cwd()) => Effect.gen(function* () {
1065
1035
  yield* Effect.logDebug(`planned packages: ${packages.length > 0 ? packages.join(", ") : "(none)"}`);
1066
1036
  yield* installPackages(pm, cwd, packages);
1067
1037
  const { pkg: installedPkg } = yield* readPkg(cwd);
1068
- yield* persistScripts(pkgPath, installedPkg, yield* applyToppings(cwd, isEsm(installedPkg), installedPkg, toppings));
1038
+ const updated = yield* applyToppings(cwd, isEsm(installedPkg), installedPkg, toppings);
1039
+ yield* persistScripts(pkgPath, installedPkg, updated);
1069
1040
  yield* setupCommitGate(cwd, pm, isEsm(installedPkg), toppings, sweetness);
1070
1041
  yield* commitChanges(cwd);
1071
1042
  yield* prompter.outro(pc.green(`Your Chanom with ${toppings.join(", ")} toppings and ${sweetness} sweetness is ready! Enjoy! 🧋`));
1072
1043
  });
1073
- //#endregion
1074
- //#region src/cli.ts
1044
+ // src/cli.ts
1075
1045
  var UnknownCommand = class extends Data.TaggedError("UnknownCommand") {};
1076
1046
  const commands = { brew };
1077
1047
  const dispatch = (name, cwd) => Effect.gen(function* () {
@@ -1110,8 +1080,7 @@ const run = (name, cwd = process.cwd(), options = {}) => {
1110
1080
  NotAtRepoRoot: (e) => reportError(`Git hooks must be set up at the repository root: ${e.root}\nRun \`chanom brew\` there, or choose light sweetness.`)
1111
1081
  }))).pipe(Logger.withMinimumLogLevel(debug ? LogLevel.Debug : LogLevel.Info));
1112
1082
  };
1113
- //#endregion
1114
- //#region src/index.ts
1083
+ // src/index.ts
1115
1084
  const args = process.argv.slice(2);
1116
1085
  const debug = args.includes("--debug");
1117
1086
  const command = args.find((arg) => !arg.startsWith("--"));
@@ -1125,5 +1094,4 @@ NodeRuntime.runMain(program, {
1125
1094
  disableErrorReporting: true,
1126
1095
  disablePrettyLogger: true
1127
1096
  });
1128
- //#endregion
1129
1097
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chanom/cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -29,10 +29,10 @@
29
29
  "@tsconfig/node-ts": "23.6.4",
30
30
  "@types/node": "26.0.1",
31
31
  "@vitest/coverage-v8": "3.2.6",
32
- "tsdown": "0.22.3",
33
- "typescript": "6.0.3",
32
+ "tsdown": "0.23.1",
33
+ "typescript": "7.0.2",
34
34
  "vitest": "3.2.6",
35
- "@chanom/dev-config": "0.0.4",
35
+ "@chanom/dev-config": "0.0.5",
36
36
  "@chanom/internal": "0.0.0"
37
37
  },
38
38
  "scripts": {