@lumerahq/cli 0.30.0 → 0.30.1-dev.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/dist/index.js CHANGED
@@ -240,25 +240,25 @@ async function main() {
240
240
  switch (command) {
241
241
  // Resource commands
242
242
  case "plan":
243
- await import("./resources-5YWEX6DG.js").then((m) => m.plan(args.slice(1)));
243
+ await import("./resources-3JZS5SVJ.js").then((m) => m.plan(args.slice(1)));
244
244
  break;
245
245
  case "apply":
246
- await import("./resources-5YWEX6DG.js").then((m) => m.apply(args.slice(1)));
246
+ await import("./resources-3JZS5SVJ.js").then((m) => m.apply(args.slice(1)));
247
247
  break;
248
248
  case "pull":
249
- await import("./resources-5YWEX6DG.js").then((m) => m.pull(args.slice(1)));
249
+ await import("./resources-3JZS5SVJ.js").then((m) => m.pull(args.slice(1)));
250
250
  break;
251
251
  case "destroy":
252
- await import("./resources-5YWEX6DG.js").then((m) => m.destroy(args.slice(1)));
252
+ await import("./resources-3JZS5SVJ.js").then((m) => m.destroy(args.slice(1)));
253
253
  break;
254
254
  case "list":
255
- await import("./resources-5YWEX6DG.js").then((m) => m.list(args.slice(1)));
255
+ await import("./resources-3JZS5SVJ.js").then((m) => m.list(args.slice(1)));
256
256
  break;
257
257
  case "show":
258
- await import("./resources-5YWEX6DG.js").then((m) => m.show(args.slice(1)));
258
+ await import("./resources-3JZS5SVJ.js").then((m) => m.show(args.slice(1)));
259
259
  break;
260
260
  case "diff":
261
- await import("./resources-5YWEX6DG.js").then((m) => m.diff(args.slice(1)));
261
+ await import("./resources-3JZS5SVJ.js").then((m) => m.diff(args.slice(1)));
262
262
  break;
263
263
  // Development
264
264
  case "dev":
@@ -2177,6 +2177,7 @@ async function applyAutomations(api, localAutomations, projectId) {
2177
2177
  const remoteByExternalId = new Map(remoteAutomations.filter((a) => a.external_id).map((a) => [a.external_id, a]));
2178
2178
  for (const { automation, code } of localAutomations) {
2179
2179
  const remote = remoteByExternalId.get(automation.external_id);
2180
+ const appliedAction = remote ? "updated" : "created";
2180
2181
  const payload = {
2181
2182
  external_id: automation.external_id,
2182
2183
  name: automation.name,
@@ -2194,11 +2195,9 @@ async function applyAutomations(api, localAutomations, projectId) {
2194
2195
  if (remote) {
2195
2196
  await api.updateAutomation(remote.id, payload);
2196
2197
  automationId = remote.id;
2197
- console.log(pc2.green(" \u2713"), `${automation.name} (updated)`);
2198
2198
  } else {
2199
2199
  const created = await api.createAutomation(payload);
2200
2200
  automationId = created.id;
2201
- console.log(pc2.green(" \u2713"), `${automation.name} (created)`);
2202
2201
  }
2203
2202
  const localPresets = automation.inputs?.presets;
2204
2203
  if (localPresets) {
@@ -2221,6 +2220,7 @@ async function applyAutomations(api, localAutomations, projectId) {
2221
2220
  );
2222
2221
  }
2223
2222
  }
2223
+ console.log(pc2.green(" \u2713"), `${automation.name} (${appliedAction})`);
2224
2224
  } catch (e) {
2225
2225
  console.log(pc2.red(" \u2717"), `${automation.name}: ${e}`);
2226
2226
  errors++;
@@ -2234,16 +2234,20 @@ async function syncPresets(api, automationId, localPresets) {
2234
2234
  for (const [presetKey, preset] of Object.entries(localPresets)) {
2235
2235
  const presetName = preset.label || presetKey;
2236
2236
  const existing = remoteByName.get(presetName);
2237
- try {
2238
- if (existing) {
2237
+ if (existing) {
2238
+ try {
2239
2239
  await api.updatePreset(existing.id, { name: presetName, inputs: preset.inputs });
2240
2240
  console.log(pc2.dim(` Updated preset: ${presetName}`));
2241
- } else {
2241
+ } catch (e) {
2242
+ throw new Error(`Failed to update preset '${presetName}': ${String(e)}`);
2243
+ }
2244
+ } else {
2245
+ try {
2242
2246
  await api.createPreset(automationId, { name: presetName, inputs: preset.inputs });
2243
2247
  console.log(pc2.dim(` Created preset: ${presetName}`));
2248
+ } catch (e) {
2249
+ throw new Error(`Failed to create preset '${presetName}': ${String(e)}`);
2244
2250
  }
2245
- } catch (e) {
2246
- console.log(pc2.yellow(` \u26A0 Failed to sync preset ${presetName}: ${e}`));
2247
2251
  }
2248
2252
  }
2249
2253
  }
@@ -2260,7 +2264,7 @@ async function deleteStalePresets(api, automationId, localPresets, preservePrese
2260
2264
  await api.deletePreset(remote.id);
2261
2265
  console.log(pc2.dim(` Deleted preset: ${remote.name}`));
2262
2266
  } catch (e) {
2263
- console.log(pc2.yellow(` \u26A0 Failed to delete preset ${remote.name}: ${e}`));
2267
+ throw new Error(`Failed to delete preset '${remote.name}': ${String(e)}`);
2264
2268
  }
2265
2269
  }
2266
2270
  }
@@ -2269,19 +2273,27 @@ async function setSchedule(api, automationId, schedule, localPresets) {
2269
2273
  const remotePresets = await api.listPresets(automationId);
2270
2274
  const preset = remotePresets.find((p) => p.name === presetName);
2271
2275
  if (!preset) {
2272
- console.log(pc2.yellow(` \u26A0 Schedule preset '${schedule.preset}' not found, skipping schedule`));
2273
- return;
2276
+ throw new Error(`Schedule preset '${presetName}' not found`);
2274
2277
  }
2278
+ const expectedSchedule = {
2279
+ schedule: schedule.cron,
2280
+ schedule_tz: schedule.timezone || "UTC",
2281
+ schedule_preset_id: preset.id
2282
+ };
2283
+ await api.updateAutomation(automationId, expectedSchedule);
2284
+ let persisted;
2275
2285
  try {
2276
- await api.updateAutomation(automationId, {
2277
- schedule: schedule.cron,
2278
- schedule_tz: schedule.timezone || "UTC",
2279
- schedule_preset_id: preset.id
2280
- });
2281
- console.log(pc2.dim(` Set schedule: ${schedule.cron}`));
2286
+ persisted = await api.getAutomation(automationId);
2282
2287
  } catch (e) {
2283
- console.log(pc2.yellow(` \u26A0 Failed to set schedule: ${e}`));
2288
+ throw new Error(`Failed to verify persisted schedule: ${String(e)}`);
2289
+ }
2290
+ const mismatches = Object.keys(expectedSchedule).filter((field) => persisted[field] !== expectedSchedule[field]).map(
2291
+ (field) => `${field} expected ${JSON.stringify(expectedSchedule[field])}, got ${JSON.stringify(persisted[field])}`
2292
+ );
2293
+ if (mismatches.length > 0) {
2294
+ throw new Error(`Schedule update was not persisted: ${mismatches.join("; ")}`);
2284
2295
  }
2296
+ console.log(pc2.dim(` Set schedule: ${schedule.cron}`));
2285
2297
  }
2286
2298
  async function applyHooks(api, localHooks, collections, projectId) {
2287
2299
  let errors = 0;
@@ -4519,6 +4531,7 @@ async function diff(args) {
4519
4531
  export {
4520
4532
  apply,
4521
4533
  applyAgents,
4534
+ applyAutomations,
4522
4535
  applyCollections,
4523
4536
  applySkills,
4524
4537
  convertCollectionToApiFormat,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumerahq/cli",
3
- "version": "0.30.0",
3
+ "version": "0.30.1-dev.1",
4
4
  "description": "CLI for building and deploying Lumera apps",
5
5
  "type": "module",
6
6
  "engines": {