@taqueria/lib-ligo 0.40.20 → 0.40.23
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 +16 -4
- package/compile.ts +3 -2
- package/index.js +38 -37
- package/index.js.map +1 -1
- package/index.mjs +16 -15
- package/index.mjs.map +1 -1
- package/ligo.ts +5 -17
- package/package.json +2 -2
- package/postinstall.js +17 -0
package/common.ts
CHANGED
|
@@ -39,12 +39,24 @@ export const formatLigoError = (err: Error): Error => {
|
|
|
39
39
|
) {
|
|
40
40
|
result =
|
|
41
41
|
`By convention, Taqueria expects you to import your contract with Contract as the module name.\nFor 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.`;
|
|
42
|
+
} else {
|
|
43
|
+
const regex = /contracts\/(.+): No such file or directory/;
|
|
44
|
+
const match = regex.exec(result);
|
|
45
|
+
if (match) {
|
|
46
|
+
const filename = match[1];
|
|
47
|
+
result =
|
|
48
|
+
`The file ${filename} was not found. Please ensure that the file exists and that it is in the contracts directory.`;
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
51
|
|
|
44
|
-
err.message = result
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
err.message = result
|
|
53
|
+
.replace(
|
|
54
|
+
'An internal error ocurred. Please, contact the developers.',
|
|
55
|
+
'The LIGO compiler experienced an internal error. Please contact the LIGO developers.',
|
|
56
|
+
).replace(
|
|
57
|
+
/Module ("Contract\.[^"]+") not found/,
|
|
58
|
+
'The module $1 was not found. If your contract is defined within a namespace, please ensure that it has been exported.',
|
|
59
|
+
);
|
|
48
60
|
|
|
49
61
|
return err;
|
|
50
62
|
};
|
package/compile.ts
CHANGED
|
@@ -222,6 +222,7 @@ export const inject = (commonObj: Common) => {
|
|
|
222
222
|
[],
|
|
223
223
|
);
|
|
224
224
|
} catch (err) {
|
|
225
|
+
const formattedErr = err instanceof Error ? formatLigoError(err) : err;
|
|
225
226
|
emitExternalError(err, sourceFile);
|
|
226
227
|
return [];
|
|
227
228
|
}
|
|
@@ -378,7 +379,6 @@ export const inject = (commonObj: Common) => {
|
|
|
378
379
|
): Promise<TableRow[]> => {
|
|
379
380
|
const contractCompileResult = await compileContract(parsedArgs, sourceFile, module);
|
|
380
381
|
if (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];
|
|
381
|
-
debugger;
|
|
382
382
|
|
|
383
383
|
const storageListFile = `${module.moduleName}.storageList${extractExt(sourceFile)}`;
|
|
384
384
|
const storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);
|
|
@@ -455,7 +455,8 @@ export const compile = async (commonObj: Common, parsedArgs: Opts): Promise<void
|
|
|
455
455
|
return sendJsonRes([
|
|
456
456
|
{
|
|
457
457
|
source: sourceFile,
|
|
458
|
-
artifact:
|
|
458
|
+
artifact:
|
|
459
|
+
`No contract modules found in "${sourceFile}".\nIf your contract is defined within a namespace, please ensure that it is exported from the contract file."`,
|
|
459
460
|
},
|
|
460
461
|
]);
|
|
461
462
|
}
|
package/index.js
CHANGED
|
@@ -33,7 +33,7 @@ __export(taqueria_lib_ligo_exports, {
|
|
|
33
33
|
configurePlugin: () => configurePlugin
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(taqueria_lib_ligo_exports);
|
|
36
|
-
var
|
|
36
|
+
var import_node_sdk8 = require("@taqueria/node-sdk");
|
|
37
37
|
|
|
38
38
|
// createContract.ts
|
|
39
39
|
var import_node_sdk = require("@taqueria/node-sdk");
|
|
@@ -107,7 +107,7 @@ var createContract = (templates) => (args) => {
|
|
|
107
107
|
var createContract_default = createContract;
|
|
108
108
|
|
|
109
109
|
// main.ts
|
|
110
|
-
var
|
|
110
|
+
var import_node_sdk7 = require("@taqueria/node-sdk");
|
|
111
111
|
|
|
112
112
|
// common.ts
|
|
113
113
|
var import_node_sdk2 = require("@taqueria/node-sdk");
|
|
@@ -119,10 +119,20 @@ var formatLigoError = (err) => {
|
|
|
119
119
|
if (result.includes("An internal error ocurred. Please, contact the developers.") && result.includes("Module Contract not found with last Contract.")) {
|
|
120
120
|
result = `By convention, Taqueria expects you to import your contract with Contract as the module name.
|
|
121
121
|
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
|
+
} else {
|
|
123
|
+
const regex = /contracts\/(.+): No such file or directory/;
|
|
124
|
+
const match = regex.exec(result);
|
|
125
|
+
if (match) {
|
|
126
|
+
const filename = match[1];
|
|
127
|
+
result = `The file ${filename} was not found. Please ensure that the file exists and that it is in the contracts directory.`;
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
130
|
err.message = result.replace(
|
|
124
131
|
"An internal error ocurred. Please, contact the developers.",
|
|
125
132
|
"The LIGO compiler experienced an internal error. Please contact the LIGO developers."
|
|
133
|
+
).replace(
|
|
134
|
+
/Module ("Contract\.[^"]+") not found/,
|
|
135
|
+
"The module $1 was not found. If your contract is defined within a namespace, please ensure that it has been exported."
|
|
126
136
|
);
|
|
127
137
|
return err;
|
|
128
138
|
};
|
|
@@ -282,6 +292,7 @@ var inject = (commonObj) => {
|
|
|
282
292
|
[]
|
|
283
293
|
);
|
|
284
294
|
} catch (err) {
|
|
295
|
+
const formattedErr = err instanceof Error ? formatLigoError(err) : err;
|
|
285
296
|
emitExternalError(err, sourceFile);
|
|
286
297
|
return [];
|
|
287
298
|
}
|
|
@@ -397,7 +408,6 @@ var inject = (commonObj) => {
|
|
|
397
408
|
const contractCompileResult = await compileContract(parsedArgs, sourceFile, module2);
|
|
398
409
|
if (contractCompileResult.artifact === COMPILE_ERR_MSG)
|
|
399
410
|
return [contractCompileResult];
|
|
400
|
-
debugger;
|
|
401
411
|
const storageListFile = `${module2.moduleName}.storageList${extractExt(sourceFile)}`;
|
|
402
412
|
const storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);
|
|
403
413
|
const storageCompileResult = await (0, import_promises2.access)(storageListFilename).then(() => compileExprs(parsedArgs, storageListFile, module2, "storage")).catch(() => {
|
|
@@ -462,7 +472,8 @@ var compile = async (commonObj, parsedArgs) => {
|
|
|
462
472
|
return (0, import_node_sdk3.sendJsonRes)([
|
|
463
473
|
{
|
|
464
474
|
source: sourceFile,
|
|
465
|
-
artifact: `No contract modules found in "${sourceFile}"
|
|
475
|
+
artifact: `No contract modules found in "${sourceFile}".
|
|
476
|
+
If your contract is defined within a namespace, please ensure that it is exported from the contract file."`
|
|
466
477
|
}
|
|
467
478
|
]);
|
|
468
479
|
}
|
|
@@ -509,8 +520,6 @@ var compile_all_default = compileAll;
|
|
|
509
520
|
|
|
510
521
|
// ligo.ts
|
|
511
522
|
var import_node_sdk5 = require("@taqueria/node-sdk");
|
|
512
|
-
var import_node_sdk6 = require("@taqueria/node-sdk");
|
|
513
|
-
var import_path4 = require("path");
|
|
514
523
|
var getArbitraryLigoCmd = (commonObj, parsedArgs, uid, gid, userArgs) => {
|
|
515
524
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
516
525
|
if (!projectDir)
|
|
@@ -538,19 +547,11 @@ var getArbitraryLigoCmd = (commonObj, parsedArgs, uid, gid, userArgs) => {
|
|
|
538
547
|
envVars
|
|
539
548
|
];
|
|
540
549
|
};
|
|
541
|
-
var
|
|
542
|
-
const esyJsonPath = (0, import_path4.join)(parsedArgs.projectDir, "esy.json");
|
|
543
|
-
try {
|
|
544
|
-
return await (0, import_node_sdk6.readJsonFile)(esyJsonPath);
|
|
545
|
-
} catch {
|
|
546
|
-
return await (0, import_node_sdk6.writeJsonFile)(esyJsonPath)({});
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
var runArbitraryLigoCmd = (commonObj, parsedArgs, cmd) => ensureEsyExists(parsedArgs).then(import_node_sdk5.getArch).then(async () => {
|
|
550
|
+
var runArbitraryLigoCmd = (commonObj, parsedArgs, cmd) => (async () => {
|
|
550
551
|
const uid = await (0, import_node_sdk5.execCmd)("id -u");
|
|
551
552
|
const gid = await (0, import_node_sdk5.execCmd)("id -g");
|
|
552
553
|
return [uid.stdout.trim(), gid.stdout.trim()];
|
|
553
|
-
}).then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd)).then(([cmd2, envVars]) => (0, import_node_sdk5.spawnCmd)(cmd2, envVars)).then(
|
|
554
|
+
})().then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd)).then(([cmd2, envVars]) => (0, import_node_sdk5.spawnCmd)(cmd2, envVars)).then(
|
|
554
555
|
(code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`
|
|
555
556
|
).catch((err) => (0, import_node_sdk5.sendAsyncErr)(`An internal error has occurred: ${err.message}`));
|
|
556
557
|
var ligo = (commonObj, parsedArgs) => {
|
|
@@ -560,7 +561,7 @@ var ligo = (commonObj, parsedArgs) => {
|
|
|
560
561
|
var ligo_default = ligo;
|
|
561
562
|
|
|
562
563
|
// test.ts
|
|
563
|
-
var
|
|
564
|
+
var import_node_sdk6 = require("@taqueria/node-sdk");
|
|
564
565
|
var inject2 = (commonObj) => {
|
|
565
566
|
const { getLigoDockerImage } = commonObj;
|
|
566
567
|
const getTestContractCmd = (parsedArgs, sourceFile) => {
|
|
@@ -572,9 +573,9 @@ var inject2 = (commonObj) => {
|
|
|
572
573
|
const cmd = `${baseCmd} ${inputFile}`;
|
|
573
574
|
return cmd;
|
|
574
575
|
};
|
|
575
|
-
const testContract = (parsedArgs, sourceFile) => (0,
|
|
576
|
+
const testContract = (parsedArgs, sourceFile) => (0, import_node_sdk6.getArch)().then(() => getTestContractCmd(parsedArgs, sourceFile)).then(import_node_sdk6.execCmd).then(({ stdout, stderr }) => {
|
|
576
577
|
if (stderr.length > 0)
|
|
577
|
-
(0,
|
|
578
|
+
(0, import_node_sdk6.sendWarn)(stderr);
|
|
578
579
|
const result = "\u{1F389} All tests passed \u{1F389}";
|
|
579
580
|
return {
|
|
580
581
|
contract: sourceFile,
|
|
@@ -597,9 +598,9 @@ var test = (commonObj, parsedArgs) => {
|
|
|
597
598
|
const { testContract } = inject2(commonObj);
|
|
598
599
|
const sourceFile = parsedArgs.sourceFile;
|
|
599
600
|
if (!sourceFile)
|
|
600
|
-
return (0,
|
|
601
|
-
return testContract(parsedArgs, sourceFile).then((result) => [result]).then(
|
|
602
|
-
(err) => (0,
|
|
601
|
+
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)
|
|
603
604
|
);
|
|
604
605
|
};
|
|
605
606
|
var test_default = test;
|
|
@@ -618,9 +619,9 @@ var main = (dockerImage, dockerImageEnvVar) => (parsedArgs) => {
|
|
|
618
619
|
case "test":
|
|
619
620
|
return test_default(commonObj, parsedArgs);
|
|
620
621
|
case "get-image":
|
|
621
|
-
return (0,
|
|
622
|
+
return (0, import_node_sdk7.sendAsyncRes)(commonObj.getLigoDockerImage());
|
|
622
623
|
default:
|
|
623
|
-
return (0,
|
|
624
|
+
return (0, import_node_sdk7.sendAsyncErr)(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);
|
|
624
625
|
}
|
|
625
626
|
};
|
|
626
627
|
var main_default = main;
|
|
@@ -633,12 +634,12 @@ var configurePlugin = (settings) => {
|
|
|
633
634
|
version: "0.1",
|
|
634
635
|
alias: settings.alias,
|
|
635
636
|
tasks: [
|
|
636
|
-
|
|
637
|
+
import_node_sdk8.Task.create({
|
|
637
638
|
task: "ligo",
|
|
638
639
|
command: "ligo",
|
|
639
640
|
description: "This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria",
|
|
640
641
|
options: [
|
|
641
|
-
|
|
642
|
+
import_node_sdk8.Option.create({
|
|
642
643
|
shortFlag: "c",
|
|
643
644
|
flag: "command",
|
|
644
645
|
type: "string",
|
|
@@ -649,18 +650,18 @@ var configurePlugin = (settings) => {
|
|
|
649
650
|
handler: "proxy",
|
|
650
651
|
encoding: "none"
|
|
651
652
|
}),
|
|
652
|
-
|
|
653
|
+
import_node_sdk8.Task.create({
|
|
653
654
|
task: "compile",
|
|
654
655
|
command: "compile <sourceFile>",
|
|
655
656
|
aliases: ["c", "compile-ligo"],
|
|
656
657
|
description: "Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found",
|
|
657
658
|
options: [
|
|
658
|
-
|
|
659
|
+
import_node_sdk8.Option.create({
|
|
659
660
|
flag: "json",
|
|
660
661
|
boolean: true,
|
|
661
662
|
description: "Emit JSON-encoded Michelson"
|
|
662
663
|
}),
|
|
663
|
-
|
|
664
|
+
import_node_sdk8.Option.create({
|
|
664
665
|
flag: "module",
|
|
665
666
|
shortFlag: "m",
|
|
666
667
|
type: "string",
|
|
@@ -670,12 +671,12 @@ var configurePlugin = (settings) => {
|
|
|
670
671
|
handler: "proxy",
|
|
671
672
|
encoding: "json"
|
|
672
673
|
}),
|
|
673
|
-
|
|
674
|
+
import_node_sdk8.Task.create({
|
|
674
675
|
task: "compile-all",
|
|
675
676
|
command: "compile-all",
|
|
676
677
|
description: "Compile all main smart contracts written in a LIGO syntax to Michelson code, along with their associated storage/parameter list files if they are found",
|
|
677
678
|
options: [
|
|
678
|
-
|
|
679
|
+
import_node_sdk8.Option.create({
|
|
679
680
|
flag: "json",
|
|
680
681
|
boolean: true,
|
|
681
682
|
description: "Emit JSON-encoded Michelson"
|
|
@@ -684,14 +685,14 @@ var configurePlugin = (settings) => {
|
|
|
684
685
|
handler: "proxy",
|
|
685
686
|
encoding: "json"
|
|
686
687
|
}),
|
|
687
|
-
|
|
688
|
+
import_node_sdk8.Task.create({
|
|
688
689
|
task: "test",
|
|
689
690
|
command: "test <sourceFile>",
|
|
690
691
|
description: "Test a smart contract written in LIGO",
|
|
691
692
|
handler: "proxy",
|
|
692
693
|
encoding: "json"
|
|
693
694
|
}),
|
|
694
|
-
|
|
695
|
+
import_node_sdk8.Task.create({
|
|
695
696
|
task: "get-image",
|
|
696
697
|
command: "get-image",
|
|
697
698
|
description: "Gets the name of the image to be used",
|
|
@@ -700,19 +701,19 @@ var configurePlugin = (settings) => {
|
|
|
700
701
|
})
|
|
701
702
|
],
|
|
702
703
|
templates: [
|
|
703
|
-
|
|
704
|
+
import_node_sdk8.Template.create({
|
|
704
705
|
template: "contract",
|
|
705
706
|
command: "contract <sourceFileName>",
|
|
706
707
|
description: "Create a LIGO contract with boilerplate code",
|
|
707
708
|
positionals: [
|
|
708
|
-
|
|
709
|
+
import_node_sdk8.PositionalArg.create({
|
|
709
710
|
placeholder: "sourceFileName",
|
|
710
711
|
type: "string",
|
|
711
712
|
description: "The name of the LIGO contract to generate"
|
|
712
713
|
})
|
|
713
714
|
],
|
|
714
715
|
options: [
|
|
715
|
-
|
|
716
|
+
import_node_sdk8.Option.create({
|
|
716
717
|
shortFlag: "s",
|
|
717
718
|
flag: "syntax",
|
|
718
719
|
type: "string",
|
|
@@ -725,7 +726,7 @@ var configurePlugin = (settings) => {
|
|
|
725
726
|
proxy: main_default(settings.dockerImage, settings.dockerImageEnvVar),
|
|
726
727
|
postInstall: `node ${__dirname}/postinstall.js`
|
|
727
728
|
};
|
|
728
|
-
return
|
|
729
|
+
return import_node_sdk8.Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);
|
|
729
730
|
};
|
|
730
731
|
// Annotate the CommonJS export names for ESM import in node:
|
|
731
732
|
0 && (module.exports = {
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","createContract.ts","ligo_templates.ts","main.ts","common.ts","compile.ts","compile-all.ts","ligo.ts","test.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport * as PluginSchema from '@taqueria/protocol/PluginSchema';\n\nimport createContract from './createContract';\nimport main from './main';\n\ntype PluginConfigurator = (plugin: PluginSchema.RawPluginSchema) => PluginSchema.RawPluginSchema;\ntype ConfiguratorArgs = {\n\tname: string;\n\talias: string;\n\tconfigurator?: PluginConfigurator;\n\tunparsedArgs: string[];\n\tdockerImage: string;\n\tdockerImageEnvVar: string;\n\ttemplates?: Record<string, string>;\n};\n\nexport const configurePlugin = (settings: ConfiguratorArgs) => {\n\tconst schema = {\n\t\tname: settings.name,\n\t\tschema: '1.0',\n\t\tversion: '0.1',\n\t\talias: settings.alias,\n\t\ttasks: [\n\t\t\tTask.create({\n\t\t\t\ttask: 'ligo',\n\t\t\t\tcommand: 'ligo',\n\t\t\t\tdescription:\n\t\t\t\t\t'This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 'c',\n\t\t\t\t\t\tflag: 'command',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The command to be passed to the underlying LIGO binary, wrapped in quotes',\n\t\t\t\t\t\trequired: true,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'none',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile',\n\t\t\t\tcommand: 'compile <sourceFile>',\n\t\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'module',\n\t\t\t\t\t\tshortFlag: 'm',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The LIGO module to be compiled',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile-all',\n\t\t\t\tcommand: 'compile-all',\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile all main smart contracts written in a LIGO syntax to Michelson code, along with their associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'test',\n\t\t\t\tcommand: 'test <sourceFile>',\n\t\t\t\tdescription: 'Test a smart contract written in LIGO',\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'get-image',\n\t\t\t\tcommand: 'get-image',\n\t\t\t\tdescription: 'Gets the name of the image to be used',\n\t\t\t\thandler: 'proxy',\n\t\t\t\thidden: true,\n\t\t\t}),\n\t\t],\n\t\ttemplates: [\n\t\t\tTemplate.create({\n\t\t\t\ttemplate: 'contract',\n\t\t\t\tcommand: 'contract <sourceFileName>',\n\t\t\t\tdescription: 'Create a LIGO contract with boilerplate code',\n\t\t\t\tpositionals: [\n\t\t\t\t\tPositionalArg.create({\n\t\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The name of the LIGO contract to generate',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 's',\n\t\t\t\t\t\tflag: 'syntax',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The syntax used in the contract',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: createContract(settings.templates),\n\t\t\t}),\n\t\t],\n\t\tproxy: main(settings.dockerImage, settings.dockerImageEnvVar),\n\t\tpostInstall: `node ${__dirname}/postinstall.js`,\n\t};\n\n\treturn Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);\n};\n","import { sendAsyncErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { writeFile } from 'fs/promises';\nimport * as default_templates from './ligo_templates';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n\tsyntax?: string;\n}\n\nconst getLigoTemplate = async (\n\tcontractName: string,\n\tsyntax: string | undefined,\n\ttemplateOverrides?: Record<string, string>,\n): Promise<string> => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0].substring(1) : null;\n\tconst templates = templateOverrides ?? default_templates;\n\n\tif (syntax === 'mligo') return templates.mligo_template;\n\tif (syntax === 'jsligo') return templates.jsligo_template;\n\n\tif (syntax === undefined) {\n\t\tif (ext === 'mligo') return templates.mligo_template;\n\t\tif (ext === 'jsligo') return templates.jsligo_template;\n\t\treturn sendAsyncErr(\n\t\t\t`Unable to infer LIGO syntax from \"${contractName}\". Please specify a LIGO syntax via the --syntax option`,\n\t\t);\n\t} else {\n\t\treturn sendAsyncErr(`\"${syntax}\" is not a valid syntax. Please specify a valid LIGO syntax`);\n\t}\n};\n\nconst createContract = (templates?: Record<string, string>) => (args: RequestArgs.t) => {\n\tconst unsafeOpts = args as unknown as Opts;\n\tconst contractName = unsafeOpts.sourceFileName as string;\n\tconst syntax = unsafeOpts.syntax;\n\tconst contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;\n\treturn getLigoTemplate(contractName, syntax, templates)\n\t\t.then(ligo_template => writeFile(`${contractsDir}/${contractName}`, ligo_template));\n};\n\nexport default createContract;\n","export const mligo_template = `\ntype storage = int\ntype return = operation list * storage\n\n(* Three entrypoints *)\n[@entry] let increment (delta : int) (store : storage) : return =\n [], store + delta\n[@entry] let decrement (delta : int) (store : storage) : return =\n [], store - delta\n[@entry] let reset (() : unit) (_ : storage) : return =\n [], 0\n`;\n\nexport const jsligo_template = `\ntype storage = int;\ntype ret = [list<operation>, storage];\n\n// Three entrypoints\n\n// @entry\nconst increment = (delta : int, store : storage) : ret =>\n [list([]), store + delta];\n\n// @entry\nconst decrement = (delta : int, store : storage) : ret =>\n [list([]), store - delta];\n\n// @entry\nconst reset = (_ : unit, _ : storage) : ret =>\n [list([]), 0];\n`;\n","import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { configure, IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compile-all';\nimport ligo from './ligo';\nimport test from './test';\n\nconst main = (dockerImage: string, dockerImageEnvVar: string) => (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst commonObj = configure(dockerImage, dockerImageEnvVar);\n\tconst unsafeOpts = parsedArgs as unknown as Opts;\n\tswitch (unsafeOpts.task) {\n\t\tcase 'ligo':\n\t\t\treturn ligo(commonObj, unsafeOpts);\n\t\tcase 'compile':\n\t\t\treturn compile(commonObj, unsafeOpts);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(commonObj, unsafeOpts);\n\t\tcase 'test':\n\t\t\treturn test(commonObj, parsedArgs);\n\t\tcase 'get-image':\n\t\t\treturn sendAsyncRes(commonObj.getLigoDockerImage());\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);\n\t}\n};\n\nexport default main;\n","import { getDockerImage, sendErr } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk/types';\nimport { join } from 'path';\n\nexport interface LigoOpts extends ProxyTaskArgs.t {\n\tcommand: string;\n}\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n\tmodule?: string;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends RequestArgs.t {\n\ttask?: string;\n\tsourceFile?: string;\n}\n\nexport type IntersectionOpts = LigoOpts & CompileOpts & CompileAllOpts & TestOpts;\n\nexport type UnionOpts = LigoOpts | CompileOpts | CompileAllOpts | TestOpts;\n\nexport const getInputFilenameAbsPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const getInputFilenameRelPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const formatLigoError = (err: Error): Error => {\n\tlet result = err.message.replace(/Command failed.+?\\n/, '');\n\tif (\n\t\tresult.includes('An internal error ocurred. Please, contact the developers.')\n\t\t&& result.includes('Module Contract not found with last Contract.')\n\t) {\n\t\tresult =\n\t\t\t`By convention, Taqueria expects you to import your contract with Contract as the module name.\\nFor 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.`;\n\t}\n\n\terr.message = result.replace(\n\t\t'An internal error ocurred. Please, contact the developers.',\n\t\t'The LIGO compiler experienced an internal error. Please contact the LIGO developers.',\n\t);\n\n\treturn err;\n};\n\nexport const emitExternalError = (errs: unknown[] | unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\tconst errors = Array.isArray(errs) ? errs : [errs];\n\terrors.map(err => {\n\t\terr instanceof Error ? sendErr(err.message) : sendErr(err as any);\n\t});\n\tsendErr(`===`);\n};\n\nexport const configure = (dockerImage: string, dockerImageEnvVar: string) => ({\n\tLIGO_DEFAULT_IMAGE: dockerImage,\n\tLIGO_IMAGE_ENV_VAR: dockerImageEnvVar,\n\tgetLigoDockerImage: () => getDockerImage(dockerImage, dockerImageEnvVar),\n});\n\nexport type Common = ReturnType<typeof configure>;\n","import {\n\texecCmd,\n\tgetArch,\n\tgetArtifactsDir,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { createReadStream } from 'fs';\nimport { access, readFile, writeFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport * as readline from 'readline';\nimport {\n\tCommon,\n\tCompileOpts as Opts,\n\tconfigure,\n\temitExternalError,\n\tformatLigoError,\n\tgetInputFilenameAbsPath,\n\tgetInputFilenameRelPath,\n\tUnionOpts,\n} from './common';\n\nexport type TableRow = { source: string; artifact: string; err?: unknown };\n\nexport type ExprKind = 'storage' | 'default_storage' | 'parameter';\n\nexport type Syntax = 'mligo' | 'jsligo' | 'religo' | 'ligo';\n\nexport type ModuleInfo = {\n\tmoduleName: string;\n\tsourceName: string;\n\tsourceFile: string;\n\tsyntax: Syntax;\n\ttype: 'file-main' | 'file-entry' | 'module-main' | 'module-entry';\n};\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' || exprKind === 'default_storage';\n\nexport const isSupportedLigoSyntax = (sourceFile: string) => /\\.(mligo|jsligo)$/.test(sourceFile);\n\nexport const isUnsupportedLigoSyntax = (sourceFile: string) => /\\.(ligo|religo)$/.test(sourceFile);\n\nexport const isLIGOFile = (sourceFile: string) =>\n\tisSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);\n\nexport const isStorageListFile = (sourceFile: string): boolean =>\n\t/.+\\.(storageList|storages)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nexport const isParameterListFile = (sourceFile: string): boolean =>\n\t/.+\\.(parameterList|parameters)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.(ligo|religo|mligo|jsligo)$/);\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\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, module: ModuleInfo): string => {\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(getArtifactsDir(parsedArgs), `${module.moduleName}${ext}`);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, module: ModuleInfo, exprKind: ExprKind, exprName: string): string => {\n\tconst contractName = module.moduleName;\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst outputFile = exprKind === 'default_storage'\n\t\t? `${contractName}.default_storage${ext}`\n\t\t: `${contractName}.${exprKind}.${exprName}${ext}`;\n\treturn join(getArtifactsDir(parsedArgs), `${outputFile}`);\n};\n\nconst getExprNames = (parsedArgs: Opts, sourceFile: string): Promise<string[]> => {\n\treturn new Promise((resolve, reject) => {\n\t\tconst inputFilePath = getInputFilenameAbsPath(parsedArgs, sourceFile);\n\t\tconst readInterface = readline.createInterface({\n\t\t\tinput: createReadStream(inputFilePath),\n\t\t\toutput: process.stdout,\n\t\t});\n\n\t\tconst variableNames: string[] = [];\n\n\t\treadInterface.on('line', function(line) {\n\t\t\t// Skip lines that start with a comment\n\t\t\tif (!line.trim().startsWith('//')) {\n\t\t\t\tconst matches = line.match(/(?<=\\s*(let|const)\\s+)[a-zA-Z0-9_]+/g);\n\t\t\t\tif (matches) {\n\t\t\t\t\tvariableNames.push(...matches);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treadInterface.on('close', function() {\n\t\t\tresolve(variableNames);\n\t\t});\n\t});\n};\n\n// Helper function to get the initial message based on the pair value\nconst getInitialMessage = (pair: string, module: ModuleInfo) => {\n\tconst messages = {\n\t\t'mligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t// ... any other combinations\n\t} as Record<string, string>;\n\n\treturn messages[pair] || '// This file was created by Taqueria.';\n};\n\n// Helper function to get a common message\nconst getCommonMsg = (langType: Syntax, listType: ExprKind) => {\n\tconst varKeyword = langType === 'mligo' ? 'let' : 'const';\n\tconst commonMsgForStorage = `// IMPORTANT: We suggest always explicitly typing your storage values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} storage: int = 10\\` or \\`${varKeyword} storage: Contract.storage = 10\\``;\n\n\tconst commonMsgForParameter = `// IMPORTANT: We suggest always explicitly typing your parameter values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} parameter: int = 10\\` or \\`${varKeyword} parameter: Contract.parameter = 10\\``;\n\n\treturn listType === 'storage' ? commonMsgForStorage : commonMsgForParameter;\n};\n\n// Main function to get the content for storage or parameter\nconst getContent = (moduleInfo: ModuleInfo, listType: ExprKind) => {\n\tconst linkToContract = `#import \"${moduleInfo.sourceFile}\" \"Contract\"`;\n\tconst pair = `${moduleInfo.syntax}-${moduleInfo.type}`;\n\tconst initialMsg = getInitialMessage(pair, moduleInfo);\n\tconst commonMsg = getCommonMsg(moduleInfo.syntax, listType);\n\n\treturn `${linkToContract}\\n\\n${initialMsg}\\n\\n${commonMsg}`;\n};\n\n// Usage for storage list\nconst initContentForStorage = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'storage');\n\n// Usage for parameter list\nconst initContentForParameter = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'parameter');\n\n// Inject commonObj to return some functions\nexport const inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getListDeclarationsCmd = async (parsedArgs: UnionOpts, sourceFile: string): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} info list-declarations`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst flags = '--display-format json';\n\t\tconst cmd = `${baseCmd} ${inputFile} ${flags}`;\n\t\treturn cmd;\n\t};\n\n\tconst listContractModules = async (parsedArgs: UnionOpts, sourceFile: string): Promise<ModuleInfo[]> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getListDeclarationsCmd(parsedArgs, sourceFile);\n\t\t\tconst { stderr, stdout } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) return Promise.reject(stderr);\n\n\t\t\treturn JSON.parse(stdout).declarations.reduce(\n\t\t\t\t(acc: ModuleInfo[], decl: string) => {\n\t\t\t\t\t// We need to process delcarations (decl) like so:\n\t\t\t\t\t// 1. If the decl is equal to the string \"main\", then the module type is \"file-main\" and the name of the module is the sourceFile.\n\t\t\t\t\t// 2. If the decl is equal to $main, then the module type is \"file-entry\" and the name fo the module is the sourceFile.\n\t\t\t\t\t// 3. If the decl ends with .main, then the module type is \"module-main\" and the name of the module is the decl without the .main suffix.\n\t\t\t\t\t// 4. If the decl ends with .$main, then the module type is \"module-entry\" and the name of the module is the decl without the .$main suffix.\n\t\t\t\t\t// Otherwise, this is not a declaration we care about.\n\t\t\t\t\tconst srcFile = removeExt(basename(sourceFile));\n\t\t\t\t\tconst syntax = extractExt(sourceFile).replace('.', '');\n\n\t\t\t\t\tif (decl === 'main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-main', syntax }];\n\t\t\t\t\t} else if (decl === '$main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-entry', syntax }];\n\t\t\t\t\t} else if (decl.endsWith('.main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-main',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t} else if (decl.endsWith('.$main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.\\$main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-entry',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [];\n\t\t}\n\t};\n\n\tconst getCompileContractCmd = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputContractFilename(parsedArgs, module)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\t\tconst moduleFlag = module.type.startsWith('file-') ? '' : `-m ${module.moduleName}`;\n\t\tconst cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileContract = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<TableRow> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getCompileContractCmd(parsedArgs, sourceFile, module);\n\t\t\tconst { stderr } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: getOutputContractFilename(parsedArgs, module),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t}\n\t};\n\n\tconst getCompileExprCmd = (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t\texprName: string,\n\t): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputExprFilename(parsedArgs, module, exprKind, exprName)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\n\t\t// Parameter and Storage list files are expected to import the smart contract file as the \"Contract\" module.\n\t\tconst moduleFlag = (() => {\n\t\t\tswitch (module.type) {\n\t\t\t\tcase 'file-main':\n\t\t\t\tcase 'file-entry':\n\t\t\t\t\treturn '-m Contract';\n\t\t\t\tdefault:\n\t\t\t\t\treturn `-m Contract.${module.moduleName}`;\n\t\t\t}\n\t\t})();\n\n\t\tconst cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags} ${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileExpr =\n\t\t(parsedArgs: Opts, sourceFile: string, module: ModuleInfo, exprKind: ExprKind) =>\n\t\t(exprName: string): Promise<TableRow> => {\n\t\t\treturn getArch()\n\t\t\t\t.then(() => getCompileExprCmd(parsedArgs, sourceFile, module, exprKind, exprName))\n\t\t\t\t.then(execCmd)\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t\tconst artifactName = getOutputExprFilename(parsedArgs, module, exprKind, exprName);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: artifactName,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: `${exprName} in ${sourceFile} not compiled`,\n\t\t\t\t\t\terr,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t};\n\n\tconst compileExprs = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t): Promise<TableRow[]> => {\n\t\t// Get expressions from file\n\t\tlet exprs = [];\n\t\ttry {\n\t\t\texprs = await getExprNames(parsedArgs, sourceFile);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [{\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: `No ${isStorageKind(exprKind) ? 'storage' : 'parameter'} expressions compiled`,\n\t\t\t}];\n\t\t}\n\n\t\tconst results = await Promise.all(exprs.map(async (exprName, index) => {\n\t\t\tconst compileResult = await compileExpr(\n\t\t\t\tparsedArgs,\n\t\t\t\tsourceFile,\n\t\t\t\tmodule,\n\t\t\t\texprKind === 'storage' && index === 0 ? 'default_storage' : exprKind,\n\t\t\t)(exprName);\n\t\t\treturn compileResult;\n\t\t}));\n\n\t\t// Collect errors\n\t\tconst errors = results.reduce(\n\t\t\t(acc, result) => {\n\t\t\t\tif (result.err) {\n\t\t\t\t\t// If its not an Error object, then just add it to the list\n\t\t\t\t\tif (!(result.err instanceof Error)) return [...acc, result.err];\n\n\t\t\t\t\t// Otherwise, get all ligo errors and ensure that the list is unique\n\t\t\t\t\tconst ligoErrs = (acc\n\t\t\t\t\t\t.filter(err => err instanceof Error) as Error[])\n\t\t\t\t\t\t.map(err => err.message);\n\n\t\t\t\t\tconst formattedError = formatLigoError(result.err);\n\n\t\t\t\t\treturn (ligoErrs.includes(formattedError.message)) ? acc : [...acc, formattedError];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[] as unknown[],\n\t\t);\n\n\t\t// Collect table rows\n\t\tconst retval = results.map(({ source, artifact }) => ({ source, artifact }));\n\n\t\tif (errors.length) emitExternalError(errors, sourceFile);\n\n\t\treturn retval;\n\t};\n\n\tconst compileContractWithStorageAndParameter = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t): Promise<TableRow[]> => {\n\t\tconst contractCompileResult = await compileContract(parsedArgs, sourceFile, module);\n\t\tif (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];\n\t\tdebugger;\n\n\t\tconst storageListFile = `${module.moduleName}.storageList${extractExt(sourceFile)}`;\n\t\tconst storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);\n\t\tconst storageCompileResult = await access(storageListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, storageListFile, module, 'storage'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(storageListFilename, initContentForStorage(module), 'utf8');\n\t\t\t});\n\n\t\tconst parameterListFile = `${module.moduleName}.parameterList${extractExt(sourceFile)}`;\n\t\tconst parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);\n\t\tconst parameterCompileResult = await access(parameterListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, parameterListFile, module, 'parameter'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(parameterListFilename, initContentForParameter(module), 'utf8');\n\t\t\t});\n\n\t\tconst storageArtifacts = storageCompileResult ? storageCompileResult.map(res => res.artifact).join('\\n') : '';\n\t\tconst parameterArtifacts = parameterCompileResult ? parameterCompileResult.map(res => res.artifact).join('\\n') : '';\n\n\t\tconst combinedArtifact = [\n\t\t\tcontractCompileResult.artifact,\n\t\t\tstorageArtifacts,\n\t\t\tparameterArtifacts,\n\t\t].filter(Boolean).join('\\n');\n\n\t\tconst combinedRow: TableRow = {\n\t\t\tsource: module.sourceName,\n\t\t\tartifact: combinedArtifact,\n\t\t};\n\n\t\treturn [combinedRow];\n\t};\n\n\treturn {\n\t\tgetLigoDockerImage,\n\t\tgetListDeclarationsCmd,\n\t\tlistContractModules,\n\t\tgetCompileContractCmd,\n\t\tcompileContract,\n\t\tgetCompileExprCmd,\n\t\tcompileExpr,\n\t\tcompileExprs,\n\t\tcompileContractWithStorageAndParameter,\n\t};\n};\n\nexport const compile = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!isLIGOFile(sourceFile)) {\n\t\tsendErr(`${sourceFile} is not a LIGO file`);\n\t\treturn;\n\t}\n\tif (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {\n\t\tsendErr(`Storage and parameter list files are not meant to be compiled directly`);\n\t\treturn;\n\t}\n\tif (isUnsupportedLigoSyntax(sourceFile)) {\n\t\tsendErr(`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst modules = await listContractModules(parsedArgs, sourceFile);\n\t\tif (modules.length === 0) {\n\t\t\treturn sendJsonRes([\n\t\t\t\t{\n\t\t\t\t\tsource: sourceFile,\n\t\t\t\t\tartifact: `No contract modules found in \"${sourceFile}\"`,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tlet allCompileResults: TableRow[] = [];\n\t\tfor (const module of modules) {\n\t\t\t// If we're only to compile a particular module, then we'll skip any that don't match\n\t\t\tif (parsedArgs.module && parsedArgs.module !== module.moduleName) continue;\n\n\t\t\tconst compileResults = await compileContractWithStorageAndParameter(parsedArgs, sourceFile, module);\n\t\t\tallCompileResults = allCompileResults.concat(compileResults);\n\t\t}\n\n\t\tsendJsonRes(allCompileResults, { footer: `\\nCompiled ${allCompileResults.length} contract(s) in \"${sourceFile}\"` });\n\t} catch (err) {\n\t\tsendErr(`Error processing \"${sourceFile}\": ${err}`);\n\t}\n};\n\nexport default compile;\n","import { sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { Common, CompileAllOpts, CompileAllOpts as Opts, CompileOpts } from './common';\nimport { inject, isParameterListFile, isStorageListFile, TableRow } from './compile';\n\nconst compileAll = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tlet compilePromises: Promise<TableRow[]>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n\t\t{\n\t\t\tcwd: join(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts'),\n\t\t\tabsolute: false,\n\t\t},\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (isStorageListFile(filename) || isParameterListFile(filename)) continue;\n\t\tconst moduleNames = await listContractModules(parsedArgs as unknown as CompileAllOpts, filename);\n\t\tfor (const moduleName of moduleNames) {\n\t\t\tcompilePromises.push(compileContractWithStorageAndParameter(parsedArgs as CompileOpts, filename, moduleName));\n\t\t}\n\t}\n\n\treturn Promise.all(compilePromises)\n\t\t.then(tables => tables.flat())\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { readJsonFile, writeJsonFile } from '@taqueria/node-sdk';\nimport { join } from 'path';\nimport { Common, configure, LigoOpts as Opts } from './common';\n\nconst getArbitraryLigoCmd = (\n\tcommonObj: Common,\n\tparsedArgs: Opts,\n\tuid: string,\n\tgid: string,\n\tuserArgs: string,\n): [string, Record<string, string>] => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\n\tconst userMap = uid && gid ? `${uid}:${gid}` : uid;\n\tconst userMapArgs = uid ? ['-u', userMap] : [];\n\n\tconst binary = 'docker';\n\tconst baseArgs = [\n\t\t'run',\n\t\t'--rm',\n\t\t'-v',\n\t\t`${projectDir}:/project`,\n\t\t'-w',\n\t\t'/project',\n\t\t...userMapArgs,\n\t\tcommonObj.getLigoDockerImage(),\n\t];\n\tconst processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\\\-') ? arg.substring(1) : arg).filter(arg =>\n\t\targ\n\t);\n\tconst args = [...baseArgs, ...processedUserArgs, '--skip-analytics'];\n\tconst envVars = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };\n\treturn [\n\t\t[binary, ...args].join(' '),\n\t\tenvVars,\n\t];\n};\n\nconst ensureEsyExists = async (parsedArgs: Opts): Promise<string> => {\n\tconst esyJsonPath = join(parsedArgs.projectDir, 'esy.json');\n\n\ttry {\n\t\treturn await readJsonFile(esyJsonPath);\n\t} catch {\n\t\treturn await writeJsonFile(esyJsonPath)({});\n\t}\n};\n\nconst runArbitraryLigoCmd = (commonObj: Common, parsedArgs: Opts, cmd: string): Promise<string> =>\n\tensureEsyExists(parsedArgs)\n\t\t.then(getArch)\n\t\t.then(async () => {\n\t\t\tconst uid = await execCmd('id -u');\n\t\t\tconst gid = await execCmd('id -g');\n\t\t\treturn [uid.stdout.trim(), gid.stdout.trim()];\n\t\t})\n\t\t.then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd))\n\t\t.then(([cmd, envVars]) => spawnCmd(cmd, envVars))\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by LIGO`\n\t\t\t\t: `Command \"${cmd}\" failed. Please check your command`\n\t\t)\n\t\t.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));\n\nconst ligo = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryLigoCmd(commonObj, parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default ligo;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { Common, emitExternalError, getInputFilenameRelPath, TestOpts as Opts } from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw `No project directory provided`;\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst cmd = `${baseCmd} ${inputFile}`;\n\t\treturn cmd;\n\t};\n\n\tconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\t\tgetArch()\n\t\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stdout, stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\temitExternalError(err, sourceFile);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t\t};\n\t\t\t});\n\n\treturn {\n\t\ttestContract,\n\t\tgetTestContractCmd,\n\t};\n};\n\nconst test = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { testContract } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!sourceFile) return sendAsyncErr(`No source file provided`);\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;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAA8D;;;ACA9D,sBAA6B;AAE7B,sBAA0B;;;ACF1B;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAavB,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ADH/B,IAAM,kBAAkB,OACvB,cACA,QACA,sBACqB;AACrB,QAAM,cAAc,aAAa,MAAM,UAAU;AACjD,QAAM,MAAM,cAAc,YAAY,CAAC,EAAE,UAAU,CAAC,IAAI;AACxD,QAAM,YAAY,qBAAqB;AAEvC,MAAI,WAAW;AAAS,WAAO,UAAU;AACzC,MAAI,WAAW;AAAU,WAAO,UAAU;AAE1C,MAAI,WAAW,QAAW;AACzB,QAAI,QAAQ;AAAS,aAAO,UAAU;AACtC,QAAI,QAAQ;AAAU,aAAO,UAAU;AACvC,eAAO;AAAA,MACN,qCAAqC,YAAY;AAAA,IAClD;AAAA,EACD,OAAO;AACN,eAAO,8BAAa,IAAI,MAAM,6DAA6D;AAAA,EAC5F;AACD;AAEA,IAAM,iBAAiB,CAAC,cAAuC,CAAC,SAAwB;AACvF,QAAM,aAAa;AACnB,QAAM,eAAe,WAAW;AAChC,QAAM,SAAS,WAAW;AAC1B,QAAM,eAAe,GA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,SAAS,eAAe,SAAS,aAAa,MAAM,IAAI,QAAQ,SAAS,YAAY;AACjH;","names":["import_node_sdk","import_node_sdk","import_node_sdk","import_node_sdk","import_promises","import_path","module","import_node_sdk","import_path","glob","import_node_sdk","import_path","cmd","import_node_sdk","inject"]}
|
|
1
|
+
{"version":3,"sources":["index.ts","createContract.ts","ligo_templates.ts","main.ts","common.ts","compile.ts","compile-all.ts","ligo.ts","test.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport * as PluginSchema from '@taqueria/protocol/PluginSchema';\n\nimport createContract from './createContract';\nimport main from './main';\n\ntype PluginConfigurator = (plugin: PluginSchema.RawPluginSchema) => PluginSchema.RawPluginSchema;\ntype ConfiguratorArgs = {\n\tname: string;\n\talias: string;\n\tconfigurator?: PluginConfigurator;\n\tunparsedArgs: string[];\n\tdockerImage: string;\n\tdockerImageEnvVar: string;\n\ttemplates?: Record<string, string>;\n};\n\nexport const configurePlugin = (settings: ConfiguratorArgs) => {\n\tconst schema = {\n\t\tname: settings.name,\n\t\tschema: '1.0',\n\t\tversion: '0.1',\n\t\talias: settings.alias,\n\t\ttasks: [\n\t\t\tTask.create({\n\t\t\t\ttask: 'ligo',\n\t\t\t\tcommand: 'ligo',\n\t\t\t\tdescription:\n\t\t\t\t\t'This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 'c',\n\t\t\t\t\t\tflag: 'command',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The command to be passed to the underlying LIGO binary, wrapped in quotes',\n\t\t\t\t\t\trequired: true,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'none',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile',\n\t\t\t\tcommand: 'compile <sourceFile>',\n\t\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'module',\n\t\t\t\t\t\tshortFlag: 'm',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The LIGO module to be compiled',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile-all',\n\t\t\t\tcommand: 'compile-all',\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile all main smart contracts written in a LIGO syntax to Michelson code, along with their associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'test',\n\t\t\t\tcommand: 'test <sourceFile>',\n\t\t\t\tdescription: 'Test a smart contract written in LIGO',\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'get-image',\n\t\t\t\tcommand: 'get-image',\n\t\t\t\tdescription: 'Gets the name of the image to be used',\n\t\t\t\thandler: 'proxy',\n\t\t\t\thidden: true,\n\t\t\t}),\n\t\t],\n\t\ttemplates: [\n\t\t\tTemplate.create({\n\t\t\t\ttemplate: 'contract',\n\t\t\t\tcommand: 'contract <sourceFileName>',\n\t\t\t\tdescription: 'Create a LIGO contract with boilerplate code',\n\t\t\t\tpositionals: [\n\t\t\t\t\tPositionalArg.create({\n\t\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The name of the LIGO contract to generate',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 's',\n\t\t\t\t\t\tflag: 'syntax',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The syntax used in the contract',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: createContract(settings.templates),\n\t\t\t}),\n\t\t],\n\t\tproxy: main(settings.dockerImage, settings.dockerImageEnvVar),\n\t\tpostInstall: `node ${__dirname}/postinstall.js`,\n\t};\n\n\treturn Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);\n};\n","import { sendAsyncErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { writeFile } from 'fs/promises';\nimport * as default_templates from './ligo_templates';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n\tsyntax?: string;\n}\n\nconst getLigoTemplate = async (\n\tcontractName: string,\n\tsyntax: string | undefined,\n\ttemplateOverrides?: Record<string, string>,\n): Promise<string> => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0].substring(1) : null;\n\tconst templates = templateOverrides ?? default_templates;\n\n\tif (syntax === 'mligo') return templates.mligo_template;\n\tif (syntax === 'jsligo') return templates.jsligo_template;\n\n\tif (syntax === undefined) {\n\t\tif (ext === 'mligo') return templates.mligo_template;\n\t\tif (ext === 'jsligo') return templates.jsligo_template;\n\t\treturn sendAsyncErr(\n\t\t\t`Unable to infer LIGO syntax from \"${contractName}\". Please specify a LIGO syntax via the --syntax option`,\n\t\t);\n\t} else {\n\t\treturn sendAsyncErr(`\"${syntax}\" is not a valid syntax. Please specify a valid LIGO syntax`);\n\t}\n};\n\nconst createContract = (templates?: Record<string, string>) => (args: RequestArgs.t) => {\n\tconst unsafeOpts = args as unknown as Opts;\n\tconst contractName = unsafeOpts.sourceFileName as string;\n\tconst syntax = unsafeOpts.syntax;\n\tconst contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;\n\treturn getLigoTemplate(contractName, syntax, templates)\n\t\t.then(ligo_template => writeFile(`${contractsDir}/${contractName}`, ligo_template));\n};\n\nexport default createContract;\n","export const mligo_template = `\ntype storage = int\ntype return = operation list * storage\n\n(* Three entrypoints *)\n[@entry] let increment (delta : int) (store : storage) : return =\n [], store + delta\n[@entry] let decrement (delta : int) (store : storage) : return =\n [], store - delta\n[@entry] let reset (() : unit) (_ : storage) : return =\n [], 0\n`;\n\nexport const jsligo_template = `\ntype storage = int;\ntype ret = [list<operation>, storage];\n\n// Three entrypoints\n\n// @entry\nconst increment = (delta : int, store : storage) : ret =>\n [list([]), store + delta];\n\n// @entry\nconst decrement = (delta : int, store : storage) : ret =>\n [list([]), store - delta];\n\n// @entry\nconst reset = (_ : unit, _ : storage) : ret =>\n [list([]), 0];\n`;\n","import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { configure, IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compile-all';\nimport ligo from './ligo';\nimport test from './test';\n\nconst main = (dockerImage: string, dockerImageEnvVar: string) => (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst commonObj = configure(dockerImage, dockerImageEnvVar);\n\tconst unsafeOpts = parsedArgs as unknown as Opts;\n\tswitch (unsafeOpts.task) {\n\t\tcase 'ligo':\n\t\t\treturn ligo(commonObj, unsafeOpts);\n\t\tcase 'compile':\n\t\t\treturn compile(commonObj, unsafeOpts);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(commonObj, unsafeOpts);\n\t\tcase 'test':\n\t\t\treturn test(commonObj, parsedArgs);\n\t\tcase 'get-image':\n\t\t\treturn sendAsyncRes(commonObj.getLigoDockerImage());\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);\n\t}\n};\n\nexport default main;\n","import { getDockerImage, sendErr } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk/types';\nimport { join } from 'path';\n\nexport interface LigoOpts extends ProxyTaskArgs.t {\n\tcommand: string;\n}\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n\tmodule?: string;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends RequestArgs.t {\n\ttask?: string;\n\tsourceFile?: string;\n}\n\nexport type IntersectionOpts = LigoOpts & CompileOpts & CompileAllOpts & TestOpts;\n\nexport type UnionOpts = LigoOpts | CompileOpts | CompileAllOpts | TestOpts;\n\nexport const getInputFilenameAbsPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const getInputFilenameRelPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const formatLigoError = (err: Error): Error => {\n\tlet result = err.message.replace(/Command failed.+?\\n/, '');\n\tif (\n\t\tresult.includes('An internal error ocurred. Please, contact the developers.')\n\t\t&& result.includes('Module Contract not found with last Contract.')\n\t) {\n\t\tresult =\n\t\t\t`By convention, Taqueria expects you to import your contract with Contract as the module name.\\nFor 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.`;\n\t} else {\n\t\tconst regex = /contracts\\/(.+): No such file or directory/;\n\t\tconst match = regex.exec(result);\n\t\tif (match) {\n\t\t\tconst filename = match[1];\n\t\t\tresult =\n\t\t\t\t`The file ${filename} was not found. Please ensure that the file exists and that it is in the contracts directory.`;\n\t\t}\n\t}\n\n\terr.message = result\n\t\t.replace(\n\t\t\t'An internal error ocurred. Please, contact the developers.',\n\t\t\t'The LIGO compiler experienced an internal error. Please contact the LIGO developers.',\n\t\t).replace(\n\t\t\t/Module (\"Contract\\.[^\"]+\") not found/,\n\t\t\t'The module $1 was not found. If your contract is defined within a namespace, please ensure that it has been exported.',\n\t\t);\n\n\treturn err;\n};\n\nexport const emitExternalError = (errs: unknown[] | unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\tconst errors = Array.isArray(errs) ? errs : [errs];\n\terrors.map(err => {\n\t\terr instanceof Error ? sendErr(err.message) : sendErr(err as any);\n\t});\n\tsendErr(`===`);\n};\n\nexport const configure = (dockerImage: string, dockerImageEnvVar: string) => ({\n\tLIGO_DEFAULT_IMAGE: dockerImage,\n\tLIGO_IMAGE_ENV_VAR: dockerImageEnvVar,\n\tgetLigoDockerImage: () => getDockerImage(dockerImage, dockerImageEnvVar),\n});\n\nexport type Common = ReturnType<typeof configure>;\n","import {\n\texecCmd,\n\tgetArch,\n\tgetArtifactsDir,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { createReadStream } from 'fs';\nimport { access, readFile, writeFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport * as readline from 'readline';\nimport {\n\tCommon,\n\tCompileOpts as Opts,\n\tconfigure,\n\temitExternalError,\n\tformatLigoError,\n\tgetInputFilenameAbsPath,\n\tgetInputFilenameRelPath,\n\tUnionOpts,\n} from './common';\n\nexport type TableRow = { source: string; artifact: string; err?: unknown };\n\nexport type ExprKind = 'storage' | 'default_storage' | 'parameter';\n\nexport type Syntax = 'mligo' | 'jsligo' | 'religo' | 'ligo';\n\nexport type ModuleInfo = {\n\tmoduleName: string;\n\tsourceName: string;\n\tsourceFile: string;\n\tsyntax: Syntax;\n\ttype: 'file-main' | 'file-entry' | 'module-main' | 'module-entry';\n};\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' || exprKind === 'default_storage';\n\nexport const isSupportedLigoSyntax = (sourceFile: string) => /\\.(mligo|jsligo)$/.test(sourceFile);\n\nexport const isUnsupportedLigoSyntax = (sourceFile: string) => /\\.(ligo|religo)$/.test(sourceFile);\n\nexport const isLIGOFile = (sourceFile: string) =>\n\tisSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);\n\nexport const isStorageListFile = (sourceFile: string): boolean =>\n\t/.+\\.(storageList|storages)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nexport const isParameterListFile = (sourceFile: string): boolean =>\n\t/.+\\.(parameterList|parameters)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.(ligo|religo|mligo|jsligo)$/);\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\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, module: ModuleInfo): string => {\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(getArtifactsDir(parsedArgs), `${module.moduleName}${ext}`);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, module: ModuleInfo, exprKind: ExprKind, exprName: string): string => {\n\tconst contractName = module.moduleName;\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst outputFile = exprKind === 'default_storage'\n\t\t? `${contractName}.default_storage${ext}`\n\t\t: `${contractName}.${exprKind}.${exprName}${ext}`;\n\treturn join(getArtifactsDir(parsedArgs), `${outputFile}`);\n};\n\nconst getExprNames = (parsedArgs: Opts, sourceFile: string): Promise<string[]> => {\n\treturn new Promise((resolve, reject) => {\n\t\tconst inputFilePath = getInputFilenameAbsPath(parsedArgs, sourceFile);\n\t\tconst readInterface = readline.createInterface({\n\t\t\tinput: createReadStream(inputFilePath),\n\t\t\toutput: process.stdout,\n\t\t});\n\n\t\tconst variableNames: string[] = [];\n\n\t\treadInterface.on('line', function(line) {\n\t\t\t// Skip lines that start with a comment\n\t\t\tif (!line.trim().startsWith('//')) {\n\t\t\t\tconst matches = line.match(/(?<=\\s*(let|const)\\s+)[a-zA-Z0-9_]+/g);\n\t\t\t\tif (matches) {\n\t\t\t\t\tvariableNames.push(...matches);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treadInterface.on('close', function() {\n\t\t\tresolve(variableNames);\n\t\t});\n\t});\n};\n\n// Helper function to get the initial message based on the pair value\nconst getInitialMessage = (pair: string, module: ModuleInfo) => {\n\tconst messages = {\n\t\t'mligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t// ... any other combinations\n\t} as Record<string, string>;\n\n\treturn messages[pair] || '// This file was created by Taqueria.';\n};\n\n// Helper function to get a common message\nconst getCommonMsg = (langType: Syntax, listType: ExprKind) => {\n\tconst varKeyword = langType === 'mligo' ? 'let' : 'const';\n\tconst commonMsgForStorage = `// IMPORTANT: We suggest always explicitly typing your storage values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} storage: int = 10\\` or \\`${varKeyword} storage: Contract.storage = 10\\``;\n\n\tconst commonMsgForParameter = `// IMPORTANT: We suggest always explicitly typing your parameter values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} parameter: int = 10\\` or \\`${varKeyword} parameter: Contract.parameter = 10\\``;\n\n\treturn listType === 'storage' ? commonMsgForStorage : commonMsgForParameter;\n};\n\n// Main function to get the content for storage or parameter\nconst getContent = (moduleInfo: ModuleInfo, listType: ExprKind) => {\n\tconst linkToContract = `#import \"${moduleInfo.sourceFile}\" \"Contract\"`;\n\tconst pair = `${moduleInfo.syntax}-${moduleInfo.type}`;\n\tconst initialMsg = getInitialMessage(pair, moduleInfo);\n\tconst commonMsg = getCommonMsg(moduleInfo.syntax, listType);\n\n\treturn `${linkToContract}\\n\\n${initialMsg}\\n\\n${commonMsg}`;\n};\n\n// Usage for storage list\nconst initContentForStorage = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'storage');\n\n// Usage for parameter list\nconst initContentForParameter = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'parameter');\n\n// Inject commonObj to return some functions\nexport const inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getListDeclarationsCmd = async (parsedArgs: UnionOpts, sourceFile: string): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} info list-declarations`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst flags = '--display-format json';\n\t\tconst cmd = `${baseCmd} ${inputFile} ${flags}`;\n\t\treturn cmd;\n\t};\n\n\tconst listContractModules = async (parsedArgs: UnionOpts, sourceFile: string): Promise<ModuleInfo[]> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getListDeclarationsCmd(parsedArgs, sourceFile);\n\t\t\tconst { stderr, stdout } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) return Promise.reject(stderr);\n\n\t\t\treturn JSON.parse(stdout).declarations.reduce(\n\t\t\t\t(acc: ModuleInfo[], decl: string) => {\n\t\t\t\t\t// We need to process delcarations (decl) like so:\n\t\t\t\t\t// 1. If the decl is equal to the string \"main\", then the module type is \"file-main\" and the name of the module is the sourceFile.\n\t\t\t\t\t// 2. If the decl is equal to $main, then the module type is \"file-entry\" and the name fo the module is the sourceFile.\n\t\t\t\t\t// 3. If the decl ends with .main, then the module type is \"module-main\" and the name of the module is the decl without the .main suffix.\n\t\t\t\t\t// 4. If the decl ends with .$main, then the module type is \"module-entry\" and the name of the module is the decl without the .$main suffix.\n\t\t\t\t\t// Otherwise, this is not a declaration we care about.\n\t\t\t\t\tconst srcFile = removeExt(basename(sourceFile));\n\t\t\t\t\tconst syntax = extractExt(sourceFile).replace('.', '');\n\n\t\t\t\t\tif (decl === 'main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-main', syntax }];\n\t\t\t\t\t} else if (decl === '$main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-entry', syntax }];\n\t\t\t\t\t} else if (decl.endsWith('.main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-main',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t} else if (decl.endsWith('.$main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.\\$main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-entry',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tconst formattedErr = err instanceof Error ? formatLigoError(err) : err;\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [];\n\t\t}\n\t};\n\n\tconst getCompileContractCmd = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputContractFilename(parsedArgs, module)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\t\tconst moduleFlag = module.type.startsWith('file-') ? '' : `-m ${module.moduleName}`;\n\t\tconst cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileContract = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<TableRow> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getCompileContractCmd(parsedArgs, sourceFile, module);\n\t\t\tconst { stderr } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: getOutputContractFilename(parsedArgs, module),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t}\n\t};\n\n\tconst getCompileExprCmd = (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t\texprName: string,\n\t): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputExprFilename(parsedArgs, module, exprKind, exprName)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\n\t\t// Parameter and Storage list files are expected to import the smart contract file as the \"Contract\" module.\n\t\tconst moduleFlag = (() => {\n\t\t\tswitch (module.type) {\n\t\t\t\tcase 'file-main':\n\t\t\t\tcase 'file-entry':\n\t\t\t\t\treturn '-m Contract';\n\t\t\t\tdefault:\n\t\t\t\t\treturn `-m Contract.${module.moduleName}`;\n\t\t\t}\n\t\t})();\n\n\t\tconst cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags} ${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileExpr =\n\t\t(parsedArgs: Opts, sourceFile: string, module: ModuleInfo, exprKind: ExprKind) =>\n\t\t(exprName: string): Promise<TableRow> => {\n\t\t\treturn getArch()\n\t\t\t\t.then(() => getCompileExprCmd(parsedArgs, sourceFile, module, exprKind, exprName))\n\t\t\t\t.then(execCmd)\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t\tconst artifactName = getOutputExprFilename(parsedArgs, module, exprKind, exprName);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: artifactName,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: `${exprName} in ${sourceFile} not compiled`,\n\t\t\t\t\t\terr,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t};\n\n\tconst compileExprs = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t): Promise<TableRow[]> => {\n\t\t// Get expressions from file\n\t\tlet exprs = [];\n\t\ttry {\n\t\t\texprs = await getExprNames(parsedArgs, sourceFile);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [{\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: `No ${isStorageKind(exprKind) ? 'storage' : 'parameter'} expressions compiled`,\n\t\t\t}];\n\t\t}\n\n\t\tconst results = await Promise.all(exprs.map(async (exprName, index) => {\n\t\t\tconst compileResult = await compileExpr(\n\t\t\t\tparsedArgs,\n\t\t\t\tsourceFile,\n\t\t\t\tmodule,\n\t\t\t\texprKind === 'storage' && index === 0 ? 'default_storage' : exprKind,\n\t\t\t)(exprName);\n\t\t\treturn compileResult;\n\t\t}));\n\n\t\t// Collect errors\n\t\tconst errors = results.reduce(\n\t\t\t(acc, result) => {\n\t\t\t\tif (result.err) {\n\t\t\t\t\t// If its not an Error object, then just add it to the list\n\t\t\t\t\tif (!(result.err instanceof Error)) return [...acc, result.err];\n\n\t\t\t\t\t// Otherwise, get all ligo errors and ensure that the list is unique\n\t\t\t\t\tconst ligoErrs = (acc\n\t\t\t\t\t\t.filter(err => err instanceof Error) as Error[])\n\t\t\t\t\t\t.map(err => err.message);\n\n\t\t\t\t\tconst formattedError = formatLigoError(result.err);\n\n\t\t\t\t\treturn (ligoErrs.includes(formattedError.message)) ? acc : [...acc, formattedError];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[] as unknown[],\n\t\t);\n\n\t\t// Collect table rows\n\t\tconst retval = results.map(({ source, artifact }) => ({ source, artifact }));\n\n\t\tif (errors.length) emitExternalError(errors, sourceFile);\n\n\t\treturn retval;\n\t};\n\n\tconst compileContractWithStorageAndParameter = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t): Promise<TableRow[]> => {\n\t\tconst contractCompileResult = await compileContract(parsedArgs, sourceFile, module);\n\t\tif (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];\n\n\t\tconst storageListFile = `${module.moduleName}.storageList${extractExt(sourceFile)}`;\n\t\tconst storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);\n\t\tconst storageCompileResult = await access(storageListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, storageListFile, module, 'storage'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(storageListFilename, initContentForStorage(module), 'utf8');\n\t\t\t});\n\n\t\tconst parameterListFile = `${module.moduleName}.parameterList${extractExt(sourceFile)}`;\n\t\tconst parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);\n\t\tconst parameterCompileResult = await access(parameterListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, parameterListFile, module, 'parameter'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(parameterListFilename, initContentForParameter(module), 'utf8');\n\t\t\t});\n\n\t\tconst storageArtifacts = storageCompileResult ? storageCompileResult.map(res => res.artifact).join('\\n') : '';\n\t\tconst parameterArtifacts = parameterCompileResult ? parameterCompileResult.map(res => res.artifact).join('\\n') : '';\n\n\t\tconst combinedArtifact = [\n\t\t\tcontractCompileResult.artifact,\n\t\t\tstorageArtifacts,\n\t\t\tparameterArtifacts,\n\t\t].filter(Boolean).join('\\n');\n\n\t\tconst combinedRow: TableRow = {\n\t\t\tsource: module.sourceName,\n\t\t\tartifact: combinedArtifact,\n\t\t};\n\n\t\treturn [combinedRow];\n\t};\n\n\treturn {\n\t\tgetLigoDockerImage,\n\t\tgetListDeclarationsCmd,\n\t\tlistContractModules,\n\t\tgetCompileContractCmd,\n\t\tcompileContract,\n\t\tgetCompileExprCmd,\n\t\tcompileExpr,\n\t\tcompileExprs,\n\t\tcompileContractWithStorageAndParameter,\n\t};\n};\n\nexport const compile = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!isLIGOFile(sourceFile)) {\n\t\tsendErr(`${sourceFile} is not a LIGO file`);\n\t\treturn;\n\t}\n\tif (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {\n\t\tsendErr(`Storage and parameter list files are not meant to be compiled directly`);\n\t\treturn;\n\t}\n\tif (isUnsupportedLigoSyntax(sourceFile)) {\n\t\tsendErr(`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst modules = await listContractModules(parsedArgs, sourceFile);\n\t\tif (modules.length === 0) {\n\t\t\treturn sendJsonRes([\n\t\t\t\t{\n\t\t\t\t\tsource: sourceFile,\n\t\t\t\t\tartifact:\n\t\t\t\t\t\t`No contract modules found in \"${sourceFile}\".\\nIf your contract is defined within a namespace, please ensure that it is exported from the contract file.\"`,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tlet allCompileResults: TableRow[] = [];\n\t\tfor (const module of modules) {\n\t\t\t// If we're only to compile a particular module, then we'll skip any that don't match\n\t\t\tif (parsedArgs.module && parsedArgs.module !== module.moduleName) continue;\n\n\t\t\tconst compileResults = await compileContractWithStorageAndParameter(parsedArgs, sourceFile, module);\n\t\t\tallCompileResults = allCompileResults.concat(compileResults);\n\t\t}\n\n\t\tsendJsonRes(allCompileResults, { footer: `\\nCompiled ${allCompileResults.length} contract(s) in \"${sourceFile}\"` });\n\t} catch (err) {\n\t\tsendErr(`Error processing \"${sourceFile}\": ${err}`);\n\t}\n};\n\nexport default compile;\n","import { sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { Common, CompileAllOpts, CompileAllOpts as Opts, CompileOpts } from './common';\nimport { inject, isParameterListFile, isStorageListFile, TableRow } from './compile';\n\nconst compileAll = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tlet compilePromises: Promise<TableRow[]>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n\t\t{\n\t\t\tcwd: join(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts'),\n\t\t\tabsolute: false,\n\t\t},\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (isStorageListFile(filename) || isParameterListFile(filename)) continue;\n\t\tconst moduleNames = await listContractModules(parsedArgs as unknown as CompileAllOpts, filename);\n\t\tfor (const moduleName of moduleNames) {\n\t\t\tcompilePromises.push(compileContractWithStorageAndParameter(parsedArgs as CompileOpts, filename, moduleName));\n\t\t}\n\t}\n\n\treturn Promise.all(compilePromises)\n\t\t.then(tables => tables.flat())\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { readJsonFile, writeJsonFile } from '@taqueria/node-sdk';\nimport { join } from 'path';\nimport { Common, configure, LigoOpts as Opts } from './common';\n\nconst getArbitraryLigoCmd = (\n\tcommonObj: Common,\n\tparsedArgs: Opts,\n\tuid: string,\n\tgid: string,\n\tuserArgs: string,\n): [string, Record<string, string>] => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\n\tconst userMap = uid && gid ? `${uid}:${gid}` : uid;\n\tconst userMapArgs = uid ? ['-u', userMap] : [];\n\n\tconst binary = 'docker';\n\tconst baseArgs = [\n\t\t'run',\n\t\t'--rm',\n\t\t'-v',\n\t\t`${projectDir}:/project`,\n\t\t'-w',\n\t\t'/project',\n\t\t...userMapArgs,\n\t\tcommonObj.getLigoDockerImage(),\n\t];\n\tconst processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\\\-') ? arg.substring(1) : arg).filter(arg =>\n\t\targ\n\t);\n\tconst args = [...baseArgs, ...processedUserArgs, '--skip-analytics'];\n\tconst envVars = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };\n\treturn [\n\t\t[binary, ...args].join(' '),\n\t\tenvVars,\n\t];\n};\n\nconst runArbitraryLigoCmd = (commonObj: Common, parsedArgs: Opts, cmd: string): Promise<string> =>\n\t(async () => {\n\t\tconst uid = await execCmd('id -u');\n\t\tconst gid = await execCmd('id -g');\n\t\treturn [uid.stdout.trim(), gid.stdout.trim()];\n\t})()\n\t\t.then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd))\n\t\t.then(([cmd, envVars]) => spawnCmd(cmd, envVars))\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by LIGO`\n\t\t\t\t: `Command \"${cmd}\" failed. Please check your command`\n\t\t)\n\t\t.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));\n\nconst ligo = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryLigoCmd(commonObj, parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default ligo;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { Common, emitExternalError, getInputFilenameRelPath, TestOpts as Opts } from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw `No project directory provided`;\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst cmd = `${baseCmd} ${inputFile}`;\n\t\treturn cmd;\n\t};\n\n\tconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\t\tgetArch()\n\t\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stdout, stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\temitExternalError(err, sourceFile);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t\t};\n\t\t\t});\n\n\treturn {\n\t\ttestContract,\n\t\tgetTestContractCmd,\n\t};\n};\n\nconst test = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { testContract } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!sourceFile) return sendAsyncErr(`No source file provided`);\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;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAA8D;;;ACA9D,sBAA6B;AAE7B,sBAA0B;;;ACF1B;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAavB,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ADH/B,IAAM,kBAAkB,OACvB,cACA,QACA,sBACqB;AACrB,QAAM,cA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AAU;AAAA,QACV,SAAS;AAAA,QACT,aAAa;AAAA,QACb,aAAa;AAAA,UACZ,+BAAc,OAAO;AAAA,YACpB,aAAa;AAAA,YACb,MAAM;AAAA,YACN,aAAa;AAAA,UACd,CAAC;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UACR,wBAAO,OAAO;AAAA,YACb,WAAW;AAAA,YACX,MAAM;AAAA,YACN,MAAM;AAAA,YACN,aAAa;AAAA,UACd,CAAC;AAAA,QACF;AAAA,QACA,SAAS,uBAAe,SAAS,SAAS;AAAA,MAC3C,CAAC;AAAA,IACF;AAAA,IACA,OAAO,aAAK,SAAS,aAAa,SAAS,iBAAiB;AAAA,IAC5D,aAAa,QAAQ,SAAS;AAAA,EAC/B;AAEA,SAAO,wBAAO,OAAO,MAAM,SAAS,eAAe,SAAS,aAAa,MAAM,IAAI,QAAQ,SAAS,YAAY;AACjH;","names":["import_node_sdk","import_node_sdk","import_node_sdk","import_node_sdk","import_promises","import_path","module","import_node_sdk","import_path","glob","import_node_sdk","cmd","import_node_sdk","inject"]}
|
package/index.mjs
CHANGED
|
@@ -91,10 +91,20 @@ var formatLigoError = (err) => {
|
|
|
91
91
|
if (result.includes("An internal error ocurred. Please, contact the developers.") && result.includes("Module Contract not found with last Contract.")) {
|
|
92
92
|
result = `By convention, Taqueria expects you to import your contract with Contract as the module name.
|
|
93
93
|
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
|
+
} else {
|
|
95
|
+
const regex = /contracts\/(.+): No such file or directory/;
|
|
96
|
+
const match = regex.exec(result);
|
|
97
|
+
if (match) {
|
|
98
|
+
const filename = match[1];
|
|
99
|
+
result = `The file ${filename} was not found. Please ensure that the file exists and that it is in the contracts directory.`;
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
102
|
err.message = result.replace(
|
|
96
103
|
"An internal error ocurred. Please, contact the developers.",
|
|
97
104
|
"The LIGO compiler experienced an internal error. Please contact the LIGO developers."
|
|
105
|
+
).replace(
|
|
106
|
+
/Module ("Contract\.[^"]+") not found/,
|
|
107
|
+
"The module $1 was not found. If your contract is defined within a namespace, please ensure that it has been exported."
|
|
98
108
|
);
|
|
99
109
|
return err;
|
|
100
110
|
};
|
|
@@ -261,6 +271,7 @@ var inject = (commonObj) => {
|
|
|
261
271
|
[]
|
|
262
272
|
);
|
|
263
273
|
} catch (err) {
|
|
274
|
+
const formattedErr = err instanceof Error ? formatLigoError(err) : err;
|
|
264
275
|
emitExternalError(err, sourceFile);
|
|
265
276
|
return [];
|
|
266
277
|
}
|
|
@@ -376,7 +387,6 @@ var inject = (commonObj) => {
|
|
|
376
387
|
const contractCompileResult = await compileContract(parsedArgs, sourceFile, module);
|
|
377
388
|
if (contractCompileResult.artifact === COMPILE_ERR_MSG)
|
|
378
389
|
return [contractCompileResult];
|
|
379
|
-
debugger;
|
|
380
390
|
const storageListFile = `${module.moduleName}.storageList${extractExt(sourceFile)}`;
|
|
381
391
|
const storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);
|
|
382
392
|
const storageCompileResult = await access(storageListFilename).then(() => compileExprs(parsedArgs, storageListFile, module, "storage")).catch(() => {
|
|
@@ -441,7 +451,8 @@ var compile = async (commonObj, parsedArgs) => {
|
|
|
441
451
|
return sendJsonRes([
|
|
442
452
|
{
|
|
443
453
|
source: sourceFile,
|
|
444
|
-
artifact: `No contract modules found in "${sourceFile}"
|
|
454
|
+
artifact: `No contract modules found in "${sourceFile}".
|
|
455
|
+
If your contract is defined within a namespace, please ensure that it is exported from the contract file."`
|
|
445
456
|
}
|
|
446
457
|
]);
|
|
447
458
|
}
|
|
@@ -487,9 +498,7 @@ var compileAll = async (commonObj, parsedArgs) => {
|
|
|
487
498
|
var compile_all_default = compileAll;
|
|
488
499
|
|
|
489
500
|
// ligo.ts
|
|
490
|
-
import { execCmd as execCmd2,
|
|
491
|
-
import { readJsonFile, writeJsonFile } from "@taqueria/node-sdk";
|
|
492
|
-
import { join as join4 } from "path";
|
|
501
|
+
import { execCmd as execCmd2, sendAsyncErr as sendAsyncErr3, sendRes as sendRes2, spawnCmd } from "@taqueria/node-sdk";
|
|
493
502
|
var getArbitraryLigoCmd = (commonObj, parsedArgs, uid, gid, userArgs) => {
|
|
494
503
|
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
495
504
|
if (!projectDir)
|
|
@@ -517,19 +526,11 @@ var getArbitraryLigoCmd = (commonObj, parsedArgs, uid, gid, userArgs) => {
|
|
|
517
526
|
envVars
|
|
518
527
|
];
|
|
519
528
|
};
|
|
520
|
-
var
|
|
521
|
-
const esyJsonPath = join4(parsedArgs.projectDir, "esy.json");
|
|
522
|
-
try {
|
|
523
|
-
return await readJsonFile(esyJsonPath);
|
|
524
|
-
} catch {
|
|
525
|
-
return await writeJsonFile(esyJsonPath)({});
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
var runArbitraryLigoCmd = (commonObj, parsedArgs, cmd) => ensureEsyExists(parsedArgs).then(getArch2).then(async () => {
|
|
529
|
+
var runArbitraryLigoCmd = (commonObj, parsedArgs, cmd) => (async () => {
|
|
529
530
|
const uid = await execCmd2("id -u");
|
|
530
531
|
const gid = await execCmd2("id -g");
|
|
531
532
|
return [uid.stdout.trim(), gid.stdout.trim()];
|
|
532
|
-
}).then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd)).then(([cmd2, envVars]) => spawnCmd(cmd2, envVars)).then(
|
|
533
|
+
})().then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd)).then(([cmd2, envVars]) => spawnCmd(cmd2, envVars)).then(
|
|
533
534
|
(code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`
|
|
534
535
|
).catch((err) => sendAsyncErr3(`An internal error has occurred: ${err.message}`));
|
|
535
536
|
var ligo = (commonObj, parsedArgs) => {
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","createContract.ts","ligo_templates.ts","main.ts","common.ts","compile.ts","compile-all.ts","ligo.ts","test.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport * as PluginSchema from '@taqueria/protocol/PluginSchema';\n\nimport createContract from './createContract';\nimport main from './main';\n\ntype PluginConfigurator = (plugin: PluginSchema.RawPluginSchema) => PluginSchema.RawPluginSchema;\ntype ConfiguratorArgs = {\n\tname: string;\n\talias: string;\n\tconfigurator?: PluginConfigurator;\n\tunparsedArgs: string[];\n\tdockerImage: string;\n\tdockerImageEnvVar: string;\n\ttemplates?: Record<string, string>;\n};\n\nexport const configurePlugin = (settings: ConfiguratorArgs) => {\n\tconst schema = {\n\t\tname: settings.name,\n\t\tschema: '1.0',\n\t\tversion: '0.1',\n\t\talias: settings.alias,\n\t\ttasks: [\n\t\t\tTask.create({\n\t\t\t\ttask: 'ligo',\n\t\t\t\tcommand: 'ligo',\n\t\t\t\tdescription:\n\t\t\t\t\t'This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 'c',\n\t\t\t\t\t\tflag: 'command',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The command to be passed to the underlying LIGO binary, wrapped in quotes',\n\t\t\t\t\t\trequired: true,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'none',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile',\n\t\t\t\tcommand: 'compile <sourceFile>',\n\t\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'module',\n\t\t\t\t\t\tshortFlag: 'm',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The LIGO module to be compiled',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile-all',\n\t\t\t\tcommand: 'compile-all',\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile all main smart contracts written in a LIGO syntax to Michelson code, along with their associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'test',\n\t\t\t\tcommand: 'test <sourceFile>',\n\t\t\t\tdescription: 'Test a smart contract written in LIGO',\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'get-image',\n\t\t\t\tcommand: 'get-image',\n\t\t\t\tdescription: 'Gets the name of the image to be used',\n\t\t\t\thandler: 'proxy',\n\t\t\t\thidden: true,\n\t\t\t}),\n\t\t],\n\t\ttemplates: [\n\t\t\tTemplate.create({\n\t\t\t\ttemplate: 'contract',\n\t\t\t\tcommand: 'contract <sourceFileName>',\n\t\t\t\tdescription: 'Create a LIGO contract with boilerplate code',\n\t\t\t\tpositionals: [\n\t\t\t\t\tPositionalArg.create({\n\t\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The name of the LIGO contract to generate',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 's',\n\t\t\t\t\t\tflag: 'syntax',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The syntax used in the contract',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: createContract(settings.templates),\n\t\t\t}),\n\t\t],\n\t\tproxy: main(settings.dockerImage, settings.dockerImageEnvVar),\n\t\tpostInstall: `node ${__dirname}/postinstall.js`,\n\t};\n\n\treturn Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);\n};\n","import { sendAsyncErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { writeFile } from 'fs/promises';\nimport * as default_templates from './ligo_templates';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n\tsyntax?: string;\n}\n\nconst getLigoTemplate = async (\n\tcontractName: string,\n\tsyntax: string | undefined,\n\ttemplateOverrides?: Record<string, string>,\n): Promise<string> => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0].substring(1) : null;\n\tconst templates = templateOverrides ?? default_templates;\n\n\tif (syntax === 'mligo') return templates.mligo_template;\n\tif (syntax === 'jsligo') return templates.jsligo_template;\n\n\tif (syntax === undefined) {\n\t\tif (ext === 'mligo') return templates.mligo_template;\n\t\tif (ext === 'jsligo') return templates.jsligo_template;\n\t\treturn sendAsyncErr(\n\t\t\t`Unable to infer LIGO syntax from \"${contractName}\". Please specify a LIGO syntax via the --syntax option`,\n\t\t);\n\t} else {\n\t\treturn sendAsyncErr(`\"${syntax}\" is not a valid syntax. Please specify a valid LIGO syntax`);\n\t}\n};\n\nconst createContract = (templates?: Record<string, string>) => (args: RequestArgs.t) => {\n\tconst unsafeOpts = args as unknown as Opts;\n\tconst contractName = unsafeOpts.sourceFileName as string;\n\tconst syntax = unsafeOpts.syntax;\n\tconst contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;\n\treturn getLigoTemplate(contractName, syntax, templates)\n\t\t.then(ligo_template => writeFile(`${contractsDir}/${contractName}`, ligo_template));\n};\n\nexport default createContract;\n","export const mligo_template = `\ntype storage = int\ntype return = operation list * storage\n\n(* Three entrypoints *)\n[@entry] let increment (delta : int) (store : storage) : return =\n [], store + delta\n[@entry] let decrement (delta : int) (store : storage) : return =\n [], store - delta\n[@entry] let reset (() : unit) (_ : storage) : return =\n [], 0\n`;\n\nexport const jsligo_template = `\ntype storage = int;\ntype ret = [list<operation>, storage];\n\n// Three entrypoints\n\n// @entry\nconst increment = (delta : int, store : storage) : ret =>\n [list([]), store + delta];\n\n// @entry\nconst decrement = (delta : int, store : storage) : ret =>\n [list([]), store - delta];\n\n// @entry\nconst reset = (_ : unit, _ : storage) : ret =>\n [list([]), 0];\n`;\n","import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { configure, IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compile-all';\nimport ligo from './ligo';\nimport test from './test';\n\nconst main = (dockerImage: string, dockerImageEnvVar: string) => (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst commonObj = configure(dockerImage, dockerImageEnvVar);\n\tconst unsafeOpts = parsedArgs as unknown as Opts;\n\tswitch (unsafeOpts.task) {\n\t\tcase 'ligo':\n\t\t\treturn ligo(commonObj, unsafeOpts);\n\t\tcase 'compile':\n\t\t\treturn compile(commonObj, unsafeOpts);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(commonObj, unsafeOpts);\n\t\tcase 'test':\n\t\t\treturn test(commonObj, parsedArgs);\n\t\tcase 'get-image':\n\t\t\treturn sendAsyncRes(commonObj.getLigoDockerImage());\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);\n\t}\n};\n\nexport default main;\n","import { getDockerImage, sendErr } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk/types';\nimport { join } from 'path';\n\nexport interface LigoOpts extends ProxyTaskArgs.t {\n\tcommand: string;\n}\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n\tmodule?: string;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends RequestArgs.t {\n\ttask?: string;\n\tsourceFile?: string;\n}\n\nexport type IntersectionOpts = LigoOpts & CompileOpts & CompileAllOpts & TestOpts;\n\nexport type UnionOpts = LigoOpts | CompileOpts | CompileAllOpts | TestOpts;\n\nexport const getInputFilenameAbsPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const getInputFilenameRelPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const formatLigoError = (err: Error): Error => {\n\tlet result = err.message.replace(/Command failed.+?\\n/, '');\n\tif (\n\t\tresult.includes('An internal error ocurred. Please, contact the developers.')\n\t\t&& result.includes('Module Contract not found with last Contract.')\n\t) {\n\t\tresult =\n\t\t\t`By convention, Taqueria expects you to import your contract with Contract as the module name.\\nFor 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.`;\n\t}\n\n\terr.message = result.replace(\n\t\t'An internal error ocurred. Please, contact the developers.',\n\t\t'The LIGO compiler experienced an internal error. Please contact the LIGO developers.',\n\t);\n\n\treturn err;\n};\n\nexport const emitExternalError = (errs: unknown[] | unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\tconst errors = Array.isArray(errs) ? errs : [errs];\n\terrors.map(err => {\n\t\terr instanceof Error ? sendErr(err.message) : sendErr(err as any);\n\t});\n\tsendErr(`===`);\n};\n\nexport const configure = (dockerImage: string, dockerImageEnvVar: string) => ({\n\tLIGO_DEFAULT_IMAGE: dockerImage,\n\tLIGO_IMAGE_ENV_VAR: dockerImageEnvVar,\n\tgetLigoDockerImage: () => getDockerImage(dockerImage, dockerImageEnvVar),\n});\n\nexport type Common = ReturnType<typeof configure>;\n","import {\n\texecCmd,\n\tgetArch,\n\tgetArtifactsDir,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { createReadStream } from 'fs';\nimport { access, readFile, writeFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport * as readline from 'readline';\nimport {\n\tCommon,\n\tCompileOpts as Opts,\n\tconfigure,\n\temitExternalError,\n\tformatLigoError,\n\tgetInputFilenameAbsPath,\n\tgetInputFilenameRelPath,\n\tUnionOpts,\n} from './common';\n\nexport type TableRow = { source: string; artifact: string; err?: unknown };\n\nexport type ExprKind = 'storage' | 'default_storage' | 'parameter';\n\nexport type Syntax = 'mligo' | 'jsligo' | 'religo' | 'ligo';\n\nexport type ModuleInfo = {\n\tmoduleName: string;\n\tsourceName: string;\n\tsourceFile: string;\n\tsyntax: Syntax;\n\ttype: 'file-main' | 'file-entry' | 'module-main' | 'module-entry';\n};\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' || exprKind === 'default_storage';\n\nexport const isSupportedLigoSyntax = (sourceFile: string) => /\\.(mligo|jsligo)$/.test(sourceFile);\n\nexport const isUnsupportedLigoSyntax = (sourceFile: string) => /\\.(ligo|religo)$/.test(sourceFile);\n\nexport const isLIGOFile = (sourceFile: string) =>\n\tisSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);\n\nexport const isStorageListFile = (sourceFile: string): boolean =>\n\t/.+\\.(storageList|storages)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nexport const isParameterListFile = (sourceFile: string): boolean =>\n\t/.+\\.(parameterList|parameters)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.(ligo|religo|mligo|jsligo)$/);\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\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, module: ModuleInfo): string => {\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(getArtifactsDir(parsedArgs), `${module.moduleName}${ext}`);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, module: ModuleInfo, exprKind: ExprKind, exprName: string): string => {\n\tconst contractName = module.moduleName;\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst outputFile = exprKind === 'default_storage'\n\t\t? `${contractName}.default_storage${ext}`\n\t\t: `${contractName}.${exprKind}.${exprName}${ext}`;\n\treturn join(getArtifactsDir(parsedArgs), `${outputFile}`);\n};\n\nconst getExprNames = (parsedArgs: Opts, sourceFile: string): Promise<string[]> => {\n\treturn new Promise((resolve, reject) => {\n\t\tconst inputFilePath = getInputFilenameAbsPath(parsedArgs, sourceFile);\n\t\tconst readInterface = readline.createInterface({\n\t\t\tinput: createReadStream(inputFilePath),\n\t\t\toutput: process.stdout,\n\t\t});\n\n\t\tconst variableNames: string[] = [];\n\n\t\treadInterface.on('line', function(line) {\n\t\t\t// Skip lines that start with a comment\n\t\t\tif (!line.trim().startsWith('//')) {\n\t\t\t\tconst matches = line.match(/(?<=\\s*(let|const)\\s+)[a-zA-Z0-9_]+/g);\n\t\t\t\tif (matches) {\n\t\t\t\t\tvariableNames.push(...matches);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treadInterface.on('close', function() {\n\t\t\tresolve(variableNames);\n\t\t});\n\t});\n};\n\n// Helper function to get the initial message based on the pair value\nconst getInitialMessage = (pair: string, module: ModuleInfo) => {\n\tconst messages = {\n\t\t'mligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t// ... any other combinations\n\t} as Record<string, string>;\n\n\treturn messages[pair] || '// This file was created by Taqueria.';\n};\n\n// Helper function to get a common message\nconst getCommonMsg = (langType: Syntax, listType: ExprKind) => {\n\tconst varKeyword = langType === 'mligo' ? 'let' : 'const';\n\tconst commonMsgForStorage = `// IMPORTANT: We suggest always explicitly typing your storage values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} storage: int = 10\\` or \\`${varKeyword} storage: Contract.storage = 10\\``;\n\n\tconst commonMsgForParameter = `// IMPORTANT: We suggest always explicitly typing your parameter values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} parameter: int = 10\\` or \\`${varKeyword} parameter: Contract.parameter = 10\\``;\n\n\treturn listType === 'storage' ? commonMsgForStorage : commonMsgForParameter;\n};\n\n// Main function to get the content for storage or parameter\nconst getContent = (moduleInfo: ModuleInfo, listType: ExprKind) => {\n\tconst linkToContract = `#import \"${moduleInfo.sourceFile}\" \"Contract\"`;\n\tconst pair = `${moduleInfo.syntax}-${moduleInfo.type}`;\n\tconst initialMsg = getInitialMessage(pair, moduleInfo);\n\tconst commonMsg = getCommonMsg(moduleInfo.syntax, listType);\n\n\treturn `${linkToContract}\\n\\n${initialMsg}\\n\\n${commonMsg}`;\n};\n\n// Usage for storage list\nconst initContentForStorage = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'storage');\n\n// Usage for parameter list\nconst initContentForParameter = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'parameter');\n\n// Inject commonObj to return some functions\nexport const inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getListDeclarationsCmd = async (parsedArgs: UnionOpts, sourceFile: string): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} info list-declarations`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst flags = '--display-format json';\n\t\tconst cmd = `${baseCmd} ${inputFile} ${flags}`;\n\t\treturn cmd;\n\t};\n\n\tconst listContractModules = async (parsedArgs: UnionOpts, sourceFile: string): Promise<ModuleInfo[]> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getListDeclarationsCmd(parsedArgs, sourceFile);\n\t\t\tconst { stderr, stdout } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) return Promise.reject(stderr);\n\n\t\t\treturn JSON.parse(stdout).declarations.reduce(\n\t\t\t\t(acc: ModuleInfo[], decl: string) => {\n\t\t\t\t\t// We need to process delcarations (decl) like so:\n\t\t\t\t\t// 1. If the decl is equal to the string \"main\", then the module type is \"file-main\" and the name of the module is the sourceFile.\n\t\t\t\t\t// 2. If the decl is equal to $main, then the module type is \"file-entry\" and the name fo the module is the sourceFile.\n\t\t\t\t\t// 3. If the decl ends with .main, then the module type is \"module-main\" and the name of the module is the decl without the .main suffix.\n\t\t\t\t\t// 4. If the decl ends with .$main, then the module type is \"module-entry\" and the name of the module is the decl without the .$main suffix.\n\t\t\t\t\t// Otherwise, this is not a declaration we care about.\n\t\t\t\t\tconst srcFile = removeExt(basename(sourceFile));\n\t\t\t\t\tconst syntax = extractExt(sourceFile).replace('.', '');\n\n\t\t\t\t\tif (decl === 'main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-main', syntax }];\n\t\t\t\t\t} else if (decl === '$main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-entry', syntax }];\n\t\t\t\t\t} else if (decl.endsWith('.main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-main',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t} else if (decl.endsWith('.$main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.\\$main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-entry',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [];\n\t\t}\n\t};\n\n\tconst getCompileContractCmd = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputContractFilename(parsedArgs, module)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\t\tconst moduleFlag = module.type.startsWith('file-') ? '' : `-m ${module.moduleName}`;\n\t\tconst cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileContract = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<TableRow> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getCompileContractCmd(parsedArgs, sourceFile, module);\n\t\t\tconst { stderr } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: getOutputContractFilename(parsedArgs, module),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t}\n\t};\n\n\tconst getCompileExprCmd = (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t\texprName: string,\n\t): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputExprFilename(parsedArgs, module, exprKind, exprName)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\n\t\t// Parameter and Storage list files are expected to import the smart contract file as the \"Contract\" module.\n\t\tconst moduleFlag = (() => {\n\t\t\tswitch (module.type) {\n\t\t\t\tcase 'file-main':\n\t\t\t\tcase 'file-entry':\n\t\t\t\t\treturn '-m Contract';\n\t\t\t\tdefault:\n\t\t\t\t\treturn `-m Contract.${module.moduleName}`;\n\t\t\t}\n\t\t})();\n\n\t\tconst cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags} ${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileExpr =\n\t\t(parsedArgs: Opts, sourceFile: string, module: ModuleInfo, exprKind: ExprKind) =>\n\t\t(exprName: string): Promise<TableRow> => {\n\t\t\treturn getArch()\n\t\t\t\t.then(() => getCompileExprCmd(parsedArgs, sourceFile, module, exprKind, exprName))\n\t\t\t\t.then(execCmd)\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t\tconst artifactName = getOutputExprFilename(parsedArgs, module, exprKind, exprName);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: artifactName,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: `${exprName} in ${sourceFile} not compiled`,\n\t\t\t\t\t\terr,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t};\n\n\tconst compileExprs = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t): Promise<TableRow[]> => {\n\t\t// Get expressions from file\n\t\tlet exprs = [];\n\t\ttry {\n\t\t\texprs = await getExprNames(parsedArgs, sourceFile);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [{\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: `No ${isStorageKind(exprKind) ? 'storage' : 'parameter'} expressions compiled`,\n\t\t\t}];\n\t\t}\n\n\t\tconst results = await Promise.all(exprs.map(async (exprName, index) => {\n\t\t\tconst compileResult = await compileExpr(\n\t\t\t\tparsedArgs,\n\t\t\t\tsourceFile,\n\t\t\t\tmodule,\n\t\t\t\texprKind === 'storage' && index === 0 ? 'default_storage' : exprKind,\n\t\t\t)(exprName);\n\t\t\treturn compileResult;\n\t\t}));\n\n\t\t// Collect errors\n\t\tconst errors = results.reduce(\n\t\t\t(acc, result) => {\n\t\t\t\tif (result.err) {\n\t\t\t\t\t// If its not an Error object, then just add it to the list\n\t\t\t\t\tif (!(result.err instanceof Error)) return [...acc, result.err];\n\n\t\t\t\t\t// Otherwise, get all ligo errors and ensure that the list is unique\n\t\t\t\t\tconst ligoErrs = (acc\n\t\t\t\t\t\t.filter(err => err instanceof Error) as Error[])\n\t\t\t\t\t\t.map(err => err.message);\n\n\t\t\t\t\tconst formattedError = formatLigoError(result.err);\n\n\t\t\t\t\treturn (ligoErrs.includes(formattedError.message)) ? acc : [...acc, formattedError];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[] as unknown[],\n\t\t);\n\n\t\t// Collect table rows\n\t\tconst retval = results.map(({ source, artifact }) => ({ source, artifact }));\n\n\t\tif (errors.length) emitExternalError(errors, sourceFile);\n\n\t\treturn retval;\n\t};\n\n\tconst compileContractWithStorageAndParameter = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t): Promise<TableRow[]> => {\n\t\tconst contractCompileResult = await compileContract(parsedArgs, sourceFile, module);\n\t\tif (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];\n\t\tdebugger;\n\n\t\tconst storageListFile = `${module.moduleName}.storageList${extractExt(sourceFile)}`;\n\t\tconst storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);\n\t\tconst storageCompileResult = await access(storageListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, storageListFile, module, 'storage'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(storageListFilename, initContentForStorage(module), 'utf8');\n\t\t\t});\n\n\t\tconst parameterListFile = `${module.moduleName}.parameterList${extractExt(sourceFile)}`;\n\t\tconst parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);\n\t\tconst parameterCompileResult = await access(parameterListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, parameterListFile, module, 'parameter'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(parameterListFilename, initContentForParameter(module), 'utf8');\n\t\t\t});\n\n\t\tconst storageArtifacts = storageCompileResult ? storageCompileResult.map(res => res.artifact).join('\\n') : '';\n\t\tconst parameterArtifacts = parameterCompileResult ? parameterCompileResult.map(res => res.artifact).join('\\n') : '';\n\n\t\tconst combinedArtifact = [\n\t\t\tcontractCompileResult.artifact,\n\t\t\tstorageArtifacts,\n\t\t\tparameterArtifacts,\n\t\t].filter(Boolean).join('\\n');\n\n\t\tconst combinedRow: TableRow = {\n\t\t\tsource: module.sourceName,\n\t\t\tartifact: combinedArtifact,\n\t\t};\n\n\t\treturn [combinedRow];\n\t};\n\n\treturn {\n\t\tgetLigoDockerImage,\n\t\tgetListDeclarationsCmd,\n\t\tlistContractModules,\n\t\tgetCompileContractCmd,\n\t\tcompileContract,\n\t\tgetCompileExprCmd,\n\t\tcompileExpr,\n\t\tcompileExprs,\n\t\tcompileContractWithStorageAndParameter,\n\t};\n};\n\nexport const compile = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!isLIGOFile(sourceFile)) {\n\t\tsendErr(`${sourceFile} is not a LIGO file`);\n\t\treturn;\n\t}\n\tif (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {\n\t\tsendErr(`Storage and parameter list files are not meant to be compiled directly`);\n\t\treturn;\n\t}\n\tif (isUnsupportedLigoSyntax(sourceFile)) {\n\t\tsendErr(`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst modules = await listContractModules(parsedArgs, sourceFile);\n\t\tif (modules.length === 0) {\n\t\t\treturn sendJsonRes([\n\t\t\t\t{\n\t\t\t\t\tsource: sourceFile,\n\t\t\t\t\tartifact: `No contract modules found in \"${sourceFile}\"`,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tlet allCompileResults: TableRow[] = [];\n\t\tfor (const module of modules) {\n\t\t\t// If we're only to compile a particular module, then we'll skip any that don't match\n\t\t\tif (parsedArgs.module && parsedArgs.module !== module.moduleName) continue;\n\n\t\t\tconst compileResults = await compileContractWithStorageAndParameter(parsedArgs, sourceFile, module);\n\t\t\tallCompileResults = allCompileResults.concat(compileResults);\n\t\t}\n\n\t\tsendJsonRes(allCompileResults, { footer: `\\nCompiled ${allCompileResults.length} contract(s) in \"${sourceFile}\"` });\n\t} catch (err) {\n\t\tsendErr(`Error processing \"${sourceFile}\": ${err}`);\n\t}\n};\n\nexport default compile;\n","import { sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { Common, CompileAllOpts, CompileAllOpts as Opts, CompileOpts } from './common';\nimport { inject, isParameterListFile, isStorageListFile, TableRow } from './compile';\n\nconst compileAll = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tlet compilePromises: Promise<TableRow[]>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n\t\t{\n\t\t\tcwd: join(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts'),\n\t\t\tabsolute: false,\n\t\t},\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (isStorageListFile(filename) || isParameterListFile(filename)) continue;\n\t\tconst moduleNames = await listContractModules(parsedArgs as unknown as CompileAllOpts, filename);\n\t\tfor (const moduleName of moduleNames) {\n\t\t\tcompilePromises.push(compileContractWithStorageAndParameter(parsedArgs as CompileOpts, filename, moduleName));\n\t\t}\n\t}\n\n\treturn Promise.all(compilePromises)\n\t\t.then(tables => tables.flat())\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { readJsonFile, writeJsonFile } from '@taqueria/node-sdk';\nimport { join } from 'path';\nimport { Common, configure, LigoOpts as Opts } from './common';\n\nconst getArbitraryLigoCmd = (\n\tcommonObj: Common,\n\tparsedArgs: Opts,\n\tuid: string,\n\tgid: string,\n\tuserArgs: string,\n): [string, Record<string, string>] => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\n\tconst userMap = uid && gid ? `${uid}:${gid}` : uid;\n\tconst userMapArgs = uid ? ['-u', userMap] : [];\n\n\tconst binary = 'docker';\n\tconst baseArgs = [\n\t\t'run',\n\t\t'--rm',\n\t\t'-v',\n\t\t`${projectDir}:/project`,\n\t\t'-w',\n\t\t'/project',\n\t\t...userMapArgs,\n\t\tcommonObj.getLigoDockerImage(),\n\t];\n\tconst processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\\\-') ? arg.substring(1) : arg).filter(arg =>\n\t\targ\n\t);\n\tconst args = [...baseArgs, ...processedUserArgs, '--skip-analytics'];\n\tconst envVars = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };\n\treturn [\n\t\t[binary, ...args].join(' '),\n\t\tenvVars,\n\t];\n};\n\nconst ensureEsyExists = async (parsedArgs: Opts): Promise<string> => {\n\tconst esyJsonPath = join(parsedArgs.projectDir, 'esy.json');\n\n\ttry {\n\t\treturn await readJsonFile(esyJsonPath);\n\t} catch {\n\t\treturn await writeJsonFile(esyJsonPath)({});\n\t}\n};\n\nconst runArbitraryLigoCmd = (commonObj: Common, parsedArgs: Opts, cmd: string): Promise<string> =>\n\tensureEsyExists(parsedArgs)\n\t\t.then(getArch)\n\t\t.then(async () => {\n\t\t\tconst uid = await execCmd('id -u');\n\t\t\tconst gid = await execCmd('id -g');\n\t\t\treturn [uid.stdout.trim(), gid.stdout.trim()];\n\t\t})\n\t\t.then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd))\n\t\t.then(([cmd, envVars]) => spawnCmd(cmd, envVars))\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by LIGO`\n\t\t\t\t: `Command \"${cmd}\" failed. Please check your command`\n\t\t)\n\t\t.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));\n\nconst ligo = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryLigoCmd(commonObj, parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default ligo;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { Common, emitExternalError, getInputFilenameRelPath, TestOpts as Opts } from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw `No project directory provided`;\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst cmd = `${baseCmd} ${inputFile}`;\n\t\treturn cmd;\n\t};\n\n\tconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\t\tgetArch()\n\t\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stdout, stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\temitExternalError(err, sourceFile);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t\t};\n\t\t\t});\n\n\treturn {\n\t\ttestContract,\n\t\tgetTestContractCmd,\n\t};\n};\n\nconst test = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { testContract } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!sourceFile) return sendAsyncErr(`No source file provided`);\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,eAAe,MAAM,gBAAgB;;;ACA9D,SAAS,oBAAoB;AAE7B,SAAS,iBAAiB;;;ACF1B;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAavB,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ADH/B,IAAM,kBAAkB,OACvB,cACA,QACA,sBACqB;AACrB,QAAM,cAAc,aAAa,MAAM,UAAU;AACjD,QAAM,MAAM,cAAc,YAAY,CAAC,EAAE,UAAU,CAAC,IAAI;AACxD,QAAM,YAAY,qBAAqB;AAEvC,MAAI,WAAW;AAAS,WAAO,UAAU;AACzC,MAAI,WAAW;AAAU,WAAO,UAAU;AAE1C,MAAI,WAAW,QAAW;AACzB,QAAI,QAAQ;AAAS,aAAO,UAAU;AACtC,QAAI,QAAQ;AAAU,aAAO,UAAU;AACvC,WAAO;AAAA,MACN,qCAAqC,YAAY;AAAA,IA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cAAc,OAAO;AAAA,YACpB,aAAa;AAAA,YACb,MAAM;AAAA,YACN,aAAa;AAAA,UACd,CAAC;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UACR,OAAO,OAAO;AAAA,YACb,WAAW;AAAA,YACX,MAAM;AAAA,YACN,MAAM;AAAA,YACN,aAAa;AAAA,UACd,CAAC;AAAA,QACF;AAAA,QACA,SAAS,uBAAe,SAAS,SAAS;AAAA,MAC3C,CAAC;AAAA,IACF;AAAA,IACA,OAAO,aAAK,SAAS,aAAa,SAAS,iBAAiB;AAAA,IAC5D,aAAa,QAAQ,SAAS;AAAA,EAC/B;AAEA,SAAO,OAAO,OAAO,MAAM,SAAS,eAAe,SAAS,aAAa,MAAM,IAAI,QAAQ,SAAS,YAAY;AACjH;","names":["sendAsyncErr","sendErr","writeFile","join","join","writeFile","sendErr","sendErr","sendJsonRes","join","join","sendJsonRes","sendErr","execCmd","getArch","sendAsyncErr","sendRes","join","cmd","execCmd","getArch","sendAsyncErr","sendJsonRes","sendWarn","inject","getArch","execCmd","sendWarn","sendAsyncErr","sendJsonRes","sendAsyncErr"]}
|
|
1
|
+
{"version":3,"sources":["index.ts","createContract.ts","ligo_templates.ts","main.ts","common.ts","compile.ts","compile-all.ts","ligo.ts","test.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport * as PluginSchema from '@taqueria/protocol/PluginSchema';\n\nimport createContract from './createContract';\nimport main from './main';\n\ntype PluginConfigurator = (plugin: PluginSchema.RawPluginSchema) => PluginSchema.RawPluginSchema;\ntype ConfiguratorArgs = {\n\tname: string;\n\talias: string;\n\tconfigurator?: PluginConfigurator;\n\tunparsedArgs: string[];\n\tdockerImage: string;\n\tdockerImageEnvVar: string;\n\ttemplates?: Record<string, string>;\n};\n\nexport const configurePlugin = (settings: ConfiguratorArgs) => {\n\tconst schema = {\n\t\tname: settings.name,\n\t\tschema: '1.0',\n\t\tversion: '0.1',\n\t\talias: settings.alias,\n\t\ttasks: [\n\t\t\tTask.create({\n\t\t\t\ttask: 'ligo',\n\t\t\t\tcommand: 'ligo',\n\t\t\t\tdescription:\n\t\t\t\t\t'This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 'c',\n\t\t\t\t\t\tflag: 'command',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The command to be passed to the underlying LIGO binary, wrapped in quotes',\n\t\t\t\t\t\trequired: true,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'none',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile',\n\t\t\t\tcommand: 'compile <sourceFile>',\n\t\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'module',\n\t\t\t\t\t\tshortFlag: 'm',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The LIGO module to be compiled',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile-all',\n\t\t\t\tcommand: 'compile-all',\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile all main smart contracts written in a LIGO syntax to Michelson code, along with their associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'test',\n\t\t\t\tcommand: 'test <sourceFile>',\n\t\t\t\tdescription: 'Test a smart contract written in LIGO',\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'get-image',\n\t\t\t\tcommand: 'get-image',\n\t\t\t\tdescription: 'Gets the name of the image to be used',\n\t\t\t\thandler: 'proxy',\n\t\t\t\thidden: true,\n\t\t\t}),\n\t\t],\n\t\ttemplates: [\n\t\t\tTemplate.create({\n\t\t\t\ttemplate: 'contract',\n\t\t\t\tcommand: 'contract <sourceFileName>',\n\t\t\t\tdescription: 'Create a LIGO contract with boilerplate code',\n\t\t\t\tpositionals: [\n\t\t\t\t\tPositionalArg.create({\n\t\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The name of the LIGO contract to generate',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 's',\n\t\t\t\t\t\tflag: 'syntax',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The syntax used in the contract',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: createContract(settings.templates),\n\t\t\t}),\n\t\t],\n\t\tproxy: main(settings.dockerImage, settings.dockerImageEnvVar),\n\t\tpostInstall: `node ${__dirname}/postinstall.js`,\n\t};\n\n\treturn Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);\n};\n","import { sendAsyncErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { writeFile } from 'fs/promises';\nimport * as default_templates from './ligo_templates';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n\tsyntax?: string;\n}\n\nconst getLigoTemplate = async (\n\tcontractName: string,\n\tsyntax: string | undefined,\n\ttemplateOverrides?: Record<string, string>,\n): Promise<string> => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0].substring(1) : null;\n\tconst templates = templateOverrides ?? default_templates;\n\n\tif (syntax === 'mligo') return templates.mligo_template;\n\tif (syntax === 'jsligo') return templates.jsligo_template;\n\n\tif (syntax === undefined) {\n\t\tif (ext === 'mligo') return templates.mligo_template;\n\t\tif (ext === 'jsligo') return templates.jsligo_template;\n\t\treturn sendAsyncErr(\n\t\t\t`Unable to infer LIGO syntax from \"${contractName}\". Please specify a LIGO syntax via the --syntax option`,\n\t\t);\n\t} else {\n\t\treturn sendAsyncErr(`\"${syntax}\" is not a valid syntax. Please specify a valid LIGO syntax`);\n\t}\n};\n\nconst createContract = (templates?: Record<string, string>) => (args: RequestArgs.t) => {\n\tconst unsafeOpts = args as unknown as Opts;\n\tconst contractName = unsafeOpts.sourceFileName as string;\n\tconst syntax = unsafeOpts.syntax;\n\tconst contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;\n\treturn getLigoTemplate(contractName, syntax, templates)\n\t\t.then(ligo_template => writeFile(`${contractsDir}/${contractName}`, ligo_template));\n};\n\nexport default createContract;\n","export const mligo_template = `\ntype storage = int\ntype return = operation list * storage\n\n(* Three entrypoints *)\n[@entry] let increment (delta : int) (store : storage) : return =\n [], store + delta\n[@entry] let decrement (delta : int) (store : storage) : return =\n [], store - delta\n[@entry] let reset (() : unit) (_ : storage) : return =\n [], 0\n`;\n\nexport const jsligo_template = `\ntype storage = int;\ntype ret = [list<operation>, storage];\n\n// Three entrypoints\n\n// @entry\nconst increment = (delta : int, store : storage) : ret =>\n [list([]), store + delta];\n\n// @entry\nconst decrement = (delta : int, store : storage) : ret =>\n [list([]), store - delta];\n\n// @entry\nconst reset = (_ : unit, _ : storage) : ret =>\n [list([]), 0];\n`;\n","import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { configure, IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compile-all';\nimport ligo from './ligo';\nimport test from './test';\n\nconst main = (dockerImage: string, dockerImageEnvVar: string) => (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst commonObj = configure(dockerImage, dockerImageEnvVar);\n\tconst unsafeOpts = parsedArgs as unknown as Opts;\n\tswitch (unsafeOpts.task) {\n\t\tcase 'ligo':\n\t\t\treturn ligo(commonObj, unsafeOpts);\n\t\tcase 'compile':\n\t\t\treturn compile(commonObj, unsafeOpts);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(commonObj, unsafeOpts);\n\t\tcase 'test':\n\t\t\treturn test(commonObj, parsedArgs);\n\t\tcase 'get-image':\n\t\t\treturn sendAsyncRes(commonObj.getLigoDockerImage());\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);\n\t}\n};\n\nexport default main;\n","import { getDockerImage, sendErr } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk/types';\nimport { join } from 'path';\n\nexport interface LigoOpts extends ProxyTaskArgs.t {\n\tcommand: string;\n}\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n\tmodule?: string;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends RequestArgs.t {\n\ttask?: string;\n\tsourceFile?: string;\n}\n\nexport type IntersectionOpts = LigoOpts & CompileOpts & CompileAllOpts & TestOpts;\n\nexport type UnionOpts = LigoOpts | CompileOpts | CompileAllOpts | TestOpts;\n\nexport const getInputFilenameAbsPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const getInputFilenameRelPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const formatLigoError = (err: Error): Error => {\n\tlet result = err.message.replace(/Command failed.+?\\n/, '');\n\tif (\n\t\tresult.includes('An internal error ocurred. Please, contact the developers.')\n\t\t&& result.includes('Module Contract not found with last Contract.')\n\t) {\n\t\tresult =\n\t\t\t`By convention, Taqueria expects you to import your contract with Contract as the module name.\\nFor 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.`;\n\t} else {\n\t\tconst regex = /contracts\\/(.+): No such file or directory/;\n\t\tconst match = regex.exec(result);\n\t\tif (match) {\n\t\t\tconst filename = match[1];\n\t\t\tresult =\n\t\t\t\t`The file ${filename} was not found. Please ensure that the file exists and that it is in the contracts directory.`;\n\t\t}\n\t}\n\n\terr.message = result\n\t\t.replace(\n\t\t\t'An internal error ocurred. Please, contact the developers.',\n\t\t\t'The LIGO compiler experienced an internal error. Please contact the LIGO developers.',\n\t\t).replace(\n\t\t\t/Module (\"Contract\\.[^\"]+\") not found/,\n\t\t\t'The module $1 was not found. If your contract is defined within a namespace, please ensure that it has been exported.',\n\t\t);\n\n\treturn err;\n};\n\nexport const emitExternalError = (errs: unknown[] | unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\tconst errors = Array.isArray(errs) ? errs : [errs];\n\terrors.map(err => {\n\t\terr instanceof Error ? sendErr(err.message) : sendErr(err as any);\n\t});\n\tsendErr(`===`);\n};\n\nexport const configure = (dockerImage: string, dockerImageEnvVar: string) => ({\n\tLIGO_DEFAULT_IMAGE: dockerImage,\n\tLIGO_IMAGE_ENV_VAR: dockerImageEnvVar,\n\tgetLigoDockerImage: () => getDockerImage(dockerImage, dockerImageEnvVar),\n});\n\nexport type Common = ReturnType<typeof configure>;\n","import {\n\texecCmd,\n\tgetArch,\n\tgetArtifactsDir,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { createReadStream } from 'fs';\nimport { access, readFile, writeFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport * as readline from 'readline';\nimport {\n\tCommon,\n\tCompileOpts as Opts,\n\tconfigure,\n\temitExternalError,\n\tformatLigoError,\n\tgetInputFilenameAbsPath,\n\tgetInputFilenameRelPath,\n\tUnionOpts,\n} from './common';\n\nexport type TableRow = { source: string; artifact: string; err?: unknown };\n\nexport type ExprKind = 'storage' | 'default_storage' | 'parameter';\n\nexport type Syntax = 'mligo' | 'jsligo' | 'religo' | 'ligo';\n\nexport type ModuleInfo = {\n\tmoduleName: string;\n\tsourceName: string;\n\tsourceFile: string;\n\tsyntax: Syntax;\n\ttype: 'file-main' | 'file-entry' | 'module-main' | 'module-entry';\n};\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' || exprKind === 'default_storage';\n\nexport const isSupportedLigoSyntax = (sourceFile: string) => /\\.(mligo|jsligo)$/.test(sourceFile);\n\nexport const isUnsupportedLigoSyntax = (sourceFile: string) => /\\.(ligo|religo)$/.test(sourceFile);\n\nexport const isLIGOFile = (sourceFile: string) =>\n\tisSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);\n\nexport const isStorageListFile = (sourceFile: string): boolean =>\n\t/.+\\.(storageList|storages)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nexport const isParameterListFile = (sourceFile: string): boolean =>\n\t/.+\\.(parameterList|parameters)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.(ligo|religo|mligo|jsligo)$/);\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\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, module: ModuleInfo): string => {\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(getArtifactsDir(parsedArgs), `${module.moduleName}${ext}`);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, module: ModuleInfo, exprKind: ExprKind, exprName: string): string => {\n\tconst contractName = module.moduleName;\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst outputFile = exprKind === 'default_storage'\n\t\t? `${contractName}.default_storage${ext}`\n\t\t: `${contractName}.${exprKind}.${exprName}${ext}`;\n\treturn join(getArtifactsDir(parsedArgs), `${outputFile}`);\n};\n\nconst getExprNames = (parsedArgs: Opts, sourceFile: string): Promise<string[]> => {\n\treturn new Promise((resolve, reject) => {\n\t\tconst inputFilePath = getInputFilenameAbsPath(parsedArgs, sourceFile);\n\t\tconst readInterface = readline.createInterface({\n\t\t\tinput: createReadStream(inputFilePath),\n\t\t\toutput: process.stdout,\n\t\t});\n\n\t\tconst variableNames: string[] = [];\n\n\t\treadInterface.on('line', function(line) {\n\t\t\t// Skip lines that start with a comment\n\t\t\tif (!line.trim().startsWith('//')) {\n\t\t\t\tconst matches = line.match(/(?<=\\s*(let|const)\\s+)[a-zA-Z0-9_]+/g);\n\t\t\t\tif (matches) {\n\t\t\t\t\tvariableNames.push(...matches);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treadInterface.on('close', function() {\n\t\t\tresolve(variableNames);\n\t\t});\n\t});\n};\n\n// Helper function to get the initial message based on the pair value\nconst getInitialMessage = (pair: string, module: ModuleInfo) => {\n\tconst messages = {\n\t\t'mligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t// ... any other combinations\n\t} as Record<string, string>;\n\n\treturn messages[pair] || '// This file was created by Taqueria.';\n};\n\n// Helper function to get a common message\nconst getCommonMsg = (langType: Syntax, listType: ExprKind) => {\n\tconst varKeyword = langType === 'mligo' ? 'let' : 'const';\n\tconst commonMsgForStorage = `// IMPORTANT: We suggest always explicitly typing your storage values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} storage: int = 10\\` or \\`${varKeyword} storage: Contract.storage = 10\\``;\n\n\tconst commonMsgForParameter = `// IMPORTANT: We suggest always explicitly typing your parameter values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} parameter: int = 10\\` or \\`${varKeyword} parameter: Contract.parameter = 10\\``;\n\n\treturn listType === 'storage' ? commonMsgForStorage : commonMsgForParameter;\n};\n\n// Main function to get the content for storage or parameter\nconst getContent = (moduleInfo: ModuleInfo, listType: ExprKind) => {\n\tconst linkToContract = `#import \"${moduleInfo.sourceFile}\" \"Contract\"`;\n\tconst pair = `${moduleInfo.syntax}-${moduleInfo.type}`;\n\tconst initialMsg = getInitialMessage(pair, moduleInfo);\n\tconst commonMsg = getCommonMsg(moduleInfo.syntax, listType);\n\n\treturn `${linkToContract}\\n\\n${initialMsg}\\n\\n${commonMsg}`;\n};\n\n// Usage for storage list\nconst initContentForStorage = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'storage');\n\n// Usage for parameter list\nconst initContentForParameter = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'parameter');\n\n// Inject commonObj to return some functions\nexport const inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getListDeclarationsCmd = async (parsedArgs: UnionOpts, sourceFile: string): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} info list-declarations`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst flags = '--display-format json';\n\t\tconst cmd = `${baseCmd} ${inputFile} ${flags}`;\n\t\treturn cmd;\n\t};\n\n\tconst listContractModules = async (parsedArgs: UnionOpts, sourceFile: string): Promise<ModuleInfo[]> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getListDeclarationsCmd(parsedArgs, sourceFile);\n\t\t\tconst { stderr, stdout } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) return Promise.reject(stderr);\n\n\t\t\treturn JSON.parse(stdout).declarations.reduce(\n\t\t\t\t(acc: ModuleInfo[], decl: string) => {\n\t\t\t\t\t// We need to process delcarations (decl) like so:\n\t\t\t\t\t// 1. If the decl is equal to the string \"main\", then the module type is \"file-main\" and the name of the module is the sourceFile.\n\t\t\t\t\t// 2. If the decl is equal to $main, then the module type is \"file-entry\" and the name fo the module is the sourceFile.\n\t\t\t\t\t// 3. If the decl ends with .main, then the module type is \"module-main\" and the name of the module is the decl without the .main suffix.\n\t\t\t\t\t// 4. If the decl ends with .$main, then the module type is \"module-entry\" and the name of the module is the decl without the .$main suffix.\n\t\t\t\t\t// Otherwise, this is not a declaration we care about.\n\t\t\t\t\tconst srcFile = removeExt(basename(sourceFile));\n\t\t\t\t\tconst syntax = extractExt(sourceFile).replace('.', '');\n\n\t\t\t\t\tif (decl === 'main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-main', syntax }];\n\t\t\t\t\t} else if (decl === '$main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-entry', syntax }];\n\t\t\t\t\t} else if (decl.endsWith('.main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-main',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t} else if (decl.endsWith('.$main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.\\$main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-entry',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tconst formattedErr = err instanceof Error ? formatLigoError(err) : err;\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [];\n\t\t}\n\t};\n\n\tconst getCompileContractCmd = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputContractFilename(parsedArgs, module)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\t\tconst moduleFlag = module.type.startsWith('file-') ? '' : `-m ${module.moduleName}`;\n\t\tconst cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileContract = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<TableRow> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getCompileContractCmd(parsedArgs, sourceFile, module);\n\t\t\tconst { stderr } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: getOutputContractFilename(parsedArgs, module),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t}\n\t};\n\n\tconst getCompileExprCmd = (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t\texprName: string,\n\t): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputExprFilename(parsedArgs, module, exprKind, exprName)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\n\t\t// Parameter and Storage list files are expected to import the smart contract file as the \"Contract\" module.\n\t\tconst moduleFlag = (() => {\n\t\t\tswitch (module.type) {\n\t\t\t\tcase 'file-main':\n\t\t\t\tcase 'file-entry':\n\t\t\t\t\treturn '-m Contract';\n\t\t\t\tdefault:\n\t\t\t\t\treturn `-m Contract.${module.moduleName}`;\n\t\t\t}\n\t\t})();\n\n\t\tconst cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags} ${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileExpr =\n\t\t(parsedArgs: Opts, sourceFile: string, module: ModuleInfo, exprKind: ExprKind) =>\n\t\t(exprName: string): Promise<TableRow> => {\n\t\t\treturn getArch()\n\t\t\t\t.then(() => getCompileExprCmd(parsedArgs, sourceFile, module, exprKind, exprName))\n\t\t\t\t.then(execCmd)\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t\tconst artifactName = getOutputExprFilename(parsedArgs, module, exprKind, exprName);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: artifactName,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.catch(err => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\t\tartifact: `${exprName} in ${sourceFile} not compiled`,\n\t\t\t\t\t\terr,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t};\n\n\tconst compileExprs = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t): Promise<TableRow[]> => {\n\t\t// Get expressions from file\n\t\tlet exprs = [];\n\t\ttry {\n\t\t\texprs = await getExprNames(parsedArgs, sourceFile);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [{\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: `No ${isStorageKind(exprKind) ? 'storage' : 'parameter'} expressions compiled`,\n\t\t\t}];\n\t\t}\n\n\t\tconst results = await Promise.all(exprs.map(async (exprName, index) => {\n\t\t\tconst compileResult = await compileExpr(\n\t\t\t\tparsedArgs,\n\t\t\t\tsourceFile,\n\t\t\t\tmodule,\n\t\t\t\texprKind === 'storage' && index === 0 ? 'default_storage' : exprKind,\n\t\t\t)(exprName);\n\t\t\treturn compileResult;\n\t\t}));\n\n\t\t// Collect errors\n\t\tconst errors = results.reduce(\n\t\t\t(acc, result) => {\n\t\t\t\tif (result.err) {\n\t\t\t\t\t// If its not an Error object, then just add it to the list\n\t\t\t\t\tif (!(result.err instanceof Error)) return [...acc, result.err];\n\n\t\t\t\t\t// Otherwise, get all ligo errors and ensure that the list is unique\n\t\t\t\t\tconst ligoErrs = (acc\n\t\t\t\t\t\t.filter(err => err instanceof Error) as Error[])\n\t\t\t\t\t\t.map(err => err.message);\n\n\t\t\t\t\tconst formattedError = formatLigoError(result.err);\n\n\t\t\t\t\treturn (ligoErrs.includes(formattedError.message)) ? acc : [...acc, formattedError];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[] as unknown[],\n\t\t);\n\n\t\t// Collect table rows\n\t\tconst retval = results.map(({ source, artifact }) => ({ source, artifact }));\n\n\t\tif (errors.length) emitExternalError(errors, sourceFile);\n\n\t\treturn retval;\n\t};\n\n\tconst compileContractWithStorageAndParameter = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t): Promise<TableRow[]> => {\n\t\tconst contractCompileResult = await compileContract(parsedArgs, sourceFile, module);\n\t\tif (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];\n\n\t\tconst storageListFile = `${module.moduleName}.storageList${extractExt(sourceFile)}`;\n\t\tconst storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);\n\t\tconst storageCompileResult = await access(storageListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, storageListFile, module, 'storage'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(storageListFilename, initContentForStorage(module), 'utf8');\n\t\t\t});\n\n\t\tconst parameterListFile = `${module.moduleName}.parameterList${extractExt(sourceFile)}`;\n\t\tconst parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);\n\t\tconst parameterCompileResult = await access(parameterListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, parameterListFile, module, 'parameter'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`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\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(parameterListFilename, initContentForParameter(module), 'utf8');\n\t\t\t});\n\n\t\tconst storageArtifacts = storageCompileResult ? storageCompileResult.map(res => res.artifact).join('\\n') : '';\n\t\tconst parameterArtifacts = parameterCompileResult ? parameterCompileResult.map(res => res.artifact).join('\\n') : '';\n\n\t\tconst combinedArtifact = [\n\t\t\tcontractCompileResult.artifact,\n\t\t\tstorageArtifacts,\n\t\t\tparameterArtifacts,\n\t\t].filter(Boolean).join('\\n');\n\n\t\tconst combinedRow: TableRow = {\n\t\t\tsource: module.sourceName,\n\t\t\tartifact: combinedArtifact,\n\t\t};\n\n\t\treturn [combinedRow];\n\t};\n\n\treturn {\n\t\tgetLigoDockerImage,\n\t\tgetListDeclarationsCmd,\n\t\tlistContractModules,\n\t\tgetCompileContractCmd,\n\t\tcompileContract,\n\t\tgetCompileExprCmd,\n\t\tcompileExpr,\n\t\tcompileExprs,\n\t\tcompileContractWithStorageAndParameter,\n\t};\n};\n\nexport const compile = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!isLIGOFile(sourceFile)) {\n\t\tsendErr(`${sourceFile} is not a LIGO file`);\n\t\treturn;\n\t}\n\tif (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {\n\t\tsendErr(`Storage and parameter list files are not meant to be compiled directly`);\n\t\treturn;\n\t}\n\tif (isUnsupportedLigoSyntax(sourceFile)) {\n\t\tsendErr(`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst modules = await listContractModules(parsedArgs, sourceFile);\n\t\tif (modules.length === 0) {\n\t\t\treturn sendJsonRes([\n\t\t\t\t{\n\t\t\t\t\tsource: sourceFile,\n\t\t\t\t\tartifact:\n\t\t\t\t\t\t`No contract modules found in \"${sourceFile}\".\\nIf your contract is defined within a namespace, please ensure that it is exported from the contract file.\"`,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tlet allCompileResults: TableRow[] = [];\n\t\tfor (const module of modules) {\n\t\t\t// If we're only to compile a particular module, then we'll skip any that don't match\n\t\t\tif (parsedArgs.module && parsedArgs.module !== module.moduleName) continue;\n\n\t\t\tconst compileResults = await compileContractWithStorageAndParameter(parsedArgs, sourceFile, module);\n\t\t\tallCompileResults = allCompileResults.concat(compileResults);\n\t\t}\n\n\t\tsendJsonRes(allCompileResults, { footer: `\\nCompiled ${allCompileResults.length} contract(s) in \"${sourceFile}\"` });\n\t} catch (err) {\n\t\tsendErr(`Error processing \"${sourceFile}\": ${err}`);\n\t}\n};\n\nexport default compile;\n","import { sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { Common, CompileAllOpts, CompileAllOpts as Opts, CompileOpts } from './common';\nimport { inject, isParameterListFile, isStorageListFile, TableRow } from './compile';\n\nconst compileAll = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { listContractModules, compileContractWithStorageAndParameter } = inject(commonObj);\n\n\tlet compilePromises: Promise<TableRow[]>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n\t\t{\n\t\t\tcwd: join(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts'),\n\t\t\tabsolute: false,\n\t\t},\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (isStorageListFile(filename) || isParameterListFile(filename)) continue;\n\t\tconst moduleNames = await listContractModules(parsedArgs as unknown as CompileAllOpts, filename);\n\t\tfor (const moduleName of moduleNames) {\n\t\t\tcompilePromises.push(compileContractWithStorageAndParameter(parsedArgs as CompileOpts, filename, moduleName));\n\t\t}\n\t}\n\n\treturn Promise.all(compilePromises)\n\t\t.then(tables => tables.flat())\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { readJsonFile, writeJsonFile } from '@taqueria/node-sdk';\nimport { join } from 'path';\nimport { Common, configure, LigoOpts as Opts } from './common';\n\nconst getArbitraryLigoCmd = (\n\tcommonObj: Common,\n\tparsedArgs: Opts,\n\tuid: string,\n\tgid: string,\n\tuserArgs: string,\n): [string, Record<string, string>] => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\n\tconst userMap = uid && gid ? `${uid}:${gid}` : uid;\n\tconst userMapArgs = uid ? ['-u', userMap] : [];\n\n\tconst binary = 'docker';\n\tconst baseArgs = [\n\t\t'run',\n\t\t'--rm',\n\t\t'-v',\n\t\t`${projectDir}:/project`,\n\t\t'-w',\n\t\t'/project',\n\t\t...userMapArgs,\n\t\tcommonObj.getLigoDockerImage(),\n\t];\n\tconst processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\\\-') ? arg.substring(1) : arg).filter(arg =>\n\t\targ\n\t);\n\tconst args = [...baseArgs, ...processedUserArgs, '--skip-analytics'];\n\tconst envVars = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };\n\treturn [\n\t\t[binary, ...args].join(' '),\n\t\tenvVars,\n\t];\n};\n\nconst runArbitraryLigoCmd = (commonObj: Common, parsedArgs: Opts, cmd: string): Promise<string> =>\n\t(async () => {\n\t\tconst uid = await execCmd('id -u');\n\t\tconst gid = await execCmd('id -g');\n\t\treturn [uid.stdout.trim(), gid.stdout.trim()];\n\t})()\n\t\t.then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd))\n\t\t.then(([cmd, envVars]) => spawnCmd(cmd, envVars))\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by LIGO`\n\t\t\t\t: `Command \"${cmd}\" failed. Please check your command`\n\t\t)\n\t\t.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));\n\nconst ligo = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryLigoCmd(commonObj, parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default ligo;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { Common, emitExternalError, getInputFilenameRelPath, TestOpts as Opts } from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst inject = (commonObj: Common) => {\n\tconst { getLigoDockerImage } = commonObj;\n\n\tconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw `No project directory provided`;\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst cmd = `${baseCmd} ${inputFile}`;\n\t\treturn cmd;\n\t};\n\n\tconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\t\tgetArch()\n\t\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stdout, stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\temitExternalError(err, sourceFile);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t\t};\n\t\t\t});\n\n\treturn {\n\t\ttestContract,\n\t\tgetTestContractCmd,\n\t};\n};\n\nconst test = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { testContract } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!sourceFile) return sendAsyncErr(`No source file provided`);\n\treturn testContract(parsedArgs,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","names":["sendAsyncErr","sendErr","writeFile","join","join","writeFile","sendErr","sendErr","sendJsonRes","join","join","sendJsonRes","sendErr","execCmd","sendAsyncErr","sendRes","cmd","execCmd","getArch","sendAsyncErr","sendJsonRes","sendWarn","inject","getArch","execCmd","sendWarn","sendAsyncErr","sendJsonRes","sendAsyncErr"]}
|
package/ligo.ts
CHANGED
|
@@ -38,24 +38,12 @@ const getArbitraryLigoCmd = (
|
|
|
38
38
|
];
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const ensureEsyExists = async (parsedArgs: Opts): Promise<string> => {
|
|
42
|
-
const esyJsonPath = join(parsedArgs.projectDir, 'esy.json');
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
return await readJsonFile(esyJsonPath);
|
|
46
|
-
} catch {
|
|
47
|
-
return await writeJsonFile(esyJsonPath)({});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
41
|
const runArbitraryLigoCmd = (commonObj: Common, parsedArgs: Opts, cmd: string): Promise<string> =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return [uid.stdout.trim(), gid.stdout.trim()];
|
|
58
|
-
})
|
|
42
|
+
(async () => {
|
|
43
|
+
const uid = await execCmd('id -u');
|
|
44
|
+
const gid = await execCmd('id -g');
|
|
45
|
+
return [uid.stdout.trim(), gid.stdout.trim()];
|
|
46
|
+
})()
|
|
59
47
|
.then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd))
|
|
60
48
|
.then(([cmd, envVars]) => spawnCmd(cmd, envVars))
|
|
61
49
|
.then(code =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/lib-ligo",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.23",
|
|
4
4
|
"description": "A taqueria library which provides common functionality for the LIGO and LIGO Legacy Plugins",
|
|
5
5
|
"targets": {
|
|
6
6
|
"default": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/pinnacle-labs/taqueria#readme",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@taqueria/node-sdk": "^0.40.
|
|
44
|
+
"@taqueria/node-sdk": "^0.40.23",
|
|
45
45
|
"fast-glob": "^3.3.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
package/postinstall.js
CHANGED
|
@@ -17,3 +17,20 @@ if (!fs.existsSync(filePath)) {
|
|
|
17
17
|
// If not, create and write 'accepted' to it
|
|
18
18
|
fs.writeFileSync(filePath, 'accepted');
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
// If we're provided JSON as input, parse it, and determine if the plugin name is `@taqueria/plugin-ligo-legacy`. If so, create an empty esy.json file if it doesn't exist.
|
|
22
|
+
const schema = process.argv.find(arg => arg.startsWith('{'))
|
|
23
|
+
if (schema) {
|
|
24
|
+
try {
|
|
25
|
+
const json = JSON.parse(schema);
|
|
26
|
+
if (json.name === '@taqueria/plugin-ligo-legacy') {
|
|
27
|
+
const esyJsonPath = path.join(process.cwd(), 'esy.json');
|
|
28
|
+
if (!fs.existsSync(esyJsonPath)) {
|
|
29
|
+
fs.writeFileSync(esyJsonPath, '{}');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Do nothing
|
|
35
|
+
}
|
|
36
|
+
}
|