@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.js
CHANGED
|
@@ -111,12 +111,19 @@ var import_node_sdk7 = require("@taqueria/node-sdk");
|
|
|
111
111
|
|
|
112
112
|
// common.ts
|
|
113
113
|
var import_node_sdk2 = require("@taqueria/node-sdk");
|
|
114
|
+
var fs = __toESM(require("fs"));
|
|
114
115
|
var import_path = require("path");
|
|
115
|
-
var getInputFilenameAbsPath = (parsedArgs, sourceFile) => (0, import_path.join)(
|
|
116
|
+
var getInputFilenameAbsPath = (parsedArgs, sourceFile) => (0, import_path.join)(
|
|
117
|
+
parsedArgs.config.projectDir,
|
|
118
|
+
parsedArgs.config.contractsDir ?? "contracts",
|
|
119
|
+
sourceFile
|
|
120
|
+
);
|
|
116
121
|
var getInputFilenameRelPath = (parsedArgs, sourceFile) => (0, import_path.join)(parsedArgs.config.contractsDir ?? "contracts", sourceFile);
|
|
117
122
|
var formatLigoError = (err) => {
|
|
118
123
|
let result = err.message.replace(/Command failed.+?\n/, "");
|
|
119
|
-
if (result.includes(
|
|
124
|
+
if (result.includes(
|
|
125
|
+
"An internal error ocurred. Please, contact the developers."
|
|
126
|
+
) && result.includes("Module Contract not found with last Contract.")) {
|
|
120
127
|
result = `By convention, Taqueria expects you to import your contract with Contract as the module name.
|
|
121
128
|
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.`;
|
|
122
129
|
} else {
|
|
@@ -145,11 +152,42 @@ var emitExternalError = (errs, sourceFile) => {
|
|
|
145
152
|
});
|
|
146
153
|
(0, import_node_sdk2.sendErr)(`===`);
|
|
147
154
|
};
|
|
148
|
-
var configure = (dockerImage, dockerImageEnvVar) => ({
|
|
155
|
+
var configure = (dockerImage, dockerImageEnvVar, canUseLIGOBinary) => ({
|
|
149
156
|
LIGO_DEFAULT_IMAGE: dockerImage,
|
|
150
157
|
LIGO_IMAGE_ENV_VAR: dockerImageEnvVar,
|
|
151
|
-
getLigoDockerImage: () => (0, import_node_sdk2.getDockerImage)(dockerImage, dockerImageEnvVar)
|
|
158
|
+
getLigoDockerImage: () => (0, import_node_sdk2.getDockerImage)(dockerImage, dockerImageEnvVar),
|
|
159
|
+
baseDriverCmd: (projectDir) => baseDriverCmd(projectDir, dockerImage, canUseLIGOBinary)
|
|
152
160
|
});
|
|
161
|
+
function exists(path) {
|
|
162
|
+
try {
|
|
163
|
+
fs.accessSync(path, fs.constants.X_OK);
|
|
164
|
+
return true;
|
|
165
|
+
} catch {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function getLigoBinaryFromPath() {
|
|
170
|
+
const { PATH } = process.env;
|
|
171
|
+
if (!PATH) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
const paths = PATH.split(import_path.delimiter);
|
|
175
|
+
for (const candidatePath of paths) {
|
|
176
|
+
const possibleLigoPath = (0, import_path.join)(candidatePath, "ligo");
|
|
177
|
+
if (exists(possibleLigoPath)) {
|
|
178
|
+
return possibleLigoPath;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
function baseDriverCmd(projectDir, ligoDockerImage, canUseLIGOBinary) {
|
|
184
|
+
const ligoBinaryFromPath = canUseLIGOBinary ? getLigoBinaryFromPath() : null;
|
|
185
|
+
if (ligoBinaryFromPath !== null) {
|
|
186
|
+
return ligoBinaryFromPath;
|
|
187
|
+
} else {
|
|
188
|
+
return `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${ligoDockerImage}`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
153
191
|
|
|
154
192
|
// compile.ts
|
|
155
193
|
var import_node_sdk3 = require("@taqueria/node-sdk");
|
|
@@ -163,7 +201,9 @@ var isSupportedLigoSyntax = (sourceFile) => /\.(mligo|jsligo)$/.test(sourceFile)
|
|
|
163
201
|
var isUnsupportedLigoSyntax = (sourceFile) => /\.(ligo|religo)$/.test(sourceFile);
|
|
164
202
|
var isLIGOFile = (sourceFile) => isSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);
|
|
165
203
|
var isStorageListFile = (sourceFile) => /.+\.(storageList|storages)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
|
|
166
|
-
var isParameterListFile = (sourceFile) => /.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(
|
|
204
|
+
var isParameterListFile = (sourceFile) => /.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(
|
|
205
|
+
sourceFile
|
|
206
|
+
);
|
|
167
207
|
var extractExt = (path) => {
|
|
168
208
|
const matchResult = path.match(/\.(ligo|religo|mligo|jsligo)$/);
|
|
169
209
|
return matchResult ? matchResult[0] : "";
|
|
@@ -247,7 +287,7 @@ var inject = (commonObj) => {
|
|
|
247
287
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
248
288
|
if (!projectDir)
|
|
249
289
|
throw new Error(`No project directory provided`);
|
|
250
|
-
const baseCmd =
|
|
290
|
+
const baseCmd = `${commonObj.baseDriverCmd(projectDir)} info list-declarations`;
|
|
251
291
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
252
292
|
const flags = "--display-format json";
|
|
253
293
|
const cmd = `${baseCmd} ${inputFile} ${flags}`;
|
|
@@ -265,27 +305,51 @@ var inject = (commonObj) => {
|
|
|
265
305
|
const srcFile = removeExt((0, import_path2.basename)(sourceFile));
|
|
266
306
|
const syntax = extractExt(sourceFile).replace(".", "");
|
|
267
307
|
if (decl === "main") {
|
|
268
|
-
return [
|
|
308
|
+
return [
|
|
309
|
+
...acc,
|
|
310
|
+
{
|
|
311
|
+
moduleName: srcFile,
|
|
312
|
+
sourceName: sourceFile,
|
|
313
|
+
sourceFile,
|
|
314
|
+
type: "file-main",
|
|
315
|
+
syntax
|
|
316
|
+
}
|
|
317
|
+
];
|
|
269
318
|
} else if (decl === "$main") {
|
|
270
|
-
return [
|
|
319
|
+
return [
|
|
320
|
+
...acc,
|
|
321
|
+
{
|
|
322
|
+
moduleName: srcFile,
|
|
323
|
+
sourceName: sourceFile,
|
|
324
|
+
sourceFile,
|
|
325
|
+
type: "file-entry",
|
|
326
|
+
syntax
|
|
327
|
+
}
|
|
328
|
+
];
|
|
271
329
|
} else if (decl.endsWith(".main")) {
|
|
272
330
|
const moduleName = decl.replace(/\.main$/, "");
|
|
273
|
-
return [
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
331
|
+
return [
|
|
332
|
+
...acc,
|
|
333
|
+
{
|
|
334
|
+
moduleName,
|
|
335
|
+
sourceName: `${sourceFile}/${moduleName}`,
|
|
336
|
+
sourceFile,
|
|
337
|
+
type: "module-main",
|
|
338
|
+
syntax
|
|
339
|
+
}
|
|
340
|
+
];
|
|
280
341
|
} else if (decl.endsWith(".$main")) {
|
|
281
342
|
const moduleName = decl.replace(/\.\$main$/, "");
|
|
282
|
-
return [
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
343
|
+
return [
|
|
344
|
+
...acc,
|
|
345
|
+
{
|
|
346
|
+
moduleName,
|
|
347
|
+
sourceName: `${sourceFile}/${moduleName}`,
|
|
348
|
+
sourceFile,
|
|
349
|
+
type: "module-entry",
|
|
350
|
+
syntax
|
|
351
|
+
}
|
|
352
|
+
];
|
|
289
353
|
}
|
|
290
354
|
return acc;
|
|
291
355
|
},
|
|
@@ -301,7 +365,7 @@ var inject = (commonObj) => {
|
|
|
301
365
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
302
366
|
if (!projectDir)
|
|
303
367
|
throw new Error(`No project directory provided`);
|
|
304
|
-
const baseCmd =
|
|
368
|
+
const baseCmd = `${commonObj.baseDriverCmd(projectDir)} compile contract`;
|
|
305
369
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
306
370
|
const outputFile = `-o ${getOutputContractFilename(parsedArgs, module2)}`;
|
|
307
371
|
const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
|
|
@@ -333,9 +397,14 @@ var inject = (commonObj) => {
|
|
|
333
397
|
if (!projectDir)
|
|
334
398
|
throw new Error(`No project directory provided`);
|
|
335
399
|
const compilerType = isStorageKind(exprKind) ? "storage" : "parameter";
|
|
336
|
-
const baseCmd =
|
|
400
|
+
const baseCmd = `${commonObj.baseDriverCmd(projectDir)} compile ${compilerType}`;
|
|
337
401
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
338
|
-
const outputFile = `-o ${getOutputExprFilename(
|
|
402
|
+
const outputFile = `-o ${getOutputExprFilename(
|
|
403
|
+
parsedArgs,
|
|
404
|
+
module2,
|
|
405
|
+
exprKind,
|
|
406
|
+
exprName
|
|
407
|
+
)}`;
|
|
339
408
|
const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
|
|
340
409
|
const moduleFlag = (() => {
|
|
341
410
|
switch (module2.type) {
|
|
@@ -353,7 +422,12 @@ var inject = (commonObj) => {
|
|
|
353
422
|
return (0, import_node_sdk3.getArch)().then(() => getCompileExprCmd(parsedArgs, sourceFile, module2, exprKind, exprName)).then(import_node_sdk3.execCmd).then(({ stderr }) => {
|
|
354
423
|
if (stderr.length > 0)
|
|
355
424
|
(0, import_node_sdk3.sendWarn)(stderr);
|
|
356
|
-
const artifactName = getOutputExprFilename(
|
|
425
|
+
const artifactName = getOutputExprFilename(
|
|
426
|
+
parsedArgs,
|
|
427
|
+
module2,
|
|
428
|
+
exprKind,
|
|
429
|
+
exprName
|
|
430
|
+
);
|
|
357
431
|
return {
|
|
358
432
|
source: module2.sourceName,
|
|
359
433
|
artifact: artifactName
|
|
@@ -372,59 +446,85 @@ var inject = (commonObj) => {
|
|
|
372
446
|
exprs = await getExprNames(parsedArgs, sourceFile);
|
|
373
447
|
} catch (err) {
|
|
374
448
|
emitExternalError(err, sourceFile);
|
|
375
|
-
return [
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
const results = await Promise.all(exprs.map(async (exprName, index) => {
|
|
381
|
-
const compileResult = await compileExpr(
|
|
382
|
-
parsedArgs,
|
|
383
|
-
sourceFile,
|
|
384
|
-
module2,
|
|
385
|
-
exprKind === "storage" && index === 0 ? "default_storage" : exprKind
|
|
386
|
-
)(exprName);
|
|
387
|
-
return compileResult;
|
|
388
|
-
}));
|
|
389
|
-
const errors = results.reduce(
|
|
390
|
-
(acc, result) => {
|
|
391
|
-
if (result.err) {
|
|
392
|
-
if (!(result.err instanceof Error))
|
|
393
|
-
return [...acc, result.err];
|
|
394
|
-
const ligoErrs = acc.filter((err) => err instanceof Error).map((err) => err.message);
|
|
395
|
-
const formattedError = formatLigoError(result.err);
|
|
396
|
-
return ligoErrs.includes(formattedError.message) ? acc : [...acc, formattedError];
|
|
449
|
+
return [
|
|
450
|
+
{
|
|
451
|
+
source: module2.sourceName,
|
|
452
|
+
artifact: `No ${isStorageKind(exprKind) ? "storage" : "parameter"} expressions compiled`
|
|
397
453
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
454
|
+
];
|
|
455
|
+
}
|
|
456
|
+
const results = await Promise.all(
|
|
457
|
+
exprs.map(async (exprName, index) => {
|
|
458
|
+
const compileResult = await compileExpr(
|
|
459
|
+
parsedArgs,
|
|
460
|
+
sourceFile,
|
|
461
|
+
module2,
|
|
462
|
+
exprKind === "storage" && index === 0 ? "default_storage" : exprKind
|
|
463
|
+
)(exprName);
|
|
464
|
+
return compileResult;
|
|
465
|
+
})
|
|
401
466
|
);
|
|
402
|
-
const
|
|
467
|
+
const errors = results.reduce((acc, result) => {
|
|
468
|
+
if (result.err) {
|
|
469
|
+
if (!(result.err instanceof Error))
|
|
470
|
+
return [...acc, result.err];
|
|
471
|
+
const ligoErrs = acc.filter((err) => err instanceof Error).map((err) => err.message);
|
|
472
|
+
const formattedError = formatLigoError(result.err);
|
|
473
|
+
return ligoErrs.includes(formattedError.message) ? acc : [...acc, formattedError];
|
|
474
|
+
}
|
|
475
|
+
return acc;
|
|
476
|
+
}, []);
|
|
477
|
+
const retval = results.map(({ source, artifact }) => ({
|
|
478
|
+
source,
|
|
479
|
+
artifact
|
|
480
|
+
}));
|
|
403
481
|
if (errors.length)
|
|
404
482
|
emitExternalError(errors, sourceFile);
|
|
405
483
|
return retval;
|
|
406
484
|
};
|
|
407
485
|
const compileContractWithStorageAndParameter = async (parsedArgs, sourceFile, module2) => {
|
|
408
|
-
const contractCompileResult = await compileContract(
|
|
486
|
+
const contractCompileResult = await compileContract(
|
|
487
|
+
parsedArgs,
|
|
488
|
+
sourceFile,
|
|
489
|
+
module2
|
|
490
|
+
);
|
|
409
491
|
if (contractCompileResult.artifact === COMPILE_ERR_MSG)
|
|
410
492
|
return [contractCompileResult];
|
|
411
|
-
const storageListFile = `${module2.moduleName}.storageList${extractExt(
|
|
412
|
-
|
|
493
|
+
const storageListFile = `${module2.moduleName}.storageList${extractExt(
|
|
494
|
+
sourceFile
|
|
495
|
+
)}`;
|
|
496
|
+
const storageListFilename = getInputFilenameAbsPath(
|
|
497
|
+
parsedArgs,
|
|
498
|
+
storageListFile
|
|
499
|
+
);
|
|
413
500
|
const storageCompileResult = await (0, import_promises2.access)(storageListFilename).then(() => compileExprs(parsedArgs, storageListFile, module2, "storage")).catch(() => {
|
|
414
501
|
(0, import_node_sdk3.sendWarn)(
|
|
415
502
|
`Note: storage file associated with "${module2.moduleName}" can't be found, so "${storageListFile}" has been created for you. Use this file to define all initial storage values for this contract
|
|
416
503
|
`
|
|
417
504
|
);
|
|
418
|
-
return (0, import_promises2.writeFile)(
|
|
505
|
+
return (0, import_promises2.writeFile)(
|
|
506
|
+
storageListFilename,
|
|
507
|
+
initContentForStorage(module2),
|
|
508
|
+
"utf8"
|
|
509
|
+
);
|
|
419
510
|
});
|
|
420
|
-
const parameterListFile = `${module2.moduleName}.parameterList${extractExt(
|
|
421
|
-
|
|
511
|
+
const parameterListFile = `${module2.moduleName}.parameterList${extractExt(
|
|
512
|
+
sourceFile
|
|
513
|
+
)}`;
|
|
514
|
+
const parameterListFilename = getInputFilenameAbsPath(
|
|
515
|
+
parsedArgs,
|
|
516
|
+
parameterListFile
|
|
517
|
+
);
|
|
422
518
|
const parameterCompileResult = await (0, import_promises2.access)(parameterListFilename).then(() => compileExprs(parsedArgs, parameterListFile, module2, "parameter")).catch(() => {
|
|
423
519
|
(0, import_node_sdk3.sendWarn)(
|
|
424
520
|
`Note: parameter file associated with "${module2.moduleName}" can't be found, so "${parameterListFile}" has been created for you. Use this file to define all parameter values for this contract
|
|
425
521
|
`
|
|
426
522
|
);
|
|
427
|
-
return (0, import_promises2.writeFile)(
|
|
523
|
+
return (0, import_promises2.writeFile)(
|
|
524
|
+
parameterListFilename,
|
|
525
|
+
initContentForParameter(module2),
|
|
526
|
+
"utf8"
|
|
527
|
+
);
|
|
428
528
|
});
|
|
429
529
|
const storageArtifacts = storageCompileResult ? storageCompileResult.map((res) => res.artifact).join("\n") : "";
|
|
430
530
|
const parameterArtifacts = parameterCompileResult ? parameterCompileResult.map((res) => res.artifact).join("\n") : "";
|
|
@@ -459,11 +559,15 @@ var compile = async (commonObj, parsedArgs) => {
|
|
|
459
559
|
return;
|
|
460
560
|
}
|
|
461
561
|
if (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {
|
|
462
|
-
(0, import_node_sdk3.sendErr)(
|
|
562
|
+
(0, import_node_sdk3.sendErr)(
|
|
563
|
+
`Storage and parameter list files are not meant to be compiled directly`
|
|
564
|
+
);
|
|
463
565
|
return;
|
|
464
566
|
}
|
|
465
567
|
if (isUnsupportedLigoSyntax(sourceFile)) {
|
|
466
|
-
(0, import_node_sdk3.sendErr)(
|
|
568
|
+
(0, import_node_sdk3.sendErr)(
|
|
569
|
+
`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`
|
|
570
|
+
);
|
|
467
571
|
return;
|
|
468
572
|
}
|
|
469
573
|
try {
|
|
@@ -481,11 +585,17 @@ If your contract is defined within a namespace, please ensure that it is exporte
|
|
|
481
585
|
for (const module2 of modules) {
|
|
482
586
|
if (parsedArgs.module && parsedArgs.module !== module2.moduleName)
|
|
483
587
|
continue;
|
|
484
|
-
const compileResults = await compileContractWithStorageAndParameter(
|
|
588
|
+
const compileResults = await compileContractWithStorageAndParameter(
|
|
589
|
+
parsedArgs,
|
|
590
|
+
sourceFile,
|
|
591
|
+
module2
|
|
592
|
+
);
|
|
485
593
|
allCompileResults = allCompileResults.concat(compileResults);
|
|
486
594
|
}
|
|
487
|
-
(0, import_node_sdk3.sendJsonRes)(allCompileResults, {
|
|
488
|
-
|
|
595
|
+
(0, import_node_sdk3.sendJsonRes)(allCompileResults, {
|
|
596
|
+
footer: `
|
|
597
|
+
Compiled ${allCompileResults.length} contract(s) in "${sourceFile}"`
|
|
598
|
+
});
|
|
489
599
|
} catch (err) {
|
|
490
600
|
(0, import_node_sdk3.sendErr)(`Error processing "${sourceFile}": ${err}`);
|
|
491
601
|
}
|
|
@@ -520,40 +630,21 @@ var compile_all_default = compileAll;
|
|
|
520
630
|
|
|
521
631
|
// ligo.ts
|
|
522
632
|
var import_node_sdk5 = require("@taqueria/node-sdk");
|
|
523
|
-
var getArbitraryLigoCmd = (commonObj, parsedArgs,
|
|
633
|
+
var getArbitraryLigoCmd = (commonObj, parsedArgs, userArgs) => {
|
|
524
634
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
525
635
|
if (!projectDir)
|
|
526
636
|
throw `No project directory provided`;
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
"
|
|
536
|
-
|
|
537
|
-
...userMapArgs,
|
|
538
|
-
commonObj.getLigoDockerImage()
|
|
539
|
-
];
|
|
540
|
-
const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter(
|
|
541
|
-
(arg) => arg
|
|
542
|
-
);
|
|
543
|
-
const args = [...baseArgs, ...processedUserArgs, "--skip-analytics"];
|
|
544
|
-
const envVars = { "DOCKER_DEFAULT_PLATFORM": "linux/amd64" };
|
|
545
|
-
return [
|
|
546
|
-
[binary, ...args].join(" "),
|
|
547
|
-
envVars
|
|
548
|
-
];
|
|
637
|
+
const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter((arg) => arg);
|
|
638
|
+
const cmd = `${commonObj.baseDriverCmd(projectDir)} ${processedUserArgs.join(" ")}`;
|
|
639
|
+
const envVars = { DOCKER_DEFAULT_PLATFORM: "linux/amd64" };
|
|
640
|
+
return [cmd, envVars];
|
|
641
|
+
};
|
|
642
|
+
var runArbitraryLigoCmd = (commonObj, parsedArgs, userCmd) => {
|
|
643
|
+
let [cmd, envVars] = getArbitraryLigoCmd(commonObj, parsedArgs, userCmd);
|
|
644
|
+
return (0, import_node_sdk5.spawnCmd)(cmd, envVars).then(
|
|
645
|
+
(code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`
|
|
646
|
+
).catch((err) => (0, import_node_sdk5.sendAsyncErr)(`An internal error has occurred: ${err.message}`));
|
|
549
647
|
};
|
|
550
|
-
var runArbitraryLigoCmd = (commonObj, parsedArgs, cmd) => (async () => {
|
|
551
|
-
const uid = await (0, import_node_sdk5.execCmd)("id -u");
|
|
552
|
-
const gid = await (0, import_node_sdk5.execCmd)("id -g");
|
|
553
|
-
return [uid.stdout.trim(), gid.stdout.trim()];
|
|
554
|
-
})().then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd)).then(([cmd2, envVars]) => (0, import_node_sdk5.spawnCmd)(cmd2, envVars)).then(
|
|
555
|
-
(code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`
|
|
556
|
-
).catch((err) => (0, import_node_sdk5.sendAsyncErr)(`An internal error has occurred: ${err.message}`));
|
|
557
648
|
var ligo = (commonObj, parsedArgs) => {
|
|
558
649
|
const args = parsedArgs.command;
|
|
559
650
|
return runArbitraryLigoCmd(commonObj, parsedArgs, args).then(import_node_sdk5.sendRes).catch((err) => (0, import_node_sdk5.sendAsyncErr)(err, false));
|
|
@@ -563,12 +654,12 @@ var ligo_default = ligo;
|
|
|
563
654
|
// test.ts
|
|
564
655
|
var import_node_sdk6 = require("@taqueria/node-sdk");
|
|
565
656
|
var inject2 = (commonObj) => {
|
|
566
|
-
const {
|
|
657
|
+
const { baseDriverCmd: baseDriverCmd2 } = commonObj;
|
|
567
658
|
const getTestContractCmd = (parsedArgs, sourceFile) => {
|
|
568
659
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
569
660
|
if (!projectDir)
|
|
570
661
|
throw `No project directory provided`;
|
|
571
|
-
const baseCmd =
|
|
662
|
+
const baseCmd = `${baseDriverCmd2(projectDir)} run test`;
|
|
572
663
|
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
573
664
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
574
665
|
return cmd;
|
|
@@ -599,15 +690,13 @@ var test = (commonObj, parsedArgs) => {
|
|
|
599
690
|
const sourceFile = parsedArgs.sourceFile;
|
|
600
691
|
if (!sourceFile)
|
|
601
692
|
return (0, import_node_sdk6.sendAsyncErr)(`No source file provided`);
|
|
602
|
-
return testContract(parsedArgs, sourceFile).then((result) => [result]).then(import_node_sdk6.sendJsonRes).catch(
|
|
603
|
-
(err) => (0, import_node_sdk6.sendAsyncErr)(err, false)
|
|
604
|
-
);
|
|
693
|
+
return testContract(parsedArgs, sourceFile).then((result) => [result]).then(import_node_sdk6.sendJsonRes).catch((err) => (0, import_node_sdk6.sendAsyncErr)(err, false));
|
|
605
694
|
};
|
|
606
695
|
var test_default = test;
|
|
607
696
|
|
|
608
697
|
// main.ts
|
|
609
|
-
var main = (dockerImage, dockerImageEnvVar) => (parsedArgs) => {
|
|
610
|
-
const commonObj = configure(dockerImage, dockerImageEnvVar);
|
|
698
|
+
var main = (dockerImage, dockerImageEnvVar, canUseLIGOBinary) => (parsedArgs) => {
|
|
699
|
+
const commonObj = configure(dockerImage, dockerImageEnvVar, canUseLIGOBinary);
|
|
611
700
|
const unsafeOpts = parsedArgs;
|
|
612
701
|
switch (unsafeOpts.task) {
|
|
613
702
|
case "ligo":
|
|
@@ -723,7 +812,7 @@ var configurePlugin = (settings) => {
|
|
|
723
812
|
handler: createContract_default(settings.templates)
|
|
724
813
|
})
|
|
725
814
|
],
|
|
726
|
-
proxy: main_default(settings.dockerImage, settings.dockerImageEnvVar),
|
|
815
|
+
proxy: main_default(settings.dockerImage, settings.dockerImageEnvVar, settings.canUseLIGOBinary),
|
|
727
816
|
postInstall: `node ${__dirname}/postinstall.js`
|
|
728
817
|
};
|
|
729
818
|
return import_node_sdk8.Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);
|