replicas-engine 0.1.46 → 0.1.48

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/src/index.js +28 -22
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -872,14 +872,14 @@ function parseWarmHookConfig(value) {
872
872
  if (!isRecord2(value)) {
873
873
  throw new Error('Invalid replicas.json: "warmHook" must be a string or object');
874
874
  }
875
- if (typeof value.content !== "string") {
876
- throw new Error('Invalid replicas.json: "warmHook.content" must be a string');
875
+ if (!Array.isArray(value.commands) || !value.commands.every((entry) => typeof entry === "string")) {
876
+ throw new Error('Invalid replicas.json: "warmHook.commands" must be an array of shell commands');
877
877
  }
878
878
  if (value.timeout !== void 0 && (typeof value.timeout !== "number" || value.timeout <= 0)) {
879
879
  throw new Error('Invalid replicas.json: "warmHook.timeout" must be a positive number');
880
880
  }
881
881
  return {
882
- content: value.content,
882
+ commands: value.commands,
883
883
  timeout: value.timeout
884
884
  };
885
885
  }
@@ -888,12 +888,12 @@ function resolveWarmHookConfig(value) {
888
888
  return null;
889
889
  }
890
890
  const parsed = parseWarmHookConfig(value);
891
- const content = (typeof parsed === "string" ? parsed : parsed.content).trim();
892
- if (!content) {
891
+ const commands = typeof parsed === "string" ? [parsed.trim()].filter(Boolean) : parsed.commands.map((command) => command.trim()).filter(Boolean);
892
+ if (commands.length === 0) {
893
893
  return null;
894
894
  }
895
895
  return {
896
- content,
896
+ commands,
897
897
  timeoutMs: typeof parsed === "string" ? void 0 : parsed.timeout
898
898
  };
899
899
  }
@@ -2867,8 +2867,12 @@ async function readRepoWarmHook(repoPath) {
2867
2867
  return null;
2868
2868
  }
2869
2869
  return resolveWarmHookConfig(parsed.warmHook);
2870
- } catch {
2871
- return null;
2870
+ } catch (error) {
2871
+ const nodeError = error;
2872
+ if (nodeError?.code === "ENOENT") {
2873
+ return null;
2874
+ }
2875
+ throw error;
2872
2876
  }
2873
2877
  }
2874
2878
  async function collectRepoWarmHooks() {
@@ -2882,7 +2886,7 @@ async function collectRepoWarmHooks() {
2882
2886
  collected.push({
2883
2887
  repoName: repo.name,
2884
2888
  repoPath: repo.path,
2885
- content: warmHook.content,
2889
+ commands: warmHook.commands,
2886
2890
  timeoutMs: warmHook.timeoutMs
2887
2891
  });
2888
2892
  }
@@ -2911,19 +2915,21 @@ async function runWarmHooks(params) {
2911
2915
  if (params.includeRepoHooks !== false) {
2912
2916
  const repoHooks = await collectRepoWarmHooks();
2913
2917
  for (const repoHook of repoHooks) {
2914
- const repoResult = await executeHookScript({
2915
- label: `repo-warm-hook:${repoHook.repoName}`,
2916
- cwd: repoHook.repoPath,
2917
- content: repoHook.content,
2918
- timeoutMs: repoHook.timeoutMs
2919
- });
2920
- outputBlocks.push(repoResult.output);
2921
- if (repoResult.exitCode !== 0) {
2922
- return {
2923
- exitCode: repoResult.exitCode,
2924
- output: outputBlocks.join("\n\n"),
2925
- timedOut: repoResult.timedOut
2926
- };
2918
+ for (const command of repoHook.commands) {
2919
+ const repoResult = await executeHookScript({
2920
+ label: `repo-warm-hook:${repoHook.repoName}`,
2921
+ cwd: repoHook.repoPath,
2922
+ content: command,
2923
+ timeoutMs: repoHook.timeoutMs
2924
+ });
2925
+ outputBlocks.push(repoResult.output);
2926
+ if (repoResult.exitCode !== 0) {
2927
+ return {
2928
+ exitCode: repoResult.exitCode,
2929
+ output: outputBlocks.join("\n\n"),
2930
+ timedOut: repoResult.timedOut
2931
+ };
2932
+ }
2927
2933
  }
2928
2934
  }
2929
2935
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",