@openfn/cli 1.19.0 → 1.20.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 +121 -51
- package/dist/process/runner.js +1017 -537
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -236,14 +236,6 @@ var apolloUrl = {
|
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
|
-
var json = {
|
|
240
|
-
name: "json",
|
|
241
|
-
yargs: {
|
|
242
|
-
boolean: true,
|
|
243
|
-
description: "Output the result as a json object",
|
|
244
|
-
default: false
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
239
|
var beta = {
|
|
248
240
|
name: "beta",
|
|
249
241
|
yargs: {
|
|
@@ -601,6 +593,21 @@ var workflowMappings = {
|
|
|
601
593
|
description: "A manual object mapping of which workflows in source and target should be matched for a merge."
|
|
602
594
|
}
|
|
603
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
|
+
};
|
|
604
611
|
|
|
605
612
|
// src/util/command-builders.ts
|
|
606
613
|
import c from "chalk";
|
|
@@ -616,15 +623,16 @@ function build(opts2, yargs2) {
|
|
|
616
623
|
yargs2
|
|
617
624
|
);
|
|
618
625
|
}
|
|
619
|
-
var ensure = (
|
|
620
|
-
yargs2.command =
|
|
626
|
+
var ensure = (command6, opts2) => (yargs2) => {
|
|
627
|
+
yargs2.command = command6;
|
|
621
628
|
opts2.filter((opt) => opt.ensure).forEach((opt) => {
|
|
622
629
|
try {
|
|
623
630
|
opt.ensure(yargs2);
|
|
624
631
|
} catch (e) {
|
|
632
|
+
console.log(e);
|
|
625
633
|
console.error(
|
|
626
634
|
c.red(`
|
|
627
|
-
Error parsing command arguments: ${
|
|
635
|
+
Error parsing command arguments: ${command6}.${opt.name}
|
|
628
636
|
`)
|
|
629
637
|
);
|
|
630
638
|
console.error(c.red("Aborting"));
|
|
@@ -633,11 +641,11 @@ Error parsing command arguments: ${command}.${opt.name}
|
|
|
633
641
|
}
|
|
634
642
|
});
|
|
635
643
|
};
|
|
636
|
-
var override = (
|
|
644
|
+
var override = (command6, yargs2) => {
|
|
637
645
|
return {
|
|
638
|
-
...
|
|
646
|
+
...command6,
|
|
639
647
|
yargs: {
|
|
640
|
-
...
|
|
648
|
+
...command6.yargs || {},
|
|
641
649
|
...yargs2
|
|
642
650
|
}
|
|
643
651
|
};
|
|
@@ -718,9 +726,10 @@ var token = {
|
|
|
718
726
|
description: "Lightning Personal Access Token (PAT)"
|
|
719
727
|
}
|
|
720
728
|
};
|
|
721
|
-
var
|
|
722
|
-
name: "
|
|
729
|
+
var endpoint2 = {
|
|
730
|
+
name: "endpoint",
|
|
723
731
|
yargs: {
|
|
732
|
+
alias: ["e", "lightning"],
|
|
724
733
|
description: "URL to OpenFn server. Defaults to OPENFN_ENDPOINT or https://app.openfn.org"
|
|
725
734
|
}
|
|
726
735
|
};
|
|
@@ -773,7 +782,7 @@ var getOptions = [
|
|
|
773
782
|
collectionName,
|
|
774
783
|
key,
|
|
775
784
|
token,
|
|
776
|
-
|
|
785
|
+
endpoint2,
|
|
777
786
|
pageSize,
|
|
778
787
|
limit,
|
|
779
788
|
pretty,
|
|
@@ -809,7 +818,7 @@ var removeOptions = [
|
|
|
809
818
|
collectionName,
|
|
810
819
|
key,
|
|
811
820
|
token,
|
|
812
|
-
|
|
821
|
+
endpoint2,
|
|
813
822
|
dryRun,
|
|
814
823
|
createdBefore,
|
|
815
824
|
createdAfter,
|
|
@@ -844,7 +853,7 @@ var setOptions = [
|
|
|
844
853
|
demand: false
|
|
845
854
|
}),
|
|
846
855
|
token,
|
|
847
|
-
|
|
856
|
+
endpoint2,
|
|
848
857
|
value,
|
|
849
858
|
items,
|
|
850
859
|
override(log, {
|
|
@@ -1037,7 +1046,11 @@ var options7 = [
|
|
|
1037
1046
|
projectPath,
|
|
1038
1047
|
snapshots,
|
|
1039
1048
|
statePath,
|
|
1040
|
-
path2
|
|
1049
|
+
path2,
|
|
1050
|
+
// These are hidden commands used only by beta
|
|
1051
|
+
// The need to be declared here to be initialised and defaulted properly
|
|
1052
|
+
override(force, { hidden: true }),
|
|
1053
|
+
override(workspace, { hidden: true })
|
|
1041
1054
|
];
|
|
1042
1055
|
var pullCommand = {
|
|
1043
1056
|
command: "pull [projectId]",
|
|
@@ -1120,34 +1133,51 @@ var command_default10 = {
|
|
|
1120
1133
|
builder: (yargs2) => build(options8, yargs2).example("test", "Run the test script")
|
|
1121
1134
|
};
|
|
1122
1135
|
|
|
1123
|
-
// src/projects/
|
|
1124
|
-
|
|
1125
|
-
var
|
|
1126
|
-
|
|
1136
|
+
// src/projects/list.ts
|
|
1137
|
+
import { Workspace } from "@openfn/project";
|
|
1138
|
+
var options9 = [log, workspace];
|
|
1139
|
+
var command = {
|
|
1140
|
+
command: "list [project-path]",
|
|
1127
1141
|
describe: "List all the openfn projects available in the current directory",
|
|
1128
|
-
aliases: ["project"],
|
|
1129
|
-
handler: ensure("
|
|
1142
|
+
aliases: ["project", "$0"],
|
|
1143
|
+
handler: ensure("project-list", options9),
|
|
1130
1144
|
builder: (yargs2) => build(options9, yargs2)
|
|
1131
1145
|
};
|
|
1132
|
-
var
|
|
1146
|
+
var list_default = command;
|
|
1133
1147
|
|
|
1134
|
-
// src/
|
|
1135
|
-
|
|
1136
|
-
var
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1148
|
+
// src/projects/version.ts
|
|
1149
|
+
import { Workspace as Workspace2 } from "@openfn/project";
|
|
1150
|
+
var options10 = [workflow, workspace, workflowMappings];
|
|
1151
|
+
var command2 = {
|
|
1152
|
+
command: "version [workflow]",
|
|
1153
|
+
describe: "Returns the version hash of a given workflow in a workspace",
|
|
1154
|
+
handler: ensure("project-version", options10),
|
|
1140
1155
|
builder: (yargs2) => build(options10, yargs2)
|
|
1141
1156
|
};
|
|
1142
|
-
var
|
|
1157
|
+
var version_default = command2;
|
|
1158
|
+
|
|
1159
|
+
// src/projects/merge.ts
|
|
1160
|
+
import Project3, { Workspace as Workspace4 } from "@openfn/project";
|
|
1161
|
+
|
|
1162
|
+
// src/projects/checkout.ts
|
|
1163
|
+
import Project2, { Workspace as Workspace3 } from "@openfn/project";
|
|
1164
|
+
import { rimraf } from "rimraf";
|
|
1165
|
+
var options11 = [projectId, workspace, log];
|
|
1166
|
+
var command3 = {
|
|
1167
|
+
command: "checkout <project-id>",
|
|
1168
|
+
describe: "Switch to a different OpenFn project in the same workspace",
|
|
1169
|
+
handler: ensure("project-checkout", options11),
|
|
1170
|
+
builder: (yargs2) => build(options11, yargs2)
|
|
1171
|
+
};
|
|
1172
|
+
var checkout_default = command3;
|
|
1143
1173
|
|
|
1144
|
-
// src/merge
|
|
1145
|
-
var
|
|
1174
|
+
// src/projects/merge.ts
|
|
1175
|
+
var options12 = [
|
|
1146
1176
|
projectId,
|
|
1147
|
-
projectPath,
|
|
1148
1177
|
removeUnmapped,
|
|
1149
1178
|
workflowMappings,
|
|
1150
1179
|
log,
|
|
1180
|
+
workspace,
|
|
1151
1181
|
// custom output because we don't want defaults or anything
|
|
1152
1182
|
{
|
|
1153
1183
|
name: "output-path",
|
|
@@ -1167,23 +1197,63 @@ var options11 = [
|
|
|
1167
1197
|
description: "Force a merge even when workflows are incompatible"
|
|
1168
1198
|
})
|
|
1169
1199
|
];
|
|
1170
|
-
var
|
|
1200
|
+
var command4 = {
|
|
1171
1201
|
command: "merge <project-id>",
|
|
1172
|
-
describe: "Merges the specified project into the checked out project",
|
|
1173
|
-
handler: ensure("merge",
|
|
1174
|
-
builder: (yargs2) => build(
|
|
1202
|
+
describe: "Merges the specified project into the currently checked out project",
|
|
1203
|
+
handler: ensure("project-merge", options12),
|
|
1204
|
+
builder: (yargs2) => build(options12, yargs2)
|
|
1175
1205
|
};
|
|
1176
|
-
var
|
|
1206
|
+
var merge_default = command4;
|
|
1177
1207
|
|
|
1178
|
-
// src/
|
|
1179
|
-
|
|
1180
|
-
var
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1208
|
+
// src/projects/fetch.ts
|
|
1209
|
+
import Project4, { Workspace as Workspace5 } from "@openfn/project";
|
|
1210
|
+
var options13 = [
|
|
1211
|
+
apikey,
|
|
1212
|
+
configPath,
|
|
1213
|
+
endpoint,
|
|
1214
|
+
env2,
|
|
1215
|
+
log,
|
|
1216
|
+
override(outputPath, {
|
|
1217
|
+
description: "Path to output the fetched project to"
|
|
1218
|
+
}),
|
|
1219
|
+
logJson,
|
|
1220
|
+
workspace,
|
|
1221
|
+
snapshots,
|
|
1222
|
+
statePath,
|
|
1223
|
+
override(force, {
|
|
1224
|
+
description: "Overwrite local file contents with the fetched contents"
|
|
1225
|
+
})
|
|
1226
|
+
];
|
|
1227
|
+
var command5 = {
|
|
1228
|
+
command: "fetch [projectId]",
|
|
1229
|
+
describe: `Fetch a project's state and spec from a Lightning Instance to the local state file without expanding to the filesystem.`,
|
|
1230
|
+
builder: (yargs2) => build(options13, yargs2).positional("projectId", {
|
|
1231
|
+
describe: "The id of the project that should be fetched, should be a UUID",
|
|
1232
|
+
demandOption: true
|
|
1233
|
+
}).example(
|
|
1234
|
+
"fetch 57862287-23e6-4650-8d79-e1dd88b24b1c",
|
|
1235
|
+
"Fetch an updated copy of a the above spec and state from a Lightning Instance"
|
|
1236
|
+
),
|
|
1237
|
+
handler: ensure("project-fetch", options13)
|
|
1238
|
+
};
|
|
1239
|
+
var fetch_default = command5;
|
|
1240
|
+
|
|
1241
|
+
// src/projects/command.ts
|
|
1242
|
+
var projectsCommand = {
|
|
1243
|
+
command: "project [subcommand]",
|
|
1244
|
+
aliases: ["projects"],
|
|
1245
|
+
describe: "Sync and manage an OpenFn project",
|
|
1246
|
+
handler: () => {
|
|
1247
|
+
},
|
|
1248
|
+
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(
|
|
1249
|
+
"project checkout staging",
|
|
1250
|
+
"Checkout the project with id staging"
|
|
1251
|
+
).example(
|
|
1252
|
+
"project merge staging",
|
|
1253
|
+
"Merge staging into the checkout-out branch"
|
|
1254
|
+
)
|
|
1185
1255
|
};
|
|
1186
|
-
var
|
|
1256
|
+
var command_default11 = projectsCommand;
|
|
1187
1257
|
|
|
1188
1258
|
// src/cli.ts
|
|
1189
1259
|
var env3 = env_default();
|
|
@@ -1191,7 +1261,7 @@ if (env3) {
|
|
|
1191
1261
|
process.env.$DOT_ENV_OVERRIDES = Object.keys(env3).join(",");
|
|
1192
1262
|
}
|
|
1193
1263
|
var y = yargs(hideBin(process.argv));
|
|
1194
|
-
var cmd = y.command(command_default7).command(command_default3).command(command_default2).command(command_default4).command(install).command(repo).command(command_default10).command(command_default6).command(command_default).command(command_default8).command(command_default5).command(command_default9).command(command_default11).command(
|
|
1264
|
+
var cmd = y.command(command_default7).command(command_default3).command(command_default2).command(command_default4).command(install).command(repo).command(command_default10).command(command_default6).command(command_default).command(command_default8).command(command_default5).command(command_default9).command(command_default11).command(checkout_default).command(merge_default).command(fetch_default).command({
|
|
1195
1265
|
command: "version",
|
|
1196
1266
|
describe: "Show the currently installed version of the CLI, compiler and runtime.",
|
|
1197
1267
|
handler: (argv) => {
|