eitri-cli 1.10.0-beta.6 → 1.10.0-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.10.0-beta.6",
3
+ "version": "1.10.0-beta.8",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -18,10 +18,30 @@ module.exports = class AndroidEmulatorService {
18
18
  try {
19
19
  console.log("Verificando instalação do ABD",)
20
20
  const command = "adb --version"
21
- await exec(command)
22
- console.log("ADB Instalado. Continuando...")
21
+ const {stdout} = await exec(command)
22
+ console.log("ADB Instalado. Continuando...\n");
23
+
24
+ debug('checkHasInstalledAdb (adb --version):', stdout)
23
25
  } catch (error) {
24
- debug("checkHasInstalledAdb:", {message: e?.message || "", error})
26
+ console.error("checkHasInstalledAdb: Comando 'adb --version' não executado. Iniciando fallback. \n")
27
+ await this.checkHasInstalledAdbFallback(error)
28
+ }
29
+ }
30
+
31
+ static async checkHasInstalledAdbFallback(firstError = {}) {
32
+ try {
33
+ console.log("Verificação novamente instalação do ADB...");
34
+
35
+ const command = "adb devices"
36
+ const {stdout} = await exec(command)
37
+ console.log("ADB Instalado. Continuando...\n");
38
+
39
+ debug('checkHasInstalledAdb (adb devices):', stdout)
40
+ } catch (fallbackError) {
41
+ console.error("checkHasInstalledAdb: Comando 'adb devices' não executado. \n")
42
+ console.error("\n\ncheckHasInstalledAdb error: 'adb --version': \n", {message: firstError?.message || "", error: firstError})
43
+ console.error("\n\ncheckHasInstalledAdb error: 'adb devices': \n", {message: fallbackError?.message || "", error: fallbackError})
44
+
25
45
  throw new Error('"adb" não instalado. Saiba mais em https://developer.android.com/tools/adb')
26
46
  }
27
47
  }
@@ -67,7 +87,7 @@ module.exports = class AndroidEmulatorService {
67
87
 
68
88
  static async openDeepLink(cmd) {
69
89
  try {
70
- const {stderr} = await exec(cmd)
90
+ const { stderr } = await exec(cmd)
71
91
  return !(stderr);
72
92
  } catch (error) {
73
93
  console.log(`Houve um erro ao tentar abrir o Eitri-App via deep link`)
@@ -14,12 +14,12 @@ class MiniLog {
14
14
  return new Promise((resolve, reject) => {
15
15
  const socket = this.createSocket()
16
16
  socket.on('connect', () => {
17
- if(!silentOnConnect) console.log('✓ Construindo para Workspace Temporário: ', roomName)
17
+ if (!silentOnConnect) console.log('✓ Construindo para Workspace Temporário: ', roomName)
18
18
  socket.emit('joinRoom', roomName)
19
19
  resolve()
20
20
  })
21
21
  socket.on('connect_error', (e) => {
22
- if(silentOnConnect) console.error('Não foi possível contectar ao compilador', roomName)
22
+ if (silentOnConnect) console.error('Não foi possível contectar ao compilador', roomName)
23
23
  else console.error('Não foi possível contectar ao compilador', roomName, `${this._config.url} ${this._config.path}`)
24
24
  reject(e)
25
25
  })
@@ -29,36 +29,6 @@ class MiniLog {
29
29
  this.socket = socket
30
30
  })
31
31
  }
32
- //TODO: ESSE MÉTODO DEVE SER APAGADO, QUANDO NÃO EXISTIR MAIS O COMANDO PUBLISH
33
- awaitForPublish() {
34
- return new Promise((resolve, reject) => {
35
- this.socket.on('onLog', (event) => {
36
- if (!event.publish) {
37
- return
38
- }
39
- if (event.publish.ok) {
40
- resolve(event)
41
- } else {
42
- reject(new Error(event.publish.error))
43
- }
44
- })
45
- })
46
- }
47
-
48
- awaitForBuild() {
49
- return new Promise((resolve, reject) => {
50
- this.socket.on('onLog', (event) => {
51
- if (!event.publish) {
52
- return
53
- }
54
- if (event.publish.ok) {
55
- resolve(event)
56
- } else {
57
- reject(new Error(event.publish.error))
58
- }
59
- })
60
- })
61
- }
62
32
 
63
33
  awaitForPushVersion() {
64
34
  return new Promise((resolve, reject) => {
@@ -69,7 +39,8 @@ class MiniLog {
69
39
  if (event.publish.ok) {
70
40
  resolve(event)
71
41
  } else {
72
- reject(new Error(event.publish.error))
42
+ console.error(event.publish.friendlyMessage || event.publish.error)
43
+ return process.exit(1)
73
44
  }
74
45
  })
75
46
  })
@@ -83,18 +54,6 @@ class MiniLog {
83
54
  }
84
55
  }
85
56
 
86
- format2JSON(str) {
87
- let parsedToJSON
88
-
89
- try {
90
- parsedToJSON = JSON.parse(str)
91
- } catch (e) {
92
- return undefined
93
- }
94
-
95
- return parsedToJSON
96
- }
97
-
98
57
  printLog(data) {
99
58
  if (typeof data.msg === 'undefined') {
100
59
  return
@@ -121,7 +80,7 @@ class MiniLog {
121
80
  console.log(chalk.cyan(msg))
122
81
  } else {
123
82
  // A propriedade userFriendlyMessage deve ser tratada pelo Eitri-App. Logaremos da forma como o Eitri-App nos fornecer o objeto.
124
- if(!data.method) {
83
+ if (!data.method) {
125
84
  console.log(`\x1b[34meitri:\x1b[0m\x1b[97m${data.msg}\x1b[0m`);
126
85
  } else {
127
86
  const message = this._colorizeMessage(data.msg, data.method)