@taqueria/plugin-ligo 0.0.9 → 0.2.0
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/compile.js +23 -23
- package/index.js +2 -1
- package/package.json +2 -2
package/compile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {execCmd, getArch} = require('@taqueria/node-sdk')
|
|
1
|
+
const {execCmd, getArch, sendAsyncErr, sendJsonRes, sendErr} = require('@taqueria/node-sdk')
|
|
2
2
|
const {extname, basename, join} = require('path')
|
|
3
3
|
const glob = require('fast-glob')
|
|
4
4
|
|
|
@@ -22,21 +22,25 @@ const getCompileCommand = (opts, _arch) => (sourceFile) => {
|
|
|
22
22
|
return cmd
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const getLigoCompilationError = (stderr) => {
|
|
26
|
-
const err = stderr.split("\n").slice(1).join("\n")
|
|
27
|
-
return `There was a compilation error.\n\n${err}`
|
|
28
|
-
}
|
|
29
|
-
|
|
30
25
|
const compileContract = (opts) => (sourceFile) =>
|
|
31
26
|
getArch()
|
|
32
27
|
.then(arch => getCompileCommand(opts, arch) (sourceFile))
|
|
33
28
|
.then(execCmd)
|
|
34
|
-
.then(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
.then(({stderr}) => { // How should we output warnings?
|
|
30
|
+
if (stderr.length > 0) sendErr(stderr)
|
|
31
|
+
return {
|
|
32
|
+
contract: sourceFile,
|
|
33
|
+
artifact: getContractArtifactFilename(opts) (sourceFile)
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
.catch(err => {
|
|
37
|
+
sendErr(" ")
|
|
38
|
+
sendErr(err.message.split("\n").slice(1).join("\n"))
|
|
39
|
+
return Promise.resolve({
|
|
40
|
+
contract: sourceFile,
|
|
41
|
+
artifact: "Not compiled"
|
|
42
|
+
})
|
|
43
|
+
})
|
|
40
44
|
|
|
41
45
|
const compileAll = parsedArgs => {
|
|
42
46
|
// TODO: Fetch list of files from SDK
|
|
@@ -44,7 +48,7 @@ const compileAll = parsedArgs => {
|
|
|
44
48
|
['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],
|
|
45
49
|
{cwd: parsedArgs.contractsDir, absolute: false}
|
|
46
50
|
)
|
|
47
|
-
.then(entries => entries.map(compileContract(parsedArgs)))
|
|
51
|
+
.then(entries => entries.map(sourceFile => compileContract(parsedArgs) (sourceFile)))
|
|
48
52
|
.then(processes => processes.length > 0
|
|
49
53
|
? processes
|
|
50
54
|
: [{contract: "None found", artifact: "N/A"}]
|
|
@@ -57,18 +61,14 @@ const compile = parsedArgs => {
|
|
|
57
61
|
? compileContract(parsedArgs) (parsedArgs.sourceFile)
|
|
58
62
|
.then(result => [result])
|
|
59
63
|
: compileAll(parsedArgs)
|
|
64
|
+
.then(results => {
|
|
65
|
+
if (results.length === 0) sendErr("No contracts found to compile.")
|
|
66
|
+
return results
|
|
67
|
+
})
|
|
60
68
|
|
|
61
69
|
return p
|
|
62
|
-
.then(
|
|
63
|
-
|
|
64
|
-
stdout: results,
|
|
65
|
-
stderr: "",
|
|
66
|
-
render: 'table'
|
|
67
|
-
}))
|
|
68
|
-
.catch(err => err.errCode
|
|
69
|
-
? Promise.resolve({status: 'failed', stdout: '', stderr: err.errMsg, previous: err})
|
|
70
|
-
: Promise.resolve({status: 'failed', stderr: err.getMessage(), stdout: '', previous: err})
|
|
71
|
-
)
|
|
70
|
+
.then(sendJsonRes)
|
|
71
|
+
.catch(err => sendAsyncErr(err, false))
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
module.exports = compile
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-ligo",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A taqueria plugin for compiling LIGO smart contracts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"homepage": "https://github.com/ecadlabs/taqueria#readme",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"fast-glob": "^3.2.7",
|
|
37
|
-
"@taqueria/node-sdk": "^0.0
|
|
37
|
+
"@taqueria/node-sdk": "^0.2.0"
|
|
38
38
|
}
|
|
39
39
|
}
|