eitri-cli 1.20.0 → 1.21.0-beta.2

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.
@@ -1,5 +1,14 @@
1
1
  {
2
- "cSpell.words": ["bifrost", "eitri", "luminus", "miniapp", "napi", "Unmocked", "Vegvisir"],
2
+ "cSpell.words": [
3
+ "bifrost",
4
+ "eitri",
5
+ "luminus",
6
+ "miniapp",
7
+ "napi",
8
+ "Unmocked",
9
+ "vegvisir",
10
+ "Vegvisir"
11
+ ],
3
12
  "rust-analyzer.showUnlinkedFileNotification": false,
4
13
  "cSpell.language": "en,pt,pt-BR"
5
- }
14
+ }
@@ -17,7 +17,7 @@ pipelines:
17
17
  - dig +short ns eitri.tech
18
18
  - cd eitri-cli-v2
19
19
  - npm i
20
- - npm i puppeteer@21.4.1
20
+ - npm i puppeteer@22.12.1
21
21
  - npm run build:debug
22
22
  - cd ..
23
23
  - npm i
@@ -34,7 +34,7 @@ pipelines:
34
34
  - dig +short ns eitri.tech
35
35
  - cd eitri-cli-v2
36
36
  - npm i
37
- - npm i puppeteer@21.4.1
37
+ - npm i puppeteer@22.12.1
38
38
  - npm run build:debug
39
39
  - cd ..
40
40
  - yarn
@@ -42,6 +42,7 @@ sha1 = "0.10.6"
42
42
  file-hashing = "0.1.2"
43
43
  qr2term = "0.3.1"
44
44
  fs_extra = "1.3.0"
45
+ base64 = "0.22.1"
45
46
 
46
47
  [dependencies.uuid]
47
48
  version = "1.8.0"
package/index.js CHANGED
@@ -88,12 +88,8 @@ const run = async () => {
88
88
  .option("-sh, --shared", "Executa o Eitri-App no modo compartilhável.")
89
89
 
90
90
  startProgram.action(async (cmdObj) => {
91
- if (process.env.FT_START_V2 === "true") {
92
- console.log("Eitri-App start (v2)");
93
- const eitriCLIV2 = require("./eitri-cli-v2/index.js");
94
- return await eitriCLIV2.start(cmdObj);
95
- }
96
- require("./src/cmd/start")(cmdObj);
91
+ const eitriCLIV2 = require("./eitri-cli-v2/index.js");
92
+ return await eitriCLIV2.start(cmdObj);
97
93
  });
98
94
 
99
95
  program
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.20.0",
3
+ "version": "1.21.0-beta.2",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -73,7 +73,6 @@
73
73
  "@faker-js/faker": "^7.6.0",
74
74
  "@semantic-release/changelog": "^6.0.3",
75
75
  "@semantic-release/git": "^10.0.1",
76
- "docsify-cli": "^4.4.2",
77
76
  "eslint": "^9.5.0",
78
77
  "eslint-config-google": "^0.14.0",
79
78
  "eslint-plugin-jest": "^28.6.0",
@@ -83,7 +82,7 @@
83
82
  "lint-staged": "^9.5.0",
84
83
  "nock": "^13.3.0",
85
84
  "prettier": "^3.3.2",
86
- "puppeteer": "^22.11.2",
85
+ "puppeteer": "22.12.1",
87
86
  "semantic-release": "^22.0.8"
88
87
  },
