@taqueria/plugin-ligo 0.0.0-pr-436-e7e3929e → 0.0.0-pr-436-ea8737d2

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/compile.ts CHANGED
@@ -15,9 +15,12 @@ const getInputFilename = (opts: Opts) => (sourceFile: string) => {
15
15
  }
16
16
 
17
17
  const getCompileCommand = (opts: Opts) => (sourceFile: string) => {
18
- const {projectDir} = opts
18
+ const projectDir = process.env.PROJECT_DIR ?? opts.projectDir
19
+
20
+ if (!projectDir) throw `No project directory provided`
21
+
19
22
  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}`
23
+ const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project ligolang/ligo:0.41.0 compile contract ${inputFile}`
21
24
  const entryPoint = opts.e ? `-e ${opts.e}` : ""
22
25
  const syntax = opts["-s"] ? `s ${opts['s']} : ""` : ""
23
26
  const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`
package/index.js CHANGED
@@ -16,9 +16,10 @@ const $24b2f47d8f306cb3$var$getInputFilename = (opts)=>(sourceFile)=>{
16
16
  }
17
17
  ;
18
18
  const $24b2f47d8f306cb3$var$getCompileCommand = (opts)=>(sourceFile)=>{
19
- const { projectDir: projectDir } = opts;
19
+ const projectDir = process.env.PROJECT_DIR ?? opts.projectDir;
20
+ if (!projectDir) throw `No project directory provided`;
20
21
  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}`;
22
+ const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project ligolang/ligo:0.41.0 compile contract ${inputFile}`;
22
23
  const entryPoint = opts.e ? `-e ${opts.e}` : "";
23
24
  const syntax = opts["-s"] ? `s ${opts['s']} : ""` : "";
24
25
  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,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;KACpD;AAAA;AAED,MAAM,uCAAiB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAC9D,MAAM,EAjBV,YAiBW,UAAU,CAAA,EAAC,GAAG,IAAI;QACzB,MAAM,SAAS,GAAG,sCAAgB,CAAE,IAAI,CAAC,CAAE,UAAU,CAAC;QACtD,MAAM,WAAW,GAAG,CAAC,yDAAyD,EAAE,UAAU,CAAC,4DAA4D,EAAE,SAAS,CAAC,CAAC;QACpK,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QACtD,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,iDAA2B,C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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 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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AM,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 const projectDir = process.env.PROJECT_DIR ?? opts.projectDir\n\n if (!projectDir) throw `No project directory provided`\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-436-e7e3929e",
3
+ "version": "0.0.0-pr-436-ea8737d2",
4
4
  "description": "A taqueria plugin for compiling LIGO smart contracts",
5
5
  "targets": {
6
6
  "default": {