eitri-cli 1.27.1-beta.3 → 1.27.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.
- package/eitri-cli-v2/eitri-cli-v2.darwin-arm64.node +0 -0
- package/eitri-cli-v2/eitri-cli-v2.darwin-x64.node +0 -0
- package/eitri-cli-v2/eitri-cli-v2.linux-x64-gnu.node +0 -0
- package/eitri-cli-v2/eitri-cli-v2.win32-x64-msvc.node +0 -0
- package/eitri-cli-v2/index.d.ts +1 -0
- package/eitri-cli-v2/index.js +2 -1
- package/index.js +3 -6
- package/package.json +1 -1
- package/src/service/PrerequisitesValidator.js +12 -36
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/eitri-cli-v2/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare function doctor(): Promise<void>
|
|
|
25
25
|
export declare function start(args: StartArguments): Promise<void>
|
|
26
26
|
export declare function create(args: CreateArguments): Promise<void>
|
|
27
27
|
export declare function updateChecker(): void
|
|
28
|
+
export declare function connectionCheck(): Promise<void>
|
|
28
29
|
export declare namespace app {
|
|
29
30
|
export function start(args: StartArguments): Promise<void>
|
|
30
31
|
export function appLogs(): Promise<void>
|
package/eitri-cli-v2/index.js
CHANGED
|
@@ -310,7 +310,7 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { publish, runTest, eitriLibs, doctor, start, create, updateChecker, app, workspace } = nativeBinding
|
|
313
|
+
const { publish, runTest, eitriLibs, doctor, start, create, updateChecker, connectionCheck, app, workspace } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.publish = publish
|
|
316
316
|
module.exports.runTest = runTest
|
|
@@ -319,5 +319,6 @@ module.exports.doctor = doctor
|
|
|
319
319
|
module.exports.start = start
|
|
320
320
|
module.exports.create = create
|
|
321
321
|
module.exports.updateChecker = updateChecker
|
|
322
|
+
module.exports.connectionCheck = connectionCheck
|
|
322
323
|
module.exports.app = app
|
|
323
324
|
module.exports.workspace = workspace
|
package/index.js
CHANGED
|
@@ -52,8 +52,10 @@ const run = async () => {
|
|
|
52
52
|
if (hasCommandsList) {
|
|
53
53
|
const command = process.argv[2];
|
|
54
54
|
|
|
55
|
+
const showCheckConnection = command !== "version" && command !== "-v"
|
|
55
56
|
const showCheckUpdate = command !== "--version" && command !== "-v" && command !== "self-update";;
|
|
56
57
|
|
|
58
|
+
if (showCheckConnection) await globalEitriCLIV2.connectionCheck();
|
|
57
59
|
if (showCheckUpdate) globalEitriCLIV2.updateChecker();
|
|
58
60
|
}
|
|
59
61
|
} catch (error) {
|
|
@@ -155,12 +157,7 @@ const run = async () => {
|
|
|
155
157
|
)
|
|
156
158
|
.option("-v, --verbose", "Exibe mais logs")
|
|
157
159
|
.action(async (cmdObj) => {
|
|
158
|
-
|
|
159
|
-
console.log("clean (v2)");
|
|
160
|
-
const eitriCLIV2 = require("./eitri-cli-v2/index.js");
|
|
161
|
-
return await eitriCLIV2.workspace.clean();
|
|
162
|
-
}
|
|
163
|
-
require("./src/cmd/clean")(cmdObj);
|
|
160
|
+
return await globalEitriCLIV2.workspace.clean(cmdObj);
|
|
164
161
|
});
|
|
165
162
|
|
|
166
163
|
program
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ const UserLocalCredential = require('../util/UserLocalCredential');
|
|
|
3
3
|
const Http = require('./Http');
|
|
4
4
|
const TrackingEitriAnalytics = require('./TrackingEitriAnalytics');
|
|
5
5
|
const MANAGER_URL = configService.get('eitriManager')?.url
|
|
6
|
-
const {workspace} = require('../service/Workspace')
|
|
6
|
+
const { workspace } = require('../service/Workspace')
|
|
7
7
|
const debug = require('debug')('eitri:PrerequisitesValidator')
|
|
8
8
|
class PrerequisitesValidator {
|
|
9
9
|
|
|
@@ -11,39 +11,15 @@ class PrerequisitesValidator {
|
|
|
11
11
|
this.workspace = workspace
|
|
12
12
|
this.blindGuardian = workspace.blindGuardian;
|
|
13
13
|
this.http = new Http(workspace.blindGuardian);
|
|
14
|
-
this.userInfo = {id: "", email: ""}
|
|
14
|
+
this.userInfo = { id: "", email: "" }
|
|
15
15
|
this.userOrgsData = []
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async checkAll(args = {}) {
|
|
19
|
-
await this.checkConnection(args)
|
|
20
19
|
this.checkCredentials(args)
|
|
21
20
|
await this.isUserInOrg()
|
|
22
21
|
}
|
|
23
22
|
|
|
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
23
|
checkCredentials(args) {
|
|
48
24
|
try {
|
|
49
25
|
UserLocalCredential.checkForCredentials()
|
|
@@ -54,9 +30,9 @@ class PrerequisitesValidator {
|
|
|
54
30
|
const friendlyErrorMessage = `Por favor, execute o comando 'eitri login' para configurar suas credenciais`
|
|
55
31
|
console.log(`\n\x1b[1m\x1b[31m${friendlyErrorMessage}\x1b[0m\n`);
|
|
56
32
|
|
|
57
|
-
if(args?.verbose) {
|
|
58
|
-
debug("ERRO na checagem de credenciais", {message: error?.message, error})
|
|
59
|
-
console.error("\nError: ", {message: error?.message, error})
|
|
33
|
+
if (args?.verbose) {
|
|
34
|
+
debug("ERRO na checagem de credenciais", { message: error?.message, error })
|
|
35
|
+
console.error("\nError: ", { message: error?.message, error })
|
|
60
36
|
}
|
|
61
37
|
|
|
62
38
|
process.exit(1);
|
|
@@ -66,24 +42,24 @@ class PrerequisitesValidator {
|
|
|
66
42
|
async isUserInOrg() {
|
|
67
43
|
try {
|
|
68
44
|
const eitriAppConf = workspace.getMiniConf();
|
|
69
|
-
|
|
45
|
+
|
|
70
46
|
const respEitriAppData = await this.http.get(`${MANAGER_URL}/v2/eitri-apps/${eitriAppConf.id}`);
|
|
71
47
|
const respMyOrgsData = this.userOrgsData
|
|
72
|
-
|
|
48
|
+
|
|
73
49
|
const belongTo = respMyOrgsData?.some(org => org?.id === respEitriAppData?.organizationId)
|
|
74
50
|
const myOrgs = respMyOrgsData?.length > 0
|
|
75
51
|
if (myOrgs && belongTo) {
|
|
76
52
|
return
|
|
77
53
|
}
|
|
78
|
-
|
|
54
|
+
|
|
79
55
|
} catch (error) {
|
|
80
|
-
this.sendErrorToAnalytics("isUserInOrg.error", {organizations: this.userOrgsData})
|
|
56
|
+
this.sendErrorToAnalytics("isUserInOrg.error", { organizations: this.userOrgsData })
|
|
81
57
|
|
|
82
58
|
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})
|
|
59
|
+
debug("ERRO na verificação de conexão", { message: error?.message, error })
|
|
60
|
+
console.error("\nError: \n", { message: error?.message, errorData: error?.response?.data })
|
|
85
61
|
}
|
|
86
|
-
|
|
62
|
+
|
|
87
63
|
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
64
|
console.log(`\n\x1b[1m\x1b[31m ${friendlyErrorMessage} \x1b[0m\n`)
|
|
89
65
|
process.exit(1)
|