89
88
  "resolutions": {
@@ -46,7 +46,7 @@ module.exports = async function runTests(args) {
46
46
  const separator = '======================================================================='
47
47
  let displayFriendlyErrorAtEnd = ""
48
48
 
49
- await prerequisitesValidator.checkAll()
49
+ await prerequisitesValidator.checkAll(args)
50
50
 
51
51
  try {
52
52
  if (!args.force) {
package/src/cmd/start.js CHANGED
@@ -47,7 +47,7 @@ module.exports = async function start(args) {
47
47
  const separator = '======================================================================='
48
48
  let displayFriendlyErrorAtEnd = ""
49
49
 
50
- await prerequisitesValidator.checkAll()
50
+ await prerequisitesValidator.checkAll(args)
51
51
 
52
52
  try {
53
53
  if (!args.force) {
@@ -12,43 +12,82 @@ class PrerequisitesValidator {
12
12
  this.blindGuardian = workspace.blindGuardian;
13
13
  this.http = new Http(workspace.blindGuardian);
14
14
  this.userInfo = {id: "", email: ""}
15
+ this.userOrgsData = []
15
16
  }
16
17
 
17
- async checkAll() {
18
- this.checkCredentials()
18
+ async checkAll(args = {}) {
19
+ await this.checkConnection(args)
20
+ this.checkCredentials(args)
19
21
  await this.isUserInOrg()
20
22
  }
21
23
 
22
- checkCredentials() {
24
+ async checkConnection(args = {}) {
25
+ try {
26
+ if(args?.verbose) console.log("\n ↺ Verificando conexão com a internet...")
27
+
28
+ const respMyOrgsData = await this.http.get(`${MANAGER_URL}/users/me/organizations`);
29
+ this.userOrgsData = respMyOrgsData
30
+
31
+ if(args?.verbose) console.log("\n ✔ Conectado \n\n")
32
+
33
+ } catch (error) {
34
+ this.sendErrorToAnalytics("checkConnection.error", error)
35
+
36
+ if(args?.verbose) {
37
+ debug("ERRO na verificação de conexão", {message: error?.message, error})
38
+ console.error("\nError: \n", {message: error?.message, errorData: error?.response?.data})
39
+ }
40
+
41
+ const friendlyErrorMessage = `Não foi possível conectar. \n Por favor, verifique sua conexão com a internet e tente novamente.`
42
+ console.error(`\n\x1b[1m\x1b[31m ${friendlyErrorMessage} \x1b[0m\n`)
43
+ process.exit(1)
44
+ }
45
+ }
46
+
47
+ checkCredentials(args) {
23
48
  try {
24
49
  UserLocalCredential.checkForCredentials()
25
- debug("Successo na checagem de credenciais")
50
+ debug("Sucesso na checagem de credenciais")
26
51
  } catch (error) {
27
52
  this.sendErrorToAnalytics("checkCredentials.error", error)
28
53
 
29
- debug("ERRO na checagem de credenciais", {message: error?.message, error})
30
- console.error("\nError: ", {message: error?.message, error})
54
+ const friendlyErrorMessage = `Por favor, execute o comando 'eitri login' para configurar suas credenciais`
55
+ console.log(`\n\x1b[1m\x1b[31m${friendlyErrorMessage}\x1b[0m\n`);
56
+
57
+ if(args?.verbose) {
58
+ debug("ERRO na checagem de credenciais", {message: error?.message, error})
59
+ console.error("\nError: ", {message: error?.message, error})
60
+ }
61
+
31
62
  process.exit(1);
32
63
  }
33
64
  }
34
65
 
35
66
  async isUserInOrg() {
36
- const eitriAppConf = workspace.getMiniConf();
37
-
38
- const respEitriAppData = await this.http.get(`${MANAGER_URL}/v2/eitri-apps/${eitriAppConf.id}`);
39
- const respMyOrgsData = await this.http.get(`${MANAGER_URL}/users/me/organizations`);
67
+ try {
68
+ const eitriAppConf = workspace.getMiniConf();
69
+
70
+ const respEitriAppData = await this.http.get(`${MANAGER_URL}/v2/eitri-apps/${eitriAppConf.id}`);
71
+ const respMyOrgsData = this.userOrgsData
72
+
73
+ const belongTo = respMyOrgsData?.some(org => org?.id === respEitriAppData?.organizationId)
74
+ const myOrgs = respMyOrgsData?.length > 0
75
+ if (myOrgs && belongTo) {
76
+ return
77
+ }
78
+
79
+ } catch (error) {
80
+ this.sendErrorToAnalytics("isUserInOrg.error", {organizations: this.userOrgsData})
40
81
 
41
- const belongTo = respMyOrgsData?.some(org => org?.id === respEitriAppData?.organizationId)
42
- const myOrgs = respMyOrgsData?.length > 0
43
- if (myOrgs && belongTo) {
44
- return
82
+ if (args?.verbose) {
83
+ debug("ERRO na verificação de conexão", {message: error?.message, error})
84
+ console.error("\nError: \n", {message: error?.message, errorData: error?.response?.data})
85
+ }
86
+
87
+ const friendlyErrorMessage = `Você ainda não foi registrado em nenhuma organização ou não pertence a organização deste Eitri-App. \n Por favor, entre em contato com o administrador da sua organização.`
88
+ console.log(`\n\x1b[1m\x1b[31m ${friendlyErrorMessage} \x1b[0m\n`)
89
+ process.exit(1)
45
90
  }
46
-
47
- this.sendErrorToAnalytics("isUserInOrg.error", {confOrgId: respEitriAppData.organizationId, organizations: respMyOrgsData})
48
-
49
- const friendlyErrorMessage = `Você ainda não foi registrado em nenhuma organização ou não pertence a organização deste Eitri-App. \n Por favor, entre em contato com o administrador da sua organização.`
50
- console.log(`\n\x1b[1m\x1b[31m ${friendlyErrorMessage} \x1b[0m\n`)
51
- process.exit(1)
52
91
  }
53
92
 
54
93
  async getUserBasicInfo() {