-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcommand.ts
More file actions
64 lines (60 loc) · 1.53 KB
/
command.ts
File metadata and controls
64 lines (60 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import yargs from 'yargs';
import { Opts } from '../options';
import * as o from '../options';
import { build, ensure, override } from '../util/command-builders';
export type CompileOptions = Pick<
Opts,
| 'adaptors'
| 'command'
| 'expandAdaptors'
| 'ignoreImports'
| 'expressionPath'
| 'logJson'
| 'log'
| 'outputPath'
| 'outputStdout'
| 'repoDir'
| 'path'
| 'useAdaptorsMonorepo'
| 'globals'
> & {
workflow?: Opts['workflow'];
repoDir?: string;
};
const options = [
o.expandAdaptors, // order important
o.adaptors,
o.ignoreImports,
o.inputPath,
o.log,
o.logJson,
override(o.outputStdout, {
default: true,
}),
o.outputPath,
o.repoDir,
o.useAdaptorsMonorepo,
o.workflow,
];
const compileCommand: yargs.CommandModule<CompileOptions> = {
command: 'compile [path]',
describe:
'Compile an openfn job or workflow and print or save the resulting JavaScript.',
handler: ensure('compile', options),
builder: (yargs) =>
build(options, yargs)
.positional('path', {
describe:
'The path to load the job or workflow from (a .js or .json file or a dir containing a job.js file)',
demandOption: true,
})
.example(
'compile foo/job.js',
'Compiles the job at foo/job.js and prints the result to stdout'
)
.example(
'compile foo/workflow.json -o foo/workflow-compiled.json',
'Compiles the workflow at foo/work.json and prints the result to -o foo/workflow-compiled.json'
),
};
export default compileCommand;