@openfn/cli 0.4.0 → 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/process/runner.js +30 -12
- package/package.json +3 -3
package/dist/process/runner.js
CHANGED
|
@@ -1083,16 +1083,32 @@ import path5 from "path";
|
|
|
1083
1083
|
import fs3 from "node:fs/promises";
|
|
1084
1084
|
import {
|
|
1085
1085
|
getConfig as getConfig2,
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1086
|
+
getProject,
|
|
1087
|
+
getSpec,
|
|
1088
|
+
getStateFromProjectPayload
|
|
1089
1089
|
} from "@openfn/deploy";
|
|
1090
1090
|
async function pullHandler(options, logger) {
|
|
1091
1091
|
try {
|
|
1092
1092
|
assert_path_default(options.projectId);
|
|
1093
1093
|
const config = mergeOverrides2(await getConfig2(options.configPath), options);
|
|
1094
|
-
logger.always("Downloading project
|
|
1095
|
-
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
|
+
);
|
|
1096
1112
|
const url2 = new URL(
|
|
1097
1113
|
`api/provision/yaml?id=${options.projectId}`,
|
|
1098
1114
|
config.endpoint
|
|
@@ -1104,22 +1120,24 @@ async function pullHandler(options, logger) {
|
|
|
1104
1120
|
Accept: "application/json"
|
|
1105
1121
|
}
|
|
1106
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
|
+
}
|
|
1107
1131
|
const resolvedPath = path5.resolve(config.specPath);
|
|
1108
1132
|
logger.debug("reading spec from", resolvedPath);
|
|
1109
1133
|
await fs3.writeFile(resolvedPath, res.body);
|
|
1110
|
-
const spec = await getSpec(
|
|
1111
|
-
logger.debug("validated spec: ", spec);
|
|
1134
|
+
const spec = await getSpec(resolvedPath);
|
|
1112
1135
|
if (spec.errors.length > 0) {
|
|
1113
1136
|
logger.error("ERROR: invalid spec");
|
|
1114
1137
|
logger.error(spec.errors);
|
|
1115
1138
|
process.exitCode = 1;
|
|
1116
1139
|
process.exit(1);
|
|
1117
1140
|
}
|
|
1118
|
-
const nextState = mergeSpecIntoState(state, spec.doc);
|
|
1119
|
-
await fs3.writeFile(
|
|
1120
|
-
path5.resolve(config.statePath),
|
|
1121
|
-
JSON.stringify(nextState, null, 2)
|
|
1122
|
-
);
|
|
1123
1141
|
logger.success("Project pulled successfully");
|
|
1124
1142
|
process.exitCode = 0;
|
|
1125
1143
|
return true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "CLI devtools for the openfn toolchain.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"treeify": "^1.1.0",
|
|
46
46
|
"yargs": "^17.7.2",
|
|
47
47
|
"@openfn/compiler": "0.0.36",
|
|
48
|
-
"@openfn/deploy": "0.2.
|
|
48
|
+
"@openfn/deploy": "0.2.7",
|
|
49
49
|
"@openfn/describe-package": "0.0.18",
|
|
50
50
|
"@openfn/logger": "0.0.17",
|
|
51
|
-
"@openfn/runtime": "0.0.
|
|
51
|
+
"@openfn/runtime": "0.0.31"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"dist",
|