eitri-cli 1.10.1 → 1.11.0-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 (79) hide show
  1. package/eitri-cli-v2/Cargo.toml +1 -0
  2. package/eitri-cli-v2/config/config.dev.toml +67 -0
  3. package/eitri-cli-v2/config/config.loc.toml +67 -0
  4. package/eitri-cli-v2/config/config.prod.toml +62 -0
  5. package/eitri-cli-v2/config/config.runes-foundry.toml +7 -0
  6. package/eitri-cli-v2/config/config.test.toml +67 -0
  7. package/eitri-cli-v2/eitri-cli-v2.darwin-arm64.node +0 -0
  8. package/eitri-cli-v2/eitri-cli-v2.darwin-x64.node +0 -0
  9. package/eitri-cli-v2/eitri-cli-v2.linux-x64-gnu.node +0 -0
  10. package/eitri-cli-v2/eitri-cli-v2.win32-x64-msvc.node +0 -0
  11. package/index.js +4 -1
  12. package/package.json +1 -1
  13. package/src/modules/vegvisir/VegvisirService.js +1 -1
  14. package/src/service/Emulator/AndroidEmulatorService.js +25 -3
  15. package/src/service/MiniLog.js +5 -46
  16. package/src/service/factories/WoodCoffeeFactory.js +4 -3
  17. package/src/util/LibUtil.js +32 -0
  18. package/eitri-cli-v2/src/commands/mod.rs +0 -2
  19. package/eitri-cli-v2/src/commands/publish.rs +0 -35
  20. package/eitri-cli-v2/src/commands/run_test.rs +0 -41
  21. package/eitri-cli-v2/src/config/mod.rs +0 -1
  22. package/eitri-cli-v2/src/config/user_credentials.rs +0 -38
  23. package/eitri-cli-v2/src/infra/http_client.rs +0 -493
  24. package/eitri-cli-v2/src/infra/mod.rs +0 -1
  25. package/eitri-cli-v2/src/lib.rs +0 -30
  26. package/eitri-cli-v2/src/model/auth_response.rs +0 -8
  27. package/eitri-cli-v2/src/model/credentials.rs +0 -8
  28. package/eitri-cli-v2/src/model/eitri_conf.rs +0 -43
  29. package/eitri-cli-v2/src/model/mod.rs +0 -8
  30. package/eitri-cli-v2/src/model/process_output.rs +0 -8
  31. package/eitri-cli-v2/src/model/revision.rs +0 -14
  32. package/eitri-cli-v2/src/model/test_config.rs +0 -7
  33. package/eitri-cli-v2/src/model/url.rs +0 -11
  34. package/eitri-cli-v2/src/model/workspace_auth.rs +0 -4
  35. package/eitri-cli-v2/src/services/blind_guardian.rs +0 -87
  36. package/eitri-cli-v2/src/services/eitri_foundry.rs +0 -84
  37. package/eitri-cli-v2/src/services/eitri_manager.rs +0 -78
  38. package/eitri-cli-v2/src/services/mod.rs +0 -4
  39. package/eitri-cli-v2/src/services/workspace.rs +0 -49
  40. package/eitri-cli-v2/src/utils/convert_eitri_conf.rs +0 -98
  41. package/eitri-cli-v2/src/utils/mod.rs +0 -1
  42. package/test/Executor.js +0 -60
  43. package/test/Factory.js +0 -13
  44. package/test/Helper.js +0 -15
  45. package/test/_fixtures/factory.js +0 -30
  46. package/test/_fixtures/miniWebApp/miniapp.conf.js +0 -4
  47. package/test/_fixtures/miniapp.conf.js +0 -5
  48. package/test/_fixtures/server/HelloWorldBackend.js +0 -7
  49. package/test/_fixtures/src/Home.js +0 -5
  50. package/test/_fixtures/src/Home2.js +0 -5
  51. package/test/_fixtures/src/commons/util.js +0 -3
  52. package/test/_fixtures/src/components/TagA.jsx +0 -4
  53. package/test/_fixtures/src/components/TagB.jsx +0 -4
  54. package/test/_fixtures/src/components/TagC.jsx +0 -3
  55. package/test/_fixtures/src/components/TagD.jsx +0 -3
  56. package/test/_fixtures/src/server/foo.js +0 -7
  57. package/test/_fixtures/src/views/AboutTemplate.jsx +0 -14
  58. package/test/_fixtures/woodcoffee/miniapp.conf.js +0 -5
  59. package/test/ame.conf.js +0 -3
  60. package/test/cmd/clean.test.js +0 -66
  61. package/test/cmd/create.test.js +0 -252
  62. package/test/cmd/list.test.js +0 -74
  63. package/test/cmd/manage-env.test.js +0 -168
  64. package/test/e2e/cli.test.js +0 -473
  65. package/test/miniapp.conf.js +0 -3
  66. package/test/model/Payload.test.js +0 -35
  67. package/test/modules/vegvisir/VegvisirService.test.js +0 -37
  68. package/test/service/BlindGuardian.test.js +0 -84
  69. package/test/service/CheckAmeConf.test.js +0 -313
  70. package/test/service/Http.test.js +0 -312
  71. package/test/service/InviteService.test.js +0 -117
  72. package/test/service/MiniWebAppFactory.test.js +0 -40
  73. package/test/service/TagTree.test.js +0 -81
  74. package/test/service/TargetService.test.js +0 -48
  75. package/test/service/TrackingService.test.js +0 -105
  76. package/test/service/UserAmeConf.test.js +0 -47
  77. package/test/service/WoodCoffeeFactory.test.js +0 -148
  78. package/test/service/Workspace.test.js +0 -211
  79. package/test/utils/getWorkspaceId.test.js +0 -17
