eitri-cli 1.12.0-beta.1 → 1.12.0-beta.10

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.
@@ -27,6 +27,7 @@ pipelines:
27
27
  script:
28
28
  - cd eitri-cli-v2
29
29
  - npm i
30
+ - npm i puppeteer@21.4.1
30
31
  - npm run build:debug
31
32
  - cd ..
32
33
  - yarn
@@ -39,7 +40,7 @@ pipelines:
39
40
  - node
40
41
  script:
41
42
  - cd eitri-cli-v2
42
- - cargo test
43
+ - cargo test -- --test-threads=1
43
44
  - step: &macOSCrossCompile
44
45
  image:
45
46
  name: 343482176926.dkr.ecr.us-east-1.amazonaws.com/eitri-base-cli-pipeline:macos
@@ -29,6 +29,12 @@ url = "2.5.0"
29
29
  urlencoding = "2.1.3"
30
30
  url-parse = "1.0.7"
31
31
  config = "0.14.0"
32
+ futures-util = "0.3.30"
33
+ rust_socketio = { version = "0.4.2", features = ["async"] }
34
+ log = "0.4.21"
35
+ env_logger = "0.11.3"
36
+ crossterm = "0.27.0"
37
+ spinners = "4.1.1"
32
38
 
33
39
  [dependencies.uuid]
34
40
  version = "1.8.0"
@@ -8,7 +8,8 @@ old_config_file_path = ".miniapp/prod-eitri.conf.js"
8
8
  create_url = "https://console.eitri.tech/docs"
9
9
 
10
10
  [blind_guardian]
11
- url = "https://api.eitri.tech/blind-guardian-api"
11
+ url = "https://api.eitri.tech"
12
+ base_path = "/blind-guardian-api"
12
13
  auth_path = "/v2/o/auth"
13
14
 
14
15
  [share_api]
@@ -16,10 +17,12 @@ url = "https://api.eitri.tech/share-api/share"
16
17
 
17
18
  [foundry]
18
19
  url = "https://api.eitri.tech"
19
- base_path = "runes-foundry"
20
+ base_path = "/runes-foundry"
20
21
  target_path = "/runes-foundry/targets"
21
22
  run_test_path = "/runes-foundry/run-test"
22
23
  share_path = "/foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
23
26
 
24
27
  [foundry.libs]
25
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -34,8 +37,9 @@ watch_user_dir = "/server"
34
37
  url = "https://prod.eitri.calindra.com.br/workspace/share"
35
38
 
36
39
  [mini_log]
37
- url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
38
- path = "/mini-log/socket.io"
40
+ url = "https://prod.eitri.calindra.com.br/mini-log"
41
+ path = "/socket.io/"
42
+ rooms = "/mini-log/rooms"
39
43
 
40
44
  [manager_api]
41
45
  url = "https://api.eitri.tech/miniapp-manager-api"
@@ -44,6 +48,7 @@ url = "https://api.eitri.tech/miniapp-manager-api"
44
48
  url = "https://api.eitri.tech/eitri-manager-api"
45
49
  revision_path = "/v2/revisions"
46
50
  publish_path = "/revisions/:eitriAppId/publish"
51
+ application_by_id_path = "/applications/:applicationId"
47
52
 
48
53
  [eitri_analytics]
49
54
  url = "https://api.eitri.tech/analytics/event"
@@ -8,7 +8,8 @@ old_config_file_path = ".miniapp/prod-eitri.conf.js"
8
8
  create_url = "https://console.eitri.tech/docs"
9
9
 
10
10
  [blind_guardian]
11
- url = "https://api.eitri.tech/blind-guardian-api"
11
+ url = "https://api.eitri.tech"
12
+ base_path = "/blind-guardian-api"
12
13
  auth_path = "/v2/o/auth"
13
14
 
14
15
  [share_api]
@@ -16,10 +17,12 @@ url = "https://api.eitri.tech/share-api/share"
16
17
 
17
18
  [foundry]
18
19
  url = "http://localhost:3000"
19
- base_path = "runes-foundry"
20
+ base_path = "/runes-foundry"
20
21
  target_path = "/runes-foundry/targets"
21
22
  run_test_path = "/runes-foundry/run-test"
22
23
  share_path = "/runes-foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
23
26
 
24
27
  [foundry.libs]
25
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -34,8 +37,9 @@ watch_user_dir = "/server"
34
37
  url = "https://prod.eitri.calindra.com.br/workspace/share"
35
38
 
36
39
  [mini_log]
