@openfn/cli 0.0.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/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # @openfn/cli (devtools)
2
+
3
+ This package contains a new devtools CLI.
4
+
5
+ The CLI allows you to
6
+ * Run a job (expression), writing output to disk or stdout
7
+ * ~~Compile a job~~ (coming soon)
8
+ * ~~Validate a job~~ (coming soon)
9
+ * Use local language adaptors to run the job
10
+
11
+ The CLI reads a path as its main argument. That path should either point to a .js file or a folder.
12
+
13
+ * If the path ends in .js, load as a job file and execute. State and output will be read/written relative to it.
14
+ * If the path is a folder, the CLI will look for a job.js, state.json and write an output.json.
15
+
16
+ From this input it will infer a working directory, from which state will be read and output will be written.
17
+
18
+ All inputs and outputs can be configured with arguments.
19
+
20
+ Run `pnpm openfn -h` to print usage help (the best source of truth right now).
21
+
22
+ ## Usage from the global CLI
23
+
24
+ See Getting Started for more setup steps.
25
+
26
+ ```
27
+ $ npm install -g @openfn/cli`
28
+ $ openfn --help
29
+ $ openfn path/to/expression.js`
30
+ ```
31
+
32
+ ## legacy Jobs failing?
33
+
34
+ If legacy jobs ar failing because adaptor functions aren't found, you need to tell the CLI which adaptor to use. It will then auto-insert import statements for you.
35
+
36
+ ```
37
+ $ openfn job.js -a @openfn/language-commmon
38
+ ```
39
+
40
+ There's more detail in this further down in the readme.
41
+
42
+ ## Usage from this repo
43
+
44
+ You can run the cli straight from source with `pnpm`
45
+
46
+ ```
47
+ $ pnpm openfn path/to/job.js
48
+ $ pnpm openfn -h
49
+ ```
50
+
51
+ See test/execute.test.ts for more usage examples
52
+
53
+ ## Installing globally
54
+
55
+ To install the CLI globally from this repo (ie, to do `openfn job.js` instead of `pnpm openfn job.js`), run:
56
+
57
+ ```
58
+ $ npm install -g .
59
+ ```
60
+
61
+ Note that this will install the built source from `dist`
62
+
63
+ ## Current state
64
+
65
+ For legacy jobs (ie, jobs without explicit imports), the new runtime is only compatible with language adaptors with type definitions.
66
+
67
+ Right now, that means @openfn/language-common@2.0.0-rc3.
68
+
69
+ ## Getting Started
70
+
71
+ Here's how I recommend getting set up:
72
+
73
+ * Create a folder for next-gen language adaptors somewhere on your machine
74
+
75
+ ```
76
+ $ mkdir -p ~/adaptors/@openfn
77
+ ```
78
+
79
+ * Clone `language-common` into that folder
80
+
81
+ ```
82
+ git clone https://github.com/OpenFn/language-common.git ~/adaptors/@openfn --branch 2.0.0-pre
83
+ ```
84
+
85
+ * Set your `OPENFN_MODULES_HOME` environment variable to point to the next-gen adaptors folder. This will tell the CLI to load adaptors from this folder by default.
86
+
87
+ ```
88
+ # In ~/.bashc or whatever
89
+ export OPENFN_MODULES_HOME=~/adaptors/@openfn
90
+ ```
91
+
92
+ This will improve in future, as we implement automatic module loading and add type definitions to the published adaptor packages.
93
+
94
+ ## Automatic Imports
95
+
96
+ The v2 runtime requires explicit imports to be in the job file, or else the job will fail.
97
+
98
+ The v2 compiler can automatically insert import statements, but it needs to be told which adaptor to use.
99
+
100
+ ```
101
+ $ openfn job.js --adaptors @openfn/language-http
102
+ $ openfn job.js --adaptors @openfn/language-http=path/to/adaptor
103
+ ```
104
+
105
+ If a path is passed (relative to the working directory), that path will be used to load a local version of the adaptor (both at runtime and for import generation)
106
+
107
+ If no path is passed, the currently deployed npm package will be used.
108
+
109
+ ## Notes on Module Resolution
110
+
111
+ Any import statements inside a job have to resolve to a node module.
112
+
113
+ A module can be resolved:
114
+
115
+ * Relative to the env var OPENFN_MODULE_HOME
116
+ * Relative to CLI's node_modules
117
+ * Relative to global node_modules
118
+
119
+ Basically, to work with adaptors, you should:
120
+
121
+ * Save your adaptors globally
122
+
123
+ Or
124
+
125
+ * Save adaptors to a folder somewhere (~/openfn) and set OPENFN_MODULE_HOME=~/openfn
package/dist/cli.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import yargs from 'yargs';
2
+ export declare const cmd: yargs.Argv<{
3
+ path: unknown;
4
+ } & {
5
+ "output-path": unknown;
6
+ } & {
7
+ "output-stdout": boolean | undefined;
8
+ } & {
9
+ "state-path": unknown;
10
+ } & {
11
+ "state-stdin": unknown;
12
+ } & {
13
+ "no-validation": boolean | undefined;
14
+ } & {
15
+ "no-compile": boolean | undefined;
16
+ } & {
17
+ adaptors: (string | number)[] | undefined;
18
+ } & {
19
+ "trace-linker": boolean | undefined;
20
+ }>;
@@ -0,0 +1,14 @@
1
+ export declare type Opts = {
2
+ silent?: boolean;
3
+ jobPath?: string;
4
+ statePath?: string;
5
+ stateStdin?: string;
6
+ outputPath?: string;
7
+ outputStdout?: boolean;
8
+ modulesHome?: string;
9
+ adaptors?: string[];
10
+ noCompile?: boolean;
11
+ traceLinker?: boolean;
12
+ };
13
+ export declare const execute: (basePath: string, options: Opts) => Promise<void>;
14
+ export default execute;
@@ -0,0 +1,6 @@
1
+ import { TransformOptions } from '@openfn/compiler';
2
+ import type { SafeOpts } from '../util/ensure-opts';
3
+ declare const _default: (opts: SafeOpts, log?: (message?: any, ...optionalParams: any[]) => void) => Promise<string>;
4
+ export default _default;
5
+ export declare const stripVersionSpecifier: (specifier: string) => string;
6
+ export declare const loadTransformOptions: (opts: SafeOpts, log?: (_str: string) => void) => Promise<TransformOptions>;
@@ -0,0 +1,3 @@
1
+ import type { SafeOpts } from '../util/ensure-opts';
2
+ declare const _default: (code: string, state: any, opts: SafeOpts) => Promise<any>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { SafeOpts } from '../util/ensure-opts';
2
+ declare const _default: (opts: SafeOpts, log?: (message?: any, ...optionalParams: any[]) => void) => Promise<any>;
3
+ export default _default;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+ import path from 'node:path';
3
+ import { fork } from 'node:child_process';
4
+ import yargs from 'yargs';
5
+ import { hideBin } from 'yargs/helpers';
6
+
7
+ /**
8
+ * Utility to run CLI commands inside a child process
9
+ * This lets us hide the neccessary arguments needed to run our devtools
10
+ */
11
+ // The default export will create a new child process which calls itself
12
+ function runInChildProcess (basePath, opts) {
13
+ const execArgv = [
14
+ // Suppress experimental argument warnings
15
+ '--no-warnings',
16
+ // Allows us to load an ESM module from a text string
17
+ '--experimental-vm-modules',
18
+ // Allows us to do import('path/to/language-common') in the linker
19
+ '--experimental-specifier-resolution=node',
20
+ ];
21
+ const child = fork(path.resolve('dist/process/child-process.js'), [], { execArgv });
22
+ child.on('message', ({ done }) => {
23
+ if (done) {
24
+ child.kill();
25
+ process.exit(0);
26
+ }
27
+ });
28
+ child.send({ basePath, opts });
29
+ }
30
+
31
+ const cmd = yargs(hideBin(process.argv))
32
+ .command('openfn [path]', "Run the job at the path")
33
+ .example('openfn path/to/dir', 'Looks for job.js, state.json in path/to/dir')
34
+ .example('openfn foo/job.js', 'Reads foo/job.js, looks for state and output in foo')
35
+ .example('openfn job.js -adaptor @openfn/language-common', 'Run job.js with automatic imports from the commmon language adaptor')
36
+ .example('openfn job.js -adaptor @openfn/language-common=repo/openfn/language-common', 'Run job.js with a local implementation of the common language adaptor')
37
+ .positional('path', {
38
+ describe: 'The path to load the job from (a .js file or a dir containing a job.js file)',
39
+ demandOption: true
40
+ })
41
+ .option('output-path', {
42
+ alias: 'o',
43
+ description: 'Path to the output file',
44
+ })
45
+ .option('output-stdout', {
46
+ alias: 'O',
47
+ boolean: true,
48
+ description: 'Print output to stdout (intead of a file)',
49
+ })
50
+ .option('state-path', {
51
+ alias: 's',
52
+ description: 'Path to the state file'
53
+ })
54
+ .option('state-stdin', {
55
+ alias: 'S',
56
+ description: 'Read state from stdin (instead of a file)'
57
+ })
58
+ .option('no-validation', {
59
+ boolean: true,
60
+ description: 'Skip validation'
61
+ })
62
+ .option('no-compile', {
63
+ boolean: true,
64
+ description: 'Skip compilation'
65
+ })
66
+ .option('adaptors', {
67
+ alias: ['a', 'adaptor'],
68
+ description: 'Pass one or more adaptors in the form name[]=path/to/adaptor]',
69
+ array: true
70
+ })
71
+ .option('trace-linker', {
72
+ alias: ['t', 'trace'],
73
+ description: 'Trace module resolution output in the linker',
74
+ boolean: true,
75
+ });
76
+
77
+ const opts = cmd.parse();
78
+ const basePath = opts._[0];
79
+ if (basePath) {
80
+ // If all inputs have parsed OK, we can go ahead and run in a child process
81
+ runInChildProcess(basePath, opts);
82
+ }
83
+ else {
84
+ console.error('ERROR: no path provided!');
85
+ console.error('\nUsage:');
86
+ console.error(' open path/to/job.js');
87
+ console.error('\nFor more help do:');
88
+ console.error(' openfn --help ');
89
+ }
90
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../packages/cli/src/process/spawn.ts","../packages/cli/src/cli.ts","../packages/cli/src/index.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;;;AAAA,CAAA,CAAA,CAAA;;;AAGG,CAAA,CAAA,CAAA;AAKH,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACyB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgB,CAAE,C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A,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqB,CAAC,CAAC;AACrC,CAAA,CAAA,CAAA,CAAA,OAAO,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAkB,CAAC,CAAC;AACnC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,203 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import compile$1, { preloadAdaptorExports } from '@openfn/compiler';
4
+ import run$1 from '@openfn/runtime';
5
+
6
+ function ensureOpts(basePath, opts) {
7
+ const newOpts = {
8
+ noCompile: opts.noCompile,
9
+ outputStdout: opts.outputStdout ?? false,
10
+ silent: opts.silent,
11
+ stateStdin: opts.stateStdin,
12
+ traceLinker: opts.traceLinker,
13
+ modulesHome: opts.modulesHome || process.env.OPENFN_MODULES_HOME,
14
+ };
15
+ const set = (key, value) => {
16
+ // @ts-ignore TODO
17
+ newOpts[key] = opts.hasOwnProperty(key) ? opts[key] : value;
18
+ };
19
+ let baseDir = basePath;
20
+ if (basePath.endsWith('.js')) {
21
+ baseDir = path.dirname(basePath);
22
+ set('jobPath', basePath);
23
+ }
24
+ else {
25
+ set('jobPath', `${baseDir}/job.js`);
26
+ }
27
+ set('statePath', `${baseDir}/state.json`);
28
+ if (!opts.outputStdout) {
29
+ set('outputPath', `${baseDir}/output.json`);
30
+ }
31
+ // TODO if no adaptor is provided, default to language common
32
+ // Should we go further and bundle language-common?
33
+ // But 90% of jobs use something else. Better to use auto loading.
34
+ if (opts.adaptors) {
35
+ newOpts.adaptors = opts.adaptors;
36
+ // newOpts.adaptors = opts.adaptors.map((adaptor) => {
37
+ // if (!adaptor.startsWith('@openfn/')) {
38
+ // return `@openfn/${adaptor}`
39
+ // }
40
+ // return adaptor
41
+ // });
42
+ }
43
+ return newOpts;
44
+ }
45
+
46
+ // Dumb utility for typings and defaults
47
+ var defaultLogger = console.log;
48
+
49
+ // Load and compile a job from a file
50
+ var compile = async (opts, log = defaultLogger) => {
51
+ // TODO to make output more readable this should use log groups
52
+ log(`Loading job from ${opts.jobPath}`);
53
+ if (opts.noCompile) {
54
+ log('Skipping compilation');
55
+ return fs.readFile(opts.jobPath, 'utf8');
56
+ }
57
+ else {
58
+ log('Compiling job source');
59
+ const options = await loadTransformOptions(opts, log);
60
+ return compile$1(opts.jobPath, options);
61
+ }
62
+ };
63
+ // TODO this is a bit of a temporary solution
64
+ // Adaptors need a version specifier right now to load type definitions for auto import
65
+ // But that specifier must be excluded in the actual import by the adaptor
66
+ const stripVersionSpecifier = (specifier) => {
67
+ const idx = specifier.lastIndexOf('@');
68
+ if (idx > 0) {
69
+ return specifier.substring(0, idx);
70
+ }
71
+ return specifier;
72
+ };
73
+ // Mutate the opts object to write export information for the add-imports transformer
74
+ const loadTransformOptions = async (opts, log = (_str) => { }) => {
75
+ const options = {};
76
+ // If an adaptor is passed in, we need to look up its declared exports
77
+ // and pass them along to the compiler
78
+ if (opts.adaptors) {
79
+ const [pattern] = opts.adaptors; // TODO add-imports only takes on adaptor, but the cli can take multiple
80
+ const [specifier, path] = pattern.split('=');
81
+ // Preload exports from a path, optionally logging errors in case of a failure
82
+ const doPreload = async (path, logError = true) => {
83
+ try {
84
+ const result = await preloadAdaptorExports(path);
85
+ if (result) {
86
+ log(`Compiler loading typedefs for ${specifier} from ${path}`);
87
+ }
88
+ return result;
89
+ }
90
+ catch (e) {
91
+ if (logError) {
92
+ console.error(`error processing adaptors from path ${path}`);
93
+ console.error(e);
94
+ }
95
+ }
96
+ };
97
+ // TODO need better trace/debug output on this I think
98
+ // Looking up the adaptor's type definition is complex. In this order, we should use:
99
+ const exports =
100
+ // 1) An explicit file path
101
+ (path && await doPreload(path)) ||
102
+ // 2) A module defined in the opts.modulesHome folder
103
+ (opts.modulesHome && await doPreload(`${opts.modulesHome}/${specifier}`, false)) ||
104
+ // 3) An npm module specifier
105
+ await doPreload(specifier);
106
+ if (exports) {
107
+ options['add-imports'] = {
108
+ adaptor: {
109
+ name: stripVersionSpecifier(specifier),
110
+ exports
111
+ }
112
+ };
113
+ }
114
+ else {
115
+ console.error(`Failed to load exports for ${pattern}`);
116
+ }
117
+ }
118
+ return options;
119
+ };
120
+
121
+ var loadState = async (opts, log = defaultLogger) => {
122
+ if (opts.stateStdin) {
123
+ try {
124
+ log('Reading state from stdin');
125
+ return JSON.parse(opts.stateStdin);
126
+ }
127
+ catch (e) {
128
+ console.error("Failed to load state from stdin");
129
+ console.error(opts.stateStdin);
130
+ process.exit(1);
131
+ }
132
+ }
133
+ try {
134
+ log(`Loading state from ${opts.statePath}`);
135
+ const str = await fs.readFile(opts.statePath, 'utf8');
136
+ return JSON.parse(str);
137
+ }
138
+ catch (e) {
139
+ console.warn('Error loading state!');
140
+ console.log(e);
141
+ }
142
+ log('Using default state');
143
+ return {
144
+ data: {},
145
+ configuration: {}
146
+ };
147
+ };
148
+
149
+ var run = (code, state, opts) => {
150
+ return run$1(code, state, {
151
+ linker: {
152
+ modulesHome: opts.modulesHome,
153
+ modulePaths: parseAdaptors(opts),
154
+ trace: opts.traceLinker
155
+ }
156
+ });
157
+ };
158
+ // TODO we should throw if the adaptor strings are invalid for any reason
159
+ function parseAdaptors(opts) {
160
+ const adaptors = {};
161
+ opts.adaptors?.reduce((obj, exp) => {
162
+ const [module, path] = exp.split('=');
163
+ obj[module] = path;
164
+ return obj;
165
+ }, adaptors);
166
+ return adaptors;
167
+ }
168
+
169
+ const execute = async (basePath, options) => {
170
+ console.log(basePath);
171
+ const opts = ensureOpts(basePath, options);
172
+ const log = (...args) => {
173
+ if (!opts.silent) {
174
+ console.log(...args);
175
+ }
176
+ };
177
+ const state = await loadState(opts, log);
178
+ const code = await compile(opts, log);
179
+ const result = await run(code, state, opts);
180
+ if (opts.outputStdout) {
181
+ // Log this even if in silent mode
182
+ console.log(`\nResult: `);
183
+ console.log(result);
184
+ }
185
+ else {
186
+ if (!opts.silent) {
187
+ console.log(`Writing output to ${opts.outputPath}`);
188
+ }
189
+ await fs.writeFile(opts.outputPath, JSON.stringify(result, null, 4));
190
+ }
191
+ log(`\nDone! ✨`);
192
+ };
193
+
194
+ console.log("foo");
195
+ // When receiving a message as a child process, we pull out the args and run
196
+ process.on('message', ({ basePath, opts }) => {
197
+ if (basePath && typeof basePath === 'string') {
198
+ execute(basePath, opts).then(() => {
199
+ process.send({ done: true });
200
+ });
201
+ }
202
+ });
203
+ //# sourceMappingURL=child-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child-process.js","sources":["../../packages/cli/src/util/ensure-opts.ts","../../packages/cli/src/util/default-logger.ts","../../packages/cli/src/compile/load-job.ts","../../packages/cli/src/execute/load-state.ts","../../packages/cli/src/execute/execute.ts","../../packages/cli/src/commands.ts","../../packages/cli/src/process/child-process.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["compile","run"],"mappings":";;;;;AAKc,SAAU,UAAU,CAAC,QAAgB,EAAE,IAAU,EAAA;AAC7D,IAAA,MAAM,OAAO,GAAG;QACd,SAAS,EAAE,IAAI,CAAC,SAAS;AACzB,QAAA,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,KAAK;QACxC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB;KACzD,CAAC;AAEV,IAAA,MAAM,GAAG,GAAG,CAAC,GAAe,EAAE,KAAa,KAAI;;QAE7C,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAA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Q,KAAK,QAAQ,EAAE;QAC5C,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAK;YAChC,OAAO,CAAC,IAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAChC,SAAC,CAAC,CAAC;AACJ,KAAA;AACH,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import yargs from 'yargs';
2
+ export declare const cmd: yargs.Argv<{
3
+ path: unknown;
4
+ } & {
5
+ "output-path": unknown;
6
+ } & {
7
+ "output-stdout": boolean | undefined;
8
+ } & {
9
+ "state-path": unknown;
10
+ } & {
11
+ "state-stdin": unknown;
12
+ } & {
13
+ "no-validation": boolean | undefined;
14
+ } & {
15
+ "no-compile": boolean | undefined;
16
+ } & {
17
+ adaptors: (string | number)[] | undefined;
18
+ } & {
19
+ "trace-linker": boolean | undefined;
20
+ }>;
@@ -0,0 +1,14 @@
1
+ export declare type Opts = {
2
+ silent?: boolean;
3
+ jobPath?: string;
4
+ statePath?: string;
5
+ stateStdin?: string;
6
+ outputPath?: string;
7
+ outputStdout?: boolean;
8
+ modulesHome?: string;
9
+ adaptors?: string[];
10
+ noCompile?: boolean;
11
+ traceLinker?: boolean;
12
+ };
13
+ export declare const execute: (basePath: string, options: Opts) => Promise<void>;
14
+ export default execute;
@@ -0,0 +1,6 @@
1
+ import { TransformOptions } from '@openfn/compiler';
2
+ import type { SafeOpts } from '../util/ensure-opts';
3
+ declare const _default: (opts: SafeOpts, log?: (message?: any, ...optionalParams: any[]) => void) => Promise<string>;
4
+ export default _default;
5
+ export declare const stripVersionSpecifier: (specifier: string) => string;
6
+ export declare const loadTransformOptions: (opts: SafeOpts, log?: (_str: string) => void) => Promise<TransformOptions>;
@@ -0,0 +1,3 @@
1
+ import type { SafeOpts } from '../util/ensure-opts';
2
+ declare const _default: (code: string, state: any, opts: SafeOpts) => Promise<any>;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { SafeOpts } from '../util/ensure-opts';
2
+ declare const _default: (opts: SafeOpts, log?: (message?: any, ...optionalParams: any[]) => void) => Promise<any>;
3
+ export default _default;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Opts } from '../commands';
2
+ export default function (basePath: string, opts: Opts): void;
@@ -0,0 +1,2 @@
1
+ import type { Opts } from '../commands';
2
+ export default function (basePath: string, opts: Opts): void;
@@ -0,0 +1,2 @@
1
+ declare const _default: (message?: any, ...optionalParams: any[]) => void;
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { Opts } from '../commands';
2
+ export declare type SafeOpts = Required<Opts>;
3
+ export default function ensureOpts(basePath: string, opts: Opts): SafeOpts;
@@ -0,0 +1,2 @@
1
+ declare const _default: (message?: any, ...optionalParams: any[]) => void;
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { Opts } from '../commands';
2
+ export declare type SafeOpts = Required<Opts>;
3
+ export default function ensureOpts(basePath: string, opts: Opts): SafeOpts;
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@openfn/cli",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "engines": {
6
+ "node": ">=16",
7
+ "pnpm": ">=7"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ }
16
+ },
17
+ "type": "module",
18
+ "bin": {
19
+ "openfn": "dist/index.js"
20
+ },
21
+ "module": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "keywords": [],
24
+ "author": "Joe Clark<jclark@openfn.org>",
25
+ "license": "ISC",
26
+ "devDependencies": {
27
+ "@openfn/language-common": "2.0.0-rc3",
28
+ "@rollup/plugin-typescript": "^8.3.2",
29
+ "@types/node": "^17.0.45",
30
+ "esbuild": "^0.15.7",
31
+ "rimraf": "^3.0.2",
32
+ "rollup": "^2.72.1",
33
+ "rollup-plugin-dts": "^4.2.1",
34
+ "rollup-plugin-preserve-shebang": "^1.0.1",
35
+ "ts-node": "^10.8.1",
36
+ "tslib": "^2.4.0",
37
+ "typescript": "^4.7.4"
38
+ },
39
+ "dependencies": {
40
+ "@openfn/compiler": "^0.0.2",
41
+ "@openfn/runtime": "^0.0.1",
42
+ "@types/yargs": "^17.0.12",
43
+ "ava": "^4.2.0",
44
+ "mock-fs": "^5.1.4",
45
+ "tsm": "^2.2.2",
46
+ "yargs": "^17.5.1"
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "README.md"
51
+ ],
52
+ "scripts": {
53
+ "test": "pnpm ava",
54
+ "test:watch": "pnpm ava -w",
55
+ "build": "rimraf dist/ .rollup.cache ts.cache && rollup -c",
56
+ "build:watch": "pnpm rollup -cw --no-watch.clearScreen",
57
+ "openfn": "node --no-warnings dist/index.js"
58
+ }
59
+ }