@openfn/cli 0.3.1 → 0.4.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.
- package/dist/index.js +34 -1
- package/dist/process/runner.js +31 -12
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -113,6 +113,9 @@ var ensureLogOpts = (opts2) => {
|
|
|
113
113
|
} else {
|
|
114
114
|
component = "default";
|
|
115
115
|
level = l.toLowerCase();
|
|
116
|
+
if (level === "none" && !parts.find((p) => p.startsWith("job"))) {
|
|
117
|
+
components["job"] = "none";
|
|
118
|
+
}
|
|
116
119
|
}
|
|
117
120
|
if (!/^(cli|runtime|compiler|job|default)$/i.test(component)) {
|
|
118
121
|
throw new Error(ERROR_MESSAGE_LOG_COMPONENT);
|
|
@@ -416,8 +419,26 @@ var useAdaptorsMonorepo = {
|
|
|
416
419
|
}
|
|
417
420
|
}
|
|
418
421
|
};
|
|
422
|
+
var sanitize = {
|
|
423
|
+
name: "sanitize",
|
|
424
|
+
yargs: {
|
|
425
|
+
string: true,
|
|
426
|
+
alias: ["sanitise"],
|
|
427
|
+
description: "Sanitize logging of objects and arrays: none (default), remove, summarize, obfuscate.",
|
|
428
|
+
default: "none"
|
|
429
|
+
},
|
|
430
|
+
ensure: (opts2) => {
|
|
431
|
+
if (!opts2.sanitize || opts2.sanitize?.match(/^(none|summarize|remove|obfuscate)$/)) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const err = "Unknown sanitize value provided: " + opts2.sanitize;
|
|
435
|
+
console.error(err);
|
|
436
|
+
throw new Error(err);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
419
439
|
|
|
420
440
|
// src/util/command-builders.ts
|
|
441
|
+
import c from "chalk";
|
|
421
442
|
var expandYargs = (y2) => {
|
|
422
443
|
if (typeof y2 === "function") {
|
|
423
444
|
return y2();
|
|
@@ -433,7 +454,18 @@ function build(opts2, yargs2) {
|
|
|
433
454
|
var ensure = (command, opts2) => (yargs2) => {
|
|
434
455
|
yargs2.command = command;
|
|
435
456
|
opts2.filter((opt) => opt.ensure).forEach((opt) => {
|
|
436
|
-
|
|
457
|
+
try {
|
|
458
|
+
opt.ensure(yargs2);
|
|
459
|
+
} catch (e) {
|
|
460
|
+
console.error(
|
|
461
|
+
c.red(`
|
|
462
|
+
Error parsing command arguments: ${command}.${opt.name}
|
|
463
|
+
`)
|
|
464
|
+
);
|
|
465
|
+
console.error(c.red("Aborting"));
|
|
466
|
+
console.error();
|
|
467
|
+
process.exit(9);
|
|
468
|
+
}
|
|
437
469
|
});
|
|
438
470
|
};
|
|
439
471
|
var override = (command, yargs2) => {
|
|
@@ -537,6 +569,7 @@ var options4 = [
|
|
|
537
569
|
outputStdout,
|
|
538
570
|
repoDir,
|
|
539
571
|
skipAdaptorValidation,
|
|
572
|
+
sanitize,
|
|
540
573
|
start,
|
|
541
574
|
statePath,
|
|
542
575
|
stateStdin,
|
package/dist/process/runner.js
CHANGED
|
@@ -24,6 +24,7 @@ var createLogger = (name = "", options) => {
|
|
|
24
24
|
return actualCreateLogger(namespaces[name] || name, {
|
|
25
25
|
level,
|
|
26
26
|
json,
|
|
27
|
+
sanitize: options.sanitize || "none",
|
|
27
28
|
...logOptions
|
|
28
29
|
});
|
|
29
30
|
};
|
|
@@ -1082,16 +1083,32 @@ import path5 from "path";
|
|
|
1082
1083
|
import fs3 from "node:fs/promises";
|
|
1083
1084
|
import {
|
|
1084
1085
|
getConfig as getConfig2,
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1086
|
+
getProject,
|
|
1087
|
+
getSpec,
|
|
1088
|
+
getStateFromProjectPayload
|
|
1088
1089
|
} from "@openfn/deploy";
|
|
1089
1090
|
async function pullHandler(options, logger) {
|
|
1090
1091
|
try {
|
|
1091
1092
|
assert_path_default(options.projectId);
|
|
1092
1093
|
const config = mergeOverrides2(await getConfig2(options.configPath), options);
|
|
1093
|
-
logger.always("Downloading project
|
|
1094
|
-
const
|
|
1094
|
+
logger.always("Downloading existing project state (as JSON) from the server.");
|
|
1095
|
+
const { data: project } = await getProject(config, options.projectId);
|
|
1096
|
+
if (!project) {
|
|
1097
|
+
logger.error("ERROR: Project not found.");
|
|
1098
|
+
logger.warn(
|
|
1099
|
+
"Please check the UUID and verify your endpoint and apiKey in your config."
|
|
1100
|
+
);
|
|
1101
|
+
process.exitCode = 1;
|
|
1102
|
+
process.exit(1);
|
|
1103
|
+
}
|
|
1104
|
+
const state = getStateFromProjectPayload(project);
|
|
1105
|
+
await fs3.writeFile(
|
|
1106
|
+
path5.resolve(config.statePath),
|
|
1107
|
+
JSON.stringify(state, null, 2)
|
|
1108
|
+
);
|
|
1109
|
+
logger.always(
|
|
1110
|
+
"Downloading the project spec (as YAML) from the server."
|
|
1111
|
+
);
|
|
1095
1112
|
const url2 = new URL(
|
|
1096
1113
|
`api/provision/yaml?id=${options.projectId}`,
|
|
1097
1114
|
config.endpoint
|
|
@@ -1103,22 +1120,24 @@ async function pullHandler(options, logger) {
|
|
|
1103
1120
|
Accept: "application/json"
|
|
1104
1121
|
}
|
|
1105
1122
|
});
|
|
1123
|
+
if (res.status != 200) {
|
|
1124
|
+
logger.error("ERROR: Project spec not retrieved.");
|
|
1125
|
+
logger.warn(
|
|
1126
|
+
"No YAML representation of this project could be retrieved from the server."
|
|
1127
|
+
);
|
|
1128
|
+
process.exitCode = 1;
|
|
1129
|
+
process.exit(1);
|
|
1130
|
+
}
|
|
1106
1131
|
const resolvedPath = path5.resolve(config.specPath);
|
|
1107
1132
|
logger.debug("reading spec from", resolvedPath);
|
|
1108
1133
|
await fs3.writeFile(resolvedPath, res.body);
|
|
1109
|
-
const spec = await getSpec(
|
|
1110
|
-
logger.debug("validated spec: ", spec);
|
|
1134
|
+
const spec = await getSpec(resolvedPath);
|
|
1111
1135
|
if (spec.errors.length > 0) {
|
|
1112
1136
|
logger.error("ERROR: invalid spec");
|
|
1113
1137
|
logger.error(spec.errors);
|
|
1114
1138
|
process.exitCode = 1;
|
|
1115
1139
|
process.exit(1);
|
|
1116
1140
|
}
|
|
1117
|
-
const nextState = mergeSpecIntoState(state, spec.doc);
|
|
1118
|
-
await fs3.writeFile(
|
|
1119
|
-
path5.resolve(config.statePath),
|
|
1120
|
-
JSON.stringify(nextState, null, 2)
|
|
1121
|
-
);
|
|
1122
1141
|
logger.success("Project pulled successfully");
|
|
1123
1142
|
process.exitCode = 0;
|
|
1124
1143
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "CLI devtools for the openfn toolchain.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18",
|
|
@@ -39,15 +39,16 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@inquirer/prompts": "^1.1.4",
|
|
42
|
+
"chalk": "^5.1.2",
|
|
42
43
|
"figures": "^5.0.0",
|
|
43
44
|
"rimraf": "^3.0.2",
|
|
44
45
|
"treeify": "^1.1.0",
|
|
45
46
|
"yargs": "^17.7.2",
|
|
46
|
-
"@openfn/compiler": "0.0.
|
|
47
|
-
"@openfn/deploy": "0.2.
|
|
47
|
+
"@openfn/compiler": "0.0.36",
|
|
48
|
+
"@openfn/deploy": "0.2.7",
|
|
48
49
|
"@openfn/describe-package": "0.0.18",
|
|
49
|
-
"@openfn/logger": "0.0.
|
|
50
|
-
"@openfn/runtime": "0.0.
|
|
50
|
+
"@openfn/logger": "0.0.17",
|
|
51
|
+
"@openfn/runtime": "0.0.31"
|
|
51
52
|
},
|
|
52
53
|
"files": [
|
|
53
54
|
"dist",
|