@taqueria/plugin-ligo 0.0.0-pr-575-e34f9ec4 → 0.0.0-pr-704-db506596

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 CHANGED
@@ -1,6 +1,13 @@
1
1
  # Taqueria LIGO Plugin
2
2
 
3
- The LIGO plugin provides a task to compile LIGO smart contracts to Michelson `.tz` files
3
+ This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK and distributed via NPM
4
+
5
+ The LIGO plugin exposes a compile task in Taqueria which can target one, or all the LIGO contracts in the contracts folder and compile them to Michelson code output to the artifacts folder
6
+
7
+ ## Tasks
8
+
9
+ The LIGO plugin provides the following tasks to Taqueria:
10
+ - `compile`
4
11
 
5
12
  ## Requirements
6
13
 
@@ -10,51 +17,15 @@ The LIGO plugin provides a task to compile LIGO smart contracts to Michelson `.t
10
17
 
11
18
  ## Installation
12
19
 
20
+ The LIGO plugin is distributed as an NPM package that can be installed and uninstalled on a project from the Taqueria CLI
21
+
13
22
  To install the LIGO plugin on a Taqueria project, navigate to the project folder and run:
14
23
  ```shell
15
24
  taq install @taqueria/plugin-ligo
16
25
  ```
17
26
 
18
- > ### :page_with_curl: Note
19
- > At this time, all Taqueria projects must also be initialized as node projects by running `npm init -y` from the root of your project directory
20
-
21
- ## Configuration
22
-
23
- No additional configuration is available
24
- ## Usage
25
-
26
- The LIGO plugin exposes a `compile` task in Taqueria which can target one, or all the LIGO contracts in the `contracts` folder and compile them to Michelson `.tz` files output to the `artifacts` folder
27
-
28
- ### Running the Compile Task
29
-
30
- The LIGO plugin's `taq compile` task can be run with or without arguments. The basic syntax for the task is `taq compile <file-name>`
31
-
32
- Running the `compile` task with no options will result in any source LIGO smart contracts in the `contracts` folder being compiled to Michelson files in the `artifacts` folder. If you speficy an optional filename, only LIGO contracts matching the specified filename in the `contracts` folder will be compiled
33
-
34
- > ### :warning: CAUTION
35
- > The `compile` task can be implemented by more than one compiler plugin installed on a project (LIGO, SmartPY). If this is the case, you must use the `--plugin ligo` flag to specify a particular compiler
36
-
37
- ### Options
38
-
39
- The LIGO `compile` task will accept the following optional parameters:
40
-
41
- | flag | name | description |
42
- |:-----:|:------------|---------------------------------------|
43
- | -e | entry-point | The entry point that will be compiled |
44
- | -s | syntax | The syntax used in the contract |
45
- | -i | infer | Enable type inference |
46
-
47
-
48
27
  ## Plugin Architecture
49
28
 
50
- This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
51
-
52
- Docker is used under the hood to provide a self contained environment for LIGO to prevent the need for it to be installed on the user's local machine
53
-
54
- The plugin provides a single task `compile`, used for compiling LIGO smart contracts to Michelson:
29
+ This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK and distributed via NPM
55
30
 
56
- | attribute | value |
57
- |------------|:------------------------:|
58
- | task | 'compile' |
59
- | command | 'compile [sourceFile] |
60
- | aliases | ['c', 'compile-ligo'] |
31
+ For detailed usage and configuration information, view the LIGO plugin documentation on the Taqueria website [here](https://taqueria.io/docs/plugins/plugin-ligo)
package/compile.ts CHANGED
@@ -15,9 +15,13 @@ const getInputFilename = (opts: Opts) => (sourceFile: string) => {
15
15
  }
16
16
 
17
17
  const getCompileCommand = (opts: Opts) => (sourceFile: string) => {
18
- const {projectDir} = opts
18
+ let {projectDir} = opts
19
+ // if process.env.PROJECT_DIR is not null
20
+ if (process.env.PROJECT_DIR && process.env.PROJECT_DIR?.length > 0) {
21
+ projectDir = process.env.PROJECT_DIR
22
+ }
19
23
  const inputFile = getInputFilename (opts) (sourceFile)
20
- const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project ligolang/ligo:next compile contract ${inputFile}`
24
+ const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project ligolang/ligo:0.41.0 compile contract ${inputFile}`
21
25
  const entryPoint = opts.e ? `-e ${opts.e}` : ""
22
26
  const syntax = opts["-s"] ? `s ${opts['s']} : ""` : ""
23
27
  const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`