37
- url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
38
- path = "/mini-log/socket.io"
40
+ url = "https://prod.eitri.calindra.com.br/mini-log"
41
+ path = "/socket.io/"
42
+ rooms = "/mini-log/rooms"
39
43
 
40
44
  [manager_api]
41
45
  url = "https://api.eitri.tech/miniapp-manager-api"
@@ -44,6 +48,7 @@ url = "https://api.eitri.tech/miniapp-manager-api"
44
48
  url = "https://api.eitri.tech/eitri-manager-api"
45
49
  revision_path = "/v2/revisions"
46
50
  publish_path = "/revisions/:eitriAppId/publish"
51
+ application_by_id_path = "/applications/:applicationId"
47
52
 
48
53
  [eitri_analytics]
49
54
  url = "https://api.eitri.tech/analytics/event"
@@ -8,7 +8,8 @@ old_config_file_path = ".miniapp/prod-eitri.conf.js"
8
8
  create_url = "https://console.eitri.tech/docs"
9
9
 
10
10
  [blind_guardian]
11
- url = "https://api.eitri.tech/blind-guardian-api"
11
+ url = "https://api.eitri.tech"
12
+ base_path = "/blind-guardian-api"
12
13
  auth_path = "/v2/o/auth"
13
14
 
14
15
  [share_api]
@@ -16,10 +17,12 @@ url = "https://api.eitri.tech/share-api/share"
16
17
 
17
18
  [foundry]
18
19
  url = "https://api.eitri.tech"
19
- base_path = "foundry"
20
+ base_path = "/foundry"
20
21
  target_path = "/foundry/targets"
21
22
  run_test_path = "/foundry/run-test"
22
23
  share_path = "/foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
23
26
 
24
27
  [foundry.libs]
25
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -31,14 +34,16 @@ upload_file = "/uploadSingle"
31
34
  watch_user_dir = "/server"
32
35
 
33
36
  [mini_log]
34
- url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
35
- path = "/mini-log/socket.io"
37
+ url = "https://prod.eitri.calindra.com.br/mini-log"
38
+ path = "/socket.io/"
39
+ rooms = "/mini-log/rooms"
36
40
 
37
41
 
38
42
  [eitri_manager]
39
43
  url = "https://api.eitri.tech/eitri-manager-api"
40
44
  revision_path = "/v2/revisions"
41
45
  publish_path = "/revisions/:eitriAppId/publish"
46
+ application_by_id_path = "/applications/:applicationId"
42
47
 
43
48
  [eitri_analytics]
44
49
  url = "https://api.eitri.tech/analytics/event"
@@ -1,7 +1,9 @@
1
1
 
2
2
  [foundry]
3
3
  url = "https://api.eitri.tech"
4
- base_path = "runes-foundry"
4
+ base_path = "/runes-foundry"
5
5
  target_path = "/runes-foundry/targets"
6
6
  run_test_path = "/runes-foundry/run-test"
7
7
  share_path = "/runes-foundry/share"
8
+ clean_path = "/sources"
9
+ shared_tags_json_path = "/user/:workspaceId/index.json"
@@ -8,7 +8,8 @@ old_config_file_path = ".miniapp/prod-eitri.conf.js"
8
8
  create_url = "https://console.eitri.tech/docs"
9
9
 
10
10
  [blind_guardian]
11
- url = "https://api.eitri.tech/blind-guardian-api"
11
+ url = "https://api.eitri.tech"
12
+ base_path = "/blind-guardian-api"
12
13
  auth_path = "/v2/o/auth"
13
14
 
14
15
  [share_api]
@@ -16,10 +17,12 @@ url = "https://api.eitri.tech/share-api/share"
16
17
 
17
18
  [foundry]
18
19
  url = "https://api.eitri.tech"
19
- base_path = "runes-foundry"
20
+ base_path = "/runes-foundry"
20
21
  target_path = "/runes-foundry/targets"
21
22
  run_test_path = "/runes-foundry/run-test"
22
23
  share_path = "/foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
23
26
 
24
27
  [foundry.libs]
25
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -34,8 +37,9 @@ watch_user_dir = "/server"
34
37
  url = "https://prod.eitri.calindra.com.br/workspace/share"
35
38
 
36
39
  [mini_log]
37
- url = "https://prod.eitri.calindra.com.br/mini-log/rooms"
38
- path = "/mini-log/socket.io"
40
+ url = "https://prod.eitri.calindra.com.br/mini-log"
41
+ path = "/socket.io/"
42
+ rooms = "/mini-log/rooms"
39
43
 
40
44
  [manager_api]
41
45
  url = "https://api.eitri.tech/miniapp-manager-api"
