@taqueria/plugin-archetype 0.0.0-pr-582-9da5741a → 0.2.1

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
@@ -7,20 +7,18 @@ The Archetype plugin exposes a compile task in Taqueria which can target one, or
7
7
  ## Tasks
8
8
 
9
9
  The Archetype plugin provides the following tasks to Taqueria:
10
-
11
- - `compile`
10
+ - `compile`
12
11
 
13
12
  ## Requirements
14
13
 
15
- - Taqueria v0.0.6 or later
16
- - Node.js v16 or later
14
+ - Taqueria v0.0.6 or later
15
+ - Node.js v16 or later
17
16
 
18
17
  ## Installation
19
18
 
20
19
  The Archetype plugin is distributed as an NPM package that can be installed and uninstalled on a project from the Taqueria CLI
21
20
 
22
21
  To install the Archetype plugin on a Taqueria project, navigate to the project folder and run:
23
-
24
22
  ```shell
25
23
  taq install @taqueria/plugin-archetype
26
24
  ```
package/compile.ts CHANGED
@@ -1,70 +1,77 @@
1
- import { execCmd, sendErr, sendJsonRes, sendAsyncErr } from '@taqueria/node-sdk'
2
- import { Failure, LikeAPromise, ParsedArgs, PluginResponse, SanitizedArgs } from '@taqueria/node-sdk/types'
1
+ import {execCmd, sendErr, sendJsonRes, sendAsyncErr} from "@taqueria/node-sdk"
2
+ import { Failure, LikeAPromise, ParsedArgs, PluginResponse, SanitizedArgs } from "@taqueria/node-sdk/types";
3
3
  import glob from 'fast-glob'
4
4
  import { extname, join, basename } from 'path'
5
5
  import { readFile } from 'fs/promises'
6
6
 
7
- type Opts = SanitizedArgs & { sourceFile: string }
7
+ type Opts = SanitizedArgs & {sourceFile: string}
8
8
 
9
9
  const getInputFilename = (opts: Opts) => (sourceFile: string) => {
10
- const inputFile = basename(sourceFile, extname(sourceFile))
11
- return join(opts.config.contractsDir, `${inputFile}.arl`)
10
+ const inputFile = basename(sourceFile, extname(sourceFile))
11
+ return join(opts.config.contractsDir, `${inputFile}.arl`)
12
12
  }
13
13
 
14
14
  const getContractArtifactFilename = (opts: Opts) => (sourceFile: string) => {
15
- const outFile = basename(sourceFile, extname(sourceFile))
16
- return join(opts.config.artifactsDir, `${outFile}.tz`)
15
+ const outFile = basename(sourceFile, extname(sourceFile))
16
+ return join(opts.config.artifactsDir, `${outFile}.tz`)
17
17
  }
18
18
 
19
19
  const getCompileCommand = (opts: Opts) => (sourceFile: string) => {
20
- const { projectDir } = opts
21
- const inputFile = getInputFilename(opts)(sourceFile)
22
- const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project completium/archetype:1.2.12 ${inputFile}`
23
- const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`
24
- const cmd = `${baseCommand} ${outFile}`
25
- return cmd
20
+ const { projectDir } = opts
21
+ const inputFile = getInputFilename(opts)(sourceFile)
22
+ const baseCommand = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project completium/archetype:1.2.12 ${inputFile}`
23
+ const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`
24
+ const cmd = `${baseCommand} ${outFile}`
25
+ return cmd
26
26
  }
27
27
 
28
- const compileContract =
29
- (opts: Opts) =>
30
- (sourceFile: string): Promise<{ contract: string; artifact: string }> =>
31
- // const sourceAbspath = join(opts.contractsDir, sourceFile)
32
- execCmd(getCompileCommand(opts)(sourceFile))
33
- .then(({ stderr }) => {
34
- // How should we output warnings?
35
- if (stderr.length > 0) sendErr(stderr)
36
- return {
37
- contract: sourceFile,
38
- artifact: getContractArtifactFilename(opts)(sourceFile),
39
- }
40
- })
41
- .catch((err) => {
42
- sendErr(' ')
43
- sendErr(err.message.split('\n').slice(1).join('\n'))
44
- return Promise.resolve({
45
- contract: sourceFile,
46
- artifact: 'Not compiled',
47
- })
48
- })
28
+ const compileContract = (opts: Opts) => (sourceFile: string): Promise<{ contract: string, artifact: string }> =>
29
+ // const sourceAbspath = join(opts.contractsDir, sourceFile)
30
+ execCmd(getCompileCommand(opts)(sourceFile))
31
+ .then(({stderr}) => { // How should we output warnings?
32
+ if (stderr.length > 0) sendErr(stderr)
33
+ return {
34
+ contract: sourceFile,
35
+ artifact: getContractArtifactFilename(opts) (sourceFile)
36
+ }
37
+ })
38
+ .catch(err => {
39
+ sendErr(" ")
40
+ sendErr(err.message.split("\n").slice(1).join("\n"))
41
+ return Promise.resolve({
42
+ contract: sourceFile,
43
+ artifact: "Not compiled"
44
+ })
45
+ })
49
46
 
