@darkhorseprojects/circuitry 0.3.5 → 0.3.7
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/cli.js +10 -20
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -167,12 +167,6 @@ var parseYamlData = (text) => {
|
|
|
167
167
|
${message}`);
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
-
var stringifyYamlData = (value) => YAML2.stringify(value, {
|
|
171
|
-
aliasDuplicateObjects: false,
|
|
172
|
-
defaultKeyType: "PLAIN",
|
|
173
|
-
defaultStringType: "QUOTE_DOUBLE",
|
|
174
|
-
doubleQuotedAsJSON: true
|
|
175
|
-
});
|
|
176
170
|
var parseCircuitryYaml = (text, standard = {}, options = {}) => {
|
|
177
171
|
const graph = parseYamlData(text);
|
|
178
172
|
if (!graph || typeof graph !== "object" || Array.isArray(graph)) {
|
|
@@ -253,28 +247,24 @@ var loadCircuitryGraphFile = async (filename2 = defaultFilename, standard, stack
|
|
|
253
247
|
// src/cli.ts
|
|
254
248
|
var [, , command, filename] = process.argv;
|
|
255
249
|
var usage = () => {
|
|
256
|
-
console.error("usage: circuitry <check|
|
|
250
|
+
console.error("usage: circuitry <check|parse> <file.yaml>");
|
|
257
251
|
process.exit(2);
|
|
258
252
|
};
|
|
259
253
|
if (!command || !filename) usage();
|
|
260
254
|
try {
|
|
261
255
|
if (command === "parse") {
|
|
262
256
|
const text = await readFile2(filename, "utf8");
|
|
263
|
-
process.stdout.write(
|
|
264
|
-
} else {
|
|
257
|
+
process.stdout.write(JSON.stringify(parseYamlData(text)));
|
|
258
|
+
} else if (command === "check") {
|
|
265
259
|
const loaded = await loadCircuitryGraphFile(filename);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
process.exit(1);
|
|
271
|
-
}
|
|
272
|
-
console.log(`ok: ${loaded.filename}`);
|
|
273
|
-
} else if (command === "normalize") {
|
|
274
|
-
process.stdout.write(stringifyYamlData({ circuitryBundle: CIRCUITRY_SPEC_VERSION, graph: loaded.graph, origins: loaded.origins }));
|
|
275
|
-
} else {
|
|
276
|
-
usage();
|
|
260
|
+
const result = validateCircuitryExecutionGraphWithStandard(loaded.graph);
|
|
261
|
+
if (!result.ok) {
|
|
262
|
+
console.error(result.errors.map((error) => error.message).join("\n"));
|
|
263
|
+
process.exit(1);
|
|
277
264
|
}
|
|
265
|
+
console.log(`ok: ${loaded.filename}`);
|
|
266
|
+
} else {
|
|
267
|
+
usage();
|
|
278
268
|
}
|
|
279
269
|
} catch (error) {
|
|
280
270
|
console.error(error instanceof Error ? error.message : String(error));
|