@taqueria/plugin-smartpy-legacy 0.37.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/LICENSE +201 -0
- package/README.md +73 -0
- package/index.d.ts +1 -0
- package/index.js +328 -0
- package/index.js.map +1 -0
- package/index.mjs +308 -0
- package/index.mjs.map +1 -0
- package/install.sh +128 -0
- package/package.json +78 -0
- package/smartpy-v0.16.0/smart-ts-cli.js +17 -0
- package/smartpy-v0.16.0/smart.js +348 -0
- package/smartpy-v0.16.0/smartpyc.js +274828 -0
- package/smartpy-v0.16.0/theme.js +251 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
// index.ts
|
|
2
|
+
import { Option, Plugin, Task } from "@taqueria/node-sdk";
|
|
3
|
+
|
|
4
|
+
// main.ts
|
|
5
|
+
import { sendAsyncErr as sendAsyncErr4 } from "@taqueria/node-sdk";
|
|
6
|
+
|
|
7
|
+
// compile.ts
|
|
8
|
+
import { execCmd as execCmd2, getArch, getArtifactsDir as getArtifactsDir2, sendAsyncErr, sendJsonRes, sendWarn as sendWarn2 } from "@taqueria/node-sdk";
|
|
9
|
+
import { copyFile as copyFile2, readFile } from "fs/promises";
|
|
10
|
+
import { basename, extname, join as join2 } from "path";
|
|
11
|
+
|
|
12
|
+
// common.ts
|
|
13
|
+
import { execCmd, getArtifactsDir, getContractsDir, sendErr, sendWarn } from "@taqueria/node-sdk";
|
|
14
|
+
import { access } from "fs/promises";
|
|
15
|
+
import { join } from "path";
|
|
16
|
+
var SMARTPY_DEFAULT_VERSION = "v0.16.0";
|
|
17
|
+
var SMARTPY_VERSION_ENV_VAR = "TAQ_SMARTPY_VERSION";
|
|
18
|
+
var SMARTPY_ARTIFACTS_DIR = ".smartpy";
|
|
19
|
+
var smartpyVersionToInstallerMap = {
|
|
20
|
+
"v0.16.0": "https://smartpy.io/releases/20221215-8f134ebb649f5a7b37c44fca8f336f970f523565/cli/install.sh"
|
|
21
|
+
};
|
|
22
|
+
var getSmartpyVersion = () => {
|
|
23
|
+
const userDefinedSmartpyVersion = process.env[SMARTPY_VERSION_ENV_VAR];
|
|
24
|
+
if (userDefinedSmartpyVersion) {
|
|
25
|
+
if (/v0\.1[4-6]\./.test(userDefinedSmartpyVersion)) {
|
|
26
|
+
return userDefinedSmartpyVersion;
|
|
27
|
+
} else {
|
|
28
|
+
sendWarn(
|
|
29
|
+
`Version ${userDefinedSmartpyVersion} is not supported by Taqueria yet. The supported versions are [${Object.keys(smartpyVersionToInstallerMap)}]. Will default to ${SMARTPY_DEFAULT_VERSION}`
|
|
30
|
+
);
|
|
31
|
+
return SMARTPY_DEFAULT_VERSION;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
return SMARTPY_DEFAULT_VERSION;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var getPathToSmartPyCliDir = () => `${process.env.HOME}/smartpy-cli-${getSmartpyVersion()}`;
|
|
38
|
+
var getSmartPyCli = () => `${getPathToSmartPyCliDir()}/SmartPy.sh`;
|
|
39
|
+
var getSmartPyInstallerCmd = (projectDir) => {
|
|
40
|
+
const trimmedProjectdir = projectDir.replace(/\/$/, "");
|
|
41
|
+
const installer = join(__dirname, "install.sh");
|
|
42
|
+
const install = `bash ${installer} --yes --prefix ${getPathToSmartPyCliDir()} --project ${trimmedProjectdir};`;
|
|
43
|
+
return install;
|
|
44
|
+
};
|
|
45
|
+
var addPyExtensionIfMissing = (sourceFile) => /\.py$/.test(sourceFile) ? sourceFile : `${sourceFile}.py`;
|
|
46
|
+
var extractExt = (path) => {
|
|
47
|
+
const matchResult = path.match(/\.py$/);
|
|
48
|
+
return matchResult ? matchResult[0] : "";
|
|
49
|
+
};
|
|
50
|
+
var removeExt = (path) => {
|
|
51
|
+
const extRegex = new RegExp(extractExt(path));
|
|
52
|
+
return path.replace(extRegex, "");
|
|
53
|
+
};
|
|
54
|
+
var getInputFilename = (parsedArgs, sourceFile) => join(parsedArgs.config.projectDir, getContractsDir(parsedArgs), sourceFile);
|
|
55
|
+
var getCompilationTargetsDirname = (parsedArgs, sourceFile) => join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), SMARTPY_ARTIFACTS_DIR, removeExt(sourceFile));
|
|
56
|
+
var installSmartPyCliIfNotExist = (projectDir) => access(getSmartPyCli()).catch(() => {
|
|
57
|
+
sendWarn("SmartPy CLI not found. Installing it now...");
|
|
58
|
+
return execCmd(getSmartPyInstallerCmd(projectDir)).then(({ stderr }) => {
|
|
59
|
+
if (stderr.length > 0)
|
|
60
|
+
sendWarn(stderr);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
var emitExternalError = (err, sourceFile) => {
|
|
64
|
+
sendErr(`
|
|
65
|
+
=== Error messages for ${sourceFile} ===`);
|
|
66
|
+
err instanceof Error ? sendErr(err.message.replace(/Command failed.+?\n/, "")) : sendErr(err);
|
|
67
|
+
sendErr(`
|
|
68
|
+
===`);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// compile.ts
|
|
72
|
+
var COMPILE_ERR_MSG = "Not compiled";
|
|
73
|
+
var isOutputFormatJSON = (parsedArgs) => parsedArgs.json;
|
|
74
|
+
var getOutputContractFilename = (parsedArgs, sourceFile) => {
|
|
75
|
+
const outputFile = basename(sourceFile, extname(sourceFile));
|
|
76
|
+
const ext = isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
|
|
77
|
+
return join2(parsedArgs.config.projectDir, getArtifactsDir2(parsedArgs), `${outputFile}${ext}`);
|
|
78
|
+
};
|
|
79
|
+
var getOutputStorageFilename = (parsedArgs, sourceFile, compilationTargetName, isDefaultStorage) => {
|
|
80
|
+
const outputFile = basename(sourceFile, extname(sourceFile));
|
|
81
|
+
const ext = isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
|
|
82
|
+
const storageName = isDefaultStorage ? `${outputFile}.default_storage${ext}` : `${outputFile}.storage.${compilationTargetName}${ext}`;
|
|
83
|
+
return join2(parsedArgs.config.projectDir, getArtifactsDir2(parsedArgs), storageName);
|
|
84
|
+
};
|
|
85
|
+
var getOutputExprFilename = (parsedArgs, sourceFile, compilationTargetName) => {
|
|
86
|
+
const outputFile = basename(sourceFile, extname(sourceFile));
|
|
87
|
+
const ext = isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
|
|
88
|
+
const exprName = `${outputFile}.expression.${compilationTargetName}${ext}`;
|
|
89
|
+
return join2(parsedArgs.config.projectDir, getArtifactsDir2(parsedArgs), exprName);
|
|
90
|
+
};
|
|
91
|
+
var getCompilationTargetNames = (parsedArgs, sourceFile) => readFile(getInputFilename(parsedArgs, sourceFile), "utf8").then((data) => ({
|
|
92
|
+
compTargetNames: data.match(/(?<=add_compilation_target\s*\(\s*['"])[^'"]+(?=['"])/g) ?? [],
|
|
93
|
+
exprCompTargetNames: data.match(/(?<=add_expression_compilation_target\s*\(\s*['"])[^'"]+(?=['"])/g) ?? []
|
|
94
|
+
}));
|
|
95
|
+
var copyArtifactsForFirstCompTarget = async (parsedArgs, sourceFile, compTargetNames) => {
|
|
96
|
+
if (compTargetNames.length === 0)
|
|
97
|
+
return [];
|
|
98
|
+
const firstCompTargetName = compTargetNames.slice(0, 1)[0];
|
|
99
|
+
const dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);
|
|
100
|
+
await copyFile2(
|
|
101
|
+
join2(
|
|
102
|
+
getCompilationTargetsDirname(parsedArgs, sourceFile),
|
|
103
|
+
firstCompTargetName,
|
|
104
|
+
isOutputFormatJSON(parsedArgs) ? "step_000_cont_0_contract.json" : "step_000_cont_0_contract.tz"
|
|
105
|
+
),
|
|
106
|
+
dstContractPath
|
|
107
|
+
);
|
|
108
|
+
const dstDefaultStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, firstCompTargetName, true);
|
|
109
|
+
await copyFile2(
|
|
110
|
+
join2(
|
|
111
|
+
getCompilationTargetsDirname(parsedArgs, sourceFile),
|
|
112
|
+
firstCompTargetName,
|
|
113
|
+
isOutputFormatJSON(parsedArgs) ? "step_000_cont_0_storage.json" : "step_000_cont_0_storage.tz"
|
|
114
|
+
),
|
|
115
|
+
dstDefaultStoragePath
|
|
116
|
+
);
|
|
117
|
+
return [dstContractPath, dstDefaultStoragePath];
|
|
118
|
+
};
|
|
119
|
+
var copyArtifactsForRestCompTargets = async (parsedArgs, sourceFile, compTargetNames) => {
|
|
120
|
+
if (compTargetNames.length === 0)
|
|
121
|
+
return [];
|
|
122
|
+
const restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);
|
|
123
|
+
const dstStoragePaths = await Promise.all(restCompTargetNames.map(async (compTargetName) => {
|
|
124
|
+
const dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);
|
|
125
|
+
await copyFile2(
|
|
126
|
+
join2(
|
|
127
|
+
getCompilationTargetsDirname(parsedArgs, sourceFile),
|
|
128
|
+
compTargetName,
|
|
129
|
+
isOutputFormatJSON(parsedArgs) ? "step_000_cont_0_storage.json" : "step_000_cont_0_storage.tz"
|
|
130
|
+
),
|
|
131
|
+
dstStoragePath
|
|
132
|
+
);
|
|
133
|
+
return dstStoragePath;
|
|
134
|
+
}));
|
|
135
|
+
return dstStoragePaths;
|
|
136
|
+
};
|
|
137
|
+
var copyArtifactsForExprCompTargets = async (parsedArgs, sourceFile, exprCompTargetNames) => {
|
|
138
|
+
if (exprCompTargetNames.length === 0)
|
|
139
|
+
return [];
|
|
140
|
+
const dstExprPaths = await Promise.all(exprCompTargetNames.map(async (compTargetName) => {
|
|
141
|
+
const dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);
|
|
142
|
+
await copyFile2(
|
|
143
|
+
join2(
|
|
144
|
+
getCompilationTargetsDirname(parsedArgs, sourceFile),
|
|
145
|
+
compTargetName,
|
|
146
|
+
isOutputFormatJSON(parsedArgs) ? "step_000_expression.json" : "step_000_expression.tz"
|
|
147
|
+
),
|
|
148
|
+
dstExprPath
|
|
149
|
+
);
|
|
150
|
+
return dstExprPath;
|
|
151
|
+
}));
|
|
152
|
+
return dstExprPaths;
|
|
153
|
+
};
|
|
154
|
+
var copyRelevantArtifactsForCompTargets = (parsedArgs, sourceFile) => async ({ compTargetNames, exprCompTargetNames }) => {
|
|
155
|
+
if (compTargetNames.length === 0 && exprCompTargetNames.length === 0)
|
|
156
|
+
return "No compilation targets defined";
|
|
157
|
+
const dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(
|
|
158
|
+
parsedArgs,
|
|
159
|
+
sourceFile,
|
|
160
|
+
compTargetNames
|
|
161
|
+
);
|
|
162
|
+
const dstStoragePaths = await copyArtifactsForRestCompTargets(
|
|
163
|
+
parsedArgs,
|
|
164
|
+
sourceFile,
|
|
165
|
+
compTargetNames
|
|
166
|
+
);
|
|
167
|
+
const dstExpressionPaths = await copyArtifactsForExprCompTargets(
|
|
168
|
+
parsedArgs,
|
|
169
|
+
sourceFile,
|
|
170
|
+
exprCompTargetNames
|
|
171
|
+
);
|
|
172
|
+
return dstContractAndDefaultStoragePaths.concat(dstStoragePaths).concat(dstExpressionPaths).join("\n");
|
|
173
|
+
};
|
|
174
|
+
var getCompileContractCmd = (parsedArgs, sourceFile) => {
|
|
175
|
+
const outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);
|
|
176
|
+
const booleanFlags = " --html --purge ";
|
|
177
|
+
return `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;
|
|
178
|
+
};
|
|
179
|
+
var compileContract = (parsedArgs, sourceFile) => getArch().then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir)).then(() => getCompileContractCmd(parsedArgs, sourceFile)).then(execCmd2).then(({ stderr }) => {
|
|
180
|
+
if (stderr.length > 0)
|
|
181
|
+
sendWarn2(stderr);
|
|
182
|
+
}).then(() => getCompilationTargetNames(parsedArgs, sourceFile)).then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile)).then((relevantArtifacts) => ({
|
|
183
|
+
contract: sourceFile,
|
|
184
|
+
artifact: relevantArtifacts
|
|
185
|
+
})).catch((err) => {
|
|
186
|
+
emitExternalError(err, sourceFile);
|
|
187
|
+
return {
|
|
188
|
+
contract: sourceFile,
|
|
189
|
+
artifact: COMPILE_ERR_MSG
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
var compile = (parsedArgs) => compileContract(parsedArgs, addPyExtensionIfMissing(parsedArgs.sourceFile)).then((result) => [result]).then(sendJsonRes).catch((err) => sendAsyncErr(err, false));
|
|
193
|
+
var compile_default = compile;
|
|
194
|
+
|
|
195
|
+
// compileAll.ts
|
|
196
|
+
import { getContractsDir as getContractsDir2, sendAsyncErr as sendAsyncErr2, sendJsonRes as sendJsonRes2 } from "@taqueria/node-sdk";
|
|
197
|
+
import glob from "fast-glob";
|
|
198
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
199
|
+
import { join as join3 } from "path";
|
|
200
|
+
var contractHasCompTarget = (parsedArgs, contactFilename) => readFile2(getInputFilename(parsedArgs, contactFilename), "utf8").then((data) => /add_(expression_)?compilation_target\s*\(\s*['"][^'"]+['"]/.test(data));
|
|
201
|
+
var compileAll = async (parsedArgs) => {
|
|
202
|
+
let p = [];
|
|
203
|
+
const contractFilenames = await glob(
|
|
204
|
+
["**/*.py"],
|
|
205
|
+
{ cwd: join3(parsedArgs.config.projectDir, getContractsDir2(parsedArgs)), absolute: false }
|
|
206
|
+
);
|
|
207
|
+
for (const filename of contractFilenames) {
|
|
208
|
+
if (await contractHasCompTarget(parsedArgs, filename)) {
|
|
209
|
+
p.push(compileContract(parsedArgs, filename));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return Promise.all(p).then(sendJsonRes2).catch((err) => sendAsyncErr2(err, false));
|
|
213
|
+
};
|
|
214
|
+
var compileAll_default = compileAll;
|
|
215
|
+
|
|
216
|
+
// test.ts
|
|
217
|
+
import { execCmd as execCmd3, getArch as getArch2, sendAsyncErr as sendAsyncErr3, sendJsonRes as sendJsonRes3, sendWarn as sendWarn3 } from "@taqueria/node-sdk";
|
|
218
|
+
var getTestContractCmd = (parsedArgs, sourceFile) => {
|
|
219
|
+
const outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);
|
|
220
|
+
const booleanFlags = " --html --purge ";
|
|
221
|
+
return `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;
|
|
222
|
+
};
|
|
223
|
+
var testContract = (parsedArgs, sourceFile) => getArch2().then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir)).then(() => getTestContractCmd(parsedArgs, sourceFile)).then(execCmd3).then(({ stdout, stderr }) => {
|
|
224
|
+
if (stderr.length > 0)
|
|
225
|
+
sendWarn3(stderr);
|
|
226
|
+
const result = "\u{1F389} All tests passed \u{1F389}";
|
|
227
|
+
return {
|
|
228
|
+
contract: sourceFile,
|
|
229
|
+
testResults: stdout.length > 0 ? `${stdout}
|
|
230
|
+
${result}` : result
|
|
231
|
+
};
|
|
232
|
+
}).catch((err) => {
|
|
233
|
+
emitExternalError(err, sourceFile);
|
|
234
|
+
return {
|
|
235
|
+
contract: sourceFile,
|
|
236
|
+
testResults: "Some tests failed :("
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
var test = (parsedArgs) => {
|
|
240
|
+
const sourceFile = addPyExtensionIfMissing(parsedArgs.sourceFile);
|
|
241
|
+
return testContract(parsedArgs, sourceFile).then((result) => [result]).then(sendJsonRes3).catch(
|
|
242
|
+
(err) => sendAsyncErr3(err, false)
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
var test_default = test;
|
|
246
|
+
|
|
247
|
+
// main.ts
|
|
248
|
+
var main = (parsedArgs) => {
|
|
249
|
+
const unsafeArgs = parsedArgs;
|
|
250
|
+
switch (unsafeArgs.task) {
|
|
251
|
+
case "compile":
|
|
252
|
+
return compile_default(unsafeArgs);
|
|
253
|
+
case "compile-all":
|
|
254
|
+
return compileAll_default(unsafeArgs);
|
|
255
|
+
case "test":
|
|
256
|
+
return test_default(unsafeArgs);
|
|
257
|
+
default:
|
|
258
|
+
return sendAsyncErr4(`${unsafeArgs.task} is not an understood task by the SmartPy plugin`);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var main_default = main;
|
|
262
|
+
|
|
263
|
+
// index.ts
|
|
264
|
+
Plugin.create((i18n) => ({
|
|
265
|
+
alias: "smartpy",
|
|
266
|
+
schema: "1.0",
|
|
267
|
+
version: "0.1",
|
|
268
|
+
tasks: [
|
|
269
|
+
Task.create({
|
|
270
|
+
task: "compile",
|
|
271
|
+
command: "compile <sourceFile>",
|
|
272
|
+
aliases: ["c", "compile-smartpy"],
|
|
273
|
+
description: "Compile a smart contract written in a SmartPy syntax to Michelson code, along with its associated storage values, per compilation targets, and some expressions per expression compilation targets",
|
|
274
|
+
handler: "proxy",
|
|
275
|
+
encoding: "json",
|
|
276
|
+
options: [
|
|
277
|
+
Option.create({
|
|
278
|
+
flag: "json",
|
|
279
|
+
boolean: true,
|
|
280
|
+
description: "Emit JSON-encoded Michelson"
|
|
281
|
+
})
|
|
282
|
+
]
|
|
283
|
+
}),
|
|
284
|
+
Task.create({
|
|
285
|
+
task: "compile-all",
|
|
286
|
+
command: "compile-all",
|
|
287
|
+
description: "Compile all SmartPy smart contracts with at least one SmartPy compilation target to Michelson code, along with their associated storage values, per compilation targets, and some expressions per expression compilation targets",
|
|
288
|
+
handler: "proxy",
|
|
289
|
+
encoding: "json",
|
|
290
|
+
options: [
|
|
291
|
+
Option.create({
|
|
292
|
+
flag: "json",
|
|
293
|
+
boolean: true,
|
|
294
|
+
description: "Emit JSON-encoded Michelson"
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
}),
|
|
298
|
+
Task.create({
|
|
299
|
+
task: "test",
|
|
300
|
+
command: "test <sourceFile>",
|
|
301
|
+
description: "Test a smart contract written in SmartPy",
|
|
302
|
+
handler: "proxy",
|
|
303
|
+
encoding: "json"
|
|
304
|
+
})
|
|
305
|
+
],
|
|
306
|
+
proxy: main_default
|
|
307
|
+
}), process.argv);
|
|
308
|
+
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts","main.ts","compile.ts","common.ts","compileAll.ts","test.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\talias: 'smartpy',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'compile',\n\t\t\tcommand: 'compile <sourceFile>',\n\t\t\taliases: ['c', 'compile-smartpy'],\n\t\t\tdescription:\n\t\t\t\t'Compile a smart contract written in a SmartPy syntax to Michelson code, along with its associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'compile-all',\n\t\t\tcommand: 'compile-all',\n\t\t\tdescription:\n\t\t\t\t'Compile all SmartPy smart contracts with at least one SmartPy compilation target to Michelson code, along with their associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test <sourceFile>',\n\t\t\tdescription: 'Test a smart contract written in SmartPy',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compileAll';\nimport test from './test';\n\nconst main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'compile':\n\t\t\treturn compile(unsafeArgs);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(unsafeArgs);\n\t\tcase 'test':\n\t\t\treturn test(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs.task} is not an understood task by the SmartPy plugin`);\n\t}\n};\n\nexport default main;\n","import { execCmd, getArch, getArtifactsDir, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { copyFile, readFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport {\n\taddPyExtensionIfMissing,\n\tCompileOpts as Opts,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n} from './common';\n\nexport type TableRow = { contract: string; artifact: string };\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), `${outputFile}${ext}`);\n};\n\nconst getOutputStorageFilename = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompilationTargetName: string,\n\tisDefaultStorage: boolean,\n): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst storageName = isDefaultStorage\n\t\t? `${outputFile}.default_storage${ext}`\n\t\t: `${outputFile}.storage.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), storageName);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, sourceFile: string, compilationTargetName: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst exprName = `${outputFile}.expression.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), exprName);\n};\n\nconst getCompilationTargetNames = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n): Promise<{ compTargetNames: string[]; exprCompTargetNames: string[] }> =>\n\treadFile(getInputFilename(parsedArgs, sourceFile), 'utf8')\n\t\t.then(data => ({\n\t\t\tcompTargetNames: data.match(/(?<=add_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t\texprCompTargetNames: data.match(/(?<=add_expression_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t}));\n\nconst copyArtifactsForFirstCompTarget = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst firstCompTargetName = compTargetNames.slice(0, 1)[0];\n\n\tconst dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_contract.json' : 'step_000_cont_0_contract.tz',\n\t\t),\n\t\tdstContractPath,\n\t);\n\n\tconst dstDefaultStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, firstCompTargetName, true);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t),\n\t\tdstDefaultStoragePath,\n\t);\n\n\treturn [dstContractPath, dstDefaultStoragePath];\n};\n\nconst copyArtifactsForRestCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);\n\n\tconst dstStoragePaths = await Promise.all(restCompTargetNames.map(async compTargetName => {\n\t\tconst dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t\t),\n\t\t\tdstStoragePath,\n\t\t);\n\t\treturn dstStoragePath;\n\t}));\n\n\treturn dstStoragePaths;\n};\n\nconst copyArtifactsForExprCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\texprCompTargetNames: string[],\n): Promise<string[]> => {\n\tif (exprCompTargetNames.length === 0) return [];\n\n\tconst dstExprPaths = await Promise.all(exprCompTargetNames.map(async compTargetName => {\n\t\tconst dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_expression.json' : 'step_000_expression.tz',\n\t\t\t),\n\t\t\tdstExprPath,\n\t\t);\n\t\treturn dstExprPath;\n\t}));\n\n\treturn dstExprPaths;\n};\n\nconst copyRelevantArtifactsForCompTargets = (parsedArgs: Opts, sourceFile: string) =>\n\tasync (\n\t\t{ compTargetNames, exprCompTargetNames }: { compTargetNames: string[]; exprCompTargetNames: string[] },\n\t): Promise<string> => {\n\t\tif (compTargetNames.length === 0 && exprCompTargetNames.length === 0) return 'No compilation targets defined';\n\n\t\tconst dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(\n\t\t\tparsedArgs,\n\t\t\tsourceFile,\n\t\t\tcompTargetNames,\n\t\t);\n\n\t\tconst dstStoragePaths = await copyArtifactsForRestCompTargets(\n\t\t\tparsedArgs,\n\t\t\tsourceFile,\n\t\t\tcompTargetNames,\n\t\t);\n\n\t\tconst dstExpressionPaths = await copyArtifactsForExprCompTargets(\n\t\t\tparsedArgs,\n\t\t\tsourceFile,\n\t\t\texprCompTargetNames,\n\t\t);\n\n\t\treturn dstContractAndDefaultStoragePaths.concat(dstStoragePaths).concat(dstExpressionPaths).join('\\n');\n\t};\n\nconst getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nexport const compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getCompileContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t})\n\t\t.then(() => getCompilationTargetNames(parsedArgs, sourceFile))\n\t\t.then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile))\n\t\t.then(relevantArtifacts => ({\n\t\t\tcontract: sourceFile,\n\t\t\tartifact: relevantArtifacts,\n\t\t}))\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t});\n\nconst compile = (parsedArgs: Opts): Promise<void> =>\n\tcompileContract(parsedArgs, addPyExtensionIfMissing(parsedArgs.sourceFile))\n\t\t.then(result => [result])\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n\nexport default compile;\n","import { execCmd, getArtifactsDir, getContractsDir, sendErr, sendWarn } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs } from '@taqueria/node-sdk/types';\nimport { access, copyFile, readdir, stat } from 'fs/promises';\nimport { join } from 'path';\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n}\n\nexport type IntersectionOpts = CompileOpts & CompileAllOpts & TestOpts;\n\ntype UnionOpts = CompileOpts | CompileAllOpts | TestOpts;\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst SMARTPY_DEFAULT_VERSION = 'v0.16.0';\n\nconst SMARTPY_VERSION_ENV_VAR = 'TAQ_SMARTPY_VERSION';\n\nconst SMARTPY_ARTIFACTS_DIR = '.smartpy';\n\nconst smartpyVersionToInstallerMap: { [k: string]: string } = {\n\t'v0.16.0': 'https://smartpy.io/releases/20221215-8f134ebb649f5a7b37c44fca8f336f970f523565/cli/install.sh',\n};\n\nconst getSmartpyVersion = (): string => {\n\tconst userDefinedSmartpyVersion = process.env[SMARTPY_VERSION_ENV_VAR];\n\tif (userDefinedSmartpyVersion) {\n\t\tif (/v0\\.1[4-6]\\./.test(userDefinedSmartpyVersion)) {\n\t\t\treturn userDefinedSmartpyVersion;\n\t\t} else {\n\t\t\tsendWarn(\n\t\t\t\t`Version ${userDefinedSmartpyVersion} is not supported by Taqueria yet. The supported versions are [${\n\t\t\t\t\tObject.keys(smartpyVersionToInstallerMap)\n\t\t\t\t}]. Will default to ${SMARTPY_DEFAULT_VERSION}`,\n\t\t\t);\n\t\t\treturn SMARTPY_DEFAULT_VERSION;\n\t\t}\n\t} else {\n\t\treturn SMARTPY_DEFAULT_VERSION;\n\t}\n};\n\nconst getPathToSmartPyCliDir = (): string => `${process.env.HOME}/smartpy-cli-${getSmartpyVersion()}`;\n\nexport const getSmartPyCli = (): string => `${getPathToSmartPyCliDir()}/SmartPy.sh`;\n\nconst getSmartPyInstallerCmd = (projectDir: string): string => {\n\tconst trimmedProjectdir = projectDir.replace(/\\/$/, '');\n\tconst installer = join(__dirname, 'install.sh');\n\tconst install = `bash ${installer} --yes --prefix ${getPathToSmartPyCliDir()} --project ${trimmedProjectdir};`;\n\treturn install;\n};\n\nexport const addPyExtensionIfMissing = (sourceFile: string): string =>\n\t/\\.py$/.test(sourceFile) ? sourceFile : `${sourceFile}.py`;\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.py$/);\n\treturn matchResult ? matchResult[0] : '';\n};\n\nconst removeExt = (path: string): string => {\n\tconst extRegex = new RegExp(extractExt(path));\n\treturn path.replace(extRegex, '');\n};\n\nexport const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getContractsDir(parsedArgs), sourceFile);\n\nexport const getCompilationTargetsDirname = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), SMARTPY_ARTIFACTS_DIR, removeExt(sourceFile));\n\nexport const installSmartPyCliIfNotExist = (projectDir: string) =>\n\taccess(getSmartPyCli())\n\t\t.catch(() => {\n\t\t\tsendWarn('SmartPy CLI not found. Installing it now...');\n\t\t\treturn execCmd(getSmartPyInstallerCmd(projectDir))\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t});\n\t\t});\n\nexport const emitExternalError = (err: unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\terr instanceof Error ? sendErr(err.message.replace(/Command failed.+?\\n/, '')) : sendErr(err as any);\n\tsendErr(`\\n===`);\n};\n","import { getContractsDir, sendAsyncErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { CompileAllOpts as Opts, CompileOpts, getInputFilename } from './common';\nimport { compileContract, TableRow } from './compile';\n\nconst contractHasCompTarget = (parsedArgs: Opts, contactFilename: string): Promise<boolean> =>\n\treadFile(getInputFilename(parsedArgs, contactFilename), 'utf8')\n\t\t.then(data => /add_(expression_)?compilation_target\\s*\\(\\s*['\"][^'\"]+['\"]/.test(data));\n\nconst compileAll = async (parsedArgs: Opts): Promise<void> => {\n\tlet p: Promise<TableRow>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.py'],\n\t\t{ cwd: join(parsedArgs.config.projectDir, getContractsDir(parsedArgs)), absolute: false },\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (await contractHasCompTarget(parsedArgs, filename)) {\n\t\t\tp.push(compileContract(parsedArgs as CompileOpts, filename));\n\t\t}\n\t}\n\n\treturn Promise.all(p).then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\taddPyExtensionIfMissing,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n\tTestOpts as Opts,\n} from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stdout, stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t};\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t};\n\t\t});\n\nconst test = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = addPyExtensionIfMissing(parsedArgs.sourceFile);\n\treturn testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default test;\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,YAAY;;;ACArC,SAAsB,gBAAAA,qBAAoB;;;ACA1C,SAAS,WAAAC,UAAS,SAAS,mBAAAC,kBAAiB,cAAc,aAAa,YAAAC,iBAAgB;AACvF,SAAS,YAAAC,WAAU,gBAAgB;AACnC,SAAS,UAAU,SAAS,QAAAC,aAAY;;;ACFxC,SAAS,SAAS,iBAAiB,iBAAiB,SAAS,gBAAgB;AAE7E,SAAS,cAAuC;AAChD,SAAS,YAAY;AAoBrB,IAAM,0BAA0B;AAEhC,IAAM,0BAA0B;AAEhC,IAAM,wBAAwB;AAE9B,IAAM,+BAAwD;AAAA,EAC7D,WAAW;AACZ;AAEA,IAAM,oBAAoB,MAAc;AACvC,QAAM,4BAA4B,QAAQ,IAAI;AAC9C,MAAI,2BAA2B;AAC9B,QAAI,eAAe,KAAK,yBAAyB,GAAG;AACnD,aAAO;AAAA,IACR,OAAO;AACN;AAAA,QACC,WAAW,2FACV,OAAO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M;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","execCmd","getArtifactsDir","sendWarn","copyFile","join","join","getArtifactsDir","copyFile","execCmd","sendWarn","getContractsDir","sendAsyncErr","sendJsonRes","readFile","join","readFile","join","getContractsDir","sendJsonRes","sendAsyncErr","execCmd","getArch","sendAsyncErr","sendJsonRes","sendWarn","getArch","execCmd","sendWarn","sendJsonRes","sendAsyncErr","sendAsyncErr"]}
|
package/install.sh
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
usage () {
|
|
6
|
+
>&2 cat <<EOF
|
|
7
|
+
Usage: $(basename $0) <options>
|
|
8
|
+
|
|
9
|
+
The options are as follows:
|
|
10
|
+
|
|
11
|
+
--prefix <prefix>
|
|
12
|
+
Install into directory <prefix>.
|
|
13
|
+
|
|
14
|
+
--native
|
|
15
|
+
Install native binaries (experimental).
|
|
16
|
+
|
|
17
|
+
--yes
|
|
18
|
+
Answer 'y' to all questions during installation.
|
|
19
|
+
|
|
20
|
+
--projectDir
|
|
21
|
+
The directory where the project is located.
|
|
22
|
+
|
|
23
|
+
--help
|
|
24
|
+
|
|
25
|
+
EOF
|
|
26
|
+
exit
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
prefix=~/smartpy-cli
|
|
30
|
+
from=AUTO
|
|
31
|
+
with_smartml=false
|
|
32
|
+
native=false
|
|
33
|
+
yes=false
|
|
34
|
+
projectDir="."
|
|
35
|
+
|
|
36
|
+
while [[ $# -gt 0 ]]; do
|
|
37
|
+
case "$1" in
|
|
38
|
+
--prefix)
|
|
39
|
+
prefix="$2"
|
|
40
|
+
shift 2
|
|
41
|
+
;;
|
|
42
|
+
--native)
|
|
43
|
+
native=true
|
|
44
|
+
shift
|
|
45
|
+
;;
|
|
46
|
+
--yes)
|
|
47
|
+
yes=true
|
|
48
|
+
shift
|
|
49
|
+
;;
|
|
50
|
+
--project)
|
|
51
|
+
projectDir="$2"
|
|
52
|
+
shift 2
|
|
53
|
+
;;
|
|
54
|
+
--help)
|
|
55
|
+
usage
|
|
56
|
+
;;
|
|
57
|
+
*)
|
|
58
|
+
>&2 echo Unexpected argument: "$1"
|
|
59
|
+
>&2 echo NOTE: SmartML not supported yet.
|
|
60
|
+
exit 1
|
|
61
|
+
;;
|
|
62
|
+
esac
|
|
63
|
+
done
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
>&2 echo -n "Install into $prefix? [y/N] "
|
|
67
|
+
if [ "$yes" == "true" ]; then
|
|
68
|
+
>&2 echo "y"
|
|
69
|
+
else
|
|
70
|
+
read ok
|
|
71
|
+
if [ "$ok" != "y" ]; then
|
|
72
|
+
>&2 echo "Installation aborted."
|
|
73
|
+
exit 1
|
|
74
|
+
fi
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
if [ -d "$prefix" ]; then
|
|
78
|
+
>&2 echo -n "The directory $prefix exists. Delete and replace? [y/N] "
|
|
79
|
+
if [ "$yes" == "true" ]; then
|
|
80
|
+
>&2 echo "y"
|
|
81
|
+
else
|
|
82
|
+
read ok
|
|
83
|
+
if [ "$ok" != "y" ]; then
|
|
84
|
+
>&2 echo "Installation aborted."
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
87
|
+
fi
|
|
88
|
+
rm -rf "$prefix"
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
if [ -e "$prefix" ]; then
|
|
92
|
+
>&2 echo "$prefix exists, but is not a directory."
|
|
93
|
+
exit 1
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
mkdir -p "$prefix"
|
|
97
|
+
|
|
98
|
+
>&2 echo "Downloading files..."
|
|
99
|
+
git clone https://gitlab.com/SmartPy/SmartPy /tmp/smartpy
|
|
100
|
+
# curl "$from"/smartpy-cli.tar.gz | tar xzf - -C "$prefix"
|
|
101
|
+
cp -Lr /tmp/smartpy/smartpy-cli/* "$prefix" 2>/dev/null || true
|
|
102
|
+
if [ "$native" != true ]; then
|
|
103
|
+
rm -f "$prefix/smartpyc"
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
# # Copy prebuilt files stored in the plugin
|
|
107
|
+
>&2 echo "Copying prebuilt files..."
|
|
108
|
+
>&2 ls $projectDir/node_modules/@taqueria/plugin-smartpy-legacy
|
|
109
|
+
PREBUILD_DIR="$projectDir/node_modules/@taqueria/plugin-smartpy-legacy/smartpy-v0.16.0"
|
|
110
|
+
for file in `ls $PREBUILD_DIR/`; do
|
|
111
|
+
dst="$prefix/`basename $file`"
|
|
112
|
+
>&2 echo $dst
|
|
113
|
+
if [ -L "$dst" ]; then
|
|
114
|
+
rm -f "$dst"
|
|
115
|
+
fi
|
|
116
|
+
cp "$PREBUILD_DIR/$file" $dst
|
|
117
|
+
done
|
|
118
|
+
|
|
119
|
+
>&2 echo "Installing npm packages..."
|
|
120
|
+
cd "$prefix"
|
|
121
|
+
npm --loglevel silent --ignore-scripts init --yes > /dev/null
|
|
122
|
+
npm --loglevel silent --ignore-scripts install libsodium-wrappers-sumo bs58check js-sha3 tezos-bls12-381 chalk @smartpy/originator @smartpy/timelock
|
|
123
|
+
cd -
|
|
124
|
+
|
|
125
|
+
>&2 echo "Cleaning up..."
|
|
126
|
+
rm -rf /tmp/smartpy
|
|
127
|
+
|
|
128
|
+
>&2 echo "Installation successful in $prefix."
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taqueria/plugin-smartpy-legacy",
|
|
3
|
+
"version": "0.37.1",
|
|
4
|
+
"description": "A taqueria plugin for compiling SmartPy smart contracts using SmartPy v0.16 (legacy syntax).",
|
|
5
|
+
"targets": {
|
|
6
|
+
"default": {
|
|
7
|
+
"source": "./index.ts",
|
|
8
|
+
"distDir": "./",
|
|
9
|
+
"context": "node",
|
|
10
|
+
"isLibrary": true
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.d.ts",
|
|
15
|
+
"index.js",
|
|
16
|
+
"index.js.map",
|
|
17
|
+
"index.mjs",
|
|
18
|
+
"index.mjs.map",
|
|
19
|
+
"install.sh",
|
|
20
|
+
"README.md",
|
|
21
|
+
"smartpy-v0.16.0"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
|
+
"build": "npx tsc -noEmit -p ./tsconfig.json && npx tsup",
|
|
26
|
+
"pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"taqueria",
|
|
30
|
+
"tezos",
|
|
31
|
+
"build",
|
|
32
|
+
"pinnaclelabs",
|
|
33
|
+
"pinnacle-labs",
|
|
34
|
+
"plugin",
|
|
35
|
+
"smartpy",
|
|
36
|
+
"smart contract",
|
|
37
|
+
"compile"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=14.5"
|
|
41
|
+
},
|
|
42
|
+
"author": "Pinnacle Labs",
|
|
43
|
+
"license": "Apache-2.0",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/pinnacle-labs/taqueria.git",
|
|
47
|
+
"directory": "taqueria-plugin-smartpy-legacy"
|
|
48
|
+
},
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/pinnacle-labs/taqueria/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/pinnacle-labs/taqueria#readme",
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@taqueria/node-sdk": "^0.37.1",
|
|
55
|
+
"fast-glob": "^3.2.12"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"tsup": "6.5.0",
|
|
59
|
+
"typescript": "^4.9.5"
|
|
60
|
+
},
|
|
61
|
+
"tsup": {
|
|
62
|
+
"entry": [
|
|
63
|
+
"index.ts"
|
|
64
|
+
],
|
|
65
|
+
"sourcemap": true,
|
|
66
|
+
"target": "node16",
|
|
67
|
+
"outDir": "./",
|
|
68
|
+
"dts": true,
|
|
69
|
+
"clean": false,
|
|
70
|
+
"skipNodeModulesBundle": true,
|
|
71
|
+
"platform": "node",
|
|
72
|
+
"format": [
|
|
73
|
+
"esm",
|
|
74
|
+
"cjs"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"gitHead": "ff58a2fc06ad233869ad6be574093c8b3b272e2e"
|
|
78
|
+
}
|