eitri-cli 1.15.0 → 1.16.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.
@@ -44,8 +44,10 @@ pipelines:
44
44
  caches:
45
45
  - node
46
46
  script:
47
+ - mkdir -p ~/.eitri/workspaces
48
+ - cp -r eitri-cli-v2/tests/fixtures/fake-workspace ~/.eitri/workspaces/workspace
47
49
  - cd eitri-cli-v2
48
- - cargo test -- --test-threads=1
50
+ - cargo test -- --test-threads=1 --nocapture
49
51
  - step: &macOSCrossCompile
50
52
  image:
51
53
  name: 343482176926.dkr.ecr.us-east-1.amazonaws.com/eitri-base-cli-pipeline:macos
@@ -35,6 +35,12 @@ log = "0.4.21"
35
35
  env_logger = "0.11.3"
36
36
  crossterm = "0.27.0"
37
37
  spinners = "4.1.1"
38
+ regex = "1.10.4"
39
+ walkdir = "2.5.0"
40
+ zip = "2.1.0"
41
+ sha1 = "0.10.6"
42
+ file-hashing = "0.1.2"
43
+ qr2term = "0.3.1"
38
44
 
39
45
  [dependencies.uuid]
40
46
  version = "1.8.0"
@@ -23,6 +23,11 @@ run_test_path = "/runes-foundry/run-test"
23
23
  share_path = "/foundry/share"
24
24
  clean_path = "/sources"
25
25
  shared_tags_json_path = "/user/:workspaceId/index.json"
26
+ setup = "/v2/workspace/setup"
27
+ version = "/version"
28
+ upload_all = "/uploadAll"
29
+ file_upload = "/fileupload"
30
+ setup_app = "/v2/workspace/setup-app"
26
31
 
27
32
  [foundry.libs]
28
33
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -23,6 +23,12 @@ run_test_path = "/runes-foundry/run-test"
23
23
  share_path = "/runes-foundry/share"
24
24
  clean_path = "/sources"
25
25
  shared_tags_json_path = "/user/:workspaceId/index.json"
26
+ setup = "/v2/workspace/setup"
27
+ version = "/version"
28
+ upload_all = "/uploadAll"
29
+ file_upload = "/fileupload"
30
+ setup_app = "/v2/workspace/setup-app"
31
+
26
32
 
27
33
  [foundry.libs]
28
34
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -23,6 +23,12 @@ run_test_path = "/foundry/run-test"
23
23
  share_path = "/foundry/share"
24
24
  clean_path = "/sources"
25
25
  shared_tags_json_path = "/user/:workspaceId/index.json"
26
+ setup = "/v2/workspace/setup"
27
+ version = "/version"
28
+ upload_all = "/uploadAll"
29
+ file_upload = "/fileupload"
30
+ setup_app = "/v2/workspace/setup-app"
31
+
26
32
 
27
33
  [foundry.libs]
28
34
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -7,3 +7,8 @@ run_test_path = "/runes-foundry/run-test"
7
7
  share_path = "/runes-foundry/share"
8
8
  clean_path = "/sources"
9
9
  shared_tags_json_path = "/user/:workspaceId/index.json"
10
+ setup = "/v2/workspace/setup"
11
+ version = "/version"
12
+ upload_all = "/uploadAll"
13
+ file_upload = "/fileupload"
14
+ setup_app = "/v2/workspace/setup-app"
@@ -17,12 +17,18 @@ url = "https://api.eitri.tech/share-api/share"
17
17
 
18
18
  [foundry]
19
19
  url = "https://api.eitri.tech"
20
- base_path = "/runes-foundry"
21
- target_path = "/runes-foundry/targets"
22
- run_test_path = "/runes-foundry/run-test"
20
+ base_path = "/foundry"
21
+ target_path = "/foundry/targets"
22
+ run_test_path = "/foundry/run-test"
23
23
  share_path = "/foundry/share"
24
24
  clean_path = "/sources"
