effect-ci 0.1.0 → 0.1.2

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,4 +1,23 @@
1
1
  // ../ci/src/vite-plus.ts
2
+ import { createHash } from "node:crypto";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ var parseRunPlan = (body) => {
6
+ const start = body.startsWith("{") ? 0 : body.indexOf("\n{") + 1;
7
+ let plan;
8
+ try {
9
+ plan = JSON.parse(body.slice(start));
10
+ } catch (error) {
11
+ throw new Error(
12
+ `Expected a JSON run plan from \`vp run --dry-run --json\`, got: ${JSON.stringify(body.slice(0, 200))}`,
13
+ { cause: error }
14
+ );
15
+ }
16
+ if (plan?.version !== 1 || typeof plan.plan !== "object" || plan.plan === null) {
17
+ throw new Error("Expected a version 1 Vite+ run plan from `vp run --dry-run --json`");
18
+ }
19
+ return plan;
20
+ };
2
21
  var marker = (change) => change === "added" ? "+" : change === "removed" ? "-" : "\xB1";
3
22
  var describeChange = (change) => {
4
23
  switch (change.kind) {
@@ -31,10 +50,7 @@ var describeStatus = (cache) => {
31
50
  }
32
51
  };
33
52
  var cacheLog = (body) => {
34
- const plan = JSON.parse(body);
35
- if (plan.version !== 1 || typeof plan.plan !== "object" || plan.plan === null) {
36
- throw new Error("Expected a version 1 Vite+ run plan from `vp run --dry-run --json`");
37
- }
53
+ const plan = parseRunPlan(body);
38
54
  const lines = [];
39
55
  const visit = (tasks, prefix) => {
40
56
  for (const [id, task] of Object.entries(tasks)) {
@@ -59,7 +75,7 @@ var cacheLog = (body) => {
59
75
  return lines;
60
76
  };
61
77
  var untracedHits = (body) => {
62
- const plan = JSON.parse(body);
78
+ const plan = parseRunPlan(body);
63
79
  const labels = [];
64
80
  const visit = (tasks, prefix) => {
65
81
  for (const [id, task] of Object.entries(tasks)) {
@@ -77,8 +93,42 @@ var untracedHits = (body) => {
77
93
  visit(plan.plan, "");
78
94
  return labels;
79
95
  };
96
+ var synthesizedConfigMarker = "// Generated by effect-ci for one command. Safe to delete.";
97
+ var configFiles = ["vite.config.mjs", "vite.config.ts", "vite.config.cjs", "vite.config.mts", "vite.config.cts"];
98
+ var commandTaskName = (command) => `effect-ci:${createHash("sha256").update(command).digest("hex").slice(0, 12)}`;
99
+ var synthesizedConfig = (cwd, name, command) => {
100
+ if (!existsSync(join(cwd, "package.json")) || !existsSync(join(cwd, "node_modules"))) return void 0;
101
+ const own = join(cwd, "vite.config.js");
102
+ if (existsSync(own) && !readFileSync(own, "utf8").startsWith(synthesizedConfigMarker)) return void 0;
103
+ const task = JSON.stringify({ command, cache: { env: ["CLOUDFLARE_*", "NODE_ENV", "VITE_*"], untrackedEnv: ["*"] } });
104
+ const user = configFiles.find((file) => existsSync(join(cwd, file)));
105
+ if (!user) return `${synthesizedConfigMarker}
106
+ export default { run: { tasks: { ${JSON.stringify(name)}: ${task} } } }
107
+ `;
108
+ return `${synthesizedConfigMarker}
109
+ import config from ${JSON.stringify(`./${user}`)}
110
+ export default async env => {
111
+ const base = (typeof config === "function" ? await config(env) : await config) ?? {}
112
+ return { ...base, run: { ...base.run, tasks: { ...base.run?.tasks, ${JSON.stringify(name)}: ${task} } } }
113
+ }
114
+ `;
115
+ };
116
+ var packageScript = (cwd, command) => {
117
+ const [, runner, script] = /^(npm run|npm|pnpm run|pnpm|yarn run|yarn|bun run) ([\w:.-]+)$/.exec(command.trim()) ?? [];
118
+ if (!script || !existsSync(join(cwd, "package.json"))) return void 0;
119
+ if (runner === "npm" && !["test", "start", "stop", "restart"].includes(script)) return void 0;
120
+ if (!runner?.endsWith(" run") && ["install", "add", "remove", "update", "publish", "pack", "link", "exec"].includes(script))
121
+ return void 0;
122
+ const { scripts } = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"));
123
+ return typeof scripts?.[script] === "string" ? script : void 0;
124
+ };
80
125
 
81
126
  export {
127
+ parseRunPlan,
82
128
  cacheLog,
83
- untracedHits
129
+ untracedHits,
130
+ synthesizedConfigMarker,
131
+ commandTaskName,
132
+ synthesizedConfig,
133
+ packageScript
84
134
  };
@@ -9,13 +9,18 @@ import {
9
9
  } from "./chunk-U3DVQKHN.js";
10
10
  import {
11
11
  cacheLog,
12
+ commandTaskName,
13
+ packageScript,
14
+ synthesizedConfig,
15
+ synthesizedConfigMarker,
12
16
  untracedHits
13
- } from "./chunk-WOG7K3QJ.js";
17
+ } from "./chunk-Q5USMIJ3.js";
14
18
 
15
19
  // ../ci/src/index.ts
16
- import { spawn } from "node:child_process";
17
- import { existsSync, readFileSync, writeSync } from "node:fs";
20
+ import { execFile, spawn } from "node:child_process";
21
+ import { existsSync, readFileSync, rmSync, writeFileSync, writeSync } from "node:fs";
18
22
  import { dirname, join, relative } from "node:path";
23
+ import { promisify } from "node:util";
19
24
  import picomatch from "picomatch";
20
25
  import * as Cache from "effect/Cache";
21
26
  import * as Cause from "effect/Cause";
@@ -24,6 +29,7 @@ import * as Effect2 from "effect/Effect";
24
29
  import * as Exit from "effect/Exit";
25
30
  import * as Redacted from "effect/Redacted";
26
31
  import * as Schedule from "effect/Schedule";
32
+ import * as Semaphore from "effect/Semaphore";
27
33
  import * as Context from "effect/Context";
28
34
 
29
35
  // ../ci/src/turbo.ts
@@ -250,7 +256,7 @@ var makeTurboToolchain = (workspace, namespace, prerequisites) => ({
250
256
  const planFile = ".effect-ci/turbo/plan.json";
251
257
  const discover = action(`${prefix}:plan`, function* () {
252
258
  yield* prerequisites;
253
- return () => workspace.exec(command({ operation: "plan", file: planFile, tags }));
259
+ return () => workspace.exec(command({ operation: "plan", file: planFile, tags }), { cache: false });
254
260
  });
255
261
  return Effect.gen(function* () {
256
262
  const planned = yield* discover();
@@ -290,7 +296,7 @@ var makeTurboToolchain = (workspace, namespace, prerequisites) => ({
290
296
  task,
291
297
  hashes,
292
298
  files: files2
293
- }));
299
+ }), { cache: false });
294
300
  });
295
301
  factories.set(id, run2);
296
302
  return run2;
@@ -300,7 +306,7 @@ var makeTurboToolchain = (workspace, namespace, prerequisites) => ({
300
306
  yield* parallel(sinks.map((task) => factory(task.taskId)()));
301
307
  const outputs = yield* Effect.all(sinks.map((task) => factory(task.taskId)()));
302
308
  const files = yield* filesFrom(sinks.map((task, index) => ({ task, workspace: outputs[index] })));
303
- return yield* planned.exec(command({ operation: "restore", file: planFile, files }));
309
+ return yield* planned.exec(command({ operation: "restore", file: planFile, files }), { cache: false });
304
310
  });
305
311
  })
306
312
  });
