@taqueria/plugin-ligo 0.0.3 → 0.0.5

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.
Files changed (2) hide show
  1. package/compile.js +22 -3
  2. package/package.json +2 -3
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(() => ({contract: sourceFile, artifact: getContractArtifactFilename(opts) (sourceFile)}))
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.then(results => ({
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,11 +1,10 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-ligo",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
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
10
  "debugPluginInfo": "node --inspect index.js --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\"}' --projectDir ../test-project --configDir ./.taq"
@@ -35,6 +34,6 @@
35
34
  "homepage": "https://github.com/ecadlabs/taqueria#readme",
36
35
  "dependencies": {
37
36
  "fast-glob": "^3.2.7",
38
- "@taqueria/node-sdk": "^0.0.1"
37
+ "@taqueria/node-sdk": "^0.0.5"
39
38
  }
40
39
  }