@@ -22,6 +22,7 @@ serde_derive = "1.0.197"
22
22
  serde_json = "1.0.114"
23
23
  tokio = { version = "1.36.0", features = ["full"] }
24
24
  colored = "2.0"
25
+ config = "0.14.0"
25
26
 
26
27
  [target.x86_64-unknown-linux-gnu]
27
28
  openssl = { version = "0.9", features = ["vendored"] }
@@ -0,0 +1,67 @@
1
+ user_agent = "eitri-cli"
2
+
3
+ [signup]
4
+ config_file_path = ".eitri/prod-eitri.conf.js"
5
+ old_config_file_path = ".miniapp/prod-eitri.conf.js"
6
+
7
+ [doc]
8
+ create_url = "https://console.eitri.tech/docs"
9
+
10
+ [blind_guardian]
11
+ url = "https://api.eitri.tech/blind-guardian-api"
12
+ auth_path = "/v2/o/auth"
13
+
14
+ [share_api]
15
+ url = "https://api.eitri.tech/share-api/share"
16
+
17
+ [foundry]
18
+ url = "https://api.eitri.tech"
19
+ base_path = "runes-foundry"
20
+ target_path = "/runes-foundry/targets"
21
+ run_test_path = "/runes-foundry/run-test"
22
+ share_path = "/foundry/share"
23
+
24
+ [foundry.libs]
25
+ update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
26
+
27
+ [hugin]
28
+ url = "https://api.eitri.tech/eitri-hugin-api"
29
+ upload_zip = "/uploadAll"
30
+ upload_file = "/uploadSingle"
31
+ watch_user_dir = "/server"
32
+
33
+ [qr_code]
34
+ url = "https://prod.eitri.calindra.com.br/workspace/share"
35
+
36
+ [mini_log]
37
+ url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
38
+ path = "/mini-log/socket.io"
39
+
40
+ [manager_api]
41
+ url = "https://api.eitri.tech/miniapp-manager-api"
42
+
43
+ [eitri_manager]
44
+ url = "https://api.eitri.tech/eitri-manager-api"
45
+ revision_path = "/v2/revisions"
46
+ publish_path = "/revisions/:eitriAppId/publish"
47
+
48
+ [eitri_analytics]
49
+ url = "https://api.eitri.tech/analytics/event"
50
+
51
+ [manager_front]
52
+ url = "https://console.eitri.tech"
53
+ manager_credential = "/settings/manager-credential"
54
+ cli_generate_login_credential = "/settings/cli-generate-credential"
55
+
56
+ [vegvisir]
57
+ url = "https://api.eitri.tech"
58
+ base_path = "/eitri-vegvisir-api"
59
+ workspace = "/workspace"
60
+ my = "/workspace/my"
61
+ check = "/workspace/check"
62
+
63
+
64
+ [cdn_library]
65
+ url = "https://cdn.83io.com.br/library"
66
+ bifrost_versions = "/eitri-bifrost/versions/index.json"
67
+ luminus_ui_versions = "/luminus-ui/versions/index.json"
@@ -0,0 +1,67 @@
1
+ user_agent = "eitri-cli"
2
+
3
+ [signup]
4
+ config_file_path = ".eitri/prod-eitri.conf.js"
5
+ old_config_file_path = ".miniapp/prod-eitri.conf.js"
6
+
7
+ [doc]
8
+ create_url = "https://console.eitri.tech/docs"
9
+
10
+ [blind_guardian]
11
+ url = "https://api.eitri.tech/blind-guardian-api"
12
+ auth_path = "/v2/o/auth"
13
+
14
+ [share_api]
15
+ url = "https://api.eitri.tech/share-api/share"
16
+
17
+ [foundry]
18
+ url = "http://localhost:3000"
19
+ base_path = "runes-foundry"
20
+ target_path = "/runes-foundry/targets"
21
+ run_test_path = "/runes-foundry/run-test"
22
+ share_path = "/runes-foundry/share"
23
+
24
+ [foundry.libs]
25
+ update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
26
+
27
+ [hugin]
28
+ url = "https://api.eitri.tech/eitri-hugin-api"
29
+ upload_zip = "/uploadAll"
30
+ upload_file = "/uploadSingle"
31
+ watch_user_dir = "/server"
32
+
33
+ [qr_code]
34
+ url = "https://prod.eitri.calindra.com.br/workspace/share"
35
+
36
+ [mini_log]
37
+ url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
38
+ path = "/mini-log/socket.io"
39
+
40
+ [manager_api]
41
+ url = "https://api.eitri.tech/miniapp-manager-api"
42
+
43
+ [eitri_manager]
44
+ url = "https://api.eitri.tech/eitri-manager-api"
45
+ revision_path = "/v2/revisions"
46
+ publish_path = "/revisions/:eitriAppId/publish"
47
+
48
+ [eitri_analytics]
49
+ url = "https://api.eitri.tech/analytics/event"
50
+
51
+ [manager_front]
52
+ url = "https://console.eitri.tech"
53
+ manager_credential = "/settings/manager-credential"
54
+ cli_generate_login_credential = "/settings/cli-generate-credential"
55
+
56
+ [vegvisir]
57
+ url = "https://api.eitri.tech"
58
+ base_path = "/eitri-vegvisir-api"
59
+ workspace = "/workspace"
60
+ my = "/workspace/my"
61
+ check = "/workspace/check"
62
+
63
+
64
+ [cdn_library]
65
+ url = "https://cdn.83io.com.br/library"
66
+ bifrost_versions = "/eitri-bifrost/versions/index.json"
67
+ luminus_ui_versions = "/luminus-ui/versions/index.json"
@@ -0,0 +1,62 @@
1
+ user_agent = "eitri-cli"
2
+
3
+ [signup]
4
+ config_file_path = ".eitri/prod-eitri.conf.js"
5
+ old_config_file_path = ".miniapp/prod-eitri.conf.js"
6
+
7
+ [doc]
8
+ create_url = "https://console.eitri.tech/docs"
9
+
10
+ [blind_guardian]
11
+ url = "https://api.eitri.tech/blind-guardian-api"
12
+ auth_path = "/v2/o/auth"
13
+
14
+ [share_api]
15
+ url = "https://api.eitri.tech/share-api/share"
16
+
17
+ [foundry]
18
+ url = "https://api.eitri.tech"
19
+ base_path = "foundry"
20
+ target_path = "/foundry/targets"
21
+ run_test_path = "/foundry/run-test"
22
+ share_path = "/foundry/share"
23
+
24
+ [foundry.libs]
25
+ update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
26
+
27
+ [hugin]
28
+ url = "https://api.eitri.tech/eitri-hugin-api"
29
+ upload_zip = "/uploadAll"
30
+ upload_file = "/uploadSingle"
31
+ watch_user_dir = "/server"
32
+
33
+ [mini_log]
34
+ url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
35
+ path = "/mini-log/socket.io"
36
+
37
+
38
+ [eitri_manager]
39
+ url = "https://api.eitri.tech/eitri-manager-api"
40
+ revision_path = "/v2/revisions"
41
+ publish_path = "/revisions/:eitriAppId/publish"
42
+
43
+ [eitri_analytics]
44
+ url = "https://api.eitri.tech/analytics/event"
45
+
46
+ [manager_front]
47
+ url = "https://console.eitri.tech"
48
+ manager_credential = "/settings/manager-credential"
49
+ cli_generate_login_credential = "/settings/cli-generate-credential"
50
+
51
+ [vegvisir]
52
+ url = "https://api.eitri.tech"
53
+ base_path = "/eitri-vegvisir-api"
54
+ workspace = "/workspace"
55
+ my = "/workspace/my"
56
+ check = "/workspace/check"
57
+
58
+
59
+ [cdn_library]
60
+ url = "https://cdn.83io.com.br/library"
61
+ bifrost_versions = "/eitri-bifrost/versions/index.json"
62
+ luminus_ui_versions = "/luminus-ui/versions/index.json"
@@ -0,0 +1,7 @@
1
+
2
+ [foundry]
3
+ url = "https://api.eitri.tech"
4
+ base_path = "runes-foundry"
5
+ target_path = "/runes-foundry/targets"
6
+ run_test_path = "/runes-foundry/run-test"
7
+ share_path = "/runes-foundry/share"
@@ -0,0 +1,67 @@
1
+ user_agent = "eitri-cli"
2
+
3
+ [signup]
4
+ config_file_path = ".eitri/prod-eitri.conf.js"
5
+ old_config_file_path = ".miniapp/prod-eitri.conf.js"
6
+
7
+ [doc]
8
+ create_url = "https://console.eitri.tech/docs"
9
+
10
+ [blind_guardian]
11
+ url = "https://api.eitri.tech/blind-guardian-api"
12
+ auth_path = "/v2/o/auth"
13
+
14
+ [share_api]
15
+ url = "https://api.eitri.tech/share-api/share"
16
+
17
+ [foundry]
18
+ url = "https://api.eitri.tech"
19
+ base_path = "runes-foundry"
20
+ target_path = "/runes-foundry/targets"
21
+ run_test_path = "/runes-foundry/run-test"
22
+ share_path = "/foundry/share"
23
+
24
+ [foundry.libs]
25
+ update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
26
+
27
+ [hugin]
28
+ url = "https://api.eitri.tech/eitri-hugin-api"
29
+ upload_zip = "/uploadAll"
30
+ upload_file = "/uploadSingle"
31
+ watch_user_dir = "/server"
32
+
33
+ [qr_code]
34
+ url = "https://prod.eitri.calindra.com.br/workspace/share"
35
+
36
+ [mini_log]
37
+ url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
38
+ path = "/mini-log/socket.io"
39
+
40
+ [manager_api]
41
+ url = "https://api.eitri.tech/miniapp-manager-api"
42
+
43
+ [eitri_manager]
44
+ url = "https://api.eitri.tech/eitri-manager-api"
45
+ revision_path = "/v2/revisions"
46
+ publish_path = "/revisions/:eitriAppId/publish"
47
+
48
+ [eitri_analytics]
49
+ url = "https://api.eitri.tech/analytics/event"
50
+
51
+ [manager_front]
52
+ url = "https://console.eitri.tech"
53
+ manager_credential = "/settings/manager-credential"
54
+ cli_generate_login_credential = "/settings/cli-generate-credential"
55
+
56
+ [vegvisir]
57
+ url = "https://api.eitri.tech"
58
+ base_path = "/eitri-vegvisir-api"
59
+ workspace = "/workspace"
60
+ my = "/workspace/my"
61
+ check = "/workspace/check"
62
+
63
+
64
+ [cdn_library]
65
+ url = "https://cdn.83io.com.br/library"
66
+ bifrost_versions = "/eitri-bifrost/versions/index.json"
67
+ luminus_ui_versions = "/luminus-ui/versions/index.json"
package/index.js CHANGED
@@ -12,6 +12,9 @@ const debug = require('debug')('eitri:run')
12
12
 