@@ -44,6 +48,7 @@ url = "https://api.eitri.tech/miniapp-manager-api"
44
48
  url = "https://api.eitri.tech/eitri-manager-api"
45
49
  revision_path = "/v2/revisions"
46
50
  publish_path = "/revisions/:eitriAppId/publish"
51
+ application_by_id_path = "/applications/:applicationId"
47
52
 
48
53
  [eitri_analytics]
49
54
  url = "https://api.eitri.tech/analytics/event"
@@ -11,3 +11,7 @@ export function publish(environment: string, message: string): Promise<void>
11
11
  export function runTest(userJwt: string, userWorkspaceId: string, testPath: string): Promise<void>
12
12
  export function eitriLibs(eitriLibsArgs: EitriLibsArguments): Promise<void>
13
13
  export function doctor(): Promise<void>
14
+ export namespace app {
15
+ export function start(): Promise<void>
16
+ export function appLogs(): Promise<void>
17
+ }
@@ -295,9 +295,10 @@ if (!nativeBinding) {
295
295
  throw new Error(`Failed to load native binding`)
296
296
  }
297
297
 
298
- const { publish, runTest, eitriLibs, doctor } = nativeBinding
298
+ const { publish, runTest, eitriLibs, doctor, app } = 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.app = app
package/index.js CHANGED
@@ -7,6 +7,7 @@ const path = require("path");
7
7
  const { workspace } = require("./src/service/Workspace");
8
8
  const configService = require("./src/service/ConfigService");
9
9
  const VegvisirCommand = require("./src/modules/vegvisir/VegvisirCommand");
10
+ const AppCommand = require("./src/modules/app/AppCommand");
10
11
  const debug = require('debug')('eitri:run')
11
12
 
12
13
 
