eitri-cli 1.38.0-beta.9 → 1.39.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/.husky/pre-commit +0 -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/eitri-cli-v2/index.d.ts +11 -1
- package/index.js +4 -21
- package/package.json +3 -49
- package/src/modules/app/AppCommand.js +1 -1
- package/src/modules/vegvisir/VegvisirCommand.js +7 -13
- package/.eslintrc.json +0 -26
- package/.prettierrc +0 -6
- package/src/cmd/clean.js +0 -144
- package/src/cmd/create.js +0 -332
- package/src/cmd/credentials.js +0 -105
- package/src/cmd/doctor.js +0 -70
- package/src/cmd/invite.js +0 -87
- package/src/cmd/list.js +0 -36
- package/src/cmd/login.js +0 -70
- package/src/cmd/loginV2.js +0 -89
- package/src/cmd/manage-env.js +0 -129
- package/src/cmd/open-share.js +0 -6
- package/src/cmd/order-details.js +0 -6
- package/src/cmd/push-version.js +0 -260
- package/src/cmd/show-message-if-outdated-package.js +0 -32
- package/src/cmd/signup.js +0 -71
- package/src/cmd/start.js +0 -181
- package/src/cmd/tail-logs.js +0 -26
- package/src/cmd/test-initialization-params.js +0 -6
- package/src/cmd/validate.js +0 -164
- package/src/cmd/version.js +0 -18
- package/src/enum/WatcherOpts.js +0 -3
- package/src/enum/target.js +0 -6
- package/src/helpers/request-listener-helper.js +0 -55
- package/src/model/EitriAppType.js +0 -4
- package/src/model/Payload.js +0 -45
- package/src/model/Target.js +0 -61
- package/src/model/User.js +0 -11
- package/src/service/AuthConfig.js +0 -85
- package/src/service/BlindGuardian.js +0 -131
- package/src/service/CliLogin.js +0 -52
- package/src/service/ConfigService.js +0 -9
- package/src/service/CredentialsService.js +0 -47
- package/src/service/EitriAppManager.js +0 -32
- package/src/service/EitriAppService.js +0 -49
- package/src/service/Emulator/AndroidEmulatorService.js +0 -132
- package/src/service/Emulator/IOSEmulatorService.js +0 -71
- package/src/service/EmulatorService.js +0 -17
- package/src/service/GATrackingStrategy.js +0 -16
- package/src/service/HashFolder.js +0 -79
- package/src/service/Http.js +0 -300
- package/src/service/HuginService.js +0 -38
- package/src/service/InviteService.js +0 -45
- package/src/service/LibsService.js +0 -191
- package/src/service/ManageEnvService.js +0 -10
- package/src/service/MiniLog.js +0 -166
- package/src/service/PrerequisitesValidator.js +0 -99
- package/src/service/QRCodeFactory.js +0 -81
- package/src/service/ReleaseService.js +0 -126
- package/src/service/Server.js +0 -220
- package/src/service/StarterService.js +0 -31
- package/src/service/TagTree.js +0 -101
- package/src/service/TargetService.js +0 -97
- package/src/service/TrackService.js +0 -11
- package/src/service/TrackingEitriAnalytics.js +0 -26
- package/src/service/TrackingService.js +0 -183
- package/src/service/ValidateResult.js +0 -57
- package/src/service/Watcher.js +0 -118
- package/src/service/Workspace.js +0 -1045
- package/src/service/WorkspaceManager.js +0 -76
- package/src/service/factories/DoubtsStarterFactory.js +0 -25
- package/src/service/factories/MiniWebAppFactory.js +0 -44
- package/src/service/factories/QRCodeStarterFactory.js +0 -154
- package/src/service/factories/WebStarterFactory.js +0 -88
- package/src/service/factories/WoodCoffeeFactory.js +0 -292
- package/src/util/AboutTemplate.jsx +0 -14
- package/src/util/FileUtils.js +0 -25
- package/src/util/GenericUtils.js +0 -41
- package/src/util/LibUtil.js +0 -32
- package/src/util/LogUtil.js +0 -14
- package/src/util/UrlUtils.js +0 -12
- package/src/util/UserLocalCredential.js +0 -128
- package/src/util/convertKeysToCamelCase.js +0 -26
- package/src/util/error-messages/error-messages.js +0 -24
- package/src/util/error-messages/invite/invite-error-messages.js +0 -14
- package/src/util/getCliVersion.js +0 -13
- package/src/util/getCreateFactory.js +0 -9
- package/src/util/getWorkspace.js +0 -37
- package/src/util/ipv4.js +0 -19
- package/src/util/manage-env.js +0 -65
- package/src/util/open-docs.js +0 -7
- package/src/util/os.js +0 -39
- package/src/util/server-url.js +0 -15
- package/src/util/template-utils.js +0 -21
- package/src/view/index.html +0 -19
package/src/cmd/create.js
DELETED
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
const Watcher = require("../service/Watcher");
|
|
2
|
-
const inquirer = require("inquirer");
|
|
3
|
-
const slugify = require("slugify");
|
|
4
|
-
const configService = require("../service/ConfigService");
|
|
5
|
-
const { Workspace } = require("../service/Workspace");
|
|
6
|
-
const BlindGuardian = require("../service/BlindGuardian");
|
|
7
|
-
const HashFolder = require("../service/HashFolder");
|
|
8
|
-
const TrackingService = require("../service/TrackingService");
|
|
9
|
-
const { NAME_TITLE_REGEX, SLUG_REGEX } = require("./validate");
|
|
10
|
-
const handleStartServer = require("../service/StarterService");
|
|
11
|
-
const getCreateFactory = require("../util/getCreateFactory");
|
|
12
|
-
const UrlUtils = require("../util/UrlUtils");
|
|
13
|
-
const open = require("open");
|
|
14
|
-
// eslint-disable-next-line no-unused-vars
|
|
15
|
-
const Target = require("../model/Target");
|
|
16
|
-
const EitriAppManager = require("../service/EitriAppManager");
|
|
17
|
-
const WoodCoffee = require("../service/factories/WoodCoffeeFactory");
|
|
18
|
-
const TrackingEitriAnalytics = require("../service/TrackingEitriAnalytics");
|
|
19
|
-
const UserLocalCredential = require("../util/UserLocalCredential");
|
|
20
|
-
|
|
21
|
-
const blindGuardian = new BlindGuardian();
|
|
22
|
-
const hashFolder = new HashFolder();
|
|
23
|
-
const workspace = new Workspace(blindGuardian, hashFolder);
|
|
24
|
-
const trackingService = new TrackingService(blindGuardian, {
|
|
25
|
-
ignoreCredentialError: true,
|
|
26
|
-
});
|
|
27
|
-
const watcher = new Watcher(workspace, hashFolder, trackingService);
|
|
28
|
-
const ITEM_DOUBT = "DOUBTS";
|
|
29
|
-
const eitriAppManager = new EitriAppManager(blindGuardian);
|
|
30
|
-
|
|
31
|
-
const nameOrTitle = (inpt) => {
|
|
32
|
-
if (!NAME_TITLE_REGEX.test(inpt)) {
|
|
33
|
-
return "Não use caracteres especiais";
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const slug = (inpt) => {
|
|
39
|
-
if (!SLUG_REGEX.test(inpt)) {
|
|
40
|
-
return "Não use caracteres especiais";
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line no-unused-vars
|
|
46
|
-
module.exports = async function create(projectName, cmdObj) {
|
|
47
|
-
blindGuardian.verbose = cmdObj.verbose
|
|
48
|
-
try {
|
|
49
|
-
UserLocalCredential.checkForCredentials()
|
|
50
|
-
} catch (error) {
|
|
51
|
-
const errorMessage = cmdObj?.verbose ? error : error?.message
|
|
52
|
-
console.error("\n", errorMessage, "\n")
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
console.log(
|
|
57
|
-
"Vamos criar o seu Eitri-App. Carregando configurações..."
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
const url = configService.get("workspace").url;
|
|
62
|
-
workspace.setServerUrl(url);
|
|
63
|
-
const clientApplication = await askClientApplication(cmdObj.application);
|
|
64
|
-
if (clientApplication.name === ITEM_DOUBT) {
|
|
65
|
-
open("https://docs.eitri.tech/")
|
|
66
|
-
handleStartServer(
|
|
67
|
-
cmdObj,
|
|
68
|
-
trackingService,
|
|
69
|
-
watcher,
|
|
70
|
-
workspace,
|
|
71
|
-
clientApplication.name
|
|
72
|
-
);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const responseAskProjMetadata = await askProjMetadata(clientApplication, cmdObj, projectName);
|
|
76
|
-
TrackingEitriAnalytics.sendEvent({
|
|
77
|
-
eventName: "create",
|
|
78
|
-
userId: workspace?.userEmail,
|
|
79
|
-
});
|
|
80
|
-
console.log("Eitri-App criado com sucesso!")
|
|
81
|
-
return responseAskProjMetadata
|
|
82
|
-
} catch (e) {
|
|
83
|
-
TrackingEitriAnalytics.sendEvent({
|
|
84
|
-
eventName: "create.error",
|
|
85
|
-
userId: workspace?.userEmail,
|
|
86
|
-
data: {
|
|
87
|
-
errorMessage: e?.message,
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
console.error(e?.message);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
async function askClientApplication(applicationName) {
|
|
95
|
-
const availableApplications = await eitriAppManager.findAllApplications();
|
|
96
|
-
|
|
97
|
-
console.log(
|
|
98
|
-
"\x1b[34m \nAgora, responda algumas perguntas:\n\x1b[0m"
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
if (availableApplications.length <= 0) {
|
|
102
|
-
console.log(
|
|
103
|
-
"Sua organização não contém nenhuma aplicação disponível para prosseguir com a criação."
|
|
104
|
-
);
|
|
105
|
-
process.exit(0);
|
|
106
|
-
}
|
|
107
|
-
if (applicationName) {
|
|
108
|
-
const clientApplication = availableApplications.find(application => application.name === applicationName)
|
|
109
|
-
if (clientApplication) {
|
|
110
|
-
return clientApplication
|
|
111
|
-
} else {
|
|
112
|
-
throw new Error(`Application not found by name ${applicationName}`)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const cliOptions = [
|
|
116
|
-
{ name: ITEM_DOUBT, label: "Dúvidas? Veja documentação no browser" },
|
|
117
|
-
...availableApplications,
|
|
118
|
-
];
|
|
119
|
-
const createLabel = (tgt) => {
|
|
120
|
-
const orgLabel = tgt.organization?.name ? `(${tgt.organization?.name})`: ''
|
|
121
|
-
return `${tgt.label || tgt.name} ${orgLabel}`;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const res = await inquirer.prompt([
|
|
125
|
-
{
|
|
126
|
-
name: "accepted",
|
|
127
|
-
type: "rawlist",
|
|
128
|
-
message:
|
|
129
|
-
"Selecione o Aplicativo para o Eitri-App:",
|
|
130
|
-
choices: cliOptions.map(createLabel),
|
|
131
|
-
pageSize: 10,
|
|
132
|
-
loop: false,
|
|
133
|
-
},
|
|
134
|
-
]);
|
|
135
|
-
const clientApplication = cliOptions.find(
|
|
136
|
-
(tgt) => createLabel(tgt) === res.accepted
|
|
137
|
-
);
|
|
138
|
-
clientApplication.onSelected && clientApplication.onSelected();
|
|
139
|
-
return clientApplication;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async function askProjMetadata(clientApplication, cmdObj, projectName) {
|
|
143
|
-
const factory = new WoodCoffee();
|
|
144
|
-
let questions = createQuestions(projectName);
|
|
145
|
-
try {
|
|
146
|
-
await workspace.init();
|
|
147
|
-
} catch (e) {
|
|
148
|
-
console.log(e.message);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
let answers;
|
|
152
|
-
if (cmdObj.yes) {
|
|
153
|
-
answers = {
|
|
154
|
-
name: projectName,
|
|
155
|
-
title: projectName,
|
|
156
|
-
slug: projectName,
|
|
157
|
-
};
|
|
158
|
-
} else {
|
|
159
|
-
answers = await inquirer.prompt(questions);
|
|
160
|
-
}
|
|
161
|
-
let conf = {
|
|
162
|
-
...answers,
|
|
163
|
-
organization: { id: clientApplication.organizationId },
|
|
164
|
-
};
|
|
165
|
-
delete conf.organizationName;
|
|
166
|
-
|
|
167
|
-
let keepGoing = true;
|
|
168
|
-
while (keepGoing) {
|
|
169
|
-
try {
|
|
170
|
-
keepGoing = false;
|
|
171
|
-
await factory.verifyFolder(projectName, { supressLog: true });
|
|
172
|
-
|
|
173
|
-
// Comentado até implementarmos os múltiplos boilerplates nos targets do banco
|
|
174
|
-
//const {template} = cmdObj
|
|
175
|
-
|
|
176
|
-
const selectedTemplate = _getBoilerplateUrl(
|
|
177
|
-
clientApplication,
|
|
178
|
-
cmdObj
|
|
179
|
-
);
|
|
180
|
-
cmdObj.verbose &&
|
|
181
|
-
console.log(`Usando template ${selectedTemplate}`);
|
|
182
|
-
|
|
183
|
-
let templateProject = await factory.create(
|
|
184
|
-
projectName,
|
|
185
|
-
selectedTemplate,
|
|
186
|
-
clientApplication
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
// conf sera usado pra escrever o arquivo miniapp.conf.js e nao queremos 'target' la.
|
|
190
|
-
const eitriAppToCreate = {
|
|
191
|
-
...conf,
|
|
192
|
-
organizationId: clientApplication.organization.id,
|
|
193
|
-
applicationId: clientApplication.id,
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
// Cria no banco no final das configs locais
|
|
197
|
-
const eitriApp = await eitriAppManager.create(eitriAppToCreate);
|
|
198
|
-
|
|
199
|
-
conf["id"] = eitriApp.id;
|
|
200
|
-
conf["public-key"] = eitriApp.publicKey;
|
|
201
|
-
|
|
202
|
-
const templateEitriAppConf =
|
|
203
|
-
templateProject?.structure?.eitriAppConf;
|
|
204
|
-
|
|
205
|
-
const finalConf = {
|
|
206
|
-
...templateEitriAppConf,
|
|
207
|
-
...conf,
|
|
208
|
-
organizationId: clientApplication.organization.id,
|
|
209
|
-
applicationId: clientApplication.id,
|
|
210
|
-
"type":"module",
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
await factory.writeEitriAppConf(templateProject, finalConf);
|
|
214
|
-
} catch (err) {
|
|
215
|
-
if (cmdObj.verbose) {
|
|
216
|
-
console.error(
|
|
217
|
-
"Houve uma falha durante a criação do Eitri-App",
|
|
218
|
-
err
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (err.isDuplicatedError) {
|
|
223
|
-
if (cmdObj.yes) {
|
|
224
|
-
process.exit(1);
|
|
225
|
-
}
|
|
226
|
-
if (err.field === "name") {
|
|
227
|
-
keepGoing = true;
|
|
228
|
-
conf.name = await askName(projectName);
|
|
229
|
-
}
|
|
230
|
-
if (err.field === "slug") {
|
|
231
|
-
keepGoing = true;
|
|
232
|
-
conf.slug = await askSlug(projectName);
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
if (err.isAxiosError) {
|
|
236
|
-
console.log(err.response && err.response.status);
|
|
237
|
-
} else {
|
|
238
|
-
console.log(err);
|
|
239
|
-
}
|
|
240
|
-
await trackingService.sendError(err);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function createQuestions(projectName) {
|
|
247
|
-
return [
|
|
248
|
-
{
|
|
249
|
-
type: "input",
|
|
250
|
-
name: "name",
|
|
251
|
-
message: "Digite um nome legível para seu Eitri-App",
|
|
252
|
-
validate: nameOrTitle,
|
|
253
|
-
default: () => {
|
|
254
|
-
return projectName;
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
type: "input",
|
|
259
|
-
name: "title",
|
|
260
|
-
message: "Digite um nome para divulgação",
|
|
261
|
-
validate: nameOrTitle,
|
|
262
|
-
default: () => {
|
|
263
|
-
return projectName;
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
type: "input",
|
|
268
|
-
name: "slug",
|
|
269
|
-
message:
|
|
270
|
-
"Digite um nome único para seu Eitri-App. Não pode conter espaços",
|
|
271
|
-
default: (currentAnswers) => {
|
|
272
|
-
return slugify(currentAnswers.name).toLowerCase();
|
|
273
|
-
},
|
|
274
|
-
validate: slug,
|
|
275
|
-
},
|
|
276
|
-
];
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
async function askSlug(projectName) {
|
|
280
|
-
let answer = await inquirer.prompt([
|
|
281
|
-
{
|
|
282
|
-
type: "input",
|
|
283
|
-
name: "slug",
|
|
284
|
-
message: "Outro nome único para o Eitri-App:",
|
|
285
|
-
validate: slug,
|
|
286
|
-
default: () => {
|
|
287
|
-
return slugify(projectName).toLowerCase();
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
]);
|
|
291
|
-
return answer.slug;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
async function askName(projectName) {
|
|
295
|
-
let answer = await inquirer.prompt([
|
|
296
|
-
{
|
|
297
|
-
type: "input",
|
|
298
|
-
name: "name",
|
|
299
|
-
message: "Outro nome para o Eitri-App:",
|
|
300
|
-
validate: nameOrTitle,
|
|
301
|
-
default: () => {
|
|
302
|
-
return projectName;
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
]);
|
|
306
|
-
return answer.name;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
*
|
|
311
|
-
* @param {Target} target
|
|
312
|
-
* @param {*} cmdObj
|
|
313
|
-
*/
|
|
314
|
-
function _getBoilerplateUrl(target, cmdObj) {
|
|
315
|
-
const { template } = cmdObj;
|
|
316
|
-
if (!template || !target.miniAppBoilerplateList) {
|
|
317
|
-
return target.boilerplateUrl;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const boilerplate = target.miniAppBoilerplateList.find(
|
|
321
|
-
(bp) => bp.name === template
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
if (!boilerplate) {
|
|
325
|
-
console.error(
|
|
326
|
-
`O template [${template}] não existe para a aplicação que você selecionou.`
|
|
327
|
-
);
|
|
328
|
-
return process.exit(0);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return boilerplate.boilerplateUrl;
|
|
332
|
-
}
|
package/src/cmd/credentials.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const { Workspace } = require('../service/Workspace')
|
|
3
|
-
const BlindGuardian = require('../service/BlindGuardian')
|
|
4
|
-
const CredentialsService = require('../service/CredentialsService')
|
|
5
|
-
const validator = require('./validate')
|
|
6
|
-
const TrackingService = require('../service/TrackingService')
|
|
7
|
-
const HashFolder = require('../service/HashFolder')
|
|
8
|
-
|
|
9
|
-
const blindGuardian = new BlindGuardian()
|
|
10
|
-
const workspace = new Workspace(blindGuardian, new HashFolder())
|
|
11
|
-
const credentialService = new CredentialsService(workspace)
|
|
12
|
-
const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
|
|
13
|
-
|
|
14
|
-
const config = require('../service/ConfigService')
|
|
15
|
-
|
|
16
|
-
const credentialStrategies = {
|
|
17
|
-
[credentialService.upsert.name]: credentialService.upsert,
|
|
18
|
-
[credentialService.createApproval.name]: credentialService.createApproval
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function credentials(args) {
|
|
22
|
-
const theFunction = credentialStrategies[credentialService.upsert.name]
|
|
23
|
-
await doCredentials(args, theFunction.bind(credentialService))
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function askForApproval(args) {
|
|
27
|
-
const theFunction = credentialStrategies[credentialService.createApproval.name]
|
|
28
|
-
await doCredentials(args, theFunction.bind(credentialService))
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function doCredentials(args, strategy) {
|
|
32
|
-
try {
|
|
33
|
-
|
|
34
|
-
if(!strategy || strategy.constructor.name !== 'AsyncFunction') {
|
|
35
|
-
throw new Error(`Argumento strategy é invalido: ${strategy.name}`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await assertNotRunning(args)
|
|
39
|
-
|
|
40
|
-
setupBlindGuardian()
|
|
41
|
-
|
|
42
|
-
await setupWorkspace(args)
|
|
43
|
-
|
|
44
|
-
await strategy(args)
|
|
45
|
-
|
|
46
|
-
console.log('Operacao realizada com sucesso.')
|
|
47
|
-
} catch (e) {
|
|
48
|
-
if (args.verbose) {
|
|
49
|
-
console.log('\n')
|
|
50
|
-
console.error(e)
|
|
51
|
-
} else if (e && e.response && e.response.data) {
|
|
52
|
-
|
|
53
|
-
const { data } = e.response
|
|
54
|
-
if( data.friendlyMessage) {
|
|
55
|
-
console.error(`ERRO: ${data.friendlyMessage}`)
|
|
56
|
-
} else if (data.message) {
|
|
57
|
-
console.error(`ERRO: ${data.message}`)
|
|
58
|
-
} else if (data.error) {
|
|
59
|
-
console.error(`ERRO: status: ${e.response.status} - ${data.error}`)
|
|
60
|
-
} else if (e.response.status === 500) {
|
|
61
|
-
console.error('ERRO: Erro interno')
|
|
62
|
-
} else {
|
|
63
|
-
console.error(`ERRO: ${e.response.status} - ${e.message} - ${data.error}`)
|
|
64
|
-
}
|
|
65
|
-
} else if (e && e.message) {
|
|
66
|
-
console.error(`ERRO: ${e.message}`)
|
|
67
|
-
} else {
|
|
68
|
-
console.error('Erro inesperado, tente novamente mais tarde.', e)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await trackingService.sendError(e)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function assertNotRunning(args) {
|
|
76
|
-
if (!args.force) {
|
|
77
|
-
await validator.assertCommandNotRunning('credentials')
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function setupBlindGuardian() {
|
|
82
|
-
blindGuardian.readConf()
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function setupWorkspace(args) {
|
|
86
|
-
const url = config.get('workspace').url
|
|
87
|
-
const qrCodeUrl = config.get('qrCode').url
|
|
88
|
-
if (args.verbose) {
|
|
89
|
-
console.log('WS url', url)
|
|
90
|
-
console.log('qrCodeUrl url', qrCodeUrl)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const folder2watch = path.join(process.cwd(), 'src')
|
|
94
|
-
workspace.setFolder2Watch(folder2watch)
|
|
95
|
-
workspace.setServerUrl(url)
|
|
96
|
-
workspace.setQrCodeUrl(qrCodeUrl)
|
|
97
|
-
await workspace.init()
|
|
98
|
-
|
|
99
|
-
let publicKey = workspace.getMiniConf()['public-key']
|
|
100
|
-
if (!publicKey) {
|
|
101
|
-
throw new Error('Vc nao possui [publicKey] no arquivo de configuração do projeto.')
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
module.exports = { credentials, askForApproval }
|
package/src/cmd/doctor.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const child_process = require("child_process");
|
|
2
|
-
const chalk = require("chalk");
|
|
3
|
-
const exec = child_process.exec;
|
|
4
|
-
const os = require("os");
|
|
5
|
-
module.exports = function () {
|
|
6
|
-
console.log("Checando dependências externas do Eitri CLI.\n");
|
|
7
|
-
checkGitDependency();
|
|
8
|
-
adbDependency();
|
|
9
|
-
xcodeCLIDependency();
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const checkGitDependency = () => {
|
|
13
|
-
exec("git -v", (error, _, stderr) => {
|
|
14
|
-
if (error) {
|
|
15
|
-
console.log(
|
|
16
|
-
`[${chalk.red(
|
|
17
|
-
"✘"
|
|
18
|
-
)}] GIT. Para instalar basta acessar o link e seguir a documentação: https://git-scm.com/`
|
|
19
|
-
);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (stderr) {
|
|
23
|
-
console.log(
|
|
24
|
-
`[✘] GIT. Para instalar basta acessar o link e seguir a documentação: https://git-scm.com/`
|
|
25
|
-
);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
console.log(`[${chalk.green("✔")}] GIT`);
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const adbDependency = () => {
|
|
33
|
-
exec("adb version", (error, _, stderr) => {
|
|
34
|
-
if (error) {
|
|
35
|
-
console.log(
|
|
36
|
-
`[${chalk.red(
|
|
37
|
-
"✘"
|
|
38
|
-
)}] ADB. Para instalar basta acessar o link e seguir a documentação: https://developer.android.com/tools/releases/platform-tools?hl=pt-br`
|
|
39
|
-
);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (stderr) {
|
|
43
|
-
console.log(
|
|
44
|
-
`[✘] ADB. Para instalar basta acessar o link e seguir a documentação: https://developer.android.com/tools/releases/platform-tools?hl=pt-br`
|
|
45
|
-
);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
console.log(`[${chalk.green("✔")}] ADB`);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
const xcodeCLIDependency = () => {
|
|
52
|
-
if (os.platform() !== "darwin") return;
|
|
53
|
-
exec("xcrun version", (error, _, stderr) => {
|
|
54
|
-
if (error) {
|
|
55
|
-
console.log(
|
|
56
|
-
`[${chalk.red(
|
|
57
|
-
"✘"
|
|
58
|
-
)}] XCode. Para instalar basta acessar o link e seguir a documentação: https://developer.apple.com/documentation/Xcode`
|
|
59
|
-
);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (stderr) {
|
|
63
|
-
console.log(
|
|
64
|
-
`[✘] XCode. Para instalar basta acessar o link e seguir a documentação: https://developer.apple.com/documentation/Xcode`
|
|
65
|
-
);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
console.log(`[${chalk.green("✔")}] XCode`);
|
|
69
|
-
});
|
|
70
|
-
};
|
package/src/cmd/invite.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
const emoji = require('emojilib')
|
|
2
|
-
const inquirer = require('inquirer')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const {workspace} = require('../service/Workspace')
|
|
5
|
-
const InviteService = require('../service/InviteService')
|
|
6
|
-
const TrackingService = require('../service/TrackingService')
|
|
7
|
-
const ErrorMessages = require('../util/error-messages/error-messages')
|
|
8
|
-
const trackingService = new TrackingService(workspace.blindGuardian, { ignoreCredentialError: true })
|
|
9
|
-
const inviteService = new InviteService(workspace)
|
|
10
|
-
|
|
11
|
-
module.exports = async function invite(email, cmdObj) {
|
|
12
|
-
try {
|
|
13
|
-
const folder2watch = path.join(process.cwd(), 'src')
|
|
14
|
-
workspace.setFolder2Watch(folder2watch)
|
|
15
|
-
await workspace.init()
|
|
16
|
-
if (cmdObj.remove) {
|
|
17
|
-
let slug = workspace.getMiniConf().slug
|
|
18
|
-
let invites = await inviteService.findAllBySlug(slug)
|
|
19
|
-
let invite = invites.find(i => i.email === email)
|
|
20
|
-
if (!invite) {
|
|
21
|
-
console.log(`Convite inexistente para ${email} do Eitri-App ${slug}.`)
|
|
22
|
-
process.exit(1)
|
|
23
|
-
}
|
|
24
|
-
await inviteService.remove(invite)
|
|
25
|
-
console.log(`${email} removido com sucesso do Eitri-App ${slug}.`)
|
|
26
|
-
} else if (cmdObj.list) {
|
|
27
|
-
let slug = workspace.getMiniConf().slug
|
|
28
|
-
let invites = await inviteService.findAllBySlug(slug)
|
|
29
|
-
invites.forEach(invite => {
|
|
30
|
-
console.log(invite.email, '\t', invite.status)
|
|
31
|
-
})
|
|
32
|
-
} else if (cmdObj.accept) {
|
|
33
|
-
let invites = await inviteService.findAllPending()
|
|
34
|
-
if (!invites.length) {
|
|
35
|
-
console.log('Sem convites.')
|
|
36
|
-
process.exit(0)
|
|
37
|
-
}
|
|
38
|
-
console.log(`${invites.length} convites`)
|
|
39
|
-
const createLabel = (inv) => {
|
|
40
|
-
return `aceitar convite do Eitri-App "${inv.slug}" enviado por ${inv.inviterEmail || 'desconhecido'}`
|
|
41
|
-
}
|
|
42
|
-
let res = await inquirer.prompt([
|
|
43
|
-
{
|
|
44
|
-
name: 'accepted',
|
|
45
|
-
type: 'rawlist',
|
|
46
|
-
message: 'Escolha:',
|
|
47
|
-
choices: invites.map(createLabel).concat(['não aceitar nenhum convite'])
|
|
48
|
-
}
|
|
49
|
-
])
|
|
50
|
-
let inviteToAccept = invites.find(inv => createLabel(inv) === res.accepted)
|
|
51
|
-
if (inviteToAccept) {
|
|
52
|
-
console.log(`Aceitando participar do Eitri-App ${inviteToAccept.slug}...`)
|
|
53
|
-
await inviteService.accept(inviteToAccept)
|
|
54
|
-
console.log(`Convite aceito! ${emoji.lib.clinking_glasses.char}`)
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
let slug = workspace.getMiniConf().slug
|
|
58
|
-
if (!email) {
|
|
59
|
-
console.log('Informe um email.')
|
|
60
|
-
process.exit(1)
|
|
61
|
-
}
|
|
62
|
-
await inviteService.sendInvite(slug, email)
|
|
63
|
-
console.log('Convite enviado com sucesso.')
|
|
64
|
-
}
|
|
65
|
-
process.exit(0)
|
|
66
|
-
} catch(e) {
|
|
67
|
-
if (cmdObj.verbose) {
|
|
68
|
-
console.log(e)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (e.response) {
|
|
72
|
-
if(e.response.status) {
|
|
73
|
-
const { message } = new ErrorMessages('invite', e.response.status)
|
|
74
|
-
console.log(`Ops! Não foi possivel executar ação de aceite do convite\n ${message}`)
|
|
75
|
-
} else {
|
|
76
|
-
console.log(
|
|
77
|
-
`Ops! Houve um problema no convite\n ${e.response.data}`
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
console.log(`Ops! Erro enviando convite\n ${e.message}`)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
await trackingService.sendError(e)
|
|
85
|
-
process.exit(1)
|
|
86
|
-
}
|
|
87
|
-
}
|
package/src/cmd/list.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const inquirer = require('inquirer')
|
|
2
|
-
const TargetService = require('../service/TargetService')
|
|
3
|
-
const {workspace} = require('../service/Workspace')
|
|
4
|
-
const targetService = new TargetService(workspace)
|
|
5
|
-
|
|
6
|
-
module.exports = async function list(args) {
|
|
7
|
-
try {
|
|
8
|
-
const targets = await targetService.getTargets()
|
|
9
|
-
if(targets.length === 0) {
|
|
10
|
-
console.error('Houve um erro ao listar os targets.')
|
|
11
|
-
return process.exit(0)
|
|
12
|
-
}
|
|
13
|
-
const res = await inquirer.prompt([
|
|
14
|
-
{
|
|
15
|
-
name: 'selected',
|
|
16
|
-
type: 'rawlist',
|
|
17
|
-
message: 'Selecione o Target em que deseja ver os templates:',
|
|
18
|
-
choices: targets
|
|
19
|
-
}
|
|
20
|
-
])
|
|
21
|
-
|
|
22
|
-
const selectedTarget = targets.find(tg => tg.name === res.selected)
|
|
23
|
-
|
|
24
|
-
if(args.template){
|
|
25
|
-
const boilerplates = selectedTarget.miniAppBoilerplateList
|
|
26
|
-
if(!boilerplates) {
|
|
27
|
-
console.error(`O Target ${selectedTarget.name} não possui boilerplates disponíveis.`)
|
|
28
|
-
return process.exit(0)
|
|
29
|
-
}
|
|
30
|
-
boilerplates.map( boilerplate => console.log(`${boilerplate.name}: ${boilerplate.description} \n`))
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error('Houve um erro ao listar os targets.')
|
|
34
|
-
return process.exit(0)
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/cmd/login.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const inquirer = require("inquirer");
|
|
2
|
-
const configService = require("../service/ConfigService");
|
|
3
|
-
const open = require("open");
|
|
4
|
-
const TrackingEitriAnalytics = require("../service/TrackingEitriAnalytics");
|
|
5
|
-
const Server = require("../service/Server");
|
|
6
|
-
|
|
7
|
-
module.exports = async function login(args) {
|
|
8
|
-
try {
|
|
9
|
-
console.log("\n\n");
|
|
10
|
-
const urlAdminManagerCredential = `${
|
|
11
|
-
configService.get("managerFront").url
|
|
12
|
-
}`;
|
|
13
|
-
const res = Server.startCliLogin();
|
|
14
|
-
const urlAdminManagerCredentialWithParams = `${urlAdminManagerCredential}?loginType=EITRI_CLI&port=${res?.port}`;
|
|
15
|
-
|
|
16
|
-
let portalOpenMessage = "";
|
|
17
|
-
|
|
18
|
-
if (args.yes) {
|
|
19
|
-
try {
|
|
20
|
-
open(urlAdminManagerCredentialWithParams);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
portalOpenMessage =
|
|
23
|
-
"Não foi possível abrir automaticamente. Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. " +
|
|
24
|
-
urlAdminManagerCredentialWithParams;
|
|
25
|
-
}
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const { openPortalAnwser } = await inquirer.prompt([
|
|
30
|
-
{
|
|
31
|
-
type: "confirm",
|
|
32
|
-
name: "openPortalAnwser",
|
|
33
|
-
message: " Podemos redirecioná-lo para o login?",
|
|
34
|
-
},
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
if (openPortalAnwser) {
|
|
38
|
-
console.log("\n", "Redirecionando...");
|
|
39
|
-
try {
|
|
40
|
-
open(urlAdminManagerCredentialWithParams);
|
|
41
|
-
portalOpenMessage = "Aberto em seu navegador padrão";
|
|
42
|
-
} catch (error) {
|
|
43
|
-
portalOpenMessage =
|
|
44
|
-
"Não foi possível abrir automaticamente. Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. " +
|
|
45
|
-
urlAdminManagerCredentialWithParams;
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
portalOpenMessage =
|
|
49
|
-
"Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. " +
|
|
50
|
-
urlAdminManagerCredentialWithParams;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
console.log("\n", portalOpenMessage);
|
|
54
|
-
console.log("\n\n Aguardando autenticação...");
|
|
55
|
-
} catch (error) {
|
|
56
|
-
TrackingEitriAnalytics.sendEvent({
|
|
57
|
-
eventName: "login.error",
|
|
58
|
-
data: {
|
|
59
|
-
errorMessage: error?.message ?? "",
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
console.log(
|
|
64
|
-
"Erro inesperado, tente novamente mais tarde.",
|
|
65
|
-
error?.message
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
};
|