eitri-cli 1.10.0 → 1.10.1-beta.1

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 (70) hide show
  1. package/eitri-cli-v2/eitri-cli-v2.darwin-arm64.node +0 -0
  2. package/eitri-cli-v2/eitri-cli-v2.darwin-x64.node +0 -0
  3. package/eitri-cli-v2/eitri-cli-v2.linux-x64-gnu.node +0 -0
  4. package/eitri-cli-v2/eitri-cli-v2.win32-x64-msvc.node +0 -0
  5. package/package.json +1 -1
  6. package/src/modules/vegvisir/VegvisirService.js +1 -1
  7. package/src/service/Emulator/AndroidEmulatorService.js +25 -3
  8. package/src/service/MiniLog.js +5 -46
  9. package/eitri-cli-v2/src/commands/mod.rs +0 -2
  10. package/eitri-cli-v2/src/commands/publish.rs +0 -35
  11. package/eitri-cli-v2/src/commands/run_test.rs +0 -41
  12. package/eitri-cli-v2/src/config/mod.rs +0 -1
  13. package/eitri-cli-v2/src/config/user_credentials.rs +0 -38
  14. package/eitri-cli-v2/src/infra/http_client.rs +0 -493
  15. package/eitri-cli-v2/src/infra/mod.rs +0 -1
  16. package/eitri-cli-v2/src/lib.rs +0 -30
  17. package/eitri-cli-v2/src/model/auth_response.rs +0 -8
  18. package/eitri-cli-v2/src/model/credentials.rs +0 -8
  19. package/eitri-cli-v2/src/model/eitri_conf.rs +0 -43
  20. package/eitri-cli-v2/src/model/mod.rs +0 -8
  21. package/eitri-cli-v2/src/model/process_output.rs +0 -8
  22. package/eitri-cli-v2/src/model/revision.rs +0 -14
  23. package/eitri-cli-v2/src/model/test_config.rs +0 -7
  24. package/eitri-cli-v2/src/model/url.rs +0 -11
  25. package/eitri-cli-v2/src/model/workspace_auth.rs +0 -4
  26. package/eitri-cli-v2/src/services/blind_guardian.rs +0 -87
  27. package/eitri-cli-v2/src/services/eitri_foundry.rs +0 -84
  28. package/eitri-cli-v2/src/services/eitri_manager.rs +0 -78
  29. package/eitri-cli-v2/src/services/mod.rs +0 -4
  30. package/eitri-cli-v2/src/services/workspace.rs +0 -49
  31. package/eitri-cli-v2/src/utils/convert_eitri_conf.rs +0 -98
  32. package/eitri-cli-v2/src/utils/mod.rs +0 -1
  33. package/test/Executor.js +0 -60
  34. package/test/Factory.js +0 -13
  35. package/test/Helper.js +0 -15
  36. package/test/_fixtures/factory.js +0 -30
  37. package/test/_fixtures/miniWebApp/miniapp.conf.js +0 -4
  38. package/test/_fixtures/miniapp.conf.js +0 -5
  39. package/test/_fixtures/server/HelloWorldBackend.js +0 -7
  40. package/test/_fixtures/src/Home.js +0 -5
  41. package/test/_fixtures/src/Home2.js +0 -5
  42. package/test/_fixtures/src/commons/util.js +0 -3
  43. package/test/_fixtures/src/components/TagA.jsx +0 -4
  44. package/test/_fixtures/src/components/TagB.jsx +0 -4
  45. package/test/_fixtures/src/components/TagC.jsx +0 -3
  46. package/test/_fixtures/src/components/TagD.jsx +0 -3
  47. package/test/_fixtures/src/server/foo.js +0 -7
  48. package/test/_fixtures/src/views/AboutTemplate.jsx +0 -14
  49. package/test/_fixtures/woodcoffee/miniapp.conf.js +0 -5
  50. package/test/ame.conf.js +0 -3
  51. package/test/cmd/clean.test.js +0 -66
  52. package/test/cmd/create.test.js +0 -252
  53. package/test/cmd/list.test.js +0 -74
  54. package/test/cmd/manage-env.test.js +0 -168
  55. package/test/e2e/cli.test.js +0 -473
  56. package/test/miniapp.conf.js +0 -3
  57. package/test/model/Payload.test.js +0 -35
  58. package/test/modules/vegvisir/VegvisirService.test.js +0 -37
  59. package/test/service/BlindGuardian.test.js +0 -84
  60. package/test/service/CheckAmeConf.test.js +0 -313
  61. package/test/service/Http.test.js +0 -312
  62. package/test/service/InviteService.test.js +0 -117
  63. package/test/service/MiniWebAppFactory.test.js +0 -40
  64. package/test/service/TagTree.test.js +0 -81
  65. package/test/service/TargetService.test.js +0 -48
  66. package/test/service/TrackingService.test.js +0 -105
  67. package/test/service/UserAmeConf.test.js +0 -47
  68. package/test/service/WoodCoffeeFactory.test.js +0 -148
  69. package/test/service/Workspace.test.js +0 -211
  70. package/test/utils/getWorkspaceId.test.js +0 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.10.0",
3
+ "version": "1.10.1-beta.1",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -125,7 +125,7 @@ module.exports = class VegvisirService {
125
125
  );
126
126
  const fileContent = await readFile(workspaceGlobalPath, "utf8");
127
127
  const workspace = JSON.parse(fileContent);
