eitri-cli 1.2.1 → 1.3.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.
@@ -1,11 +1,25 @@
1
- image: node:18
1
+ image: node:18-alpine
2
2
  pipelines:
3
+ custom:
4
+ test-validation:
5
+ - step:
6
+ name: Run validation tests
7
+ caches:
8
+ - node
9
+ script:
10
+ - yarn
11
+ - npm i -g .
12
+ - export FOUNDRY_CONTEXT_PATH=runes-foundry
13
+ - yarn test cli.test.js --force-exit
3
14
  default:
4
15
  - step: &runTests
5
16
  name: Run tests
6
17
  caches:
7
18
  - node
8
19
  script:
20
+ - apk add git
21
+ - apk add chromium
22
+ - export PUPPETEER_EXECUTABLE_PATH='/usr/bin/chromium-browser'
9
23
  - yarn
10
24
  - npm i -g .
11
25
  - yarn test cli.test.js --force-exit
@@ -19,6 +33,7 @@ pipelines:
19
33
  caches:
20
34
  - node
21
35
  script:
36
+ - apk add git
22
37
  - echo 'Start release'
23
38
  - echo 'If there is a new version, it will be automatically published on NPM according to the channel/branch (beta or master (stable)).'
24
39
  - yarn
package/config/dev.js CHANGED
@@ -86,11 +86,9 @@ const config = {
86
86
  url: "https://analytics.dev.eitri.calindra.com.br/analytics/event",
87
87
  },
88
88
  managerFront: {
89
- url: `https://admin.${HOST}`,
89
+ url: `https://console.eitri.tech`,
90
90
  managerCredential: "/settings/manager-credential",
91
91
  cliGenerateLoginCredential: "/settings/cli-generate-credential",
92
-
93
- url: `https://admin.${HOST}`,
94
92
  },
