@openfn/cli 0.2.0 → 0.2.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 CHANGED
@@ -11,7 +11,9 @@ import { fork } from "node:child_process";
11
11
  import process2 from "node:process";
12
12
  function spawn_default(basePath, opts2) {
13
13
  const execArgv = [
14
+ // Suppress experimental argument warnings
14
15
  "--no-warnings",
16
+ // Allows us to load an ESM module from a text string
15
17
  "--experimental-vm-modules"
16
18
  ];
17
19
  const dirname = path.dirname(url.fileURLToPath(import.meta.url));
@@ -386,7 +388,9 @@ var command_default2 = deployCommand;
386
388
  // src/docgen/command.ts
387
389
  var docgenCommand = {
388
390
  command: "docgen <specifier>",
391
+ // Hide this command as it's not really for public usage
389
392
  desc: false,
393
+ // 'Generate documentation into the repo. Specifier must include a version number.'
390
394
  handler: (argv) => {
391
395
  argv.command = "docgen";
392
396
  },
@@ -0,0 +1,98 @@
1
+ // package.json
2
+ var name = "@openfn/cli";
3
+ var version = "0.2.1";
4
+ var description = "CLI devtools for the openfn toolchain.";
5
+ var engines = {
6
+ node: ">=18",
7
+ pnpm: ">=7"
8
+ };
9
+ var scripts = {
10
+ test: "pnpm ava",
11
+ "test:watch": "pnpm ava -w",
12
+ "test:types": "pnpm tsc --noEmit --project tsconfig.json",
13
+ build: "tsup --config ./tsup.config.js",
14
+ "build:watch": "pnpm build --watch",
15
+ openfn: "node --no-warnings dist/index.js",
16
+ pack: "pnpm pack --pack-destination ../../dist"
17
+ };
18
+ var exports = {
19
+ ".": {
20
+ import: {
21
+ types: "./dist/index.d.ts",
22
+ default: "./dist/index.js"
23
+ }
24
+ }
25
+ };
26
+ var type = "module";
27
+ var bin = {
28
+ openfn: "dist/index.js"
29
+ };
30
+ var module = "dist/index.js";
31
+ var types = "dist/index.d.ts";
32
+ var keywords = [];
33
+ var author = "Open Function Group <admin@openfn.org>";
34
+ var license = "ISC";
35
+ var devDependencies = {
36
+ "@openfn/language-common": "2.0.0-rc3",
37
+ "@types/mock-fs": "^4.13.1",
38
+ "@types/node": "^17.0.45",
39
+ "@types/yargs": "^17.0.24",
40
+ ava: "5.1.0",
41
+ "mock-fs": "^5.1.4",
42
+ "ts-node": "^10.9.1",
43
+ tslib: "^2.4.0",
44
+ tsup: "^7.1.0",
45
+ typescript: "^4.7.4"
46
+ };
47
+ var dependencies = {
48
+ "@openfn/compiler": "workspace:*",
49
+ "@openfn/deploy": "workspace:*",
50
+ "@openfn/describe-package": "workspace:*",
51
+ "@openfn/logger": "workspace:*",
52
+ "@openfn/runtime": "workspace:*",
53
+ figures: "^5.0.0",
54
+ rimraf: "^3.0.2",
55
+ treeify: "^1.1.0",
56
+ yargs: "^17.7.2"
57
+ };
58
+ var files = [
59
+ "dist",
60
+ "README.md"
61
+ ];
62
+ var package_default = {
63
+ name,
64
+ version,
65
+ description,
66
+ engines,
67
+ scripts,
68
+ exports,
69
+ type,
70
+ bin,
71
+ module,
72
+ types,
73
+ keywords,
74
+ author,
75
+ license,
76
+ devDependencies,
77
+ dependencies,
78
+ files
79
+ };
80
+ export {
81
+ author,
82
+ bin,
83
+ package_default as default,
84
+ dependencies,
85
+ description,
86
+ devDependencies,
87
+ engines,
88
+ exports,
89
+ files,
90
+ keywords,
91
+ license,
92
+ module,
93
+ name,
94
+ scripts,
95
+ type,
96
+ types,
97
+ version
98
+ };
@@ -1 +1,2 @@
1
1
 
2
+ export { }
@@ -39,8 +39,8 @@ var createNullLogger = () => createLogger(void 0, { log: { default: "none" } });
39
39
  var AbortError = class extends Error {
40
40
  constructor(reason) {
41
41
  super(reason);
42
- this.handled = true;
43
42
  }
43
+ handled = true;
44
44
  };
45
45
  var abort_default = (logger, reason, error, help) => {
46
46
  const e = new AbortError(reason);
@@ -65,7 +65,9 @@ var execute_default = async (input, state, opts, logger) => {
65
65
  timeout: opts.timeout,
66
66
  immutableState: opts.immutable,
67
67
  logger: logger_default(RUNTIME, opts),
68
+ // TODO log types are flaky right now
68
69
  jobLogger: logger_default(JOB, opts),
70
+ // ditto
69
71
  linker: {
70
72
  repo: opts.repoDir,
71
73
  modules: parseAdaptors(opts)
@@ -566,7 +568,7 @@ var map_adaptors_to_monorepo_default = mapAdaptorsToMonorepo;
566
568
 
567
569
  // src/execute/handler.ts
568
570
  var executeHandler = async (options, logger) => {
569
- const start = new Date().getTime();
571
+ const start = (/* @__PURE__ */ new Date()).getTime();
570
572
  await validate_adaptors_default(options, logger);
571
573
  let input = await load_input_default(options, logger);
572
574
  if (options.workflow) {
@@ -597,7 +599,7 @@ var executeHandler = async (options, logger) => {
597
599
  try {
598
600
  const result = await execute_default(input, state, options, logger);
599
601
  await serialize_output_default(options, result, logger);
600
- const duration = printDuration(new Date().getTime() - start);
602
+ const duration = printDuration((/* @__PURE__ */ new Date()).getTime() - start);
601
603
  if (result.errors) {
602
604
  logger.warn(
603
605
  `Errors reported in ${Object.keys(result.errors).length} jobs`
@@ -610,7 +612,7 @@ var executeHandler = async (options, logger) => {
610
612
  logger.error("Unexpected error in execution");
611
613
  logger.error(err);
612
614
  }
613
- const duration = printDuration(new Date().getTime() - start);
615
+ const duration = printDuration((/* @__PURE__ */ new Date()).getTime() - start);
614
616
  logger.always(`Workflow failed in ${duration}.`);
615
617
  process.exitCode = 1;
616
618
  }
@@ -883,6 +885,7 @@ var docsHandler = async (options, logger) => {
883
885
  specifier: `${name}@${version}`,
884
886
  repoDir
885
887
  },
888
+ // TODO I'm not sure how to handle logging here - we ought to feedback SOMETHING though
886
889
  createNullLogger()
887
890
  );
888
891
  let didError = false;
@@ -958,7 +961,7 @@ var cache_default = { get, set, generateKey, getPath, sortKeys };
958
961
  // src/metadata/handler.ts
959
962
  import { getModuleEntryPoint } from "@openfn/runtime";
960
963
  var decorateMetadata = (metadata) => {
961
- metadata.created = new Date().toISOString();
964
+ metadata.created = (/* @__PURE__ */ new Date()).toISOString();
962
965
  };
963
966
  var getAdaptorPath = async (adaptor, logger, repoDir) => {
964
967
  let adaptorPath;
@@ -1076,6 +1079,7 @@ var handler_default8 = pullHandler;
1076
1079
  import path6 from "node:path";
1077
1080
  var defaultLoggerOptions = {
1078
1081
  default: "default",
1082
+ // TODO fix to lower case
1079
1083
  job: "debug"
1080
1084
  };
1081
1085
  var ERROR_MESSAGE_LOG_LEVEL = "Unknown log level. Valid levels are none, debug, info and default.";
@@ -1125,6 +1129,7 @@ var ensureLogOpts = (opts) => {
1125
1129
  function ensureOpts(basePath = ".", opts) {
1126
1130
  const newOpts = {
1127
1131
  adaptor: opts.adaptor,
1132
+ // only applies to install (a bit messy) (now applies to docs too)
1128
1133
  adaptors: opts.adaptors || [],
1129
1134
  autoinstall: opts.autoinstall,
1130
1135
  command: opts.command,
@@ -1132,6 +1137,7 @@ function ensureOpts(basePath = ".", opts) {
1132
1137
  force: opts.force || false,
1133
1138
  immutable: opts.immutable || false,
1134
1139
  log: opts.log,
1140
+ // TMP this will be overwritten later
1135
1141
  logJson: typeof opts.logJson == "boolean" ? opts.logJson : Boolean(process.env.OPENFN_LOG_JSON),
1136
1142
  compile: Boolean(opts.compile),
1137
1143
  operation: opts.operation,
@@ -1212,7 +1218,7 @@ var printVersions = async (logger, options = {}) => {
1212
1218
  adaptorName
1213
1219
  ].map((s) => s.length));
1214
1220
  const prefix = (str) => ` ${t} ${str.padEnd(longest + 4, " ")}`;
1215
- const pkg = await import("../../package.json", { assert: { type: "json" } });
1221
+ const pkg = await import("../package-JMR2GBIW.js");
1216
1222
  const { version, dependencies } = pkg.default;
1217
1223
  const compilerVersion = dependencies["@openfn/compiler"];
1218
1224
  const runtimeVersion = dependencies["@openfn/runtime"];
@@ -1258,7 +1264,13 @@ var handlers = {
1258
1264
  ["repo-list"]: list,
1259
1265
  version: async (opts, logger) => print_versions_default(logger, opts)
1260
1266
  };
1261
- var maybeEnsureOpts = (basePath, options) => /(^(deploy|execute|compile|test)$)|(repo-)/.test(options.command) ? ensureLogOpts(options) : ensureOpts(basePath, options);
1267
+ var maybeEnsureOpts = (basePath, options) => (
1268
+ // If the command is compile or execute, just return the opts (yargs will do all the validation)
1269
+ /(^(deploy|execute|compile|test)$)|(repo-)/.test(options.command) ? ensureLogOpts(options) : (
1270
+ // Otherwise older commands still need to go through ensure opts
1271
+ ensureOpts(basePath, options)
1272
+ )
1273
+ );
1262
1274
  var parse = async (basePath, options, log) => {
1263
1275
  const opts = maybeEnsureOpts(basePath, options);
1264
1276
  const logger = log || logger_default(CLI, opts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI devtools for the openfn toolchain.",
5
5
  "engines": {
6
6
  "node": ">=18",
@@ -27,24 +27,24 @@
27
27
  "@openfn/language-common": "2.0.0-rc3",
28
28
  "@types/mock-fs": "^4.13.1",
29
29
  "@types/node": "^17.0.45",
30
- "@types/yargs": "^17.0.12",
30
+ "@types/yargs": "^17.0.24",
31
31
  "ava": "5.1.0",
32
32
  "mock-fs": "^5.1.4",
33
33
  "ts-node": "^10.9.1",
34
34
  "tslib": "^2.4.0",
35
- "tsup": "^6.2.3",
35
+ "tsup": "^7.1.0",
36
36
  "typescript": "^4.7.4"
37
37
  },
38
38
  "dependencies": {
39
39
  "figures": "^5.0.0",
40
40
  "rimraf": "^3.0.2",
41
41
  "treeify": "^1.1.0",
42
- "yargs": "^17.5.1",
43
- "@openfn/compiler": "0.0.32",
44
- "@openfn/deploy": "0.2.0",
45
- "@openfn/logger": "0.0.13",
46
- "@openfn/describe-package": "0.0.16",
47
- "@openfn/runtime": "0.0.26"
42
+ "yargs": "^17.7.2",
43
+ "@openfn/deploy": "0.2.1",
44
+ "@openfn/describe-package": "0.0.17",
45
+ "@openfn/logger": "0.0.14",
46
+ "@openfn/runtime": "0.0.27",
47
+ "@openfn/compiler": "0.0.33"
48
48
  },
49
49
  "files": [
50
50
  "dist",