@taqueria/plugin-archetype 0.24.1 → 0.25.0-alpha

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
@@ -4,7 +4,7 @@ The Archetype plugin provides a task to compile Archetype smart contracts (`.arl
4
4
 
5
5
  ## Requirements
6
6
 
7
- - Taqueria v0.24.0 or later
7
+ - Taqueria v0.24.2 or later
8
8
  - Node.js v16.17.1 or later
9
9
  - Docker v20.10.12 or later
10
10
 
@@ -15,6 +15,9 @@ To install the Archetype plugin on a Taqueria project, navigate to the project f
15
15
  taq install @taqueria/plugin-archetype
16
16
  ```
17
17
 
18
+ > ### :page_with_curl: Note
19
+ > You can override the Archetype version used by the plugin by creating the environment variable `TAQ_ARCHETYPE_IMAGE` and setting it to your desired Ligo Docker image
20
+
18
21
  ## Configuration
19
22
 
20
23
  No additional configuration is available
package/_readme.eta CHANGED
@@ -6,7 +6,7 @@ The Archetype plugin provides a task to compile Archetype smart contracts (`.arl
6
6
 
7
7
  ## Requirements
8
8
 
9
- - Taqueria v0.24.0 or later
9
+ - Taqueria v0.24.2 or later
10
10
  - Node.js v16.17.1 or later
11
11
  - Docker v20.10.12 or later
12
12
 
@@ -17,6 +17,10 @@ To install the Archetype plugin on a Taqueria project, navigate to the project f
17
17
  taq install @taqueria/plugin-archetype
18
18
  ```
19
19
 
20
+ <%~ it.noteOpenAdmonition %>
21
+ You can override the Archetype version used by the plugin by creating the environment variable `TAQ_ARCHETYPE_IMAGE` and setting it to your desired Ligo Docker image
22
+ <%= it.closeAdmonition %>
23
+
20
24
  ## Configuration
21
25
 
22
26
  No additional configuration is available
package/compile.ts CHANGED
@@ -1,8 +1,24 @@
1
- import { execCmd, getContracts, sendAsyncErr, sendErr, sendJsonRes } from '@taqueria/node-sdk';
2
- import { RequestArgs, TaqError } from '@taqueria/node-sdk/types';
1
+ import {
2
+ execCmd,
3
+ getContracts,
4
+ getDockerImage,
5
+ sendAsyncErr,
6
+ sendAsyncRes,
7
+ sendErr,
8
+ sendJsonRes,
9
+ } from '@taqueria/node-sdk';
10
+ import { RequestArgs } from '@taqueria/node-sdk/types';
3
11
  import { basename, extname, join } from 'path';
12
+ import { match } from 'ts-pattern';
4
13
 
5
- interface Opts extends RequestArgs.t {
14
+ // Should point to the latest stable version, so it needs to be updated as part of our release process.
15
+ const ARCHETYPE_DEFAULT_IMAGE = 'completium/archetype:1.2.12';
16
+
17
+ const ARCHETYPE_IMAGE_ENV_VAR = 'TAQ_ARCHETYPE_IMAGE';
18
+
19
+ export const getArchetypeDockerImage = (): string => getDockerImage(ARCHETYPE_DEFAULT_IMAGE, ARCHETYPE_IMAGE_ENV_VAR);
20
+
21
+ interface Opts extends RequestArgs.ProxyRequestArgs {
6
22
  sourceFile?: string;
7
23
  }
8
24
 
@@ -23,7 +39,7 @@ const getCompileCommand = (opts: Opts) =>
23
39
  const { projectDir } = opts;
24
40
  const inputFile = getInputFilename(opts)(sourceFile);
25
41
  const baseCommand =
26
- `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -u $(id -u):$(id -g) -w /project completium/archetype:1.2.12 ${inputFile}`;
42
+ `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -u $(id -u):$(id -g) -w /project ${getArchetypeDockerImage()} ${inputFile}`;
27
43
  const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`;
28
44
  const cmd = `${baseCommand} ${outFile}`;
29
45
  return cmd;
@@ -59,19 +75,22 @@ const compileAll = (opts: Opts): Promise<{ contract: string; artifact: string }[
59
75
  )
60
76
  .then(promises => Promise.all(promises));
61
77
 
62
- const compile = <T>(parsedArgs: Opts) => {
63
- const p = parsedArgs.sourceFile
64
- ? compileContract(parsedArgs)(parsedArgs.sourceFile)
65
- .then(result => [result])
66
- : compileAll(parsedArgs)
67
- .then(results => {
68
- if (results.length === 0) sendErr('No contracts found to compile.');
69
- return results;
70
- });
78
+ const compile = <T>(parsedArgs: Opts) =>
79
+ match(parsedArgs)
80
+ .when(opts => opts.task === 'get-image', () => sendAsyncRes(getArchetypeDockerImage()))
81
+ .otherwise(() => {
82
+ const p = parsedArgs.sourceFile
83
+ ? compileContract(parsedArgs)(parsedArgs.sourceFile)
84
+ .then(result => [result])
85
+ : compileAll(parsedArgs)
86
+ .then(results => {
87
+ if (results.length === 0) sendErr('No contracts found to compile.');
88
+ return results;
89
+ });
71
90
 
72
- return p
73
- .then(sendJsonRes)
74
- .catch(err => sendAsyncErr(err, false));
75
- };
91
+ return p
92
+ .then(sendJsonRes)
93
+ .catch(err => sendAsyncErr(err, false));
94
+ });
76
95
 
77
96
  export default compile;
package/index.js CHANGED
@@ -1,10 +1,16 @@
1
1
  var $dTHpf$taquerianodesdk = require("@taqueria/node-sdk");
2
2
  var $dTHpf$path = require("path");
3
+ var $dTHpf$tspattern = require("ts-pattern");
3
4
  var $dTHpf$fspromises = require("fs/promises");
4
5
 
5
6
 
6
7
 
7
8
 
9
+
10
+ // Should point to the latest stable version, so it needs to be updated as part of our release process.
11
+ const $bb055a91efa18df7$var$ARCHETYPE_DEFAULT_IMAGE = "completium/archetype:1.2.12";
12
+ const $bb055a91efa18df7$var$ARCHETYPE_IMAGE_ENV_VAR = "TAQ_ARCHETYPE_IMAGE";
13
+ const $bb055a91efa18df7$export$9c99d2e0f552e13b = ()=>(0, $dTHpf$taquerianodesdk.getDockerImage)($bb055a91efa18df7$var$ARCHETYPE_DEFAULT_IMAGE, $bb055a91efa18df7$var$ARCHETYPE_IMAGE_ENV_VAR);
8
14
  const $bb055a91efa18df7$var$getInputFilename = (opts)=>(sourceFile)=>{
9
15
  const inputFile = (0, $dTHpf$path.basename)(sourceFile, (0, $dTHpf$path.extname)(sourceFile));
10
16
  return (0, $dTHpf$path.join)(opts.config.contractsDir, `${inputFile}.arl`);
@@ -16,7 +22,7 @@ const $bb055a91efa18df7$var$getContractArtifactFilename = (opts)=>(sourceFile)=>
16
22
  const $bb055a91efa18df7$var$getCompileCommand = (opts)=>(sourceFile)=>{
17
23
  const { projectDir: projectDir } = opts;
18
24
  const inputFile = $bb055a91efa18df7$var$getInputFilename(opts)(sourceFile);
19
- const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -u $(id -u):$(id -g) -w /project completium/archetype:1.2.12 ${inputFile}`;
25
+ const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -u $(id -u):$(id -g) -w /project ${$bb055a91efa18df7$export$9c99d2e0f552e13b()} ${inputFile}`;
20
26
  const outFile = `-o ${$bb055a91efa18df7$var$getContractArtifactFilename(opts)(sourceFile)}`;
21
27
  const cmd = `${baseCommand} ${outFile}`;
22
28
  return cmd;
@@ -42,15 +48,15 @@ const $bb055a91efa18df7$var$compileAll = (opts)=>Promise.all((0, $dTHpf$taqueria
42
48
  artifact: "N/A"
43
49
  }
44
50
  ]).then((promises)=>Promise.all(promises));
45
- const $bb055a91efa18df7$var$compile = (parsedArgs)=>{
46
- const p = parsedArgs.sourceFile ? $bb055a91efa18df7$var$compileContract(parsedArgs)(parsedArgs.sourceFile).then((result)=>[
47
- result
48
- ]) : $bb055a91efa18df7$var$compileAll(parsedArgs).then((results)=>{
49
- if (results.length === 0) (0, $dTHpf$taquerianodesdk.sendErr)("No contracts found to compile.");
50
- return results;
51
+ const $bb055a91efa18df7$var$compile = (parsedArgs)=>(0, $dTHpf$tspattern.match)(parsedArgs).when((opts)=>opts.task === "get-image", ()=>(0, $dTHpf$taquerianodesdk.sendAsyncRes)($bb055a91efa18df7$export$9c99d2e0f552e13b())).otherwise(()=>{
52
+ const p = parsedArgs.sourceFile ? $bb055a91efa18df7$var$compileContract(parsedArgs)(parsedArgs.sourceFile).then((result)=>[
53
+ result
54
+ ]) : $bb055a91efa18df7$var$compileAll(parsedArgs).then((results)=>{
55
+ if (results.length === 0) (0, $dTHpf$taquerianodesdk.sendErr)("No contracts found to compile.");
56
+ return results;
57
+ });
58
+ return p.then((0, $dTHpf$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $dTHpf$taquerianodesdk.sendAsyncErr)(err, false));
51
59
  });
52
- return p.then((0, $dTHpf$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $dTHpf$taquerianodesdk.sendAsyncErr)(err, false));
53
- };
54
60
  var $bb055a91efa18df7$export$2e2bcd8739ae039 = $bb055a91efa18df7$var$compile;
55
61
 
56
62
 
@@ -99,6 +105,13 @@ var $decf18aeaad317ec$export$2e2bcd8739ae039 = $decf18aeaad317ec$var$createContr
99
105
  options: [],
100
106
  handler: "proxy",
101
107
  encoding: "json"
108
+ }),
109
+ (0, $dTHpf$taquerianodesdk.Task).create({
110
+ task: "get-image",
111
+ command: "get-image",
112
+ description: "Gets the name of the image to be used",
113
+ handler: "proxy",
114
+ hidden: true
102
115
  }),
103
116
  ],
104
117
  templates: [
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;ACAA;;AAQA,MAAM,sCAAgB,GAAG,CAAC,IAAU,GACnC,CAAC,UAAkB,GAAK;QACvB,MAAM,SAAS,GAAG,CAAA,GAAA,oBAAQ,CAAA,CAAC,UAAU,EAAE,CAAA,GAAA,mBAAO,CAAA,CAAC,UAAU,CAAC,CAAC,AAAC;QAC5D,OAAO,CAAA,GAAA,gBAAI,CAAA,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KAC1D,AAAC;AAEH,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAC9C,CAAC,UAAkB,GAAK;QACvB,MAAM,OAAO,GAAG,CAAA,GAAA,oBAAQ,CAAA,CAAC,UAAU,EAAE,CAAA,GAAA,mBAAO,CAAA,CAAC,UAAU,CAAC,CAAC,AAAC;QAC1D,OAAO,CAAA,GAAA,gBAAI,CAAA,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE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2BAAI,CAAA,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,sBAAsB;gBAC/B,OAAO,EAAE;oBAAC,GAAG;oBAAE,mBAAmB;iBAAC;gBACnC,WAAW,EAAE,0EAA0E;gBACvF,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,MAAM;aAChB,CAAC;SACF;QACD,SAAS,EAAE;YACV,CAAA,GAAA,+BAAQ,CAAA,CAAC,MAAM,CAAC;gBACf,QAAQ,EAAE,mBAAmB;gBAC7B,OAAO,EAAE,oCAAoC;gBAC7C,WAAW,EAAE,mDAAmD;gBAChE,WAAW,EAAE;oBACZ,CAAA,GAAA,oCAAa,CAAA,CAAC,MAAM,CAAC;wBACpB,WAAW,EAAE,gBAAgB;wBAC7B,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,gDAAgD;qBAC7D,CAAC;iBACF;gBACD,OAAO,EAAE,CAAA,GAAA,wCAAc,CAAA;aACvB,CAAC;SACF;QACD,KAAK,EAAE,CAAA,GAAA,wCAAO,CAAA;KACd,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-archetype/index.ts","taqueria-plugin-archetype/compile.ts","taqueria-plugin-archetype/createContract.ts","taqueria-plugin-archetype/archetype_template.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport compile from './compile';\nimport createContract from './createContract';\n\nPlugin.create(i18n => ({\n\tschema: '1.0',\n\tversion: '0.1',\n\talias: 'archetype',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'compile',\n\t\t\tcommand: 'compile [sourceFile]',\n\t\t\taliases: ['c', 'compile-archetype'],\n\t\t\tdescription: 'Compile a smart contract written in a Archetype syntax to Michelson code',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'archetypeContract',\n\t\t\tcommand: 'archetypeContract <sourceFileName>',\n\t\t\tdescription: 'Create a Archetype contract with boilerplate code',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The name of the Archetype contract to generate',\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: createContract,\n\t\t}),\n\t],\n\tproxy: compile,\n}), process.argv);\n","import { execCmd, getContracts, sendAsyncErr, sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport { RequestArgs, TaqError } from '@taqueria/node-sdk/types';\nimport { basename, extname, join } from 'path';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFile?: string;\n}\n\nconst getInputFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst inputFile = basename(sourceFile, extname(sourceFile));\n\t\treturn join(opts.config.contractsDir, `${inputFile}.arl`);\n\t};\n\nconst getContractArtifactFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst outFile = basename(sourceFile, extname(sourceFile));\n\t\treturn join(opts.config.artifactsDir, `${outFile}.tz`);\n\t};\n\nconst getCompileCommand = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst { projectDir } = opts;\n\t\tconst inputFile = getInputFilename(opts)(sourceFile);\n\t\tconst baseCommand =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -u $(id -u):$(id -g) -w /project completium/archetype:1.2.12 ${inputFile}`;\n\t\tconst outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`;\n\t\tconst cmd = `${baseCommand} ${outFile}`;\n\t\treturn cmd;\n\t};\n\nconst compileContract = (opts: Opts) =>\n\t(sourceFile: string): Promise<{ contract: string; artifact: string }> =>\n\t\t// const sourceAbspath = join(opts.contractsDir, sourceFile)\n\t\texecCmd(getCompileCommand(opts)(sourceFile))\n\t\t\t.then(({ stderr }) => { // How should we output warnings?\n\t\t\t\tif (stderr.length > 0) sendErr(stderr);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: getContractArtifactFilename(opts)(sourceFile),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\tsendErr(' ');\n\t\t\t\tsendErr(err.message.split('\\n').slice(1).join('\\n'));\n\t\t\t\treturn Promise.resolve({\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: 'Not compiled',\n\t\t\t\t});\n\t\t\t});\n\nconst compileAll = (opts: Opts): Promise<{ contract: string; artifact: string }[]> =>\n\tPromise.all(getContracts(/\\.arl$/, opts.config))\n\t\t.then(entries => entries.map(compileContract(opts)))\n\t\t.then(processes =>\n\t\t\tprocesses.length > 0\n\t\t\t\t? processes\n\t\t\t\t: [{ contract: 'None found', artifact: 'N/A' }]\n\t\t)\n\t\t.then(promises => Promise.all(promises));\n\nconst compile = <T>(parsedArgs: Opts) => {\n\tconst p = parsedArgs.sourceFile\n\t\t? compileContract(parsedArgs)(parsedArgs.sourceFile)\n\t\t\t.then(result => [result])\n\t\t: compileAll(parsedArgs)\n\t\t\t.then(results => {\n\t\t\t\tif (results.length === 0) sendErr('No contracts found to compile.');\n\t\t\t\treturn results;\n\t\t\t});\n\n\treturn p\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n};\n\nexport default compile;\n","import { experimental, sendAsyncErr } from '@taqueria/node-sdk';\nimport * as RequestArgs from '@taqueria/protocol/RequestArgs';\nimport { writeFile } from 'fs/promises';\nimport { arl_template } from './archetype_template';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n}\n\nconst registerContract = (arg: Opts, contractName: string) => {\n\texperimental.registerContract(arg, contractName);\n};\n\nconst validateExtension = async (contractName: string) => {\n\tconst matchResult = contractName.match(/\\.arl$/);\n\tif (matchResult) return;\n\treturn sendAsyncErr(`\"${contractName}\" doesn't have extension \"arl\".`);\n};\n\nconst createContract = (arg: Opts) => {\n\tconst contractName = arg.sourceFileName as string;\n\tconst contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;\n\treturn validateExtension(contractName)\n\t\t.then(_ => writeFile(`${contractsDir}/${contractName}`, arl_template))\n\t\t.then(_ => registerContract(arg, contractName));\n};\n\nexport default createContract;\n","export const arl_template = `\narchetype hello\n\nvariable msg : string = \"Hello\"\n\nentry input(name : string) {\n msg += \" \" + name\n}\n`;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;;AAAA;ACAA;;;AAaA,uGAAuG;AACvG,MAAM,6CAAuB,GAAG,6BAA6B,AAAC;AAE9D,MAAM,6CAAuB,GAAG,qBAAqB,AAAC;AAE/C,MAAM,yCAAuB,GAAG,IAAc,CAAA,GAAA,qCAAc,CAAA,CAAC,6CAAuB,EAAE,6CAAuB,CAAC,AAAC;AAMtH,MAAM,sCAAgB,GAAG,CAAC,IAAU,GACnC,CAAC,UAAkB,GAAK;QACvB,MAAM,SAAS,GAAG,CAAA,GAAA,oBAAQ,CAAA,CAAC,UAAU,EAAE,CAAA,GAAA,mBAAO,CAAA,CAAC,UAAU,CAAC,CAAC,AAAC;QAC5D,OAAO,CAAA,GAAA,gBAAI,CAAA,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KAC1D,AAAC;AAEH,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAC9C,CAAC,UAAkB,GAAK;QACvB,MAAM,OAAO,GAAG,CAAA,GAAA,oBAAQ,CAAA,CAAC,UAAU,EAAE,CAAA,GAAA,mBAAO,CAAA,CAAC,UAAU,CAAC,CAAC,AAAC;QAC1D,OAAO,CAAA,GAAA,gBAAI,CAAA,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAA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8B,GAAf,oCAAc;;;AFvB7B,CAAA,GAAA,6BAAM,CAAA,CAAC,MAAM,CAAC,CAAA,IAAI,GAAK,CAAA;QACtB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE;YACN,CAAA,GAAA,2BAAI,CAAA,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,sBAAsB;gBAC/B,OAAO,EAAE;oBAAC,GAAG;oBAAE,mBAAmB;iBAAC;gBACnC,WAAW,EAAE,0EAA0E;gBACvF,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,MAAM;aAChB,CAAC;YACF,CAAA,GAAA,2BAAI,CAAA,CAAC,MAAM,CAAC;gBACX,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,WAAW;gBACpB,WAAW,EAAE,uCAAuC;gBACpD,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,IAAI;aACZ,CAAC;SACF;QACD,SAAS,EAAE;YACV,CAAA,GAAA,+BAAQ,CAAA,CAAC,MAAM,CAAC;gBACf,QAAQ,EAAE,mBAAmB;gBAC7B,OAAO,EAAE,oCAAoC;gBAC7C,WAAW,EAAE,mDAAmD;gBAChE,WAAW,EAAE;oBACZ,CAAA,GAAA,oCAAa,CAAA,CAAC,MAAM,CAAC;wBACpB,WAAW,EAAE,gBAAgB;wBAC7B,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,gDAAgD;qBAC7D,CAAC;iBACF;gBACD,OAAO,EAAE,CAAA,GAAA,wCAAc,CAAA;aACvB,CAAC;SACF;QACD,KAAK,EAAE,CAAA,GAAA,wCAAO,CAAA;KACd,CAAA,AAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-archetype/index.ts","taqueria-plugin-archetype/compile.ts","taqueria-plugin-archetype/createContract.ts","taqueria-plugin-archetype/archetype_template.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport compile from './compile';\nimport createContract from './createContract';\n\nPlugin.create(i18n => ({\n\tschema: '1.0',\n\tversion: '0.1',\n\talias: 'archetype',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'compile',\n\t\t\tcommand: 'compile [sourceFile]',\n\t\t\taliases: ['c', 'compile-archetype'],\n\t\t\tdescription: 'Compile a smart contract written in a Archetype syntax to Michelson code',\n\t\t\toptions: [],\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'get-image',\n\t\t\tcommand: 'get-image',\n\t\t\tdescription: 'Gets the name of the image to be used',\n\t\t\thandler: 'proxy',\n\t\t\thidden: true,\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'archetypeContract',\n\t\t\tcommand: 'archetypeContract <sourceFileName>',\n\t\t\tdescription: 'Create a Archetype contract with boilerplate code',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'The name of the Archetype contract to generate',\n\t\t\t\t}),\n\t\t\t],\n\t\t\thandler: createContract,\n\t\t}),\n\t],\n\tproxy: compile,\n}), process.argv);\n","import {\n\texecCmd,\n\tgetContracts,\n\tgetDockerImage,\n\tsendAsyncErr,\n\tsendAsyncRes,\n\tsendErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk/types';\nimport { basename, extname, join } from 'path';\nimport { match } from 'ts-pattern';\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst ARCHETYPE_DEFAULT_IMAGE = 'completium/archetype:1.2.12';\n\nconst ARCHETYPE_IMAGE_ENV_VAR = 'TAQ_ARCHETYPE_IMAGE';\n\nexport const getArchetypeDockerImage = (): string => getDockerImage(ARCHETYPE_DEFAULT_IMAGE, ARCHETYPE_IMAGE_ENV_VAR);\n\ninterface Opts extends RequestArgs.ProxyRequestArgs {\n\tsourceFile?: string;\n}\n\nconst getInputFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst inputFile = basename(sourceFile, extname(sourceFile));\n\t\treturn join(opts.config.contractsDir, `${inputFile}.arl`);\n\t};\n\nconst getContractArtifactFilename = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst outFile = basename(sourceFile, extname(sourceFile));\n\t\treturn join(opts.config.artifactsDir, `${outFile}.tz`);\n\t};\n\nconst getCompileCommand = (opts: Opts) =>\n\t(sourceFile: string) => {\n\t\tconst { projectDir } = opts;\n\t\tconst inputFile = getInputFilename(opts)(sourceFile);\n\t\tconst baseCommand =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -u $(id -u):$(id -g) -w /project ${getArchetypeDockerImage()} ${inputFile}`;\n\t\tconst outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`;\n\t\tconst cmd = `${baseCommand} ${outFile}`;\n\t\treturn cmd;\n\t};\n\nconst compileContract = (opts: Opts) =>\n\t(sourceFile: string): Promise<{ contract: string; artifact: string }> =>\n\t\t// const sourceAbspath = join(opts.contractsDir, sourceFile)\n\t\texecCmd(getCompileCommand(opts)(sourceFile))\n\t\t\t.then(({ stderr }) => { // How should we output warnings?\n\t\t\t\tif (stderr.length > 0) sendErr(stderr);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: getContractArtifactFilename(opts)(sourceFile),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\tsendErr(' ');\n\t\t\t\tsendErr(err.message.split('\\n').slice(1).join('\\n'));\n\t\t\t\treturn Promise.resolve({\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\tartifact: 'Not compiled',\n\t\t\t\t});\n\t\t\t});\n\nconst compileAll = (opts: Opts): Promise<{ contract: string; artifact: string }[]> =>\n\tPromise.all(getContracts(/\\.arl$/, opts.config))\n\t\t.then(entries => entries.map(compileContract(opts)))\n\t\t.then(processes =>\n\t\t\tprocesses.length > 0\n\t\t\t\t? processes\n\t\t\t\t: [{ contract: 'None found', artifact: 'N/A' }]\n\t\t)\n\t\t.then(promises => Promise.all(promises));\n\nconst compile = <T>(parsedArgs: Opts) =>\n\tmatch(parsedArgs)\n\t\t.when(opts => opts.task === 'get-image', () => sendAsyncRes(getArchetypeDockerImage()))\n\t\t.otherwise(() => {\n\t\t\tconst p = parsedArgs.sourceFile\n\t\t\t\t? compileContract(parsedArgs)(parsedArgs.sourceFile)\n\t\t\t\t\t.then(result => [result])\n\t\t\t\t: compileAll(parsedArgs)\n\t\t\t\t\t.then(results => {\n\t\t\t\t\t\tif (results.length === 0) sendErr('No contracts found to compile.');\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t});\n\n\t\t\treturn p\n\t\t\t\t.then(sendJsonRes)\n\t\t\t\t.catch(err => sendAsyncErr(err, false));\n\t\t});\n\nexport default compile;\n","import { experimental, sendAsyncErr } from '@taqueria/node-sdk';\nimport * as RequestArgs from '@taqueria/protocol/RequestArgs';\nimport { writeFile } from 'fs/promises';\nimport { arl_template } from './archetype_template';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n}\n\nconst registerContract = (arg: Opts, contractName: string) => {\n\texperimental.registerContract(arg, contractName);\n};\n\nconst validateExtension = async (contractName: string) => {\n\tconst matchResult = contractName.match(/\\.arl$/);\n\tif (matchResult) return;\n\treturn sendAsyncErr(`\"${contractName}\" doesn't have extension \"arl\".`);\n};\n\nconst createContract = (arg: Opts) => {\n\tconst contractName = arg.sourceFileName as string;\n\tconst contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;\n\treturn validateExtension(contractName)\n\t\t.then(_ => writeFile(`${contractsDir}/${contractName}`, arl_template))\n\t\t.then(_ => registerContract(arg, contractName));\n};\n\nexport default createContract;\n","export const arl_template = `\narchetype hello\n\nvariable msg : string = \"Hello\"\n\nentry input(name : string) {\n msg += \" \" + name\n}\n`;\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
package/index.ts CHANGED
@@ -16,6 +16,13 @@ Plugin.create(i18n => ({
16
16
  handler: 'proxy',
17
17
  encoding: 'json',
18
18
  }),
19
+ Task.create({
20
+ task: 'get-image',
21
+ command: 'get-image',
22
+ description: 'Gets the name of the image to be used',
23
+ handler: 'proxy',
24
+ hidden: true,
25
+ }),
19
26
  ],
20
27
  templates: [
21
28
  Template.create({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-archetype",
3
- "version": "0.24.1",
3
+ "version": "0.25.0-alpha",
4
4
  "description": "A taqueria plugin for compiling Archetype smart contracts",
5
5
  "targets": {
6
6
  "default": {
@@ -40,8 +40,9 @@
40
40
  },
41
41
  "homepage": "https://github.com/ecadlabs/taqueria#readme",
42
42
  "dependencies": {
43
- "@taqueria/node-sdk": "^0.24.1",
44
- "fast-glob": "^3.2.11"
43
+ "@taqueria/node-sdk": "^0.25.0-alpha",
44
+ "fast-glob": "^3.2.11",
45
+ "ts-pattern": "^3.3.3"
45
46
  },
46
47
  "devDependencies": {
47
48
  "parcel": "2.6.1",