@devicecloud.dev/dcd 3.3.4-beta.3 → 3.3.4-beta.4
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 +21 -14
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/dist/plan.js
CHANGED
|
@@ -37,14 +37,19 @@ 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
45
|
console.log('[getWorkspaceConfig] Input path:', input);
|
|
46
46
|
console.log('[getWorkspaceConfig] Unfiltered flow files:', unfilteredFlowFiles);
|
|
47
|
-
const
|
|
47
|
+
const possibleConfigPaths = [
|
|
48
|
+
path.join(input, 'config.yaml'),
|
|
49
|
+
path.join(input, 'config.yml'),
|
|
50
|
+
].map((p) => path.normalize(p));
|
|
51
|
+
console.log('[getWorkspaceConfig] Looking for config files:', possibleConfigPaths);
|
|
52
|
+
const configFilePath = unfilteredFlowFiles.find((file) => possibleConfigPaths.includes(path.normalize(file)));
|
|
48
53
|
console.log('[getWorkspaceConfig] Found config file path:', configFilePath);
|
|
49
54
|
const config = configFilePath
|
|
50
55
|
? (0, planMethods_1.readYamlFileAsJson)(configFilePath)
|
|
@@ -53,37 +58,39 @@ function getWorkspaceConfig(input, unfilteredFlowFiles) {
|
|
|
53
58
|
return config;
|
|
54
59
|
}
|
|
55
60
|
async function plan(input, includeTags, excludeTags, excludeFlows) {
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
const normalizedInput = path.normalize(input);
|
|
62
|
+
if (!fs.existsSync(normalizedInput)) {
|
|
63
|
+
throw new Error(`Flow path does not exist: ${path.resolve(normalizedInput)}`);
|
|
58
64
|
}
|
|
59
|
-
if (fs.lstatSync(
|
|
60
|
-
if (
|
|
65
|
+
if (fs.lstatSync(normalizedInput).isFile()) {
|
|
66
|
+
if (normalizedInput.endsWith('config.yaml') ||
|
|
67
|
+
normalizedInput.endsWith('config.yml')) {
|
|
61
68
|
throw new Error('If using config.yaml, pass the workspace folder path, not the config file');
|
|
62
69
|
}
|
|
63
|
-
const checkedDependancies = await checkDependencies(
|
|
70
|
+
const checkedDependancies = await checkDependencies(normalizedInput);
|
|
64
71
|
return {
|
|
65
|
-
flowsToRun: [
|
|
72
|
+
flowsToRun: [normalizedInput],
|
|
66
73
|
referencedFiles: [...new Set(checkedDependancies)],
|
|
67
74
|
totalFlowFiles: 1,
|
|
68
75
|
};
|
|
69
76
|
}
|
|
70
|
-
let unfilteredFlowFiles = await (0, planMethods_1.readDirectory)(
|
|
77
|
+
let unfilteredFlowFiles = await (0, planMethods_1.readDirectory)(normalizedInput, planMethods_1.isFlowFile);
|
|
71
78
|
if (unfilteredFlowFiles.length === 0) {
|
|
72
|
-
throw new Error(`Flow directory does not contain any Flow files: ${path.resolve(
|
|
79
|
+
throw new Error(`Flow directory does not contain any Flow files: ${path.resolve(normalizedInput)}`);
|
|
73
80
|
}
|
|
74
81
|
unfilteredFlowFiles = filterFlowFiles(unfilteredFlowFiles, excludeFlows);
|
|
75
|
-
const workspaceConfig = getWorkspaceConfig(
|
|
82
|
+
const workspaceConfig = getWorkspaceConfig(normalizedInput, unfilteredFlowFiles);
|
|
76
83
|
if (workspaceConfig.flows) {
|
|
77
84
|
const globs = workspaceConfig.flows.map((glob) => glob);
|
|
78
85
|
const matchedFiles = await (0, glob_1.glob)(globs, {
|
|
79
|
-
cwd:
|
|
86
|
+
cwd: normalizedInput,
|
|
80
87
|
nodir: true,
|
|
81
88
|
});
|
|
82
89
|
// overwrite the list of files with the globbed ones
|
|
83
90
|
unfilteredFlowFiles = matchedFiles
|
|
84
91
|
.filter((file) => file !== 'config.yaml' &&
|
|
85
92
|
(file.endsWith('.yaml') || file.endsWith('.yml')))
|
|
86
|
-
.map((file) => path.resolve(
|
|
93
|
+
.map((file) => path.resolve(normalizedInput, file));
|
|
87
94
|
}
|
|
88
95
|
else {
|
|
89
96
|
// workspace config has no flows, so we need to remove the config file from the test list
|
|
@@ -92,7 +99,7 @@ async function plan(input, includeTags, excludeTags, excludeFlows) {
|
|
|
92
99
|
if (unfilteredFlowFiles.length === 0) {
|
|
93
100
|
const error = workspaceConfig.flows
|
|
94
101
|
? 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(
|
|
102
|
+
: new Error(`Workspace does not contain any Flows: ${path.resolve(normalizedInput)}`);
|
|
96
103
|
throw error;
|
|
97
104
|
}
|
|
98
105
|
const configPerFlowFile =
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED