@devicecloud.dev/dcd 4.1.1 → 4.1.2-beta.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.
@@ -308,7 +308,7 @@ class Cloud extends core_1.Command {
308
308
  if (debug) {
309
309
  this.log('DEBUG: Generating execution plan...');
310
310
  }
311
- executionPlan = await (0, plan_1.plan)(flowFile, includeTags.flat(), excludeTags.flat(), excludeFlows.flat(), configFile);
311
+ executionPlan = await (0, plan_1.plan)(flowFile, includeTags.flat(), excludeTags.flat(), excludeFlows.flat(), configFile, debug);
312
312
  if (debug) {
313
313
  this.log(`DEBUG: Execution plan generated`);
314
314
  this.log(`DEBUG: Total flow files: ${executionPlan.totalFlowFiles}`);
package/dist/plan.d.ts CHANGED
@@ -35,5 +35,5 @@ interface IFlowSequence {
35
35
  continueOnFailure?: boolean;
36
36
  flows: string[];
37
37
  }
38
- export declare function plan(input: string, includeTags: string[], excludeTags: string[], excludeFlows?: string[], configFile?: string): Promise<IExecutionPlan>;
38
+ export declare function plan(input: string, includeTags: string[], excludeTags: string[], excludeFlows?: string[], configFile?: string, debug?: boolean): Promise<IExecutionPlan>;
39
39
  export {};
package/dist/plan.js CHANGED
@@ -64,7 +64,7 @@ function extractDeviceCloudOverrides(config) {
64
64
  }
65
65
  return overrides;
66
66
  }
67
- async function plan(input, includeTags, excludeTags, excludeFlows, configFile) {
67
+ async function plan(input, includeTags, excludeTags, excludeFlows, configFile, debug = false) {
68
68
  const normalizedInput = path.normalize(input);
69
69
  const flowMetadata = {};
70
70
  if (!fs.existsSync(normalizedInput)) {
@@ -189,12 +189,30 @@ async function plan(input, includeTags, excludeTags, excludeFlows, configFile) {
189
189
  const config = configPerFlowFile[filePath];
190
190
  const name = config?.name || path.parse(filePath).name;
191
191
  acc[name] = filePath;
192
+ if (debug) {
193
+ console.log(`[DEBUG] Flow name mapping: "${name}" -> ${filePath}`);
194
+ }
192
195
  return acc;
193
196
  }, {});
197
+ if (debug && workspaceConfig.executionOrder?.flowsOrder) {
198
+ console.log('[DEBUG] executionOrder.flowsOrder:', workspaceConfig.executionOrder.flowsOrder);
199
+ console.log('[DEBUG] Available flow names:', Object.keys(pathsByName));
200
+ }
194
201
  const flowsToRunInSequence = workspaceConfig.executionOrder?.flowsOrder
195
- ?.map((flowOrder) => flowOrder.replace('.yaml', '').replace('.yml', '')) // support case where ext is left on
196
- ?.map((flowOrder) => (0, planMethods_1.getFlowsToRunInSequence)(pathsByName, [flowOrder]))
202
+ ?.map((flowOrder) => {
203
+ // Strip .yaml/.yml extension only from the END of the string
204
+ // This supports flowsOrder entries like "my_test.yml" matching "my_test"
205
+ // while preserving extensions in the middle like "(file.yml) Name"
206
+ const normalizedFlowOrder = flowOrder.replace(/\.ya?ml$/i, '');
207
+ if (debug && flowOrder !== normalizedFlowOrder) {
208
+ console.log(`[DEBUG] Stripping trailing extension: "${flowOrder}" -> "${normalizedFlowOrder}"`);
209
+ }
210
+ return (0, planMethods_1.getFlowsToRunInSequence)(pathsByName, [normalizedFlowOrder], debug);
211
+ })
197
212
  .flat() || [];
213
+ if (debug) {
214
+ console.log(`[DEBUG] Sequential flows resolved: ${flowsToRunInSequence.length} flow(s)`);
215
+ }
198
216
  const normalFlows = allFlows
199
217
  .filter((flow) => !flowsToRunInSequence.includes(flow))
200
218
  .sort((a, b) => a.localeCompare(b));
@@ -1,6 +1,6 @@
1
1
  export declare function getFlowsToRunInSequence(paths: {
2
2
  [key: string]: string;
3
- }, flowOrder: string[]): string[];
3
+ }, flowOrder: string[], debug?: boolean): string[];
4
4
  export declare function isFlowFile(filePath: string): boolean;
5
5
  export declare const readYamlFileAsJson: (filePath: string) => unknown;
6
6
  export declare const readTestYamlFileAsJson: (filePath: string) => {
@@ -9,25 +9,50 @@ const yaml = require("js-yaml");
9
9
  const fs = require("node:fs");
10
10
  const path = require("node:path");
11
11
  const commandsThatRequireFiles = new Set(['addMedia', 'runFlow', 'runScript']);
12
- function getFlowsToRunInSequence(paths, flowOrder) {
13
- if (flowOrder.length === 0)
12
+ function getFlowsToRunInSequence(paths, flowOrder, debug = false) {
13
+ if (flowOrder.length === 0) {
14
+ if (debug) {
15
+ console.log('[DEBUG] getFlowsToRunInSequence: flowOrder is empty, returning []');
16
+ }
14
17
  return [];
18
+ }
15
19
  const orderSet = new Set(flowOrder);
16
- const namesInOrder = Object.keys(paths).filter((key) => orderSet.has(key));
17
- if (namesInOrder.length === 0)
20
+ const availableNames = Object.keys(paths);
21
+ if (debug) {
22
+ console.log(`[DEBUG] getFlowsToRunInSequence: Looking for flows in order: [${[...orderSet].join(', ')}]`);
23
+ console.log(`[DEBUG] getFlowsToRunInSequence: Available flow names: [${availableNames.join(', ')}]`);
24
+ }
25
+ const namesInOrder = availableNames.filter((key) => orderSet.has(key));
26
+ if (debug) {
27
+ console.log(`[DEBUG] getFlowsToRunInSequence: Matched ${namesInOrder.length} flow(s): [${namesInOrder.join(', ')}]`);
28
+ }
29
+ if (namesInOrder.length === 0) {
30
+ const notFound = [...orderSet].filter((item) => !availableNames.includes(item));
31
+ if (debug) {
32
+ console.log(`[DEBUG] getFlowsToRunInSequence: No flows matched, not found: [${notFound.join(', ')}]`);
33
+ }
18
34
  return [];
35
+ }
19
36
  const result = [...orderSet].filter((item) => namesInOrder.includes(item));
20
37
  if (result.length === 0) {
21
- throw new Error(`Could not find flows needed for execution in order: ${[...orderSet]
22
- .filter((item) => !namesInOrder.includes(item))
23
- .join(', ')}`);
38
+ const notFound = [...orderSet].filter((item) => !namesInOrder.includes(item));
39
+ throw new Error(`Could not find flows needed for execution in order: ${notFound.join(', ')}\n\nAvailable flow names:\n${availableNames.join('\n')}`);
24
40
  }
25
41
  else if (flowOrder
26
42
  .slice(0, result.length)
27
43
  .every((value, index) => value === result[index])) {
28
- return result.map((item) => paths[item]);
44
+ const resolvedPaths = result.map((item) => paths[item]);
45
+ if (debug) {
46
+ console.log(`[DEBUG] getFlowsToRunInSequence: Order matches, returning ${resolvedPaths.length} path(s)`);
47
+ }
48
+ return resolvedPaths;
29
49
  }
30
50
  else {
51
+ if (debug) {
52
+ console.log('[DEBUG] getFlowsToRunInSequence: Order does not match, returning []');
53
+ console.log(`[DEBUG] Expected order: [${flowOrder.slice(0, result.length).join(', ')}]`);
54
+ console.log(`[DEBUG] Actual result: [${result.join(', ')}]`);
55
+ }
31
56
  return [];
32
57
  }
33
58
  }
@@ -579,5 +579,5 @@
579
579
  ]
580
580
  }
581
581
  },
582
- "version": "4.1.1"
582
+ "version": "4.1.2-beta.1"
583
583
  }
package/package.json CHANGED
@@ -72,7 +72,7 @@
72
72
  "type": "git",
73
73
  "url": "https://devicecloud.dev"
74
74
  },
75
- "version": "4.1.1",
75
+ "version": "4.1.2-beta.1",
76
76
  "bugs": {
77
77
  "url": "https://discord.gg/gm3mJwcNw8"
78
78
  },