@taqueria/plugin-archetype 0.0.0-pr-776-b4c3aaa5 → 0.0.0-pr-786-5e56f0fc

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 +37 -25
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -10,13 +10,15 @@ function $parcel$interopDefault(a) {
10
10
 
11
11
 
12
12
  const $bb055a91efa18df7$var$getInputFilename = (opts)=>(sourceFile)=>{
13
- const inputFile = (0, $dTHpf$path.basename)(sourceFile, (0, $dTHpf$path.extname)(sourceFile));
14
- return (0, $dTHpf$path.join)(opts.config.contractsDir, `${inputFile}.arl`);
15
- };
13
+ const inputFile = $dTHpf$path.basename(sourceFile, $dTHpf$path.extname(sourceFile));
14
+ return $dTHpf$path.join(opts.config.contractsDir, `${inputFile}.arl`);
15
+ }
16
+ ;
16
17
  const $bb055a91efa18df7$var$getContractArtifactFilename = (opts)=>(sourceFile)=>{
17
- const outFile = (0, $dTHpf$path.basename)(sourceFile, (0, $dTHpf$path.extname)(sourceFile));
18
- return (0, $dTHpf$path.join)(opts.config.artifactsDir, `${outFile}.tz`);
19
- };
18
+ const outFile = $dTHpf$path.basename(sourceFile, $dTHpf$path.extname(sourceFile));
19
+ return $dTHpf$path.join(opts.config.artifactsDir, `${outFile}.tz`);
20
+ }
21
+ ;
20
22
  const $bb055a91efa18df7$var$getCompileCommand = (opts)=>(sourceFile)=>{
21
23
  const { projectDir: projectDir } = opts;
22
24
  const inputFile = $bb055a91efa18df7$var$getInputFilename(opts)(sourceFile);
@@ -24,54 +26,61 @@ const $bb055a91efa18df7$var$getCompileCommand = (opts)=>(sourceFile)=>{
24
26
  const outFile = `-o ${$bb055a91efa18df7$var$getContractArtifactFilename(opts)(sourceFile)}`;
25
27
  const cmd = `${baseCommand} ${outFile}`;
26
28
  return cmd;
27
- };
29
+ }
30
+ ;
28
31
  const $bb055a91efa18df7$var$compileContract = (opts)=>(sourceFile)=>// const sourceAbspath = join(opts.contractsDir, sourceFile)
29
- (0, $dTHpf$taquerianodesdk.execCmd)($bb055a91efa18df7$var$getCompileCommand(opts)(sourceFile)).then(({ stderr: stderr })=>{
30
- if (stderr.length > 0) (0, $dTHpf$taquerianodesdk.sendErr)(stderr);
32
+ $dTHpf$taquerianodesdk.execCmd($bb055a91efa18df7$var$getCompileCommand(opts)(sourceFile)).then(({ stderr: stderr })=>{
33
+ if (stderr.length > 0) $dTHpf$taquerianodesdk.sendErr(stderr);
31
34
  return {
32
35
  contract: sourceFile,
33
36
  artifact: $bb055a91efa18df7$var$getContractArtifactFilename(opts)(sourceFile)
34
37
  };
35
38
  }).catch((err)=>{
36
- (0, $dTHpf$taquerianodesdk.sendErr)(" ");
37
- (0, $dTHpf$taquerianodesdk.sendErr)(err.message.split("\n").slice(1).join("\n"));
39
+ $dTHpf$taquerianodesdk.sendErr(" ");
40
+ $dTHpf$taquerianodesdk.sendErr(err.message.split("\n").slice(1).join("\n"));
38
41
  return Promise.resolve({
39
42
  contract: sourceFile,
40
43
  artifact: "Not compiled"
41
44
  });
42
- });
45
+ })
46
+ ;
43
47
  const $bb055a91efa18df7$var$compileAll = (opts)=>{
44
48
  // TODO: Fetch list of files from SDK
45
- return (0, ($parcel$interopDefault($dTHpf$fastglob)))([
46
- "**/*.arl"
49
+ return ($parcel$interopDefault($dTHpf$fastglob))([
50
+ '**/*.arl'
47
51
  ], {
48
52
  cwd: opts.config.contractsDir,
49
53
  absolute: false
50
- }).then((entries)=>entries.map($bb055a91efa18df7$var$compileContract(opts))).then((processes)=>processes.length > 0 ? processes : [
54
+ }).then((entries)=>entries.map($bb055a91efa18df7$var$compileContract(opts))
55
+ ).then((processes)=>processes.length > 0 ? processes : [
51
56
  {
52
57
  contract: "None found",
53
58
  artifact: "N/A"
54
59
  }
55
- ]).then((promises)=>Promise.all(promises));
60
+ ]
61
+ ).then((promises)=>Promise.all(promises)
62
+ );
56
63
  };