package/index.js CHANGED
@@ -16,9 +16,11 @@ const $24b2f47d8f306cb3$var$getInputFilename = (opts)=>(sourceFile)=>{
16
16
  }
17
17
  ;
18
18
  const $24b2f47d8f306cb3$var$getCompileCommand = (opts)=>(sourceFile)=>{
19
- const { projectDir: projectDir } = opts;
19
+ let { projectDir: projectDir } = opts;
20
+ // if process.env.PROJECT_DIR is not null
21
+ if (process.env.PROJECT_DIR && process.env.PROJECT_DIR?.length > 0) projectDir = process.env.PROJECT_DIR;
20
22
  const inputFile = $24b2f47d8f306cb3$var$getInputFilename(opts)(sourceFile);
21
- const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project ligolang/ligo:next compile contract ${inputFile}`;
23
+ const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project ligolang/ligo:0.41.0 compile contract ${inputFile}`;
22
24
  const entryPoint = opts.e ? `-e ${opts.e}` : "";
23
25
  const syntax = opts["-s"] ? `s ${opts['s']} : ""` : "";
24
26
  const outFile = `-o ${$24b2f47d8f306cb3$var$getContractArtifactFilename(opts)(sourceFile)}`;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;ACAA;;;AAOA,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QACxE,MAAM,OAAO,GAAG,oBAAQ,CAAC,UAAU,EAAE,mBAAO,CAAC,UAAU,CAAC,CAAC;QACzD,OAAO,gBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;KACzD;AAAA;AAED,MAAM,sCAAgB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAC7D,OAAO,gBAAI,CAAC,IAAI,CAAC,MAAM,CA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AI,EAAE,UAAU;wBAAE,GAAG,EAAE,IAAI;qBAAC;iBACjF;aACJ,CAAC;QAAA;QACF,0BAA0B,EAAE,IAAM,OAAO,CAAC,OAAO,CAAC;gBAC9C,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,iCAAiC,CAAC,4BAA4B;aACzE,CAAC;QAAA;QACF,KAAK,EAAE,wCAAO;KACjB,CAAA;AAAC,EAAE,OAAO,CAAC,IAAI,CAAC","sources":["taqueria-plugin-ligo/index.ts","taqueria-plugin-ligo/compile.ts"],"sourcesContent":["import {Plugin, Task, Option} from '@taqueria/node-sdk'\nimport compile from './compile'\n\nPlugin.create(i18n => ({\n schema: \"1.0\",\n version: \"0.1\",\n alias: \"ligo\",\n tasks: [\n Task.create({\n task: \"compile\",\n command: \"compile [sourceFile]\",\n aliases: [\"c\", \"compile-ligo\"],\n description: \"Compile a smart contract written in a Ligo syntax to Michelson code\",\n options: [\n Option.create({\n shortFlag: \"e\",\n flag: \"entry-point\",\n description: \"The entry point that will be compiled\"\n }),\n Option.create({\n shortFlag: \"s\",\n flag: \"syntax\",\n description: \"The syntax used in the contract\"\n }),\n Option.create({\n shortFlag: \"i\",\n flag: \"infer\",\n description: \"Enable type inference\"\n })\n ],\n handler: 'proxy',\n encoding: 'json'\n })\n ],\n checkRuntimeDependencies: () => Promise.resolve({\n status: \"success\",\n report: [\n {name: \"LIGO\", path: \"ligo\", version: \">=0.27.0\", kind: \"required\", met: true}\n ]\n }),\n installRunTimeDependencies: () => Promise.resolve({\n status: \"success\",\n output: \"LIGO was found in /usr/bin/ligo\" // TODO this should use i18n\n }),\n proxy: compile\n}), process.argv)","import {execCmd, getArch, sendAsyncErr, sendJsonRes, sendErr} from '@taqueria/node-sdk'\nimport {SanitizedArgs, PluginResponse, Failure, LikeAPromise} from \"@taqueria/node-sdk/types\";\nimport {extname, basename, join} from 'path'\nimport glob = require('fast-glob')\n\ntype Opts = SanitizedArgs & Record<string, unknown>\n\nconst getContractArtifactFilename = (opts: Opts) => (sourceFile: string) => {\n const outFile = basename(sourceFile, extname(sourceFile))\n return join(opts.config.artifactsDir, `${outFile}.tz`)\n}\n\nconst getInputFilename = (opts: Opts) => (sourceFile: string) => {\n return join(opts.config.contractsDir, sourceFile)\n}\n\nconst getCompileCommand = (opts: Opts) => (sourceFile: string) => {\n const {projectDir} = opts\n const inputFile = getInputFilename (opts) (sourceFile)\n const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project ligolang/ligo:next compile contract ${inputFile}`\n const entryPoint = opts.e ? `-e ${opts.e}` : \"\"\n const syntax = opts[\"-s\"] ? `s ${opts['s']} : \"\"` : \"\"\n const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`\n const cmd = `${baseCommand} ${entryPoint} ${syntax} ${outFile}`\n return cmd\n}\n\nconst compileContract = (opts: Opts) => (sourceFile: string): Promise<{contract: string, artifact: string}> =>\n getArch()\n .then(() => getCompileCommand (opts) (sourceFile))\n .then(execCmd)\n .then(({stderr}) => { // How should we output warnings?\n if (stderr.length > 0) sendErr(stderr)\n return {\n contract: sourceFile,\n artifact: getContractArtifactFilename (opts) (sourceFile)\n }\n })\n .catch(err => {\n sendErr(\" \")\n sendErr(err.message.split(\"\\n\").slice(1).join(\"\\n\"))\n return Promise.resolve({\n contract: sourceFile,\n artifact: \"Not compiled\"\n })\n })\n\nconst compileAll = (parsedArgs: Opts): Promise<{contract: string, artifact: string}[]> => {\n // TODO: Fetch list of files from SDK\n return glob(\n ['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n {cwd: parsedArgs.contractsDir, absolute: false}\n )\n .then(entries => entries.map(compileContract (parsedArgs)))\n .then(processes => processes.length > 0\n ? processes\n : [{contract: \"None found\", artifact: \"N/A\"}]\n )\n .then(promises => Promise.all(promises))\n}\n\nexport const compile = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, Failure<T>> => {\n const p = parsedArgs.sourceFile\n ? compileContract (parsedArgs) (parsedArgs.sourceFile as string)\n .then(result => [result])\n : compileAll(parsedArgs)\n .then(results => {\n if (results.length === 0) sendErr(\"No contracts found to compile.\")\n return results\n })\n \n return p\n .then(sendJsonRes)\n .catch(err => sendAsyncErr(err, false))\n}\n\nexport default compile"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;AAAA;ACAA;;;AAOA,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QACxE,MAAM,OAAO,GAAG,oBAAQ,CAAC,UAAU,EAAE,mBAAO,CAAC,UAAU,CAAC,CAAC;QACzD,OAAO,gBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;KACzD;AAAA;AAED,MAAM,sCAAgB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAC7D,OAAO,gBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;KACpD;AAAA;AAED,MAAM,uCAAiB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAC9D,IAAI,EAjBR,YAiBS,UAAU,CAAA,EAAC,GAAG,IAAI;QACvB,0CAA0C;QAC1C,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,CAAC,EAC9D,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW;QAExC,MAAM,SAAS,GAAG,sCAAgB,CAAE,IAAI,CAAC,CAAE,UAAU,CAAC;QACtD,MAAM,WAAW,GAAG,CAAC,yDAAyD,EAAE,UAAU,CAAC,8DAA8D,EAAE,SAAS,CAAC,CAAC;QACtK,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;QAC/C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I,CAAC,MAAM,CAAC;gBACR,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,sBAAsB;gBAC/B,OAAO,EAAE;oBAAC,GAAG;oBAAE,cAAc;iBAAC;gBAC9B,WAAW,EAAE,qEAAqE;gBAClF,OAAO,EAAE;oBACL,6BAAM,CAAC,MAAM,CAAC;wBACV,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,aAAa;wBACnB,WAAW,EAAE,uCAAuC;qBACvD,CAAC;oBACF,6BAAM,CAAC,MAAM,CAAC;wBACV,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,iCAAiC;qBACjD,CAAC;oBACF,6BAAM,CAAC,MAAM,CAAC;wBACV,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,uBAAuB;qBACvC,CAAC;iBACL;gBACD,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,MAAM;aACnB,CAAC;SACL;QACD,wBAAwB,EAAE,IAAM,OAAO,CAAC,OAAO,CAAC;gBAC5C,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE;oBACJ;wBAAC,IAAI,EAAE,MAAM;wBAAE,IAAI,EAAE,MAAM;wBAAE,OAAO,EAAE,UAAU;wBAAE,IAAI,EAAE,UAAU;wBAAE,GAAG,EAAE,IAAI;qBAAC;iBACjF;aACJ,CAAC;QAAA;QACF,0BAA0B,EAAE,IAAM,OAAO,CAAC,OAAO,CAAC;gBAC9C,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,iCAAiC,CAAC,4BAA4B;aACzE,CAAC;QAAA;QACF,KAAK,EAAE,wCAAO;KACjB,CAAA;AAAC,EAAE,OAAO,CAAC,IAAI,CAAC","sources":["taqueria-plugin-ligo/index.ts","taqueria-plugin-ligo/compile.ts"],"sourcesContent":["import {Plugin, Task, Option} from '@taqueria/node-sdk'\nimport compile from './compile'\n\nPlugin.create(i18n => ({\n schema: \"1.0\",\n version: \"0.1\",\n alias: \"ligo\",\n tasks: [\n Task.create({\n task: \"compile\",\n command: \"compile [sourceFile]\",\n aliases: [\"c\", \"compile-ligo\"],\n description: \"Compile a smart contract written in a Ligo syntax to Michelson code\",\n options: [\n Option.create({\n shortFlag: \"e\",\n flag: \"entry-point\",\n description: \"The entry point that will be compiled\"\n }),\n Option.create({\n shortFlag: \"s\",\n flag: \"syntax\",\n description: \"The syntax used in the contract\"\n }),\n Option.create({\n shortFlag: \"i\",\n flag: \"infer\",\n description: \"Enable type inference\"\n })\n ],\n handler: 'proxy',\n encoding: 'json'\n })\n ],\n checkRuntimeDependencies: () => Promise.resolve({\n status: \"success\",\n report: [\n {name: \"LIGO\", path: \"ligo\", version: \">=0.27.0\", kind: \"required\", met: true}\n ]\n }),\n installRunTimeDependencies: () => Promise.resolve({\n status: \"success\",\n output: \"LIGO was found in /usr/bin/ligo\" // TODO this should use i18n\n }),\n proxy: compile\n}), process.argv)","import {execCmd, getArch, sendAsyncErr, sendJsonRes, sendErr} from '@taqueria/node-sdk'\nimport {SanitizedArgs, PluginResponse, Failure, LikeAPromise} from \"@taqueria/node-sdk/types\";\nimport {extname, basename, join} from 'path'\nimport glob = require('fast-glob')\n\ntype Opts = SanitizedArgs & Record<string, unknown>\n\nconst getContractArtifactFilename = (opts: Opts) => (sourceFile: string) => {\n const outFile = basename(sourceFile, extname(sourceFile))\n return join(opts.config.artifactsDir, `${outFile}.tz`)\n}\n\nconst getInputFilename = (opts: Opts) => (sourceFile: string) => {\n return join(opts.config.contractsDir, sourceFile)\n}\n\nconst getCompileCommand = (opts: Opts) => (sourceFile: string) => {\n let {projectDir} = opts\n // if process.env.PROJECT_DIR is not null \n if (process.env.PROJECT_DIR && process.env.PROJECT_DIR?.length > 0) {\n projectDir = process.env.PROJECT_DIR\n }\n const inputFile = getInputFilename (opts) (sourceFile)\n const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project ligolang/ligo:0.41.0 compile contract ${inputFile}`\n const entryPoint = opts.e ? `-e ${opts.e}` : \"\"\n const syntax = opts[\"-s\"] ? `s ${opts['s']} : \"\"` : \"\"\n const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`\n const cmd = `${baseCommand} ${entryPoint} ${syntax} ${outFile}`\n return cmd\n}\n\nconst compileContract = (opts: Opts) => (sourceFile: string): Promise<{contract: string, artifact: string}> =>\n getArch()\n .then(() => getCompileCommand (opts) (sourceFile))\n .then(execCmd)\n .then(({stderr}) => { // How should we output warnings?\n if (stderr.length > 0) sendErr(stderr)\n return {\n contract: sourceFile,\n artifact: getContractArtifactFilename (opts) (sourceFile)\n }\n })\n .catch(err => {\n sendErr(\" \")\n sendErr(err.message.split(\"\\n\").slice(1).join(\"\\n\"))\n return Promise.resolve({\n contract: sourceFile,\n artifact: \"Not compiled\"\n })\n })\n\nconst compileAll = (parsedArgs: Opts): Promise<{contract: string, artifact: string}[]> => {\n // TODO: Fetch list of files from SDK\n return glob(\n ['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n {cwd: parsedArgs.contractsDir, absolute: false}\n )\n .then(entries => entries.map(compileContract (parsedArgs)))\n .then(processes => processes.length > 0\n ? processes\n : [{contract: \"None found\", artifact: \"N/A\"}]\n )\n .then(promises => Promise.all(promises))\n}\n\nexport const compile = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, Failure<T>> => {\n const p = parsedArgs.sourceFile\n ? compileContract (parsedArgs) (parsedArgs.sourceFile as string)\n .then(result => [result])\n : compileAll(parsedArgs)\n .then(results => {\n if (results.length === 0) sendErr(\"No contracts found to compile.\")\n return results\n })\n \n return p\n .then(sendJsonRes)\n .catch(err => sendAsyncErr(err, false))\n}\n\nexport default compile"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-ligo",
3
- "version": "0.0.0-pr-575-e34f9ec4",
3
+ "version": "0.0.0-pr-704-db506596",
4
4
  "description": "A taqueria plugin for compiling LIGO smart contracts",
5
5
  "targets": {
6
6
  "default": {
package/_readme.eta DELETED
@@ -1,64 +0,0 @@
1
- <% if (it.output == "github") { %>
2
- # Taqueria LIGO Plugin
3
- <% } %>
4
-
5
- The LIGO plugin provides a task to compile LIGO smart contracts to Michelson `.tz` files
6
-
7
- ## Requirements
8
-
9
- - Taqueria v0.0.6 or later
10
- - Node.js v16 or later
11
- - Docker v0.8.4 or later
12
-
13
- ## Installation
14
-
15
- To install the LIGO plugin on a Taqueria project, navigate to the project folder and run:
16
- ```shell
17
- taq install @taqueria/plugin-ligo
18
- ```
19
-
20
- <%~ it.noteOpenAdmonition %>
21
- At this time, all Taqueria projects must also be initialized as node projects by running `npm init -y` from the root of your project directory
22
- <%= it.closeAdmonition %>
23
-
24
- ## Configuration
25
-
26
- No additional configuration is available
27
- ## Usage
28
-
29
- The LIGO plugin exposes a `compile` task in Taqueria which can target one, or all the LIGO contracts in the `contracts` folder and compile them to Michelson `.tz` files output to the `artifacts` folder
30
-
31
- ### Running the Compile Task
32
-
33
- The LIGO plugin's `taq compile` task can be run with or without arguments. The basic syntax for the task is `taq compile <file-name>`
34
-
35
- Running the `compile` task with no options will result in any source LIGO smart contracts in the `contracts` folder being compiled to Michelson files in the `artifacts` folder. If you speficy an optional filename, only LIGO contracts matching the specified filename in the `contracts` folder will be compiled
36
-
37
- <%~ it.cautionOpenAdmonition %>
38
- The `compile` task can be implemented by more than one compiler plugin installed on a project (LIGO, SmartPY). If this is the case, you must use the `--plugin ligo` flag to specify a particular compiler
39
- <%= it.closeAdmonition %>
40
-
41
- ### Options
42
-
43
- The LIGO `compile` task will accept the following optional parameters:
44
-
45
- | flag | name | description |
46
- |:-----:|:------------|---------------------------------------|
47
- | -e | entry-point | The entry point that will be compiled |
48
- | -s | syntax | The syntax used in the contract |
49
- | -i | infer | Enable type inference |
50
-
51
-
52
- ## Plugin Architecture
53
-
54
- This is a plugin developed for Taqueria built on NodeJS using the Taqueria Node SDK
55
-
56
- Docker is used under the hood to provide a self contained environment for LIGO to prevent the need for it to be installed on the user's local machine
57
-
58
- The plugin provides a single task `compile`, used for compiling LIGO smart contracts to Michelson:
59
-
60
- | attribute | value |
61
- |------------|:------------------------:|
62
- | task | 'compile' |
63
- | command | 'compile [sourceFile] |
64
- | aliases | ['c', 'compile-ligo'] |