128
- debug(`Construindo para o Workspace [${workspace.id}]`)
128
+ debug(`Construindo para o Workspace [${workspace.id} / Email: ${workspace.userEmail}]`)
129
129
  workspace.id = validateUUID(this.workspaceId) ? this.workspaceId : workspace.id;
130
130
  return workspace;
131
131
  } catch (error) {
@@ -2,6 +2,7 @@ const util = require('util');
2
2
  const inquirer = require("inquirer");
3
3
  const GenericUtils = require('../../util/GenericUtils');
4
4
  const exec = util.promisify(require("child_process").exec)
5
+ const debug = require('debug')('eitri:AndroidEmulatorService')
5
6
 
6
7
  module.exports = class AndroidEmulatorService {
7
8
 
@@ -17,9 +18,30 @@ module.exports = class AndroidEmulatorService {
17
18
  try {
18
19
  console.log("Verificando instalação do ABD",)
19
20
  const command = "adb --version"
20
- await exec(command)
21
- 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)
22
25
  } catch (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
+
23
45
  throw new Error('"adb" não instalado. Saiba mais em https://developer.android.com/tools/adb')
24
46
  }
25
47
  }
@@ -65,7 +87,7 @@ module.exports = class AndroidEmulatorService {
65
87
 
66
88
  static async openDeepLink(cmd) {
67
89
  try {
68
- const {stderr} = await exec(cmd)
90
+ const { stderr } = await exec(cmd)
69
91
  return !(stderr);
70
92
  } catch (error) {
71
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)
@@ -1,2 +0,0 @@
1
- pub mod publish;
2
- pub mod run_test;
@@ -1,35 +0,0 @@
1
- use std::process::exit;
2
-
3
- use crate::services::{eitri_manager, workspace};
4
-
5
- const DIVISOR: &str = "========================================================";
6
-
7
- pub async fn execute(environment: String, message: String) {
8
- let init_message = format!("Iniciando publicação de Eitri-App",);
9
- println!("{DIVISOR}");
10
- println!("\t{init_message}");
11
- println!("{DIVISOR}");
12
-
13
- let eitri_conf = workspace::read_eitri_conf().await;
14
- let version = eitri_conf.version;
15
- println!("Versão a ser publicada: {}", version);
16
- println!("Environment: {}", environment);
17
- println!("Mensagem: {}", message);
18
-
19
- let revision = match eitri_manager::get_revision(&eitri_conf.id, &version).await {
20
- Ok(revision) => revision,
21
- Err(_err) => {
22
- eprintln!("Houve um erro ao buscar revisão.");
23
- exit(1)
24
- }
25
- };
26
- match eitri_manager::publish_revision(&revision.id, &environment, &message).await {
27
- Ok(_) => {
28
- println!("Eitri-App publicado com sucesso!")
29
- }
30
- Err(err) => {
31
- eprintln!("Houve um erro. Error: {:?}", err);
32
- exit(1)
33
- }
34
- }
35
- }
@@ -1,41 +0,0 @@
1
- use std::{env, process::exit};
2
- use colored::*;
3
-
4
- use crate::{
5
- model::{url::Url, workspace_auth::WorkspaceAuth},
6
- services::eitri_foundry,
7
- };
8
-
9
- pub async fn execute(_workspace_auth: WorkspaceAuth, _path: String) {
10
- let path = env::var("FOUNDRY_CONTEXT_PATH")
11
- .ok()
12
- .and_then(|context_path| {
13
- if context_path.is_empty() {
14
- Some(String::from("foundry/run-test"))
15
- } else {
16
- Some(format!("{}/run-test", context_path))
17
- }
18
- })
19
- .unwrap_or_else(|| String::from("foundry/run-test"));
20
-
21
- let url = Url {
22
- host: String::from("https://api.eitri.tech/"),
23
- path: path,
24
- };
25
- let result = eitri_foundry::run_test(_workspace_auth, _path, url).await;
26
-
27
- match result {
28
- Ok(output) => {
29
- let output_str = output.stderr;
30
- eprint!("{output_str}");
31
- }
32
- Err(http_error) => {
33
- if let Some(message) = http_error.get_message() {
34
- eprintln!("{}", message.red().bold());
35
- } else {
36
- eprintln!("Houve um erro ao executar os testes.");
37
- }
38
- exit(1)
39
- }
40
- }
41
- }
@@ -1 +0,0 @@
1
- pub mod user_credentials;
@@ -1,38 +0,0 @@
1
- use std::{fs, process::exit};
2
-
3
- use homedir::get_my_home;
4
-
5
- use crate::model::credentials::Credentials;
6
-
7
- pub fn get_credentials() -> Result<Credentials, serde_json::Error> {
8
- let home_dir = match get_my_home() {
9
- Ok(dir) => dir,
10
- Err(_) => {
11
- eprintln!("Houve um erro ao ler a home do usuário");
12
- exit(1)
13
- }
14
- };
15
-
16
- let home_dir = match home_dir {
17
- Some(dir) => dir,
18
- _ => exit(1),
19
- };
20
-
21
- let credentials_file_path = home_dir.join(".eitri").join("prod-eitri.conf.js");
22
-
23
- let content = match fs::read_to_string(credentials_file_path.to_owned()) {
24
- Ok(c) => c,
25
- Err(_) => {
26
- eprintln!(
27
- "Houve um erro ao ler credenciais do usuário, certifique-se de ter feito login"
28
- );
29
- exit(1)
30
- }
31
- };
32
-
33
- let content = content.replace("module.exports = ", "");
34
-
35
- let credentials: Credentials = serde_json::from_str(&content)?;
36
-
37
- Ok(credentials)
38
- }