eitri-cli 1.12.0-beta.2 → 1.12.0-beta.4

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
@@ -29,6 +29,8 @@ url = "2.5.0"
29
29
  urlencoding = "2.1.3"
30
30
  url-parse = "1.0.7"
31
31
  config = "0.14.0"
32
+ crossterm = "0.27.0"
33
+ spinners = "4.1.1"
32
34
 
33
35
  [dependencies.uuid]
34
36
  version = "1.8.0"
@@ -17,10 +17,12 @@ 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"
20
+ base_path = "/runes-foundry"
21
21
  target_path = "/runes-foundry/targets"
22
22
  run_test_path = "/runes-foundry/run-test"
23
23
  share_path = "/foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
24
26
 
25
27
  [foundry.libs]
26
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -45,6 +47,7 @@ url = "https://api.eitri.tech/miniapp-manager-api"
45
47
  url = "https://api.eitri.tech/eitri-manager-api"
46
48
  revision_path = "/v2/revisions"
47
49
  publish_path = "/revisions/:eitriAppId/publish"
50
+ application_by_id_path = "/applications/:applicationId"
48
51
 
49
52
  [eitri_analytics]
50
53
  url = "https://api.eitri.tech/analytics/event"
@@ -17,10 +17,12 @@ url = "https://api.eitri.tech/share-api/share"
17
17
 
18
18
  [foundry]
19
19
  url = "http://localhost:3000"
20
- base_path = "runes-foundry"
20
+ base_path = "/runes-foundry"
21
21
  target_path = "/runes-foundry/targets"
22
22
  run_test_path = "/runes-foundry/run-test"
23
23
  share_path = "/runes-foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
24
26
 
25
27
  [foundry.libs]
26
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -45,6 +47,7 @@ url = "https://api.eitri.tech/miniapp-manager-api"
45
47
  url = "https://api.eitri.tech/eitri-manager-api"
46
48
  revision_path = "/v2/revisions"
47
49
  publish_path = "/revisions/:eitriAppId/publish"
50
+ application_by_id_path = "/applications/:applicationId"
48
51
 
49
52
  [eitri_analytics]
50
53
  url = "https://api.eitri.tech/analytics/event"
@@ -17,10 +17,12 @@ url = "https://api.eitri.tech/share-api/share"
17
17
 
18
18
  [foundry]
19
19
  url = "https://api.eitri.tech"
20
- base_path = "foundry"
20
+ base_path = "/foundry"
21
21
  target_path = "/foundry/targets"
22
22
  run_test_path = "/foundry/run-test"
23
23
  share_path = "/foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
24
26
 
25
27
  [foundry.libs]
26
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -40,6 +42,7 @@ path = "/mini-log/socket.io"
40
42
  url = "https://api.eitri.tech/eitri-manager-api"
41
43
  revision_path = "/v2/revisions"
42
44
  publish_path = "/revisions/:eitriAppId/publish"
45
+ application_by_id_path = "/applications/:applicationId"
43
46
 
44
47
  [eitri_analytics]
45
48
  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"
@@ -17,10 +17,12 @@ 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"
20
+ base_path = "/runes-foundry"
21
21
  target_path = "/runes-foundry/targets"
22
22
  run_test_path = "/runes-foundry/run-test"
23
23
  share_path = "/foundry/share"
24
+ clean_path = "/sources"
25
+ shared_tags_json_path = "/user/:workspaceId/index.json"
24
26
 
25
27
  [foundry.libs]
26
28
  update_libs_endpoint_version = "application/vnd.workspace.api.v2+json"
@@ -45,6 +47,7 @@ url = "https://api.eitri.tech/miniapp-manager-api"
45
47
  url = "https://api.eitri.tech/eitri-manager-api"
46
48
  revision_path = "/v2/revisions"
47
49
  publish_path = "/revisions/:eitriAppId/publish"
50
+ application_by_id_path = "/applications/:applicationId"
48
51
 
49
52
  [eitri_analytics]
50
53
  url = "https://api.eitri.tech/analytics/event"
@@ -11,3 +11,6 @@ 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
+ }
@@ -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.2",
3
+ "version": "1.12.0-beta.4",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
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,11 +45,11 @@ 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
-
48
+ debug("Fim da busca e validação do EitriAppConf", { miniConf })
49
+
50
50
  const url = config.get('workspace').url
51
- const setupResult = await workspace.setup()
52
- debug("Informações do setupResult do workspace", {setupResult})
51
+ const setupResult = await workspace.setup(args)
52
+ debug("Informações do setupResult do workspace", { setupResult })
53
53
 
54
54
 
55
55
  const target = setupResult.target.name