57
64
  const $bb055a91efa18df7$var$compile = (parsedArgs)=>{
58
65
  const p = parsedArgs.sourceFile ? $bb055a91efa18df7$var$compileContract(parsedArgs)(parsedArgs.sourceFile).then((result)=>[
59
66
  result
60
- ]) : $bb055a91efa18df7$var$compileAll(parsedArgs).then((results)=>{
61
- if (results.length === 0) (0, $dTHpf$taquerianodesdk.sendErr)("No contracts found to compile.");
67
+ ]
68
+ ) : $bb055a91efa18df7$var$compileAll(parsedArgs).then((results)=>{
69
+ if (results.length === 0) $dTHpf$taquerianodesdk.sendErr("No contracts found to compile.");
62
70
  return results;
63
71
  });
64
- return p.then((0, $dTHpf$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $dTHpf$taquerianodesdk.sendAsyncErr)(err, false));
72
+ return p.then($dTHpf$taquerianodesdk.sendJsonRes).catch((err)=>$dTHpf$taquerianodesdk.sendAsyncErr(err, false)
73
+ );
65
74
  };
66
75
  var $bb055a91efa18df7$export$2e2bcd8739ae039 = $bb055a91efa18df7$var$compile;
67
76
 
68
77
 
69
- (0, $dTHpf$taquerianodesdk.Plugin).create((i18n)=>({
78
+ $dTHpf$taquerianodesdk.Plugin.create((i18n)=>({
70
79
  schema: "1.0",
71
80
  version: "0.1",
72
81
  alias: "archetype",
73
82
  tasks: [
74
- (0, $dTHpf$taquerianodesdk.Task).create({
83
+ $dTHpf$taquerianodesdk.Task.create({
75
84
  task: "compile",
76
85
  command: "compile [sourceFile]",
77
86
  aliases: [
@@ -95,13 +104,16 @@ var $bb055a91efa18df7$export$2e2bcd8739ae039 = $bb055a91efa18df7$var$compile;
95
104
  met: true
96
105
  }
97
106
  ]
98
- }),
107
+ })
108
+ ,
99
109
  installRunTimeDependencies: ()=>Promise.resolve({
100
110
  status: "success",
101
111
  output: "Archetype was found in /usr/bin/archetype" // TODO this should use i18n
102
- }),
103
- proxy: (0, $bb055a91efa18df7$export$2e2bcd8739ae039)
104
- }), process.argv);
112
+ })
113
+ ,
114
+ proxy: $bb055a91efa18df7$export$2e2b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5C,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE;oBACJ;wBAAC,IAAI,EAAE,WAAW;wBAAE,IAAI,EAAE,WAAW;wBAAE,OAAO,EAAE,UAAU;wBAAE,IAAI,EAAE,UAAU;wBAAE,GAAG,EAAE,IAAI;qBAAC;iBAC3F;aACJ,CAAC;QACF,0BAA0B,EAAE,IAAM,OAAO,CAAC,OAAO,CAAC;gBAC9C,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,2CAA2C,CAAC,4BAA4B;aACnF,CAAC;QACF,KAAK,EAAE,CAAA,GAAA,wCAAO,CAAA;KACjB,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC","sources":["taqueria-plugin-archetype/index.ts","taqueria-plugin-archetype/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: \"archetype\",\n tasks: [\n Task.create({\n task: \"compile\",\n command: \"compile [sourceFile]\",\n aliases: [\"c\", \"compile-archetype\"],\n description: \"Compile a smart contract written in a Archetype syntax to Michelson code\",\n options: [],\n handler: \"proxy\",\n encoding: \"json\"\n })\n ],\n checkRuntimeDependencies: () => Promise.resolve({\n status: \"success\",\n report: [\n {name: \"Archetype\", path: \"archetype\", version: \">=1.2.12\", kind: \"required\", met: true}\n ]\n }),\n installRunTimeDependencies: () => Promise.resolve({\n status: \"success\",\n output: \"Archetype was found in /usr/bin/archetype\" // TODO this should use i18n\n }),\n proxy: compile\n}), process.argv)","import {execCmd, sendErr, sendJsonRes, sendAsyncErr} from \"@taqueria/node-sdk\"\nimport { TaqError, LikeAPromise, PluginResponse, RequestArgs } from \"@taqueria/node-sdk/types\";\nimport glob from 'fast-glob'\nimport { extname, join, basename } from 'path'\nimport { readFile } from 'fs/promises'\n\ninterface Opts extends RequestArgs.t {\n sourceFile?: string\n}\n\nconst getInputFilename = (opts: Opts) => (sourceFile: string) => {\n const inputFile = basename(sourceFile, extname(sourceFile))\n return join(opts.config.contractsDir, `${inputFile}.arl`)\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 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 completium/archetype:1.2.12 ${inputFile}`\n const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`\n const cmd = `${baseCommand} ${outFile}`\n return cmd\n}\n\nconst compileContract = (opts: Opts) => (sourceFile: string): Promise<{ contract: string, artifact: string }> =>\n // const sourceAbspath = join(opts.contractsDir, sourceFile)\n execCmd(getCompileCommand(opts)(sourceFile))\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 = (opts: Opts): Promise<{ contract: string, artifact: string }[]> => {\n // TODO: Fetch list of files from SDK\n return glob(\n ['**/*.arl'],\n { cwd: opts.config.contractsDir, absolute: false }\n )\n .then(entries => entries.map(compileContract(opts)))\n .then(processes => processes.length > 0\n ? processes\n : [{contract: \"None found\", artifact: \"N/A\"}]\n )\n .then(promises => Promise.all(promises))\n}\n\nconst compile = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, TaqError.t> => {\n const p = parsedArgs.sourceFile\n ? compileContract(parsedArgs) (parsedArgs.sourceFile)\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;;;AAUA,MAAM,sCAAgB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAC/D,MAAM,SAAS,GAAG,oBAAQ,CAAC,UAAU,EAAE,mBAAO,CAAC,UAAU,CAAC,CAAC;QAC3D,OAAO,gBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;KAC1D;AAAA;AAED,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAC1E,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;KACvD;AAAA;AAED,MAAM,uCAAiB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAChE,MAAM,EArBR,YAqBU,UAAU,CAAA,EAAE,GAAG,IAAI;QAC3B,MAAM,SAAS,GAAG,sCAAgB,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;QACpD,MAAM,WAAW,GAAG,CAAC,yDAAyD,EAAE,UAAU,CAAC,oDAAoD,EAAE,SAAS,CAAC,CAAC;QAC5J,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,iDAA2B,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACvC,OAAO,GAAG,CAAA;KACX;AAAA;AAED,MAAM,qCAAe,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GACzD,4DAA4D;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B,EAAE,IAAM,OAAO,CAAC,OAAO,CAAC;gBAC9C,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,2CAA2C,CAAC,4BAA4B;aACnF,CAAC;QAAA;QACF,KAAK,EAAE,wCAAO;KACjB,CAAA;AAAC,EAAE,OAAO,CAAC,IAAI,CAAC","sources":["taqueria-plugin-archetype/index.ts","taqueria-plugin-archetype/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: \"archetype\",\n tasks: [\n Task.create({\n task: \"compile\",\n command: \"compile [sourceFile]\",\n aliases: [\"c\", \"compile-archetype\"],\n description: \"Compile a smart contract written in a Archetype syntax to Michelson code\",\n options: [],\n handler: \"proxy\",\n encoding: \"json\"\n })\n ],\n checkRuntimeDependencies: () => Promise.resolve({\n status: \"success\",\n report: [\n {name: \"Archetype\", path: \"archetype\", version: \">=1.2.12\", kind: \"required\", met: true}\n ]\n }),\n installRunTimeDependencies: () => Promise.resolve({\n status: \"success\",\n output: \"Archetype was found in /usr/bin/archetype\" // TODO this should use i18n\n }),\n proxy: compile\n}), process.argv)","import {execCmd, sendErr, sendJsonRes, sendAsyncErr} from \"@taqueria/node-sdk\"\nimport { TaqError, LikeAPromise, PluginResponse, RequestArgs } from \"@taqueria/node-sdk/types\";\nimport glob from 'fast-glob'\nimport { extname, join, basename } from 'path'\nimport { readFile } from 'fs/promises'\n\ninterface Opts extends RequestArgs.t {\n sourceFile?: string\n}\n\nconst getInputFilename = (opts: Opts) => (sourceFile: string) => {\n const inputFile = basename(sourceFile, extname(sourceFile))\n return join(opts.config.contractsDir, `${inputFile}.arl`)\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 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 completium/archetype:1.2.12 ${inputFile}`\n const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`\n const cmd = `${baseCommand} ${outFile}`\n return cmd\n}\n\nconst compileContract = (opts: Opts) => (sourceFile: string): Promise<{ contract: string, artifact: string }> =>\n // const sourceAbspath = join(opts.contractsDir, sourceFile)\n execCmd(getCompileCommand(opts)(sourceFile))\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 = (opts: Opts): Promise<{ contract: string, artifact: string }[]> => {\n // TODO: Fetch list of files from SDK\n return glob(\n ['**/*.arl'],\n { cwd: opts.config.contractsDir, absolute: false }\n )\n .then(entries => entries.map(compileContract(opts)))\n .then(processes => processes.length > 0\n ? processes\n : [{contract: \"None found\", artifact: \"N/A\"}]\n )\n .then(promises => Promise.all(promises))\n}\n\nconst compile = <T>(parsedArgs: Opts): LikeAPromise<PluginResponse, TaqError.t> => {\n const p = parsedArgs.sourceFile\n ? compileContract(parsedArgs) (parsedArgs.sourceFile)\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-archetype",
3
- "version": "0.0.0-pr-776-b4c3aaa5",
3
+ "version": "0.0.0-pr-786-5e56f0fc",
4
4
  "description": "A taqueria plugin for compiling Archetype smart contracts",
5
5
  "targets": {
6
6
  "default": {