@taqueria/plugin-archetype 0.25.0-alpha → 0.25.4-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/compile.ts CHANGED
@@ -2,12 +2,13 @@ import {
2
2
  execCmd,
3
3
  getContracts,
4
4
  getDockerImage,
5
+ ProxyTaskArgs,
6
+ RequestArgs,
5
7
  sendAsyncErr,
6
8
  sendAsyncRes,
7
9
  sendErr,
8
10
  sendJsonRes,
9
11
  } from '@taqueria/node-sdk';
10
- import { RequestArgs } from '@taqueria/node-sdk/types';
11
12
  import { basename, extname, join } from 'path';
12
13
  import { match } from 'ts-pattern';
13
14
 
@@ -18,20 +19,20 @@ const ARCHETYPE_IMAGE_ENV_VAR = 'TAQ_ARCHETYPE_IMAGE';
18
19
 
19
20
  export const getArchetypeDockerImage = (): string => getDockerImage(ARCHETYPE_DEFAULT_IMAGE, ARCHETYPE_IMAGE_ENV_VAR);
20
21
 
21
- interface Opts extends RequestArgs.ProxyRequestArgs {
22
+ interface Opts extends ProxyTaskArgs.t {
22
23
  sourceFile?: string;
23
24
  }
24
25
 
25
26
  const getInputFilename = (opts: Opts) =>
26
27
  (sourceFile: string) => {
27
28
  const inputFile = basename(sourceFile, extname(sourceFile));
28
- return join(opts.config.contractsDir, `${inputFile}.arl`);
29
+ return join(opts.config.contractsDir ?? 'contracts', `${inputFile}.arl`);
29
30
  };
30
31
 
31
32
  const getContractArtifactFilename = (opts: Opts) =>
32
33
  (sourceFile: string) => {
33
34
  const outFile = basename(sourceFile, extname(sourceFile));
34
- return join(opts.config.artifactsDir, `${outFile}.tz`);
35
+ return join(opts.config.artifactsDir ?? 'contracts', `${outFile}.tz`);
35
36
  };
36
37
 
37
38
  const getCompileCommand = (opts: Opts) =>
@@ -75,14 +76,15 @@ const compileAll = (opts: Opts): Promise<{ contract: string; artifact: string }[
75
76
  )
76
77
  .then(promises => Promise.all(promises));
77
78
 
78
- const compile = <T>(parsedArgs: Opts) =>
79
- match(parsedArgs)
80
- .when(opts => opts.task === 'get-image', () => sendAsyncRes(getArchetypeDockerImage()))
79
+ const compile = (parsedArgs: RequestArgs.t) => {
80
+ const unsafeOpts = parsedArgs as unknown as Opts;
81
+ return match(unsafeOpts)
82
+ .when(unsafeOpts => unsafeOpts.task === 'get-image', () => sendAsyncRes(getArchetypeDockerImage()))
81
83
  .otherwise(() => {
82
- const p = parsedArgs.sourceFile
83
- ? compileContract(parsedArgs)(parsedArgs.sourceFile)
84
+ const p = unsafeOpts.sourceFile
85
+ ? compileContract(unsafeOpts)(unsafeOpts.sourceFile)
84
86
  .then(result => [result])
85
- : compileAll(parsedArgs)
87
+ : compileAll(unsafeOpts)
86
88
  .then(results => {
87
89
  if (results.length === 0) sendErr('No contracts found to compile.');
88
90
  return results;
@@ -92,5 +94,6 @@ const compile = <T>(parsedArgs: Opts) =>
92
94
  .then(sendJsonRes)
93
95
  .catch(err => sendAsyncErr(err, false));
94
96
  });
97
+ };
95
98
 
96
99
  export default compile;
package/createContract.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { experimental, sendAsyncErr } from '@taqueria/node-sdk';
2
- import * as RequestArgs from '@taqueria/protocol/RequestArgs';
1
+ import { experimental, RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';
3
2
  import { writeFile } from 'fs/promises';
4
3
  import { arl_template } from './archetype_template';
5
4
 
@@ -17,12 +16,12 @@ const validateExtension = async (contractName: string) => {
17
16
  return sendAsyncErr(`"${contractName}" doesn't have extension "arl".`);
18
17
  };
19
18
 
20
- const createContract = (arg: Opts) => {
21
- const contractName = arg.sourceFileName as string;
22
- const contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;
19
+ const createContract = (args: Opts) => {
20
+ const contractName = args.sourceFileName as string;
21
+ const contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;
23
22
  return validateExtension(contractName)
24
23
  .then(_ => writeFile(`${contractsDir}/${contractName}`, arl_template))
25
- .then(_ => registerContract(arg, contractName));
24
+ .then(_ => registerContract(args, contractName));
26
25
  };
27
26
 
28
27
  export default createContract;
package/index.js CHANGED
@@ -13,11 +13,11 @@ const $bb055a91efa18df7$var$ARCHETYPE_IMAGE_ENV_VAR = "TAQ_ARCHETYPE_IMAGE";
13
13
  const $bb055a91efa18df7$export$9c99d2e0f552e13b = ()=>(0, $dTHpf$taquerianodesdk.getDockerImage)($bb055a91efa18df7$var$ARCHETYPE_DEFAULT_IMAGE, $bb055a91efa18df7$var$ARCHETYPE_IMAGE_ENV_VAR);
14
14
  const $bb055a91efa18df7$var$getInputFilename = (opts)=>(sourceFile)=>{
15
15
  const inputFile = (0, $dTHpf$path.basename)(sourceFile, (0, $dTHpf$path.extname)(sourceFile));
16
- return (0, $dTHpf$path.join)(opts.config.contractsDir, `${inputFile}.arl`);
16
+ return (0, $dTHpf$path.join)(opts.config.contractsDir ?? "contracts", `${inputFile}.arl`);
17
17
  };
18
18
  const $bb055a91efa18df7$var$getContractArtifactFilename = (opts)=>(sourceFile)=>{
19
19
  const outFile = (0, $dTHpf$path.basename)(sourceFile, (0, $dTHpf$path.extname)(sourceFile));
20
- return (0, $dTHpf$path.join)(opts.config.artifactsDir, `${outFile}.tz`);
20
+ return (0, $dTHpf$path.join)(opts.config.artifactsDir ?? "contracts", `${outFile}.tz`);
21
21
  };
22
22
  const $bb055a91efa18df7$var$getCompileCommand = (opts)=>(sourceFile)=>{
23
23
  const { projectDir: projectDir } = opts;
@@ -48,15 +48,18 @@ const $bb055a91efa18df7$var$compileAll = (opts)=>Promise.all((0, $dTHpf$taqueria
48
48
  artifact: "N/A"
49
49
  }
50
50
  ]).then((promises)=>Promise.all(promises));
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)=>[
51
+ const $bb055a91efa18df7$var$compile = (parsedArgs)=>{
52
+ const unsafeOpts = parsedArgs;
53
+ return (0, $dTHpf$tspattern.match)(unsafeOpts).when((unsafeOpts)=>unsafeOpts.task === "get-image", ()=>(0, $dTHpf$taquerianodesdk.sendAsyncRes)($bb055a91efa18df7$export$9c99d2e0f552e13b())).otherwise(()=>{
54
+ const p = unsafeOpts.sourceFile ? $bb055a91efa18df7$var$compileContract(unsafeOpts)(unsafeOpts.sourceFile).then((result)=>[
53
55
  result
54
- ]) : $bb055a91efa18df7$var$compileAll(parsedArgs).then((results)=>{
56
+ ]) : $bb055a91efa18df7$var$compileAll(unsafeOpts).then((results)=>{
55
57
  if (results.length === 0) (0, $dTHpf$taquerianodesdk.sendErr)("No contracts found to compile.");
56
58
  return results;
57
59
  });
58
60
  return p.then((0, $dTHpf$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $dTHpf$taquerianodesdk.sendAsyncErr)(err, false));
59
61
  });
62
+ };
60
63
  var $bb055a91efa18df7$export$2e2bcd8739ae039 = $bb055a91efa18df7$var$compile;
61
64
 
62
65
 
@@ -81,10 +84,10 @@ const $decf18aeaad317ec$var$validateExtension = async (contractName)=>{
81
84
  if (matchResult) return;
82
85
  return (0, $dTHpf$taquerianodesdk.sendAsyncErr)(`"${contractName}" doesn't have extension "arl".`);
83
86
  };
84
- const $decf18aeaad317ec$var$createContract = (arg)=>{
85
- const contractName = arg.sourceFileName;
86
- const contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;
87
- return $decf18aeaad317ec$var$validateExtension(contractName).then((_)=>(0, $dTHpf$fspromises.writeFile)(`${contractsDir}/${contractName}`, (0, $94ea212fa0656741$export$fc3df5870c3ce31c))).then((_)=>$decf18aeaad317ec$var$registerContract(arg, contractName));
87
+ const $decf18aeaad317ec$var$createContract = (args)=>{
88
+ const contractName = args.sourceFileName;
89
+ const contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;
90
+ return $decf18aeaad317ec$var$validateExtension(contractName).then((_)=>(0, $dTHpf$fspromises.writeFile)(`${contractsDir}/${contractName}`, (0, $94ea212fa0656741$export$fc3df5870c3ce31c))).then((_)=>$decf18aeaad317ec$var$registerContract(args, contractName));
88
91
  };
89
92
  var $decf18aeaad317ec$export$2e2bcd8739ae039 = $decf18aeaad317ec$var$createContract;
90
93
 
@@ -112,7 +115,7 @@ var $decf18aeaad317ec$export$2e2bcd8739ae039 = $decf18aeaad317ec$var$createContr
112
115
  description: "Gets the name of the image to be used",
113
116
  handler: "proxy",
114
117
  hidden: true
115
- }),
118
+ })
116
119
  ],
117
120
  templates: [
118
121
  (0, $dTHpf$taquerianodesdk.Template).create({
@@ -124,10 +127,10 @@ var $decf18aeaad317ec$export$2e2bcd8739ae039 = $decf18aeaad317ec$var$createContr
124
127
  placeholder: "sourceFileName",
125
128
  type: "string",
126
129
  description: "The name of the Archetype contract to generate"
127
- }),
130
+ })
128
131
  ],
