@rudderhq/cli 0.2.6-canary.1 → 0.2.6-canary.10

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/dist/index.js CHANGED
@@ -1768,7 +1768,7 @@ var init_approval = __esm({
1768
1768
 
1769
1769
  // ../packages/shared/dist/validators/automation.js
1770
1770
  import { z as z19 } from "zod";
1771
- var automationBodySchema, requireChatConversationForChatOutput, createAutomationSchema, updateAutomationSchema, baseTriggerSchema, createAutomationTriggerSchema, updateAutomationTriggerSchema, runAutomationSchema, rotateAutomationTriggerSecretSchema;
1771
+ var automationBodySchema, updateAutomationSchema, baseTriggerSchema, createAutomationTriggerSchema, updateAutomationTriggerSchema, runAutomationSchema, rotateAutomationTriggerSecretSchema;
1772
1772
  var init_automation = __esm({
1773
1773
  "../packages/shared/dist/validators/automation.js"() {
1774
1774
  "use strict";
@@ -1788,17 +1788,7 @@ var init_automation = __esm({
1788
1788
  chatConversationId: z19.string().uuid().optional().nullable().default(null),
1789
1789
  allowAssigneeChatMismatch: z19.boolean().optional().default(false)
1790
1790
  });
1791
- requireChatConversationForChatOutput = (value, ctx) => {
1792
- if (value.outputMode === "chat_output" && !value.chatConversationId) {
1793
- ctx.addIssue({
1794
- code: z19.ZodIssueCode.custom,
1795
- message: "chatConversationId is required when outputMode is chat_output",
1796
- path: ["chatConversationId"]
1797
- });
1798
- }
1799
- };
1800
- createAutomationSchema = automationBodySchema.superRefine(requireChatConversationForChatOutput);
1801
- updateAutomationSchema = automationBodySchema.partial().superRefine(requireChatConversationForChatOutput);
1791
+ updateAutomationSchema = automationBodySchema.partial();
1802
1792
  baseTriggerSchema = z19.object({
1803
1793
  label: z19.string().trim().max(120).optional().nullable(),
1804
1794
  enabled: z19.boolean().optional().default(true)
@@ -3797,6 +3787,43 @@ async function ensureRuntimeInstalled(options) {
3797
3787
  const spawnSyncImpl = options.spawnSyncImpl ?? spawnSync;
3798
3788
  const result = runNpmRuntimeInstall(spawnSyncImpl, cacheDir, packageSpec);
3799
3789
  const output = collectSpawnOutput(result);
3790
+ if (result.status !== 0 && packageVersion !== "latest" && isVersionNotFoundError(output)) {
3791
+ const fallbackVersion = "latest";
3792
+ const fallbackCacheDir = resolveRuntimeCacheDir(fallbackVersion, options.homeDir);
3793
+ const fallbackSpec = resolveRuntimePackageSpec(fallbackVersion, packageName);
3794
+ if (await isRuntimeCacheHit({ cacheDir: fallbackCacheDir, version: fallbackVersion, packageName })) {
3795
+ await touchRuntimeInstallMetadata(fallbackCacheDir);
3796
+ return {
3797
+ status: "hit",
3798
+ cacheDir: fallbackCacheDir,
3799
+ packageSpec: fallbackSpec,
3800
+ command: `npm install --prefix ${fallbackCacheDir} --omit=dev --no-audit --no-fund ${fallbackSpec}`,
3801
+ output: ""
3802
+ };
3803
+ }
3804
+ await mkdir(fallbackCacheDir, { recursive: true });
3805
+ await writeFile(path6.join(fallbackCacheDir, "package.json"), `${JSON.stringify({ private: true, type: "module" }, null, 2)}
3806
+ `, "utf8");
3807
+ const fallbackResult = runNpmRuntimeInstall(spawnSyncImpl, fallbackCacheDir, fallbackSpec);
3808
+ const fallbackOutput = collectSpawnOutput(fallbackResult);
3809
+ if (fallbackResult.status === 0) {
3810
+ const fallbackMetadata = {
3811
+ version: 1,
3812
+ packageName,
3813
+ packageVersion: fallbackVersion,
3814
+ installedAt: (/* @__PURE__ */ new Date()).toISOString(),
3815
+ lastUsedAt: (/* @__PURE__ */ new Date()).toISOString()
3816
+ };
3817
+ await writeRuntimeInstallMetadata(fallbackCacheDir, fallbackMetadata);
3818
+ return {
3819
+ status: "installed",
3820
+ cacheDir: fallbackCacheDir,
3821
+ packageSpec: fallbackSpec,
3822
+ command: `npm install --prefix ${fallbackCacheDir} --omit=dev --no-audit --no-fund ${fallbackSpec}`,
3823
+ output: fallbackOutput
3824
+ };
3825
+ }
3826
+ }
3800
3827
  if (result.status !== 0) {
3801
3828
  throw new RuntimeInstallError(
3802
3829
  `Rudder runtime installation failed. Re-run manually: ${command}`,
@@ -3840,6 +3867,10 @@ function runNpmRuntimeInstall(spawnSyncImpl, cacheDir, packageSpec) {
3840
3867
  function collectSpawnOutput(result) {
3841
3868
  return [result.stdout, result.stderr, result.error instanceof Error ? result.error.message : null].filter((value) => typeof value === "string" && value.trim().length > 0).join("\n").trim();
3842
3869
  }
3870
+ function isVersionNotFoundError(output) {
3871
+ const normalized = output.toLowerCase();
3872
+ return normalized.includes("enoent") || normalized.includes("etarget") || normalized.includes("no matching version found");
3873
+ }
3843
3874
  async function maybePruneRuntimeCache(options) {
3844
3875
  if (!options.enabled) return null;
3845
3876
  return pruneRuntimeCache({