50
- const compileAll = (opts: Opts): Promise<{ contract: string; artifact: string }[]> => {
51
- // TODO: Fetch list of files from SDK
52
- return glob(['**/*.arl'], { cwd: opts.contractsDir, absolute: false })
53
- .then((entries) => entries.map(compileContract(opts)))
54
- .then((processes) => (processes.length > 0 ? processes : [{ contract: 'None found', artifact: 'N/A' }]))
55
- .then((promises) => Promise.all(promises))
47
+ const compileAll = (opts: Opts): Promise<{ contract: string, artifact: string }[]> => {
48
+ // TODO: Fetch list of files from SDK
49
+ return glob(
50
+ ['**/*.arl'],
51
+ { cwd: opts.contractsDir, absolute: false }
52
+ )
53
+ .then(entries => entries.map(compileContract(opts)))
54
+ .then(processes => processes.length > 0
55
+ ? processes
56
+ : [{contract: "None found", artifact: "N/A"}]
57
+ )
58
+ .then(promises => Promise.all(promises))
56
59
  }
57
60
 
58
61
  const compile = <T>(parsedArgs: SanitizedArgs): LikeAPromise<PluginResponse, Failure<T>> => {
59
- const params = parsedArgs as Opts
60
- const p = parsedArgs.sourceFile
61
- ? compileContract(params)(params.sourceFile).then((result) => [result])
62
- : compileAll(params).then((results) => {
63
- if (results.length === 0) sendErr('No contracts found to compile.')
62
+ const params = parsedArgs as Opts
63
+ const p = parsedArgs.sourceFile
64
+ ? compileContract(params) (params.sourceFile)
65
+ .then(result => [result])
66
+ : compileAll(params)
67
+ .then(results => {
68
+ if (results.length === 0) sendErr("No contracts found to compile.")
64
69
  return results
65
70
  })
66
-
67
- return p.then(sendJsonRes).catch((err) => sendAsyncErr(err, false))
71
+
72
+ return p
73
+ .then(sendJsonRes)
74
+ .catch(err => sendAsyncErr(err, false))
68
75
  }
69
76
 
70
- export default compile
77
+ export default compile
package/index.js CHANGED
@@ -30,18 +30,17 @@ const $bb055a91efa18df7$var$getCompileCommand = (opts)=>(sourceFile)=>{
30
30
  ;
31
31
  const $bb055a91efa18df7$var$compileContract = (opts)=>(sourceFile)=>// const sourceAbspath = join(opts.contractsDir, sourceFile)
32
32
  $dTHpf$taquerianodesdk.execCmd($bb055a91efa18df7$var$getCompileCommand(opts)(sourceFile)).then(({ stderr: stderr })=>{
33
- // How should we output warnings?
34
33
  if (stderr.length > 0) $dTHpf$taquerianodesdk.sendErr(stderr);
35
34
  return {
36
35
  contract: sourceFile,
37
36
  artifact: $bb055a91efa18df7$var$getContractArtifactFilename(opts)(sourceFile)
38
37
  };
39
38
  }).catch((err)=>{
40
- $dTHpf$taquerianodesdk.sendErr(' ');
41
- $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"));
42
41
  return Promise.resolve({
43
42
  contract: sourceFile,
44
- artifact: 'Not compiled'
43
+ artifact: "Not compiled"
45
44
  });
46
45
  })
47
46
  ;
@@ -55,8 +54,8 @@ const $bb055a91efa18df7$var$compileAll = (opts)=>{
55
54
  }).then((entries)=>entries.map($bb055a91efa18df7$var$compileContract(opts))
56
55
  ).then((processes)=>processes.length > 0 ? processes : [
57
56
  {
58
- contract: 'None found',
59
- artifact: 'N/A'
57
+ contract: "None found",
58
+ artifact: "N/A"
60
59
  }
61
60
  ]
62
61
  ).then((promises)=>Promise.all(promises)
@@ -68,7 +67,7 @@ const $bb055a91efa18df7$var$compile = (parsedArgs)=>{
68
67
  result
69
68
  ]
70
69
  ) : $bb055a91efa18df7$var$compileAll(params).then((results)=>{
71
- if (results.length === 0) $dTHpf$taquerianodesdk.sendErr('No contracts found to compile.');
70
+ if (results.length === 0) $dTHpf$taquerianodesdk.sendErr("No contracts found to compile.");
72
71
  return results;
73
72
  });
74
73
  return p.then($dTHpf$taquerianodesdk.sendJsonRes).catch((err)=>$dTHpf$taquerianodesdk.sendAsyncErr(err, false)
@@ -78,39 +77,39 @@ var $bb055a91efa18df7$export$2e2bcd8739ae039 = $bb055a91efa18df7$var$compile;
78
77
 
79
78
 
80
79
  $dTHpf$taquerianodesdk.Plugin.create((i18n)=>({
81
- schema: '1.0',
82
- version: '0.1',
83
- alias: 'archetype',
80
+ schema: "1.0",
81
+ version: "0.1",
82
+ alias: "archetype",
84
83
  tasks: [
85
84
  $dTHpf$taquerianodesdk.Task.create({
86
- task: 'compile',
87
- command: 'compile [sourceFile]',
85
+ task: "compile",
86
+ command: "compile [sourceFile]",
88
87
  aliases: [
89
- 'c',
90
- 'compile-archetype'
88
+ "c",
89
+ "compile-archetype"
91
90
  ],
92
- description: 'Compile a smart contract written in a Archetype syntax to Michelson code',
91
+ description: "Compile a smart contract written in a Archetype syntax to Michelson code",
93
92
  options: [],
94
- handler: 'proxy',
95
- encoding: 'json'
96
- }),
93
+ handler: "proxy",
94
+ encoding: "json"
95
+ })
97
96
  ],
98
97
  checkRuntimeDependencies: ()=>Promise.resolve({
99
- status: 'success',
98
+ status: "success",
100
99
  report: [
101
100
  {
102
- name: 'Archetype',
103
- path: 'archetype',
104
- version: '>=1.2.12',
105
- kind: 'required',
101
+ name: "Archetype",
102
+ path: "archetype",
103
+ version: ">=1.2.12",
104
+ kind: "required",
106
105
  met: true
107
106
  }
108
107
  ]
109
108
  })
110
109
  ,
111
110
  installRunTimeDependencies: ()=>Promise.resolve({
112
- status: 'success',
113
- output: 'Archetype was found in /usr/bin/archetype'
111
+ status: "success",
112
+ output: "Archetype was found in /usr/bin/archetype" // TODO this should use i18n
114
113
  })
115
114
  ,
116
115
  proxy: $bb055a91efa18df7$export$2e2bcd8739ae039
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;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AAE,2CAA2C;aACtD,CAAC;QAAA;QACN,KAAK,EAAE,wCAAO;KACjB,CAAA;AAAC,EACF,OAAO,CAAC,IAAI,CACf","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(\n (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: () =>\n Promise.resolve({\n status: 'success',\n report: [{ name: 'Archetype', path: 'archetype', version: '>=1.2.12', kind: 'required', met: true }],\n }),\n installRunTimeDependencies: () =>\n Promise.resolve({\n status: 'success',\n output: 'Archetype was found in /usr/bin/archetype', // TODO this should use i18n\n }),\n proxy: compile,\n }),\n process.argv,\n)\n","import { execCmd, sendErr, sendJsonRes, sendAsyncErr } from '@taqueria/node-sdk'\nimport { Failure, LikeAPromise, ParsedArgs, PluginResponse, SanitizedArgs } from '@taqueria/node-sdk/types'\nimport glob from 'fast-glob'\nimport { extname, join, basename } from 'path'\nimport { readFile } from 'fs/promises'\n\ntype Opts = SanitizedArgs & { sourceFile: string }\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 =\n (opts: Opts) =>\n (sourceFile: string): Promise<{ contract: string; artifact: string }> =>\n // const sourceAbspath = join(opts.contractsDir, sourceFile)\n execCmd(getCompileCommand(opts)(sourceFile))\n .then(({ stderr }) => {\n // 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(['**/*.arl'], { cwd: opts.contractsDir, absolute: false })\n .then((entries) => entries.map(compileContract(opts)))\n .then((processes) => (processes.length > 0 ? processes : [{ contract: 'None found', artifact: 'N/A' }]))\n .then((promises) => Promise.all(promises))\n}\n\nconst compile = <T>(parsedArgs: SanitizedArgs): LikeAPromise<PluginResponse, Failure<T>> => {\n const params = parsedArgs as Opts\n const p = parsedArgs.sourceFile\n ? compileContract(params)(params.sourceFile).then((result) => [result])\n : compileAll(params).then((results) => {\n if (results.length === 0) sendErr('No contracts found to compile.')\n return results\n })\n\n return p.then(sendJsonRes).catch((err) => sendAsyncErr(err, false))\n}\n\nexport default compile\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;;;;AAAA;ACAA;;;AAQA,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,CA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BAAO,CAAC,gCAAgC,CAAC;QACnE,OAAO,OAAO,CAAA;KACjB,CAAC;IAEV,OAAO,CAAC,CACP,IAAI,CAAC,kCAAW,CAAC,CACjB,KAAK,CAAC,CAAA,GAAG,GAAI,mCAAY,CAAC,GAAG,EAAE,KAAK,CAAC;IAAA,CAAC,CAAA;CACxC;IAED,wCAAsB,GAAP,6BAAO;;;ADzEtB,6BAAM,CAAC,MAAM,CAAC,CAAA,IAAI,GAAK,CAAA;QACnB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,WAAW;QAClB,KAAK,EAAE;YACH,2BAAI,CAAC,MAAM,CAAC;gBACR,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;aACnB,CAAC;SACL;QACD,wBAAwB,EAAE,IAAM,OAAO,CAAC,OAAO,CAAC;gBAC5C,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;QAAA;QACF,0BAA0B,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 { Failure, LikeAPromise, ParsedArgs, PluginResponse, SanitizedArgs } from \"@taqueria/node-sdk/types\";\nimport glob from 'fast-glob'\nimport { extname, join, basename } from 'path'\nimport { readFile } from 'fs/promises'\n\ntype Opts = SanitizedArgs & {sourceFile: string}\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.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: SanitizedArgs): LikeAPromise<PluginResponse, Failure<T>> => {\n const params = parsedArgs as Opts\n const p = parsedArgs.sourceFile\n ? compileContract(params) (params.sourceFile)\n .then(result => [result])\n : compileAll(params)\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/index.ts CHANGED
@@ -1,33 +1,30 @@
1
- import { Plugin, Task, Option } from '@taqueria/node-sdk'
1
+ import {Plugin, Task, Option} from '@taqueria/node-sdk'
2
2
  import compile from './compile'
3
3
 
4
- Plugin.create(
5
- (i18n) => ({
6
- schema: '1.0',
7
- version: '0.1',
8
- alias: 'archetype',
9
- tasks: [
10
- Task.create({
11
- task: 'compile',
12
- command: 'compile [sourceFile]',
13
- aliases: ['c', 'compile-archetype'],
14
- description: 'Compile a smart contract written in a Archetype syntax to Michelson code',
15
- options: [],
16
- handler: 'proxy',
17
- encoding: 'json',
18
- }),
19
- ],
20
- checkRuntimeDependencies: () =>
21
- Promise.resolve({
22
- status: 'success',
23
- report: [{ name: 'Archetype', path: 'archetype', version: '>=1.2.12', kind: 'required', met: true }],
24
- }),
25
- installRunTimeDependencies: () =>
26
- Promise.resolve({
27
- status: 'success',
28
- output: 'Archetype was found in /usr/bin/archetype', // TODO this should use i18n
29
- }),
30
- proxy: compile,
4
+ Plugin.create(i18n => ({
5
+ schema: "1.0",
6
+ version: "0.1",
7
+ alias: "archetype",
8
+ tasks: [
9
+ Task.create({
10
+ task: "compile",
11
+ command: "compile [sourceFile]",
12
+ aliases: ["c", "compile-archetype"],
13
+ description: "Compile a smart contract written in a Archetype syntax to Michelson code",
14
+ options: [],
15
+ handler: "proxy",
16
+ encoding: "json"
17
+ })
18
+ ],
19
+ checkRuntimeDependencies: () => Promise.resolve({
20
+ status: "success",
21
+ report: [
22
+ {name: "Archetype", path: "archetype", version: ">=1.2.12", kind: "required", met: true}
23
+ ]
31
24
  }),
32
- process.argv,
33
- )
25
+ installRunTimeDependencies: () => Promise.resolve({
26
+ status: "success",
27
+ output: "Archetype was found in /usr/bin/archetype" // TODO this should use i18n
28
+ }),
29
+ proxy: compile
30
+ }), process.argv)
package/package.json CHANGED
@@ -1,50 +1,50 @@
1
1
  {
2
- "name": "@taqueria/plugin-archetype",
3
- "version": "0.0.0-pr-582-9da5741a",
4
- "description": "A taqueria plugin for compiling Archetype smart contracts",
5
- "targets": {
6
- "default": {
7
- "source": "./index.ts",
8
- "distDir": "./",
9
- "context": "node",
10
- "isLibrary": true
11
- }
12
- },
13
- "scripts": {
14
- "test": "echo \"Error: no test specified\" && exit 1",
15
- "build": "npx parcel build --no-cache 2>&1",
16
- "pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}",
17
- "compile": "node index.js --taqRun proxy --task compile --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\",\"artifactsDir\": \"artifacts\"}' --projectDir ../test-project --configDir ./.taq",
18
- "debugPluginInfo": "node --inspect index.js --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\"}' --projectDir ../test-project --configDir ./.taq"
19
- },
20
- "keywords": [
21
- "taqueria",
22
- "tezos",
23
- "build",
24
- "ecad",
25
- "ecadlabs",
26
- "plugin",
27
- "archetype",
28
- "smart contract",
29
- "compile"
30
- ],
31
- "author": "ECAD Labs",
32
- "license": "Apache-2.0",
33
- "repository": {
34
- "type": "git",
35
- "url": "https://github.com/ecadlabs/taqueria.git",
36
- "directory": "taqueria-plugin-archetype"
37
- },
38
- "bugs": {
39
- "url": "https://github.com/ecadlabs/taqueria/issues"
40
- },
41
- "homepage": "https://github.com/ecadlabs/taqueria#readme",
42
- "dependencies": {
43
- "@taqueria/node-sdk": "^0.2.0",
44
- "fast-glob": "^3.2.7"
45
- },
46
- "devDependencies": {
47
- "parcel": "^2.0.1",
48
- "typescript": "4.5.4"
2
+ "name": "@taqueria/plugin-archetype",
3
+ "version": "0.2.1",
4
+ "description": "A taqueria plugin for compiling Archetype smart contracts",
5
+ "targets": {
6
+ "default": {
7
+ "source": "./index.ts",
8
+ "distDir": "./",
9
+ "context": "node",
10
+ "isLibrary": true
49
11
  }
12
+ },
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "build": "npx parcel build --no-cache 2>&1",
16
+ "pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}",
17
+ "compile": "node index.js --taqRun proxy --task compile --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\",\"artifactsDir\": \"artifacts\"}' --projectDir ../test-project --configDir ./.taq",
18
+ "debugPluginInfo": "node --inspect index.js --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\"}' --projectDir ../test-project --configDir ./.taq"
19
+ },
20
+ "keywords": [
21
+ "taqueria",
22
+ "tezos",
23
+ "build",
24
+ "ecad",
25
+ "ecadlabs",
26
+ "plugin",
27
+ "archetype",
28
+ "smart contract",
29
+ "compile"
30
+ ],
31
+ "author": "ECAD Labs",
32
+ "license": "Apache-2.0",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/ecadlabs/taqueria.git",
36
+ "directory": "taqueria-plugin-archetype"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/ecadlabs/taqueria/issues"
40
+ },
41
+ "homepage": "https://github.com/ecadlabs/taqueria#readme",
42
+ "dependencies": {
43
+ "@taqueria/node-sdk": "^0.2.1",
44
+ "fast-glob": "^3.2.7"
45
+ },
46
+ "devDependencies": {
47
+ "parcel": "^2.0.1",
48
+ "typescript": "4.5.4"
49
+ }
50
50
  }