@savvy-web/cli 2.5.0 → 2.5.1

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/cli/index.js CHANGED
@@ -76,7 +76,7 @@ const rootCommand = Command.make("savvy").pipe(Command.withSubcommands([
76
76
  * CLI application: reads argv from the Stdio service provided by NodeServices.
77
77
  * (v4's `Command.run` takes only `version` — the name comes from the root command.)
78
78
  */
79
- const cli = Command.run(rootCommand, { version: "2.5.0" });
79
+ const cli = Command.run(rootCommand, { version: "2.5.1" });
80
80
  /**
81
81
  * Shared workspace services from `@effected/workspaces`, wired as a
82
82
  * self-contained unit and built ONCE (layers memoize by reference).
@@ -1,6 +1,6 @@
1
1
  import { Lint } from "@savvy-web/silk-effects";
2
- import { Effect } from "effect";
3
- import { Argument, Command } from "effect/unstable/cli";
2
+ import { Effect, Option } from "effect";
3
+ import { Argument, Command, Flag } from "effect/unstable/cli";
4
4
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { Yaml } from "@effected/yaml";
6
6
 
@@ -17,6 +17,15 @@ import { Yaml } from "@effected/yaml";
17
17
  */
18
18
  /** Repeated file path arguments. */
19
19
  const filesArg = Argument.file("files", { mustExist: true }).pipe(Argument.variadic());
20
+ /**
21
+ * Formatting options forwarded from `Lint.Yaml.fmtCommand`.
22
+ *
23
+ * @remarks
24
+ * This subcommand runs in its own process, so options set on the lint-staged
25
+ * handler only reach the formatter across this flag. Omitting it would make
26
+ * `fmtCommand({ format })` and `create({ format })` write different bytes.
27
+ */
28
+ const yamlFormatOption = Flag.string("format").pipe(Flag.withDescription("JSON-encoded @effected/yaml formatting options"), Flag.optional);
20
29
  /** Sort package.json files with sort-package-json. */
21
30
  const packageJsonCommand = Command.make("package-json", { files: filesArg }, ({ files }) => Effect.sync(() => {
22
31
  for (const filepath of files) {
@@ -35,9 +44,13 @@ const pnpmWorkspaceCommand = Command.make("pnpm-workspace", {}, () => Effect.gen
35
44
  const formatted = yield* Effect.promise(() => Lint.PnpmWorkspace.formatContent(sorted));
36
45
  writeFileSync(filepath, formatted, "utf-8");
37
46
  }));
38
- /** Format YAML files with Prettier. */
39
- const yamlCommand = Command.make("yaml", { files: filesArg }, ({ files }) => Effect.gen(function* () {
40
- for (const filepath of files) yield* Effect.promise(() => Lint.Yaml.formatFile(filepath));
47
+ /** Format YAML files with @effected/yaml. */
48
+ const yamlCommand = Command.make("yaml", {
49
+ files: filesArg,
50
+ format: yamlFormatOption
51
+ }, ({ files, format }) => Effect.sync(() => {
52
+ const options = Option.isSome(format) ? Lint.Yaml.parseFormatOptions(format.value) : void 0;
53
+ for (const filepath of files) Lint.Yaml.formatFile(filepath, options);
41
54
  }));
42
55
  /** Parent fmt command with formatting subcommands. */
43
56
  const _fmtCommand = Command.make("fmt").pipe(Command.withSubcommands([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/cli",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "private": false,
5
5
  "description": "The savvy CLI — unified commit, changeset, and lint commands for the Silk Suite",
6
6
  "homepage": "https://github.com/savvy-web/systems/tree/main/packages/cli",
@@ -36,9 +36,9 @@
36
36
  "@effected/git": "^0.7.0",
37
37
  "@effected/jsonc": "^0.6.0",
38
38
  "@effected/templates": "^0.2.0",
39
- "@effected/workspaces": "^0.11.1",
40
- "@effected/yaml": "^0.7.0",
41
- "@savvy-web/silk-effects": "5.6.0",
39
+ "@effected/workspaces": "^0.11.2",
40
+ "@effected/yaml": "^0.8.0",
41
+ "@savvy-web/silk-effects": "5.7.0",
42
42
  "effect": "4.0.0-beta.107"
43
43
  }
44
44
  }