@stacksjs/buddy 0.70.71 → 0.70.73

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.
@@ -1,24 +1,9 @@
1
- import { existsSync } from "node:fs";
2
1
  import process from "node:process";
3
- import { intro, log, onUnknownSubcommand, outro, runCommand } from "@stacksjs/cli";
4
- import { path } from "@stacksjs/path";
2
+ import { intro, log, onUnknownSubcommand, outro } from "@stacksjs/cli";
5
3
  import { ExitCode } from "@stacksjs/types";
6
- function lintActionCommand(entry) {
7
- const vendored = path.projectPath(`storage/framework/core/actions/src/lint/${entry}.ts`);
8
- if (existsSync(vendored))
9
- return `bun storage/framework/core/actions/src/lint/${entry}.ts`;
10
- try {
11
- const pkgJson = Bun.resolveSync("@stacksjs/actions/package.json", path.projectPath()), dist = path.resolve(path.dirname(pkgJson), `dist/lint/${entry}.js`);
12
- if (existsSync(dist))
13
- return `bun ${dist}`;
14
- } catch {}
15
- return `bun storage/framework/core/actions/src/lint/${entry}.ts`;
16
- }
17
- function exitOnFailure(result, label) {
18
- if (!result || typeof result !== "object" || !("isErr" in result))
19
- return;
20
- const marker = result.isErr;
21
- if (typeof marker === "function" ? marker() : marker === !0) {
4
+ async function runStyleAction(entry, label, options) {
5
+ const actions = await import("@stacksjs/actions"), { ok } = await actions[entry](options);
6
+ if (!ok) {
22
7
  log.error(`${label} reported failure`);
23
8
  process.exit(ExitCode.FatalError);
24
9
  }
@@ -34,28 +19,27 @@ export function lint(buddy) {
34
19
  };
35
20
  buddy.command("lint", descriptions.lint).option("-f, --fix", descriptions.lintFix, { default: !1 }).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
36
21
  log.debug("Running `buddy lint` ...", options);
37
- const startTime = await intro("buddy lint"), result = options.fix ? await runCommand(lintActionCommand("fix"), { cwd: path.projectPath() }) : await runCommand(lintActionCommand("index"), { cwd: path.projectPath() });
38
- exitOnFailure(result, "lint");
22
+ const startTime = await intro("buddy lint");
23
+ await runStyleAction(options.fix ? "lintFix" : "lintProject", "lint");
39
24
  await outro("Linted your project", { startTime, useSeconds: !0 });
40
25
  });
41
26
  buddy.command("lint:fix", descriptions.lintFix).option("-p, --project [project]", descriptions.project, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
42
27
  log.debug("Running `buddy lint:fix` ...", options);
43
28
  const startTime = await intro("buddy lint:fix");
44
29
  log.info("Fixing lint errors...");
45
- const result = await runCommand(lintActionCommand("fix"), { cwd: path.projectPath() });
46
- exitOnFailure(result, "lint:fix");
30
+ await runStyleAction("lintFix", "lint:fix");
47
31
  await outro("Fixed lint errors", { startTime, useSeconds: !0 });
48
32
  });
49
33
  buddy.command("format", descriptions.format).option("-w, --write", "Write changes to files", { default: !1 }).option("-c, --check", descriptions.formatCheck, { default: !1 }).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
50
34
  log.debug("Running `buddy format` ...", options);
51
- const startTime = await intro("buddy format"), result = options.check ? await runCommand("bunx --bun pickier run --mode format --config ./pickier.config.ts --check", { cwd: path.projectPath() }) : await runCommand("bunx --bun pickier run --mode format --config ./pickier.config.ts --write", { cwd: path.projectPath() });
52
- exitOnFailure(result, "format");
35
+ const startTime = await intro("buddy format");
36
+ await runStyleAction("formatProject", "format", options.check ? { check: !0 } : { write: !0 });
53
37
  await outro("Formatted your project", { startTime, useSeconds: !0 });
54
38
  });
55
39
  buddy.command("format:check", descriptions.formatCheck).option("--verbose", descriptions.verbose, { default: !1 }).action(async (options) => {
56
40
  log.debug("Running `buddy format:check` ...", options);
57
- const startTime = await intro("buddy format:check"), result = await runCommand("bunx --bun pickier run --mode format --config ./pickier.config.ts --check", { cwd: path.projectPath() });
58
- exitOnFailure(result, "format:check");
41
+ const startTime = await intro("buddy format:check");
42
+ await runStyleAction("formatProject", "format:check", { check: !0 });
59
43
  await outro("Format check complete", { startTime, useSeconds: !0 });
60
44
  });
61
45
  onUnknownSubcommand(buddy, "lint");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
- "version": "0.70.71",
4
+ "version": "0.70.73",
5
5
  "description": "Meet Buddy. The Stacks runtime.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [