@taqueria/plugin-archetype 0.0.0-pr-489-0ae8e14f → 0.0.0-pr-582-9da5741a
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 +5 -3
- package/compile.ts +48 -55
- package/index.js +25 -24
- package/index.js.map +1 -1
- package/index.ts +30 -27
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -7,18 +7,20 @@ 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
|
-
|
|
10
|
+
|
|
11
|
+
- `compile`
|
|
11
12
|
|
|
12
13
|
## Requirements
|
|
13
14
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
15
|
+
- Taqueria v0.0.6 or later
|
|
16
|
+
- Node.js v16 or later
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
19
20
|
The Archetype plugin is distributed as an NPM package that can be installed and uninstalled on a project from the Taqueria CLI
|
|
20
21
|
|
|
21
22
|
To install the Archetype plugin on a Taqueria project, navigate to the project folder and run:
|
|
23
|
+
|
|
22
24
|
```shell
|
|
23
25
|
taq install @taqueria/plugin-archetype
|
|
24
26
|
```
|
package/compile.ts
CHANGED
|
@@ -1,77 +1,70 @@
|
|
|
1
|
-
import {execCmd, sendErr, sendJsonRes, sendAsyncErr} from
|
|
2
|
-
import { Failure, LikeAPromise, ParsedArgs, PluginResponse, SanitizedArgs } from
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
16
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
})
|
|
46
49
|
|
|
47
|
-
const compileAll = (opts: Opts): Promise<{ contract: string
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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))
|
|
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))
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
const compile = <T>(parsedArgs: SanitizedArgs): LikeAPromise<PluginResponse, Failure<T>> => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.then(results => {
|
|
68
|
-
if (results.length === 0) sendErr("No contracts found to compile.")
|
|
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.')
|
|
69
64
|
return results
|
|
70
65
|
})
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.then(sendJsonRes)
|
|
74
|
-
.catch(err => sendAsyncErr(err, false))
|
|
66
|
+
|
|
67
|
+
return p.then(sendJsonRes).catch((err) => sendAsyncErr(err, false))
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
export default compile
|
|
70
|
+
export default compile
|
package/index.js
CHANGED
|
@@ -30,17 +30,18 @@ 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?
|
|
33
34
|
if (stderr.length > 0) $dTHpf$taquerianodesdk.sendErr(stderr);
|
|
34
35
|
return {
|
|
35
36
|
contract: sourceFile,
|
|
36
37
|
artifact: $bb055a91efa18df7$var$getContractArtifactFilename(opts)(sourceFile)
|
|
37
38
|
};
|
|
38
39
|
}).catch((err)=>{
|
|
39
|
-
$dTHpf$taquerianodesdk.sendErr(
|
|
40
|
-
$dTHpf$taquerianodesdk.sendErr(err.message.split(
|
|
40
|
+
$dTHpf$taquerianodesdk.sendErr(' ');
|
|
41
|
+
$dTHpf$taquerianodesdk.sendErr(err.message.split('\n').slice(1).join('\n'));
|
|
41
42
|
return Promise.resolve({
|
|
42
43
|
contract: sourceFile,
|
|
43
|
-
artifact:
|
|
44
|
+
artifact: 'Not compiled'
|
|
44
45
|
});
|
|
45
46
|
})
|
|
46
47
|
;
|
|
@@ -54,8 +55,8 @@ const $bb055a91efa18df7$var$compileAll = (opts)=>{
|
|
|
54
55
|
}).then((entries)=>entries.map($bb055a91efa18df7$var$compileContract(opts))
|
|
55
56
|
).then((processes)=>processes.length > 0 ? processes : [
|
|
56
57
|
{
|
|
57
|
-
contract:
|
|
58
|
-
artifact:
|
|
58
|
+
contract: 'None found',
|
|
59
|
+
artifact: 'N/A'
|
|
59
60
|
}
|
|
60
61
|
]
|
|
61
62
|
).then((promises)=>Promise.all(promises)
|
|
@@ -67,7 +68,7 @@ const $bb055a91efa18df7$var$compile = (parsedArgs)=>{
|
|
|
67
68
|
result
|
|
68
69
|
]
|
|
69
70
|
) : $bb055a91efa18df7$var$compileAll(params).then((results)=>{
|
|
70
|
-
if (results.length === 0) $dTHpf$taquerianodesdk.sendErr(
|
|
71
|
+
if (results.length === 0) $dTHpf$taquerianodesdk.sendErr('No contracts found to compile.');
|
|
71
72
|
return results;
|
|
72
73
|
});
|
|
73
74
|
return p.then($dTHpf$taquerianodesdk.sendJsonRes).catch((err)=>$dTHpf$taquerianodesdk.sendAsyncErr(err, false)
|
|
@@ -77,39 +78,39 @@ var $bb055a91efa18df7$export$2e2bcd8739ae039 = $bb055a91efa18df7$var$compile;
|
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
$dTHpf$taquerianodesdk.Plugin.create((i18n)=>({
|
|
80
|
-
schema:
|
|
81
|
-
version:
|
|
82
|
-
alias:
|
|
81
|
+
schema: '1.0',
|
|
82
|
+
version: '0.1',
|
|
83
|
+
alias: 'archetype',
|
|
83
84
|
tasks: [
|
|
84
85
|
$dTHpf$taquerianodesdk.Task.create({
|
|
85
|
-
task:
|
|
86
|
-
command:
|
|
86
|
+
task: 'compile',
|
|
87
|
+
command: 'compile [sourceFile]',
|
|
87
88
|
aliases: [
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
'c',
|
|
90
|
+
'compile-archetype'
|
|
90
91
|
],
|
|
91
|
-
description:
|
|
92
|
+
description: 'Compile a smart contract written in a Archetype syntax to Michelson code',
|
|
92
93
|
options: [],
|
|
93
|
-
handler:
|
|
94
|
-
encoding:
|
|
95
|
-
})
|
|
94
|
+
handler: 'proxy',
|
|
95
|
+
encoding: 'json'
|
|
96
|
+
}),
|
|
96
97
|
],
|
|
97
98
|
checkRuntimeDependencies: ()=>Promise.resolve({
|
|
98
|
-
status:
|
|
99
|
+
status: 'success',
|
|
99
100
|
report: [
|
|
100
101
|
{
|
|
101
|
-
name:
|
|
102
|
-
path:
|
|
103
|
-
version:
|
|
104
|
-
kind:
|
|
102
|
+
name: 'Archetype',
|
|
103
|
+
path: 'archetype',
|
|
104
|
+
version: '>=1.2.12',
|
|
105
|
+
kind: 'required',
|
|
105
106
|
met: true
|
|
106
107
|
}
|
|
107
108
|
]
|
|
108
109
|
})
|
|
109
110
|
,
|
|
110
111
|
installRunTimeDependencies: ()=>Promise.resolve({
|
|
111
|
-
status:
|
|
112
|
-
output:
|
|
112
|
+
status: 'success',
|
|
113
|
+
output: 'Archetype was found in /usr/bin/archetype'
|
|
113
114
|
})
|
|
114
115
|
,
|
|
115
116
|
proxy: $bb055a91efa18df7$export$2e2bcd8739ae039
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;ACAA;;;AAQA,MAAM,sCAAgB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;
|
|
1
|
+
{"mappings":";;;;;;;AAAA;ACAA;;;AAQA,MAAM,sCAAgB,GAAG,CAAC,IAAU,GAAK,CAAC,UAAkB,GAAK;QAC7D,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;KAC5D;AAAA;AAED,MAAM,iDAA2B,GAAG,CAAC,IAAU,GAAK,CAAC,U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AC,kCAAW,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,GAAK,mCAAY,CAAC,GAAG,EAAE,KAAK,CAAC;IAAA,CAAC,CAAA;CACtE;IAED,wCAAsB,GAAP,6BAAO;;;ADlEtB,6BAAM,CAAC,MAAM,CACT,CAAC,IAAI,GAAM,CAAA;QACP,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,IACtB,OAAO,CAAC,OAAO,CAAC;gBACZ,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE;oBAAC;wBAAE,IAAI,EAAE,WAAW;wBAAE,IAAI,EAAE,WAAW;wBAAE,OAAO,EAAE,UAAU;wBAAE,IAAI,EAAE,UAAU;wBAAE,GAAG,EAAE,IAAI;qBAAE;iBAAC;aACvG,CAAC;QAAA;QACN,0BAA0B,EAAE,IACxB,OAAO,CAAC,OAAO,CAAC;gBACZ,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,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":"../"}
|
package/index.ts
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,
|
|
24
31
|
}),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
output: "Archetype was found in /usr/bin/archetype" // TODO this should use i18n
|
|
28
|
-
}),
|
|
29
|
-
proxy: compile
|
|
30
|
-
}), process.argv)
|
|
32
|
+
process.argv,
|
|
33
|
+
)
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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"
|
|
11
49
|
}
|
|
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"
|
|
49
|
-
}
|
|
50
50
|
}
|