eitri-cli 1.1.2 → 1.1.4-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 +1 -1
- package/check-version.js +4 -3
- package/package.json +2 -2
- package/src/cmd/login.js +6 -6
- package/src/cmd/push-version.js +3 -3
- package/src/cmd/version.js +1 -1
- package/src/service/CliLogin.js +1 -3
- package/src/service/QRCodeFactory.js +20 -4
- package/src/service/factories/QRCodeStarterFactory.js +11 -19
- package/src/util/GenericUtils.js +19 -0
package/bitbucket-pipelines.yml
CHANGED
package/check-version.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const semver = require('semver')
|
|
2
2
|
const packageJson = require('./package')
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const minVersion = packageJson.engines.node
|
|
5
5
|
|
|
6
6
|
const systemVersion = semver.clean(process.version)
|
|
7
7
|
|
|
8
8
|
if (!semver.satisfies(systemVersion, minVersion)){
|
|
9
|
-
console.error('
|
|
10
|
-
console.error('Por favor,
|
|
9
|
+
console.error(' O Eitri-CLI requer uma versão mais recente do Node.js')
|
|
10
|
+
console.error(' Por favor, atualize o Node.js para a versão mínima necessária: ', minVersion)
|
|
11
|
+
console.error(' Versão atual em seu dispositivo: ', systemVersion)
|
|
11
12
|
process.exit(1)
|
|
12
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eitri-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4-beta.1",
|
|
4
4
|
"description": "Command Line Interface to make \"eitri app\" with code and fire.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build": "echo \"no build\""
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": ">=16.0.0",
|
|
17
17
|
"npm": ">=3.0.0"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [],
|
package/src/cmd/login.js
CHANGED
|
@@ -6,13 +6,13 @@ const Server = require('../service/Server')
|
|
|
6
6
|
|
|
7
7
|
module.exports = async function login(args) {
|
|
8
8
|
try {
|
|
9
|
-
console.log("
|
|
9
|
+
console.log("==========================================\n\n")
|
|
10
10
|
|
|
11
11
|
const {openPortalAnwser} = await inquirer.prompt([
|
|
12
12
|
{
|
|
13
13
|
type: 'confirm',
|
|
14
14
|
name: 'openPortalAnwser',
|
|
15
|
-
message: ' Podemos
|
|
15
|
+
message: ' Podemos guiá-lo até o nosso sagrado portal?',
|
|
16
16
|
},
|
|
17
17
|
])
|
|
18
18
|
|
|
@@ -24,19 +24,19 @@ module.exports = async function login(args) {
|
|
|
24
24
|
let portalOpenMessage = ""
|
|
25
25
|
|
|
26
26
|
if (openPortalAnwser) {
|
|
27
|
-
console.log("\n", "
|
|
27
|
+
console.log("\n", "Abrindo o portal...")
|
|
28
28
|
try {
|
|
29
29
|
open(urlAdminManagerCredentialWithParams)
|
|
30
|
-
portalOpenMessage = "
|
|
30
|
+
portalOpenMessage = "Portal aberto em seu navegador padrão"
|
|
31
31
|
} catch (error) {
|
|
32
|
-
portalOpenMessage = "Não foi possível abrir
|
|
32
|
+
portalOpenMessage = "Não foi possível abrir o portal. Você terá que fazer isso dessa vez. Copie o link e cole em seu navegador para fazer o login na Eitri CLI. " + urlAdminManagerCredentialWithParams
|
|
33
33
|
}
|
|
34
34
|
} else {
|
|
35
35
|
portalOpenMessage = "Copie o link e cole em seu navegador para fazer o login na Eitri CLI. " + urlAdminManagerCredentialWithParams
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
console.log("\n", portalOpenMessage)
|
|
39
|
-
console.log("\n\n Aguardando autenticação...")
|
|
39
|
+
console.log("\n\n Aguardando pela autenticação...")
|
|
40
40
|
} catch (error) {
|
|
41
41
|
await TrackingEitriAnalytics.sendEvent({
|
|
42
42
|
command: "login",
|
package/src/cmd/push-version.js
CHANGED
|
@@ -72,7 +72,7 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
72
72
|
const separator = '======================================================================='
|
|
73
73
|
blindGuardian.readConf()
|
|
74
74
|
workspace.setServerUrl(config.get('workspace').url)
|
|
75
|
-
console.log('Conectando
|
|
75
|
+
console.log('Conectando à forja de Eitri')
|
|
76
76
|
await workspace.init()
|
|
77
77
|
const userWorkspace = await getWorkspace()
|
|
78
78
|
await miniLog.connect(userWorkspace.id)
|
|
@@ -101,7 +101,7 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
101
101
|
console.log(separator)
|
|
102
102
|
console.log('\x1b[1m\x1b[32mSucesso!!\x1b[0m');
|
|
103
103
|
console.log(`\x1b[1mA versão [${miniConf.version}] do seu eitri-app foi gerada e está\x1b[0m`);
|
|
104
|
-
console.log('\x1b[1mdisponível no Eitri
|
|
104
|
+
console.log('\x1b[1mdisponível no Eitri-console para aprovação\x1b[0m');
|
|
105
105
|
console.log(separator)
|
|
106
106
|
|
|
107
107
|
await TrackingEitriAnalytics.sendEvent({
|
|
@@ -125,7 +125,7 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
125
125
|
} else if (e && e.message) {
|
|
126
126
|
console.log(`\x1b[1m\x1b[31m${e.message}\x1b[0m`);
|
|
127
127
|
} else {
|
|
128
|
-
console.log(`\x1b[1m\x1b[31mNão será possível continuar por enquanto.
|
|
128
|
+
console.log(`\x1b[1m\x1b[31mNão será possível continuar por enquanto. A forja encontrou um erro.\x1b[0m`);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
await TrackingEitriAnalytics.sendEvent({
|
package/src/cmd/version.js
CHANGED
|
@@ -14,7 +14,7 @@ function version() {
|
|
|
14
14
|
`\n> Você está usando a versão ${packageJson.version}, temos uma nova versão: ${publishedVersion}!`
|
|
15
15
|
)
|
|
16
16
|
console.log(
|
|
17
|
-
`> Para atualizar use o comando:
|
|
17
|
+
`> Para atualizar use o comando: ${packageJson.name} self-update`
|
|
18
18
|
)
|
|
19
19
|
} else {
|
|
20
20
|
console.log(packageJson.version)
|
package/src/service/CliLogin.js
CHANGED
|
@@ -27,8 +27,6 @@ class CliLogin {
|
|
|
27
27
|
process.exit(1)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
console.log("\n", "Eis que a jornada tem início...")
|
|
31
|
-
|
|
32
30
|
await new UserLocalCredential().asyncSaveContent({devUser, devKey})
|
|
33
31
|
TrackingEitriAnalytics.sendEvent({
|
|
34
32
|
command: "login",
|
|
@@ -38,7 +36,7 @@ class CliLogin {
|
|
|
38
36
|
devUser
|
|
39
37
|
}
|
|
40
38
|
})
|
|
41
|
-
console.log("\n", `✔
|
|
39
|
+
console.log("\n", `✔ Credencial gerada! Você está logado como ${email}.`)
|
|
42
40
|
process.exit(0)
|
|
43
41
|
}
|
|
44
42
|
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
const tmp = require('tmp')
|
|
2
2
|
const qrcode = require('qrcode')
|
|
3
|
+
const GenericUtils = require('../util/GenericUtils')
|
|
4
|
+
const qrcodeTerminal = require('qrcode-terminal')
|
|
5
|
+
const open = require('open')
|
|
3
6
|
|
|
4
7
|
// Fabrica de QR code :-)
|
|
5
8
|
class QRCodeFactory {
|
|
6
|
-
|
|
9
|
+
|
|
10
|
+
generate(args) {
|
|
11
|
+
if (args?.qrPrinter) {
|
|
12
|
+
console.log(`Abrindo QR-Code no ${args?.qrPrinter}`)
|
|
13
|
+
open(args?.qrCodePath, {app: args?.qrPrinter})
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
qrcodeTerminal.generate(args?.fullUrl ?? "", {small: true})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async create(data, eitriAppSlug = "") {
|
|
7
21
|
console.log('==================================================')
|
|
8
22
|
console.log('Utilize o QR-Code para iniciar o seu eitri-app')
|
|
9
23
|
console.log('É importante utilizar o leitor de QR-Code do')
|
|
10
24
|
console.log('aplicativo à qual destina-se o seu eitri-app')
|
|
11
25
|
console.log('==================================================')
|
|
12
|
-
|
|
26
|
+
const qrCodeTempPath = await this.tempFile(eitriAppSlug)
|
|
13
27
|
await this.createQRCodeImage(qrCodeTempPath, data)
|
|
14
28
|
return qrCodeTempPath
|
|
15
29
|
}
|
|
@@ -25,10 +39,12 @@ class QRCodeFactory {
|
|
|
25
39
|
})
|
|
26
40
|
}
|
|
27
41
|
|
|
28
|
-
tempFile() {
|
|
42
|
+
tempFile(eitriAppSlug = "") {
|
|
29
43
|
return new Promise((resolve, reject) => {
|
|
44
|
+
const currentDateTime = GenericUtils.formatQrCodeCurrentDateTime()
|
|
45
|
+
const qrCodeName = `[eitri] ${eitriAppSlug} ${currentDateTime}.png`
|
|
30
46
|
tmp.file(
|
|
31
|
-
{
|
|
47
|
+
{ name: qrCodeName, keep: true },
|
|
32
48
|
function (err, tempPath) {
|
|
33
49
|
if (err) {
|
|
34
50
|
return reject(err)
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
const QRCodeFactory = require('../QRCodeFactory')
|
|
2
|
-
const TrackService = require('../TrackService')
|
|
3
|
-
const Server = require('../Server')
|
|
4
|
-
const qrcodeTerminal = require('qrcode-terminal')
|
|
5
|
-
const TERMINAL_PRINTER_NAME = 'terminal'
|
|
6
2
|
|
|
7
3
|
function QRCodeStarter(args, trackingService, watcher, workspace, targetConfig ) {
|
|
8
4
|
this.args = args
|
|
@@ -23,22 +19,8 @@ function QRCodeStarter(args, trackingService, watcher, workspace, targetConfig )
|
|
|
23
19
|
if (this.args.verbose) {
|
|
24
20
|
console.log(`QrCodeUrl: ${fullUrl}`)
|
|
25
21
|
}
|
|
26
|
-
const qrCodePath = await new QRCodeFactory().create(fullUrl)
|
|
27
|
-
|
|
28
|
-
if (this.args.verbose) {
|
|
29
|
-
console.log(`QrCode Path: ${qrCodePath}`)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if(process.env.AAT_QRCODE_PRINTER === TERMINAL_PRINTER_NAME || this.args.qrPrinter === TERMINAL_PRINTER_NAME) {
|
|
33
|
-
qrcodeTerminal.generate(fullUrl, {small: true})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const libsInfoForGA = this.args.libsInfoForGA
|
|
37
22
|
|
|
38
23
|
this.watcher.start()
|
|
39
|
-
let miniConf = this.workspace.getMiniConf()
|
|
40
|
-
TrackService.track(miniConf, this.trackingService, libsInfoForGA)
|
|
41
|
-
// tryToOpenAndroidEmulator(fullUrl, this.args)
|
|
42
24
|
if(this.args.showDeeplink){
|
|
43
25
|
console.log('######################################')
|
|
44
26
|
console.log('########### Deep Link URL ############')
|
|
@@ -46,7 +28,17 @@ function QRCodeStarter(args, trackingService, watcher, workspace, targetConfig )
|
|
|
46
28
|
console.log(`${fullUrl}`)
|
|
47
29
|
console.log('######################################')
|
|
48
30
|
}
|
|
49
|
-
|
|
31
|
+
|
|
32
|
+
const _QRCodeFactory = new QRCodeFactory()
|
|
33
|
+
|
|
34
|
+
const eitriAppSlug = this.workspace?._miniConf?.slug ?? ""
|
|
35
|
+
const qrCodePath = await _QRCodeFactory.create(fullUrl, eitriAppSlug)
|
|
36
|
+
|
|
37
|
+
if (this.args.verbose) {
|
|
38
|
+
console.log(`QrCode Path: ${qrCodePath}`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_QRCodeFactory.generate({...this.args, qrCodePath, fullUrl})
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
44
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class GenericUtils {
|
|
2
|
+
|
|
3
|
+
static formatQrCodeCurrentDateTime = () => {
|
|
4
|
+
const now = new Date();
|
|
5
|
+
|
|
6
|
+
const year = now.getFullYear();
|
|
7
|
+
const month = String(now.getMonth() + 1).padStart(2, '0'); // Mês começa em 0, então adicionamos 1 e formatamos com zero à esquerda, se necessário.
|
|
8
|
+
const day = String(now.getDate()).padStart(2, '0');
|
|
9
|
+
const hours = String(now.getHours()).padStart(2, '0');
|
|
10
|
+
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
11
|
+
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
12
|
+
|
|
13
|
+
const formattedDateTime = `${hours}:${minutes}:${seconds} ${day}-${month}-${year}`;
|
|
14
|
+
return formattedDateTime;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = GenericUtils
|