@openfn/cli 0.1.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 +32 -6
- package/dist/package-JMR2GBIW.js +98 -0
- package/dist/process/runner.d.ts +1 -0
- package/dist/process/runner.js +98 -46
- package/package.json +9 -9
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));
|
|
@@ -100,6 +102,16 @@ var configPath = {
|
|
|
100
102
|
default: "./.config.json"
|
|
101
103
|
}
|
|
102
104
|
};
|
|
105
|
+
var describe = {
|
|
106
|
+
name: "describe",
|
|
107
|
+
yargs: {
|
|
108
|
+
boolean: true,
|
|
109
|
+
description: "Downloads the project yaml from the specified instance"
|
|
110
|
+
},
|
|
111
|
+
ensure: (opts2) => {
|
|
112
|
+
setDefaultValue(opts2, "describe", true);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
103
115
|
var expandAdaptors = {
|
|
104
116
|
name: "no-expand-adaptors",
|
|
105
117
|
yargs: {
|
|
@@ -362,7 +374,7 @@ var compileCommand = {
|
|
|
362
374
|
var command_default = compileCommand;
|
|
363
375
|
|
|
364
376
|
// src/deploy/command.ts
|
|
365
|
-
var options2 = [statePath, projectPath, configPath, confirm];
|
|
377
|
+
var options2 = [statePath, projectPath, configPath, confirm, describe];
|
|
366
378
|
var deployCommand = {
|
|
367
379
|
command: "deploy",
|
|
368
380
|
desc: "Deploy a project's config to a remote Lightning instance",
|
|
@@ -376,7 +388,9 @@ var command_default2 = deployCommand;
|
|
|
376
388
|
// src/docgen/command.ts
|
|
377
389
|
var docgenCommand = {
|
|
378
390
|
command: "docgen <specifier>",
|
|
391
|
+
// Hide this command as it's not really for public usage
|
|
379
392
|
desc: false,
|
|
393
|
+
// 'Generate documentation into the repo. Specifier must include a version number.'
|
|
380
394
|
handler: (argv) => {
|
|
381
395
|
argv.command = "docgen";
|
|
382
396
|
},
|
|
@@ -469,6 +483,18 @@ var command_default6 = {
|
|
|
469
483
|
)
|
|
470
484
|
};
|
|
471
485
|
|
|
486
|
+
// src/pull/command.ts
|
|
487
|
+
var options5 = [statePath, projectPath, configPath];
|
|
488
|
+
var pullCommand = {
|
|
489
|
+
command: "pull",
|
|
490
|
+
desc: "Pull aproject's state and spec from a Lightning Instance to the local directory",
|
|
491
|
+
builder: (yargs2) => {
|
|
492
|
+
return build(options5, yargs2).example("pull", "Pull an updated copy of a project spec and state from a Lightning Instance");
|
|
493
|
+
},
|
|
494
|
+
handler: ensure("pull", options5)
|
|
495
|
+
};
|
|
496
|
+
var command_default7 = pullCommand;
|
|
497
|
+
|
|
472
498
|
// src/repo/command.ts
|
|
473
499
|
var repo = {
|
|
474
500
|
command: "repo [subcommand]",
|
|
@@ -525,17 +551,17 @@ var list = {
|
|
|
525
551
|
};
|
|
526
552
|
|
|
527
553
|
// src/test/command.ts
|
|
528
|
-
var
|
|
529
|
-
var
|
|
554
|
+
var options6 = [stateStdin];
|
|
555
|
+
var command_default8 = {
|
|
530
556
|
command: "test",
|
|
531
557
|
desc: "Compiles and runs a test job, printing the result to stdout",
|
|
532
|
-
handler: ensure("test",
|
|
533
|
-
builder: (yargs2) => build(
|
|
558
|
+
handler: ensure("test", options6),
|
|
559
|
+
builder: (yargs2) => build(options6, yargs2).example("test", "Run the test script")
|
|
534
560
|
};
|
|
535
561
|
|
|
536
562
|
// src/cli.ts
|
|
537
563
|
var y = yargs(hideBin(process.argv));
|
|
538
|
-
var cmd = y.command(command_default5).command(command_default).command(command_default2).command(install).command(repo).command(
|
|
564
|
+
var cmd = y.command(command_default5).command(command_default).command(command_default2).command(install).command(repo).command(command_default8).command(command_default4).command(command_default6).command(command_default3).command(command_default7).option("log", {
|
|
539
565
|
alias: ["l"],
|
|
540
566
|
description: "Set the default log level to none, default, info or debug",
|
|
541
567
|
array: true
|
|
@@ -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
|
+
};
|
package/dist/process/runner.d.ts
CHANGED
package/dist/process/runner.js
CHANGED
|
@@ -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)
|
|
@@ -78,13 +80,13 @@ var execute_default = async (input, state, opts, logger) => {
|
|
|
78
80
|
};
|
|
79
81
|
function parseAdaptors(opts) {
|
|
80
82
|
const extractInfo = (specifier) => {
|
|
81
|
-
const [module,
|
|
83
|
+
const [module, path8] = specifier.split("=");
|
|
82
84
|
const { name, version } = getNameAndVersion(module);
|
|
83
85
|
const info = {
|
|
84
86
|
name
|
|
85
87
|
};
|
|
86
|
-
if (
|
|
87
|
-
info.path =
|
|
88
|
+
if (path8) {
|
|
89
|
+
info.path = path8;
|
|
88
90
|
}
|
|
89
91
|
if (version) {
|
|
90
92
|
info.version = version;
|
|
@@ -286,10 +288,10 @@ var stripVersionSpecifier = (specifier) => {
|
|
|
286
288
|
return specifier;
|
|
287
289
|
};
|
|
288
290
|
var resolveSpecifierPath = async (pattern, repoDir, log) => {
|
|
289
|
-
const [specifier,
|
|
290
|
-
if (
|
|
291
|
-
log.debug(`Resolved ${specifier} to path: ${
|
|
292
|
-
return
|
|
291
|
+
const [specifier, path8] = pattern.split("=");
|
|
292
|
+
if (path8) {
|
|
293
|
+
log.debug(`Resolved ${specifier} to path: ${path8}`);
|
|
294
|
+
return path8;
|
|
293
295
|
}
|
|
294
296
|
const repoPath = await getModulePath(specifier, repoDir, log);
|
|
295
297
|
if (repoPath) {
|
|
@@ -306,16 +308,16 @@ var loadTransformOptions = async (opts, log) => {
|
|
|
306
308
|
const [pattern] = opts.adaptors;
|
|
307
309
|
const [specifier] = pattern.split("=");
|
|
308
310
|
log.debug(`Attempting to preload types for ${specifier}`);
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
+
const path8 = await resolveSpecifierPath(pattern, opts.repoDir, log);
|
|
312
|
+
if (path8) {
|
|
311
313
|
try {
|
|
312
314
|
exports = await preloadAdaptorExports(
|
|
313
|
-
|
|
315
|
+
path8,
|
|
314
316
|
opts.useAdaptorsMonorepo,
|
|
315
317
|
log
|
|
316
318
|
);
|
|
317
319
|
} catch (e) {
|
|
318
|
-
log.error(`Failed to load adaptor typedefs from path ${
|
|
320
|
+
log.error(`Failed to load adaptor typedefs from path ${path8}`);
|
|
319
321
|
log.error(e);
|
|
320
322
|
}
|
|
321
323
|
}
|
|
@@ -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
|
}
|
|
@@ -754,20 +756,20 @@ var RETRY_COUNT = 20;
|
|
|
754
756
|
var TIMEOUT_MS = 1e3 * 60;
|
|
755
757
|
var actualDocGen = (specifier) => describePackage(specifier, {});
|
|
756
758
|
var ensurePath = (filePath) => mkdirSync(path3.dirname(filePath), { recursive: true });
|
|
757
|
-
var generatePlaceholder = (
|
|
758
|
-
writeFileSync(
|
|
759
|
+
var generatePlaceholder = (path8) => {
|
|
760
|
+
writeFileSync(path8, `{ "loading": true, "timestamp": ${Date.now()}}`);
|
|
759
761
|
};
|
|
760
762
|
var finish = (logger, resultPath) => {
|
|
761
763
|
logger.success("Done! Docs can be found at:\n");
|
|
762
764
|
logger.print(` ${path3.resolve(resultPath)}`);
|
|
763
765
|
};
|
|
764
|
-
var generateDocs = async (specifier,
|
|
766
|
+
var generateDocs = async (specifier, path8, docgen, logger) => {
|
|
765
767
|
const result = await docgen(specifier);
|
|
766
|
-
await writeFile3(
|
|
767
|
-
finish(logger,
|
|
768
|
-
return
|
|
768
|
+
await writeFile3(path8, JSON.stringify(result, null, 2));
|
|
769
|
+
finish(logger, path8);
|
|
770
|
+
return path8;
|
|
769
771
|
};
|
|
770
|
-
var waitForDocs = async (docs,
|
|
772
|
+
var waitForDocs = async (docs, path8, logger, retryDuration = RETRY_DURATION) => {
|
|
771
773
|
try {
|
|
772
774
|
if (docs.hasOwnProperty("loading")) {
|
|
773
775
|
logger.info("Docs are being loaded by another process. Waiting.");
|
|
@@ -779,19 +781,19 @@ var waitForDocs = async (docs, path7, logger, retryDuration = RETRY_DURATION) =>
|
|
|
779
781
|
clearInterval(i);
|
|
780
782
|
reject(new Error("Timed out waiting for docs to load"));
|
|
781
783
|
}
|
|
782
|
-
const updated = JSON.parse(readFileSync(
|
|
784
|
+
const updated = JSON.parse(readFileSync(path8, "utf8"));
|
|
783
785
|
if (!updated.hasOwnProperty("loading")) {
|
|
784
786
|
logger.info("Docs found!");
|
|
785
787
|
clearInterval(i);
|
|
786
|
-
resolve(
|
|
788
|
+
resolve(path8);
|
|
787
789
|
}
|
|
788
790
|
count++;
|
|
789
791
|
}, retryDuration);
|
|
790
792
|
});
|
|
791
793
|
} else {
|
|
792
|
-
logger.info(`Docs already written to cache at ${
|
|
793
|
-
finish(logger,
|
|
794
|
-
return
|
|
794
|
+
logger.info(`Docs already written to cache at ${path8}`);
|
|
795
|
+
finish(logger, path8);
|
|
796
|
+
return path8;
|
|
795
797
|
}
|
|
796
798
|
} catch (e) {
|
|
797
799
|
logger.error("Existing doc JSON corrupt. Aborting");
|
|
@@ -808,28 +810,28 @@ var docgenHandler = (options, logger, docgen = actualDocGen, retryDuration = RET
|
|
|
808
810
|
process.exit(9);
|
|
809
811
|
}
|
|
810
812
|
logger.success(`Generating docs for ${specifier}`);
|
|
811
|
-
const
|
|
812
|
-
ensurePath(
|
|
813
|
+
const path8 = `${repoDir}/docs/${specifier}.json`;
|
|
814
|
+
ensurePath(path8);
|
|
813
815
|
const handleError = () => {
|
|
814
816
|
logger.info("Removing placeholder");
|
|
815
|
-
rmSync(
|
|
817
|
+
rmSync(path8);
|
|
816
818
|
};
|
|
817
819
|
try {
|
|
818
|
-
const existing = readFileSync(
|
|
820
|
+
const existing = readFileSync(path8, "utf8");
|
|
819
821
|
const json = JSON.parse(existing);
|
|
820
822
|
if (json && json.timeout && Date.now() - json.timeout >= TIMEOUT_MS) {
|
|
821
823
|
logger.info(`Expired placeholder found. Removing.`);
|
|
822
|
-
rmSync(
|
|
824
|
+
rmSync(path8);
|
|
823
825
|
throw new Error("TIMEOUT");
|
|
824
826
|
}
|
|
825
|
-
return waitForDocs(json,
|
|
827
|
+
return waitForDocs(json, path8, logger, retryDuration);
|
|
826
828
|
} catch (e) {
|
|
827
829
|
if (e.message !== "TIMEOUT") {
|
|
828
|
-
logger.info(`Docs JSON not found at ${
|
|
830
|
+
logger.info(`Docs JSON not found at ${path8}`);
|
|
829
831
|
}
|
|
830
832
|
logger.debug("Generating placeholder");
|
|
831
|
-
generatePlaceholder(
|
|
832
|
-
return generateDocs(specifier,
|
|
833
|
+
generatePlaceholder(path8);
|
|
834
|
+
return generateDocs(specifier, path8, docgen, logger).catch((e2) => {
|
|
833
835
|
logger.error("Error generating documentation");
|
|
834
836
|
logger.error(e2);
|
|
835
837
|
handleError();
|
|
@@ -878,16 +880,17 @@ var docsHandler = async (options, logger) => {
|
|
|
878
880
|
logger.success(`Showing docs for ${adaptorName} v${version}`);
|
|
879
881
|
}
|
|
880
882
|
logger.info("Generating/loading documentation...");
|
|
881
|
-
const
|
|
883
|
+
const path8 = await handler_default5(
|
|
882
884
|
{
|
|
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;
|
|
889
|
-
if (
|
|
890
|
-
const source = await readFile2(
|
|
892
|
+
if (path8) {
|
|
893
|
+
const source = await readFile2(path8, "utf8");
|
|
891
894
|
const data = JSON.parse(source);
|
|
892
895
|
let desc;
|
|
893
896
|
if (operation) {
|
|
@@ -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;
|
|
@@ -1033,10 +1036,50 @@ var metadataHandler = async (options, logger) => {
|
|
|
1033
1036
|
};
|
|
1034
1037
|
var handler_default7 = metadataHandler;
|
|
1035
1038
|
|
|
1039
|
+
// src/pull/handler.ts
|
|
1040
|
+
import path5 from "path";
|
|
1041
|
+
import fs3 from "node:fs/promises";
|
|
1042
|
+
import {
|
|
1043
|
+
getProject,
|
|
1044
|
+
getConfig as getConfig2,
|
|
1045
|
+
getState
|
|
1046
|
+
} from "@openfn/deploy";
|
|
1047
|
+
async function pullHandler(options, logger) {
|
|
1048
|
+
try {
|
|
1049
|
+
const config = mergeOverrides2(await getConfig2(options.configPath), options);
|
|
1050
|
+
logger.always("Downloading project yaml and state from instance");
|
|
1051
|
+
const state = await getState(config.statePath);
|
|
1052
|
+
const { data: new_state } = await getProject(config, state.id);
|
|
1053
|
+
const url = new URL(`/download/yaml?id=${state.id}`, config.endpoint);
|
|
1054
|
+
const res = await fetch(url);
|
|
1055
|
+
await fs3.writeFile(path5.resolve(config.specPath), res.body);
|
|
1056
|
+
await fs3.writeFile(path5.resolve(config.statePath), new_state);
|
|
1057
|
+
logger.success("Project pulled successfully");
|
|
1058
|
+
process.exitCode = 0;
|
|
1059
|
+
return true;
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
throw error;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
function mergeOverrides2(config, options) {
|
|
1065
|
+
return {
|
|
1066
|
+
...config,
|
|
1067
|
+
apiKey: pickFirst2(process.env["OPENFN_API_KEY"], config.apiKey),
|
|
1068
|
+
endpoint: pickFirst2(process.env["OPENFN_ENDPOINT"], config.endpoint),
|
|
1069
|
+
configPath: options.configPath,
|
|
1070
|
+
requireConfirmation: pickFirst2(options.confirm, config.requireConfirmation)
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
function pickFirst2(...args) {
|
|
1074
|
+
return args.find((arg) => arg !== void 0 && arg !== null);
|
|
1075
|
+
}
|
|
1076
|
+
var handler_default8 = pullHandler;
|
|
1077
|
+
|
|
1036
1078
|
// src/util/ensure-opts.ts
|
|
1037
|
-
import
|
|
1079
|
+
import path6 from "node:path";
|
|
1038
1080
|
var defaultLoggerOptions = {
|
|
1039
1081
|
default: "default",
|
|
1082
|
+
// TODO fix to lower case
|
|
1040
1083
|
job: "debug"
|
|
1041
1084
|
};
|
|
1042
1085
|
var ERROR_MESSAGE_LOG_LEVEL = "Unknown log level. Valid levels are none, debug, info and default.";
|
|
@@ -1086,6 +1129,7 @@ var ensureLogOpts = (opts) => {
|
|
|
1086
1129
|
function ensureOpts(basePath = ".", opts) {
|
|
1087
1130
|
const newOpts = {
|
|
1088
1131
|
adaptor: opts.adaptor,
|
|
1132
|
+
// only applies to install (a bit messy) (now applies to docs too)
|
|
1089
1133
|
adaptors: opts.adaptors || [],
|
|
1090
1134
|
autoinstall: opts.autoinstall,
|
|
1091
1135
|
command: opts.command,
|
|
@@ -1093,6 +1137,7 @@ function ensureOpts(basePath = ".", opts) {
|
|
|
1093
1137
|
force: opts.force || false,
|
|
1094
1138
|
immutable: opts.immutable || false,
|
|
1095
1139
|
log: opts.log,
|
|
1140
|
+
// TMP this will be overwritten later
|
|
1096
1141
|
logJson: typeof opts.logJson == "boolean" ? opts.logJson : Boolean(process.env.OPENFN_LOG_JSON),
|
|
1097
1142
|
compile: Boolean(opts.compile),
|
|
1098
1143
|
operation: opts.operation,
|
|
@@ -1112,7 +1157,7 @@ function ensureOpts(basePath = ".", opts) {
|
|
|
1112
1157
|
}
|
|
1113
1158
|
let baseDir = basePath;
|
|
1114
1159
|
if (basePath.endsWith(".js")) {
|
|
1115
|
-
baseDir =
|
|
1160
|
+
baseDir = path6.dirname(basePath);
|
|
1116
1161
|
set2("jobPath", basePath);
|
|
1117
1162
|
} else {
|
|
1118
1163
|
set2("jobPath", `${baseDir}/job.js`);
|
|
@@ -1130,7 +1175,7 @@ function ensureOpts(basePath = ".", opts) {
|
|
|
1130
1175
|
|
|
1131
1176
|
// src/util/print-versions.ts
|
|
1132
1177
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
1133
|
-
import
|
|
1178
|
+
import path7 from "node:path";
|
|
1134
1179
|
import { getNameAndVersion as getNameAndVersion6 } from "@openfn/runtime";
|
|
1135
1180
|
import { mainSymbols } from "figures";
|
|
1136
1181
|
var NODE = "node.js";
|
|
@@ -1140,7 +1185,7 @@ var COMPILER2 = "compiler";
|
|
|
1140
1185
|
var { triangleRightSmall: t } = mainSymbols;
|
|
1141
1186
|
var loadVersionFromPath = (adaptorPath) => {
|
|
1142
1187
|
try {
|
|
1143
|
-
const pkg = JSON.parse(readFileSync3(
|
|
1188
|
+
const pkg = JSON.parse(readFileSync3(path7.resolve(adaptorPath, "package.json"), "utf8"));
|
|
1144
1189
|
return pkg.version;
|
|
1145
1190
|
} catch (e) {
|
|
1146
1191
|
return "unknown";
|
|
@@ -1173,7 +1218,7 @@ var printVersions = async (logger, options = {}) => {
|
|
|
1173
1218
|
adaptorName
|
|
1174
1219
|
].map((s) => s.length));
|
|
1175
1220
|
const prefix = (str) => ` ${t} ${str.padEnd(longest + 4, " ")}`;
|
|
1176
|
-
const pkg = await import("
|
|
1221
|
+
const pkg = await import("../package-JMR2GBIW.js");
|
|
1177
1222
|
const { version, dependencies } = pkg.default;
|
|
1178
1223
|
const compilerVersion = dependencies["@openfn/compiler"];
|
|
1179
1224
|
const runtimeVersion = dependencies["@openfn/runtime"];
|
|
@@ -1212,13 +1257,20 @@ var handlers = {
|
|
|
1212
1257
|
docgen: handler_default5,
|
|
1213
1258
|
docs: handler_default6,
|
|
1214
1259
|
metadata: handler_default7,
|
|
1260
|
+
pull: handler_default8,
|
|
1215
1261
|
["repo-clean"]: clean,
|
|
1216
1262
|
["repo-install"]: install,
|
|
1217
1263
|
["repo-pwd"]: pwd,
|
|
1218
1264
|
["repo-list"]: list,
|
|
1219
1265
|
version: async (opts, logger) => print_versions_default(logger, opts)
|
|
1220
1266
|
};
|
|
1221
|
-
var maybeEnsureOpts = (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
|
+
);
|
|
1222
1274
|
var parse = async (basePath, options, log) => {
|
|
1223
1275
|
const opts = maybeEnsureOpts(basePath, options);
|
|
1224
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.1
|
|
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.
|
|
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": "^
|
|
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.
|
|
43
|
-
"@openfn/deploy": "0.1
|
|
44
|
-
"@openfn/
|
|
45
|
-
"@openfn/logger": "0.0.
|
|
46
|
-
"@openfn/
|
|
47
|
-
"@openfn/compiler": "0.0.
|
|
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",
|