eitri-cli 1.31.0 → 1.32.0-beta.2
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 +7 -1
- package/index.js +2 -1
- package/package.json +1 -1
- package/src/cmd/runTests.js +0 -170
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/eitri-cli-v2/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
export interface StartArguments {
|
|
7
7
|
shared?: boolean
|
|
8
8
|
verbose?: boolean
|
|
9
|
+
skipLibs?: boolean
|
|
9
10
|
playground?: boolean
|
|
10
11
|
initializationParams?: string
|
|
11
12
|
}
|
|
@@ -23,8 +24,13 @@ export interface PushArgs {
|
|
|
23
24
|
shared?: boolean
|
|
24
25
|
message?: string
|
|
25
26
|
}
|
|
27
|
+
export interface TestingArgs {
|
|
28
|
+
testPath?: string
|
|
29
|
+
verbose?: boolean
|
|
30
|
+
watch?: boolean
|
|
31
|
+
}
|
|
26
32
|
export declare function publish(environment: string, message: string): Promise<void>
|
|
27
|
-
export declare function runTest(
|
|
33
|
+
export declare function runTest(args: TestingArgs): Promise<void>
|
|
28
34
|
export declare function eitriLibs(eitriLibsArgs: EitriLibsArguments): Promise<void>
|
|
29
35
|
export declare function doctor(): Promise<void>
|
|
30
36
|
export declare function start(args: StartArguments): Promise<void>
|
package/index.js
CHANGED
|
@@ -219,12 +219,13 @@ const run = async () => {
|
|
|
219
219
|
.command("test")
|
|
220
220
|
.description("Executa os testes do eitri-app.")
|
|
221
221
|
.option("-v, --verbose", "Exibe mais logs")
|
|
222
|
+
.option("-w, --watch", "Observa a alteração dos arquivos e executa os testes novamente a cada alteração")
|
|
222
223
|
.option(
|
|
223
224
|
"-p --path <test_path>",
|
|
224
225
|
"Define o path do arquivo de teste que será executado."
|
|
225
226
|
)
|
|
226
227
|
.action(async (cmdObj) => {
|
|
227
|
-
return
|
|
228
|
+
return await globalEitriCLIV2.runTest(cmdObj);
|
|
228
229
|
});
|
|
229
230
|
|
|
230
231
|
program
|
package/package.json
CHANGED
package/src/cmd/runTests.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const Watcher = require('../service/Watcher')
|
|
3
|
-
const { workspace } = require('../service/Workspace')
|
|
4
|
-
const MiniLog = require('../service/MiniLog')
|
|
5
|
-
const validator = require('./validate')
|
|
6
|
-
const TrackingService = require('../service/TrackingService')
|
|
7
|
-
const fs = require('fs')
|
|
8
|
-
const config = require('../service/ConfigService')
|
|
9
|
-
const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
|
|
10
|
-
const VegvisirService = require('../modules/vegvisir/VegvisirService')
|
|
11
|
-
const PrerequisitesValidator = require('../service/PrerequisitesValidator')
|
|
12
|
-
const { LogVerbose } = require('../util/LogUtil')
|
|
13
|
-
const eitriCLIV2 = require('../../eitri-cli-v2/index.js')
|
|
14
|
-
|
|
15
|
-
const blindGuardian = workspace.blindGuardian
|
|
16
|
-
const hashFolder = workspace.hashFolder
|
|
17
|
-
const trackingService = new TrackingService(blindGuardian, { ignoreCredentialError: true })
|
|
18
|
-
const watcher = new Watcher(workspace, hashFolder, trackingService)
|
|
19
|
-
const vegvisirService = new VegvisirService(workspace)
|
|
20
|
-
const prerequisitesValidator = new PrerequisitesValidator(workspace)
|
|
21
|
-
const debug = require('debug')('eitri:run-test')
|
|
22
|
-
const COMMAND_NAME = "run-test"
|
|
23
|
-
|
|
24
|
-
module.exports = async function runTests(args) {
|
|
25
|
-
debug("Iniciando runTests()")
|
|
26
|
-
const miniConf = workspace.getMiniConf()
|
|
27
|
-
let testPath = ""
|
|
28
|
-
|
|
29
|
-
if (!Object.prototype.hasOwnProperty.call(miniConf, 'type')) {
|
|
30
|
-
const message = "Erro no arquivo eitri-app.conf.js: A propriedade 'type' não está presente."
|
|
31
|
-
console.log(`\x1b[1m\x1b[31m${message}\x1b[0m`);
|
|
32
|
-
process.exit(1)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
Object.prototype.hasOwnProperty.call(miniConf, 'type') &&
|
|
37
|
-
miniConf.type !== 'module'
|
|
38
|
-
) {
|
|
39
|
-
const message = " Os testes não podem ser executados devido à ausência do tipo 'module' no arquivo 'eitri-app.conf.js'. Certifique-se de incluir o atributo 'type' com o valor 'module' no arquivo de configuração para permitir a execução dos testes com sucesso."
|
|
40
|
-
console.log(`\x1b[1m\x1b[31m${message}\x1b[0m`);
|
|
41
|
-
process.exit(1)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
await vegvisirService.isCurrentWorkspaceOwnedByUser(miniConf.slug)
|
|
45
|
-
|
|
46
|
-
const separator = '======================================================================='
|
|
47
|
-
let displayFriendlyErrorAtEnd = ""
|
|
48
|
-
|
|
49
|
-
await prerequisitesValidator.checkAll(args)
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
if (!args.force) {
|
|
53
|
-
await validator.assertCommandNotRunning(COMMAND_NAME)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (args.path) {
|
|
57
|
-
testPath = args.path
|
|
58
|
-
debug("Foi definido um path para a execução do teste", testPath)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const miniLog = new MiniLog(config.get('miniLog'))
|
|
62
|
-
debug("Obtendo informações do MiniLog", miniLog)
|
|
63
|
-
|
|
64
|
-
const resourceFolders2watch = [path.join(process.cwd(), 'public')]
|
|
65
|
-
if (fs.existsSync(resourceFolders2watch)) {
|
|
66
|
-
workspace.setResourceFolder2Watch(resourceFolders2watch)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
await vegvisirService.check(miniConf.slug)
|
|
70
|
-
debug("Fim da busca e validação do EitriAppConf", { miniConf })
|
|
71
|
-
|
|
72
|
-
const url = config.get('workspace').url
|
|
73
|
-
const setupResult = await workspace.setup(args)
|
|
74
|
-
debug("Informações do setupResult do workspace", { setupResult })
|
|
75
|
-
|
|
76
|
-
blindGuardian.readConf()
|
|
77
|
-
const qrCodeUrl = config.get('qrCode').url
|
|
78
|
-
if (args.verbose) {
|
|
79
|
-
blindGuardian.verbose = true
|
|
80
|
-
miniLog.verbose = true
|
|
81
|
-
console.log('WS url', url)
|
|
82
|
-
}
|
|
83
|
-
workspace.setServerUrl(url)
|
|
84
|
-
workspace.setQrCodeUrl(qrCodeUrl)
|
|
85
|
-
|
|
86
|
-
debug("Iniciando workspace", { workspace })
|
|
87
|
-
await workspace.init()
|
|
88
|
-
debug("Workspace iniciado", { workspace })
|
|
89
|
-
|
|
90
|
-
const silentOnConnect = args.verbose ? false : true
|
|
91
|
-
const userWorkspace = await vegvisirService.getWorkspace()
|
|
92
|
-
console.log(`Construindo para o Workspace [${userWorkspace.id}]`)
|
|
93
|
-
await miniLog.connect(userWorkspace.id, silentOnConnect)
|
|
94
|
-
|
|
95
|
-
LogVerbose(args.verbose, "Construindo...");
|
|
96
|
-
const isDevMode = true
|
|
97
|
-
try {
|
|
98
|
-
debug("Iniciando workspace.uploadZip", { isDevMode, workspace })
|
|
99
|
-
await workspace.uploadZip(isDevMode);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
debug("Erro no workspace.uploadZip", { isDevMode, workspace, error })
|
|
102
|
-
if (args.verbose) {
|
|
103
|
-
console.error("::uploadZip::", error?.message)
|
|
104
|
-
console.error(":::uploadZip::: ", error)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const friendlyMessage1 = "Desculpe, não foi possível realizar a sincronização dos arquivos."
|
|
108
|
-
const friendlyMessage2 = "Recomendamos que verifique eventuais erros no código. Para mais informações, consulte nossa documentação em: https://docs.eitri.tech/."
|
|
109
|
-
const friendlyMessage3 = "Se o problema persistir, por favor, entre em contato com o suporte técnico do Eitri."
|
|
110
|
-
const friendlyMessage4 = "Você pode continuar o desenvolvimento localmente, mesmo que a sincronização não esteja disponível no momento."
|
|
111
|
-
displayFriendlyErrorAtEnd = `\x1b[1m\x1b[31m\n${friendlyMessage1}\n${friendlyMessage2} \x1b[0m` + "\n" + `\n${friendlyMessage3}\n${friendlyMessage4}\n\x1b[0m`
|
|
112
|
-
|
|
113
|
-
const errorData = error.response.data
|
|
114
|
-
const commonStartErrors = ['CodeCompileError', 'TagNotFound']
|
|
115
|
-
if (commonStartErrors.includes(errorData.name)) {
|
|
116
|
-
displayFriendlyErrorAtEnd += `\n\x1b[1m\x1b[31mMotivo: ${errorData.friendlyMessage}\x1b[0m\n`;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
console.log("Eitri-app carregado e pronto para testes!!\n");
|
|
120
|
-
watcher.start()
|
|
121
|
-
|
|
122
|
-
await eitriCLIV2.runTest(testPath)
|
|
123
|
-
|
|
124
|
-
TrackingEitriAnalytics.sendEvent({
|
|
125
|
-
eventName: COMMAND_NAME,
|
|
126
|
-
userId: workspace?.userEmail,
|
|
127
|
-
data: {
|
|
128
|
-
workspaceId: userWorkspace.id,
|
|
129
|
-
miniConf,
|
|
130
|
-
args
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
process.exit(0)
|
|
134
|
-
} catch (e) {
|
|
135
|
-
debug(`Erro no processo de ${COMMAND_NAME}`, { message: e?.message, error: e })
|
|
136
|
-
TrackingEitriAnalytics.sendEvent({
|
|
137
|
-
eventName: `${COMMAND_NAME}.error`,
|
|
138
|
-
userId: workspace?.userEmail,
|
|
139
|
-
data: {
|
|
140
|
-
errorMessage: e?.message || `${COMMAND_NAME}.error`
|
|
141
|
-
}
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
if (args.verbose) console.error(e)
|
|
145
|
-
|
|
146
|
-
if (e.response && e.response.data && e.response.data.friendlyMessage) {
|
|
147
|
-
const { name, friendlyMessage } = e.response.data
|
|
148
|
-
|
|
149
|
-
console.error(`ERRO: ${friendlyMessage}`)
|
|
150
|
-
|
|
151
|
-
if (name === 'NameCharacterLimitExceed') {
|
|
152
|
-
process.exit(1)
|
|
153
|
-
}
|
|
154
|
-
} else if (e && e.message) {
|
|
155
|
-
console.log(`\x1b[1m\x1b[31m${e.message}\x1b[0m`);
|
|
156
|
-
} else {
|
|
157
|
-
console.log(`\x1b[1m\x1b[31mEitri encontrou um erro e por isso parou, tente novamente mais tarde.\x1b[0m`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
await trackingService.sendError(e)
|
|
161
|
-
|
|
162
|
-
process.exit(1)
|
|
163
|
-
} finally {
|
|
164
|
-
if (displayFriendlyErrorAtEnd) {
|
|
165
|
-
const folderHash = workspace.getFolderHashPath()
|
|
166
|
-
await workspace.transpile([folderHash])
|
|
167
|
-
console.log("\n\n" + separator + "\n" + displayFriendlyErrorAtEnd + "\n" + separator + "\n\n")
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|