@taqueria/plugin-ligo 0.27.2-alpha → 0.27.3-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,11 +1,32 @@
1
- var $kQNfl$taquerianodesdk = require("@taqueria/node-sdk");
2
- var $kQNfl$fspromises = require("fs/promises");
3
- var $kQNfl$path = require("path");
4
-
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
18
+ mod
19
+ ));
5
20
 
21
+ // index.ts
22
+ var import_node_sdk8 = require("@taqueria/node-sdk");
6
23
 
24
+ // createContract.ts
25
+ var import_node_sdk = require("@taqueria/node-sdk");
26
+ var import_promises = require("fs/promises");
7
27
 
8
- const $9d8c61104c8e60ad$export$1336661d942c7074 = `
28
+ // ligo_templates.ts
29
+ var mligo_template = `
9
30
  type storage = int
10
31
 
11
32
  type parameter =
@@ -30,7 +51,7 @@ let main (action, store : parameter * storage) : return =
30
51
  | Decrement (n) -> sub (store, n)
31
52
  | Reset -> 0)
32
53
  `;
33
- const $9d8c61104c8e60ad$export$ec41334b92330d9b = `
54
+ var pascaligo_template = `
34
55
  type storage is int
35
56
 
36
57
  type parameter is
@@ -59,7 +80,7 @@ function main (const action : parameter; const store : storage) : return is
59
80
  | Reset -> 0
60
81
  ])
61
82
  `;
62
- const $9d8c61104c8e60ad$export$9e59f1f7960689be = `
83
+ var religo_template = `
63
84
  type storage = int;
64
85
 
65
86
  type parameter =
@@ -85,7 +106,7 @@ let main = ((action, store) : (parameter, storage)) : return => {
85
106
  | Reset => 0}))
86
107
  };
87
108
  `;
88
- const $9d8c61104c8e60ad$export$6d35abb7f92d1079 = `
109
+ var jsligo_template = `
89
110
  type storage = int;
90
111
 
91
112
  type parameter =
@@ -112,427 +133,476 @@ const main = ([action, store] : [parameter, storage]) : ret => {
112
133
  };
113
134
  `;
114
135
 
