eitri-cli 1.1.3 → 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/index.js +85 -23
- package/package.json +2 -2
- package/src/cmd/clean.js +40 -0
- package/src/cmd/login.js +6 -6
- package/src/cmd/push-version.js +4 -8
- package/src/cmd/validate.js +6 -0
- package/src/cmd/version.js +1 -1
- package/src/modules/vegvisir/VegvisirCommand.js +1 -3
- package/src/service/CliLogin.js +1 -3
- package/src/service/MiniLog.js +1 -18
- package/src/service/QRCodeFactory.js +20 -4
- package/src/service/Workspace.js +73 -13
- package/src/service/factories/QRCodeStarterFactory.js +11 -19
- package/src/util/GenericUtils.js +19 -0
- package/src/service/EitriAppService.js +0 -49
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/index.js
CHANGED
|
@@ -20,10 +20,12 @@ const run = async () => {
|
|
|
20
20
|
// Continuando como antes...
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
program
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
program
|
|
24
|
+
.option('-v, --version', 'Mostra a versao da CLI')
|
|
25
|
+
.action(() => {
|
|
26
|
+
const {version} = require('./src/cmd/version')
|
|
27
|
+
version()
|
|
28
|
+
})
|
|
27
29
|
|
|
28
30
|
program
|
|
29
31
|
.command("login")
|
|
@@ -36,7 +38,9 @@ const run = async () => {
|
|
|
36
38
|
|
|
37
39
|
program
|
|
38
40
|
.command("create <project-name>")
|
|
39
|
-
.description(
|
|
41
|
+
.description(
|
|
42
|
+
`Cria um projeto com um mini app totalmente funcional. Mais detalhes em ${config?.doc?.createUrl}`
|
|
43
|
+
)
|
|
40
44
|
.option(
|
|
41
45
|
"--yes",
|
|
42
46
|
"Aceita os valores default para nome titulo e organizacao"
|
|
@@ -45,7 +49,7 @@ const run = async () => {
|
|
|
45
49
|
"--template <template-name>",
|
|
46
50
|
"Define um boilerplate para a criação do projeto"
|
|
47
51
|
)
|
|
48
|
-
.option("--target", "Define
|
|
52
|
+
.option("--target", "Define a plataforma de execução do Mini App")
|
|
49
53
|
.option("-v, --verbose", "Exibe mais logs")
|
|
50
54
|
.action((projectName, cmdObj) => {
|
|
51
55
|
require("./src/cmd/create")(projectName, cmdObj);
|
|
@@ -111,16 +115,40 @@ const run = async () => {
|
|
|
111
115
|
require("./src/cmd/start")(cmdObj);
|
|
112
116
|
});
|
|
113
117
|
|
|
118
|
+
// program
|
|
119
|
+
// .command('test-initialization-params <initializationParams>')
|
|
120
|
+
// .description('Passa parâmetros em querystring para a inicialização do mini app. ex: "stringChave1=stringValor1&stringChave2=stringValor2..."')
|
|
121
|
+
// .option('-Q, --old-qrcode', 'QR Code legado')
|
|
122
|
+
// .option('-N, --new-qrcode', '(Obsoleto) Novo qrcode')
|
|
123
|
+
// .option('-S, --show-deeplink', 'Exibe o deep link do workspace')
|
|
124
|
+
// .option('-V, --verbose', 'Exibe mais logs')
|
|
125
|
+
// .action((initializationParams, cmdObj) => {
|
|
126
|
+
// if (cmdObj.newQrcode) {
|
|
127
|
+
// console.log('Uso de -N ou --new-qrcode é redundante. O "eitri" já otimiza o Qr Code.')
|
|
128
|
+
// }
|
|
129
|
+
|
|
130
|
+
// require('./src/cmd/test-initialization-params')(initializationParams, cmdObj)
|
|
131
|
+
// })
|
|
132
|
+
|
|
133
|
+
// program
|
|
134
|
+
// .command('order-details <orderId>')
|
|
135
|
+
// .description('Abre o mini app na tela de detalhes da ordem')
|
|
136
|
+
// .option('-l, --local', 'Aponta para o servidor local')
|
|
137
|
+
// .option('-A, --upload-all', 'Sobe todos os arquivos')
|
|
138
|
+
// .action((orderId, cmdObj) => {
|
|
139
|
+
// require('./src/cmd/order-details')(orderId, cmdObj)
|
|
140
|
+
// })
|
|
141
|
+
|
|
114
142
|
program
|
|
115
143
|
.command("push-version")
|
|
116
144
|
.description(
|
|
117
|
-
"Cria e envia um build do
|
|
145
|
+
"Cria e envia um build do mini app para ser avaliado por um revisor antes de ser publicado"
|
|
118
146
|
)
|
|
119
147
|
.option("-l, --local", "Aponta para o servidor local")
|
|
120
148
|
.option("-v, --verbose", "Exibe mais logs")
|
|
121
149
|
.option(
|
|
122
150
|
"-c, --components",
|
|
123
|
-
"Publica o
|
|
151
|
+
"Publica o Eitri-App como biblioteca de components"
|
|
124
152
|
)
|
|
125
153
|
.option(
|
|
126
154
|
"-m, --message <revision-message>",
|
|
@@ -131,27 +159,61 @@ const run = async () => {
|
|
|
131
159
|
require("./src/cmd/push-version")(cmdObj);
|
|
132
160
|
});
|
|
133
161
|
|
|
134
|
-
program
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
162
|
+
// program
|
|
163
|
+
// .command('clean')
|
|
164
|
+
// .description(
|
|
165
|
+
// 'Realiza a limpeza do workspace remoto do desenvolvedor. Útil quando há mal fucionamento na compilação em nuvem do eitri-app.'
|
|
166
|
+
// )
|
|
167
|
+
// .option('-v, --verbose', 'Exibe mais logs')
|
|
168
|
+
// .action(cmdObj => {
|
|
169
|
+
// require('./src/cmd/clean')(cmdObj)
|
|
170
|
+
// })
|
|
143
171
|
|
|
144
172
|
program
|
|
145
173
|
.command("self-update")
|
|
146
174
|
.description("Desinstala a versao antiga e instala a mais nova")
|
|
147
175
|
.action(() => {
|
|
148
|
-
require(
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
)
|
|
152
|
-
})
|
|
176
|
+
require('child_process').execSync(
|
|
177
|
+
'npm uninstall -g eitri-cli && npm i eitri-cli -g',
|
|
178
|
+
{stdio: 'inherit'}
|
|
179
|
+
)
|
|
180
|
+
})
|
|
153
181
|
|
|
154
|
-
program
|
|
182
|
+
// program
|
|
183
|
+
// .command('open-share <share-id>')
|
|
184
|
+
// .description('Abre um compartilhamento do share-api')
|
|
185
|
+
// .action((shareId, cmdObj) =>
|
|
186
|
+
// require('./src/cmd/open-share')(shareId, cmdObj)
|
|
187
|
+
// )
|
|
188
|
+
|
|
189
|
+
// program
|
|
190
|
+
// .command('tail-logs <email>')
|
|
191
|
+
// .description('Para ler logs de prod do email')
|
|
192
|
+
// .action((email, cmdObj) => {
|
|
193
|
+
// require('./src/cmd/tail-logs')(email, cmdObj)
|
|
194
|
+
// })
|
|
195
|
+
|
|
196
|
+
// program
|
|
197
|
+
// .command('invite [email]')
|
|
198
|
+
// .option('--remove', 'Remove o desenvolvedor')
|
|
199
|
+
// .option('--list', 'Lista todos os desenvolvedores')
|
|
200
|
+
// .option('--accept', 'Aceita um convite')
|
|
201
|
+
// .option('-v, --verbose', 'Exibe mais logs')
|
|
202
|
+
// .description('Convida um desenvolvedor para contribuir com o seu miniapp')
|
|
203
|
+
// .action((email, cmdObj) => require('./src/cmd/invite')(email, cmdObj))
|
|
204
|
+
|
|
205
|
+
// program
|
|
206
|
+
// .command('list')
|
|
207
|
+
// .description('Lista as opções de um determinado comando')
|
|
208
|
+
// .option('--template', 'exibe os tipos de templates disponíveis, para gerar um exemplo de projeto.')
|
|
209
|
+
// .action((cmdObj) =>
|
|
210
|
+
// require('./src/cmd/list')(cmdObj))
|
|
211
|
+
|
|
212
|
+
// if (!process.argv.slice(2).length) {
|
|
213
|
+
// program.outputHelp()
|
|
214
|
+
// }
|
|
215
|
+
|
|
216
|
+
program.addCommand(VegvisirCommand());
|
|
155
217
|
|
|
156
218
|
if (
|
|
157
219
|
process.argv.length > 2 &&
|
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/clean.js
CHANGED
|
@@ -12,7 +12,46 @@ const targetService = new TargetService(workspace)
|
|
|
12
12
|
|
|
13
13
|
module.exports = async function clean(cmdObj) {
|
|
14
14
|
try {
|
|
15
|
+
const start = Date.now()
|
|
15
16
|
await validator.assertCommandNotRunning('clean')
|
|
17
|
+
let miniConf = workspace.getMiniConf()
|
|
18
|
+
let validateResult = checkErros(miniConf)
|
|
19
|
+
|
|
20
|
+
if (!validateResult.isSuccess()) {
|
|
21
|
+
console.log(
|
|
22
|
+
'Por favor, verifique atentamente os erros exibidos acima. Siga o exemplo abaixo: ' +
|
|
23
|
+
`
|
|
24
|
+
module.exports = {
|
|
25
|
+
|
|
26
|
+
// Dados da sua empresa
|
|
27
|
+
organization: {
|
|
28
|
+
"name": "Minha Empresa"
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
// Nome do seu mini app
|
|
32
|
+
"name": "Meu Mini App",
|
|
33
|
+
|
|
34
|
+
// Titulo do mini app, que vai em baixo do botao na pagina de transacoes
|
|
35
|
+
"title": "Meu super mini app",
|
|
36
|
+
|
|
37
|
+
// Chave para gerar a ordem/qrcode de pagamento (opcional)
|
|
38
|
+
"public-key": "",
|
|
39
|
+
|
|
40
|
+
// Identificador amigavel para colocar em uma url
|
|
41
|
+
"slug": "com.eitri.loja",
|
|
42
|
+
|
|
43
|
+
// Versao do mini app
|
|
44
|
+
"version": "1.0.0",
|
|
45
|
+
|
|
46
|
+
${await targetService.getAppConfExampleSnippet()}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
`
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return
|
|
54
|
+
}
|
|
16
55
|
|
|
17
56
|
blindGuardian.readConf()
|
|
18
57
|
workspace.setServerUrl(config.get('workspace').url)
|
|
@@ -24,6 +63,7 @@ module.exports = async function clean(cmdObj) {
|
|
|
24
63
|
|
|
25
64
|
console.log('[1] Limpo.')
|
|
26
65
|
|
|
66
|
+
await track(miniConf, start)
|
|
27
67
|
TrackingEitriAnalytics.sendEvent({
|
|
28
68
|
command: "clean",
|
|
29
69
|
success: true,
|
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,20 +101,16 @@ ${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
|
-
const organization = miniConf?.organization ? Object.keys(miniConf?.organization).length !== 0 ? miniConf?.organization : "-" : {
|
|
108
|
-
id: miniConf?.organizationId
|
|
109
|
-
}
|
|
110
|
-
|
|
111
107
|
await TrackingEitriAnalytics.sendEvent({
|
|
112
108
|
command: "push-version",
|
|
113
109
|
success: true,
|
|
114
110
|
data: {
|
|
115
111
|
eitriApp: {
|
|
116
112
|
...miniConf,
|
|
117
|
-
organization
|
|
113
|
+
organization: Object.keys(miniConf?.organization).length !== 0 ? miniConf?.organization : "-"
|
|
118
114
|
},
|
|
119
115
|
target,
|
|
120
116
|
startDate: `${start}`,
|
|
@@ -129,7 +125,7 @@ ${await targetService.getAppConfExampleSnippet()}
|
|
|
129
125
|
} else if (e && e.message) {
|
|
130
126
|
console.log(`\x1b[1m\x1b[31m${e.message}\x1b[0m`);
|
|
131
127
|
} else {
|
|
132
|
-
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`);
|
|
133
129
|
}
|
|
134
130
|
|
|
135
131
|
await TrackingEitriAnalytics.sendEvent({
|
package/src/cmd/validate.js
CHANGED
|
@@ -73,6 +73,12 @@ module.exports.validate = function (miniConf) {
|
|
|
73
73
|
let isversionvalid = checkAmeVersion(miniConf)
|
|
74
74
|
|
|
75
75
|
|
|
76
|
+
if (!miniConf.organization) {
|
|
77
|
+
validateResult.addError(
|
|
78
|
+
'Por Favor, preencha o campo \'organization\' (Utilize apenas caracteres maiusculo, minusculo e espaco. Ex: \'Minha Empresa\').'
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
76
82
|
if (!miniConf.name) {
|
|
77
83
|
validateResult.addError(
|
|
78
84
|
'Por Favor, preencha o campo \'name\' (Utilize apenas caracteres maiusculo, minusculo e espaco. Ex: \'Meu Mini App\').'
|
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)
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const commander = require("commander");
|
|
2
2
|
|
|
3
3
|
module.exports = function VegvisirCommand() {
|
|
4
|
-
const workspaceCommand = commander.command("workspace")
|
|
5
|
-
.description("Gerencia os workspaces do desenvolvedor, para mais informações execute 'eitri workspace --help'")
|
|
6
|
-
|
|
4
|
+
const workspaceCommand = commander.command("workspace");
|
|
7
5
|
workspaceCommand
|
|
8
6
|
.command("list")
|
|
9
7
|
.description("Lista os workspaces do usuário")
|
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
|
|
package/src/service/MiniLog.js
CHANGED
|
@@ -121,29 +121,12 @@ class MiniLog {
|
|
|
121
121
|
console.log(chalk.cyan(msg))
|
|
122
122
|
} else {
|
|
123
123
|
// A propriedade userFriendlyMessage deve ser tratada pelo miniapp. Logaremos da forma como o miniapp nos fornecer o objeto.
|
|
124
|
-
|
|
125
|
-
console.log(`\x1b[34meitri:\x1b[0m\x1b[97m${data.msg}\x1b[0m`);
|
|
126
|
-
} else {
|
|
127
|
-
const message = this._colorizeMessage(data.msg, data.method)
|
|
128
|
-
console[data.method](`\x1b[34meitri:\x1b[0m${message}`);
|
|
129
|
-
}
|
|
124
|
+
console.log(`\x1b[34meitri:\x1b[0m\x1b[97m${data.msg}\x1b[0m`);
|
|
130
125
|
}
|
|
131
126
|
if (data.stopCLI) {
|
|
132
127
|
process.exit(1)
|
|
133
128
|
}
|
|
134
129
|
}
|
|
135
|
-
|
|
136
|
-
_colorizeMessage(message, method) {
|
|
137
|
-
const colorizedMessage = {
|
|
138
|
-
log: chalk.hex("#95DB00")(message),
|
|
139
|
-
warn: chalk.yellow(message),
|
|
140
|
-
error: chalk.red(message),
|
|
141
|
-
info: chalk.green(message),
|
|
142
|
-
debug: chalk.blue(message),
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
return colorizedMessage[method] || colorizedMessage.log
|
|
146
|
-
}
|
|
147
130
|
}
|
|
148
131
|
|
|
149
132
|
module.exports = MiniLog
|
|
@@ -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)
|
package/src/service/Workspace.js
CHANGED
|
@@ -18,6 +18,7 @@ const packageJson = require(path.resolve(
|
|
|
18
18
|
const tempFolderPath = require("../util/os").OS_MAPPER;
|
|
19
19
|
const TargetService = require("../service/TargetService");
|
|
20
20
|
const WatcherOpts = require("../enum/WatcherOpts");
|
|
21
|
+
const { default: axios } = require("../../node_modules/axios/index");
|
|
21
22
|
const ipv4 = require("../util/ipv4");
|
|
22
23
|
const { compressToBase64 } = require("lz-string");
|
|
23
24
|
const Buffer = require("buffer");
|
|
@@ -25,10 +26,7 @@ const DEFAULT_ENV = "dev";
|
|
|
25
26
|
const cliProgress = require("cli-progress");
|
|
26
27
|
const EitriAppManager = require("./EitriAppManager");
|
|
27
28
|
const getWorkspace = require("../util/getWorkspace");
|
|
28
|
-
const EitriAppService = require("./EitriAppService");
|
|
29
|
-
|
|
30
29
|
class Workspace {
|
|
31
|
-
|
|
32
30
|
constructor(blindGuardian, hashFolder) {
|
|
33
31
|
this.config = config.get("workspace");
|
|
34
32
|
this.basePath = this.config.basePath;
|
|
@@ -53,11 +51,6 @@ class Workspace {
|
|
|
53
51
|
*/
|
|
54
52
|
this.progressBar;
|
|
55
53
|
this.progressBarCounter = 0;
|
|
56
|
-
/**
|
|
57
|
-
* @type {EitriAppService}
|
|
58
|
-
* @private
|
|
59
|
-
*/
|
|
60
|
-
this.eitriAppService = new EitriAppService();
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
getTargets() {
|
|
@@ -218,11 +211,7 @@ class Workspace {
|
|
|
218
211
|
|
|
219
212
|
const setupData = setupResponse.data;
|
|
220
213
|
|
|
221
|
-
const { state, target: remoteTarget
|
|
222
|
-
|
|
223
|
-
if(!this.eitriAppService.validEitriConf(miniConf)) {
|
|
224
|
-
await this.eitriAppService.writeEitriConf(remoteEitriConf, miniConf, this.folder2watch);
|
|
225
|
-
}
|
|
214
|
+
const { state, target: remoteTarget } = setupData;
|
|
226
215
|
|
|
227
216
|
this.printLibsVersion(state);
|
|
228
217
|
|
|
@@ -963,6 +952,77 @@ class Workspace {
|
|
|
963
952
|
return results;
|
|
964
953
|
}
|
|
965
954
|
|
|
955
|
+
//TODO: ESSE MÉTODO DEVE SER APAGADO, QUANDO NÃO EXISTIR MAIS O COMANDO PUBLISH
|
|
956
|
+
async publish(publishMessage) {
|
|
957
|
+
const miniConf = this.getMiniConf();
|
|
958
|
+
const formData = new FormData();
|
|
959
|
+
|
|
960
|
+
formData.append("miniAppName", miniConf.name || "sem nome");
|
|
961
|
+
formData.append("miniAppSlug", miniConf.slug || "sem-slug");
|
|
962
|
+
formData.append("miniAppTitle", miniConf.title || "Sem Titulo");
|
|
963
|
+
formData.append(
|
|
964
|
+
"miniAppVersion",
|
|
965
|
+
miniConf.miniAppVersion || miniConf.version || "0.1.0"
|
|
966
|
+
);
|
|
967
|
+
formData.append("organizationName", miniConf.organization.name);
|
|
968
|
+
formData.append("publishMessage", publishMessage || "");
|
|
969
|
+
|
|
970
|
+
const url = `${this.serverUrl}/${this.basePath}/publish?async=true`;
|
|
971
|
+
await this.http.postForm(url, formData);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
async build(buildMessage) {
|
|
975
|
+
const miniConf = this.getMiniConf();
|
|
976
|
+
const formData = new FormData();
|
|
977
|
+
|
|
978
|
+
formData.append("miniAppName", miniConf.name || "sem nome");
|
|
979
|
+
formData.append("miniAppSlug", miniConf.slug || "sem-slug");
|
|
980
|
+
formData.append("miniAppTitle", miniConf.title || "Sem Titulo");
|
|
981
|
+
formData.append(
|
|
982
|
+
"miniAppVersion",
|
|
983
|
+
miniConf.miniAppVersion || miniConf.version || "v1"
|
|
984
|
+
);
|
|
985
|
+
formData.append("organizationName", miniConf.organization.name);
|
|
986
|
+
formData.append("publishMessage", buildMessage || "");
|
|
987
|
+
|
|
988
|
+
const url = `${this.serverUrl}/${this.basePath}/publish?async=true`;
|
|
989
|
+
await this.http.postForm(url, formData);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* @deprecated Prefira {@link Workspace#pushVersionAsJson}
|
|
994
|
+
*/
|
|
995
|
+
async pushVersionAsForm(buildMessage) {
|
|
996
|
+
const miniConf = this.getMiniConf();
|
|
997
|
+
const formData = new FormData();
|
|
998
|
+
|
|
999
|
+
let attrValue;
|
|
1000
|
+
|
|
1001
|
+
formData.append("miniAppName", miniConf.name || "sem nome");
|
|
1002
|
+
formData.append("miniAppSlug", miniConf.slug || "sem-slug");
|
|
1003
|
+
formData.append("miniAppTitle", miniConf.title || "Sem Titulo");
|
|
1004
|
+
formData.append(
|
|
1005
|
+
"miniAppVersion",
|
|
1006
|
+
miniConf.miniAppVersion || miniConf.version || "v1"
|
|
1007
|
+
);
|
|
1008
|
+
formData.append("organizationName", miniConf.organization.name);
|
|
1009
|
+
formData.append("miniAppSubSetName", miniConf.name);
|
|
1010
|
+
formData.append("miniAppSubSetTitle", miniConf.title);
|
|
1011
|
+
if ((attrValue = miniConf["eitri-app-components"]))
|
|
1012
|
+
formData.append("cliComponentsVersion", attrValue);
|
|
1013
|
+
if ((attrValue = miniConf["eitri-app-client"]))
|
|
1014
|
+
formData.append("cliSuperAppClientVersion", attrValue);
|
|
1015
|
+
if ((attrValue = packageJson.version))
|
|
1016
|
+
formData.append("cliVersion", attrValue);
|
|
1017
|
+
if ((attrValue = buildMessage))
|
|
1018
|
+
formData.append("publishMessage", attrValue);
|
|
1019
|
+
if ((attrValue = miniConf.privacy))
|
|
1020
|
+
formData.append("privacy", JSON.stringify(attrValue));
|
|
1021
|
+
|
|
1022
|
+
const url = `${this.serverUrl}/${this.basePath}/publish?async=true`;
|
|
1023
|
+
await this.http.postForm(url, formData);
|
|
1024
|
+
}
|
|
1025
|
+
|
|
966
1026
|
async pushVersionAsJson(args) {
|
|
967
1027
|
let headers = {};
|
|
968
1028
|
if (this.config.apiVersion && this.config.apiVersion.v2Header) {
|
|
@@ -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
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const { writeFile, rename } = require("fs/promises");
|
|
2
|
-
const chalk = require("chalk");
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const {existsSync} = require('fs')
|
|
5
|
-
module.exports = class EitriAppService {
|
|
6
|
-
validEitriConf(eitriConf) {
|
|
7
|
-
const requiredFields = ["id", "applicationId", "organizationId"];
|
|
8
|
-
let isValid = true;
|
|
9
|
-
for (const field of requiredFields) {
|
|
10
|
-
if (!eitriConf[field]) isValid = false;
|
|
11
|
-
}
|
|
12
|
-
return isValid;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async writeEitriConf(remoteEitriConf, localEitriConf, folder2WatchPath) {
|
|
16
|
-
if (!remoteEitriConf) return;
|
|
17
|
-
|
|
18
|
-
const eitriAppConfPath = path.resolve(
|
|
19
|
-
folder2WatchPath,
|
|
20
|
-
"../eitri-app.conf.js"
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
if (!existsSync(eitriAppConfPath)) {
|
|
24
|
-
console.warn(
|
|
25
|
-
chalk.yellow.underline.bold(
|
|
26
|
-
"Renomeando arquivo de configuração de miniapp.conf.js -> eitri-app.conf.js",
|
|
27
|
-
)
|
|
28
|
-
);
|
|
29
|
-
const miniAppConfPath = path.resolve(
|
|
30
|
-
folder2WatchPath,
|
|
31
|
-
"../miniapp.conf.js"
|
|
32
|
-
);
|
|
33
|
-
await rename(miniAppConfPath, eitriAppConfPath);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let updatedEitriConf = {
|
|
37
|
-
...localEitriConf,
|
|
38
|
-
...remoteEitriConf,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const eitriConf = `module.exports = ${JSON.stringify(
|
|
42
|
-
updatedEitriConf,
|
|
43
|
-
null,
|
|
44
|
-
'\t'
|
|
45
|
-
)}`;
|
|
46
|
-
|
|
47
|
-
await writeFile(eitriAppConfPath, eitriConf, "utf8");
|
|
48
|
-
}
|
|
49
|
-
}
|