25
25
  shared_tags_json_path = "/user/:workspaceId/index.json"
26
+ setup = "/v2/workspace/setup"
27
+ version = "/version"
28
+ upload_all = "/uploadAll"
29
+ file_upload = "/fileupload"
30
+ setup_app = "/v2/workspace/setup-app"
31
+
26
32
 
27
33
  [foundry.libs]
28
34
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -3,6 +3,11 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ export interface StartArguments {
7
+ shared?: boolean
8
+ verbose?: boolean
9
+ playground?: boolean
10
+ }
6
11
  export interface EitriLibsArguments {
7
12
  bifrost?: boolean
8
13
  luminus?: boolean
@@ -11,8 +16,9 @@ export function publish(environment: string, message: string): Promise<void>
11
16
  export function runTest(userJwt: string, userWorkspaceId: string, testPath: string): Promise<void>
12
17
  export function eitriLibs(eitriLibsArgs: EitriLibsArguments): Promise<void>
13
18
  export function doctor(): Promise<void>
19
+ export function start(args: StartArguments): Promise<void>
14
20
  export namespace app {
15
- export function start(): Promise<void>
21
+ export function start(args: StartArguments): Promise<void>
16
22
  export function appLogs(): Promise<void>
17
23
  }
18
24
  export namespace workspace {
@@ -295,11 +295,12 @@ if (!nativeBinding) {
295
295
  throw new Error(`Failed to load native binding`)
296
296
  }
297
297
 
298
- const { publish, runTest, eitriLibs, doctor, app, workspace } = nativeBinding
298
+ const { publish, runTest, eitriLibs, doctor, start, app, workspace } = nativeBinding
299
299
 
300
300
  module.exports.publish = publish
301
301
  module.exports.runTest = runTest
302
302
  module.exports.eitriLibs = eitriLibs
303
303
  module.exports.doctor = doctor
304
+ module.exports.start = start
304
305
  module.exports.app = app
305
306
  module.exports.workspace = workspace
package/index.js CHANGED
@@ -72,6 +72,10 @@ const run = async () => {
72
72
  .option("-f, --force", "Força o start")
73
73
  .option("-S, --show-deeplink", "Exibe o deep link do workspace")
74
74
  .option("-sm, --skip-mini-log", "Skipa conexão com o mini-log")
75
+ .option(
76
+ "-p, --playground",
77
+ "Gera um QR code com a URL de abertura do Eitri Playground"
78
+ )
75
79
  .option(
76
80
  "-P, --qr-printer <qrPrinter>",
77
81
  "Indica qual programa imprimirá o QR Code. Se omitido, exibe o QrCode no terminal. Valores válidos: terminal|chrome|msedge|firefox"
@@ -80,12 +84,24 @@ const run = async () => {
80
84
  "-e, --emulator <platform>",
81
85
  "Abre o Eitri-App no emulador, desde que seja definido qual plataforma será aberto, android ou ios."
82
86
  )
83
- .option("-sh, --shared", "Executa o Eitri-App no modo compartilhável.");
87
+ .option("-sh, --shared", "Executa o Eitri-App no modo compartilhável.")
84
88
 
85
89
  startProgram.action((cmdObj) => {
90
+ if (process.env.FT_START_V2 === "true") {
91
+ require('./eitri-cli-v2/eitri-cli-v2.linux-x64-gnu.node').start(cmdObj);
92
+ return;
93
+ }
86
94
  require("./src/cmd/start")(cmdObj);
87
95
  });
88
96
 
97
+ program
98
+ .command('test-initialization-params <initializationParams>')
99
+ .option("-v, --verbose", "Exibe mais logs")
100
+ .description('Define parâmetros na query string para inicializar o Eitri-App. Exemplo: stringChave1=stringValor1&stringChave2=stringValor2...')
101
+ .action((initializationParams, cmdObj) => {
102
+ require('./src/cmd/test-initialization-params')(initializationParams, cmdObj)
103
+ })
104
+
89
105
  program
90
106
  .command("push-version")
91
107
  .description(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.15.0",
3
+ "version": "1.16.0-beta.2",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -70,7 +70,7 @@ module.exports = async function runTests(args) {
70
70
  debug("Fim da busca e validação do EitriAppConf", { miniConf })
71
71
 
72
72
  const url = config.get('workspace').url
73
- const setupResult = await workspace.setup()
73
+ const setupResult = await workspace.setup(args)
74
74
  debug("Informações do setupResult do workspace", { setupResult })
75
75
 
76
76
  blindGuardian.readConf()
package/src/cmd/start.js CHANGED
@@ -54,7 +54,10 @@ module.exports = async function start(args) {
54
54
  const applicationName = setupResult?.application?.name
55
55
 
56
56
  blindGuardian.readConf()
57
- const qrCodeUrl = config.get('qrCode').url
57
+ let qrCodeUrl = setupResult?.eitriAppBootstrapURL
58
+ if(args.playground){
59
+ qrCodeUrl = config.get('qrCode').url
60
+ }
58
61
  if (args.verbose) {
59
62
  blindGuardian.verbose = true
60
63
  miniLog.verbose = true
@@ -6,6 +6,11 @@ module.exports = function AppCommand() {
6
6
  app
7
7
  .command("start")
8
8
  .description("Inicializa todos os Eitri-Apps do arquivo de configuração app-config.yaml")
9
+ .option("-v, --verbose", "Exibe mais logs")
10
+ .option(
11
+ "-p, --playground",
12
+ "Gera um QR code com a URL de abertura do Eitri Playground"
13
+ )
9
14
  .action(async (cmdObj) => {
10
15
  const eitriCLIV2 = require("../../../eitri-cli-v2/index.js");
11
16
  await eitriCLIV2.app.start(cmdObj)
@@ -6,10 +6,10 @@ const debug = require('debug')('eitri:AndroidEmulatorService')
6
6
 
7
7
  module.exports = class AndroidEmulatorService {
8
8
 
9
- static async open(deepLink, shareId) {
9
+ static async open(deepLink) {
10
10
  await this.checkHasInstalledAdb()
11
11
  const serialNumber = await this.selectDevice()
12
- const cmd = `adb -s ${serialNumber} shell am start -a android.intent.action.VIEW -d ${deepLink}/${shareId}`
12
+ const cmd = `adb -s ${serialNumber} shell am start -a android.intent.action.VIEW -d ${deepLink}`
13
13
  const opened = await this.openDeepLink(cmd)
14
14
  if (opened) return;
15
15
  }
@@ -4,10 +4,10 @@ const inquirer = require("inquirer");
4
4
 
5
5
  module.exports = class IOSEmulatorService {
6
6
 
7
- static async open(deepLink, shareId) {
7
+ static async open(deepLink) {
8
8
  await this.checkHasInstalledXcode()
9
9
 
10
- const cmd = `xcrun simctl openurl booted ${deepLink}/${shareId}`
10
+ const cmd = `xcrun simctl openurl booted ${deepLink}`
11
11
  const opened = await this.openDeepLink(cmd)
12
12
  if (opened) return;
13
13
 
@@ -3,13 +3,10 @@ const IOSEmulatorService = require('./Emulator/IOSEmulatorService');
3
3
 
4
4
  module.exports = class EmulatorService {
5
5
 
6
- static async openSimulator(emulator, shareId, deepLinks) {
6
+ static async openSimulator(emulator, deeplink) {
7
7
  try {
8
8
  const emulatorService = emulator === "ios" ? IOSEmulatorService : AndroidEmulatorService;
9
-
10
- for (const deepLink of deepLinks) {
11
- await emulatorService.open(deepLink, shareId)
12
- }
9
+ await emulatorService.open(deeplink)
13
10
  } catch (error) {
14
11
  throw {message: error.message}
15
12
  }
@@ -18,15 +18,11 @@ class QRCodeFactory {
18
18
  })
19
19
  }
20
20
 
21
- async create(data, eitriAppSlug = "", displayOutsideTerminal = false) {
22
- console.log('\n==================================================')
23
- console.log('Utilize o QR-Code para iniciar o seu Eitri-App')
24
- console.log('É importante utilizar o leitor de QR-Code do')
25
- console.log('aplicativo à qual destina-se o seu Eitri-App')
26
- console.log('==================================================')
21
+ async create(data, eitriAppSlug = "", args = {}) {
22
+ this.displayQrCodeInstruction(args?.playground)
27
23
 
28
24
  let qrCodeTempPath = `${eitriAppSlug}::${new Date().getTime()}`
29
- if(displayOutsideTerminal){
25
+ if(args?.qrPrinter){
30
26
  qrCodeTempPath = await this.tempFile(eitriAppSlug)
31
27
  await this.createQRCodeImage(qrCodeTempPath, data)
32
28
  }
@@ -63,6 +59,23 @@ class QRCodeFactory {
63
59
  )
64
60
  })
65
61
  }
62
+
63
+ displayQrCodeInstruction(playGroundMode = false) {
64
+ const separator = "=================================================="
65
+ console.log("\n" + separator)
66
+
67
+ if (playGroundMode) {
68
+ console.log('Para iniciar seu Eitri-App, escaneie o QR Code')
69
+ console.log('exibido usando o Eitri Playground')
70
+ console.log(separator)
71
+ return
72
+ }
73
+
74
+ console.log("Para iniciar seu Eitri-App, escaneie o QR Code exibido.")
75
+ console.log('Certifique-se de usar o leitor de QR Code')
76
+ console.log('do aplicativo destinado ao seu Eitri-App.')
77
+ console.log(separator)
78
+ }
66
79
  }
67
80
 
68
81
  module.exports = QRCodeFactory
@@ -35,6 +35,7 @@ const YAML = require('yaml');
35
35
  const { readFile } = require("fs/promises");
36
36
  const convertKeysToCamelCase = require("../util/convertKeysToCamelCase");
37
37
  const { exit } = require("process");
38
+ const debug = require('debug')('eitri:Workspace')
38
39
 
39
40
  class Workspace {
40
41
 
@@ -194,13 +195,20 @@ class Workspace {
194
195
  const headers = {
195
196
  accept: this.config.libs.updateLibsEndpointVersion,
196
197
  };
198
+
199
+ let runAppMode = "CLIENT_APP"
200
+ if(args?.playground) runAppMode = "PLAYGROUND"
201
+
202
+ debug("RUN_APP_MODE", runAppMode)
203
+
197
204
  try {
198
205
  const appConfig = await this.getAppConfig()
199
206
  const setupResponse = await this.http.post(
200
207
  `${this.serverUrl}/${this.basePath}/v2/workspace/setup`,
201
208
  {
202
209
  eitriConf,
203
- appConfig
210
+ appConfig,
211
+ runAppMode
204
212
  },
205
213
  headers
206
214
  ); // somente para garantir que a pasta do usuario existe
@@ -377,9 +385,9 @@ class Workspace {
377
385
  return bootstrapBaseUrl;
378
386
  }
379
387
 
380
- async getNewWorkspaceURL(args, setupConfig) {
388
+ async getNewWorkspaceURL(args, setupConfig, eitriAppConf) {
381
389
  const qrCodeConfig = await this.getQrCodeConfig(args, setupConfig);
382
- const stateData = await this.saveShareState(qrCodeConfig);
390
+ const stateData = await this.saveShareState(qrCodeConfig, eitriAppConf);
383
391
  const stateId = stateData.id;
384
392
  const miniAppUrl = `${this.qrCodeUrl}/${stateId}`;
385
393
  return {
@@ -391,11 +399,16 @@ class Workspace {
391
399
  };
392
400
  }
393
401
 
394
- async saveShareState(qrCodeConfig) {
402
+ async saveShareState(qrCodeConfig, eitriAppConf) {
395
403
  const createWorkspaceStateUrl = `${this.serverUrl}/${this.basePath}/share`;
396
404
  const requestBody = {
397
405
  id: uuidv4(),
398
- state: qrCodeConfig,
406
+ state: {
407
+ ...qrCodeConfig,
408
+ eitriAppId: eitriAppConf?.id || "",
409
+ organizationId: eitriAppConf?.organizationId || "",
410
+ applicationId: eitriAppConf?.applicationId || "",
411
+ },
399
412
  };
400
413
  const response = await this.http.post(
401
414
  createWorkspaceStateUrl,
@@ -425,6 +438,7 @@ class Workspace {
425
438
  title: miniAppConf["title"],
426
439
  permissions: miniAppConf["permissions"],
427
440
  miniAppBootstrapUrl: this.getBootstrapURL(setupConfig.eitriAppBootstrapURL),
441
+ developmentDeeplink: setupConfig.developmentDeeplink,
428
442
  initializationParams,
429
443
  orderId,
430
444
  view,
@@ -40,7 +40,7 @@ class WorkspaceManager {
40
40
  console.log(qrCode)
41
41
  })
42
42
  } else {
43
- const qrCodePath = await new QRCodeFactory().create(fullUrl)
43
+ const qrCodePath = await new QRCodeFactory().create(fullUrl, "", args)
44
44
  const sanitizedQrCodePath = qrCodePath.replace('/~', '')
45
45
  if(args) {
46
46
  Server.startServer({ qrCodePath: sanitizedQrCodePath, qrPrinter: args.qrPrinter })
@@ -19,13 +19,16 @@ function QRCodeStarter(
19
19
  this.setupConfig = setupConfig;
20
20
 
21
21
  this.startServer = async function () {
22
+ const eitriAppConf = this.workspace._miniConf;
22
23
  const workspaceURLConfig = await this.workspace.getNewWorkspaceURL(
23
- this.args,
24
- this.setupConfig
25
- );
26
- const fullUrl = workspaceURLConfig.miniAppUrl
24
+ this.args,
25
+ this.setupConfig,
26
+ eitriAppConf
27
+ );
28
+
29
+ const fullQrCodeUrl = workspaceURLConfig.miniAppConf.developmentDeeplink;
27
30
  if (this.args.verbose) {
28
- console.log(`QrCodeUrl: ${fullUrl}`);
31
+ console.log(`QrCodeUrl: ${fullQrCodeUrl}`);
29
32
  }
30
33
 
31
34
  this.watcher.start();
@@ -33,47 +36,35 @@ function QRCodeStarter(
33
36
  console.log("######################################");
34
37
  console.log("########### Deep Link URL ############");
35
38
  console.log("######################################");
36
- console.log(`${fullUrl}`);
39
+ console.log(`${fullQrCodeUrl}`);
37
40
  console.log("######################################");
38
41
  }
39
42
 
40
43
  const _QRCodeFactory = new QRCodeFactory();
41
44
 
42
45
  const eitriAppSlug = this.workspace?._miniConf?.slug ?? "";
43
- const qrCodePath = await _QRCodeFactory.create(fullUrl, eitriAppSlug, this.args.qrPrinter);
46
+ const qrCodePath = await _QRCodeFactory.create(fullQrCodeUrl, eitriAppSlug, this.args);
44
47
 
45
48
  if (this.args.verbose) {
46
49
  console.log(`QrCode Path: ${qrCodePath}`);
47
50
  }
48
51
 
49
- _QRCodeFactory.generate({ ...this.args, qrCodePath, fullUrl });
52
+ _QRCodeFactory.generate({ ...this.args, qrCodePath, fullUrl: fullQrCodeUrl });
50
53
 
51
54
  if (this.args.emulator) {
52
- await tryOpenEmulator(fullUrl, args);
55
+ await tryOpenEmulator(fullQrCodeUrl, args);
53
56
  }
54
57
 
55
- await listenerKeyPressToShowQrCode(fullUrl);
56
- await listenerKeyPressToOpenEmulator(fullUrl, args.deepLinks);
58
+ await listenerKeyPressToShowQrCode(fullQrCodeUrl);
59
+ await listenerKeyPressToOpenEmulator(fullQrCodeUrl);
57
60
  };
58
61
  }
59
62
 
60
63
  async function tryOpenEmulator(fullUrl, args) {
61
- const shareId = extractShareId(fullUrl);
62
- const { emulator, deepLinks } = args;
63
- if(!deepLinks || deepLinks?.length < 1) {
64
- const warningMessages = [
65
- 'Observamos que o seu Aplicativo não possui "deep links" configurados no momento.',
66
- 'Para obter assistência na configuração, por favor, entre em contato com o nosso suporte técnico Eitri.',
67
- 'Estamos aqui para ajudar a configurá-los para você.'
68
- ]
69
- console.log(warningMessages.join("\n"))
70
- return
71
- };
72
- await EmulatorService.openSimulator(emulator, shareId, deepLinks)
64
+ await EmulatorService.openSimulator(args.emulator, fullUrl)
73
65
  }
74
66
 
75
- async function listenerKeyPressToOpenEmulator(url, deepLinks) {
76
- if(!deepLinks || deepLinks?.length < 1) return;
67
+ async function listenerKeyPressToOpenEmulator(url) {
77
68
  const enterText = chalk.blue.bold("Enter");
78
69
  console.log("================================================");
79
70
  console.log(`\t${chalk.blue.bold("Abertura de Eitri-App automática")}`);
@@ -97,12 +88,12 @@ async function listenerKeyPressToOpenEmulator(url, deepLinks) {
97
88
  if (key && key.name == "a") {
98
89
  const emulator = "android";
99
90
  console.log(`Abrindo Eitri-App no ${chalk.blue.bold("Android")}`);
100
- await tryOpenEmulator(url, {emulator, deepLinks});
91
+ await tryOpenEmulator(url, {emulator});
101
92
  }
102
93
  if (os.platform() === "darwin" && key && key.name == "i") {
103
94
  const emulator = "ios";
104
95
  console.log(`Abrindo Eitri-App no ${chalk.blue.bold("iOS")}`);
105
- await tryOpenEmulator(url, {emulator, deepLinks});
96
+ await tryOpenEmulator(url, {emulator});
106
97
  }
107
98
  } catch (error) {
108
99
  console.log(error);
@@ -142,11 +133,6 @@ async function listenerKeyPressToShowQrCode(url) {
142
133
  });
143
134
  }
144
135
 
145
- function extractShareId(url) {
146
- const [, shareId] = url.split("/share/");
147
- return shareId;
148
- }
149
-
150
136
  function QRCodeContentFactory() {
151
137
  this.create = function (
152
138
  args,
@@ -46,11 +46,11 @@ function WebAppStarter(args, trackingService, watcher, workspace, targetConfig )
46
46
  const libsInfoForGA = this.args.libsInfoForGA
47
47
  TrackService.track(miniConf, this.trackingService, libsInfoForGA)
48
48
 
49
- const {miniAppConf} = await this.workspace.getNewWorkspaceURL(this.args, this.targetConfig)
49
+ const {miniAppConf} = await this.workspace.getNewWorkspaceURL(this.args, this.targetConfig, miniConf)
50
50
  const { slug } = miniConf
51
51
 
52
52
  if(this.args.emulator){
53
- Server.startServerEmulator({...this.args, bootstrapUrl: miniAppConf.miniAppBootstrapUrl, slug, http: this.workspace.getHttp() })
53
+ Server.startServerEmulator({...this.args, bootstrapUrl: miniAppConf.developmentDeeplink, slug, http: this.workspace.getHttp() })
54
54
  return
55
55
  }
56
56