115
-
116
- const $40622e3a438d0515$var$registerContract = (arg, contractName)=>{
117
- (0, $kQNfl$taquerianodesdk.experimental).registerContract(arg, contractName);
136
+ // createContract.ts
137
+ var getLigoTemplate = async (contractName, syntax) => {
138
+ const matchResult = contractName.match(/\.[^.]+$/);
139
+ const ext = matchResult ? matchResult[0].substring(1) : null;
140
+ if (syntax === "mligo")
141
+ return mligo_template;
142
+ if (syntax === "ligo")
143
+ return pascaligo_template;
144
+ if (syntax === "religo")
145
+ return religo_template;
146
+ if (syntax === "jsligo")
147
+ return jsligo_template;
148
+ if (syntax === void 0) {
149
+ if (ext === "mligo")
150
+ return mligo_template;
151
+ if (ext === "ligo")
152
+ return pascaligo_template;
153
+ if (ext === "religo")
154
+ return religo_template;
155
+ if (ext === "jsligo")
156
+ return jsligo_template;
157
+ return (0, import_node_sdk.sendAsyncErr)(
158
+ `Unable to infer LIGO syntax from "${contractName}". Please specify a LIGO syntax via the --syntax option`
159
+ );
160
+ } else {
161
+ return (0, import_node_sdk.sendAsyncErr)(`"${syntax}" is not a valid syntax. Please specify a valid LIGO syntax`);
162
+ }
118
163
  };
119
- const $40622e3a438d0515$var$getLigoTemplate = async (contractName, syntax)=>{
120
- const matchResult = contractName.match(/\.[^.]+$/);
121
- const ext = matchResult ? matchResult[0].substring(1) : null;
122
- if (syntax === "mligo") return 0, $9d8c61104c8e60ad$export$1336661d942c7074;
123
- if (syntax === "ligo") return 0, $9d8c61104c8e60ad$export$ec41334b92330d9b;
124
- if (syntax === "religo") return 0, $9d8c61104c8e60ad$export$9e59f1f7960689be;
125
- if (syntax === "jsligo") return 0, $9d8c61104c8e60ad$export$6d35abb7f92d1079;
126
- if (syntax === undefined) {
127
- if (ext === "mligo") return 0, $9d8c61104c8e60ad$export$1336661d942c7074;
128
- if (ext === "ligo") return 0, $9d8c61104c8e60ad$export$ec41334b92330d9b;
129
- if (ext === "religo") return 0, $9d8c61104c8e60ad$export$9e59f1f7960689be;
130
- if (ext === "jsligo") return 0, $9d8c61104c8e60ad$export$6d35abb7f92d1079;
131
- return (0, $kQNfl$taquerianodesdk.sendAsyncErr)(`Unable to infer LIGO syntax from "${contractName}". Please specify a LIGO syntax via the --syntax option`);
132
- } else return (0, $kQNfl$taquerianodesdk.sendAsyncErr)(`"${syntax}" is not a valid syntax. Please specify a valid LIGO syntax`);
164
+ var createContract = (args) => {
165
+ const unsafeOpts = args;
166
+ const contractName = unsafeOpts.sourceFileName;
167
+ const syntax = unsafeOpts.syntax;
168
+ const contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;
169
+ return getLigoTemplate(contractName, syntax).then((ligo_template) => (0, import_promises.writeFile)(`${contractsDir}/${contractName}`, ligo_template));
133
170
  };
134
- const $40622e3a438d0515$var$createContract = (args)=>{
135
- const unsafeOpts = args;
136
- const contractName = unsafeOpts.sourceFileName;
137
- const syntax = unsafeOpts.syntax;
138
- const contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;
139
- return $40622e3a438d0515$var$getLigoTemplate(contractName, syntax).then((ligo_template)=>(0, $kQNfl$fspromises.writeFile)(`${contractsDir}/${contractName}`, ligo_template)).then((_)=>$40622e3a438d0515$var$registerContract(unsafeOpts, contractName));
171
+ var createContract_default = createContract;
172
+
173
+ // main.ts
174
+ var import_node_sdk7 = require("@taqueria/node-sdk");
175
+
176
+ // common.ts
177
+ var import_node_sdk2 = require("@taqueria/node-sdk");
178
+ var import_path = require("path");
179
+ var LIGO_DEFAULT_IMAGE = "ligolang/ligo:0.57.0";
180
+ var LIGO_IMAGE_ENV_VAR = "TAQ_LIGO_IMAGE";
181
+ var getLigoDockerImage = () => (0, import_node_sdk2.getDockerImage)(LIGO_DEFAULT_IMAGE, LIGO_IMAGE_ENV_VAR);
182
+ var getInputFilenameAbsPath = (parsedArgs, sourceFile) => (0, import_path.join)(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? "contracts", sourceFile);
183
+ var getInputFilenameRelPath = (parsedArgs, sourceFile) => (0, import_path.join)(parsedArgs.config.contractsDir ?? "contracts", sourceFile);
184
+ var emitExternalError = (err, sourceFile) => {
185
+ (0, import_node_sdk2.sendErr)(`
186
+ === Error messages for ${sourceFile} ===`);
187
+ err instanceof Error ? (0, import_node_sdk2.sendErr)(err.message.replace(/Command failed.+?\n/, "")) : (0, import_node_sdk2.sendErr)(err);
188
+ (0, import_node_sdk2.sendErr)(`
189
+ ===`);
140
190
  };
141
- var $40622e3a438d0515$export$2e2bcd8739ae039 = $40622e3a438d0515$var$createContract;
142
-
143
-
144
-
145
-
146
191
 
147
- // Should point to the latest stable version, so it needs to be updated as part of our release process.
148
- const $844cb58d66fbf6db$var$LIGO_DEFAULT_IMAGE = "ligolang/ligo:0.54.1";
149
- const $844cb58d66fbf6db$var$LIGO_IMAGE_ENV_VAR = "TAQ_LIGO_IMAGE";
150
- const $844cb58d66fbf6db$export$2b403d61ac8ea302 = ()=>(0, $kQNfl$taquerianodesdk.getDockerImage)($844cb58d66fbf6db$var$LIGO_DEFAULT_IMAGE, $844cb58d66fbf6db$var$LIGO_IMAGE_ENV_VAR);
151
- const $844cb58d66fbf6db$export$17f107107c3c82c6 = (parsedArgs, sourceFile)=>(0, $kQNfl$path.join)(parsedArgs.config.contractsDir ?? "contracts", sourceFile);
152
- const $844cb58d66fbf6db$export$b59ff90dc389ce6d = (err, sourceFile)=>{
153
- (0, $kQNfl$taquerianodesdk.sendErr)(`\n=== Error messages for ${sourceFile} ===`);
154
- err instanceof Error ? (0, $kQNfl$taquerianodesdk.sendErr)(err.message.replace(/Command failed.+?\n/, "")) : (0, $kQNfl$taquerianodesdk.sendErr)(err);
155
- (0, $kQNfl$taquerianodesdk.sendErr)(`\n===`);
192
+ // compile.ts
193
+ var import_node_sdk3 = require("@taqueria/node-sdk");
194
+ var import_promises2 = require("fs/promises");
195
+ var import_path2 = require("path");
196
+ var COMPILE_ERR_MSG = "Not compiled";
197
+ var isStorageKind = (exprKind) => exprKind === "storage" || exprKind === "default_storage";
198
+ var isLIGOFile = (sourceFile) => /.+\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
199
+ var isStorageListFile = (sourceFile) => /.+\.(storageList|storages)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
200
+ var isParameterListFile = (sourceFile) => /.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
201
+ var isContractFile = (sourceFile) => isLIGOFile(sourceFile) && !isStorageListFile(sourceFile) && !isParameterListFile(sourceFile);
202
+ var extractExt = (path) => {
203
+ const matchResult = path.match(/\.(ligo|religo|mligo|jsligo)$/);
204
+ return matchResult ? matchResult[0] : "";
156
205
  };
157
-
158
-
159
-
160
-
161
-
162
-
163
- const $24b2f47d8f306cb3$var$COMPILE_ERR_MSG = "Not compiled";
164
- const $24b2f47d8f306cb3$var$isStorageKind = (exprKind)=>exprKind === "storage" || exprKind === "default_storage";
165
- const $24b2f47d8f306cb3$var$isLIGOFile = (sourceFile)=>/.+\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
166
- const $24b2f47d8f306cb3$var$isStorageListFile = (sourceFile)=>/.+\.(storageList|storages)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
167
- const $24b2f47d8f306cb3$var$isParameterListFile = (sourceFile)=>/.+\.(parameterList|parameters)\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);
168
- const $24b2f47d8f306cb3$var$isContractFile = (sourceFile)=>$24b2f47d8f306cb3$var$isLIGOFile(sourceFile) && !$24b2f47d8f306cb3$var$isStorageListFile(sourceFile) && !$24b2f47d8f306cb3$var$isParameterListFile(sourceFile);
169
- const $24b2f47d8f306cb3$var$extractExt = (path)=>{
170
- const matchResult = path.match(/\.(ligo|religo|mligo|jsligo)$/);
171
- return matchResult ? matchResult[0] : "";
206
+ var removeExt = (path) => {
207
+ const extRegex = new RegExp(extractExt(path));
208
+ return path.replace(extRegex, "");
172
209
  };
173
- const $24b2f47d8f306cb3$var$removeExt = (path)=>{
174
- const extRegex = new RegExp($24b2f47d8f306cb3$var$extractExt(path));
175
- return path.replace(extRegex, "");
210
+ var isOutputFormatJSON = (parsedArgs) => parsedArgs.json;
211
+ var getOutputContractFilename = (parsedArgs, sourceFile) => {
212
+ const outputFile = (0, import_path2.basename)(sourceFile, (0, import_path2.extname)(sourceFile));
213
+ const ext = isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
214
+ return (0, import_path2.join)((0, import_node_sdk3.getArtifactsDir)(parsedArgs), `${outputFile}${ext}`);
176
215
  };
177
- const $24b2f47d8f306cb3$var$isOutputFormatJSON = (parsedArgs)=>parsedArgs.json;
178
- const $24b2f47d8f306cb3$var$getOutputContractFilename = (parsedArgs, sourceFile)=>{
179
- const outputFile = (0, $kQNfl$path.basename)(sourceFile, (0, $kQNfl$path.extname)(sourceFile));
180
- const ext = $24b2f47d8f306cb3$var$isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
181
- return (0, $kQNfl$path.join)((0, $kQNfl$taquerianodesdk.getArtifactsDir)(parsedArgs), `${outputFile}${ext}`);
216
+ var getContractNameForExpr = (sourceFile, exprKind) => {
217
+ try {
218
+ return isStorageKind(exprKind) ? sourceFile.match(/.+(?=\.(?:storageList|storages)\.(ligo|religo|mligo|jsligo))/).join(".") : sourceFile.match(/.+(?=\.(?:parameterList|parameters)\.(ligo|religo|mligo|jsligo))/).join(".");
219
+ } catch (err) {
220
+ throw new Error(`Something went wrong internally when dealing with filename format: ${err}`);
221
+ }
182
222
  };
183
- // Get the contract name that the storage/parameter file is associated with
184
- // e.g. If sourceFile is token.storageList.mligo, then it'll return token.mligo
185
- const $24b2f47d8f306cb3$var$getContractNameForExpr = (sourceFile, exprKind)=>{
186
- try {
187
- return $24b2f47d8f306cb3$var$isStorageKind(exprKind) ? sourceFile.match(/.+(?=\.(?:storageList|storages)\.(ligo|religo|mligo|jsligo))/).join(".") : sourceFile.match(/.+(?=\.(?:parameterList|parameters)\.(ligo|religo|mligo|jsligo))/).join(".");
188
- } catch (err) {
189
- throw new Error(`Something went wrong internally when dealing with filename format: ${err}`);
190
- }
223
+ var getOutputExprFilename = (parsedArgs, sourceFile, exprKind, exprName) => {
224
+ const contractName = (0, import_path2.basename)(getContractNameForExpr(sourceFile, exprKind), (0, import_path2.extname)(sourceFile));
225
+ const ext = isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
226
+ const outputFile = exprKind === "default_storage" ? `${contractName}.default_storage${ext}` : `${contractName}.${exprKind}.${exprName}${ext}`;
227
+ return (0, import_path2.join)((0, import_node_sdk3.getArtifactsDir)(parsedArgs), `${outputFile}`);
228
+ };
229
+ var getCompileContractCmd = (parsedArgs, sourceFile) => {
230
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
231
+ if (!projectDir)
232
+ throw `No project directory provided`;
233
+ const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;
234
+ const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
235
+ const outputFile = `-o ${getOutputContractFilename(parsedArgs, sourceFile)}`;
236
+ const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
237
+ const cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}`;
238
+ return cmd;
191
239
  };
192
- // If sourceFile is token.storageList.mligo, then it'll return token.storage.{storageName}.tz
193
- const $24b2f47d8f306cb3$var$getOutputExprFilename = (parsedArgs, sourceFile, exprKind, exprName)=>{
194
- const contractName = (0, $kQNfl$path.basename)($24b2f47d8f306cb3$var$getContractNameForExpr(sourceFile, exprKind), (0, $kQNfl$path.extname)(sourceFile));
195
- const ext = $24b2f47d8f306cb3$var$isOutputFormatJSON(parsedArgs) ? ".json" : ".tz";
196
- const outputFile = exprKind === "default_storage" ? `${contractName}.default_storage${ext}` : `${contractName}.${exprKind}.${exprName}${ext}`;
197
- return (0, $kQNfl$path.join)((0, $kQNfl$taquerianodesdk.getArtifactsDir)(parsedArgs), `${outputFile}`);
240
+ var getCompileExprCmd = (parsedArgs, sourceFile, exprKind, exprName) => {
241
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
242
+ if (!projectDir)
243
+ throw `No project directory provided`;
244
+ const compilerType = isStorageKind(exprKind) ? "storage" : "parameter";
245
+ const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;
246
+ const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
247
+ const outputFile = `-o ${getOutputExprFilename(parsedArgs, sourceFile, exprKind, exprName)}`;
248
+ const flags = isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
249
+ const cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags}`;
250
+ return cmd;
198
251
  };
199
- const $24b2f47d8f306cb3$var$getCompileContractCmd = (parsedArgs, sourceFile)=>{
200
- const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
201
- if (!projectDir) throw `No project directory provided`;
202
- const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()} compile contract`;
203
- const inputFile = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile);
204
- const outputFile = `-o ${$24b2f47d8f306cb3$var$getOutputContractFilename(parsedArgs, sourceFile)}`;
205
- const flags = $24b2f47d8f306cb3$var$isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
206
- const cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}`;
207
- return cmd;
252
+ var compileContract = (parsedArgs, sourceFile) => (0, import_node_sdk3.getArch)().then(() => getCompileContractCmd(parsedArgs, sourceFile)).then(import_node_sdk3.execCmd).then(({ stderr }) => {
253
+ if (stderr.length > 0)
254
+ (0, import_node_sdk3.sendWarn)(stderr);
255
+ return {
256
+ contract: sourceFile,
257
+ artifact: getOutputContractFilename(parsedArgs, sourceFile)
258
+ };
259
+ }).catch((err) => {
260
+ emitExternalError(err, sourceFile);
261
+ return {
262
+ contract: sourceFile,
263
+ artifact: COMPILE_ERR_MSG
264
+ };
265
+ });
266
+ var compileExpr = (parsedArgs, sourceFile, exprKind) => (exprName) => (0, import_node_sdk3.getArch)().then(() => getCompileExprCmd(parsedArgs, sourceFile, exprKind, exprName)).then(import_node_sdk3.execCmd).then(({ stderr }) => {
267
+ if (stderr.length > 0)
268
+ (0, import_node_sdk3.sendWarn)(stderr);
269
+ return {
270
+ contract: sourceFile,
271
+ artifact: getOutputExprFilename(parsedArgs, sourceFile, exprKind, exprName)
272
+ };
273
+ }).catch((err) => {
274
+ emitExternalError(err, sourceFile);
275
+ return {
276
+ contract: sourceFile,
277
+ artifact: COMPILE_ERR_MSG
278
+ };
279
+ });
280
+ var getExprNames = (parsedArgs, sourceFile) => (0, import_promises2.readFile)(getInputFilenameAbsPath(parsedArgs, sourceFile), "utf8").then((data) => data.match(/(?<=\n\s*(let|const)\s+)[a-zA-Z0-9_]+/g) ?? []);
281
+ var compileExprs = (parsedArgs, sourceFile, exprKind) => getExprNames(parsedArgs, sourceFile).then((exprNames) => {
282
+ if (exprNames.length === 0)
283
+ return [];
284
+ const firstExprName = exprNames.slice(0, 1)[0];
285
+ const restExprNames = exprNames.slice(1, exprNames.length);
286
+ const firstExprKind = isStorageKind(exprKind) ? "default_storage" : "parameter";
287
+ const restExprKind = isStorageKind(exprKind) ? "storage" : "parameter";
288
+ const firstExprResult = compileExpr(parsedArgs, sourceFile, firstExprKind)(firstExprName);
289
+ const restExprResults = restExprNames.map(compileExpr(parsedArgs, sourceFile, restExprKind));
290
+ return Promise.all([firstExprResult].concat(restExprResults));
291
+ }).catch((err) => {
292
+ emitExternalError(err, sourceFile);
293
+ return [{
294
+ contract: sourceFile,
295
+ artifact: `No ${isStorageKind(exprKind) ? "storage" : "parameter"} values compiled`
296
+ }];
297
+ }).then(mergeArtifactsOutput(sourceFile));
298
+ var tryLegacyStorageNamingConvention = (parsedArgs, sourceFile) => {
299
+ const storageListFile = `${removeExt(sourceFile)}.storages${extractExt(sourceFile)}`;
300
+ const storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);
301
+ return (0, import_promises2.access)(storageListFilename).then(() => {
302
+ (0, import_node_sdk3.sendWarn)(
303
+ `Warning: The naming convention of "<CONTRACT>.storages.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.storageList.<EXTENSION>". Please adjust your storage file names accordingly
304
+ `
305
+ );
306
+ return compileExprs(parsedArgs, storageListFile, "storage");
307
+ });
208
308
  };
209
- const $24b2f47d8f306cb3$var$getCompileExprCmd = (parsedArgs, sourceFile, exprKind, exprName)=>{
210
- const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
211
- if (!projectDir) throw `No project directory provided`;
212
- const compilerType = $24b2f47d8f306cb3$var$isStorageKind(exprKind) ? "storage" : "parameter";
213
- const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()} compile ${compilerType}`;
214
- const inputFile = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile);
215
- const outputFile = `-o ${$24b2f47d8f306cb3$var$getOutputExprFilename(parsedArgs, sourceFile, exprKind, exprName)}`;
216
- const flags = $24b2f47d8f306cb3$var$isOutputFormatJSON(parsedArgs) ? " --michelson-format json " : "";
217
- const cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags}`;
218
- return cmd;
309
+ var tryLegacyParameterNamingConvention = (parsedArgs, sourceFile) => {
310
+ const parameterListFile = `${removeExt(sourceFile)}.parameters${extractExt(sourceFile)}`;
311
+ const parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);
312
+ return (0, import_promises2.access)(parameterListFilename).then(() => {
313
+ (0, import_node_sdk3.sendWarn)(
314
+ `Warning: The naming convention of "<CONTRACT>.parameters.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.parameterList.<EXTENSION>". Please adjust your parameter file names accordingly
315
+ `
316
+ );
317
+ return compileExprs(parsedArgs, parameterListFile, "parameter");
318
+ });
219
319
  };
220
- const $24b2f47d8f306cb3$var$compileContract = (parsedArgs, sourceFile)=>(0, $kQNfl$taquerianodesdk.getArch)().then(()=>$24b2f47d8f306cb3$var$getCompileContractCmd(parsedArgs, sourceFile)).then((0, $kQNfl$taquerianodesdk.execCmd)).then(({ stderr: stderr })=>{
221
- if (stderr.length > 0) (0, $kQNfl$taquerianodesdk.sendWarn)(stderr);
222
- return {
223
- contract: sourceFile,
224
- artifact: $24b2f47d8f306cb3$var$getOutputContractFilename(parsedArgs, sourceFile)
225
- };
226
- }).catch((err)=>{
227
- (0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
228
- return {
229
- contract: sourceFile,
230
- artifact: $24b2f47d8f306cb3$var$COMPILE_ERR_MSG
231
- };
232
- });
233
- const $24b2f47d8f306cb3$var$compileExpr = (parsedArgs, sourceFile, exprKind)=>(exprName)=>(0, $kQNfl$taquerianodesdk.getArch)().then(()=>$24b2f47d8f306cb3$var$getCompileExprCmd(parsedArgs, sourceFile, exprKind, exprName)).then((0, $kQNfl$taquerianodesdk.execCmd)).then(({ stderr: stderr })=>{
234
- if (stderr.length > 0) (0, $kQNfl$taquerianodesdk.sendWarn)(stderr);
235
- return {
236
- contract: sourceFile,
237
- artifact: $24b2f47d8f306cb3$var$getOutputExprFilename(parsedArgs, sourceFile, exprKind, exprName)
238
- };
239
- }).catch((err)=>{
240
- (0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
241
- return {
242
- contract: sourceFile,
243
- artifact: $24b2f47d8f306cb3$var$COMPILE_ERR_MSG
244
- };
245
- });
246
- const $24b2f47d8f306cb3$var$getExprNames = (parsedArgs, sourceFile)=>(0, $kQNfl$fspromises.readFile)((0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile), "utf8").then((data)=>data.match(/(?<=\n\s*(let|const)\s+)[a-zA-Z0-9_]+/g) ?? []);
247
- const $24b2f47d8f306cb3$var$compileExprs = (parsedArgs, sourceFile, exprKind)=>$24b2f47d8f306cb3$var$getExprNames(parsedArgs, sourceFile).then((exprNames)=>{
248
- if (exprNames.length === 0) return [];
249
- const firstExprName = exprNames.slice(0, 1)[0];
250
- const restExprNames = exprNames.slice(1, exprNames.length);
251
- const firstExprKind = $24b2f47d8f306cb3$var$isStorageKind(exprKind) ? "default_storage" : "parameter";
252
- const restExprKind = $24b2f47d8f306cb3$var$isStorageKind(exprKind) ? "storage" : "parameter";
253
- const firstExprResult = $24b2f47d8f306cb3$var$compileExpr(parsedArgs, sourceFile, firstExprKind)(firstExprName);
254
- const restExprResults = restExprNames.map($24b2f47d8f306cb3$var$compileExpr(parsedArgs, sourceFile, restExprKind));
255
- return Promise.all([
256
- firstExprResult
257
- ].concat(restExprResults));
258
- }).catch((err)=>{
259
- (0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
260
- return [
261
- {
262
- contract: sourceFile,
263
- artifact: `No ${$24b2f47d8f306cb3$var$isStorageKind(exprKind) ? "storage" : "parameter"} values compiled`
264
- }
265
- ];
266
- }).then($24b2f47d8f306cb3$var$mergeArtifactsOutput(sourceFile));
267
- // TODO: Just for backwards compatibility. Can be deleted in the future.
268
- const $24b2f47d8f306cb3$var$tryLegacyStorageNamingConvention = (parsedArgs, sourceFile)=>{
269
- const storageListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.storages${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
270
- const storageListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, storageListFile);
271
- return (0, $kQNfl$fspromises.access)(storageListFilename).then(()=>{
272
- (0, $kQNfl$taquerianodesdk.sendWarn)(`Warning: The naming convention of "<CONTRACT>.storages.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.storageList.<EXTENSION>". Please adjust your storage file names accordingly\n`);
273
- return $24b2f47d8f306cb3$var$compileExprs(parsedArgs, storageListFile, "storage");
274
- });
320
+ var initContentForStorage = (sourceFile) => {
321
+ const linkToContract = `#include "${sourceFile}"
322
+
323
+ `;
324
+ const instruction = "// Define your initial storage values as a list of LIGO variable definitions,\n// the first of which will be considered the default value to be used for origination later on\n";
325
+ const ext = extractExt(sourceFile);
326
+ let syntax = "";
327
+ if (ext === ".ligo")
328
+ syntax = "// E.g. const aStorageValue : aStorageType = 10;\n\n";
329
+ else if (ext === ".religo")
330
+ syntax = "// E.g. let aStorageValue : aStorageType = 10;\n\n";
331
+ else if (ext === ".mligo")
332
+ syntax = "// E.g. let aStorageValue : aStorageType = 10\n\n";
333
+ else if (ext === ".jsligo")
334
+ syntax = "// E.g. const aStorageValue : aStorageType = 10;\n\n";
335
+ return linkToContract + instruction + syntax;
275
336
  };
276
- // TODO: Just for backwards compatibility. Can be deleted in the future.
277
- const $24b2f47d8f306cb3$var$tryLegacyParameterNamingConvention = (parsedArgs, sourceFile)=>{
278
- const parameterListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.parameters${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
279
- const parameterListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, parameterListFile);
280
- return (0, $kQNfl$fspromises.access)(parameterListFilename).then(()=>{
281
- (0, $kQNfl$taquerianodesdk.sendWarn)(`Warning: The naming convention of "<CONTRACT>.parameters.<EXTENSION>" is deprecated and renamed to "<CONTRACT>.parameterList.<EXTENSION>". Please adjust your parameter file names accordingly\n`);
282
- return $24b2f47d8f306cb3$var$compileExprs(parsedArgs, parameterListFile, "parameter");
283
- });
337
+ var initContentForParameter = (sourceFile) => {
338
+ const linkToContract = `#include "${sourceFile}"
339
+
340
+ `;
341
+ const instruction = "// Define your parameter values as a list of LIGO variable definitions\n";
342
+ const ext = extractExt(sourceFile);
343
+ let syntax = "";
344
+ if (ext === ".ligo")
345
+ syntax = "// E.g. const aParameterValue : aParameterType = Increment(1);\n\n";
346
+ else if (ext === ".religo")
347
+ syntax = "// E.g. let aParameterValue : aParameterType = (Increment (1));\n\n";
348
+ else if (ext === ".mligo")
349
+ syntax = "// E.g. let aParameterValue : aParameterType = Increment 1\n\n";
350
+ else if (ext === ".jsligo")
351
+ syntax = "// E.g. const aParameterValue : aParameterType = (Increment (1));\n\n";
352
+ return linkToContract + instruction + syntax;
284
353
  };
285
- const $24b2f47d8f306cb3$var$initContentForStorage = (sourceFile)=>{
286
- const linkToContract = `#include "${sourceFile}"\n\n`;
287
- const instruction = "// Define your initial storage values as a list of LIGO variable definitions,\n// the first of which will be considered the default value to be used for origination later on\n";
288
- const ext = $24b2f47d8f306cb3$var$extractExt(sourceFile);
289
- let syntax = "";
290
- if (ext === ".ligo") syntax = "// E.g. const aStorageValue : aStorageType = 10;\n\n";
291
- else if (ext === ".religo") syntax = "// E.g. let aStorageValue : aStorageType = 10;\n\n";
292
- else if (ext === ".mligo") syntax = "// E.g. let aStorageValue : aStorageType = 10\n\n";
293
- else if (ext === ".jsligo") syntax = "// E.g. const aStorageValue : aStorageType = 10;\n\n";
294
- return linkToContract + instruction + syntax;
354
+ var compileContractWithStorageAndParameter = async (parsedArgs, sourceFile) => {
355
+ const contractCompileResult = await compileContract(parsedArgs, sourceFile);
356
+ if (contractCompileResult.artifact === COMPILE_ERR_MSG)
357
+ return [contractCompileResult];
358
+ const storageListFile = `${removeExt(sourceFile)}.storageList${extractExt(sourceFile)}`;
359
+ const storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);
360
+ const storageCompileResult = await (0, import_promises2.access)(storageListFilename).then(() => compileExprs(parsedArgs, storageListFile, "storage")).catch(() => tryLegacyStorageNamingConvention(parsedArgs, sourceFile)).catch(() => {
361
+ (0, import_node_sdk3.sendWarn)(
362
+ `Note: storage file associated with "${sourceFile}" can't be found, so "${storageListFile}" has been created for you. Use this file to define all initial storage values for this contract
363
+ `
364
+ );
365
+ (0, import_promises2.writeFile)(storageListFilename, initContentForStorage(sourceFile), "utf8");
366
+ });
367
+ const parameterListFile = `${removeExt(sourceFile)}.parameterList${extractExt(sourceFile)}`;
368
+ const parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);
369
+ const parameterCompileResult = await (0, import_promises2.access)(parameterListFilename).then(() => compileExprs(parsedArgs, parameterListFile, "parameter")).catch(() => tryLegacyParameterNamingConvention(parsedArgs, sourceFile)).catch(() => {
370
+ (0, import_node_sdk3.sendWarn)(
371
+ `Note: parameter file associated with "${sourceFile}" can't be found, so "${parameterListFile}" has been created for you. Use this file to define all parameter values for this contract
372
+ `
373
+ );
374
+ (0, import_promises2.writeFile)(parameterListFilename, initContentForParameter(sourceFile), "utf8");
375
+ });
376
+ let compileResults = [contractCompileResult];
377
+ if (storageCompileResult)
378
+ compileResults = compileResults.concat(storageCompileResult);
379
+ if (parameterCompileResult)
380
+ compileResults = compileResults.concat(parameterCompileResult);
381
+ return compileResults;
295
382
  };
296
- const $24b2f47d8f306cb3$var$initContentForParameter = (sourceFile)=>{
297
- const linkToContract = `#include "${sourceFile}"\n\n`;
298
- const instruction = "// Define your parameter values as a list of LIGO variable definitions\n";
299
- const ext = $24b2f47d8f306cb3$var$extractExt(sourceFile);
300
- let syntax = "";
301
- if (ext === ".ligo") syntax = "// E.g. const aParameterValue : aParameterType = Increment(1);\n\n";
302
- else if (ext === ".religo") syntax = "// E.g. let aParameterValue : aParameterType = (Increment (1));\n\n";
303
- else if (ext === ".mligo") syntax = "// E.g. let aParameterValue : aParameterType = Increment 1\n\n";
304
- else if (ext === ".jsligo") syntax = "// E.g. const aParameterValue : aParameterType = (Increment (1));\n\n";
305
- return linkToContract + instruction + syntax;
383
+ var mergeArtifactsOutput = (sourceFile) => (tableRows) => {
384
+ const artifactsOutput = tableRows.reduce(
385
+ (acc, row) => row.artifact === COMPILE_ERR_MSG ? acc : `${acc}${row.artifact}
386
+ `,
387
+ ""
388
+ );
389
+ return [{
390
+ contract: sourceFile,
391
+ artifact: artifactsOutput
392
+ }];
306
393
  };
307
- const $24b2f47d8f306cb3$var$compileContractWithStorageAndParameter = async (parsedArgs, sourceFile)=>{
308
- const contractCompileResult = await $24b2f47d8f306cb3$var$compileContract(parsedArgs, sourceFile);
309
- if (contractCompileResult.artifact === $24b2f47d8f306cb3$var$COMPILE_ERR_MSG) return [
310
- contractCompileResult
311
- ];
312
- const storageListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.storageList${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
313
- const storageListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, storageListFile);
314
- const storageCompileResult = await (0, $kQNfl$fspromises.access)(storageListFilename).then(()=>$24b2f47d8f306cb3$var$compileExprs(parsedArgs, storageListFile, "storage")).catch(()=>$24b2f47d8f306cb3$var$tryLegacyStorageNamingConvention(parsedArgs, sourceFile)).catch(()=>{
315
- (0, $kQNfl$taquerianodesdk.sendWarn)(`Note: storage file associated with "${sourceFile}" can't be found, so "${storageListFile}" has been created for you. Use this file to define all initial storage values for this contract\n`);
316
- (0, $kQNfl$fspromises.writeFile)(storageListFilename, $24b2f47d8f306cb3$var$initContentForStorage(sourceFile), "utf8");
317
- });
318
- const parameterListFile = `${$24b2f47d8f306cb3$var$removeExt(sourceFile)}.parameterList${$24b2f47d8f306cb3$var$extractExt(sourceFile)}`;
319
- const parameterListFilename = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, parameterListFile);
320
- const parameterCompileResult = await (0, $kQNfl$fspromises.access)(parameterListFilename).then(()=>$24b2f47d8f306cb3$var$compileExprs(parsedArgs, parameterListFile, "parameter")).catch(()=>$24b2f47d8f306cb3$var$tryLegacyParameterNamingConvention(parsedArgs, sourceFile)).catch(()=>{
321
- (0, $kQNfl$taquerianodesdk.sendWarn)(`Note: parameter file associated with "${sourceFile}" can't be found, so "${parameterListFile}" has been created for you. Use this file to define all parameter values for this contract\n`);
322
- (0, $kQNfl$fspromises.writeFile)(parameterListFilename, $24b2f47d8f306cb3$var$initContentForParameter(sourceFile), "utf8");
323
- });
324
- let compileResults = [
325
- contractCompileResult
326
- ];
327
- if (storageCompileResult) compileResults = compileResults.concat(storageCompileResult);
328
- if (parameterCompileResult) compileResults = compileResults.concat(parameterCompileResult);
329
- return compileResults;
394
+ var compile = (parsedArgs) => {
395
+ const sourceFile = parsedArgs.sourceFile;
396
+ let p;
397
+ if (isStorageListFile(sourceFile))
398
+ p = compileExprs(parsedArgs, sourceFile, "storage");
399
+ else if (isParameterListFile(sourceFile))
400
+ p = compileExprs(parsedArgs, sourceFile, "parameter");
401
+ else if (isContractFile(sourceFile))
402
+ p = compileContractWithStorageAndParameter(parsedArgs, sourceFile);
403
+ else {
404
+ return (0, import_node_sdk3.sendAsyncErr)(
405
+ `${sourceFile} doesn't have a valid LIGO extension ('.ligo', '.religo', '.mligo' or '.jsligo')`
406
+ );
407
+ }
408
+ return p.then(import_node_sdk3.sendJsonRes).catch((err) => (0, import_node_sdk3.sendErr)(err, false));
330
409
  };
331
- /*
332
- Compiling storage/parameter file amounts to compiling multiple expressions in that file,
333
- resulting in multiple rows with the same file name but different artifact names.
334
- This will merge these rows into one row with just one mention of the file name.
335
- e.g.
336
- ┌─────────────────────────┬─────────────────────────────────────────────┐
337
- Contract │ Artifact │
338
- ├─────────────────────────┼─────────────────────────────────────────────┤
339
- hello.storageList.mligo artifacts/hello.default_storage.storage1.tz
340
- ├─────────────────────────┼─────────────────────────────────────────────┤
341
- hello.storageList.mligo artifacts/hello.storage.storage2.tz │
342
- └─────────────────────────┴─────────────────────────────────────────────┘
343
- versus
344
- ┌─────────────────────────┬─────────────────────────────────────────────┐
345
- Contract │ Artifact │
346
- ├─────────────────────────┼─────────────────────────────────────────────┤
347
- │ hello.storageList.mligo │ artifacts/hello.default_storage.storage1.tz │
348
- │ │ artifacts/hello.storage.storage2.tz │
349
- └─────────────────────────┴─────────────────────────────────────────────┘
350
- */ const $24b2f47d8f306cb3$var$mergeArtifactsOutput = (sourceFile)=>(tableRows)=>{
351
- const artifactsOutput = tableRows.reduce((acc, row)=>row.artifact === $24b2f47d8f306cb3$var$COMPILE_ERR_MSG ? acc : `${acc}${row.artifact}\n`, "");
352
- return [
353
- {
354
- contract: sourceFile,
355
- artifact: artifactsOutput
356
- }
357
- ];
358
- };
359
- const $24b2f47d8f306cb3$var$compile = (parsedArgs)=>{
360
- const sourceFile = parsedArgs.sourceFile;
361
- let p;
362
- if ($24b2f47d8f306cb3$var$isStorageListFile(sourceFile)) p = $24b2f47d8f306cb3$var$compileExprs(parsedArgs, sourceFile, "storage");
363
- else if ($24b2f47d8f306cb3$var$isParameterListFile(sourceFile)) p = $24b2f47d8f306cb3$var$compileExprs(parsedArgs, sourceFile, "parameter");
364
- else if ($24b2f47d8f306cb3$var$isContractFile(sourceFile)) p = $24b2f47d8f306cb3$var$compileContractWithStorageAndParameter(parsedArgs, sourceFile);
365
- else return (0, $kQNfl$taquerianodesdk.sendAsyncErr)(`${sourceFile} doesn't have a valid LIGO extension ('.ligo', '.religo', '.mligo' or '.jsligo')`);
366
- return p.then((0, $kQNfl$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $kQNfl$taquerianodesdk.sendAsyncErr)(err, false));
410
+ var compile_default = compile;
411
+
412
+ // compile-all.ts
413
+ var import_node_sdk4 = require("@taqueria/node-sdk");
414
+ var import_fast_glob = __toESM(require("fast-glob"));
415
+ var import_promises3 = require("fs/promises");
416
+ var import_path3 = require("path");
417
+ var isMainContract = (parsedArgs, contactFilename) => (0, import_promises3.readFile)(getInputFilenameAbsPath(parsedArgs, contactFilename), "utf8").then((data) => /(const|let|function)\s+main/.test(data));
418
+ var compileAll = async (parsedArgs) => {
419
+ let p = [];
420
+ const contractFilenames = await (0, import_fast_glob.default)(
421
+ ["**/*.ligo", "**/*.religo", "**/*.mligo", "**/*.jsligo"],
422
+ { cwd: (0, import_path3.join)(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? "contracts"), absolute: false }
423
+ );
424
+ for (const filename of contractFilenames) {
425
+ if (await isMainContract(parsedArgs, filename)) {
426
+ p.push(compileContractWithStorageAndParameter(parsedArgs, filename));
427
+ }
428
+ }
429
+ return Promise.all(p).then((tables) => tables.flat()).then(import_node_sdk4.sendJsonRes).catch((err) => (0, import_node_sdk4.sendErr)(err, false));
367
430
  };
368
- var $24b2f47d8f306cb3$export$2e2bcd8739ae039 = $24b2f47d8f306cb3$var$compile;
369
-
370
-
371
-
372
-
373
- const $0be740342372c80a$var$getArbitraryLigoCmd = (parsedArgs, userArgs)=>{
374
- const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
375
- if (!projectDir) throw `No project directory provided`;
376
- const binary = "docker";
377
- const baseArgs = [
378
- "run",
379
- "--rm",
380
- "-v",
381
- `${projectDir}:/project`,
382
- "-w",
383
- "/project",
384
- (0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()
385
- ];
386
- const processedUserArgs = userArgs.split(" ").map((arg)=>arg.startsWith("\\-") ? arg.substring(1) : arg).filter((arg)=>arg);
387
- const args = baseArgs.concat(processedUserArgs);
388
- const envVars = {
389
- "DOCKER_DEFAULT_PLATFORM": "linux/amd64"
390
- };
391
- return [
392
- binary,
393
- args,
394
- envVars
395
- ];
431
+ var compile_all_default = compileAll;
432
+
433
+ // ligo.ts
434
+ var import_node_sdk5 = require("@taqueria/node-sdk");
435
+ var getArbitraryLigoCmd = (parsedArgs, userArgs) => {
436
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
437
+ if (!projectDir)
438
+ throw `No project directory provided`;
439
+ const binary = "docker";
440
+ const baseArgs = ["run", "--rm", "-v", `${projectDir}:/project`, "-w", "/project", getLigoDockerImage()];
441
+ const processedUserArgs = userArgs.split(" ").map((arg) => arg.startsWith("\\-") ? arg.substring(1) : arg).filter(
442
+ (arg) => arg
443
+ );
444
+ const args = baseArgs.concat(processedUserArgs);
445
+ const envVars = { "DOCKER_DEFAULT_PLATFORM": "linux/amd64" };
446
+ return [
447
+ [binary, ...args].join(" "),
448
+ envVars
449
+ ];
396
450
  };
397
- const $0be740342372c80a$var$runArbitraryLigoCmd = (parsedArgs, cmd)=>(0, $kQNfl$taquerianodesdk.getArch)().then(()=>$0be740342372c80a$var$getArbitraryLigoCmd(parsedArgs, cmd)).then((0, $kQNfl$taquerianodesdk.spawnCmd)).then((code)=>code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`).catch((err)=>(0, $kQNfl$taquerianodesdk.sendAsyncErr)(`An internal error has occurred: ${err.message}`));
398
- const $0be740342372c80a$var$ligo = (parsedArgs)=>{
399
- const args = parsedArgs.command;
400
- return $0be740342372c80a$var$runArbitraryLigoCmd(parsedArgs, args).then((0, $kQNfl$taquerianodesdk.sendRes)).catch((err)=>(0, $kQNfl$taquerianodesdk.sendAsyncErr)(err, false));
451
+ var runArbitraryLigoCmd = (parsedArgs, cmd) => (0, import_node_sdk5.getArch)().then(() => getArbitraryLigoCmd(parsedArgs, cmd)).then(([cmd2, envVars]) => (0, import_node_sdk5.spawnCmd)(cmd2, envVars)).then(
452
+ (code) => code !== null && code === 0 ? `Command "${cmd}" ran successfully by LIGO` : `Command "${cmd}" failed. Please check your command`
453
+ ).catch((err) => (0, import_node_sdk5.sendAsyncErr)(`An internal error has occurred: ${err.message}`));
454
+ var ligo = (parsedArgs) => {
455
+ const args = parsedArgs.command;
456
+ return runArbitraryLigoCmd(parsedArgs, args).then(import_node_sdk5.sendRes).catch((err) => (0, import_node_sdk5.sendAsyncErr)(err, false));
401
457
  };
402
- var $0be740342372c80a$export$2e2bcd8739ae039 = $0be740342372c80a$var$ligo;
403
-
404
-
405
-
406
-
407
- const $8d09eb70c0505719$var$getTestContractCmd = (parsedArgs, sourceFile)=>{
408
- const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
409
- if (!projectDir) throw `No project directory provided`;
410
- const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${(0, $844cb58d66fbf6db$export$2b403d61ac8ea302)()} run test`;
411
- const inputFile = (0, $844cb58d66fbf6db$export$17f107107c3c82c6)(parsedArgs, sourceFile);
412
- const cmd = `${baseCmd} ${inputFile}`;
413
- return cmd;
458
+ var ligo_default = ligo;
459
+
460
+ // test.ts
461
+ var import_node_sdk6 = require("@taqueria/node-sdk");
462
+ var getTestContractCmd = (parsedArgs, sourceFile) => {
463
+ const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
464
+ if (!projectDir)
465
+ throw `No project directory provided`;
466
+ const baseCmd = `DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v "${projectDir}":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;
467
+ const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
468
+ const cmd = `${baseCmd} ${inputFile}`;
469
+ return cmd;
414
470
  };
415
- const $8d09eb70c0505719$var$testContract = (parsedArgs, sourceFile)=>(0, $kQNfl$taquerianodesdk.getArch)().then(()=>$8d09eb70c0505719$var$getTestContractCmd(parsedArgs, sourceFile)).then((0, $kQNfl$taquerianodesdk.execCmd)).then(({ stdout: stdout , stderr: stderr })=>{
416
- if (stderr.length > 0) (0, $kQNfl$taquerianodesdk.sendWarn)(stderr);
417
- const result = "\uD83C\uDF89 All tests passed \uD83C\uDF89";
418
- return {
419
- contract: sourceFile,
420
- testResults: stdout.length > 0 ? `${stdout}\n${result}` : result
421
- };
422
- }).catch((err)=>{
423
- (0, $844cb58d66fbf6db$export$b59ff90dc389ce6d)(err, sourceFile);
424
- return {
425
- contract: sourceFile,
426
- testResults: "Some tests failed :("
427
- };
428
- });
429
- const $8d09eb70c0505719$var$test = (parsedArgs)=>{
430
- const sourceFile = parsedArgs.sourceFile;
431
- if (!sourceFile) return (0, $kQNfl$taquerianodesdk.sendAsyncErr)(`No source file provided`);
432
- return $8d09eb70c0505719$var$testContract(parsedArgs, sourceFile).then((result)=>[
433
- result
434
- ]).then((0, $kQNfl$taquerianodesdk.sendJsonRes)).catch((err)=>(0, $kQNfl$taquerianodesdk.sendAsyncErr)(err, false));
471
+ var testContract = (parsedArgs, sourceFile) => (0, import_node_sdk6.getArch)().then(() => getTestContractCmd(parsedArgs, sourceFile)).then(import_node_sdk6.execCmd).then(({ stdout, stderr }) => {
472
+ if (stderr.length > 0)
473
+ (0, import_node_sdk6.sendWarn)(stderr);
474
+ const result = "\u{1F389} All tests passed \u{1F389}";
475
+ return {
476
+ contract: sourceFile,
477
+ testResults: stdout.length > 0 ? `${stdout}
478
+ ${result}` : result
479
+ };
480
+ }).catch((err) => {
481
+ emitExternalError(err, sourceFile);
482
+ return {
483
+ contract: sourceFile,
484
+ testResults: "Some tests failed :("
485
+ };
486
+ });
487
+ var test = (parsedArgs) => {
488
+ const sourceFile = parsedArgs.sourceFile;
489
+ if (!sourceFile)
490
+ return (0, import_node_sdk6.sendAsyncErr)(`No source file provided`);
491
+ return testContract(parsedArgs, sourceFile).then((result) => [result]).then(import_node_sdk6.sendJsonRes).catch(
492
+ (err) => (0, import_node_sdk6.sendAsyncErr)(err, false)
493
+ );
435
494
  };
436
- var $8d09eb70c0505719$export$2e2bcd8739ae039 = $8d09eb70c0505719$var$test;
437
-
438
-
439
- const $9c25a106900e330c$var$main = (parsedArgs)=>{
440
- const unsafeOpts = parsedArgs;
441
- switch(unsafeOpts.task){
442
- case "ligo":
443
- return (0, $0be740342372c80a$export$2e2bcd8739ae039)(unsafeOpts);
444
- case "compile":
445
- return (0, $24b2f47d8f306cb3$export$2e2bcd8739ae039)(unsafeOpts);
446
- case "test":
447
- return (0, $8d09eb70c0505719$export$2e2bcd8739ae039)(parsedArgs);
448
- case "get-image":
449
- return (0, $kQNfl$taquerianodesdk.sendAsyncRes)((0, $844cb58d66fbf6db$export$2b403d61ac8ea302)());
450
- default:
451
- return (0, $kQNfl$taquerianodesdk.sendAsyncErr)(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);
452
- }
495
+ var test_default = test;
496
+
497
+ // main.ts
498
+ var main = (parsedArgs) => {
499
+ const unsafeOpts = parsedArgs;
500
+ switch (unsafeOpts.task) {
501
+ case "ligo":
502
+ return ligo_default(unsafeOpts);
503
+ case "compile":
504
+ return compile_default(unsafeOpts);
505
+ case "compile-all":
506
+ return compile_all_default(unsafeOpts);
507
+ case "test":
508
+ return test_default(parsedArgs);
509
+ case "get-image":
510
+ return (0, import_node_sdk7.sendAsyncRes)(getLigoDockerImage());
511
+ default:
512
+ return (0, import_node_sdk7.sendAsyncErr)(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);
513
+ }
453
514
  };
454
- var $9c25a106900e330c$export$2e2bcd8739ae039 = $9c25a106900e330c$var$main;
455
-
456
-
457
- (0, $kQNfl$taquerianodesdk.Plugin).create((i18n)=>({
458
- schema: "1.0",
459
- version: "0.1",
460
- alias: "ligo",
461
- tasks: [
462
- (0, $kQNfl$taquerianodesdk.Task).create({
463
- task: "ligo",
464
- command: "ligo",
465
- description: "This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria",
466
- options: [
467
- (0, $kQNfl$taquerianodesdk.Option).create({
468
- shortFlag: "c",
469
- flag: "command",
470
- type: "string",
471
- description: "The command to be passed to the underlying LIGO binary, wrapped in quotes",
472
- required: true
473
- })
474
- ],
475
- handler: "proxy",
476
- encoding: "none"
477
- }),
478
- (0, $kQNfl$taquerianodesdk.Task).create({
479
- task: "compile",
480
- command: "compile <sourceFile>",
481
- aliases: [
482
- "c",
483
- "compile-ligo"
484
- ],
485
- 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",
486
- options: [
487
- (0, $kQNfl$taquerianodesdk.Option).create({
488
- flag: "json",
489
- boolean: true,
490
- description: "Emit JSON-encoded Michelson"
491
- })
492
- ],
493
- handler: "proxy",
494
- encoding: "json"
495
- }),
496
- (0, $kQNfl$taquerianodesdk.Task).create({
497
- task: "test",
498
- command: "test <sourceFile>",
499
- description: "Test a smart contract written in LIGO",
500
- handler: "proxy",
501
- encoding: "json"
502
- }),
503
- (0, $kQNfl$taquerianodesdk.Task).create({
504
- task: "get-image",
505
- command: "get-image",
506
- description: "Gets the name of the image to be used",
507
- handler: "proxy",
508
- hidden: true
509
- })
510
- ],
511
- templates: [
512
- (0, $kQNfl$taquerianodesdk.Template).create({
513
- template: "contract",
514
- command: "contract <sourceFileName>",
515
- description: "Create a LIGO contract with boilerplate code",
516
- positionals: [
517
- (0, $kQNfl$taquerianodesdk.PositionalArg).create({
518
- placeholder: "sourceFileName",
519
- type: "string",
520
- description: "The name of the LIGO contract to generate"
521
- })
522
- ],
523
- options: [
524
- (0, $kQNfl$taquerianodesdk.Option).create({
525
- shortFlag: "s",
526
- flag: "syntax",
527
- type: "string",
528
- description: "The syntax used in the contract"
529
- })
530
- ],
531
- handler: (0, $40622e3a438d0515$export$2e2bcd8739ae039)
532
- })
533
- ],
534
- proxy: (0, $9c25a106900e330c$export$2e2bcd8739ae039)
535
- }), process.argv);
536
-
537
-
538
- //# sourceMappingURL=index.js.map
515
+ var main_default = main;
516
+
517
+ // index.ts
518
+ import_node_sdk8.Plugin.create((i18n) => ({
519
+ schema: "1.0",
520
+ version: "0.1",
521
+ alias: "ligo",
522
+ tasks: [
523
+ import_node_sdk8.Task.create({
524
+ task: "ligo",
525
+ command: "ligo",
526
+ description: "This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria",
527
+ options: [
528
+ import_node_sdk8.Option.create({
529
+ shortFlag: "c",
530
+ flag: "command",
531
+ type: "string",
532
+ description: "The command to be passed to the underlying LIGO binary, wrapped in quotes",
533
+ required: true
534
+ })
535
+ ],
536
+ handler: "proxy",
537
+ encoding: "none"
538
+ }),
539
+ import_node_sdk8.Task.create({
540
+ task: "compile",
541
+ command: "compile <sourceFile>",
542
+ aliases: ["c", "compile-ligo"],
543
+ 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",
544
+ options: [
545
+ import_node_sdk8.Option.create({
546
+ flag: "json",
547
+ boolean: true,
548
+ description: "Emit JSON-encoded Michelson"
549
+ })
550
+ ],
551
+ handler: "proxy",
552
+ encoding: "json"
553
+ }),
554
+ import_node_sdk8.Task.create({
555
+ task: "compile-all",
556
+ command: "compile-all",
557
+ 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",
558
+ options: [
559
+ import_node_sdk8.Option.create({
560
+ flag: "json",
561
+ boolean: true,
562
+ description: "Emit JSON-encoded Michelson"
563
+ })
564
+ ],
565
+ handler: "proxy",
566
+ encoding: "json"
567
+ }),
568
+ import_node_sdk8.Task.create({
569
+ task: "test",
570
+ command: "test <sourceFile>",
571
+ description: "Test a smart contract written in LIGO",
572
+ handler: "proxy",
573
+ encoding: "json"
574
+ }),
575
+ import_node_sdk8.Task.create({
576
+ task: "get-image",
577
+ command: "get-image",
578
+ description: "Gets the name of the image to be used",
579
+ handler: "proxy",
580
+ hidden: true
581
+ })
582
+ ],
583
+ templates: [
584
+ import_node_sdk8.Template.create({
585
+ template: "contract",
586
+ command: "contract <sourceFileName>",
587
+ description: "Create a LIGO contract with boilerplate code",
588
+ positionals: [
589
+ import_node_sdk8.PositionalArg.create({
590
+ placeholder: "sourceFileName",
591
+ type: "string",
592
+ description: "The name of the LIGO contract to generate"
593
+ })
594
+ ],
595
+ options: [
596
+ import_node_sdk8.Option.create({
597
+ shortFlag: "s",
598
+ flag: "syntax",
599
+ type: "string",
600
+ description: "The syntax used in the contract"
601
+ })
602
+ ],
603
+ handler: createContract_default
604
+ })
605
+ ],
606
+ proxy: main_default
607
+ }), process.argv);
608
+ //# sourceMappingURL=index.js.map