diff --git a/README.md b/README.md index 0ae86f6..e6ad2f5 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,21 @@ Design principals: * Useful default behaviors when not specified * Be fun to use -Note! Although cwl-ex tool already offers a lot of functionality, the -error reporting still needs a lot of work. If you are trying to use -it and running into problems, please file an issue. +# Quickstart using Docker -# Installation: +Build a self-contained script (no imports) + +``` +cwl-runner cwlex.cwl --inp myscript.cwlex +``` + +Build script with imports: + +``` +cwl-runner cwlex.cwl --inpdir . --inpfile myscript.cwlex +``` + +# Installing ``` npm install cwl-ex @@ -235,20 +245,30 @@ def workflow main(v1="hello", v2="world") { Generate the parser (requires antlr4): ``` -$ cwl-runner antlr.cwl +$ cd src && cwl-runner antlr.cwl ``` -Install dependencies (requires node.js and npm): - +Run local code in Docker ``` -$ npm install +cwl-runner cwlex.cwl --inp src/cwlex-dev.cwlex +cwl-runner cwlex-dev.cwl --inp myscript.cwlex ``` Run tests: ``` -$ ./cwlex.js cwlex-tests.cwlex > cwlex-tests.cwl +$ cwl-runner cwlex.cwl --inpdir . --inpfile cwlex-tests.cwlex $ cwl-runner cwlex-tests.cwl ``` -TODO: Create Docker image with antlr4, nodejs and dependencies. \ No newline at end of file +Install dependencies (requires node.js and npm): + +``` +$ npm install +``` + +Generate Docker image +``` +npm pack +docker build -f cwlex.Dockerfile . +``` diff --git a/README.md.tmpl b/README.md.tmpl index 77e9f02..a58ff60 100644 --- a/README.md.tmpl +++ b/README.md.tmpl @@ -10,11 +10,21 @@ Design principals: * Useful default behaviors when not specified * Be fun to use -Note! Although cwl-ex tool already offers a lot of functionality, the -error reporting still needs a lot of work. If you are trying to use -it and running into problems, please file an issue. +# Quickstart using Docker -# Installation: +Build a self-contained script (no imports) + +``` +cwl-runner cwlex.cwl --inp myscript.cwlex +``` + +Build script with imports: + +``` +cwl-runner cwlex.cwl --inpdir . --inpfile myscript.cwlex +``` + +# Installing ``` npm install cwl-ex @@ -159,20 +169,30 @@ $include: ex14.cwlex Generate the parser (requires antlr4): ``` -$ cwl-runner antlr.cwl +$ cd src && cwl-runner antlr.cwl ``` -Install dependencies (requires node.js and npm): - +Run local code in Docker ``` -$ npm install +cwl-runner cwlex.cwl --inp src/cwlex-dev.cwlex +cwl-runner cwlex-dev.cwl --inp myscript.cwlex ``` Run tests: ``` -$ ./cwlex.js cwlex-tests.cwlex > cwlex-tests.cwl +$ cwl-runner cwlex.cwl --inpdir . --inpfile cwlex-tests.cwlex $ cwl-runner cwlex-tests.cwl ``` -TODO: Create Docker image with antlr4, nodejs and dependencies. \ No newline at end of file +Install dependencies (requires node.js and npm): + +``` +$ npm install +``` + +Generate Docker image +``` +npm pack +docker build -f cwlex.Dockerfile . +``` diff --git a/cwlex-tests.cwlex b/cwlex-tests.cwlex index 0a40ac6..f698298 100644 --- a/cwlex-tests.cwlex +++ b/cwlex-tests.cwlex @@ -1,4 +1,4 @@ -import "cwlex.cwlex" as cwlex +import "src/cwlex.cwlex" as cwlex def workflow main( cases = [ diff --git a/cwlex.Dockerfile b/cwlex.Dockerfile new file mode 100644 index 0000000..ef18edd --- /dev/null +++ b/cwlex.Dockerfile @@ -0,0 +1,5 @@ +from node:slim + +COPY cwl-ex-1.0.0.tgz /root + +RUN npm install --global /root/cwl-ex-1.0.0.tgz diff --git a/src/cwlex.cwlex b/src/cwlex.cwlex index 3e81d0f..5be5605 100644 --- a/src/cwlex.cwlex +++ b/src/cwlex.cwlex @@ -1,26 +1,17 @@ def tool main( - cwlex = File("cwlex.js", "cwlex-convert.js", "cwlexLexer.js", "cwlexListener.js", "cwlexParser.js"), - node_modules = Directory("node_modules"), inp? File, inpdir? Directory, inpfile? string, outname? string) { requirements { - InitialWorkDirRequirement { - listing: [{ - entry: "$(inputs.node_modules)" - }, { - entry: "$(inputs.cwlex)" - }] - } - DockerRequirement { dockerPull: "node:slim" } + DockerRequirement { dockerPull: "commonworkflowlanguage/cwlex" } InlineJavascriptRequirement { expressionLib: [" function outname(inputs) { return inputs.outname ? inputs.outname : (inputs.inp ? inputs.inp.nameroot+'.cwl' : inputs.inpfile.replace(/(.*)\.cwlex/, '$1.cwl')); } "]} } - nodejs $(inputs.cwlex) "$(inputs.inp ? inputs.inp.path : inputs.inpdir.path+'/'+inputs.inpfile)" > "$(outname(inputs))" + cwlex "$(inputs.inp ? inputs.inp.path : inputs.inpdir.path+'/'+inputs.inpfile)" > "$(outname(inputs))" return File(outname(inputs)) as converted } \ No newline at end of file