@openfn/cli 0.0.14 → 0.0.15

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
@@ -170,7 +170,7 @@ var command_default3 = {
170
170
  // src/cli.ts
171
171
  var cmd = yargs(hideBin(process.argv)).command(command_default).command(command_default2).command(install).command(repo).command(command_default3).option("log", {
172
172
  alias: ["l"],
173
- description: "Set the default log level to none, trace, info or default",
173
+ description: "Set the default log level to none, default, info or debug",
174
174
  array: true
175
175
  }).alias("v", "version").help();
176
176
 
@@ -30,6 +30,7 @@ var defaultLoggerOptions = {
30
30
  };
31
31
  var ERROR_MESSAGE_LOG_LEVEL = "Unknown log level. Valid levels are none, debug, info and default.";
32
32
  var ERROR_MESSAGE_LOG_COMPONENT = "Unknown log component. Valid components are cli, compiler, runtime and job.";
33
+ var DEFAULT_REPO_DIR = "/tmp/openfn/repo";
33
34
  var componentShorthands = {
34
35
  cmp: "compiler",
35
36
  rt: "runtime",
@@ -71,13 +72,13 @@ var ensureLogOpts = (opts) => {
71
72
  function ensureOpts(basePath = ".", opts) {
72
73
  const newOpts = {
73
74
  adaptor: opts.adaptor,
74
- adaptors: opts.adaptors,
75
+ adaptors: opts.adaptors || [],
75
76
  autoinstall: opts.autoinstall,
76
77
  command: opts.command,
77
78
  force: opts.force || false,
78
- repoDir: opts.repoDir || process.env.OPENFN_REPO_DIR,
79
+ repoDir: opts.repoDir || process.env.OPENFN_REPO_DIR || DEFAULT_REPO_DIR,
79
80
  noCompile: Boolean(opts.noCompile),
80
- expand: Boolean(opts.expand),
81
+ expand: opts.expand !== false,
81
82
  outputStdout: Boolean(opts.outputStdout),
82
83
  packages: opts.packages,
83
84
  stateStdin: opts.stateStdin,
@@ -142,7 +143,7 @@ var load_state_default = async (opts, log) => {
142
143
  };
143
144
 
144
145
  // src/execute/execute.ts
145
- import run from "@openfn/runtime";
146
+ import run, { getNameAndVersion } from "@openfn/runtime";
146
147
  var execute_default = (code, state, opts) => {
147
148
  return run(code, state, {
148
149
  immutableState: opts.immutable,
@@ -150,16 +151,23 @@ var execute_default = (code, state, opts) => {
150
151
  jobLogger: logger_default(JOB, opts),
151
152
  linker: {
152
153
  repo: opts.repoDir,
153
- modulePaths: parseAdaptors(opts)
154
+ modules: parseAdaptors(opts)
154
155
  }
155
156
  });
156
157
  };
157
158
  function parseAdaptors(opts) {
158
- var _a;
159
159
  const adaptors = {};
160
- (_a = opts.adaptors) == null ? void 0 : _a.reduce((obj, exp) => {
160
+ opts.adaptors.reduce((obj, exp) => {
161
161
  const [module, path2] = exp.split("=");
162
- obj[module] = path2;
162
+ const { name, version } = getNameAndVersion(module);
163
+ const info = {};
164
+ if (path2) {
165
+ info.path = path2;
166
+ }
167
+ if (version) {
168
+ info.version = version;
169
+ }
170
+ obj[name] = info;
163
171
  return obj;
164
172
  }, adaptors);
165
173
  return adaptors;
@@ -201,18 +209,18 @@ var resolveSpecifierPath = async (pattern, repoDir, log) => {
201
209
  log.debug(`Resolved ${specifier} to path: ${path2}`);
202
210
  return path2;
203
211
  }
204
- const repoPath = await getModulePath(specifier, repoDir);
212
+ const repoPath = await getModulePath(specifier, repoDir, log);
205
213
  if (repoPath) {
206
- log.debug(`Resolved ${specifier} to repo module`);
207
214
  return repoPath;
208
215
  }
209
216
  return null;
210
217
  };
211
218
  var loadTransformOptions = async (opts, log) => {
219
+ var _a;
212
220
  const options = {
213
221
  logger: log
214
222
  };
215
- if (opts.adaptors) {
223
+ if ((_a = opts.adaptors) == null ? void 0 : _a.length) {
216
224
  let exports;
217
225
  const [pattern] = opts.adaptors;
218
226
  const [specifier] = pattern.split("=");
@@ -230,7 +238,7 @@ var loadTransformOptions = async (opts, log) => {
230
238
  }
231
239
  }
232
240
  if (!exports || exports.length === 0) {
233
- console.warn(`WARNING: no module exports found for ${pattern}`);
241
+ log.debug(`No module exports found for ${pattern}`);
234
242
  }
235
243
  options["add-imports"] = {
236
244
  adaptor: {
@@ -301,13 +309,15 @@ var pwd = async (options, logger) => {
301
309
  var getDependencyList = async (options, _logger) => {
302
310
  const pkg = await loadRepoPkg(options.repoDir);
303
311
  const result = {};
304
- Object.keys(pkg.dependencies).forEach((key) => {
305
- const [name, version] = key.split("_");
306
- if (!result[name]) {
307
- result[name] = [];
308
- }
309
- result[name].push(version);
310
- });
312
+ if (pkg) {
313
+ Object.keys(pkg.dependencies).forEach((key) => {
314
+ const [name, version] = key.split("_");
315
+ if (!result[name]) {
316
+ result[name] = [];
317
+ }
318
+ result[name].push(version);
319
+ });
320
+ }
311
321
  return result;
312
322
  };
313
323
  var list = async (options, logger) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/cli",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "CLI devtools for the openfn toolchain.",
5
5
  "engines": {
6
6
  "node": ">=16",
@@ -36,9 +36,9 @@
36
36
  "typescript": "^4.7.4"
37
37
  },
38
38
  "dependencies": {
39
- "@openfn/compiler": "^0.0.13",
40
- "@openfn/logger": "^0.0.5",
41
- "@openfn/runtime": "^0.0.10",
39
+ "@openfn/compiler": "^0.0.14",
40
+ "@openfn/logger": "^0.0.6",
41
+ "@openfn/runtime": "^0.0.11",
42
42
  "rimraf": "^3.0.2",
43
43
  "treeify": "^1.1.0",
44
44
  "yargs": "^17.5.1"