@taqueria/lib-ligo 0.44.0 → 0.44.2
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/common.ts +67 -10
- package/compile.ts +222 -102
- package/index.d.ts +1 -0
- package/index.js +191 -102
- package/index.js.map +1 -1
- package/index.mjs +195 -106
- package/index.mjs.map +1 -1
- package/index.ts +2 -1
- package/ligo.ts +21 -37
- package/main.ts +20 -18
- package/package.json +2 -2
- package/test.ts +10 -7
package/index.mjs
CHANGED
|
@@ -83,12 +83,19 @@ import { sendAsyncErr as sendAsyncErr5, sendAsyncRes } from "@taqueria/node-sdk"
|
|
|
83
83
|
|
|
84
84
|
// common.ts
|
|
85
85
|
import { getDockerImage, sendErr } from "@taqueria/node-sdk";
|
|
86
|
-
import
|
|
87
|
-
|
|
86
|
+
import * as fs from "fs";
|
|
87
|
+
import { delimiter, join } from "path";
|
|
88
|
+
var getInputFilenameAbsPath = (parsedArgs, sourceFile) => join(
|
|
89
|
+
parsedArgs.config.projectDir,
|
|
90
|
+
parsedArgs.config.contractsDir ?? "contracts",
|
|
91
|
+
sourceFile
|
|
92
|
+
);
|
|
88
93
|
var getInputFilenameRelPath = (parsedArgs, sourceFile) => join(parsedArgs.config.contractsDir ?? "contracts", sourceFile);
|
|
89
94
|
var formatLigoError = (err) => {
|
|
90
95
|
let result = err.message.replace(/Command failed.+?\n/, "");
|
|
91
|
-
if (result.includes(
|
|
96
|
+
if (result.includes(
|
|
97
|
+
"An internal error ocurred. Please, contact the developers."
|
|
98
|
+
) && result.includes("Module Contract not found with last Contract.")) {
|
|
92
99
|
result = `By convention, Taqueria expects you to import your contract with Contract as the module name.
|
|
93
100
|
For instance, if you have a contract in a file called "increment.mligo", in your parameter/storage list file you must include #import "Increment.mligo" "Contract" for compilation to be successful.`;
|
|
94
101
|
} else {
|
|
@@ -117,11 +124,42 @@ var emitExternalError = (errs, sourceFile) => {
|
|
|
117
124
|
});
|
|
118
125
|
sendErr(`===`);
|
|
119
126
|
};
|
|
120
|
-
var configure = (dockerImage, dockerImageEnvVar) => ({
|
|
127
|
+
var configure = (dockerImage, dockerImageEnvVar, canUseLIGOBinary) => ({
|
|
121
128
|
LIGO_DEFAULT_IMAGE: dockerImage,
|
|
122
129
|
LIGO_IMAGE_ENV_VAR: dockerImageEnvVar,
|
|
123
|
-
getLigoDockerImage: () => getDockerImage(dockerImage, dockerImageEnvVar)
|
|
130
|
+
getLigoDockerImage: () => getDockerImage(dockerImage, dockerImageEnvVar),
|
|
131
|
+
baseDriverCmd: (projectDir) => baseDriverCmd(projectDir, dockerImage, canUseLIGOBinary)
|
|
124
132
|
});
|
|
133
|
+
function exists(path) {
|
|
134
|
+
try {
|
|
135
|
+
fs.accessSync(path, fs.constants.X_OK);
|
|
136
|
+
return true;
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function getLigoBinaryFromPath() {
|
|
142
|
+
const { PATH } = process.env;
|
|
143
|
+
if (!PATH) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const paths = PATH.split(delimiter);
|
|
147
|
+
for (const candidatePath of paths) {
|
|
148
|
+
const possibleLigoPath = join(candidatePath, "ligo");
|
|
149
|
+
if (exists(possibleLigoPath)) {
|
|
150
|
+
return possibleLigoPath;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
function baseDriverCmd(projectDir, ligoDockerImage, canUseLIGOBinary) {
|
|
156
|
+
const ligoBinaryFromPath = canUseLIGOBinary ? getLigoBinaryFromPath() : null;
|
|
157
|
+
if (ligoBinaryFromPath !== null) {
|
|
158
|
+
return ligoBinaryFromPath;
|
|
159
|
+
} else {
|
|
160
|
+
return `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${ligoDockerImage}`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
125
163
|
|
|
126
164
|
// compile.ts
|
|
127
165
|
import {
|
|
@@ -142,7 +180,9 @@ var isSupportedLigoSyntax = (sourceFile) => /\.(mligo|jsligo)$/.test(sourceFile)
|
|
|
142
180
|
var isUnsupportedLigoSyntax = (sourceFile) => /\.(ligo|religo)$/.test(sourceFile);
|
|
143
181
|
var isLIGOFile = (sourceFile) => isSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);
|
|
144
182
|
var isStorageListFile = (sourceFile) => /.+\.(storageList|storages)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
145
|
-
var isParameterListFile = (sourceFile) => /.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(
|
|
183
|
+
var isParameterListFile = (sourceFile) => /.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(
|
|
184
|
+
sourceFile
|
|
185
|
+
);
|
|
146
186
|
var extractExt = (path) => {
|
|
147
187
|
const matchResult = path.match(/\.(ligo|religo|mligo|jsligo)$/);
|
|
148
188
|
return matchResult ? matchResult[0] : "";
|
|
@@ -226,7 +266,7 @@ var inject = (commonObj) => {
|
|
|
226
266
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
227
267
|
if (!projectDir)
|
|
228
268
|
throw new Error(`No project directory provided`);
|
|
229
|
-
const baseCmd =
|
|
269
|
+
const baseCmd = `${commonObj.baseDriverCmd(projectDir)} info list-declarations`;
|
|
230
270
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
231
271
|
const flags = "--display-format json";
|
|
232
272
|
const cmd = `${baseCmd} ${inputFile} ${flags}`;
|
|
@@ -244,27 +284,51 @@ var inject = (commonObj) => {
|
|
|
244
284
|
const srcFile = removeExt(basename(sourceFile));
|
|
245
285
|
const syntax = extractExt(sourceFile).replace(".", "");
|
|
246
286
|
if (decl === "main") {
|
|
247
|
-
return [
|
|
287
|
+
return [
|
|
288
|
+
...acc,
|
|
289
|
+
{
|
|
290
|
+
moduleName: srcFile,
|
|
291
|
+
sourceName: sourceFile,
|
|
292
|
+
sourceFile,
|
|
293
|
+
type: "file-main",
|
|
294
|
+
syntax
|
|
295
|
+
}
|
|
296
|
+
];
|
|
248
297
|
} else if (decl === "$main") {
|
|
249
|
-
return [
|
|
298
|
+
return [
|
|
299
|
+
...acc,
|
|
300
|
+
{
|
|
301
|
+
moduleName: srcFile,
|
|
302
|
+
sourceName: sourceFile,
|
|
303
|
+
sourceFile,
|
|
304
|
+
type: "file-entry",
|
|
305
|
+
syntax
|
|
306
|
+
}
|
|
307
|
+
];
|
|
250
308
|
} else if (decl.endsWith(".main")) {
|
|
251
309
|
const moduleName = decl.replace(/\.main$/, "");
|
|
252
|
-
return [
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
310
|
+
return [
|
|
311
|
+
...acc,
|
|
312
|
+
{
|
|
313
|
+
moduleName,
|
|
314
|
+
sourceName: `${sourceFile}/${moduleName}`,
|
|
315
|
+
sourceFile,
|
|
316
|
+
type: "module-main",
|
|
317
|
+
syntax
|
|
318
|
+
}
|
|
319
|
+
];
|
|
259
320
|
} else if (decl.endsWith(".$main")) {
|
|
260
321
|
const moduleName = decl.replace(/\.\$main$/, "");
|
|
261
|
-
return [
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
322
|
+
return [
|
|
323
|
+
...acc,
|
|
324
|
+
{
|
|
325
|
+
moduleName,
|
|
326
|
+
sourceName: `${sourceFile}/${moduleName}`,
|
|
327
|
+
sourceFile,
|
|
328
|
+
type: "module-entry",
|
|
329
|
+
syntax
|
|
330
|
+
}
|
|
331
|
+
];
|
|
268
332
|
}
|
|
269
333
|
return acc;
|
|
270
334
|
},
|
|
@@ -280,7 +344,7 @@ var inject = (commonObj) => {
|
|
|
280
344
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
281
345
|
if (!projectDir)
|
|
282
346
|
throw new Error(`No project directory provided`);
|
|
283
|
-
const baseCmd =
|
|
347
|
+
const baseCmd = `${commonObj.baseDriverCmd(projectDir)} compile contract`;
|
|
284
348
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
285
349
|
const outputFile = `-o ${getOutputContractFilename(parsedArgs, module)}`;
|
|
286
350
|
const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
|
|
@@ -312,9 +376,14 @@ var inject = (commonObj) => {
|
|
|
312
376
|
if (!projectDir)
|
|
313
377
|
throw new Error(`No project directory provided`);
|
|
314
378
|
const compilerType = isStorageKind(exprKind) ? "storage" : "parameter";
|
|
315
|
-
const baseCmd =
|
|
379
|
+
const baseCmd = `${commonObj.baseDriverCmd(projectDir)} compile ${compilerType}`;
|
|
316
380
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
317
|
-
const outputFile = `-o ${getOutputExprFilename(
|
|
381
|
+
const outputFile = `-o ${getOutputExprFilename(
|
|
382
|
+
parsedArgs,
|
|
383
|
+
module,
|
|
384
|
+
exprKind,
|
|
385
|
+
exprName
|
|
386
|
+
)}`;
|
|
318
387
|
const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
|
|
319
388
|
const moduleFlag = (() => {
|
|
320
389
|
switch (module.type) {
|
|
@@ -332,7 +401,12 @@ var inject = (commonObj) => {
|
|
|
332
401
|
return getArch().then(() => getCompileExprCmd(parsedArgs, sourceFile, module, exprKind, exprName)).then(execCmd).then(({ stderr }) => {
|
|
333
402
|
if (stderr.length > 0)
|
|
334
403
|
sendWarn(stderr);
|
|
335
|
-
const artifactName = getOutputExprFilename(
|
|
404
|
+
const artifactName = getOutputExprFilename(
|
|
405
|
+
parsedArgs,
|
|
406
|
+
module,
|
|
407
|
+
exprKind,
|
|
408
|
+
exprName
|
|
409
|
+
);
|
|
336
410
|
return {
|
|
337
411
|
source: module.sourceName,
|
|
338
412
|
artifact: artifactName
|
|
@@ -351,59 +425,85 @@ var inject = (commonObj) => {
|
|
|
351
425
|
exprs = await getExprNames(parsedArgs, sourceFile);
|
|
352
426
|
} catch (err) {
|
|
353
427
|
emitExternalError(err, sourceFile);
|
|
354
|
-
return [
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
const results = await Promise.all(exprs.map(async (exprName, index) => {
|
|
360
|
-
const compileResult = await compileExpr(
|
|
361
|
-
parsedArgs,
|
|
362
|
-
sourceFile,
|
|
363
|
-
module,
|
|
364
|
-
exprKind === "storage" && index === 0 ? "default_storage" : exprKind
|
|
365
|
-
)(exprName);
|
|
366
|
-
return compileResult;
|
|
367
|
-
}));
|
|
368
|
-
const errors = results.reduce(
|
|
369
|
-
(acc, result) => {
|
|
370
|
-
if (result.err) {
|
|
371
|
-
if (!(result.err instanceof Error))
|
|
372
|
-
return [...acc, result.err];
|
|
373
|
-
const ligoErrs = acc.filter((err) => err instanceof Error).map((err) => err.message);
|
|
374
|
-
const formattedError = formatLigoError(result.err);
|
|
375
|
-
return ligoErrs.includes(formattedError.message) ? acc : [...acc, formattedError];
|
|
428
|
+
return [
|
|
429
|
+
{
|
|
430
|
+
source: module.sourceName,
|
|
431
|
+
artifact: `No ${isStorageKind(exprKind) ? "storage" : "parameter"} expressions compiled`
|
|
376
432
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
433
|
+
];
|
|
434
|
+
}
|
|
435
|
+
const results = await Promise.all(
|
|
436
|
+
exprs.map(async (exprName, index) => {
|
|
437
|
+
const compileResult = await compileExpr(
|
|
438
|
+
parsedArgs,
|
|
439
|
+
sourceFile,
|
|
440
|
+
module,
|
|
441
|
+
exprKind === "storage" && index === 0 ? "default_storage" : exprKind
|
|
442
|
+
)(exprName);
|
|
443
|
+
return compileResult;
|
|
444
|
+
})
|
|
380
445
|
);
|
|
381
|
-
const
|
|
446
|
+
const errors = results.reduce((acc, result) => {
|
|
447
|
+
if (result.err) {
|
|
448
|
+
if (!(result.err instanceof Error))
|
|
449
|
+
return [...acc, result.err];
|
|
450
|
+
const ligoErrs = acc.filter((err) => err instanceof Error).map((err) => err.message);
|
|
451
|
+
const formattedError = formatLigoError(result.err);
|
|
452
|
+
return ligoErrs.includes(formattedError.message) ? acc : [...acc, formattedError];
|
|
453
|
+
}
|
|
454
|
+
return acc;
|
|
455
|
+
}, []);
|
|
456
|
+
const retval = results.map(({ source, artifact }) => ({
|
|
457
|
+
source,
|
|
458
|
+
artifact
|
|
459
|
+
}));
|
|
382
460
|
if (errors.length)
|
|
383
461
|
emitExternalError(errors, sourceFile);
|
|
384
462
|
return retval;
|
|
385
463
|
};
|
|
386
464
|
const compileContractWithStorageAndParameter = async (parsedArgs, sourceFile, module) => {
|
|
387
|
-
const contractCompileResult = await compileContract(
|
|
465
|
+
const contractCompileResult = await compileContract(
|
|
466
|
+
parsedArgs,
|
|
467
|
+
sourceFile,
|
|
468
|
+
module
|
|
469
|
+
);
|
|
388
470
|
if (contractCompileResult.artifact === COMPILE_ERR_MSG)
|
|
389
471
|
return [contractCompileResult];
|
|
390
|
-
const storageListFile = `${module.moduleName}.storageList${extractExt(
|
|
391
|
-
|
|
472
|
+
const storageListFile = `${module.moduleName}.storageList${extractExt(
|
|
473
|
+
sourceFile
|
|
474
|
+
)}`;
|
|
475
|
+
const storageListFilename = getInputFilenameAbsPath(
|
|
476
|
+
parsedArgs,
|
|
477
|
+
storageListFile
|
|
478
|
+
);
|
|
392
479
|
const storageCompileResult = await access(storageListFilename).then(() => compileExprs(parsedArgs, storageListFile, module, "storage")).catch(() => {
|
|
393
480
|
sendWarn(
|
|
394
481
|
`Note: storage file associated with "${module.moduleName}" can't be found, so "${storageListFile}" has been created for you. Use this file to define all initial storage values for this contract
|
|
395
482
|
`
|
|
396
483
|
);
|
|
397
|
-
return writeFile2(
|
|
484
|
+
return writeFile2(
|
|
485
|
+
storageListFilename,
|
|
486
|
+
initContentForStorage(module),
|
|
487
|
+
"utf8"
|
|
488
|
+
);
|
|
398
489
|
});
|
|
399
|
-
const parameterListFile = `${module.moduleName}.parameterList${extractExt(
|
|
400
|
-
|
|
490
|
+
const parameterListFile = `${module.moduleName}.parameterList${extractExt(
|
|
491
|
+
sourceFile
|
|
492
|
+
)}`;
|
|
493
|
+
const parameterListFilename = getInputFilenameAbsPath(
|
|
494
|
+
parsedArgs,
|
|
495
|
+
parameterListFile
|
|
496
|
+
);
|
|
401
497
|
const parameterCompileResult = await access(parameterListFilename).then(() => compileExprs(parsedArgs, parameterListFile, module, "parameter")).catch(() => {
|
|
402
498
|
sendWarn(
|
|
403
499
|
`Note: parameter file associated with "${module.moduleName}" can't be found, so "${parameterListFile}" has been created for you. Use this file to define all parameter values for this contract
|
|
404
500
|
`
|
|
405
501
|
);
|
|
406
|
-
return writeFile2(
|
|
502
|
+
return writeFile2(
|
|
503
|
+
parameterListFilename,
|
|
504
|
+
initContentForParameter(module),
|
|
505
|
+
"utf8"
|
|
506
|
+
);
|
|
407
507
|
});
|
|
408
508
|
const storageArtifacts = storageCompileResult ? storageCompileResult.map((res) => res.artifact).join("\n") : "";
|
|
409
509
|
const parameterArtifacts = parameterCompileResult ? parameterCompileResult.map((res) => res.artifact).join("\n") : "";
|
|
@@ -438,11 +538,15 @@ var compile = async (commonObj, parsedArgs) => {
|
|
|
438
538
|
return;
|
|
439
539
|
}
|
|
440
540
|
if (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {
|
|
441
|
-
sendErr2(
|
|
541
|
+
sendErr2(
|
|
542
|
+
`Storage and parameter list files are not meant to be compiled directly`
|
|
543
|
+
);
|
|
442
544
|
return;
|
|
443
545
|
}
|
|
444
546
|
if (isUnsupportedLigoSyntax(sourceFile)) {
|
|
445
|
-
sendErr2(
|
|
547
|
+
sendErr2(
|
|
548
|
+
`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`
|
|
549
|
+
);
|
|
446
550
|
return;
|
|
447
551
|
}
|
|
448
552
|
try {
|
|
@@ -460,11 +564,17 @@ If your contract is defined within a namespace, please ensure that it is exporte
|
|
|
460
564
|
for (const module of modules) {
|
|
461
565
|
if (parsedArgs.module && parsedArgs.module !== module.moduleName)
|
|
462
566
|
continue;
|
|
463
|
-
const compileResults = await compileContractWithStorageAndParameter(
|
|
567
|
+
const compileResults = await compileContractWithStorageAndParameter(
|
|
568
|
+
parsedArgs,
|
|
569
|
+
sourceFile,
|
|
570
|
+
module
|
|
571
|
+
);
|
|
464
572
|
allCompileResults = allCompileResults.concat(compileResults);
|
|
465
573
|
}
|
|
466
|
-
sendJsonRes(allCompileResults, {
|
|
467
|
-
|
|
574
|
+
sendJsonRes(allCompileResults, {
|
|
575
|
+
footer: `
|
|
576
|
+
Compiled ${allCompileResults.length} contract(s) in "${sourceFile}"`
|
|
577
|
+
});
|
|
468
578
|
} catch (err) {
|
|
469
579
|
sendErr2(`Error processing "${sourceFile}": ${err}`);
|
|
470
580
|
}
|
|
@@ -498,41 +608,22 @@ var compileAll = async (commonObj, parsedArgs) => {
|
|
|
498
608
|
var compile_all_default = compileAll;
|
|
499
609
|
|
|
500
610
|
// ligo.ts
|
|
501
|
-
import {
|
|
502
|
-
var getArbitraryLigoCmd = (commonObj, parsedArgs,
|
|
611
|
+
import { sendAsyncErr as sendAsyncErr3, sendRes as sendRes2, spawnCmd } from "@taqueria/node-sdk";
|
|
612
|
+
var getArbitraryLigoCmd = (commonObj, parsedArgs, userArgs) => {
|
|
503
613
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
504
614
|
if (!projectDir)
|
|
505
615
|
throw `No project directory provided`;
|
|
506
|
-
const
|
|
507
|
-
const
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
"
|
|
515
|
-
|
|
516
|
-
...userMapArgs,
|
|
517
|
-
commonObj.getLigoDockerImage()
|
|
518
|
-
];
|
|
519
|
-
const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter(
|
|
520
|
-
(arg) => arg
|
|
521
|
-
);
|
|
522
|
-
const args = [...baseArgs, ...processedUserArgs, "--skip-analytics"];
|
|
523
|
-
const envVars = { "DOCKER_DEFAULT_PLATFORM": "linux/amd64" };
|
|
524
|
-
return [
|
|
525
|
-
[binary, ...args].join(" "),
|
|
526
|
-
envVars
|
|
527
|
-
];
|
|
616
|
+
const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter((arg) => arg);
|
|
617
|
+
const cmd = `${commonObj.baseDriverCmd(projectDir)} ${processedUserArgs.join(" ")}`;
|
|
618
|
+
const envVars = { DOCKER_DEFAULT_PLATFORM: "linux/amd64" };
|
|
619
|
+
return [cmd, envVars];
|
|
620
|
+
};
|
|
621
|
+
var runArbitraryLigoCmd = (commonObj, parsedArgs, userCmd) => {
|
|
622
|
+
let [cmd, envVars] = getArbitraryLigoCmd(commonObj, parsedArgs, userCmd);
|
|
623
|
+
return spawnCmd(cmd, envVars).then(
|
|
624
|
+
(code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`
|
|
625
|
+
).catch((err) => sendAsyncErr3(`An internal error has occurred: ${err.message}`));
|
|
528
626
|
};
|
|
529
|
-
var runArbitraryLigoCmd = (commonObj, parsedArgs, cmd) => (async () => {
|
|
530
|
-
const uid = await execCmd2("id -u");
|
|
531
|
-
const gid = await execCmd2("id -g");
|
|
532
|
-
return [uid.stdout.trim(), gid.stdout.trim()];
|
|
533
|
-
})().then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd)).then(([cmd2, envVars]) => spawnCmd(cmd2, envVars)).then(
|
|
534
|
-
(code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`
|
|
535
|
-
).catch((err) => sendAsyncErr3(`An internal error has occurred: ${err.message}`));
|
|
536
627
|
var ligo = (commonObj, parsedArgs) => {
|
|
537
628
|
const args = parsedArgs.command;
|
|
538
629
|
return runArbitraryLigoCmd(commonObj, parsedArgs, args).then(sendRes2).catch((err) => sendAsyncErr3(err, false));
|
|
@@ -540,19 +631,19 @@ var ligo = (commonObj, parsedArgs) => {
|
|
|
540
631
|
var ligo_default = ligo;
|
|
541
632
|
|
|
542
633
|
// test.ts
|
|
543
|
-
import { execCmd as
|
|
634
|
+
import { execCmd as execCmd2, getArch as getArch2, sendAsyncErr as sendAsyncErr4, sendJsonRes as sendJsonRes3, sendWarn as sendWarn2 } from "@taqueria/node-sdk";
|
|
544
635
|
var inject2 = (commonObj) => {
|
|
545
|
-
const {
|
|
636
|
+
const { baseDriverCmd: baseDriverCmd2 } = commonObj;
|
|
546
637
|
const getTestContractCmd = (parsedArgs, sourceFile) => {
|
|
547
638
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
548
639
|
if (!projectDir)
|
|
549
640
|
throw `No project directory provided`;
|
|
550
|
-
const baseCmd =
|
|
641
|
+
const baseCmd = `${baseDriverCmd2(projectDir)} run test`;
|
|
551
642
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
552
643
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
553
644
|
return cmd;
|
|
554
645
|
};
|
|
555
|
-
const testContract = (parsedArgs, sourceFile) =>
|
|
646
|
+
const testContract = (parsedArgs, sourceFile) => getArch2().then(() => getTestContractCmd(parsedArgs, sourceFile)).then(execCmd2).then(({ stdout, stderr }) => {
|
|
556
647
|
if (stderr.length > 0)
|
|
557
648
|
sendWarn2(stderr);
|
|
558
649
|
const result = "\u{1F389} All tests passed \u{1F389}";
|
|
@@ -578,15 +669,13 @@ var test = (commonObj, parsedArgs) => {
|
|
|
578
669
|
const sourceFile = parsedArgs.sourceFile;
|
|
579
670
|
if (!sourceFile)
|
|
580
671
|
return sendAsyncErr4(`No source file provided`);
|
|
581
|
-
return testContract(parsedArgs, sourceFile).then((result) => [result]).then(sendJsonRes3).catch(
|
|
582
|
-
(err) => sendAsyncErr4(err, false)
|
|
583
|
-
);
|
|
672
|
+
return testContract(parsedArgs, sourceFile).then((result) => [result]).then(sendJsonRes3).catch((err) => sendAsyncErr4(err, false));
|
|
584
673
|
};
|
|
585
674
|
var test_default = test;
|
|
586
675
|
|
|
587
676
|
// main.ts
|
|
588
|
-
var main = (dockerImage, dockerImageEnvVar) => (parsedArgs) => {
|
|
589
|
-
const commonObj = configure(dockerImage, dockerImageEnvVar);
|
|
677
|
+
var main = (dockerImage, dockerImageEnvVar, canUseLIGOBinary) => (parsedArgs) => {
|
|
678
|
+
const commonObj = configure(dockerImage, dockerImageEnvVar, canUseLIGOBinary);
|
|
590
679
|
const unsafeOpts = parsedArgs;
|
|
591
680
|
switch (unsafeOpts.task) {
|
|
592
681
|
case "ligo":
|
|
@@ -702,7 +791,7 @@ var configurePlugin = (settings) => {
|
|
|
702
791
|
handler: createContract_default(settings.templates)
|
|
703
792
|
})
|
|
704
793
|
],
|
|
705
|
-
proxy: main_default(settings.dockerImage, settings.dockerImageEnvVar),
|
|
794
|
+
proxy: main_default(settings.dockerImage, settings.dockerImageEnvVar, settings.canUseLIGOBinary),
|
|
706
795
|
postInstall: `node ${__dirname}/postinstall.js`
|
|
707
796
|
};
|
|
708
797
|
return Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);
|