@@ -373,6 +379,7 @@ function makeRuntimeObservers(input, timeoutMs = 2e4) {
373
379
  }
374
380
 
375
381
  // ../ci/src/index.ts
382
+ var displayedCommand = /* @__PURE__ */ Symbol("effect-ci/displayedCommand");
376
383
  var WorkflowPlanError = class extends Error {
377
384
  _tag = "WorkflowPlanError";
378
385
  constructor(message) {
@@ -587,6 +594,9 @@ var Workspace = class _Workspace {
587
594
  return Effect2.gen(function* () {
588
595
  const runtime = yield* Runtime;
589
596
  const stepId = yield* CurrentStep;
597
+ const reuse = runtime.definitions.get(stepId)?.options.reuse;
598
+ const reusedByCommit = typeof reuse === "object" && reuse.scope === "commit";
599
+ if (options?.cache !== false && !options?.diagnostic && !options?.trace && !reusedByCommit && workspace.kind === "local" && (yield* VitePlusAvailable)(workspace)) return yield* vitePlusExec(workspace, command2);
590
600
  return yield* runtime.execute(stepId, workspace, command2, options);
591
601
  });
592
602
  }
@@ -716,7 +726,8 @@ var Apt = (workspace) => Effect2.gen(function* () {
716
726
  const names = packages.join(" ");
717
727
  const install = `apt-get install --yes --no-install-recommends ${names}`;
718
728
  return workspace.exec(
719
- `if [ "$(id -u)" -eq 0 ]; then apt-get update && DEBIAN_FRONTEND=noninteractive ${install}; else sudo apt-get update && sudo env DEBIAN_FRONTEND=noninteractive ${install}; fi`
729
+ `if [ "$(id -u)" -eq 0 ]; then apt-get update && DEBIAN_FRONTEND=noninteractive ${install}; else sudo apt-get update && sudo env DEBIAN_FRONTEND=noninteractive ${install}; fi`,
730
+ { cache: false }
720
731
  );
721
732
  }
722
733
  };
@@ -726,32 +737,63 @@ var VitePlusAvailable = Context.Reference(
726
737
  { defaultValue: () => () => false }
727
738
  );
728
739
  var shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
729
- var vp = `PATH="$PATH:$PWD/node_modules/.bin" vp`;
730
- var vitePlusRun = (workspace, name, cache) => Effect2.gen(function* () {
740
+ var vp = `PATH="$PWD/node_modules/.bin:$PATH" vp`;
741
+ var vitePlusRun = (workspace, name, cache, adHoc) => Effect2.gen(function* () {
731
742
  let noCache = (yield* force) ? " --no-cache" : cache ? " --cache" : "";
732
743
  let traced = !(yield* force);
733
744
  if ((yield* executionMode) === "execute") {
734
745
  const file = `node_modules/.effect-ci-vite-plus-run-plan-${name.replaceAll(/[^\w-]/g, "_")}.json`;
735
- yield* workspace.exec(
736
- `mkdir -p node_modules && ${vp} run --dry-run --json${noCache} -vv ${shellQuote(name)} > ${file}`,
737
- { diagnostic: true }
738
- );
739
- const body = yield* workspace.readFile(file);
746
+ const dryRun = `${vp} run --dry-run --json${noCache} -vv ${shellQuote(name)}`;
747
+ const body = adHoc ? yield* Effect2.tryPromise(async () => (await promisify(execFile)("sh", ["-c", dryRun], {
748
+ cwd: workspace.cwd,
749
+ encoding: "utf8",
750
+ maxBuffer: 16 * 1024 * 1024,
751
+ env: (({ EFFECT_CI_EVENT_FD: _eventPipe, ...env }) => env)(process.env)
752
+ })).stdout) : yield* workspace.exec(`mkdir -p node_modules && ${dryRun} > ${file}`, { diagnostic: true }).pipe(Effect2.andThen(workspace.readFile(file)));
740
753
  if (body === void 0) return yield* Effect2.fail(new Error(`Vite+ wrote no run plan to ${file}`));
741
- const lines = yield* Effect2.try({ try: () => cacheLog(body), catch: (error) => error });
754
+ const lines = yield* Effect2.try({ try: () => cacheLog(body), catch: (error) => error }).pipe(
755
+ // Log which vp ran: a stale global one is the usual cause of an unreadable plan.
756
+ Effect2.tapError(() => workspace.exec(
757
+ `PATH="$PWD/node_modules/.bin:$PATH"; command -v vp; vp --version`,
758
+ { diagnostic: true, cache: false }
759
+ ).pipe(Effect2.ignore)),
760
+ Effect2.mapError((error) => new Error(`${error.message}. effect-ci runs node_modules/.bin/vp, else the global vp, and needs Vite+ 1.8 or later; the diagnostic log shows which vp ran`, { cause: error }))
761
+ );
742
762
  for (const line of lines) yield* line.level === "Info" ? Effect2.logInfo(line.message) : Effect2.logDebug(line.message);
743
763
  const untraced = traced ? untracedHits(body) : [];
744
764
  if (untraced.length > 0) {
745
- yield* Effect2.logWarning(`vite+ ${untraced.join(", ")}: the cached run read no project files, so running without the cache`);
765
+ const message = `vite+ ${untraced.join(", ")}: the cached run read no project files, so running without the cache. Once Vite+ can trace the tool (TypeScript 7.1 or later for \`tsc\` on macOS), run \`vp cache clean\` once to cache it again`;
766
+ yield* adHoc?.synthesized ? Effect2.logDebug(message) : Effect2.logWarning(message);
746
767
  noCache = " --no-cache";
747
768
  traced = false;
748
769
  }
749
770
  }
750
- return yield* workspace.exec(
751
- `${vp} run -v${noCache} ${shellQuote(name)}`,
752
- traced ? { trace: { tool: "vite-plus", task: name } } : void 0
753
- );
771
+ const run2 = (flags, trace) => workspace.exec(`${vp} run -v${flags} ${shellQuote(name)}`, {
772
+ ...trace ? { trace: { tool: "vite-plus", task: name } } : { cache: false },
773
+ ...adHoc ? { [displayedCommand]: adHoc.command } : {}
774
+ });
775
+ if (!adHoc || noCache === " --no-cache") return yield* run2(noCache, traced);
776
+ return yield* run2(noCache, traced).pipe(Effect2.catch((error) => error instanceof CommandError && /Failed to spawn process: underlying os error: Invalid argument/.test(`${error.output?.stdout}${error.output?.stderr}`) ? Effect2.logWarning(`vite+ ${adHoc.command}: Vite+ can't trace a command that starts another cached \`vp run\`, so running it without the cache`).pipe(Effect2.andThen(run2(" --no-cache", false))) : Effect2.fail(error)));
754
777
  });
778
+ var synthesizedConfigLocks = /* @__PURE__ */ new Map();
779
+ var vitePlusExec = (workspace, command2) => Effect2.gen(function* () {
780
+ if ((yield* executionMode) !== "execute") return yield* workspace.exec(command2, { cache: false });
781
+ const script = packageScript(workspace.cwd, command2);
782
+ if (script) return yield* vitePlusRun(workspace, script, true, { command: command2, synthesized: false });
783
+ const name = commandTaskName(command2);
784
+ const config = synthesizedConfig(workspace.cwd, name, command2);
785
+ if (config === void 0) return yield* workspace.exec(command2, { cache: false });
786
+ const path = join(workspace.cwd, "vite.config.js");
787
+ let lock = synthesizedConfigLocks.get(workspace.cwd);
788
+ if (!lock) synthesizedConfigLocks.set(workspace.cwd, lock = Semaphore.makeUnsafe(1));
789
+ return yield* lock.withPermits(1)(Effect2.acquireUseRelease(
790
+ Effect2.sync(() => writeFileSync(path, config)),
791
+ () => vitePlusRun(workspace, name, true, { command: command2, synthesized: true }),
792
+ () => Effect2.sync(() => {
793
+ if (existsSync(path) && readFileSync(path, "utf8").startsWith(synthesizedConfigMarker)) rmSync(path);
794
+ })
795
+ ));
796
+ }).pipe(Effect2.catch((error) => error instanceof CommandError || error instanceof CommandCheckpointError || error instanceof CommandExecutionError ? Effect2.fail(error) : Effect2.die(error)));
755
797
  var withVitePlus = (manager, vitePlus) => ({
756
798
  ...manager,
757
799
  vitePlus,
@@ -816,8 +858,8 @@ var detectJavaScript = (workspace) => Effect2.gen(function* () {
816
858
  ...owner,
817
859
  workspace,
818
860
  install: (options) => owner.install(options).pipe(Effect2.as(workspace)),
819
- run: (script) => workspace.exec(`${owner.name} run ${JSON.stringify(script)}`),
820
- exec: (command3) => workspace.exec(`${owner.name === "bun" ? "bunx" : owner.name === "npm" ? "npm exec --" : `${owner.name} exec`} ${command3}`)
861
+ run: (script) => workspace.exec(`${owner.name} run ${JSON.stringify(script)}`, { cache: false }),
862
+ exec: (command3) => workspace.exec(`${owner.name === "bun" ? "bunx" : owner.name === "npm" ? "npm exec --" : `${owner.name} exec`} ${command3}`, { cache: false })
821
863
  };
822
864
  }
823
865
  }
@@ -885,10 +927,10 @@ var detectJavaScript = (workspace) => Effect2.gen(function* () {
885
927
  frozenLockfile,
886
928
  options?.offline ?? false,
887
929
  workspace.kind === "remote" || runtime.ci
888
- ));
930
+ ), { cache: false });
889
931
  }),
890
- run: (script) => workspace.exec(command2("run", script)),
891
- exec: (executable2) => workspace.exec(command2("exec", executable2))
932
+ run: (script) => workspace.exec(command2("run", script), { cache: false }),
933
+ exec: (executable2) => workspace.exec(command2("exec", executable2), { cache: false })
892
934
  };