95
93
  vegvisir: {
96
94
  url: `https://${HOST}`,
@@ -3,7 +3,7 @@ const HOST = ipv4()[0];
3
3
  const packageJson = require("../package.json");
4
4
  const PORT = process.env.EITRI_APP_TOOLS_PORT || 3333;
5
5
  const path = require("path");
6
- const HOST_EITRIAPPS = "dev.eitri.calindra.com.br";
6
+ const HOST_EITRIAPPS = "api.eitri.tech";
7
7
 
8
8
  const config = {
9
9
  userAgent: packageJson.name,
package/index.js CHANGED
@@ -30,6 +30,7 @@ const run = async () => {
30
30
  .description(
31
31
  "Configura suas credenciais de desenvolvedor no dispositivo local"
32
32
  )
33
+ .option("--yes", "Aceita o redirecionamento para o console")
33
34
  .action(async (cmdObj) => {
34
35
  require("./src/cmd/login")(cmdObj);
35
36
  });
@@ -41,7 +42,10 @@ const run = async () => {
41
42
  "--yes",
42
43
  "Aceita os valores default para nome título e organização"
43
44
  )
44
- .option("--application <application>", "Define o application de execução do Eitri-App")
45
+ .option(
46
+ "--application <application>",
47
+ "Define o application de execução do Eitri-App"
48
+ )
45
49
  .option("-v, --verbose", "Exibe mais logs")
46
50
  .action((projectName, cmdObj) => {
47
51
  require("./src/cmd/create")(projectName, cmdObj);
@@ -53,9 +57,13 @@ const run = async () => {
53
57
  .option("-v, --verbose", "Exibe mais logs")
54
58
  .option("-f, --force", "Força o start")
55
59
  .option("-S, --show-deeplink", "Exibe o deep link do workspace")
56
- .option(
60
+ .option(
57
61
  "-P, --qr-printer <qrPrinter>",
58
62
  "Indica qual programa imprimirá o QR Code. Se omitido, exibe o QrCode no terminal. Valores válidos: terminal|chrome|msedge|firefox"
63
+ )
64
+ .option(
65
+ "-e, --emulator <platform>",
66
+ "Abre o Eitri-App no emulador, desde que seja definido qual plataforma será aberto, android ou ios."
59
67
  );
60
68
 
61
69
  startProgram.action((cmdObj) => {
@@ -83,14 +91,14 @@ const run = async () => {
83
91
  });
84
92
 
85
93
  program
86
- .command('clean')
94
+ .command("clean")
87
95
  .description(
88
- 'Realiza a limpeza do workspace remoto do desenvolvedor. Útil quando há mal fucionamento na compilação em nuvem do Eitri-App.'
96
+ "Realiza a limpeza do workspace remoto do desenvolvedor. Útil quando há mal fucionamento na compilação em nuvem do Eitri-App."
89
97
  )
90
- .option('-v, --verbose', 'Exibe mais logs')
91
- .action(cmdObj => {
92
- require('./src/cmd/clean')(cmdObj)
93
- })
98
+ .option("-v, --verbose", "Exibe mais logs")
99
+ .action((cmdObj) => {
100
+ require("./src/cmd/clean")(cmdObj);
101
+ });
94
102
 
95
103
  program
96
104
  .command("self-update")
@@ -102,7 +110,7 @@ const run = async () => {
102
110
  );
103
111
  });
104
112
 
105
- program.addCommand(VegvisirCommand())
113
+ program.addCommand(VegvisirCommand());
106
114
 
107
115
  if (
108
116
  process.argv.length > 2 &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.0-beta.1",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -61,6 +61,7 @@
61
61
  "tmp": "^0.1.0",
62
62
  "tough-cookie": "^3.0.1",
63
63
  "tough-cookie-file-store": "^2.0.2",
64
+ "uri-scheme": "^1.1.0",
64
65
  "uuid": "^7.0.2"
65
66
  },
66
67
  "devDependencies": {
@@ -73,9 +74,10 @@
73
74
  "eslint": "^6.7.2",
74
75
  "eslint-config-google": "^0.14.0",
75
76
  "husky": "^8.0.3",
76
- "jest": "^24.9.0",
77
+ "jest": "^29.7.0",
77
78
  "lint-staged": "^9.5.0",
78
79
  "nock": "^13.3.0",
80
+ "puppeteer": "^21.4.1",
79
81
  "semantic-release": "^22.0.5"
80
82
  },
81
83
  "resolutions": {
package/src/cmd/login.js CHANGED
@@ -1,53 +1,70 @@
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')
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
6
 
7
7
  module.exports = async function login(args) {
8
8
  try {
9
- console.log("\n\n")
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}`;
10
15
 
11
- const {openPortalAnwser} = await inquirer.prompt([
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([
12
30
  {
13
- type: 'confirm',
14
- name: 'openPortalAnwser',
15
- message: ' Podemos redirecioná-lo para o login?',
31
+ type: "confirm",
32
+ name: "openPortalAnwser",
33
+ message: " Podemos redirecioná-lo para o login?",
16
34
  },
17
- ])
18
-
19
- const res = Server.startCliLogin()
20
-
21
- const urlAdminManagerCredential = `${configService.get("managerFront").url}`
22
- const urlAdminManagerCredentialWithParams = `${urlAdminManagerCredential}?loginType=EITRI_CLI&port=${res?.port}`
23
-
24
- let portalOpenMessage = ""
35
+ ]);
25
36
 
26
37
  if (openPortalAnwser) {
27
- console.log("\n", "Redirecionando...")
38
+ console.log("\n", "Redirecionando...");
28
39
  try {
29
- open(urlAdminManagerCredentialWithParams)
30
- portalOpenMessage = "Aberto em seu navegador padrão"
40
+ open(urlAdminManagerCredentialWithParams);
41
+ portalOpenMessage = "Aberto em seu navegador padrão";
31
42
  } catch (error) {
32
- portalOpenMessage = "Não foi possível abrir automaticamente. Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. " + urlAdminManagerCredentialWithParams
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;
33
46
  }
34
47
  } else {
35
- portalOpenMessage = "Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. " + urlAdminManagerCredentialWithParams
48
+ portalOpenMessage =
49
+ "Copie o link e cole em seu navegador para fazer o login na Eitri-CLI. " +
50
+ urlAdminManagerCredentialWithParams;
36
51
  }
37
52
 
38
- console.log("\n", portalOpenMessage)
39
- console.log("\n\n Aguardando autenticação...")
53
+ console.log("\n", portalOpenMessage);
54
+ console.log("\n\n Aguardando autenticação...");
40
55
  } catch (error) {
41
56
  TrackingEitriAnalytics.sendEvent({
42
57
  eventName: "login.error",
43
58
  data: {
44
- errorMessage: error?.message ?? ""
45
- }
46
- })
59
+ errorMessage: error?.message ?? "",
60
+ },
61
+ });
47
62
 
48
- console.log('Erro inesperado, tente novamente mais tarde.', error?.message)
63
+ console.log(
64
+ "Erro inesperado, tente novamente mais tarde.",
65
+ error?.message
66
+ );
49
67
 
50
- process.exit(1)
68
+ process.exit(1);
51
69
  }
52
-
53
- }
70
+ };
@@ -1,70 +1,146 @@
1
- const QRCodeFactory = require('../QRCodeFactory')
2
-
3
- function QRCodeStarter(args, trackingService, watcher, workspace, targetConfig ) {
4
- this.args = args
5
- this.trackingService = trackingService
6
- this.watcher = watcher
7
- this.workspace = workspace
8
- this.targetConfig = targetConfig
1
+ const QRCodeFactory = require("../QRCodeFactory");
2
+ const { Ios, Android } = require("uri-scheme");
3
+ const readline = require("readline");
4
+ const chalk = require("chalk");
5
+ const os = require("os");
6
+ function QRCodeStarter(
7
+ args,
8
+ trackingService,
9
+ watcher,
10
+ workspace,
11
+ targetConfig
12
+ ) {
13
+ this.args = args;
14
+ this.trackingService = trackingService;
15
+ this.watcher = watcher;
16
+ this.workspace = workspace;
17
+ this.targetConfig = targetConfig;
9
18
 
10
19
  this.startServer = async function () {
11
- let fullUrl
20
+ let fullUrl;
12
21
  if (this.args.oldQrcode) {
13
- fullUrl = await this.workspace.getWorkspaceURL(this.args, this.targetConfig)
22
+ fullUrl = await this.workspace.getWorkspaceURL(
23
+ this.args,
24
+ this.targetConfig
25
+ );
14
26
  } else {
15
- const {miniAppUrl} = await this.workspace.getNewWorkspaceURL(this.args, this.targetConfig)
16
- fullUrl = miniAppUrl
27
+ const { miniAppUrl } = await this.workspace.getNewWorkspaceURL(
28
+ this.args,
29
+ this.targetConfig
30
+ );
31
+ fullUrl = miniAppUrl;
17
32
  }
18
33
 
19
34
  if (this.args.verbose) {
20
- console.log(`QrCodeUrl: ${fullUrl}`)
35
+ console.log(`QrCodeUrl: ${fullUrl}`);
21
36
  }
22
37
 
23
- this.watcher.start()
24
- if(this.args.showDeeplink){
25
- console.log('######################################')
26
- console.log('########### Deep Link URL ############')
27
- console.log('######################################')
28
- console.log(`${fullUrl}`)
29
- console.log('######################################')
38
+ this.watcher.start();
39
+ if (this.args.showDeeplink) {
40
+ console.log("######################################");
41
+ console.log("########### Deep Link URL ############");
42
+ console.log("######################################");
43
+ console.log(`${fullUrl}`);
44
+ console.log("######################################");
30
45
  }
31
46
 
32
- const _QRCodeFactory = new QRCodeFactory()
47
+ const _QRCodeFactory = new QRCodeFactory();
33
48
 
34
- const eitriAppSlug = this.workspace?._miniConf?.slug ?? ""
35
- const qrCodePath = await _QRCodeFactory.create(fullUrl, eitriAppSlug)
49
+ const eitriAppSlug = this.workspace?._miniConf?.slug ?? "";
50
+ const qrCodePath = await _QRCodeFactory.create(fullUrl, eitriAppSlug);
36
51
 
37
52
  if (this.args.verbose) {
38
- console.log(`QrCode Path: ${qrCodePath}`)
53
+ console.log(`QrCode Path: ${qrCodePath}`);
54
+ }
55
+
56
+ _QRCodeFactory.generate({ ...this.args, qrCodePath, fullUrl });
57
+
58
+ if (this.args.emulator) {
59
+ tryOpenEmulator(fullUrl, args);
39
60
  }
40
61
 
41
- _QRCodeFactory.generate({...this.args, qrCodePath, fullUrl})
62
+ listenerKeyPressToOpenEmulator(fullUrl);
63
+ };
64
+ }
65
+
66
+ function tryOpenEmulator(fullUrl, args) {
67
+ const shareId = extractShareId(fullUrl);
68
+ const { emulator } = args;
69
+ if (emulator === "ios") {
70
+ return Ios.openAsync({ uri: `eitri://workspace/${shareId}` }).catch(
71
+ () => {
72
+ console.error(
73
+ `Houve um erro ao tentar abrir o Eitri-App na plataforma iOS`
74
+ );
75
+ }
76
+ );
42
77
  }
78
+ return Android.openAsync({ uri: `eitri://workspace/${shareId}` }).catch(
79
+ () => {
80
+ console.error(
81
+ `Houve um erro ao tentar abrir o Eitri-App na plataforma Android`
82
+ );
83
+ }
84
+ );
43
85
  }
44
86
 
45
- function tryToOpenAndroidEmulator(fullUrl, args) {
46
- try {
47
- const cmd = `adb shell am start -a android.intent.action.VIEW -d "${encodeURIComponent(fullUrl)}"`
48
- let options = {}
49
- if (args.verbose) {
50
- options.stdio = 'inherit'
51
- require('child_process').execSync(cmd, options)
52
- } else {
53
- require('child_process').exec(cmd, options, () => {
54
- // ignora erros
55
- })
87
+ function listenerKeyPressToOpenEmulator(url) {
88
+ console.log("================================================");
89
+ console.log(`\t${chalk.green.bold("Abertura de Eitri-App automática")}`);
90
+ console.log("================================================");
91
+ console.log(`Pressione ${chalk.blue.bold("a")} para abrir no Android`);
92
+ if (os.platform() === "darwin") {
93
+ console.log(`Pressione ${chalk.blue.bold("i")} para abrir no iOS`);
94
+ }
95
+ console.log(
96
+ `Pressione ${chalk.blue.bold(
97
+ "q"
98
+ )} para finalizar a execução do Eitri-App`
99
+ );
100
+ console.log("================================================");
101
+ readline.emitKeypressEvents(process.stdin);
102
+
103
+ if (process.stdin.isTTY) process.stdin.setRawMode(true);
104
+
105
+ process.stdin.on("keypress", (chunk, key) => {
106
+ if (key && key.name == "a") {
107
+ const emulator = "android";
108
+ console.log("Abrindo Eitri-App no Android");
109
+ tryOpenEmulator(url, { emulator });
56
110
  }
57
- } catch(e) {
58
- if (args.verbose) {
59
- console.log(e)
111
+ if (os.platform() === "darwin" && key && key.name == "i") {
112
+ const emulator = "ios";
113
+ console.log("Abrindo Eitri-App no iOS");
114
+ tryOpenEmulator(url, { emulator });
60
115
  }
61
- }
116
+ if (key && key.name == "q") {
117
+ console.log("Parando execução do Eitri-App");
118
+ process.exit(0);
119
+ }
120
+ });
62
121
  }
63
122
 
64
- function QRCodeContentFactory(){
65
- this.create = function (args, trackingService, watcher, workspace, targetConfig) {
66
- return new QRCodeStarter(args, trackingService, watcher, workspace, targetConfig )
67
- }
123
+ function extractShareId(url) {
124
+ const [, shareId] = url.split("/share/");
125
+ return shareId;
126
+ }
127
+
128
+ function QRCodeContentFactory() {
129
+ this.create = function (
130
+ args,
131
+ trackingService,
132
+ watcher,
133
+ workspace,
134
+ targetConfig
135
+ ) {
136
+ return new QRCodeStarter(
137
+ args,
138
+ trackingService,
139
+ watcher,
140
+ workspace,
141
+ targetConfig
142
+ );
143
+ };
68
144
  }
69
145
 
70
- module.exports = QRCodeContentFactory
146
+ module.exports = QRCodeContentFactory;
@@ -1,68 +1,143 @@
1
- const util = require("util")
2
- const path = require("path")
3
- const execAsync = util.promisify(require("child_process").exec)
4
- const axios = require("axios")
5
- const minutes = 60000
6
- const Executor = require("../Executor.js")
7
- const Helper = require("../Helper.js")
1
+ const util = require("util");
2
+ const puppeteer = require("puppeteer");
3
+ const path = require("path");
4
+ const execAsync = util.promisify(require("child_process").exec);
5
+ const axios = require("axios");
6
+ const minutes = 60000;
7
+ const Executor = require("../Executor.js");
8
+ const Helper = require("../Helper.js");
9
+ const ConfigService = require("../../src/service/ConfigService.js");
8
10
 
9
11
  describe("eitri-cli", () => {
10
-
11
- const EITRI_WORK_DIR = path.join(__dirname, '..', '..', 'developer-folder')
12
+ const EITRI_WORK_DIR = path.join(__dirname, "..", "..", "developer-folder");
12
13
  let devEnv = {
13
14
  ...process.env,
14
15
  EITRI_CLI_CLIENT_ID: process.env.EITRI_CLI_CLIENT_ID,
15
16
  EITRI_CLI_CLIENT_SECRET: process.env.EITRI_CLI_CLIENT_SECRET,
16
- }
17
+ };
18
+
19
+ it(
20
+ "should works",
21
+ async () => {
22
+ const EITRI_APP_NAME = `eitri-test-${Date.now()}`;
23
+ try {
24
+ await execAsync(
25
+ `cd ${EITRI_WORK_DIR} && rm -rf ./eitri-test-*`,
26
+ { env: process.env }
27
+ );
28
+
29
+ const executor = new Executor({ env: devEnv });
30
+ await executor
31
+ .exec(
32
+ `cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA`,
33
+ { env: devEnv }
34
+ )
35
+ .waitFor(/Download de template completo/);
36
+ await new Promise((resolve) => setTimeout(resolve, 200));
37
+ const EITRI_APP_FOLDER = path.resolve(
38
+ EITRI_WORK_DIR,
39
+ EITRI_APP_NAME
40
+ );
41
+
42
+ const startExecution = new Executor({ env: devEnv });
43
+ await startExecution
44
+ .exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
45
+ .waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/);
46
+
47
+ const line = await executor
48
+ .exec(`eitri workspace list`)
49
+ .waitFor(/Id:/i);
50
+
51
+ const workspaceId = line.split(/id:/i)[1].trim();
52
+ await axios.get(
53
+ `https://api.eitri.tech/foundry/user/${workspaceId}/index.html`
54
+ );
55
+ await axios.get(
56
+ `https://api.eitri.tech/foundry/user/${workspaceId}/Home.html`
57
+ );
58
+
59
+ const textContent = `SomeText${Date.now()}Content`;
60
+ const promise = startExecution.waitFor(
61
+ /Forjado em ([0-9])+ milissegundos/
62
+ );
63
+ await execAsync(
64
+ `echo "<Text>${textContent}</Text>" > ${EITRI_APP_FOLDER}/src/views/Home.jsx`
65
+ );
66
+ await promise;
17
67
 
18
- it("should works", async () => {
19
- const EITRI_APP_NAME = `eitri-test-${Date.now()}`
68
+ let res = await axios.get(
69
+ `https://api.eitri.tech/foundry/user/${workspaceId}/index.js`
70
+ );
71
+ expect(res.data).toContain(textContent);
72
+
73
+ startExecution.child.kill();
74
+ executor.child.kill();
75
+
76
+ const pushVersion = new Executor({ env: devEnv });
77
+ await pushVersion
78
+ .exec(`cd ${EITRI_APP_FOLDER} && eitri push-version`)
79
+ .waitFor(/disponível no Eitri Console/);
80
+ pushVersion.child.kill();
81
+
82
+ const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`);
83
+ await Helper.delete(conf.id);
84
+ } catch (e) {
85
+ console.error(e);
86
+ throw e;
87
+ }
88
+ },
89
+ 2 * minutes
90
+ );
91
+
92
+ it("should do eitri login", async () => {
93
+ const loginVars = {
94
+ EITRI_TEST_LOGIN_EMAIL: process.env.EITRI_TEST_LOGIN_EMAIL,
95
+ EITRI_TEST_LOGIN_PASSWORD: process.env.EITRI_TEST_LOGIN_PASSWORD,
96
+ };
20
97
  try {
98
+ const consoleUrl = ConfigService.get("managerFront").url;
99
+ const browser = await puppeteer.launch({
100
+ headless: "new",
101
+ args: ["--no-sandbox"],
102
+ });
103
+ const page = await browser.newPage();
104
+
105
+ console.log("Abrindo console");
106
+ await page.goto(consoleUrl);
107
+ const inputEmail = await page.waitForXPath('//*[@id="email"]');
108
+ console.log("Inserindo e-mail");
109
+ inputEmail.type(String(loginVars.EITRI_TEST_LOGIN_EMAIL));
110
+ await sleep(1000);
111
+ const inputPassword = await page.waitForXPath(
112
+ '//*[@id="password"]'
113
+ );
114
+ console.log("Inserindo password");
115
+ inputPassword.type(String(loginVars.EITRI_TEST_LOGIN_PASSWORD));
116
+
117
+ const buttonElement = await page.waitForXPath(
118
+ "/html/body/div/div/div[2]/div[2]/div/div/div/form/div/button"
119
+ );
120
+ console.log("Clicando no botão");
121
+ buttonElement.click();
122
+ await sleep(4000);
123
+
124
+ const executor = new Executor({ env: devEnv });
125
+ executor
126
+ .exec("eitri login --yes --verbose")
127
+ .waitFor(/Credencial gerada! Você está logado/);
21
128
 
22
- await execAsync(`cd ${EITRI_WORK_DIR} && rm -rf ./eitri-test-*`, { env: process.env })
23
-
24
- const executor = new Executor({ env: devEnv })
25
- await executor
26
- .exec(`cd ${EITRI_WORK_DIR} && eitri create ${EITRI_APP_NAME} --yes --application=APPLICATION_CALINDRA`, { env: devEnv })
27
- .waitFor(/Download de template completo/)
28
- await new Promise(resolve => setTimeout(resolve, 200))
29
- const EITRI_APP_FOLDER = path.resolve(EITRI_WORK_DIR, EITRI_APP_NAME)
30
-
31
- const startExecution = new Executor({ env: devEnv })
32
- await startExecution
33
- .exec(`cd ${EITRI_APP_FOLDER} && eitri start`)
34
- .waitFor(/Utilize o QR-Code para iniciar o seu Eitri-App/)
35
-
36
- const line = await executor
37
- .exec(`eitri workspace list`)
38
- .waitFor(/Id:/i)
39
-
40
- const workspaceId = line.split(/id:/i)[1].trim()
41
- await axios.get(`https://api.eitri.tech/foundry/user/${workspaceId}/index.html`)
42
- await axios.get(`https://api.eitri.tech/foundry/user/${workspaceId}/Home.html`)
43
-
44
- const textContent = `SomeText${Date.now()}Content`
45
- const promise = startExecution.waitFor(/Forjado em ([0-9])+ milissegundos/)
46
- await execAsync(`echo "<Text>${textContent}</Text>" > ${EITRI_APP_FOLDER}/src/views/Home.jsx`)
47
- await promise
48
-
49
- let res = await axios.get(`https://api.eitri.tech/foundry/user/${workspaceId}/index.js`)
50
- expect(res.data).toContain(textContent)
51
-
52
- startExecution.child.kill()
53
- executor.child.kill()
54
-
55
- const pushVersion = new Executor({ env: devEnv })
56
- await pushVersion.exec(`cd ${EITRI_APP_FOLDER} && eitri push-version`)
57
- .waitFor(/disponível no Eitri Console/)
58
- pushVersion.child.kill()
59
-
60
- const conf = require(`../../developer-folder/${EITRI_APP_NAME}/eitri-app.conf.js`)
61
- await Helper.delete(conf.id)
62
- } catch (e) {
63
- console.error(e)
64
- throw e
129
+ console.log(
130
+ "Executando login e abrindo no pupeeteer para enviar as credenciais geradas para a CLI"
131
+ );
132
+ await page.goto(`${consoleUrl}/?loginType=EITRI_CLI&port=3333`);
133
+ await browser.close();
134
+ } catch (error) {
135
+ console.error(error);
136
+ throw error;
65
137
  }
66
- }, 2 * minutes)
138
+ });
67
139
 
68
- })
140
+ const sleep = (timeInMs) => {
141
+ return new Promise((resolve) => setTimeout(resolve, timeInMs));
142
+ };
143
+ });