eitri-cli 1.14.0 → 1.15.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.
- package/bitbucket-pipelines.yml +4 -0
- 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/index.js +8 -0
- package/package.json +1 -1
- package/src/cmd/loginV2.js +89 -0
- package/src/cmd/push-version.js +5 -4
- package/src/service/BlindGuardian.js +1 -1
- package/src/service/MiniLog.js +40 -0
- package/src/service/PrerequisitesValidator.js +1 -1
- package/src/service/Workspace.js +4 -14
package/bitbucket-pipelines.yml
CHANGED
|
@@ -11,6 +11,8 @@ pipelines:
|
|
|
11
11
|
caches:
|
|
12
12
|
- node
|
|
13
13
|
script:
|
|
14
|
+
- apt-get update && apt-get install -y dnsutils
|
|
15
|
+
- dig +short ns eitri.tech
|
|
14
16
|
- cd eitri-cli-v2
|
|
15
17
|
- npm i
|
|
16
18
|
- npm i puppeteer@21.4.1
|
|
@@ -26,6 +28,8 @@ pipelines:
|
|
|
26
28
|
caches:
|
|
27
29
|
- node
|
|
28
30
|
script:
|
|
31
|
+
- apt-get update && apt-get install -y dnsutils
|
|
32
|
+
- dig +short ns eitri.tech
|
|
29
33
|
- cd eitri-cli-v2
|
|
30
34
|
- npm i
|
|
31
35
|
- npm i puppeteer@21.4.1
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -40,7 +40,15 @@ const run = async () => {
|
|
|
40
40
|
"Configura suas credenciais de desenvolvedor no dispositivo local"
|
|
41
41
|
)
|
|
42
42
|
.option("--yes", "Aceita o redirecionamento para o console")
|
|
43
|
+
.option("-v, --verbose", "Exibe mais logs")
|
|
43
44
|
.action(async (cmdObj) => {
|
|
45
|
+
const isLoginV2 = process.env.FT_LOGIN_V2
|
|
46
|
+
if (isLoginV2) {
|
|
47
|
+
console.log("\n\n Iniciando login (v2) \n");
|
|
48
|
+
require("./src/cmd/loginV2")(cmdObj);
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
require("./src/cmd/login")(cmdObj);
|
|
45
53
|
});
|
|
46
54
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const configService = require("../service/ConfigService");
|
|
2
|
+
const open = require("open");
|
|
3
|
+
const inquirer = require("inquirer");
|
|
4
|
+
const TrackingEitriAnalytics = require("../service/TrackingEitriAnalytics");
|
|
5
|
+
const MiniLog = require('../service/MiniLog')
|
|
6
|
+
const config = require('../service/ConfigService')
|
|
7
|
+
const {randomUUID} = require('crypto')
|
|
8
|
+
const CliLogin = require('../service/CliLogin')
|
|
9
|
+
module.exports = async function loginV2(args) {
|
|
10
|
+
try {
|
|
11
|
+
const roomName = randomUUID()?.toString()
|
|
12
|
+
|
|
13
|
+
const consoleUrl = `${configService.get("managerFront").url}`;
|
|
14
|
+
const consoleUrlWithParams = `${consoleUrl}?version=2&loginType=EITRI_CLI&callbackId=${roomName}`;
|
|
15
|
+
|
|
16
|
+
if(args.verbose){
|
|
17
|
+
console.log('Console Login URL: ', consoleUrlWithParams);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (args.yes) {
|
|
21
|
+
openConsole(consoleUrlWithParams)
|
|
22
|
+
} else {
|
|
23
|
+
const {openPortalAnwser} = await inquirer.prompt([
|
|
24
|
+
{
|
|
25
|
+
type: "confirm",
|
|
26
|
+
name: "openPortalAnwser",
|
|
27
|
+
message: " Podemos redirecioná-lo para o login?",
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
if (openPortalAnwser) {
|
|
32
|
+
openConsole(consoleUrlWithParams)
|
|
33
|
+
} else {
|
|
34
|
+
const message = "\n Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. "
|
|
35
|
+
console.log(message,consoleUrlWithParams);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(`\n\n Aguardando autenticação...`);
|
|
40
|
+
|
|
41
|
+
const miniLog = new MiniLog(config.get('miniLog'))
|
|
42
|
+
await miniLog.connectGeneric({
|
|
43
|
+
roomName: roomName.toString(),
|
|
44
|
+
args,
|
|
45
|
+
skipLogs: true,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const resp = await miniLog.awaitForGenerateLoginCrendetials()
|
|
49
|
+
|
|
50
|
+
process.stdin.resume()
|
|
51
|
+
|
|
52
|
+
if(resp.key === "credential"){
|
|
53
|
+
const {email, credential} = resp
|
|
54
|
+
|
|
55
|
+
await new CliLogin().saveCredentials({
|
|
56
|
+
email,
|
|
57
|
+
credential
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
} catch (error) {
|
|
62
|
+
TrackingEitriAnalytics.sendEvent({
|
|
63
|
+
eventName: "login.error",
|
|
64
|
+
data: {
|
|
65
|
+
errorMessage: error?.message ?? "",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(
|
|
70
|
+
"Erro inesperado, tente novamente mais tarde.",
|
|
71
|
+
error?.message
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
function openConsole(consoleUrl = "", acceptedToOpenConsole = false) {
|
|
79
|
+
let message = ""
|
|
80
|
+
try {
|
|
81
|
+
open(consoleUrl);
|
|
82
|
+
message = "Aberto em seu navegador padrão";
|
|
83
|
+
} catch (error) {
|
|
84
|
+
message =
|
|
85
|
+
"Não foi possível abrir automaticamente. Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. " +
|
|
86
|
+
consoleUrl;
|
|
87
|
+
}
|
|
88
|
+
console.log("\n", message);
|
|
89
|
+
}
|
package/src/cmd/push-version.js
CHANGED
|
@@ -2,7 +2,6 @@ const path = require('path')
|
|
|
2
2
|
const { workspace } = require('../service/Workspace')
|
|
3
3
|
const validator = require('./validate')
|
|
4
4
|
const MiniLog = require('../service/MiniLog')
|
|
5
|
-
const TrackingService = require('../service/TrackingService')
|
|
6
5
|
const fs = require('fs')
|
|
7
6
|
const config = require('../service/ConfigService')
|
|
8
7
|
const TargetService = require('../service/TargetService')
|
|
@@ -22,6 +21,7 @@ const prerequisitesValidator = new PrerequisitesValidator(workspace)
|
|
|
22
21
|
|
|
23
22
|
module.exports = async function pushVersion(cmdObj) {
|
|
24
23
|
prerequisitesValidator.checkCredentials()
|
|
24
|
+
await prerequisitesValidator.isUserInOrg()
|
|
25
25
|
|
|
26
26
|
const {slug: miniConfSlug} = workspace.getMiniConf()
|
|
27
27
|
await vegvisirService.isCurrentWorkspaceOwnedByUser(miniConfSlug)
|
|
@@ -149,7 +149,7 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
149
149
|
LogVerbose(cmdObj.verbose, "\n Analizando versões...")
|
|
150
150
|
|
|
151
151
|
const { target } = await workspace.checkVersions();
|
|
152
|
-
LogSuccess("5/
|
|
152
|
+
LogSuccess("5/7 ✓ Versões das bibliotecas analizadas.");
|
|
153
153
|
|
|
154
154
|
LogVerbose(cmdObj.verbose, " ✓ Preparando os arquivos do seu Eitri-App...")
|
|
155
155
|
|
|
@@ -157,14 +157,15 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
157
157
|
await workspace.uploadCleanZip(isDevMode);
|
|
158
158
|
LogVerbose(cmdObj.verbose, " ✓ Arquivos preparados")
|
|
159
159
|
|
|
160
|
-
LogSuccess("6/
|
|
160
|
+
LogSuccess("6/7 ✓ Gerando versão do Eitri-App");
|
|
161
161
|
|
|
162
162
|
const start = Date.now()
|
|
163
163
|
let pushVersionPromise = miniLog.awaitForPushVersion()
|
|
164
164
|
await workspace.pushVersionAsJson(cmdObj)
|
|
165
165
|
await pushVersionPromise
|
|
166
|
+
LogSuccess("7/7 ✓ Concluído");
|
|
167
|
+
|
|
166
168
|
console.log(separator)
|
|
167
|
-
LogSuccess("Sucesso!")
|
|
168
169
|
console.log(`\x1b[1mA versão [${miniConf.version}] do seu Eitri-App foi enviada e está\x1b[0m`);
|
|
169
170
|
console.log('\x1b[1mdisponível no Eitri Console em \x1b[0m');
|
|
170
171
|
|
|
@@ -74,7 +74,7 @@ class BlindGuardian {
|
|
|
74
74
|
|
|
75
75
|
const clientCredentials = this.readClientCredentials()
|
|
76
76
|
try {
|
|
77
|
-
const url = `${this.blindGuardianUrl}/
|
|
77
|
+
const url = `${this.blindGuardianUrl}/v2/o/auth`
|
|
78
78
|
const options = {
|
|
79
79
|
headers: {
|
|
80
80
|
'User-Agent': configService.get('userAgent'),
|
package/src/service/MiniLog.js
CHANGED
|
@@ -30,6 +30,35 @@ class MiniLog {
|
|
|
30
30
|
})
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
connectGeneric({roomName, args, skipLogs}) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const socket = this.createSocket()
|
|
36
|
+
socket.on('connect', () => {
|
|
37
|
+
if(args?.verbose) {
|
|
38
|
+
console.log('🔗 Conectando em: ', {roomName, args})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
socket.emit('joinRoom', roomName)
|
|
42
|
+
resolve()
|
|
43
|
+
})
|
|
44
|
+
socket.on('connect_error', (e) => {
|
|
45
|
+
if (args?.verbose) {
|
|
46
|
+
console.error('Não foi possível contectar em: ', {roomName})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
reject(e)
|
|
50
|
+
})
|
|
51
|
+
socket.on('onLog', (data) => {
|
|
52
|
+
if(!skipLogs){
|
|
53
|
+
const message = this._colorizeMessage(data?.msg, data.method)
|
|
54
|
+
const consoleProp = data?.method ? data.method : "log"
|
|
55
|
+
console[consoleProp](message);
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
this.socket = socket
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
33
62
|
awaitForPushVersion() {
|
|
34
63
|
return new Promise((resolve, reject) => {
|
|
35
64
|
this.socket.on('onLog', (event) => {
|
|
@@ -46,6 +75,17 @@ class MiniLog {
|
|
|
46
75
|
})
|
|
47
76
|
}
|
|
48
77
|
|
|
78
|
+
awaitForGenerateLoginCrendetials() {
|
|
79
|
+
return new Promise((resolve) => {
|
|
80
|
+
this.socket.on('onLog', (event) => {
|
|
81
|
+
if(event.eventKey === "loginCredentials"){
|
|
82
|
+
console.log("\n\n Iniciando configuração das suas credenciais...\n\n")
|
|
83
|
+
resolve(event.credentials)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
49
89
|
createSocket() {
|
|
50
90
|
if (this._config.path) {
|
|
51
91
|
return io.connect(this._config.url, { path: this._config.path, transport: 'websocket' })
|
|
@@ -46,7 +46,7 @@ class PrerequisitesValidator {
|
|
|
46
46
|
|
|
47
47
|
this.sendErrorToAnalytics("isUserInOrg.error", {confOrgId: respEitriAppData.organizationId, organizations: respMyOrgsData})
|
|
48
48
|
|
|
49
|
-
const friendlyErrorMessage = `Você ainda não foi registrado em nenhuma organização. Por favor, entre em contato com o administrador da sua organização.`
|
|
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
50
|
console.log(`\n\x1b[1m\x1b[31m ${friendlyErrorMessage} \x1b[0m\n`)
|
|
51
51
|
process.exit(1)
|
|
52
52
|
}
|
package/src/service/Workspace.js
CHANGED
|
@@ -301,14 +301,14 @@ class Workspace {
|
|
|
301
301
|
eitriConf,
|
|
302
302
|
headers
|
|
303
303
|
);
|
|
304
|
-
LogSuccess("1/
|
|
304
|
+
LogSuccess("1/7 ✓ Preparando ambiente de desenvolvimento")
|
|
305
305
|
const response = await this.http.put(
|
|
306
306
|
`${this.serverUrl}/${this.basePath}/version?command=push-version`,
|
|
307
307
|
eitriConf,
|
|
308
308
|
headers
|
|
309
309
|
);
|
|
310
310
|
|
|
311
|
-
LogSuccess("2/
|
|
311
|
+
LogSuccess("2/7 ✓ Ambiente de desenvolvimento preparado")
|
|
312
312
|
|
|
313
313
|
eitriConf.target = response.application;
|
|
314
314
|
const availableTargets = await this.availableTargets();
|
|
@@ -316,7 +316,7 @@ class Workspace {
|
|
|
316
316
|
eitriConf,
|
|
317
317
|
availableTargets
|
|
318
318
|
);
|
|
319
|
-
LogSuccess("3/
|
|
319
|
+
LogSuccess("3/7 ✓ Ambiente pronto para compilação.");
|
|
320
320
|
|
|
321
321
|
const eitriConfProperties = Object.getOwnPropertyNames(eitriConf)
|
|
322
322
|
const clientName = eitriConfProperties.find(p => p === libs.bifrost) || TargetService.LIBS_FOR_TARGET.MOBILE_NEW.bifrost
|
|
@@ -325,7 +325,7 @@ class Workspace {
|
|
|
325
325
|
const bifrostVersion = eitriConf[clientName]
|
|
326
326
|
const luminusVersion = eitriConf[componentsName]
|
|
327
327
|
|
|
328
|
-
LogSuccess(`4/
|
|
328
|
+
LogSuccess(`4/7 ✓ Criando versão com as bibliotecas: ${clientName} [${bifrostVersion}] | ${componentsName} [${luminusVersion}]`);
|
|
329
329
|
return { target: response.target };
|
|
330
330
|
} catch (error) {
|
|
331
331
|
console.log(`\x1b[1m\x1b[31m${error.message}\x1b[0m`);
|
|
@@ -493,16 +493,6 @@ class Workspace {
|
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
const isValidConfigs = startAppsConfig.applicationId
|
|
497
|
-
&& startAppsConfig.devEnvKey
|
|
498
|
-
&& startAppsConfig.focusedEitriApp
|
|
499
|
-
&& startAppsConfig.environmentId
|
|
500
|
-
&& startAppsConfig.workspaces?.length > 0
|
|
501
|
-
|
|
502
|
-
if(!isValidConfigs){
|
|
503
|
-
return
|
|
504
|
-
}
|
|
505
|
-
|
|
506
496
|
const fakerDevEnvKey = `dev-${new Date().getTime()}-${workspaceFocused}`
|
|
507
497
|
return {
|
|
508
498
|
focusedEitriApp,
|