@openfn/cli 1.19.0 → 1.20.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 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,15 @@ function build(opts2, yargs2) {
616
623
  yargs2
617
624
  );
618
625
  }
619
- var ensure = (command, opts2) => (yargs2) => {
620
- yargs2.command = 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) {
625
632
  console.error(
626
633
  c.red(`
627
- Error parsing command arguments: ${command}.${opt.name}
634
+ Error parsing command arguments: ${command6}.${opt.name}
628
635
  `)
629
636
  );
630
637
  console.error(c.red("Aborting"));
@@ -633,11 +640,11 @@ Error parsing command arguments: ${command}.${opt.name}
633
640
  }
634
641
  });
635
642
  };
636
- var override = (command, yargs2) => {
643
+ var override = (command6, yargs2) => {
637
644
  return {
638
- ...command,
645
+ ...command6,
639
646
  yargs: {
640
- ...command.yargs || {},
647
+ ...command6.yargs || {},
641
648
  ...yargs2
642
649
  }
643
650
  };
@@ -1037,7 +1044,11 @@ var options7 = [
1037
1044
  projectPath,
1038
1045
  snapshots,
1039
1046
  statePath,
1040
- path2
1047
+ path2,
1048
+ // These are hidden commands used only by beta
1049
+ // The need to be declared here to be initialised and defaulted properly
1050
+ override(force, { hidden: true }),
1051
+ override(workspace, { hidden: true })
1041
1052
  ];
1042
1053
  var pullCommand = {
1043
1054
  command: "pull [projectId]",
@@ -1120,34 +1131,51 @@ var command_default10 = {
1120
1131
  builder: (yargs2) => build(options8, yargs2).example("test", "Run the test script")
1121
1132
  };
1122
1133
 
1123
- // src/projects/command.ts
1124
- var options9 = [projectPath];
1125
- var projectsCommand = {
1126
- command: "projects [project-path]",
1134
+ // src/projects/list.ts
1135
+ import { Workspace } from "@openfn/project";
1136
+ var options9 = [log, workspace];
1137
+ var command = {
1138
+ command: "list [project-path]",
1127
1139
  describe: "List all the openfn projects available in the current directory",
1128
- aliases: ["project"],
1129
- handler: ensure("projects", options9),
1140
+ aliases: ["project", "$0"],
1141
+ handler: ensure("project-list", options9),
1130
1142
  builder: (yargs2) => build(options9, yargs2)
1131
1143
  };
1132
- var command_default11 = projectsCommand;
1144
+ var list_default = command;
1133
1145
 
1134
- // src/checkout/command.ts
1135
- var options10 = [projectId, projectPath, log];
1136
- var checkoutCommand = {
1137
- command: "checkout <project-id>",
1138
- describe: "Switch to a different openfn project in the same workspace",
1139
- handler: ensure("checkout", options10),
1146
+ // src/projects/version.ts
1147
+ import { Workspace as Workspace2 } from "@openfn/project";
1148
+ var options10 = [workflow, workspace, workflowMappings];
1149
+ var command2 = {
1150
+ command: "version [workflow]",
1151
+ describe: "Returns the version hash of a given workflow in a workspace",
1152
+ handler: ensure("project-version", options10),
1140
1153
  builder: (yargs2) => build(options10, yargs2)
1141
1154
  };
1142
- var command_default12 = checkoutCommand;
1155
+ var version_default = command2;
1156
+
1157
+ // src/projects/merge.ts
1158
+ import Project3, { Workspace as Workspace4 } from "@openfn/project";
1159
+
1160
+ // src/projects/checkout.ts
1161
+ import Project2, { Workspace as Workspace3 } from "@openfn/project";
1162
+ import { rimraf } from "rimraf";
1163
+ var options11 = [projectId, workspace, log];
1164
+ var command3 = {
1165
+ command: "checkout <project-id>",
1166
+ describe: "Switch to a different OpenFn project in the same workspace",
1167
+ handler: ensure("project-checkout", options11),
1168
+ builder: (yargs2) => build(options11, yargs2)
1169
+ };
1170
+ var checkout_default = command3;
1143
1171
 
1144
- // src/merge/command.ts
1145
- var options11 = [
1172
+ // src/projects/merge.ts
1173
+ var options12 = [
1146
1174
  projectId,
1147
- projectPath,
1148
1175
  removeUnmapped,
1149
1176
  workflowMappings,
1150
1177
  log,
1178
+ workspace,
1151
1179
  // custom output because we don't want defaults or anything
1152
1180
  {
1153
1181
  name: "output-path",
@@ -1167,23 +1195,63 @@ var options11 = [
1167
1195
  description: "Force a merge even when workflows are incompatible"
1168
1196
  })
1169
1197
  ];
1170
- var mergeCommand = {
1198
+ var command4 = {
1171
1199
  command: "merge <project-id>",
1172
- describe: "Merges the specified project into the checked out project",
1173
- handler: ensure("merge", options11),
1174
- builder: (yargs2) => build(options11, yargs2)
1200
+ describe: "Merges the specified project into the currently checked out project",
1201
+ handler: ensure("project-merge", options12),
1202
+ builder: (yargs2) => build(options12, yargs2)
1175
1203
  };
1176
- var command_default13 = mergeCommand;
1204
+ var merge_default = command4;
1177
1205
 
1178
- // src/version/command.ts
1179
- var options12 = [workflow, projectPath, workflowMappings, json];
1180
- var workflowVersionCommand = {
1181
- command: "project version [workflow]",
1182
- describe: "Returns the version has of a workflow",
1183
- handler: ensure("project", options12),
1184
- builder: (yargs2) => build(options12, yargs2)
1206
+ // src/projects/fetch.ts
1207
+ import Project4, { Workspace as Workspace5 } from "@openfn/project";
1208
+ var options13 = [
1209
+ apikey,
1210
+ configPath,
1211
+ endpoint,
1212
+ env2,
1213
+ log,
1214
+ override(outputPath, {
1215
+ description: "Path to output the fetched project to"
1216
+ }),
1217
+ logJson,
1218
+ workspace,
1219
+ snapshots,
1220
+ statePath,
1221
+ override(force, {
1222
+ description: "Overwrite local file contents with the fetched contents"
1223
+ })
1224
+ ];
1225
+ var command5 = {
1226
+ command: "fetch [projectId]",
1227
+ describe: `Fetch a project's state and spec from a Lightning Instance to the local state file without expanding to the filesystem.`,
1228
+ builder: (yargs2) => build(options13, yargs2).positional("projectId", {
1229
+ describe: "The id of the project that should be fetched, should be a UUID",
1230
+ demandOption: true
1231
+ }).example(
1232
+ "fetch 57862287-23e6-4650-8d79-e1dd88b24b1c",
1233
+ "Fetch an updated copy of a the above spec and state from a Lightning Instance"
1234
+ ),
1235
+ handler: ensure("project-fetch", options13)
1236
+ };
1237
+ var fetch_default = command5;
1238
+
1239
+ // src/projects/command.ts
1240
+ var projectsCommand = {
1241
+ command: "project [subcommand]",
1242
+ aliases: ["projects"],
1243
+ describe: "Sync and manage an OpenFn project",
1244
+ handler: () => {
1245
+ },
1246
+ 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(
1247
+ "project checkout staging",
1248
+ "Checkout the project with id staging"
1249
+ ).example(
1250
+ "project merge staging",
1251
+ "Merge staging into the checkout-out branch"
1252
+ )
1185
1253
  };
1186
- var command_default14 = workflowVersionCommand;
1254
+ var command_default11 = projectsCommand;
1187
1255
 
1188
1256
  // src/cli.ts
1189
1257
  var env3 = env_default();
@@ -1191,7 +1259,7 @@ if (env3) {
1191
1259
  process.env.$DOT_ENV_OVERRIDES = Object.keys(env3).join(",");
1192
1260
  }
1193
1261
  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(command_default12).command(command_default13).command(command_default14).command({
1262
+ 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
1263
  command: "version",
1196
1264
  describe: "Show the currently installed version of the CLI, compiler and runtime.",
1197
1265
  handler: (argv) => {