@@ -64,23 +64,25 @@ module.exports = async function start(args) {
64
64
  workspace.setServerUrl(url)
65
65
  workspace.setQrCodeUrl(qrCodeUrl)
66
66
 
67
- debug("Iniciando workspace", {workspace})
67
+ debug("Iniciando workspace", { workspace })
68
68
  await workspace.init()
69
- debug("Workspace iniciado", {workspace})
69
+ debug("Workspace iniciado", { workspace })
70
70
 
71
71
  const silentOnConnect = args.verbose ? false : true
72
72
  const userWorkspace = await vegvisirService.getWorkspace()
73
73
  console.log(`Construindo para o Workspace [${userWorkspace.id}]`)
74
- await miniLog.connect(userWorkspace.id, silentOnConnect)
74
+ if (!args.skipMiniLog) {
75
+ await miniLog.connect(userWorkspace.id, silentOnConnect)
76
+ }
75
77
 
76
78
  LogVerbose(args.verbose, "Construindo...");
77
79
  const isDevMode = true
78
80
  try {
79
- debug("Iniciando workspace.uploadZip", {isDevMode, workspace})
81
+ debug("Iniciando workspace.uploadZip", { isDevMode, workspace })
80
82
  await workspace.uploadZip(isDevMode);
81
83
  } catch (error) {
82
- debug("Erro no workspace.uploadZip", {isDevMode, workspace, error})
83
- if(args.verbose){
84
+ debug("Erro no workspace.uploadZip", { isDevMode, workspace, error })
85
+ if (args.verbose) {
84
86
  console.error("::uploadZip::", error?.message)
85
87
  console.error(":::uploadZip::: ", error)
86
88
  }
@@ -90,29 +92,29 @@ module.exports = async function start(args) {
90
92
  const friendlyMessage3 = "Se o problema persistir, por favor, entre em contato com o suporte técnico do Eitri."
91
93
  const friendlyMessage4 = "Você pode continuar o desenvolvimento localmente, mesmo que a sincronização não esteja disponível no momento."
92
94
  displayFriendlyErrorAtEnd = `\x1b[1m\x1b[31m\n${friendlyMessage1}\n${friendlyMessage2} \x1b[0m` + "\n" + `\n${friendlyMessage3}\n${friendlyMessage4}\n\x1b[0m`
93
-
95
+
94
96
  const errorData = error.response.data
95
97
  const commonStartErrors = ['CodeCompileError', 'TagNotFound']
96
- if(commonStartErrors.includes(errorData.name)) {
98
+ if (commonStartErrors.includes(errorData.name)) {
97
99
  displayFriendlyErrorAtEnd += `\n\x1b[1m\x1b[31mMotivo: ${errorData.friendlyMessage}\x1b[0m\n`;
98
100
  }
99
101
  }
100
102
  console.log("Pronto!\n");
101
103
 
102
104
  const loadedTarget = await workspace.getTarget()
103
- debug("Target carregado do workspace", {loadedTarget})
105
+ debug("Target carregado do workspace", { loadedTarget })
104
106
 
105
107
  const platform = loadedTarget.platform
106
108
  const argsWithDeeplinks = {
107
109
  ...args,
108
110
  deepLinks: loadedTarget?.deepLinks || []
109
111
  }
110
- debug("Iniciando servidor", {argsWithDeeplinks, trackingService, watcher, workspace, target, setupResult, platform})
112
+ debug("Iniciando servidor", { argsWithDeeplinks, trackingService, watcher, workspace, target, setupResult, platform })
111
113
  await handleStartServer(argsWithDeeplinks, trackingService, watcher, workspace, target, setupResult, platform)
112
- debug("Servidor iniciado", {loadedTarget})
114
+ debug("Servidor iniciado", { loadedTarget })
113
115
 
114
116
  TrackingEitriAnalytics.sendEvent({
115
- eventName:"start",
117
+ eventName: "start",
116
118
  userId: workspace?.userEmail,
117
119
  data: {
118
120
  workspaceId: userWorkspace.id,
@@ -121,7 +123,7 @@ module.exports = async function start(args) {
121
123
  }
122
124
  })
123
125
  } catch (e) {
124
- debug("Erro no processo de start", {message: e?.message, error: e})
126
+ debug("Erro no processo de start", { message: e?.message, error: e })
125
127
  TrackingEitriAnalytics.sendEvent({
126
128
  eventName: "start.error",
127
129
  userId: workspace?.userEmail,
@@ -149,8 +151,8 @@ module.exports = async function start(args) {
149
151
  await trackingService.sendError(e)
150
152
 
151
153
  process.exit(1)
152
- } finally{
153
- if(displayFriendlyErrorAtEnd){
154
+ } finally {
155
+ if (displayFriendlyErrorAtEnd) {
154
156
  const folderHash = workspace.getFolderHashPath()
155
157
  await workspace.transpile([folderHash])
156
158
  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,15 @@
1
+ const commander = require("commander");
2
+ module.exports = function AppCommand() {
3
+ const app = commander.command("app")
4
+ .description("Gerencia os workspaces do desenvolvedor, para mais informações execute 'eitri workspace --help'")
5
+
6
+ app
7
+ .command("start")
8
+ .description("Lista os workspaces do usuário")
9
+ .action(async (cmdObj) => {
10
+ const eitriCLIV2 = require("../../../eitri-cli-v2/index.js");
11
+ await eitriCLIV2.app.start(cmdObj)
12
+ });
13
+
14
+ return app;
15
+ };
@@ -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`);
@@ -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,7 +31,7 @@ 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
37
 
@@ -139,6 +139,9 @@ class Workspace {
139
139
  throw Error("Arquivo eitri-app.conf.js sem version");
140
140
  }
141
141
  }
142
+ if (process.env.WORKSPACE_SHARED) {
143
+ this._miniConf['eitri-luminus'] = process.env.WORKSPACE_SHARED
144
+ }
142
145
  return this._miniConf;
143
146
  }
144
147
 
@@ -183,8 +186,9 @@ class Workspace {
183
186
  });
184
187
  }
185
188
 
186
- async setup() {
189
+ async setup(args) {
187
190
  const miniConf = this.getMiniConf();
191
+ miniConf.isShared = args.shared
188
192
  const headers = {
189
193
  accept: this.config.libs.updateLibsEndpointVersion,
190
194
  };
@@ -242,7 +246,7 @@ class Workspace {
242
246
  let libVersionsOutput = "";
243
247
  state.libs.forEach((lib) => {
244
248
  let libraryDisplayName = lib.name
245
- if(libraryDisplayName === "eitri-luminus"){
249
+ if (libraryDisplayName === "eitri-luminus") {
246
250
  libraryDisplayName = extractSlug(miniConf[lib.name])
247
251
  }
248
252