@taqueria/plugin-ligo 0.0.1 → 0.0.4
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 +22 -3
- package/package.json +3 -15
package/compile.js
CHANGED
|
@@ -2,7 +2,6 @@ const {execCmd, getArch} = require('@taqueria/node-sdk')
|
|
|
2
2
|
const {extname, basename, join} = require('path')
|
|
3
3
|
const glob = require('fast-glob')
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
const getContractArtifactFilename = (opts) => (sourceFile) => {
|
|
7
6
|
const outFile = basename(sourceFile, extname(sourceFile))
|
|
8
7
|
return join(opts.config.artifactsDir, `${outFile}.tz`)
|
|
@@ -23,11 +22,21 @@ const getCompileCommand = (opts, arch) => (sourceFile) => {
|
|
|
23
22
|
return cmd
|
|
24
23
|
}
|
|
25
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
|
+
|
|
26
30
|
const compileContract = (opts) => (sourceFile) =>
|
|
27
31
|
getArch()
|
|
28
32
|
.then(arch => getCompileCommand(opts, arch) (sourceFile))
|
|
29
33
|
.then(execCmd)
|
|
30
|
-
.then(
|
|
34
|
+
.then(result => result.status === 'success'
|
|
35
|
+
? ({contract: sourceFile, artifact: getContractArtifactFilename(opts) (sourceFile)})
|
|
36
|
+
: Promise.reject({
|
|
37
|
+
errCode: "E_COMPILE", context: result, errMsg: getLigoCompilationError(result.stderr)}
|
|
38
|
+
)
|
|
39
|
+
)
|
|
31
40
|
|
|
32
41
|
const compileAll = parsedArgs => {
|
|
33
42
|
// TODO: Fetch list of files from SDK
|
|
@@ -36,20 +45,30 @@ const compileAll = parsedArgs => {
|
|
|
36
45
|
{cwd: parsedArgs.contractsDir, absolute: false}
|
|
37
46
|
)
|
|
38
47
|
.then(entries => entries.map(compileContract(parsedArgs)))
|
|
48
|
+
.then(processes => processes.length > 0
|
|
49
|
+
? processes
|
|
50
|
+
: [{contract: "None found", artifact: "N/A"}]
|
|
51
|
+
)
|
|
39
52
|
.then(promises => Promise.all(promises))
|
|
40
53
|
}
|
|
41
54
|
|
|
42
55
|
const compile = parsedArgs => {
|
|
43
56
|
const p = parsedArgs.sourceFile
|
|
44
57
|
? compileContract(parsedArgs) (parsedArgs.sourceFile)
|
|
58
|
+
.then(result => [result])
|
|
45
59
|
: compileAll(parsedArgs)
|
|
46
60
|
|
|
47
|
-
return p
|
|
61
|
+
return p
|
|
62
|
+
.then(results => ({
|
|
48
63
|
status: 'success',
|
|
49
64
|
stdout: results,
|
|
50
65
|
stderr: "",
|
|
51
66
|
render: 'table'
|
|
52
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
|
+
)
|
|
53
72
|
}
|
|
54
73
|
|
|
55
74
|
module.exports = compile
|
package/package.json
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-ligo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A taqueria plugin for compiling LIGO smart contracts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
7
|
"build": "echo 'Nothing to build.' && exit 0",
|
|
8
|
-
"build-ci": "npm run build",
|
|
9
8
|
"pluginInfo": "node index.js --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\",\"artifactsDir\": \"artifacts\"}' --projectDir ../test-project --configDir ./.taq",
|
|
10
9
|
"compile": "node index.js --taqRun proxy --task compile --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\",\"artifactsDir\": \"artifacts\"}' --projectDir ../test-project --configDir ./.taq",
|
|
11
|
-
"debugPluginInfo": "node --inspect index.js --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\"}' --projectDir ../test-project --configDir ./.taq"
|
|
12
|
-
"get-sdk-version": "cd ../taqueria-sdk && node -e 'console.log(require(\"./package.json\").version)'",
|
|
13
|
-
"backup-config": "cp package.json package.json.orig && cp package-lock.json package-lock.json.orig",
|
|
14
|
-
"restore-config": "mv package.json.orig package.json && mv package-lock.json.orig package-lock.json",
|
|
15
|
-
"update-sdk-version": "sed -i -e \"s/file:\\.\\.\\/taqueria-sdk/`npm run get-sdk-version | tail -1`/\" package.json",
|
|
16
|
-
"update-sdk-version-lock": "sed -i -e \"s/file:\\.\\.\\/taqueria-sdk/`npm run get-sdk-version | tail -1`/\" package-lock.json",
|
|
17
|
-
"prod-config": "npm run backup-config && npm run update-sdk-version && npm run update-sdk-version-lock",
|
|
18
|
-
"prod-config-ci": "npm run prod-config",
|
|
19
|
-
"build-prod": "npm run backup-config && npm run prod-config && npm run build && npm run restore-config"
|
|
10
|
+
"debugPluginInfo": "node --inspect index.js --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\"}' --projectDir ../test-project --configDir ./.taq"
|
|
20
11
|
},
|
|
21
|
-
|
|
22
12
|
"keywords": [
|
|
23
13
|
"taqueria",
|
|
24
14
|
"tezos",
|
|
@@ -33,19 +23,17 @@
|
|
|
33
23
|
],
|
|
34
24
|
"author": "ECAD Labs",
|
|
35
25
|
"license": "Apache-2.0",
|
|
36
|
-
|
|
37
26
|
"repository": {
|
|
38
27
|
"type": "git",
|
|
39
28
|
"url": "https://github.com/ecadlabs/taqueria.git",
|
|
40
29
|
"directory": "taqueria-plugin-ligo"
|
|
41
30
|
},
|
|
42
|
-
|
|
43
31
|
"bugs": {
|
|
44
32
|
"url": "https://github.com/ecadlabs/taqueria/issues"
|
|
45
33
|
},
|
|
46
34
|
"homepage": "https://github.com/ecadlabs/taqueria#readme",
|
|
47
35
|
"dependencies": {
|
|
48
36
|
"fast-glob": "^3.2.7",
|
|
49
|
-
"@taqueria/node-sdk": "0.0.
|
|
37
|
+
"@taqueria/node-sdk": "^0.0.4"
|
|
50
38
|
}
|
|
51
39
|
}
|