@taqueria/plugin-ligo 0.0.0-pr-776-23cf48f8 → 0.0.0-pr-779-eaf2ca6a

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.
Files changed (3) hide show
  1. package/index.js +45 -32
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -7,72 +7,82 @@ var $kQNfl$fastglob = require("fast-glob");
7
7
 
8
8
 
9
9
  const $24b2f47d8f306cb3$var$getContractArtifactFilename = (opts)=>(sourceFile)=>{
10
- const outFile = (0, $kQNfl$path.basename)(sourceFile, (0, $kQNfl$path.extname)(sourceFile));
11
- return (0, $kQNfl$path.join)(opts.config.artifactsDir, `${outFile}.tz`);
12
- };
10
+ const outFile = $kQNfl$path.basename(sourceFile, $kQNfl$path.extname(sourceFile));
11
+ return $kQNfl$path.join(opts.config.artifactsDir, `${outFile}.tz`);
12
+ }
13
+ ;
13
14
  const $24b2f47d8f306cb3$var$getInputFilename = (opts)=>(sourceFile)=>{
14
- return (0, $kQNfl$path.join)(opts.config.contractsDir, sourceFile);
15
- };
15
+ return $kQNfl$path.join(opts.config.contractsDir, sourceFile);
16
+ }
17
+ ;
16
18
  const $24b2f47d8f306cb3$var$getCompileCommand = (opts)=>(sourceFile)=>{
17
19
  const projectDir = process.env.PROJECT_DIR ?? opts.projectDir;
18
20
  if (!projectDir) throw `No project directory provided`;
19
21
  const inputFile = $24b2f47d8f306cb3$var$getInputFilename(opts)(sourceFile);
20
22
  const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project ligolang/ligo:next compile contract ${inputFile}`;
21
23
  const entryPoint = opts.entrypoint ? `-e ${opts.entrypoint}` : "";
22
- const syntax = opts["syntax"] ? `-s ${opts["syntax"]} : ""` : "";
24
+ const syntax = opts["syntax"] ? `-s ${opts['syntax']} : ""` : "";
23
25
  const outFile = `-o ${$24b2f47d8f306cb3$var$getContractArtifactFilename(opts)(sourceFile)}`;
24
26
  const cmd = `${baseCommand} ${entryPoint} ${syntax} ${outFile}`;
25
27
  return cmd;
26
- };
27
- const $24b2f47d8f306cb3$var$compileContract = (opts)=>(sourceFile)=>(0, $kQNfl$taquerianodesdk.getArch)().then(()=>$24b2f47d8f306cb3$var$getCompileCommand(opts)(sourceFile)).then((0, $kQNfl$taquerianodesdk.execCmd)).then(({ stderr: stderr })=>{
28
- if (stderr.length > 0) (0, $kQNfl$taquerianodesdk.sendErr)(stderr);
28
+ }
29
+ ;
30
+ const $24b2f47d8f306cb3$var$compileContract = (opts)=>(sourceFile)=>$kQNfl$taquerianodesdk.getArch().then(()=>$24b2f47d8f306cb3$var$getCompileCommand(opts)(sourceFile)
31
+ ).then($kQNfl$taquerianodesdk.execCmd).then(({ stderr: stderr })=>{
32
+ if (stderr.length > 0) $kQNfl$taquerianodesdk.sendErr(stderr);
29
33
  return {
30
34
  contract: sourceFile,
31
35
  artifact: $24b2f47d8f306cb3$var$getContractArtifactFilename(opts)(sourceFile)
32
36
  };
33
37
  }).catch((err)=>{
34
- (0, $kQNfl$taquerianodesdk.sendErr)(" ");
35
- (0, $kQNfl$taquerianodesdk.sendErr)(err.message.split("\n").slice(1).join("\n"));
38
+ $kQNfl$taquerianodesdk.sendErr(" ");
39
+ $kQNfl$taquerianodesdk.sendErr(err.message.split("\n").slice(1).join("\n"));
36
40
  return Promise.resolve({
37
41
  contract: sourceFile,
38
42
  artifact: "Not compiled"
39
43
  });
40
- });
44
+ })
45
+ ;
41
46
  const $24b2f47d8f306cb3$var$compileAll = (parsedArgs)=>{
42
47
  // TODO: Fetch list of files from SDK
43
48
  return $kQNfl$fastglob([
44
- "**/*.ligo",
45
- "**/*.religo",
46
- "**/*.mligo",
47
- "**/*.jsligo"
49
+ '**/*.ligo',
50
+ '**/*.religo',
51
+ '**/*.mligo',
52
+ '**/*.jsligo'
48
53
  ], {
49
54
  cwd: parsedArgs.config.contractsDir,
50
55
  absolute: false
51
- }).then((entries)=>entries.map($24b2f47d8f306cb3$var$compileContract(parsedArgs))).then((processes)=>processes.length > 0 ? processes : [
56
+ }).then((entries)=>entries.map($24b2f47d8f306cb3$var$compileContract(parsedArgs))
57
+ ).then((processes)=>processes.length > 0 ? processes : [
52
58
  {
53
59
  contract: "None found",
54
60
  artifact: "N/A"
55
61
  }
56
- ]).then((promises)=>Promise.all(promises));
62
+ ]
63
+ ).then((promises)=>Promise.all(promises)
64
+ );
57
65
  };
58
66
  const $24b2f47d8f306cb3$export$ef7acd7185315e22 = (parsedArgs)=>{
59
67
  const p = parsedArgs.sourceFile ? $24b2f47d8f306cb3$var$compileContract(parsedArgs)(parsedArgs.sourceFile).then((result)=>[
60
68
  result
61
- ]) : $24b2f47d8f306cb3$var$compileAll(parsedArgs).then((results)=>{
62
- if (results.length === 0) (0, $kQNfl$taquerianodesdk.sendErr)("No contracts found to compile.");
69
+ ]
70
+ ) : $24b2f47d8f306cb3$var$compileAll(parsedArgs).then((results)=>{
71
+ if (results.length === 0) $kQNfl$taquerianodesdk.sendErr("No contracts found to compile.");
63
72
  return results;
64
73
  });
65
- return p.then((0, $kQNfl$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $kQNfl$taquerianodesdk.sendAsyncErr)(err, false));
74
+ return p.then($kQNfl$taquerianodesdk.sendJsonRes).catch((err)=>$kQNfl$taquerianodesdk.sendAsyncErr(err, false)
75
+ );
66
76
  };
67
77
  var $24b2f47d8f306cb3$export$2e2bcd8739ae039 = $24b2f47d8f306cb3$export$ef7acd7185315e22;
68
78
 
69
79
 
70
- (0, $kQNfl$taquerianodesdk.Plugin).create((i18n)=>({
80
+ $kQNfl$taquerianodesdk.Plugin.create((i18n)=>({
71
81
  schema: "1.0",
72
82
  version: "0.1",
73
83
  alias: "ligo",
74
84
  tasks: [
75
- (0, $kQNfl$taquerianodesdk.Task).create({
85
+ $kQNfl$taquerianodesdk.Task.create({
76
86
  task: "compile",
77
87
  command: "compile [sourceFile]",
78
88
  aliases: [
@@ -81,24 +91,24 @@ var $24b2f47d8f306cb3$export$2e2bcd8739ae039 = $24b2f47d8f306cb3$export$ef7acd71
81
91
  ],
82
92
  description: "Compile a smart contract written in a Ligo syntax to Michelson code",
83
93
  options: [
84
- (0, $kQNfl$taquerianodesdk.Option).create({
94
+ $kQNfl$taquerianodesdk.Option.create({
85
95
  shortFlag: "e",
86
96
  flag: "entrypoint",
87
97
  description: "The entry point that will be compiled"
88
98
  }),
89
- (0, $kQNfl$taquerianodesdk.Option).create({
99
+ $kQNfl$taquerianodesdk.Option.create({
90
100
  shortFlag: "s",
91
101
  flag: "syntax",
92
102
  description: "The syntax used in the contract"
93
103
  }),
94
- (0, $kQNfl$taquerianodesdk.Option).create({
104
+ $kQNfl$taquerianodesdk.Option.create({
95
105
  shortFlag: "i",
96
106
  flag: "infer",
97
107
  description: "Enable type inference"
98
108
  })
99
109
  ],
100
- handler: "proxy",
101
- encoding: "json"
110
+ handler: 'proxy',
111
+ encoding: 'json'
102
112
  })
103
113
  ],
104
114
  checkRuntimeDependencies: ()=>Promise.resolve({
@@ -112,13 +122,16 @@ var $24b2f47d8f306cb3$export$2e2bcd8739ae039 = $24b2f47d8f306cb3$export$ef7acd71
112
122
  met: true
113
123
  }
114
124
  ]
115
- }),
125
+ })
126
+ ,
116
127
  installRunTimeDependencies: ()=>Promise.resolve({
117
128
  status: "success",
118
129
  output: "LIGO was found in /usr/bin/ligo" // TODO this should use i18n
119
- }),
120
- proxy: (0, $24b2f47d8f306cb3$export$2e2bcd8739ae039)
121
- }), process.argv);
130
+ })
131
+ ,
132
+ proxy: $24b2f47d8f306cb3$export$2e2bcd8739ae039
133
+ })
134
+ , process.argv);
122
135
 
123
136
 
124
137
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;ACAA;;;AAWA,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QACxE,MAAM,OAAO,GAAG,CAAA,G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SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,YAAY;wBAClB,WAAW,EAAE,uCAAuC;qBACvD,CAAC;oBACF,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC;wBACV,SAAS,EAAE,GAAG;wBACd,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,iCAAiC;qBACjD,CAAC;oBACF,CAAA,GAAA,6BAAM,CAAA,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;QACF,0BAA0B,EAAE,IAAM,OAAO,CAAC,OAAO,CAAC;gBAC9C,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,iCAAiC,CAAC,4BAA4B;aACzE,CAAC;QACF,KAAK,EAAE,CAAA,GAAA,wCAAO,CAAA;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: \"entrypoint\",\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 {RequestArgs, PluginResponse, LikeAPromise} from \"@taqueria/node-sdk/types\";\nimport {extname, basename, join} from 'path'\nimport glob = require('fast-glob')\n\ninterface Opts extends RequestArgs.t {\n entrypoint?: string\n syntax?: string\n sourceFile?: string\n}\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:next compile contract ${inputFile}`\n const entryPoint = opts.entrypoint ? `-e ${opts.entrypoint}` : \"\"\n const syntax = opts[\"syntax\"] ? `-s ${opts['syntax']} : \"\"` : \"\"\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.config.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 = (parsedArgs: Opts): Promise<PluginResponse> => {\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;;;AAWA,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,sCA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C;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: \"entrypoint\",\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 {RequestArgs, PluginResponse, LikeAPromise} from \"@taqueria/node-sdk/types\";\nimport {extname, basename, join} from 'path'\nimport glob = require('fast-glob')\n\ninterface Opts extends RequestArgs.t {\n entrypoint?: string\n syntax?: string\n sourceFile?: string\n}\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:next compile contract ${inputFile}`\n const entryPoint = opts.entrypoint ? `-e ${opts.entrypoint}` : \"\"\n const syntax = opts[\"syntax\"] ? `-s ${opts['syntax']} : \"\"` : \"\"\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.config.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 = (parsedArgs: Opts): Promise<PluginResponse> => {\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-776-23cf48f8",
3
+ "version": "0.0.0-pr-779-eaf2ca6a",
4
4
  "description": "A taqueria plugin for compiling LIGO smart contracts",
5
5
  "targets": {
6
6
  "default": {