@lumerahq/cli 0.18.1 → 0.18.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.
package/dist/index.js CHANGED
@@ -215,25 +215,25 @@ async function main() {
215
215
  switch (command) {
216
216
  // Resource commands
217
217
  case "plan":
218
- await import("./resources-E4XMWX7N.js").then((m) => m.plan(args.slice(1)));
218
+ await import("./resources-6SJR45CY.js").then((m) => m.plan(args.slice(1)));
219
219
  break;
220
220
  case "apply":
221
- await import("./resources-E4XMWX7N.js").then((m) => m.apply(args.slice(1)));
221
+ await import("./resources-6SJR45CY.js").then((m) => m.apply(args.slice(1)));
222
222
  break;
223
223
  case "pull":
224
- await import("./resources-E4XMWX7N.js").then((m) => m.pull(args.slice(1)));
224
+ await import("./resources-6SJR45CY.js").then((m) => m.pull(args.slice(1)));
225
225
  break;
226
226
  case "destroy":
227
- await import("./resources-E4XMWX7N.js").then((m) => m.destroy(args.slice(1)));
227
+ await import("./resources-6SJR45CY.js").then((m) => m.destroy(args.slice(1)));
228
228
  break;
229
229
  case "list":
230
- await import("./resources-E4XMWX7N.js").then((m) => m.list(args.slice(1)));
230
+ await import("./resources-6SJR45CY.js").then((m) => m.list(args.slice(1)));
231
231
  break;
232
232
  case "show":
233
- await import("./resources-E4XMWX7N.js").then((m) => m.show(args.slice(1)));
233
+ await import("./resources-6SJR45CY.js").then((m) => m.show(args.slice(1)));
234
234
  break;
235
235
  case "diff":
236
- await import("./resources-E4XMWX7N.js").then((m) => m.diff(args.slice(1)));
236
+ await import("./resources-6SJR45CY.js").then((m) => m.diff(args.slice(1)));
237
237
  break;
238
238
  // Development
239
239
  case "dev":
@@ -976,15 +976,27 @@ async function applyAutomations(api, localAutomations) {
976
976
  automationId = created.id;
977
977
  console.log(pc.green(" \u2713"), `${automation.name} (created)`);
978
978
  }
979
- if (automation.inputs?.presets) {
980
- await syncPresets(api, automationId, automation.inputs.presets);
979
+ const localPresets = automation.inputs?.presets;
980
+ if (localPresets) {
981
+ await syncPresets(api, automationId, localPresets);
981
982
  }
982
983
  if (automation.schedule) {
983
- await setSchedule(api, automationId, automation.schedule, automation.inputs?.presets || {});
984
+ await setSchedule(api, automationId, automation.schedule, localPresets || {});
984
985
  } else if (remote?.schedule) {
985
986
  await api.updateAutomation(automationId, { schedule: "", schedule_tz: "" });
986
987
  console.log(pc.dim(` Cleared schedule`));
987
988
  }
989
+ if (localPresets) {
990
+ const current = await api.getAutomation(automationId).catch(() => null);
991
+ if (current) {
992
+ await deleteStalePresets(
993
+ api,
994
+ automationId,
995
+ localPresets,
996
+ current.schedule_preset_id ? /* @__PURE__ */ new Set([current.schedule_preset_id]) : /* @__PURE__ */ new Set()
997
+ );
998
+ }
999
+ }
988
1000
  } catch (e) {
989
1001
  console.log(pc.red(" \u2717"), `${automation.name}: ${e}`);
990
1002
  errors++;
@@ -995,9 +1007,6 @@ async function applyAutomations(api, localAutomations) {
995
1007
  async function syncPresets(api, automationId, localPresets) {
996
1008
  const remotePresets = await api.listPresets(automationId);
997
1009
  const remoteByName = new Map(remotePresets.map((p) => [p.name, p]));
998
- const localPresetNames = new Set(
999
- Object.entries(localPresets).map(([key, preset]) => preset.label || key)
1000
- );
1001
1010
  for (const [presetKey, preset] of Object.entries(localPresets)) {
1002
1011
  const presetName = preset.label || presetKey;
1003
1012
  const existing = remoteByName.get(presetName);
@@ -1013,14 +1022,21 @@ async function syncPresets(api, automationId, localPresets) {
1013
1022
  console.log(pc.yellow(` \u26A0 Failed to sync preset ${presetName}: ${e}`));
1014
1023
  }
1015
1024
  }
1025
+ }
1026
+ async function deleteStalePresets(api, automationId, localPresets, preservePresetIds = /* @__PURE__ */ new Set()) {
1027
+ const remotePresets = await api.listPresets(automationId);
1028
+ const localPresetNames = new Set(
1029
+ Object.entries(localPresets).map(([key, preset]) => preset.label || key)
1030
+ );
1016
1031
  for (const remote of remotePresets) {
1017
- if (!localPresetNames.has(remote.name)) {
1018
- try {
1019
- await api.deletePreset(remote.id);
1020
- console.log(pc.dim(` Deleted preset: ${remote.name}`));
1021
- } catch (e) {
1022
- console.log(pc.yellow(` \u26A0 Failed to delete preset ${remote.name}: ${e}`));
1023
- }
1032
+ if (localPresetNames.has(remote.name) || preservePresetIds.has(remote.id)) {
1033
+ continue;
1034
+ }
1035
+ try {
1036
+ await api.deletePreset(remote.id);
1037
+ console.log(pc.dim(` Deleted preset: ${remote.name}`));
1038
+ } catch (e) {
1039
+ console.log(pc.yellow(` \u26A0 Failed to delete preset ${remote.name}: ${e}`));
1024
1040
  }
1025
1041
  }
1026
1042
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumerahq/cli",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "description": "CLI for building and deploying Lumera apps",
5
5
  "type": "module",
6
6
  "engines": {