13
13
  const run = async () => {
14
14
  debug("Iniciando run()")
15
+ // Temporariamente necessário por conta de no contexto do Rust não saber o diretório atual, dessa forma exportando o fullPath do config é possível.
16
+ // Quando se tornar uma CLI somente em rust no processo de instalação podemos declarar o caminho, como é via NPM pode ter caminhos variados de acordo com sistema de versionamento, NVM, Volta, ASDF é necessário a variável abaixo.
17
+ process.env.CONFIG_DIR_PATH = path.join(__dirname, 'eitri-cli-v2', 'config')
15
18
  try {
16
19
  const srcFolder2watch = path.join(process.cwd(), "src");
17
20
  workspace.setFolder2Watch(srcFolder2watch);
@@ -156,7 +159,7 @@ const run = async () => {
156
159
  "-p --path <test_path>",
157
160
  "Define o path do arquivo de teste que será executado."
158
161
  )
159
- .action(async (cmdObj) => {return require("./src/cmd/runTests")(cmdObj)});
162
+ .action(async (cmdObj) => { return require("./src/cmd/runTests")(cmdObj) });
160
163
 
161
164
  program.addCommand(VegvisirCommand());
162
165
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.10.1",
3
+ "version": "1.11.0-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)
@@ -6,6 +6,7 @@ const util = require("util");
6
6
  const exec = util.promisify(require("child_process").exec);
7
7
  const { writeFile, rm } = require("fs/promises");
8
8
  const axios = require("axios");
9
+ const LibUtil = require("../../util/LibUtil");
9
10
 
10
11
  class WoodCoffee {
11
12
  static COMPONENTS_LIBRARY_VERSION_HIGHLIGHTER =
@@ -250,7 +251,7 @@ class WoodCoffee {
250
251
  async writeEitriAppConf(project, conf) {
251
252
  const versions = await this._getLatestLibVersions();
252
253
  conf["version"] = "0.1.0";
253
- conf["eitri-luminus"] = versions.componentsVersion;
254
+ conf["eitri-luminus"] = LibUtil.getLuminusVersion(project.structure.miniAppConf["eitri-luminus"], versions.componentsVersion)
254
255
  conf["eitri-bifrost"] = versions.appClientVersion;
255
256
 
256
257
  let confString = `module.exports = ${JSON.stringify(conf, null, 4)}`;
@@ -260,8 +261,8 @@ class WoodCoffee {
260
261
  "utf8"
261
262
  );
262
263
  const oldConfPath = path.join(project.projectPath, "miniapp.conf.js");
263
- if(fs.existsSync(oldConfPath)) {
264
- await rm(oldConfPath, {force: true})
264
+ if (fs.existsSync(oldConfPath)) {
265
+ await rm(oldConfPath, { force: true })
265
266
  }
266
267
  }
267
268
 
@@ -0,0 +1,32 @@
1
+ module.exports = class LibUtil {
2
+ static extractVersion = (text) => {
3
+ const m = text?.match(semverRegEx);
4
+ if (m) {
5
+ return m[1];
6
+ }
7
+ return "";
8
+ };
9
+
10
+ /**
11
+ * Função utilizada apenas em casos onde a biblioteca de componentes não
12
+ * recebe uma versão, mas uma string que começa com @ e aponta para um eitri-app
13
+ * @param {string} text
14
+ * @returns
15
+ */
16
+ static extractSlug = (text) => {
17
+ const match = text?.match(/^@([^:]+):/);
18
+ if (match) {
19
+ return match[1];
20
+ }
21
+ return "";
22
+ };
23
+
24
+ static getLuminusVersion(version, latestVersion) {
25
+ const slug = LibUtil.extractSlug(version)
26
+ if (slug) {
27
+ return version
28
+ }
29
+
30
+ return latestVersion
31
+ }
32
+ }
@@ -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
- }