893
935
  }).pipe(
894
936
  Effect2.mapError((error) => error instanceof PackageManagerError ? error : new PackageManagerError(workspace.cwd, String(error)))
@@ -944,9 +986,10 @@ var Node = (workspace) => Effect2.gen(function* () {
944
986
  return {
945
987
  version,
946
988
  workspace,
947
- install: () => workspace.exec(`${miseEnvironment} mise --yes install ${tool}`),
989
+ install: () => workspace.exec(`${miseEnvironment} mise --yes install ${tool}`, { cache: false }),
948
990
  exec: (command2) => workspace.exec(
949
- `${miseEnvironment} mise exec ${tool} -- ${command2}`
991
+ `${miseEnvironment} mise exec ${tool} -- ${command2}`,
992
+ { cache: false }
950
993
  )
951
994
  };
952
995
  }).pipe(
@@ -970,10 +1013,12 @@ var Mise = (workspace) => Effect2.gen(function* () {
970
1013
  return {
971
1014
  workspace,
972
1015
  install: (options) => workspace.exec(
973
- `${miseEnvironment} mise --yes${options?.locked ? " --locked" : ""} install`
1016
+ `${miseEnvironment} mise --yes${options?.locked ? " --locked" : ""} install`,
1017
+ { cache: false }
974
1018
  ),
975
1019
  exec: (command2) => workspace.exec(
976
- `${miseEnvironment} mise exec -- ${command2}`
1020
+ `${miseEnvironment} mise exec -- ${command2}`,
1021
+ { cache: false }
977
1022
  )
978
1023
  };
979
1024
  }).pipe(
@@ -1701,7 +1746,7 @@ var makeRuntime = (workflowId, ci, mode, output, emitEvent, event, approvalHandl
1701
1746
  execute: (stepId, workspace, command2, execOptions) => {
1702
1747
  const node = nodes.get(stepId);
1703
1748
  if (!node) return Effect2.die(new Error(`Missing plan node for ${stepId}`));
1704
- node.commands.push({ command: command2, cwd: workspace.cwd });
1749
+ node.commands.push({ command: execOptions?.[displayedCommand] ?? command2, cwd: workspace.cwd });
1705
1750
  const commandIndex = node.commands.length;
1706
1751
  if (mode === "plan") {
1707
1752
  return Effect2.succeed(workspace);
@@ -14,13 +14,13 @@ import {
14
14
  parallel,
15
15
  runPromise,
16
16
  workflow
17
- } from "./chunk-X4HGOXPL.js";
17
+ } from "./chunk-VWYQILHI.js";
18
18
  import {
19
19
  decodeCommandDiagnostics
20
20
  } from "./chunk-WGBTI7DS.js";
21
21
  import "./chunk-MZ5FQEN6.js";
22
22
  import "./chunk-U3DVQKHN.js";
23
- import "./chunk-WOG7K3QJ.js";
23
+ import "./chunk-Q5USMIJ3.js";
24
24
 
25
25
  // ../cli/src/workload-auth.ts
26
26
  var hasWorkloadIdentity = () => !!process.env.EFFECT_CI_OIDC_TOKEN || !!(process.env.ACTIONS_ID_TOKEN_REQUEST_URL && process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN);
@@ -366,7 +366,7 @@ var vitePlusTasks = (root) => {
366
366
  };
367
367
  var vitePlusAvailable = (cwd) => {
368
368
  try {
369
- execFileSync4("sh", ["-c", 'PATH="$PATH:$PWD/node_modules/.bin"; command -v vp'], { cwd, stdio: "ignore" });
369
+ execFileSync4("sh", ["-c", 'PATH="$PWD/node_modules/.bin:$PATH"; command -v vp'], { cwd, stdio: "ignore" });
370
370
  return true;
371
371
  } catch {
372
372
  return false;
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  executionMode
3
- } from "./chunks/chunk-X4HGOXPL.js";
3
+ } from "./chunks/chunk-VWYQILHI.js";
4
4
  import "./chunks/chunk-WGBTI7DS.js";
5
5
  import "./chunks/chunk-MZ5FQEN6.js";
6
6
  import {
7
7
  pathPatterns,
8
8
  pathPrefixes
9
9
  } from "./chunks/chunk-U3DVQKHN.js";
10
- import "./chunks/chunk-WOG7K3QJ.js";
10
+ import "./chunks/chunk-Q5USMIJ3.js";
11
11
 
12
12
  // ../ci/src/directory-deployment.ts
13
13
  import { createHash, randomUUID } from "node:crypto";
package/dist/effect-ci.js CHANGED
@@ -39,5 +39,5 @@ registerHooks({
39
39
  });
40
40
 
41
41
  // ../cli/src/effect-ci.ts
42
- var { runCli } = await import("./chunks/src-FUJGARUK.js");
42
+ var { runCli } = await import("./chunks/src-ZJD4AHNT.js");
43
43
  await runCli();
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  step,
43
43
  when,
44
44
  workflow
45
- } from "./chunks/chunk-X4HGOXPL.js";
45
+ } from "./chunks/chunk-VWYQILHI.js";
46
46
  import {
47
47
  boundedCommandOutput,
48
48
  commandDiagnosticLimit,
@@ -51,7 +51,7 @@ import {
51
51
  } from "./chunks/chunk-WGBTI7DS.js";
52
52
  import "./chunks/chunk-MZ5FQEN6.js";
53
53
  import "./chunks/chunk-U3DVQKHN.js";
54
- import "./chunks/chunk-WOG7K3QJ.js";
54
+ import "./chunks/chunk-Q5USMIJ3.js";
55
55
  export {
56
56
  Approval,
57
57
  ApprovalError,
@@ -18,8 +18,8 @@ export declare function directoryDeployment(options: {
18
18
  changes: WorkspaceChangeProvider;
19
19
  publish: (workspace: Workspace) => Effect.Effect<DirectoryDeploymentReceipt | undefined, unknown, {
20
20
  readonly Service: import("./index.js").RuntimeShape;
21
- readonly "~effect/Context/Service": typeof import("effect/Context").ServiceTypeId;
22
21
  readonly key: "@effect-ci-testbed/Runtime";
22
+ readonly "~effect/Context/Service": typeof import("effect/Context").ServiceTypeId;
23
23
  }>;
24
24
  read: (path: string) => Effect.Effect<Buffer<ArrayBufferLike> | undefined, unknown, never>;
25
25
  };
@@ -47,7 +47,19 @@ export interface ExecOptions {
47
47
  /** A read-only command that only describes the step, such as a cache dry run.
48
48
  * It runs every time and never makes a reused check count as executed. */
49
49
  readonly diagnostic?: boolean;
50
+ /**
51
+ * With Vite+, `true` (the default) runs the command as a cached Vite+ task, like `run`
52
+ * caches package.json scripts. A cache hit replays the output and restores the files the
53
+ * command wrote, without running it. Set `false` for commands whose effect is outside the
54
+ * workspace, such as deploys, installs and pushes. `effect-ci run --force` runs every command.
55
+ * Ignored without Vite+, without a package.json and installed node_modules in the workspace,
56
+ * when the workspace has its own `vite.config.js`, or in a check reused by commit.
57
+ */
58
+ readonly cache?: boolean;
59
+ /** The command a plan shows instead. Set by `workspace.exec` with Vite+. */
60
+ readonly [displayedCommand]?: string;
50
61
  }
62
+ declare const displayedCommand: unique symbol;
51
63
  type InternalStepOptions = StepOptions & Pick<CheckOptions, "reuse">;
52
64
  export interface ActionOptions extends StepOptions {
53
65
  /**
@@ -471,7 +483,7 @@ export interface JavaScriptPackageManager {
471
483
  export declare const JavaScript: (workspace: Workspace) => Effect.Effect<JavaScriptPackageManager, PackageManagerError, Runtime | CurrentStep>;
472
484
  /**
473
485
  * The detected manager, with `run` always through Vite+. Use it for Vite+ tasks or wherever
474
- * a run must be cached. The global `vp` runs it, or the project's own from `node_modules/.bin`.
486
+ * a run must be cached. The project's own `vp` from `node_modules/.bin` runs it, or the global one.
475
487
  * Install and exec stay with the detected manager, which owns the lockfile.
476
488
  */
477
489
  export declare const VitePlus: (workspace: Workspace) => Effect.Effect<JavaScriptPackageManager, PackageManagerError, Runtime | CurrentStep>;
@@ -1,3 +1,47 @@
1
+ /** The parts of a `vp run --dry-run --json` run plan (version 1, Vite+ 1.8) that the log uses. */
2
+ interface RunPlanStep {
3
+ readonly plan?: RunPlan["plan"];
4
+ readonly cache?: {
5
+ readonly status: "hit" | "changed" | "unknown" | "noBaseline" | "error" | "disabled";
6
+ readonly baseline?: {
7
+ readonly durationMs: number;
8
+ readonly fingerprint?: {
9
+ readonly env?: ReadonlyArray<string>;
10
+ readonly inputs?: Readonly<Record<string, {
11
+ readonly type: string;
12
+ }>>;
13
+ };
14
+ readonly outputs?: ReadonlyArray<string> | "notDownloaded";
15
+ };
16
+ readonly changes?: ReadonlyArray<{
17
+ readonly kind: "program" | "args" | "cwd";
18
+ } | {
19
+ readonly kind: "config";
20
+ readonly setting: string;
21
+ } | {
22
+ readonly kind: "env";
23
+ readonly name: string;
24
+ readonly change: string;
25
+ } | {
26
+ readonly kind: "file";
27
+ readonly path: string;
28
+ readonly change: string;
29
+ }>;
30
+ readonly changesPartial?: true;
31
+ readonly message?: string;
32
+ };
33
+ }
34
+ interface RunPlan {
35
+ readonly version: number;
36
+ readonly plan: Readonly<Record<string, {
37
+ readonly steps: ReadonlyArray<RunPlanStep>;
38
+ }>>;
39
+ }
40
+ /**
41
+ * Parses `vp run --dry-run --json`. Some `vp` builds print a banner or warning to stdout
42
+ * before the plan, so anything before the first line that starts with `{` is skipped.
43
+ */
44
+ export declare const parseRunPlan: (body: string) => RunPlan;
1
45
  export interface CacheLogLine {
2
46
  readonly level: "Info" | "Debug";
3
47
  readonly message: string;
@@ -9,7 +53,25 @@ export interface CacheLogLine {
9
53
  export declare const cacheLog: (body: string) => CacheLogLine[];
10
54
  /**
11
55
  * Cache hits whose run read no project file. fspy can miss every read of some native tools,
12
- * such as TypeScript 7's `tsc` on macOS (voidzero-dev/vite-task#587). Such a hit would replay
56
+ * such as TypeScript 7.0's `tsc` on macOS (voidzero-dev/vite-task#587). Such a hit would replay
13
57
  * a stale result forever, so it must not be trusted. Needs a `-vv` plan.
14
58
  */
15
59
  export declare const untracedHits: (body: string) => string[];
60
+ /** The first line of a config effect-ci writes. A file that starts with it is safe to replace or delete. */
61
+ export declare const synthesizedConfigMarker = "// Generated by effect-ci for one command. Safe to delete.";
62
+ /** The Vite+ task that runs an ad-hoc command. The same command always gets the same task, on any machine. */
63
+ export declare const commandTaskName: (command: string) => string;
64
+ /**
65
+ * A `vite.config.js` for `cwd` that declares `command` as the Vite+ task `name` and keeps the
66
+ * project's own config. Changes to `CLOUDFLARE_*`, `NODE_ENV` and `VITE_*` variables miss the
67
+ * cache; every other variable still reaches the command but doesn't change the cache key.
68
+ * Undefined when `cwd` has no package.json or node_modules, or has its own `vite.config.js`,
69
+ * which Vite+ would load instead.
70
+ */
71
+ export declare const synthesizedConfig: (cwd: string, name: string, command: string) => string | undefined;
72
+ /**
73
+ * The package.json script that `command` runs, such as `lint` for `pnpm lint` or `npm run lint`,
74
+ * when the script exists in `cwd`. Arguments or anything else make it an ordinary command.
75
+ */
76
+ export declare const packageScript: (cwd: string, command: string) => string | undefined;
77
+ export {};
package/dist/vite-plus.js CHANGED
@@ -1,8 +1,18 @@
1
1
  import {
2
2
  cacheLog,
3
+ commandTaskName,
4
+ packageScript,
5
+ parseRunPlan,
6
+ synthesizedConfig,
7
+ synthesizedConfigMarker,
3
8
  untracedHits
4
- } from "./chunks/chunk-WOG7K3QJ.js";
9
+ } from "./chunks/chunk-Q5USMIJ3.js";
5
10
  export {
6
11
  cacheLog,
12
+ commandTaskName,
13
+ packageScript,
14
+ parseRunPlan,
15
+ synthesizedConfig,
16
+ synthesizedConfigMarker,
7
17
  untracedHits
8
18
  };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "effect-ci",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Effect CI: typed CI workflows you run locally, in agents, or on your own Cloudflare host",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/ericclemmons/effect-ci-testbed.git",
9
+ "url": "git+https://github.com/ericclemmons/effect-ci.git",
10
10
  "directory": "packages/effect-ci"
11
11
  },
12
12
  "bin": {
@@ -82,7 +82,7 @@
82
82
  "@effect-ci-testbed/cloudflare-dynamic-worker": "0.0.0",
83
83
  "@types/node": "^26.6.3",
84
84
  "esbuild": "0.28.2",
85
- "typescript": "7.1.0-beta"
85
+ "typescript": "7.1.1-rc"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "node build.ts",