@openfn/cli 1.22.0 → 1.24.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
@@ -147,6 +147,7 @@ var ensureLogOpts = (opts2) => {
147
147
  var ensure_log_opts_default = ensureLogOpts;
148
148
 
149
149
  // src/options.ts
150
+ import { existsSync } from "node:fs";
150
151
  var setDefaultValue = (opts2, key2, value2) => {
151
152
  const v = opts2[key2];
152
153
  if (isNaN(v) && !v) {
@@ -249,12 +250,16 @@ var compile = {
249
250
  }
250
251
  };
251
252
  var confirm = {
252
- name: "no-confirm",
253
+ name: "confirm",
253
254
  yargs: {
255
+ alias: ["y"],
254
256
  boolean: true,
255
257
  description: "Skip confirmation prompts (e.g. 'Are you sure?')"
256
258
  },
257
259
  ensure: (opts2) => {
260
+ if (opts2.y) {
261
+ opts2.confirm = false;
262
+ }
258
263
  setDefaultValue(opts2, "confirm", true);
259
264
  }
260
265
  };
@@ -284,6 +289,19 @@ var credentials = {
284
289
  yargs: {
285
290
  alias: ["creds"],
286
291
  description: "A path which points to a credential map"
292
+ },
293
+ ensure(opts2) {
294
+ if (opts2.credentials) {
295
+ const mapPath = nodePath.resolve(
296
+ opts2.workspace ?? "",
297
+ opts2.credentials
298
+ );
299
+ if (!existsSync(mapPath)) {
300
+ const e = new Error("Credential map not found at " + mapPath);
301
+ delete e.stack;
302
+ throw e;
303
+ }
304
+ }
287
305
  }
288
306
  };
289
307
  var describe = {
@@ -363,13 +381,12 @@ var inputPath = {
363
381
  },
364
382
  ensure: (opts2) => {
365
383
  const { path: basePath } = opts2;
366
- if (basePath?.endsWith(".json")) {
384
+ if (basePath?.match(/.(json|ya?ml)$/)) {
367
385
  opts2.planPath = basePath;
368
386
  } else if (basePath?.endsWith(".js")) {
369
387
  opts2.expressionPath = basePath;
370
- } else {
371
- const base = getBaseDir(opts2);
372
- setDefaultValue(opts2, "expressionPath", nodePath.join(base, "job.js"));
388
+ } else if (!opts2.expressionPath) {
389
+ opts2.workflowName = basePath;
373
390
  }
374
391
  }
375
392
  };
@@ -583,8 +600,8 @@ function build(opts2, yargs2) {
583
600
  return yargs2.option(o.name, expandYargs(o.yargs));
584
601
  }, yargs2);
585
602
  }
586
- var ensure = (command7, opts2) => (yargs2) => {
587
- yargs2.command = command7;
603
+ var ensure = (command8, opts2) => (yargs2) => {
604
+ yargs2.command = command8;
588
605
  opts2.filter((opt) => opt.ensure).forEach((opt) => {
589
606
  try {
590
607
  opt.ensure(yargs2);
@@ -592,7 +609,7 @@ var ensure = (command7, opts2) => (yargs2) => {
592
609
  console.log(e);
593
610
  console.error(
594
611
  c.red(`
595
- Error parsing command arguments: ${command7}.${opt.name}
612
+ Error parsing command arguments: ${command8}.${opt.name}
596
613
  `)
597
614
  );
598
615
  console.error(c.red("Aborting"));
@@ -601,11 +618,11 @@ Error parsing command arguments: ${command7}.${opt.name}
601
618
  }
602
619
  });
603
620
  };
604
- var override = (command7, yargs2) => {
621
+ var override = (command8, yargs2) => {
605
622
  return {
606
- ...command7,
623
+ ...command8,
607
624
  yargs: {
608
- ...command7.yargs || {},
625
+ ...command8.yargs || {},
609
626
  ...yargs2
610
627
  }
611
628
  };
@@ -902,9 +919,16 @@ var env2 = {
902
919
  var alias = {
903
920
  name: "alias",
904
921
  yargs: {
922
+ alias: ["env"],
905
923
  description: "Environment name (eg staging, prod, branch)"
906
924
  }
907
925
  };
926
+ var dryRun2 = {
927
+ name: "dryRun",
928
+ yargs: {
929
+ description: "Runs the command but does not commit any changes to disk or app"
930
+ }
931
+ };
908
932
  var removeUnmapped = {
909
933
  name: "remove-unmapped",
910
934
  yargs: {
@@ -923,7 +947,7 @@ var workflowMappings = {
923
947
  var outputPath2 = {
924
948
  name: "output-path",
925
949
  yargs: {
926
- alias: ["output"],
950
+ alias: ["o", "output"],
927
951
  type: "string",
928
952
  description: "Path to output the fetched project to"
929
953
  }
@@ -1021,7 +1045,8 @@ var options5 = [
1021
1045
  stateStdin,
1022
1046
  timeout,
1023
1047
  trace,
1024
- useAdaptorsMonorepo
1048
+ useAdaptorsMonorepo,
1049
+ workspace
1025
1050
  ];
1026
1051
  var executeCommand = {
1027
1052
  command: "execute <path> [workflow]",
@@ -1293,7 +1318,6 @@ var options14 = [
1293
1318
  description: "path to output the project to"
1294
1319
  }),
1295
1320
  logJson,
1296
- projectPath,
1297
1321
  snapshots,
1298
1322
  path2,
1299
1323
  force
@@ -1310,6 +1334,33 @@ var command6 = {
1310
1334
  handler: ensure("project-pull", options14)
1311
1335
  };
1312
1336
 
1337
+ // src/projects/deploy.ts
1338
+ import Project5 from "@openfn/project";
1339
+ import c2 from "chalk";
1340
+ var options15 = [
1341
+ env2,
1342
+ workspace,
1343
+ dryRun2,
1344
+ apiKey,
1345
+ endpoint,
1346
+ log,
1347
+ logJson,
1348
+ snapshots,
1349
+ force,
1350
+ confirm
1351
+ ];
1352
+ var command7 = {
1353
+ command: "deploy",
1354
+ describe: `Deploy the checked out project to a Lightning Instance`,
1355
+ builder: (yargs2) => build(options15, yargs2).positional("project", {
1356
+ describe: "The UUID, local id or local alias of the project to deploy to"
1357
+ }).example(
1358
+ "deploy",
1359
+ "Deploy the checkout project to the connected instance"
1360
+ ),
1361
+ handler: ensure("project-deploy", options15)
1362
+ };
1363
+
1313
1364
  // src/projects/command.ts
1314
1365
  var projectsCommand = {
1315
1366
  command: "project [subcommand]",
@@ -1317,7 +1368,7 @@ var projectsCommand = {
1317
1368
  describe: "Sync and manage an OpenFn project",
1318
1369
  handler: () => {
1319
1370
  },
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(
1371
+ builder: (yargs2) => yargs2.command(command6).command(command7).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(
1321
1372
  "project checkout staging",
1322
1373
  "Checkout the project with id staging"
1323
1374
  ).example(