@@ -66,6 +67,7 @@ const run = async () => {
66
67
  .option("-v, --verbose", "Exibe mais logs")
67
68
  .option("-f, --force", "Força o start")
68
69
  .option("-S, --show-deeplink", "Exibe o deep link do workspace")
70
+ .option("-sm, --skip-mini-log", "Skipa conexão com o mini-log")
69
71
  .option(
70
72
  "-P, --qr-printer <qrPrinter>",
71
73
  "Indica qual programa imprimirá o QR Code. Se omitido, exibe o QrCode no terminal. Valores válidos: terminal|chrome|msedge|firefox"
@@ -73,6 +75,10 @@ const run = async () => {
73
75
  .option(
74
76
  "-e, --emulator <platform>",
75
77
  "Abre o Eitri-App no emulador, desde que seja definido qual plataforma será aberto, android ou ios."
78
+ )
79
+ .option(
80
+ "-sh, --shared",
81
+ "Executa o Eitri-App no modo compartilhável."
76
82
  );
77
83
 
78
84
  startProgram.action((cmdObj) => {
@@ -141,7 +147,7 @@ const run = async () => {
141
147
  .command("doctor")
142
148
  .description("Valida as dependências externas para execução da CLI do Eitri")
143
149
  .action(async (cmdObj) => {
144
- if(NEW_CLI_VERSION){
150
+ if (NEW_CLI_VERSION) {
145
151
  console.log("doctor (v2)")
146
152
  const eitriCLIV2 = require('./eitri-cli-v2/index.js')
147
153
  return await eitriCLIV2.doctor()
@@ -175,6 +181,7 @@ const run = async () => {
175
181
  .action(async (cmdObj) => { return require("./src/cmd/runTests")(cmdObj) });
176
182
 
177
183
  program.addCommand(VegvisirCommand());
184
+ program.addCommand(AppCommand());
178
185
 
179
186
  if (
180
187
  process.argv.length > 2 &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.12.0-beta.1",
3
+ "version": "1.12.0-beta.10",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -34,6 +34,7 @@
34
34
  "axios-cookiejar-support": "^0.5.1",
35
35
  "base-64": "^0.1.0",
36
36
  "base64url": "^3.0.1",
37
+ "camelcase": "^6.3.0",
37
38
  "chalk": "^3.0.0",
38
39
  "cheerio": "^1.0.0-rc.3",
39
40
  "cli-progress": "^3.4.0",
@@ -47,6 +48,7 @@
47
48
  "folder-hash": "^3.3.0",
48
49
  "form-data": "^4.0.0",
49
50
  "inquirer": "^7.0.0",
51
+ "js-yaml": "^4.1.0",
50
52
  "jsonwebtoken": "^8.5.1",
51
53
  "lz-string": "^1.5.0",
52
54
  "node-watch": "^0.6.3",
@@ -62,7 +64,8 @@
62
64
  "tmp": "^0.1.0",
63
65
  "tough-cookie": "^3.0.1",
64
66
  "tough-cookie-file-store": "^2.0.2",
65
- "uuid": "^7.0.2"
67
+ "uuid": "^7.0.2",
68
+ "yaml": "^2.4.2"
66
69
  },
67
70
  "devDependencies": {
68
71
  "@commitlint/cli": "^17.7.2",
package/src/cmd/create.js CHANGED
@@ -10,7 +10,7 @@ const { NAME_TITLE_REGEX, SLUG_REGEX } = require("./validate");
10
10
  const handleStartServer = require("../service/StarterService");
11
11
  const getCreateFactory = require("../util/getCreateFactory");
12
12
  const UrlUtils = require("../util/UrlUtils");
13
-
13
+ const open = require("open");
14
14
  // eslint-disable-next-line no-unused-vars
15
15
  const Target = require("../model/Target");
16
16
  const EitriAppManager = require("../service/EitriAppManager");
@@ -54,7 +54,7 @@ module.exports = async function create(projectName, cmdObj) {
54
54
  }
55
55
 
56
56
  console.log(
57
- "\x1b[34mVamos criar o seu Eitri-App. Para isso basta responder algumas perguntas:\x1b[0m"
57
+ "Vamos criar o seu Eitri-App. Carregando configurações..."
58
58
  );
59
59
 
60
60
  try {
@@ -62,6 +62,7 @@ module.exports = async function create(projectName, cmdObj) {
62
62
  workspace.setServerUrl(url);
63
63
  const clientApplication = await askClientApplication(cmdObj.application);
64
64
  if (clientApplication.name === ITEM_DOUBT) {
65
+ open("https://docs.eitri.tech/")
65
66
  handleStartServer(
66
67
  cmdObj,
67
68
  trackingService,
@@ -92,6 +93,11 @@ module.exports = async function create(projectName, cmdObj) {
92
93
 
93
94
  async function askClientApplication(applicationName) {
94
95
  const availableApplications = await eitriAppManager.findAllApplications();
96
+
97
+ console.log(
98
+ "\x1b[34m \nAgora, responda algumas perguntas:\n\x1b[0m"
99
+ );
100
+
95
101
  if (availableApplications.length <= 0) {
96
102
  console.log(
97
103
  "Sua organização não contém nenhuma aplicação disponível para prosseguir com a criação."
@@ -120,9 +126,10 @@ async function askClientApplication(applicationName) {
120
126
  name: "accepted",
121
127
  type: "rawlist",
122
128
  message:
123
- "Selecione a aplicação para qual destina-se seu Eitri-App:",
129
+ "Selecione o Aplicativo para o Eitri-App:",
124
130
  choices: cliOptions.map(createLabel),
125
- pageSize: cliOptions.length + 2,
131
+ pageSize: 10,
132
+ loop: false,
126
133
  },
127
134
  ]);
128
135
  const clientApplication = cliOptions.find(
package/src/cmd/start.js CHANGED
@@ -10,7 +10,7 @@ const handleStartServer = require('../service/StarterService')
10
10
  const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
11
11
  const VegvisirService = require('../modules/vegvisir/VegvisirService')
12
12
  const PrerequisitesValidator = require('../service/PrerequisitesValidator')
13
- const {LogVerbose} = require('../util/LogUtil')
13
+ const { LogVerbose } = require('../util/LogUtil')
14
14
 
15
15
  const blindGuardian = workspace.blindGuardian
16
16
  const hashFolder = workspace.hashFolder
@@ -25,7 +25,7 @@ module.exports = async function start(args) {
25
25
  const miniConf = workspace.getMiniConf()
26
26
 
27
27
  await vegvisirService.isCurrentWorkspaceOwnedByUser(miniConf.slug)
28
-
28
+
29
29
  const separator = '======================================================================='
30
30
  let displayFriendlyErrorAtEnd = ""
31
31
 
@@ -45,14 +45,13 @@ module.exports = async function start(args) {
45
45
  }
46
46
 
47
47
  await vegvisirService.check(miniConf.slug)
48
- debug("Fim da busca e validação do EitriAppConf", {miniConf})
49
-
50
- const url = config.get('workspace').url
51
- const setupResult = await workspace.setup()
52
- debug("Informações do setupResult do workspace", {setupResult})
48
+ debug("Fim da busca e validação do EitriAppConf", { miniConf })
53
49
 
50
+ const url = config.get('workspace').url
51
+ const setupResult = await workspace.setup(args)
52
+ debug("Informações do setupResult do workspace", { setupResult })
54
53
 
55
- const target = setupResult.target.name
54
+ const applicationName = setupResult?.application?.name
56
55
 
57
56
  blindGuardian.readConf()
58
57
  const qrCodeUrl = config.get('qrCode').url
@@ -64,23 +63,25 @@ module.exports = async function start(args) {
64
63
  workspace.setServerUrl(url)
65
64
  workspace.setQrCodeUrl(qrCodeUrl)
66
65
 
67
- debug("Iniciando workspace", {workspace})
66
+ debug("Iniciando workspace", { workspace })
68
67
  await workspace.init()
69
- debug("Workspace iniciado", {workspace})
68
+ debug("Workspace iniciado", { workspace })
70
69
 
71
70
  const silentOnConnect = args.verbose ? false : true
72
71
  const userWorkspace = await vegvisirService.getWorkspace()
73
72
  console.log(`Construindo para o Workspace [${userWorkspace.id}]`)
74
- await miniLog.connect(userWorkspace.id, silentOnConnect)
73
+ if (!args.skipMiniLog) {
74
+ await miniLog.connect(userWorkspace.id, silentOnConnect)
75
+ }
75
76
 
76
77
  LogVerbose(args.verbose, "Construindo...");
77
78
  const isDevMode = true
78
79
  try {
79
- debug("Iniciando workspace.uploadZip", {isDevMode, workspace})
80
+ debug("Iniciando workspace.uploadZip", { isDevMode, workspace })
80
81
  await workspace.uploadZip(isDevMode);
81
82
  } catch (error) {
82
- debug("Erro no workspace.uploadZip", {isDevMode, workspace, error})
83
- if(args.verbose){
83
+ debug("Erro no workspace.uploadZip", { isDevMode, workspace, error })
84
+ if (args.verbose) {
84
85
  console.error("::uploadZip::", error?.message)
85
86
  console.error(":::uploadZip::: ", error)
86
87
  }
@@ -90,29 +91,29 @@ module.exports = async function start(args) {
90
91
  const friendlyMessage3 = "Se o problema persistir, por favor, entre em contato com o suporte técnico do Eitri."
91
92
  const friendlyMessage4 = "Você pode continuar o desenvolvimento localmente, mesmo que a sincronização não esteja disponível no momento."
92
93
  displayFriendlyErrorAtEnd = `\x1b[1m\x1b[31m\n${friendlyMessage1}\n${friendlyMessage2} \x1b[0m` + "\n" + `\n${friendlyMessage3}\n${friendlyMessage4}\n\x1b[0m`
93
-
94
+
94
95
  const errorData = error.response.data
95
96
  const commonStartErrors = ['CodeCompileError', 'TagNotFound']
96
- if(commonStartErrors.includes(errorData.name)) {
97
+ if (commonStartErrors.includes(errorData.name)) {
97
98
  displayFriendlyErrorAtEnd += `\n\x1b[1m\x1b[31mMotivo: ${errorData.friendlyMessage}\x1b[0m\n`;
98
99
  }
99
100
  }
100
101
  console.log("Pronto!\n");
101
102
 
102
103
  const loadedTarget = await workspace.getTarget()
103
- debug("Target carregado do workspace", {loadedTarget})
104
+ debug("Target carregado do workspace", { loadedTarget })
104
105
 
105
106
  const platform = loadedTarget.platform
106
107
  const argsWithDeeplinks = {
107
108
  ...args,
108
109
  deepLinks: loadedTarget?.deepLinks || []
109
110
  }
110
- debug("Iniciando servidor", {argsWithDeeplinks, trackingService, watcher, workspace, target, setupResult, platform})
111
- await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, target, setupResult, platform)
112
- debug("Servidor iniciado", {loadedTarget})
111
+ debug("Iniciando servidor", { argsWithDeeplinks, trackingService, watcher, workspace, applicationName, setupResult, platform })
112
+ await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, applicationName, setupResult, platform)
113
+ debug("Servidor iniciado", { loadedTarget })
113
114
 
114
115
  TrackingEitriAnalytics.sendEvent({
115
- eventName:"start",
116
+ eventName: "start",
116
117
  userId: workspace?.userEmail,
117
118
  data: {
118
119
  workspaceId: userWorkspace.id,
@@ -121,7 +122,7 @@ module.exports = async function start(args) {
121
122
  }
122
123
  })
123
124
  } catch (e) {
124
- debug("Erro no processo de start", {message: e?.message, error: e})
125
+ debug("Erro no processo de start", { message: e?.message, error: e })
125
126
  TrackingEitriAnalytics.sendEvent({
126
127
  eventName: "start.error",
127
128
  userId: workspace?.userEmail,
@@ -149,8 +150,8 @@ module.exports = async function start(args) {
149
150
  await trackingService.sendError(e)
150
151
 
151
152
  process.exit(1)
152
- } finally{
153
- if(displayFriendlyErrorAtEnd){
153
+ } finally {
154
+ if (displayFriendlyErrorAtEnd) {
154
155
  const folderHash = workspace.getFolderHashPath()
155
156
  await workspace.transpile([folderHash])
156
157
  console.log("\n\n" + separator + "\n" + displayFriendlyErrorAtEnd + "\n" + separator + "\n\n")
@@ -9,10 +9,10 @@ module.exports.SLUG_REGEX = SLUG_REGEX
9
9
 
10
10
  module.exports.assertCommandNotRunning = function (commandName) {
11
11
  return new Promise((resolve, reject) => {
12
- ps.lookup({command: 'node'}, (err, processes) => {
12
+ ps.lookup({ command: 'node' }, (err, processes) => {
13
13
  if (err) throw new Error('erro ao executar comando')
14
14
 
15
- console.log('\x1b[1m\x1b[34m Iniciando Eitri builder\x1b[0m');
15
+ console.log('\x1b[1m\x1b[34mIniciando Eitri builder\x1b[0m');
16
16
 
17
17
  const runningProcesses = processes.filter((process) => {
18
18
  let isAmeToolsRunning = false
@@ -34,7 +34,7 @@ module.exports.assertCommandNotRunning = function (commandName) {
34
34
  // reject()
35
35
  // process.exit(1)
36
36
  // } else {
37
- resolve()
37
+ resolve()
38
38
  // }
39
39
  })
40
40
  })
@@ -0,0 +1,23 @@
1
+ const commander = require("commander");
2
+ module.exports = function AppCommand() {
3
+ const app = commander.command("app")
4
+ .description("Gerencia a execução de Eitri-Apps do Aplicativo declarado no app-config.yaml 'eitri app --help'")
5
+
6
+ app
7
+ .command("start")
8
+ .description("Inicializa todos os Eitri-Apps do arquivo de configuração app-config.yaml")
9
+ .action(async (cmdObj) => {
10
+ const eitriCLIV2 = require("../../../eitri-cli-v2/index.js");
11
+ await eitriCLIV2.app.start(cmdObj)
12
+ });
13
+
14
+ app
15
+ .command("logs")
16
+ .description("Exibe os logs dos Eitri-Apps em execução do comando 'eitri app start'")
17
+ .action(async () => {
18
+ const eitriCLIV2 = require("../../../eitri-cli-v2/index.js");
19
+ await eitriCLIV2.app.appLogs();
20
+ });
21
+
22
+ return app;
23
+ };
@@ -2,11 +2,12 @@ const axios = require('axios')
2
2
  const configService = require('./ConfigService')
3
3
  const CDN_83io_LIBRARY = configService.get('cdn')?.library
4
4
  const TrackingEitriAnalytics = require('./TrackingEitriAnalytics')
5
+ const { validateUUID } = require('../util/GenericUtils')
5
6
 
6
7
  class LibsService {
7
8
 
8
- static async validateLibsVersions({libs = [], eitriAppConf = {}}) {
9
- const {luminusUiVersion, bifrostVersion} = this.getEitriConfLibsVersions(libs)
9
+ static async validateLibsVersions({ libs = [], eitriAppConf = {} }) {
10
+ const { luminusUiVersion, bifrostVersion } = this.getEitriConfLibsVersions(libs)
10
11
  if (!luminusUiVersion) {
11
12
  throw new Error("Nenhuma versão do [luminus-ui/eitri-app-components] encontrada em seu eitri-app.conf");
12
13
  }
@@ -15,10 +16,11 @@ class LibsService {
15
16
  throw new Error("Nenhuma versão do [bifrost/eitri-app-client] encontrada em seu eitri-app.conf");
16
17
  }
17
18
 
18
- const {luminusUiVersions, bifrostVersions} = await this.simultaneousRequestAndHandleData();
19
+ const { luminusUiVersions, bifrostVersions } = await this.simultaneousRequestAndHandleData();
19
20
  const allBifrostVersions = bifrostVersions?.versions?.concat(bifrostVersions?.betaVersions, bifrostVersions?.alphaVersions);
20
21
 
21
- if(!luminusUiVersion.includes("@")){
22
+
23
+ if (!luminusUiVersion.includes("@") && !validateUUID(luminusUiVersion)) {
22
24
  const existsLuminus = luminusUiVersions?.versions?.some(version => version === luminusUiVersion);
23
25
  if (!existsLuminus) {
24
26
  this.throwNonExistentLibError({
@@ -30,7 +32,7 @@ class LibsService {
30
32
  }
31
33
  }
32
34
 
33
- if(!bifrostVersion.includes("@")){
35
+ if (!bifrostVersion.includes("@")) {
34
36
  const existsBifrost = allBifrostVersions.some(version => version === bifrostVersion);
35
37
  if (!existsBifrost) {
36
38
  this.throwNonExistentLibError({
@@ -127,12 +129,12 @@ class LibsService {
127
129
  TrackingEitriAnalytics.sendEvent({
128
130
  eventName: `${method}.error`,
129
131
  userId: "",
130
- data: {errorMessage}
132
+ data: { errorMessage }
131
133
  })
132
134
  }
133
135
 
134
- static throwNonExistentLibError(input = {libName: "", eitriConfLibVersion: "", availableVersions: [], eitriAppConf: {}}) {
135
- const {libName, eitriConfLibVersion, availableVersions, eitriAppConf} = input
136
+ static throwNonExistentLibError(input = { libName: "", eitriConfLibVersion: "", availableVersions: [], eitriAppConf: {} }) {
137
+ const { libName, eitriConfLibVersion, availableVersions, eitriAppConf } = input
136
138
 
137
139
  const friendlyErrorMessage = `Versão da biblioteca [${libName}] não encontrada`;
138
140
  console.log(`\n\x1b[1m\x1b[31m${friendlyErrorMessage}\x1b[0m\n`);
@@ -84,7 +84,7 @@ class MiniLog {
84
84
  console.log(`\x1b[34meitri:\x1b[0m\x1b[97m${data.msg}\x1b[0m`);
85
85
  } else {
86
86
  const message = this._colorizeMessage(data.msg, data.method)
87
- console[data.method](`\x1b[34meitri:\x1b[0m${message}`);
87
+ console[data.method](`\x1b[34meitri [${data.slug}]:\x1b[0m${message}`);
88
88
  }
89
89
  }
90
90
  if (data.stopCLI) {
@@ -30,7 +30,7 @@ class Watcher {
30
30
  return
31
31
  }
32
32
  if (stat.isFile()) {
33
- console.log('\x1b[34mAlterações em: %s\x1b[0m', filePath)
33
+ console.log('\x1b[34meitri:Alterações em: %s\x1b[0m', filePath)
34
34
  this.workspace
35
35
  .upsert(filePath, { why: WatcherOpts.SAVE })
36
36
  .then((result) => {
@@ -43,10 +43,10 @@ class Watcher {
43
43
  }
44
44
  if (result.relativePath === '/folder.hash') {
45
45
 
46
- console.log(`\x1b[94mForjado em ${result.time} milissegundos\x1b[0m`);
46
+ console.log(`\x1b[94meitri:Forjado em ${result.time} milissegundos\x1b[0m`);
47
47
  this.trackingService.sendSave(event)
48
48
  } else {
49
- console.log(`\x1b[94mTransportado em ${result.time} milissegundos\x1b[0m`);
49
+ console.log(`\x1b[94meitri:Transportado em ${result.time} milissegundos\x1b[0m`);
50
50
  this.trackingService.sendCompile(event)
51
51
  }
52
52
  return this.hashFolder.updateHashFile()
@@ -31,9 +31,13 @@ const EitriAppType = require("../model/EitriAppType");
31
31
  const chalk = require("chalk");
32
32
  const LibsService = require("./LibsService");
33
33
  const { LogSuccess } = require("../util/LogUtil");
34
- const {extractSlug} = require("../util/LibUtil");
34
+ const { extractSlug } = require("../util/LibUtil");
35
35
  const vegvisirService = new VegvisirService()
36
36
  const huginService = new HuginService()
37
+ const YAML = require('yaml');
38
+ const { readFile } = require("fs/promises");
39
+ const convertKeysToCamelCase = require("../util/convertKeysToCamelCase");
40
+ const { exit } = require("process");
37
41
 
38
42
  class Workspace {
39
43
 
@@ -139,6 +143,9 @@ class Workspace {
139
143
  throw Error("Arquivo eitri-app.conf.js sem version");
140
144
  }
141
145
  }
146
+ if (process.env.WORKSPACE_SHARED) {
147
+ this._miniConf['eitri-luminus'] = process.env.WORKSPACE_SHARED
148
+ }
142
149
  return this._miniConf;
143
150
  }
144
151
 
@@ -183,39 +190,50 @@ class Workspace {
183
190
  });
184
191
  }
185
192
 
186
- async setup() {
187
- const miniConf = this.getMiniConf();
193
+ async setup(args) {
194
+ const eitriConf = this.getMiniConf();
195
+ eitriConf.isShared = args?.shared
188
196
  const headers = {
189
197
  accept: this.config.libs.updateLibsEndpointVersion,
190
198
  };
191
199
  try {
200
+ const appConfig = await this.getAppConfig()
192
201
  const setupResponse = await this.http.post(
193
- `${this.serverUrl}/${this.basePath}/setup`,
194
- miniConf,
202
+ `${this.serverUrl}/${this.basePath}/v2/workspace/setup`,
203
+ {
204
+ eitriConf,
205
+ appConfig
206
+ },
195
207
  headers
196
208
  ); // somente para garantir que a pasta do usuario existe
197
209
 
198
210
  console.log("Preparando compilador");
199
211
  await this.http.put(
200
212
  `${this.serverUrl}/${this.basePath}/version`,
201
- miniConf,
213
+ eitriConf,
202
214
  headers
203
215
  ); // TODO PDV Setup fara isso aqui
204
216
  console.log("Compilador pronto para uso contínuo");
205
217
 
206
218
  const setupData = setupResponse.data;
207
219
 
208
- const { state, target: remoteTarget, eitriConf: remoteEitriConf } = setupData;
220
+ const { state, application, eitriConf: remoteEitriConf } = setupData;
221
+
222
+ if (!application) {
223
+ console.error("O Aplicativo não foi encontrado durante o processo de setup do Eitri-App.");;
224
+ return exit(1);
225
+ }
209
226
 
210
- if (!this.eitriAppService.validEitriConf(miniConf)) {
211
- await this.eitriAppService.writeEitriConf(remoteEitriConf, miniConf, this.folder2watch);
227
+ if (!this.eitriAppService.validEitriConf(eitriConf)) {
228
+ await this.eitriAppService.writeEitriConf(remoteEitriConf, eitriConf, this.folder2watch);
212
229
  }
213
230
 
214
- await LibsService.validateLibsVersions({ libs: state.libs, eitriAppConf: miniConf });
231
+ await LibsService.validateLibsVersions({ libs: state.libs, eitriAppConf: eitriConf });
215
232
 
216
233
  this.printLibsVersion(state);
217
234
 
218
- await this.loadTarget(remoteTarget);
235
+ await this.loadTarget(application);
236
+
219
237
 
220
238
  return setupData;
221
239
  } catch (e) {
@@ -227,6 +245,18 @@ class Workspace {
227
245
  }
228
246
  }
229
247
 
248
+ async getAppConfig() {
249
+ const appConfigPath = path.resolve(
250
+ this.folder2watch,
251
+ "../../app-config.yaml"
252
+ );
253
+ if (!fs.existsSync(appConfigPath)) return
254
+ const content = await readFile(appConfigPath, 'utf8')
255
+ const appConfig = YAML.parse(content);
256
+ return convertKeysToCamelCase(appConfig);
257
+ }
258
+
259
+
230
260
  async loadTarget(remoteTarget) {
231
261
  const targets = await this.availableTargets();
232
262
  this.target = targets.find((t) => t.name === remoteTarget.name);
@@ -242,7 +272,7 @@ class Workspace {
242
272
  let libVersionsOutput = "";
243
273
  state.libs.forEach((lib) => {
244
274
  let libraryDisplayName = lib.name
245
- if(libraryDisplayName === "eitri-luminus"){
275
+ if (libraryDisplayName === "eitri-luminus") {
246
276
  libraryDisplayName = extractSlug(miniConf[lib.name])
247
277
  }
248
278
 
@@ -0,0 +1,26 @@
1
+ const camelCase = require('camelcase');
2
+
3
+ function convertKeysToCamelCase(obj) {
4
+ const newObj = {};
5
+ for (let key in obj) {
6
+ if (Object.getOwnPropertyNames(obj)) {
7
+ let value = obj[key];
8
+ const camelKey = camelCase(key);
9
+ if (typeof value === 'object' && !Array.isArray(value)) {
10
+ value = convertKeysToCamelCase(value); // Se for um objeto, chama a função recursivamente
11
+ } else if (Array.isArray(value)) {
12
+ // Se for um array, percorre cada item e chama a função recursivamente se for um objeto
13
+ value = value.map(item => {
14
+ if (typeof item === 'object' && !Array.isArray(item)) {
15
+ return convertKeysToCamelCase(item);
16
+ }
17
+ return item;
18
+ });
19
+ }
20
+ newObj[camelKey] = value;
21
+ }
22
+ }
23
+ return newObj;
24
+ }
25
+
26
+ module.exports = convertKeysToCamelCase