@taqueria/plugin-archetype 0.0.0-pr-984-ff09db7a → 0.0.0-pr-975-6c1c5cf1
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/index.js +0 -45
- package/index.js.map +1 -1
- package/index.ts +1 -17
- package/package.json +1 -1
- package/archetype_template.ts +0 -9
- package/createContract.ts +0 -28
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var $dTHpf$taquerianodesdk = require("@taqueria/node-sdk");
|
|
2
2
|
var $dTHpf$fastglob = require("fast-glob");
|
|
3
3
|
var $dTHpf$path = require("path");
|
|
4
|
-
var $dTHpf$fspromises = require("fs/promises");
|
|
5
4
|
|
|
6
5
|
function $parcel$interopDefault(a) {
|
|
7
6
|
return a && a.__esModule ? a.default : a;
|
|
@@ -67,35 +66,6 @@ const $bb055a91efa18df7$var$compile = (parsedArgs)=>{
|
|
|
67
66
|
var $bb055a91efa18df7$export$2e2bcd8739ae039 = $bb055a91efa18df7$var$compile;
|
|
68
67
|
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const $94ea212fa0656741$export$fc3df5870c3ce31c = `
|
|
73
|
-
archetype hello
|
|
74
|
-
|
|
75
|
-
variable msg : string = "Hello"
|
|
76
|
-
|
|
77
|
-
entry input(name : string) {
|
|
78
|
-
msg += " " + name
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const $decf18aeaad317ec$var$registerContract = (arg, contractName)=>{
|
|
84
|
-
(0, $dTHpf$taquerianodesdk.experimental).registerContract(arg, contractName);
|
|
85
|
-
};
|
|
86
|
-
const $decf18aeaad317ec$var$validateExtension = async (contractName)=>{
|
|
87
|
-
const matchResult = contractName.match(/\.arl$/);
|
|
88
|
-
if (matchResult) return;
|
|
89
|
-
return (0, $dTHpf$taquerianodesdk.sendAsyncErr)(`"${contractName}" doesn't have extension "arl".`);
|
|
90
|
-
};
|
|
91
|
-
const $decf18aeaad317ec$var$createContract = (arg)=>{
|
|
92
|
-
const contractName = arg.sourceFileName;
|
|
93
|
-
const contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;
|
|
94
|
-
return $decf18aeaad317ec$var$validateExtension(contractName).then((_)=>(0, $dTHpf$fspromises.writeFile)(`${contractsDir}/${contractName}`, (0, $94ea212fa0656741$export$fc3df5870c3ce31c))).then((_)=>$decf18aeaad317ec$var$registerContract(arg, contractName));
|
|
95
|
-
};
|
|
96
|
-
var $decf18aeaad317ec$export$2e2bcd8739ae039 = $decf18aeaad317ec$var$createContract;
|
|
97
|
-
|
|
98
|
-
|
|
99
69
|
(0, $dTHpf$taquerianodesdk.Plugin).create((i18n)=>({
|
|
100
70
|
schema: "1.0",
|
|
101
71
|
version: "0.1",
|
|
@@ -114,21 +84,6 @@ var $decf18aeaad317ec$export$2e2bcd8739ae039 = $decf18aeaad317ec$var$createContr
|
|
|
114
84
|
encoding: "json"
|
|
115
85
|
}),
|
|
116
86
|
],
|
|
117
|
-
templates: [
|
|
118
|
-
(0, $dTHpf$taquerianodesdk.Template).create({
|
|
119
|
-
template: "archetypeContract",
|
|
120
|
-
command: "archetypeContract <sourceFileName>",
|
|
121
|
-
description: "Create a Archetype contract with boilerplate code",
|
|
122
|
-
positionals: [
|
|
123
|
-
(0, $dTHpf$taquerianodesdk.PositionalArg).create({
|
|
124
|
-
placeholder: "sourceFileName",
|
|
125
|
-
type: "string",
|
|
126
|
-
description: "The name of the Archetype contract to generate"
|
|
127
|
-
}),
|
|
128
|
-
],
|
|
129
|
-
handler: (0, $decf18aeaad317ec$export$2e2bcd8739ae039)
|
|
130
|
-
}),
|
|
131
|
-
],
|
|
132
87
|
proxy: (0, $bb055a91efa18df7$export$2e2bcd8739ae039)
|
|
133
88
|
}), process.argv);
|
|
134
89
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;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AO,CAAC,IAAI,CAAC,CAAC","sources":["taqueria-plugin-archetype/index.ts","taqueria-plugin-archetype/compile.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport compile from './compile';\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\tproxy: compile,\n}), process.argv);\n","import { execCmd, sendAsyncErr, sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport { LikeAPromise, RequestArgs, TaqError } from '@taqueria/node-sdk/types';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\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\t// TODO: Fetch list of files from SDK\n\treturn glob(\n\t\t['**/*.arl'],\n\t\t{ cwd: opts.config.contractsDir, absolute: false },\n\t)\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};\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"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Option, Plugin,
|
|
1
|
+
import { Option, Plugin, Task } from '@taqueria/node-sdk';
|
|
2
2
|
import compile from './compile';
|
|
3
|
-
import createContract from './createContract';
|
|
4
3
|
|
|
5
4
|
Plugin.create(i18n => ({
|
|
6
5
|
schema: '1.0',
|
|
@@ -17,20 +16,5 @@ Plugin.create(i18n => ({
|
|
|
17
16
|
encoding: 'json',
|
|
18
17
|
}),
|
|
19
18
|
],
|
|
20
|
-
templates: [
|
|
21
|
-
Template.create({
|
|
22
|
-
template: 'archetypeContract',
|
|
23
|
-
command: 'archetypeContract <sourceFileName>',
|
|
24
|
-
description: 'Create a Archetype contract with boilerplate code',
|
|
25
|
-
positionals: [
|
|
26
|
-
PositionalArg.create({
|
|
27
|
-
placeholder: 'sourceFileName',
|
|
28
|
-
type: 'string',
|
|
29
|
-
description: 'The name of the Archetype contract to generate',
|
|
30
|
-
}),
|
|
31
|
-
],
|
|
32
|
-
handler: createContract,
|
|
33
|
-
}),
|
|
34
|
-
],
|
|
35
19
|
proxy: compile,
|
|
36
20
|
}), process.argv);
|
package/package.json
CHANGED
package/archetype_template.ts
DELETED
package/createContract.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { experimental, sendAsyncErr } from '@taqueria/node-sdk';
|
|
2
|
-
import * as RequestArgs from '@taqueria/protocol/RequestArgs';
|
|
3
|
-
import { writeFile } from 'fs/promises';
|
|
4
|
-
import { arl_template } from './archetype_template';
|
|
5
|
-
|
|
6
|
-
interface Opts extends RequestArgs.t {
|
|
7
|
-
sourceFileName?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const registerContract = (arg: Opts, contractName: string) => {
|
|
11
|
-
experimental.registerContract(arg, contractName);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const validateExtension = async (contractName: string) => {
|
|
15
|
-
const matchResult = contractName.match(/\.arl$/);
|
|
16
|
-
if (matchResult) return;
|
|
17
|
-
return sendAsyncErr(`"${contractName}" doesn't have extension "arl".`);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const createContract = (arg: Opts) => {
|
|
21
|
-
const contractName = arg.sourceFileName as string;
|
|
22
|
-
const contractsDir = `${arg.config.projectDir}/${arg.config.contractsDir}`;
|
|
23
|
-
return validateExtension(contractName)
|
|
24
|
-
.then(_ => writeFile(`${contractsDir}/${contractName}`, arl_template))
|
|
25
|
-
.then(_ => registerContract(arg, contractName));
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default createContract;
|