@devicecloud.dev/dcd 3.3.4-beta.3 → 3.3.5
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/plan.js +20 -20
- package/dist/planMethods.js +0 -18
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/dist/plan.js
CHANGED
|
@@ -37,53 +37,55 @@ async function checkDependencies(input) {
|
|
|
37
37
|
}
|
|
38
38
|
function filterFlowFiles(unfilteredFlowFiles, excludeFlows) {
|
|
39
39
|
if (excludeFlows) {
|
|
40
|
-
return unfilteredFlowFiles.filter((file) => !excludeFlows.some((flow) => file.startsWith(path.resolve(flow))));
|
|
40
|
+
return unfilteredFlowFiles.filter((file) => !excludeFlows.some((flow) => path.normalize(file).startsWith(path.normalize(path.resolve(flow)))));
|
|
41
41
|
}
|
|
42
42
|
return unfilteredFlowFiles;
|
|
43
43
|
}
|
|
44
44
|
function getWorkspaceConfig(input, unfilteredFlowFiles) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const possibleConfigPaths = [
|
|
46
|
+
path.join(input, 'config.yaml'),
|
|
47
|
+
path.join(input, 'config.yml'),
|
|
48
|
+
].map((p) => path.normalize(p));
|
|
49
|
+
const configFilePath = unfilteredFlowFiles.find((file) => possibleConfigPaths.includes(path.normalize(file)));
|
|
49
50
|
const config = configFilePath
|
|
50
51
|
? (0, planMethods_1.readYamlFileAsJson)(configFilePath)
|
|
51
52
|
: {};
|
|
52
|
-
console.log('[getWorkspaceConfig] Parsed config:', config);
|
|
53
53
|
return config;
|
|
54
54
|
}
|
|
55
55
|
async function plan(input, includeTags, excludeTags, excludeFlows) {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const normalizedInput = path.normalize(input);
|
|
57
|
+
if (!fs.existsSync(normalizedInput)) {
|
|
58
|
+
throw new Error(`Flow path does not exist: ${path.resolve(normalizedInput)}`);
|
|
58
59
|
}
|
|
59
|
-
if (fs.lstatSync(
|
|
60
|
-
if (
|
|
60
|
+
if (fs.lstatSync(normalizedInput).isFile()) {
|
|
61
|
+
if (normalizedInput.endsWith('config.yaml') ||
|
|
62
|
+
normalizedInput.endsWith('config.yml')) {
|
|
61
63
|
throw new Error('If using config.yaml, pass the workspace folder path, not the config file');
|
|
62
64
|
}
|
|
63
|
-
const checkedDependancies = await checkDependencies(
|
|
65
|
+
const checkedDependancies = await checkDependencies(normalizedInput);
|
|
64
66
|
return {
|
|
65
|
-
flowsToRun: [
|
|
67
|
+
flowsToRun: [normalizedInput],
|
|
66
68
|
referencedFiles: [...new Set(checkedDependancies)],
|
|
67
69
|
totalFlowFiles: 1,
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
|
-
let unfilteredFlowFiles = await (0, planMethods_1.readDirectory)(
|
|
72
|
+
let unfilteredFlowFiles = await (0, planMethods_1.readDirectory)(normalizedInput, planMethods_1.isFlowFile);
|
|
71
73
|
if (unfilteredFlowFiles.length === 0) {
|
|
72
|
-
throw new Error(`Flow directory does not contain any Flow files: ${path.resolve(
|
|
74
|
+
throw new Error(`Flow directory does not contain any Flow files: ${path.resolve(normalizedInput)}`);
|
|
73
75
|
}
|
|
74
76
|
unfilteredFlowFiles = filterFlowFiles(unfilteredFlowFiles, excludeFlows);
|
|
75
|
-
const workspaceConfig = getWorkspaceConfig(
|
|
77
|
+
const workspaceConfig = getWorkspaceConfig(normalizedInput, unfilteredFlowFiles);
|
|
76
78
|
if (workspaceConfig.flows) {
|
|
77
79
|
const globs = workspaceConfig.flows.map((glob) => glob);
|
|
78
80
|
const matchedFiles = await (0, glob_1.glob)(globs, {
|
|
79
|
-
cwd:
|
|
81
|
+
cwd: normalizedInput,
|
|
80
82
|
nodir: true,
|
|
81
83
|
});
|
|
82
84
|
// overwrite the list of files with the globbed ones
|
|
83
85
|
unfilteredFlowFiles = matchedFiles
|
|
84
86
|
.filter((file) => file !== 'config.yaml' &&
|
|
85
87
|
(file.endsWith('.yaml') || file.endsWith('.yml')))
|
|
86
|
-
.map((file) => path.resolve(
|
|
88
|
+
.map((file) => path.resolve(normalizedInput, file));
|
|
87
89
|
}
|
|
88
90
|
else {
|
|
89
91
|
// workspace config has no flows, so we need to remove the config file from the test list
|
|
@@ -92,7 +94,7 @@ async function plan(input, includeTags, excludeTags, excludeFlows) {
|
|
|
92
94
|
if (unfilteredFlowFiles.length === 0) {
|
|
93
95
|
const error = workspaceConfig.flows
|
|
94
96
|
? new Error(`Flow inclusion pattern(s) did not match any Flow files:\n${workspaceConfig.flows.join('\n')}`)
|
|
95
|
-
: new Error(`Workspace does not contain any Flows: ${path.resolve(
|
|
97
|
+
: new Error(`Workspace does not contain any Flows: ${path.resolve(normalizedInput)}`);
|
|
96
98
|
throw error;
|
|
97
99
|
}
|
|
98
100
|
const configPerFlowFile =
|
|
@@ -103,12 +105,10 @@ async function plan(input, includeTags, excludeTags, excludeFlows) {
|
|
|
103
105
|
return acc;
|
|
104
106
|
}, {});
|
|
105
107
|
const allFiles = await Promise.all(unfilteredFlowFiles.map((filePath) => checkDependencies(filePath))).then((results) => [...new Set(results.flat())]);
|
|
106
|
-
console.log('Found include tags in workspace config', workspaceConfig.includeTags);
|
|
107
108
|
const allIncludeTags = [
|
|
108
109
|
...includeTags,
|
|
109
110
|
...(workspaceConfig.includeTags || []),
|
|
110
111
|
];
|
|
111
|
-
console.log('Found exclude tags in workspace config', workspaceConfig.excludeTags);
|
|
112
112
|
const allExcludeTags = [
|
|
113
113
|
...excludeTags,
|
|
114
114
|
...(workspaceConfig.excludeTags || []),
|
package/dist/planMethods.js
CHANGED
|
@@ -37,38 +37,20 @@ function isFlowFile(filePath) {
|
|
|
37
37
|
const readYamlFileAsJson = (filePath) => {
|
|
38
38
|
try {
|
|
39
39
|
const normalizedPath = path.normalize(filePath);
|
|
40
|
-
console.log('[YAML Parser] Reading file:', normalizedPath);
|
|
41
40
|
const yamlText = fs.readFileSync(normalizedPath, 'utf8');
|
|
42
|
-
console.log('[YAML Parser] File contents:', '\n' + yamlText);
|
|
43
41
|
const result = yaml.load(yamlText);
|
|
44
|
-
console.log('[YAML Parser] Parsed result:', JSON.stringify(result, null, 2));
|
|
45
42
|
// Ensure includeTags and excludeTags are always arrays if present
|
|
46
43
|
if (result && typeof result === 'object') {
|
|
47
44
|
if ('includeTags' in result && !Array.isArray(result.includeTags)) {
|
|
48
|
-
console.log('[YAML Parser] Converting includeTags to array:', {
|
|
49
|
-
from: result.includeTags,
|
|
50
|
-
to: result.includeTags ? [result.includeTags] : [],
|
|
51
|
-
});
|
|
52
45
|
result.includeTags = result.includeTags ? [result.includeTags] : [];
|
|
53
46
|
}
|
|
54
47
|
if ('excludeTags' in result && !Array.isArray(result.excludeTags)) {
|
|
55
|
-
console.log('[YAML Parser] Converting excludeTags to array:', {
|
|
56
|
-
from: result.excludeTags,
|
|
57
|
-
to: result.excludeTags ? [result.excludeTags] : [],
|
|
58
|
-
});
|
|
59
48
|
result.excludeTags = result.excludeTags ? [result.excludeTags] : [];
|
|
60
49
|
}
|
|
61
50
|
}
|
|
62
51
|
return result;
|
|
63
52
|
}
|
|
64
53
|
catch (error) {
|
|
65
|
-
console.error('[YAML Parser] Error parsing file:', {
|
|
66
|
-
filePath,
|
|
67
|
-
normalizedPath: path.normalize(filePath),
|
|
68
|
-
errorName: error instanceof Error ? error.name : 'Unknown',
|
|
69
|
-
errorMessage: error instanceof Error ? error.message : String(error),
|
|
70
|
-
errorStack: error instanceof Error ? error.stack : undefined,
|
|
71
|
-
});
|
|
72
54
|
throw new Error(`Error parsing YAML file ${filePath}: ${error}`);
|
|
73
55
|
}
|
|
74
56
|
};
|
package/oclif.manifest.json
CHANGED