@openfn/cli 1.20.2 → 1.21.0
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 +188 -117
- package/dist/process/runner.js +787 -572
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -146,29 +146,6 @@ var ensureLogOpts = (opts2) => {
|
|
|
146
146
|
};
|
|
147
147
|
var ensure_log_opts_default = ensureLogOpts;
|
|
148
148
|
|
|
149
|
-
// src/util/get-cli-option-object.ts
|
|
150
|
-
function getCLIOptionObject(arg) {
|
|
151
|
-
if (isObject(arg)) {
|
|
152
|
-
return arg;
|
|
153
|
-
} else if (typeof arg === "string") {
|
|
154
|
-
try {
|
|
155
|
-
const p = JSON.parse(arg);
|
|
156
|
-
if (isObject(p))
|
|
157
|
-
return p;
|
|
158
|
-
} catch (e) {
|
|
159
|
-
}
|
|
160
|
-
return Object.fromEntries(
|
|
161
|
-
arg.split(",").map((pair) => {
|
|
162
|
-
const [k, v] = pair.split("=");
|
|
163
|
-
return [k.trim(), v.trim()];
|
|
164
|
-
})
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function isObject(arg) {
|
|
169
|
-
return typeof arg === "object" && arg !== null && !Array.isArray(arg);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
149
|
// src/options.ts
|
|
173
150
|
var setDefaultValue = (opts2, key2, value2) => {
|
|
174
151
|
const v = opts2[key2];
|
|
@@ -206,11 +183,16 @@ var autoinstall = {
|
|
|
206
183
|
default: true
|
|
207
184
|
}
|
|
208
185
|
};
|
|
209
|
-
var
|
|
186
|
+
var apiKey = {
|
|
210
187
|
name: "apikey",
|
|
211
188
|
yargs: {
|
|
212
|
-
alias: ["
|
|
213
|
-
description: "
|
|
189
|
+
alias: ["pat", "token", "api-key"],
|
|
190
|
+
description: "API Key, Personal Access Token (PAT), or other access token from Lightning"
|
|
191
|
+
},
|
|
192
|
+
ensure: (opts2) => {
|
|
193
|
+
if (!opts2.apikey) {
|
|
194
|
+
opts2.apiKey = process.env.OPENFN_API_KEY;
|
|
195
|
+
}
|
|
214
196
|
}
|
|
215
197
|
};
|
|
216
198
|
var apolloUrl = {
|
|
@@ -284,6 +266,26 @@ var configPath = {
|
|
|
284
266
|
default: "./.config.json"
|
|
285
267
|
}
|
|
286
268
|
};
|
|
269
|
+
var collectionsVersion = {
|
|
270
|
+
name: "collections-version",
|
|
271
|
+
yargs: {
|
|
272
|
+
description: "The version of the collections adaptor to use. Defaults to latest. Use OPENFN_COLLECTIONS_VERSION env."
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
var collectionsEndpoint = {
|
|
276
|
+
name: "collections-endpoint",
|
|
277
|
+
yargs: {
|
|
278
|
+
alias: ["endpoint"],
|
|
279
|
+
description: "The Lightning server to use for collections. Will use the project endpoint if available. Use OPENFN_COLLECTIONS_ENDPOINT env."
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
var credentials = {
|
|
283
|
+
name: "credentials",
|
|
284
|
+
yargs: {
|
|
285
|
+
alias: ["creds"],
|
|
286
|
+
description: "A path which points to a credential map"
|
|
287
|
+
}
|
|
288
|
+
};
|
|
287
289
|
var describe = {
|
|
288
290
|
name: "describe",
|
|
289
291
|
yargs: {
|
|
@@ -311,12 +313,6 @@ var endpoint = {
|
|
|
311
313
|
description: "[beta only] URL to Lightning endpoint"
|
|
312
314
|
}
|
|
313
315
|
};
|
|
314
|
-
var env2 = {
|
|
315
|
-
name: "env",
|
|
316
|
-
yargs: {
|
|
317
|
-
description: "[beta only] Environment name (eg staging, prod, branch)"
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
316
|
var force = {
|
|
321
317
|
name: "force",
|
|
322
318
|
yargs: {
|
|
@@ -360,16 +356,6 @@ var getBaseDir = (opts2) => {
|
|
|
360
356
|
}
|
|
361
357
|
return basePath;
|
|
362
358
|
};
|
|
363
|
-
var projectId = {
|
|
364
|
-
name: "project-id",
|
|
365
|
-
yargs: {
|
|
366
|
-
description: "The id or UUID of an openfn project",
|
|
367
|
-
string: true
|
|
368
|
-
},
|
|
369
|
-
ensure: (opts2) => {
|
|
370
|
-
return opts2.projectName;
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
359
|
var inputPath = {
|
|
374
360
|
name: "input-path",
|
|
375
361
|
yargs: {
|
|
@@ -578,36 +564,6 @@ var workflow = {
|
|
|
578
564
|
description: "Name of the workflow to execute"
|
|
579
565
|
}
|
|
580
566
|
};
|
|
581
|
-
var removeUnmapped = {
|
|
582
|
-
name: "remove-unmapped",
|
|
583
|
-
yargs: {
|
|
584
|
-
boolean: true,
|
|
585
|
-
description: "Removes all workflows that didn't get mapped from the final project after merge"
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
var workflowMappings = {
|
|
589
|
-
name: "workflow-mappings",
|
|
590
|
-
yargs: {
|
|
591
|
-
type: "string",
|
|
592
|
-
coerce: getCLIOptionObject,
|
|
593
|
-
description: "A manual object mapping of which workflows in source and target should be matched for a merge."
|
|
594
|
-
}
|
|
595
|
-
};
|
|
596
|
-
var workspace = {
|
|
597
|
-
name: "workspace",
|
|
598
|
-
yargs: {
|
|
599
|
-
alias: ["w"],
|
|
600
|
-
description: "Path to the project workspace (ie, path to openfn.yaml)"
|
|
601
|
-
},
|
|
602
|
-
ensure: (opts2) => {
|
|
603
|
-
const ws = opts2.workspace ?? process.env.OPENFN_WORKSPACE;
|
|
604
|
-
if (!ws) {
|
|
605
|
-
opts2.workspace = process.cwd();
|
|
606
|
-
} else {
|
|
607
|
-
opts2.workspace = nodePath.resolve(ws);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
567
|
|
|
612
568
|
// src/util/command-builders.ts
|
|
613
569
|
import c from "chalk";
|
|
@@ -618,13 +574,17 @@ var expandYargs = (y2) => {
|
|
|
618
574
|
return y2;
|
|
619
575
|
};
|
|
620
576
|
function build(opts2, yargs2) {
|
|
621
|
-
return opts2.reduce(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
577
|
+
return opts2.reduce((_y, o) => {
|
|
578
|
+
if (!o?.name) {
|
|
579
|
+
console.error(`ERROR: INVALID COMMAND OPTION PASSED`, o);
|
|
580
|
+
console.error("Check the options passed to the command builder");
|
|
581
|
+
throw new Error("Invalid command");
|
|
582
|
+
}
|
|
583
|
+
return yargs2.option(o.name, expandYargs(o.yargs));
|
|
584
|
+
}, yargs2);
|
|
625
585
|
}
|
|
626
|
-
var ensure = (
|
|
627
|
-
yargs2.command =
|
|
586
|
+
var ensure = (command7, opts2) => (yargs2) => {
|
|
587
|
+
yargs2.command = command7;
|
|
628
588
|
opts2.filter((opt) => opt.ensure).forEach((opt) => {
|
|
629
589
|
try {
|
|
630
590
|
opt.ensure(yargs2);
|
|
@@ -632,7 +592,7 @@ var ensure = (command6, opts2) => (yargs2) => {
|
|
|
632
592
|
console.log(e);
|
|
633
593
|
console.error(
|
|
634
594
|
c.red(`
|
|
635
|
-
Error parsing command arguments: ${
|
|
595
|
+
Error parsing command arguments: ${command7}.${opt.name}
|
|
636
596
|
`)
|
|
637
597
|
);
|
|
638
598
|
console.error(c.red("Aborting"));
|
|
@@ -641,11 +601,11 @@ Error parsing command arguments: ${command6}.${opt.name}
|
|
|
641
601
|
}
|
|
642
602
|
});
|
|
643
603
|
};
|
|
644
|
-
var override = (
|
|
604
|
+
var override = (command7, yargs2) => {
|
|
645
605
|
return {
|
|
646
|
-
...
|
|
606
|
+
...command7,
|
|
647
607
|
yargs: {
|
|
648
|
-
...
|
|
608
|
+
...command7.yargs || {},
|
|
649
609
|
...yargs2
|
|
650
610
|
}
|
|
651
611
|
};
|
|
@@ -719,13 +679,6 @@ var key = {
|
|
|
719
679
|
}
|
|
720
680
|
}
|
|
721
681
|
};
|
|
722
|
-
var token = {
|
|
723
|
-
name: "pat",
|
|
724
|
-
yargs: {
|
|
725
|
-
alias: ["token"],
|
|
726
|
-
description: "Lightning Personal Access Token (PAT)"
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
682
|
var endpoint2 = {
|
|
730
683
|
name: "endpoint",
|
|
731
684
|
yargs: {
|
|
@@ -781,7 +734,7 @@ var updatedAfter = {
|
|
|
781
734
|
var getOptions = [
|
|
782
735
|
collectionName,
|
|
783
736
|
key,
|
|
784
|
-
|
|
737
|
+
apiKey,
|
|
785
738
|
endpoint2,
|
|
786
739
|
pageSize,
|
|
787
740
|
limit,
|
|
@@ -817,7 +770,7 @@ var dryRun = {
|
|
|
817
770
|
var removeOptions = [
|
|
818
771
|
collectionName,
|
|
819
772
|
key,
|
|
820
|
-
|
|
773
|
+
apiKey,
|
|
821
774
|
endpoint2,
|
|
822
775
|
dryRun,
|
|
823
776
|
createdBefore,
|
|
@@ -852,7 +805,7 @@ var setOptions = [
|
|
|
852
805
|
override(key, {
|
|
853
806
|
demand: false
|
|
854
807
|
}),
|
|
855
|
-
|
|
808
|
+
apiKey,
|
|
856
809
|
endpoint2,
|
|
857
810
|
value,
|
|
858
811
|
items,
|
|
@@ -908,6 +861,89 @@ var compileCommand = {
|
|
|
908
861
|
};
|
|
909
862
|
var command_default3 = compileCommand;
|
|
910
863
|
|
|
864
|
+
// src/util/resolve-path.ts
|
|
865
|
+
import nodepath from "node:path";
|
|
866
|
+
import os from "node:os";
|
|
867
|
+
var resolve_path_default = (path3, root) => {
|
|
868
|
+
return path3.startsWith("~") ? path3.replace(`~`, os.homedir) : nodepath.resolve(root ?? "", path3);
|
|
869
|
+
};
|
|
870
|
+
|
|
871
|
+
// src/util/get-cli-option-object.ts
|
|
872
|
+
function getCLIOptionObject(arg) {
|
|
873
|
+
if (isObject(arg)) {
|
|
874
|
+
return arg;
|
|
875
|
+
} else if (typeof arg === "string") {
|
|
876
|
+
try {
|
|
877
|
+
const p = JSON.parse(arg);
|
|
878
|
+
if (isObject(p))
|
|
879
|
+
return p;
|
|
880
|
+
} catch (e) {
|
|
881
|
+
}
|
|
882
|
+
return Object.fromEntries(
|
|
883
|
+
arg.split(",").map((pair) => {
|
|
884
|
+
const [k, v] = pair.split("=");
|
|
885
|
+
return [k.trim(), v.trim()];
|
|
886
|
+
})
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
function isObject(arg) {
|
|
891
|
+
return typeof arg === "object" && arg !== null && !Array.isArray(arg);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// src/projects/options.ts
|
|
895
|
+
var env2 = {
|
|
896
|
+
name: "env",
|
|
897
|
+
yargs: {
|
|
898
|
+
description: "Environment name (eg staging, prod, branch)",
|
|
899
|
+
hidden: true
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
var alias = {
|
|
903
|
+
name: "alias",
|
|
904
|
+
yargs: {
|
|
905
|
+
description: "Environment name (eg staging, prod, branch)"
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
var removeUnmapped = {
|
|
909
|
+
name: "remove-unmapped",
|
|
910
|
+
yargs: {
|
|
911
|
+
boolean: true,
|
|
912
|
+
description: "Removes all workflows that didn't get mapped from the final project after merge"
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
var workflowMappings = {
|
|
916
|
+
name: "workflow-mappings",
|
|
917
|
+
yargs: {
|
|
918
|
+
type: "string",
|
|
919
|
+
coerce: getCLIOptionObject,
|
|
920
|
+
description: "A manual object mapping of which workflows in source and target should be matched for a merge."
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
var outputPath2 = {
|
|
924
|
+
name: "output-path",
|
|
925
|
+
yargs: {
|
|
926
|
+
alias: ["output"],
|
|
927
|
+
type: "string",
|
|
928
|
+
description: "Path to output the fetched project to"
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
var workspace = {
|
|
932
|
+
name: "workspace",
|
|
933
|
+
yargs: {
|
|
934
|
+
alias: ["w"],
|
|
935
|
+
description: "Path to the project workspace (ie, path to openfn.yaml)"
|
|
936
|
+
},
|
|
937
|
+
ensure: (opts2) => {
|
|
938
|
+
const ws = opts2.workspace ?? process.env.OPENFN_WORKSPACE;
|
|
939
|
+
if (!ws) {
|
|
940
|
+
opts2.workspace = process.cwd();
|
|
941
|
+
} else {
|
|
942
|
+
opts2.workspace = resolve_path_default(ws);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
|
|
911
947
|
// src/deploy/command.ts
|
|
912
948
|
var options3 = [
|
|
913
949
|
beta,
|
|
@@ -958,9 +994,16 @@ var command_default6 = docsCommand;
|
|
|
958
994
|
var options5 = [
|
|
959
995
|
expandAdaptors,
|
|
960
996
|
adaptors,
|
|
997
|
+
override(apiKey, {
|
|
998
|
+
description: "API token for collections",
|
|
999
|
+
alias: ["collections-api-key", "collections-token", "pat"]
|
|
1000
|
+
}),
|
|
961
1001
|
autoinstall,
|
|
962
1002
|
cacheSteps,
|
|
963
1003
|
compile,
|
|
1004
|
+
credentials,
|
|
1005
|
+
collectionsEndpoint,
|
|
1006
|
+
collectionsVersion,
|
|
964
1007
|
end,
|
|
965
1008
|
ignoreImports,
|
|
966
1009
|
immutable,
|
|
@@ -1033,8 +1076,7 @@ var command_default8 = {
|
|
|
1033
1076
|
|
|
1034
1077
|
// src/pull/command.ts
|
|
1035
1078
|
var options7 = [
|
|
1036
|
-
|
|
1037
|
-
beta,
|
|
1079
|
+
apiKey,
|
|
1038
1080
|
beta,
|
|
1039
1081
|
configPath,
|
|
1040
1082
|
endpoint,
|
|
@@ -1057,7 +1099,7 @@ var pullCommand = {
|
|
|
1057
1099
|
command: "pull [projectId]",
|
|
1058
1100
|
describe: `Pull a project's state and spec from a Lightning Instance to the local directory. Pass --beta to use the experimental new pull command. See https://github.com/OpenFn/kit/wiki/Pull-Deploy-Beta for docs`,
|
|
1059
1101
|
builder: (yargs2) => build(options7, yargs2).positional("projectId", {
|
|
1060
|
-
describe: "The id of the project that should be pulled
|
|
1102
|
+
describe: "The id of the project that should be pulled should be a UUID",
|
|
1061
1103
|
demandOption: true
|
|
1062
1104
|
}).example(
|
|
1063
1105
|
"pull 57862287-23e6-4650-8d79-e1dd88b24b1c",
|
|
@@ -1163,24 +1205,27 @@ import Project3, { Workspace as Workspace4 } from "@openfn/project";
|
|
|
1163
1205
|
// src/projects/checkout.ts
|
|
1164
1206
|
import Project2, { Workspace as Workspace3 } from "@openfn/project";
|
|
1165
1207
|
import { rimraf } from "rimraf";
|
|
1166
|
-
var options11 = [
|
|
1208
|
+
var options11 = [log, workspace];
|
|
1167
1209
|
var command3 = {
|
|
1168
|
-
command: "checkout <project
|
|
1210
|
+
command: "checkout <project>",
|
|
1169
1211
|
describe: "Switch to a different OpenFn project in the same workspace",
|
|
1170
1212
|
handler: ensure("project-checkout", options11),
|
|
1171
|
-
builder: (yargs2) => build(options11, yargs2)
|
|
1213
|
+
builder: (yargs2) => build(options11, yargs2).positional("project", {
|
|
1214
|
+
describe: "The id, alias or UUID of the project to chcekout",
|
|
1215
|
+
demandOption: true
|
|
1216
|
+
})
|
|
1172
1217
|
};
|
|
1173
1218
|
var checkout_default = command3;
|
|
1174
1219
|
|
|
1175
1220
|
// src/projects/merge.ts
|
|
1176
1221
|
var options12 = [
|
|
1177
|
-
projectId,
|
|
1178
1222
|
removeUnmapped,
|
|
1179
1223
|
workflowMappings,
|
|
1180
|
-
log,
|
|
1181
1224
|
workspace,
|
|
1225
|
+
log,
|
|
1182
1226
|
// custom output because we don't want defaults or anything
|
|
1183
1227
|
{
|
|
1228
|
+
// TODO presumably if we do this we don't also checkout?
|
|
1184
1229
|
name: "output-path",
|
|
1185
1230
|
yargs: {
|
|
1186
1231
|
alias: "o",
|
|
@@ -1199,8 +1244,8 @@ var options12 = [
|
|
|
1199
1244
|
})
|
|
1200
1245
|
];
|
|
1201
1246
|
var command4 = {
|
|
1202
|
-
command: "merge <project
|
|
1203
|
-
describe: "Merges the specified project into the currently checked out project",
|
|
1247
|
+
command: "merge <project>",
|
|
1248
|
+
describe: "Merges the specified project (by UUID, id or alias) into the currently checked out project",
|
|
1204
1249
|
handler: ensure("project-merge", options12),
|
|
1205
1250
|
builder: (yargs2) => build(options12, yargs2)
|
|
1206
1251
|
};
|
|
@@ -1209,28 +1254,25 @@ var merge_default = command4;
|
|
|
1209
1254
|
// src/projects/fetch.ts
|
|
1210
1255
|
import Project4, { Workspace as Workspace5 } from "@openfn/project";
|
|
1211
1256
|
var options13 = [
|
|
1212
|
-
|
|
1213
|
-
|
|
1257
|
+
alias,
|
|
1258
|
+
apiKey,
|
|
1214
1259
|
endpoint,
|
|
1215
|
-
env2,
|
|
1216
1260
|
log,
|
|
1217
|
-
override(outputPath, {
|
|
1218
|
-
description: "Path to output the fetched project to"
|
|
1219
|
-
}),
|
|
1220
1261
|
logJson,
|
|
1221
|
-
workspace,
|
|
1222
1262
|
snapshots,
|
|
1223
|
-
|
|
1263
|
+
// TODO need to add support for this
|
|
1224
1264
|
override(force, {
|
|
1225
1265
|
description: "Overwrite local file contents with the fetched contents"
|
|
1226
|
-
})
|
|
1266
|
+
}),
|
|
1267
|
+
outputPath2,
|
|
1268
|
+
env2,
|
|
1269
|
+
workspace
|
|
1227
1270
|
];
|
|
1228
1271
|
var command5 = {
|
|
1229
|
-
command: "fetch [
|
|
1230
|
-
describe: `
|
|
1231
|
-
builder: (yargs2) => build(options13, yargs2).positional("
|
|
1232
|
-
describe: "The id of the project
|
|
1233
|
-
demandOption: true
|
|
1272
|
+
command: "fetch [project]",
|
|
1273
|
+
describe: `Download the latest version of a project from a lightning server (does not expand the project, use checkout)`,
|
|
1274
|
+
builder: (yargs2) => build(options13, yargs2).positional("project", {
|
|
1275
|
+
describe: "The id, alias or UUID of the project to fetch. If not set, will default to the active project"
|
|
1234
1276
|
}).example(
|
|
1235
1277
|
"fetch 57862287-23e6-4650-8d79-e1dd88b24b1c",
|
|
1236
1278
|
"Fetch an updated copy of a the above spec and state from a Lightning Instance"
|
|
@@ -1239,6 +1281,35 @@ var command5 = {
|
|
|
1239
1281
|
};
|
|
1240
1282
|
var fetch_default = command5;
|
|
1241
1283
|
|
|
1284
|
+
// src/projects/pull.ts
|
|
1285
|
+
var options14 = [
|
|
1286
|
+
alias,
|
|
1287
|
+
env2,
|
|
1288
|
+
workspace,
|
|
1289
|
+
apiKey,
|
|
1290
|
+
endpoint,
|
|
1291
|
+
log,
|
|
1292
|
+
override(path2, {
|
|
1293
|
+
description: "path to output the project to"
|
|
1294
|
+
}),
|
|
1295
|
+
logJson,
|
|
1296
|
+
projectPath,
|
|
1297
|
+
snapshots,
|
|
1298
|
+
path2,
|
|
1299
|
+
force
|
|
1300
|
+
];
|
|
1301
|
+
var command6 = {
|
|
1302
|
+
command: "pull [project]",
|
|
1303
|
+
describe: `Pull a project from a Lightning Instance and expand to the file system (ie fetch + checkout)`,
|
|
1304
|
+
builder: (yargs2) => build(options14, yargs2).positional("project", {
|
|
1305
|
+
describe: "The UUID, local id or local alias of the project to pull"
|
|
1306
|
+
}).example(
|
|
1307
|
+
"pull 57862287-23e6-4650-8d79-e1dd88b24b1c",
|
|
1308
|
+
"Pull project with a UUID from a lightning instance"
|
|
1309
|
+
),
|
|
1310
|
+
handler: ensure("project-pull", options14)
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1242
1313
|
// src/projects/command.ts
|
|
1243
1314
|
var projectsCommand = {
|
|
1244
1315
|
command: "project [subcommand]",
|
|
@@ -1246,7 +1317,7 @@ var projectsCommand = {
|
|
|
1246
1317
|
describe: "Sync and manage an OpenFn project",
|
|
1247
1318
|
handler: () => {
|
|
1248
1319
|
},
|
|
1249
|
-
builder: (yargs2) => yargs2.command(list_default).command(version_default).command(merge_default).command(checkout_default).command(fetch_default).example("project", "list all projects in the workspace").example("project list", "list all projects in the workspace").example(
|
|
1320
|
+
builder: (yargs2) => yargs2.command(command6).command(list_default).command(version_default).command(merge_default).command(checkout_default).command(fetch_default).example("project", "list all projects in the workspace").example("project list", "list all projects in the workspace").example(
|
|
1250
1321
|
"project checkout staging",
|
|
1251
1322
|
"Checkout the project with id staging"
|
|
1252
1323
|
).example(
|