129
132
  handler: (0, $decf18aeaad317ec$export$2e2bcd8739ae039)
130
- }),
133
+ })
131
134
  ],
132
135
  proxy: (0, $bb055a91efa18df7$export$2e2bcd8739ae039)
133
136
  }), process.argv);
package/index.js.map CHANGED
@@ -1 +1 @@
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,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AE;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":"../"}
1
+ {"mappings":";;;;;AAAA;ACAA;;;AAcA,uGAAuG;AACvG,MAAM,gDAA0B;AAEhC,MAAM,gDAA0B;AAEzB,MAAM,4CAA0B,IAAc,CAAA,GAAA,qCAAa,EAAE,+CAAyB;AAM7F,MAAM,yCAAmB,CAAC,OACzB,CAAC,aAAuB;QACvB,MAAM,YAAY,CAAA,GAAA,oBAAQ,AAAD,EAAE,YAAY,CAAA,GAAA,mBAAO,AAAD,EAAE;QAC/C,OAAO,CAAA,GAAA,gBAAI,AAAD,EAAE,KAAK,MAAM,CAAC,YAAY,IAAI,aAAa,CAAC,EAAE,UAAU,IAAI,CAAC;IACxE;AAED,MAAM,oDAA8B,CAAC,OACpC,CAAC,aAAuB;QACvB,MAAM,UAAU,CAAA,GAAA,oBAAQ,AAAD,EAAE,YAAY,CAAA,GAAA,mBAAO,AAAD,EAAE;QAC7C,OAAO,CAAA,GAAA,gBAAI,AAAD,EAAE,KAAK,MAAM,CAAC,YAAY,IAAI,aAAa,CAAC,EAAE,QAAQ,GAAG,CAAC;IACrE;AAED,MAAM,0CAAoB,CAAC,OAC1B,CAA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CAAC,CAAA,OAAS,CAAA;QACtB,QAAQ;QACR,SAAS;QACT,OAAO;QACP,OAAO;YACN,CAAA,GAAA,2BAAG,EAAE,MAAM,CAAC;gBACX,MAAM;gBACN,SAAS;gBACT,SAAS;oBAAC;oBAAK;iBAAoB;gBACnC,aAAa;gBACb,SAAS,EAAE;gBACX,SAAS;gBACT,UAAU;YACX;YACA,CAAA,GAAA,2BAAG,EAAE,MAAM,CAAC;gBACX,MAAM;gBACN,SAAS;gBACT,aAAa;gBACb,SAAS;gBACT,QAAQ,IAAI;YACb;SACA;QACD,WAAW;YACV,CAAA,GAAA,+BAAO,EAAE,MAAM,CAAC;gBACf,UAAU;gBACV,SAAS;gBACT,aAAa;gBACb,aAAa;oBACZ,CAAA,GAAA,oCAAY,EAAE,MAAM,CAAC;wBACpB,aAAa;wBACb,MAAM;wBACN,aAAa;oBACd;iBACA;gBACD,SAAS,CAAA,GAAA,wCAAa;YACvB;SACA;QACD,OAAO,CAAA,GAAA,wCAAM;IACd,CAAA,GAAI,QAAQ,IAAI","sources":["taqueria-plugin-archetype/index.ts","taqueria-plugin-archetype/compile.ts","taqueria-plugin-archetype/createContract.ts","taqueria-plugin-archetype/archetype_template.ts"],"sourcesContent":["import { 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\tProxyTaskArgs,\n\tRequestArgs,\n\tsendAsyncErr,\n\tsendAsyncRes,\n\tsendErr,\n\tsendJsonRes,\n} from '@taqueria/node-sdk';\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 ProxyTaskArgs.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 ?? 'contracts', `${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 ?? 'contracts', `${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 = (parsedArgs: RequestArgs.t) => {\n\tconst unsafeOpts = parsedArgs as unknown as Opts;\n\treturn match(unsafeOpts)\n\t\t.when(unsafeOpts => unsafeOpts.task === 'get-image', () => sendAsyncRes(getArchetypeDockerImage()))\n\t\t.otherwise(() => {\n\t\t\tconst p = unsafeOpts.sourceFile\n\t\t\t\t? compileContract(unsafeOpts)(unsafeOpts.sourceFile)\n\t\t\t\t\t.then(result => [result])\n\t\t\t\t: compileAll(unsafeOpts)\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};\n\nexport default compile;\n","import { experimental, RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\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 = (args: Opts) => {\n\tconst contractName = args.sourceFileName as string;\n\tconst contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;\n\treturn validateExtension(contractName)\n\t\t.then(_ => writeFile(`${contractsDir}/${contractName}`, arl_template))\n\t\t.then(_ => registerContract(args, 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
@@ -1,4 +1,4 @@
1
- import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';
1
+ import { Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';
2
2
  import compile from './compile';
3
3
  import createContract from './createContract';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-archetype",
3
- "version": "0.25.0-alpha",
3
+ "version": "0.25.4-alpha",
4
4
  "description": "A taqueria plugin for compiling Archetype smart contracts",
5
5
  "targets": {
6
6
  "default": {
@@ -40,12 +40,12 @@
40
40
  },
41
41
  "homepage": "https://github.com/ecadlabs/taqueria#readme",
42
42
  "dependencies": {
43
- "@taqueria/node-sdk": "^0.25.0-alpha",
43
+ "@taqueria/node-sdk": "^0.25.4-alpha",
44
44
  "fast-glob": "^3.2.11",
45
45
  "ts-pattern": "^3.3.3"
46
46
  },
47
47
  "devDependencies": {
48
- "parcel": "2.6.1",
48
+ "parcel": "^2.8.0",
49
49
  "typescript": "^4.7.2"
50
50
  }
51
51
  }
package/tsconfig.json CHANGED
@@ -12,7 +12,9 @@
12
12
 
13
13
  /* Language and Environment */
14
14
  "target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
15
+ "lib": [
16
+ "ES2021.String"
17
+ ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
18
  // "jsx": "preserve", /* Specify what JSX code is generated. */
17
19
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
20
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */