eitri-cli 1.10.1 → 1.11.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/Cargo.toml +13 -0
- package/eitri-cli-v2/config/config.dev.toml +67 -0
- package/eitri-cli-v2/config/config.loc.toml +67 -0
- package/eitri-cli-v2/config/config.prod.toml +62 -0
- package/eitri-cli-v2/config/config.runes-foundry.toml +7 -0
- package/eitri-cli-v2/config/config.test.toml +67 -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 +4 -1
- package/package.json +1 -1
- package/src/modules/vegvisir/VegvisirService.js +1 -1
- package/src/service/Emulator/AndroidEmulatorService.js +25 -3
- package/src/service/MiniLog.js +5 -46
- package/src/service/factories/WoodCoffeeFactory.js +4 -3
- package/src/util/LibUtil.js +32 -0
- package/eitri-cli-v2/src/commands/mod.rs +0 -2
- package/eitri-cli-v2/src/commands/publish.rs +0 -35
- package/eitri-cli-v2/src/commands/run_test.rs +0 -41
- package/eitri-cli-v2/src/config/mod.rs +0 -1
- package/eitri-cli-v2/src/config/user_credentials.rs +0 -38
- package/eitri-cli-v2/src/infra/http_client.rs +0 -493
- package/eitri-cli-v2/src/infra/mod.rs +0 -1
- package/eitri-cli-v2/src/lib.rs +0 -30
- package/eitri-cli-v2/src/model/auth_response.rs +0 -8
- package/eitri-cli-v2/src/model/credentials.rs +0 -8
- package/eitri-cli-v2/src/model/eitri_conf.rs +0 -43
- package/eitri-cli-v2/src/model/mod.rs +0 -8
- package/eitri-cli-v2/src/model/process_output.rs +0 -8
- package/eitri-cli-v2/src/model/revision.rs +0 -14
- package/eitri-cli-v2/src/model/test_config.rs +0 -7
- package/eitri-cli-v2/src/model/url.rs +0 -11
- package/eitri-cli-v2/src/model/workspace_auth.rs +0 -4
- package/eitri-cli-v2/src/services/blind_guardian.rs +0 -87
- package/eitri-cli-v2/src/services/eitri_foundry.rs +0 -84
- package/eitri-cli-v2/src/services/eitri_manager.rs +0 -78
- package/eitri-cli-v2/src/services/mod.rs +0 -4
- package/eitri-cli-v2/src/services/workspace.rs +0 -49
- package/eitri-cli-v2/src/utils/convert_eitri_conf.rs +0 -98
- package/eitri-cli-v2/src/utils/mod.rs +0 -1
- package/test/Executor.js +0 -60
- package/test/Factory.js +0 -13
- package/test/Helper.js +0 -15
- package/test/_fixtures/factory.js +0 -30
- package/test/_fixtures/miniWebApp/miniapp.conf.js +0 -4
- package/test/_fixtures/miniapp.conf.js +0 -5
- package/test/_fixtures/server/HelloWorldBackend.js +0 -7
- package/test/_fixtures/src/Home.js +0 -5
- package/test/_fixtures/src/Home2.js +0 -5
- package/test/_fixtures/src/commons/util.js +0 -3
- package/test/_fixtures/src/components/TagA.jsx +0 -4
- package/test/_fixtures/src/components/TagB.jsx +0 -4
- package/test/_fixtures/src/components/TagC.jsx +0 -3
- package/test/_fixtures/src/components/TagD.jsx +0 -3
- package/test/_fixtures/src/server/foo.js +0 -7
- package/test/_fixtures/src/views/AboutTemplate.jsx +0 -14
- package/test/_fixtures/woodcoffee/miniapp.conf.js +0 -5
- package/test/ame.conf.js +0 -3
- package/test/cmd/clean.test.js +0 -66
- package/test/cmd/create.test.js +0 -252
- package/test/cmd/list.test.js +0 -74
- package/test/cmd/manage-env.test.js +0 -168
- package/test/e2e/cli.test.js +0 -473
- package/test/miniapp.conf.js +0 -3
- package/test/model/Payload.test.js +0 -35
- package/test/modules/vegvisir/VegvisirService.test.js +0 -37
- package/test/service/BlindGuardian.test.js +0 -84
- package/test/service/CheckAmeConf.test.js +0 -313
- package/test/service/Http.test.js +0 -312
- package/test/service/InviteService.test.js +0 -117
- package/test/service/MiniWebAppFactory.test.js +0 -40
- package/test/service/TagTree.test.js +0 -81
- package/test/service/TargetService.test.js +0 -48
- package/test/service/TrackingService.test.js +0 -105
- package/test/service/UserAmeConf.test.js +0 -47
- package/test/service/WoodCoffeeFactory.test.js +0 -148
- package/test/service/Workspace.test.js +0 -211
- package/test/utils/getWorkspaceId.test.js +0 -17
package/test/e2e/cli.test.js
DELETED
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
|
-
const util = require("util");
|
|
3
|
-
const puppeteer = require("puppeteer");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const execAsync = util.promisify(require("child_process").exec);
|
|
6
|
-
const axios = require("axios");
|
|
7
|
-
const minutes = 60000;
|
|
8
|
-
const Executor = require("../Executor.js");
|
|
9
|
-
const Helper = require("../Helper.js");
|
|
10
|
-
const ConfigService = require("../../src/service/ConfigService.js");
|
|
11
|
-
const Http = require("../../src/service/Http.js");
|
|
12
|
-
const BlindGuardian = require("../../src/service/BlindGuardian.js");
|
|
13
|
-
const childProcess = require('child_process');
|
|
14
|
-
const { writeFile, rm } = require("fs/promises");
|
|
15
|
-
const FOUNDRY_CONTEXT_PATH = process.env.FOUNDRY_CONTEXT_PATH ?? 'foundry'
|
|
16
|
-
|
|
17
|
-
describe("eitri-cli", () => {
|
|
18
|
-
const EITRI_WORK_DIR = path.join(__dirname, "..", "..", "developer-folder");
|
|
19
|
-
let devEnv = {
|
|
20
|
-
...process.env,
|
|
21
|
-
EITRI_CLI_CLIENT_ID: process.env.EITRI_CLI_CLIENT_ID,
|
|
22
|
-
EITRI_CLI_CLIENT_SECRET: process.env.EITRI_CLI_CLIENT_SECRET,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
beforeAll(async () => {
|
|
26
|
-
console.log('Cleaning the developer folder...')
|
|
27
|
-
await execAsync(
|
|
28
|
-
`cd ${EITRI_WORK_DIR} && rm -rf ./eitri-test-*`,
|
|
29
|
-
{ env: process.env }
|
|
30
|
-
);
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
afterEach(async () => {
|
|
34
|
-
await sleep(1000);
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it(
|
|
38
|
-
"should works",
|
|
39
|
-
async () => {
|
|
40
|
-
const EITRI_APP_NAME = `eitri-test-${Date.now()}`;
|
|
41
|
-
const executor = new Executor({ env: devEnv });
|
|
42
|
-
const startExecution = new Executor({ env: devEnv });
|
|
43
|
-
const pushVersion = new Executor({ env: devEnv });
|
|
44
|
-
try {
|
|
45
|
-
await executor
|
|
46
|
-
.exec(
|
|
47
|
-
`cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA`,
|
|
48
|
-
{ env: devEnv }
|
|
49
|
-
)
|
|
50
|
-
.waitFor(/Eitri-App criado com sucesso!/);
|
|
51
|
-
await sleep(200);
|
|
52
|
-
const EITRI_APP_FOLDER = path.resolve(
|
|
53
|
-
EITRI_WORK_DIR,
|
|
54
|
-
EITRI_APP_NAME
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
await startExecution
|
|
58
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
|
|
59
|
-
.waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/);
|
|
60
|
-
|
|
61
|
-
const line = await executor
|
|
62
|
-
.exec(`eitri workspace list`)
|
|
63
|
-
.waitFor(/Id:/i);
|
|
64
|
-
|
|
65
|
-
const workspaceId = line.split(/id:/i)[1].trim();
|
|
66
|
-
await axios.get(
|
|
67
|
-
`https://api.eitri.tech/${FOUNDRY_CONTEXT_PATH}/user/${workspaceId}/index.html`
|
|
68
|
-
);
|
|
69
|
-
await axios.get(
|
|
70
|
-
`https://api.eitri.tech/${FOUNDRY_CONTEXT_PATH}/user/${workspaceId}/Home.html`
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const textContent = `SomeText${Date.now()}Content`;
|
|
74
|
-
const promise = startExecution.waitFor(
|
|
75
|
-
/Forjado em ([0-9])+ milissegundos/
|
|
76
|
-
);
|
|
77
|
-
await execAsync(
|
|
78
|
-
`echo "<Text>${textContent}</Text>" > ${EITRI_APP_FOLDER}/src/views/Home.jsx`
|
|
79
|
-
);
|
|
80
|
-
await promise;
|
|
81
|
-
|
|
82
|
-
let res = await axios.get(
|
|
83
|
-
`https://api.eitri.tech/${FOUNDRY_CONTEXT_PATH}/user/${workspaceId}/index.js`
|
|
84
|
-
);
|
|
85
|
-
expect(res.data).toContain(textContent);
|
|
86
|
-
|
|
87
|
-
startExecution.child.kill("SIGKILL");
|
|
88
|
-
executor.child.kill("SIGKILL");
|
|
89
|
-
|
|
90
|
-
await pushVersion
|
|
91
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri push-version`)
|
|
92
|
-
.waitFor(/disponível no Eitri Console/);
|
|
93
|
-
pushVersion.child.kill("SIGKILL");
|
|
94
|
-
} catch (e) {
|
|
95
|
-
executor.child.kill("SIGKILL")
|
|
96
|
-
startExecution.child.kill("SIGKILL");
|
|
97
|
-
pushVersion.child.kill("SIGKILL");
|
|
98
|
-
console.error(e);
|
|
99
|
-
throw e;
|
|
100
|
-
} finally {
|
|
101
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
102
|
-
await Helper.delete(conf.id);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
2 * minutes
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
it("should do eitri login", async () => {
|
|
109
|
-
const loginVars = {
|
|
110
|
-
EITRI_TEST_LOGIN_EMAIL: process.env.EITRI_TEST_LOGIN_EMAIL,
|
|
111
|
-
EITRI_TEST_LOGIN_PASSWORD: process.env.EITRI_TEST_LOGIN_PASSWORD,
|
|
112
|
-
};
|
|
113
|
-
const executor = new Executor({ env: devEnv });
|
|
114
|
-
try {
|
|
115
|
-
const loginPromise = executor
|
|
116
|
-
.exec("eitri login --yes")
|
|
117
|
-
.waitFor(/Credencial gerada/);
|
|
118
|
-
|
|
119
|
-
const consoleUrl = ConfigService.get("managerFront").url;
|
|
120
|
-
const browser = await puppeteer.launch({
|
|
121
|
-
// headless: true,
|
|
122
|
-
// headless: false,
|
|
123
|
-
headless: "new",
|
|
124
|
-
args: ["--no-sandbox"],
|
|
125
|
-
});
|
|
126
|
-
const page = await browser.newPage();
|
|
127
|
-
|
|
128
|
-
const url = `${consoleUrl}/?loginType=EITRI_CLI&port=3333`
|
|
129
|
-
console.log(`Abrindo console ${url}`);
|
|
130
|
-
await page.goto(url);
|
|
131
|
-
page.on('console', async e => {
|
|
132
|
-
const args = await Promise.all(e.args().map(a => a.jsonValue()));
|
|
133
|
-
console.log('Puppeteer log:\n\t', ...args)
|
|
134
|
-
});
|
|
135
|
-
const inputEmail = await page.waitForXPath('//*[@id="email"]');
|
|
136
|
-
console.log(`Inserindo e-mail [${loginVars.EITRI_TEST_LOGIN_EMAIL}]`);
|
|
137
|
-
inputEmail.type(String(loginVars.EITRI_TEST_LOGIN_EMAIL).trim());
|
|
138
|
-
await sleep(1000);
|
|
139
|
-
const inputPassword = await page.waitForXPath(
|
|
140
|
-
'//*[@id="password"]'
|
|
141
|
-
);
|
|
142
|
-
const pass = String(loginVars.EITRI_TEST_LOGIN_PASSWORD)
|
|
143
|
-
console.log(`Inserindo password terminando com ${pass.substring(pass.length - 3)}`);
|
|
144
|
-
inputPassword.type(pass);
|
|
145
|
-
await sleep(500);
|
|
146
|
-
|
|
147
|
-
const buttonElement = await page.waitForXPath(
|
|
148
|
-
'//*[@id="button-do-login"]'
|
|
149
|
-
);
|
|
150
|
-
console.log("Clicando no botão");
|
|
151
|
-
await sleep(1000);
|
|
152
|
-
buttonElement.click();
|
|
153
|
-
await sleep(3000);
|
|
154
|
-
await browser.close();
|
|
155
|
-
await loginPromise;
|
|
156
|
-
const homeDir = os.homedir();
|
|
157
|
-
const executorLS = new Executor({ env: devEnv });
|
|
158
|
-
await executorLS.exec(`ls ${path.join(homeDir, '.eitri')}`)
|
|
159
|
-
.waitFor(/.*/);
|
|
160
|
-
console.log('ls output', executorLS.stdout)
|
|
161
|
-
const configFilePath = path.join(homeDir, '.eitri', 'dev.conf.js')
|
|
162
|
-
const config = require(configFilePath);
|
|
163
|
-
expect(config.devUser).toBeDefined();
|
|
164
|
-
expect(config.devKey).toBeDefined();
|
|
165
|
-
} catch (error) {
|
|
166
|
-
console.error(error);
|
|
167
|
-
throw error;
|
|
168
|
-
} finally {
|
|
169
|
-
executor.child.kill("SIGKILL")
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it(
|
|
174
|
-
"should do push-version",
|
|
175
|
-
async () => {
|
|
176
|
-
console.log("should do push-version - init")
|
|
177
|
-
const EITRI_APP_NAME = `eitri-test-${Date.now()}`;
|
|
178
|
-
const executor = new Executor({ env: devEnv });
|
|
179
|
-
const startExecution = new Executor({ env: devEnv });
|
|
180
|
-
const pushVersion = new Executor({ env: devEnv });
|
|
181
|
-
try {
|
|
182
|
-
console.log("==========================================")
|
|
183
|
-
console.log("Create")
|
|
184
|
-
console.log("==========================================")
|
|
185
|
-
await executor
|
|
186
|
-
.exec(
|
|
187
|
-
`cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA`,
|
|
188
|
-
{ env: devEnv }
|
|
189
|
-
)
|
|
190
|
-
.waitFor(/Eitri-App criado com sucesso!/);
|
|
191
|
-
await sleep(200);
|
|
192
|
-
|
|
193
|
-
const EITRI_APP_FOLDER = path.resolve(
|
|
194
|
-
EITRI_WORK_DIR,
|
|
195
|
-
EITRI_APP_NAME
|
|
196
|
-
);
|
|
197
|
-
console.log("==========================================")
|
|
198
|
-
console.log("Start")
|
|
199
|
-
console.log("==========================================")
|
|
200
|
-
await startExecution
|
|
201
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
|
|
202
|
-
.waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/);
|
|
203
|
-
|
|
204
|
-
startExecution.child.kill("SIGKILL");
|
|
205
|
-
|
|
206
|
-
await sleep(1000);
|
|
207
|
-
|
|
208
|
-
console.log("==========================================")
|
|
209
|
-
console.log("PUSH VERSION")
|
|
210
|
-
console.log("==========================================")
|
|
211
|
-
|
|
212
|
-
await pushVersion
|
|
213
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri push-version`)
|
|
214
|
-
.waitFor(/disponível no Eitri Console/);
|
|
215
|
-
|
|
216
|
-
await sleep(1000);
|
|
217
|
-
|
|
218
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
219
|
-
const data = await getPublishedVersion(conf.version, conf.id);
|
|
220
|
-
|
|
221
|
-
expect(data.length).toBe(1);
|
|
222
|
-
expect(data[0].version).toBe(conf.version);
|
|
223
|
-
expect(data[0].eitriAppId).toBe(conf.id);
|
|
224
|
-
} catch (e) {
|
|
225
|
-
executor.child.kill("SIGKILL");
|
|
226
|
-
startExecution.child.kill("SIGKILL");
|
|
227
|
-
pushVersion.child.kill("SIGKILL");
|
|
228
|
-
console.error(e);
|
|
229
|
-
throw e;
|
|
230
|
-
} finally {
|
|
231
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
232
|
-
await Helper.delete(conf.id);
|
|
233
|
-
}
|
|
234
|
-
console.log("should do push-version - end")
|
|
235
|
-
},
|
|
236
|
-
2 * minutes
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
it(
|
|
240
|
-
"should select workspace by name",
|
|
241
|
-
async () => {
|
|
242
|
-
const executor = new Executor({ env: devEnv });
|
|
243
|
-
try {
|
|
244
|
-
await executor
|
|
245
|
-
.exec("eitri workspace use --name DEFAULT")
|
|
246
|
-
.waitFor(/Workspace configurado com sucesso!/);
|
|
247
|
-
} catch (e) {
|
|
248
|
-
console.error(e);
|
|
249
|
-
throw e;
|
|
250
|
-
} finally {
|
|
251
|
-
executor.child.kill("SIGKILL")
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
2 * minutes
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
it(
|
|
258
|
-
"should list eitri libs versions",
|
|
259
|
-
async () => {
|
|
260
|
-
const executor = new Executor({ env: devEnv });
|
|
261
|
-
try {
|
|
262
|
-
await executor
|
|
263
|
-
.exec("eitri libs -l")
|
|
264
|
-
.waitFor(/libsVersions/);
|
|
265
|
-
expect(executor.stdout).toContain("luminusUiVersions");
|
|
266
|
-
expect(executor.stdout).toContain("versions");
|
|
267
|
-
expect(executor.stdout).toContain("bifrostVersions");
|
|
268
|
-
expect(executor.stdout).toContain("betaVersions");
|
|
269
|
-
expect(executor.stdout).toContain("alphaVersions");
|
|
270
|
-
} catch (e) {
|
|
271
|
-
executor.child.kill("SIGKILL")
|
|
272
|
-
console.error(e);
|
|
273
|
-
throw e;
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
2 * minutes
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
it(
|
|
280
|
-
"should do publish eitri-app",
|
|
281
|
-
async () => {
|
|
282
|
-
const EITRI_APP_NAME = `eitri-test-${Date.now()}`;
|
|
283
|
-
const executor = new Executor({ env: devEnv });
|
|
284
|
-
const startExecution = new Executor({ env: devEnv });
|
|
285
|
-
const pushVersion = new Executor({ env: devEnv });
|
|
286
|
-
const publishExecution = new Executor({ env: devEnv });
|
|
287
|
-
try {
|
|
288
|
-
await executor
|
|
289
|
-
.exec(
|
|
290
|
-
`cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA`,
|
|
291
|
-
{ env: devEnv }
|
|
292
|
-
)
|
|
293
|
-
.waitFor(/Eitri-App criado com sucesso!/);
|
|
294
|
-
executor.child.kill("SIGKILL");
|
|
295
|
-
await sleep(1000)
|
|
296
|
-
const EITRI_APP_FOLDER = path.resolve(
|
|
297
|
-
EITRI_WORK_DIR,
|
|
298
|
-
EITRI_APP_NAME
|
|
299
|
-
);
|
|
300
|
-
await startExecution
|
|
301
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
|
|
302
|
-
.waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/);
|
|
303
|
-
startExecution.child.kill("SIGKILL");
|
|
304
|
-
await sleep(1000)
|
|
305
|
-
|
|
306
|
-
await pushVersion
|
|
307
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri push-version`)
|
|
308
|
-
.waitFor(/disponível no Eitri Console/);
|
|
309
|
-
|
|
310
|
-
const devEnvironmentId = "852ff350-8d65-49cc-815e-12483b37d425"
|
|
311
|
-
await publishExecution
|
|
312
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri publish --environment ${devEnvironmentId} --message 'Teste e2e'`, { env: devEnv })
|
|
313
|
-
.waitFor(/Eitri-App publicado com sucesso!/)
|
|
314
|
-
|
|
315
|
-
publishExecution.child.kill("SIGKILL")
|
|
316
|
-
} catch (e) {
|
|
317
|
-
executor.child.kill("SIGKILL");
|
|
318
|
-
startExecution.child.kill("SIGKILL");
|
|
319
|
-
pushVersion.child.kill("SIGKILL");
|
|
320
|
-
publishExecution.child.kill("SIGKILL")
|
|
321
|
-
console.error(e);
|
|
322
|
-
throw e;
|
|
323
|
-
} finally {
|
|
324
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
325
|
-
await Helper.delete(conf.id);
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
3 * minutes
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
it("should do start and push-version using shared-eitri-app", async () => {
|
|
332
|
-
console.log("should do start and push-version using shared-eitri-app - init")
|
|
333
|
-
const EITRI_APP_NAME = `eitri-test-${Date.now()}`;
|
|
334
|
-
const executor = new Executor({ env: devEnv });
|
|
335
|
-
const startExecution = new Executor({ env: devEnv });
|
|
336
|
-
const pushVersion = new Executor({ env: devEnv });
|
|
337
|
-
try {
|
|
338
|
-
console.log("==========================================")
|
|
339
|
-
console.log("Create")
|
|
340
|
-
console.log("==========================================")
|
|
341
|
-
await executor
|
|
342
|
-
.exec(
|
|
343
|
-
`cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA --verbose`,
|
|
344
|
-
{ env: devEnv }
|
|
345
|
-
)
|
|
346
|
-
.waitFor(/Eitri-App criado com sucesso!/);
|
|
347
|
-
|
|
348
|
-
const EITRI_APP_FOLDER = path.resolve(
|
|
349
|
-
EITRI_WORK_DIR,
|
|
350
|
-
EITRI_APP_NAME
|
|
351
|
-
);
|
|
352
|
-
|
|
353
|
-
// Use Shared Eitri-App
|
|
354
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
355
|
-
expect(conf.id).toBeDefined()
|
|
356
|
-
expect(conf.name).toBe(EITRI_APP_NAME)
|
|
357
|
-
|
|
358
|
-
console.log({ conf })
|
|
359
|
-
conf['eitri-luminus'] = "@baldurs-gate:0.1.24"
|
|
360
|
-
const eitriConfPath = path.join(EITRI_APP_FOLDER, 'eitri-app.conf.js')
|
|
361
|
-
await writeFile(eitriConfPath, `module.exports = ${JSON.stringify(conf)}`)
|
|
362
|
-
|
|
363
|
-
const componentsFolderPath = path.join(EITRI_APP_FOLDER, 'src', 'components')
|
|
364
|
-
await rm(componentsFolderPath, { recursive: true, force: true })
|
|
365
|
-
|
|
366
|
-
console.log("==========================================")
|
|
367
|
-
console.log("Start")
|
|
368
|
-
console.log("==========================================")
|
|
369
|
-
await startExecution
|
|
370
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
|
|
371
|
-
.waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/);
|
|
372
|
-
startExecution.child.kill("SIGKILL");
|
|
373
|
-
|
|
374
|
-
console.log("==========================================")
|
|
375
|
-
console.log("PUSH VERSION")
|
|
376
|
-
console.log("==========================================")
|
|
377
|
-
|
|
378
|
-
await pushVersion
|
|
379
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri push-version`)
|
|
380
|
-
.waitFor(/disponível no Eitri Console/);
|
|
381
|
-
|
|
382
|
-
const data = await getPublishedVersion(conf.version, conf.id);
|
|
383
|
-
|
|
384
|
-
expect(data.length).toBe(1);
|
|
385
|
-
expect(data[0].version).toBe(conf.version);
|
|
386
|
-
expect(data[0].eitriAppId).toBe(conf.id);
|
|
387
|
-
} catch (e) {
|
|
388
|
-
executor.child.kill("SIGKILL");
|
|
389
|
-
startExecution.child.kill("SIGKILL");
|
|
390
|
-
pushVersion.child.kill("SIGKILL");
|
|
391
|
-
console.error(e);
|
|
392
|
-
throw e;
|
|
393
|
-
} finally {
|
|
394
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
395
|
-
await Helper.delete(conf.id);
|
|
396
|
-
}
|
|
397
|
-
console.log("should do push-version as shared-eitri-app - end")
|
|
398
|
-
}, 2 * minutes);
|
|
399
|
-
|
|
400
|
-
it("should do push-version as shared-eitri-app", async () => {
|
|
401
|
-
console.log("should do push-version as shared-eitri-app - init")
|
|
402
|
-
const EITRI_APP_NAME = `eitri-test-${Date.now()}`;
|
|
403
|
-
const executor = new Executor({ env: devEnv });
|
|
404
|
-
const startExecution = new Executor({ env: devEnv });
|
|
405
|
-
const pushVersion = new Executor({ env: devEnv });
|
|
406
|
-
try {
|
|
407
|
-
console.log("==========================================")
|
|
408
|
-
console.log("Create")
|
|
409
|
-
console.log("==========================================")
|
|
410
|
-
await executor
|
|
411
|
-
.exec(
|
|
412
|
-
`cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA`,
|
|
413
|
-
{ env: devEnv }
|
|
414
|
-
)
|
|
415
|
-
.waitFor(/Eitri-App criado com sucesso!/);
|
|
416
|
-
|
|
417
|
-
const EITRI_APP_FOLDER = path.resolve(
|
|
418
|
-
EITRI_WORK_DIR,
|
|
419
|
-
EITRI_APP_NAME
|
|
420
|
-
);
|
|
421
|
-
console.log("==========================================")
|
|
422
|
-
console.log("Start")
|
|
423
|
-
console.log("==========================================")
|
|
424
|
-
await startExecution
|
|
425
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
|
|
426
|
-
.waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/);
|
|
427
|
-
|
|
428
|
-
startExecution.child.kill("SIGKILL");
|
|
429
|
-
|
|
430
|
-
const exportComponentsPath = path.join(EITRI_APP_FOLDER, 'src', 'export.js')
|
|
431
|
-
await writeFile(exportComponentsPath, `export {default as HeaderComponent} from './components/HeaderComponent.js'`)
|
|
432
|
-
|
|
433
|
-
console.log("==========================================")
|
|
434
|
-
console.log("PUSH VERSION")
|
|
435
|
-
console.log("==========================================")
|
|
436
|
-
|
|
437
|
-
await pushVersion
|
|
438
|
-
.exec(`cd ${EITRI_APP_FOLDER} && eitri push-version --shared`)
|
|
439
|
-
.waitFor(/disponível no Eitri Console/);
|
|
440
|
-
|
|
441
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
442
|
-
const data = await getPublishedVersion(conf.version, conf.id);
|
|
443
|
-
|
|
444
|
-
expect(data.length).toBe(1);
|
|
445
|
-
expect(data[0].version).toBe(conf.version);
|
|
446
|
-
expect(data[0].eitriAppId).toBe(conf.id);
|
|
447
|
-
} catch (e) {
|
|
448
|
-
executor.child.kill("SIGKILL");
|
|
449
|
-
startExecution.child.kill("SIGKILL");
|
|
450
|
-
pushVersion.child.kill("SIGKILL");
|
|
451
|
-
console.error(e);
|
|
452
|
-
throw e;
|
|
453
|
-
} finally {
|
|
454
|
-
const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
|
|
455
|
-
await Helper.delete(conf.id);
|
|
456
|
-
}
|
|
457
|
-
console.log("should do push-version as shared-eitri-app - end")
|
|
458
|
-
}, 2 * minutes);
|
|
459
|
-
|
|
460
|
-
const getPublishedVersion = async (version, eitriAppId) => {
|
|
461
|
-
const blindGuardian = new BlindGuardian();
|
|
462
|
-
const http = new Http(blindGuardian);
|
|
463
|
-
|
|
464
|
-
const url = `https://api.eitri.tech/eitri-manager-api/revisions?eitriAppId=${eitriAppId}&version=${version}`;
|
|
465
|
-
|
|
466
|
-
const data = await http.get(url);
|
|
467
|
-
return data;
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
const sleep = (timeInMs) => {
|
|
471
|
-
return new Promise((resolve) => setTimeout(resolve, timeInMs));
|
|
472
|
-
};
|
|
473
|
-
});
|
package/test/miniapp.conf.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
const Payload = require('../../src/model/Payload')
|
|
3
|
-
|
|
4
|
-
describe('Payload Test', () => {
|
|
5
|
-
|
|
6
|
-
it('should return shareId', () => {
|
|
7
|
-
const shareId= '123456'
|
|
8
|
-
const shareEnvironment= 'test'
|
|
9
|
-
|
|
10
|
-
const payload = new Payload(shareId, shareEnvironment)
|
|
11
|
-
|
|
12
|
-
expect(payload.shareId).toEqual(shareId)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('should return shareEnvironment', () => {
|
|
16
|
-
const shareId= '123456'
|
|
17
|
-
const shareEnvironment= 'test'
|
|
18
|
-
|
|
19
|
-
const payload = new Payload(shareId, shareEnvironment)
|
|
20
|
-
|
|
21
|
-
expect(payload.shareEnvironment).toEqual(shareEnvironment)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('should return a payload object', () => {
|
|
25
|
-
const shareId= '123456'
|
|
26
|
-
const shareEnvironment= 'test'
|
|
27
|
-
|
|
28
|
-
const payload = new Payload(shareId, shareEnvironment)
|
|
29
|
-
|
|
30
|
-
expect(payload).toEqual({
|
|
31
|
-
shareId,
|
|
32
|
-
shareEnvironment
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
})
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const VegvisirService = require("../../../src/modules/vegvisir/VegvisirService");
|
|
2
|
-
const Factory = require("../../Factory");
|
|
3
|
-
describe("Vegvisir Service Test", () => {
|
|
4
|
-
let vegvisirService = new VegvisirService();
|
|
5
|
-
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
vegvisirService = new VegvisirService();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("should return error when user doesn't have workspace", async () => {
|
|
11
|
-
vegvisirService.http = {
|
|
12
|
-
get: () =>
|
|
13
|
-
Promise.reject({
|
|
14
|
-
isAxiosError: true,
|
|
15
|
-
response: {
|
|
16
|
-
status: 404,
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
const consoleErrorSpy = jest.spyOn(console, "error");
|
|
21
|
-
await vegvisirService.listMyWorkspaces();
|
|
22
|
-
|
|
23
|
-
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
24
|
-
"Você não possui workspaces cadastrados, utilize o comando 'eitri workspace create' para cadastrar"
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should list all user workspaces", async () => {
|
|
29
|
-
vegvisirService.http = {
|
|
30
|
-
get: () => Promise.resolve(Factory.generateWorkspace()),
|
|
31
|
-
};
|
|
32
|
-
const result = await vegvisirService.listMyWorkspaces();
|
|
33
|
-
|
|
34
|
-
expect(result).toBeTruthy();
|
|
35
|
-
expect(result.length).toBeGreaterThan(0);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
|
|
3
|
-
const nock = require('nock')
|
|
4
|
-
const BlindGuardian = require('../../src/service/BlindGuardian')
|
|
5
|
-
|
|
6
|
-
describe('BlindGuardian', () => {
|
|
7
|
-
let blindGuardian
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
blindGuardian = new BlindGuardian()
|
|
10
|
-
blindGuardian.readConf = () => {
|
|
11
|
-
return {
|
|
12
|
-
devUser: 'foo',
|
|
13
|
-
devKey: 'bar',
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
nock.cleanAll()
|
|
19
|
-
})
|
|
20
|
-
describe('.getToken()', () => {
|
|
21
|
-
it('retorna o token do usuario', async () => {
|
|
22
|
-
nock('https://dev.eitri.calindra.com.br')
|
|
23
|
-
.post('/blind-guardian-api/v1/o/auth', {
|
|
24
|
-
client_id: 'foo',
|
|
25
|
-
client_secret: 'bar',
|
|
26
|
-
grant_type: 'client_credentials',
|
|
27
|
-
})
|
|
28
|
-
.reply(200, { accessToken: 'xpto' })
|
|
29
|
-
let credential = await blindGuardian.getToken()
|
|
30
|
-
expect(credential.accessToken).toBe('xpto')
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('lanca um erro quando as credenciais estao erradas', (done) => {
|
|
34
|
-
nock('https://dev.eitri.calindra.com.br')
|
|
35
|
-
.post('/blind-guardian-api/v1/o/auth', {
|
|
36
|
-
client_id: 'foo',
|
|
37
|
-
client_secret: 'bar',
|
|
38
|
-
grant_type: 'client_credentials',
|
|
39
|
-
})
|
|
40
|
-
.reply(403, {})
|
|
41
|
-
|
|
42
|
-
blindGuardian
|
|
43
|
-
.getToken()
|
|
44
|
-
.then(() => {
|
|
45
|
-
done('nao deveria passar por aqui')
|
|
46
|
-
})
|
|
47
|
-
.catch((err) => {
|
|
48
|
-
try {
|
|
49
|
-
expect(err.message).toBe('Credencial inválida')
|
|
50
|
-
done()
|
|
51
|
-
} catch (e) {
|
|
52
|
-
done(e)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('lanca um erro generico quando o erro nao eh 403', (done) => {
|
|
58
|
-
nock('https://dev.eitri.calindra.com.br')
|
|
59
|
-
.post('/blind-guardian-api/v1/o/auth', {
|
|
60
|
-
client_id: 'foo',
|
|
61
|
-
client_secret: 'bar',
|
|
62
|
-
grant_type: 'client_credentials',
|
|
63
|
-
})
|
|
64
|
-
.reply(500, {})
|
|
65
|
-
|
|
66
|
-
blindGuardian
|
|
67
|
-
.getToken()
|
|
68
|
-
.then(() => {
|
|
69
|
-
done('nao deveria passar por aqui')
|
|
70
|
-
})
|
|
71
|
-
.catch((err) => {
|
|
72
|
-
try {
|
|
73
|
-
expect(err.message).toBe(
|
|
74
|
-
'Por favor tente novamente mais tarde.'
|
|
75
|
-
)
|
|
76
|
-
done()
|
|
77
|
-
} catch (e) {
|
|
78
|
-
done(e)
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
})
|