eitri-cli 1.24.0 → 1.25.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.
@@ -46,6 +46,13 @@ pipelines:
46
46
  caches:
47
47
  - node
48
48
  script:
49
+ - apt-get update
50
+ - cd eitri-cli-v2
51
+ - npm i
52
+ - npm run build:debug
53
+ - cd ..
54
+ - npm i
55
+ - npm i -g .
49
56
  - mkdir -p ~/.eitri/workspaces
50
57
  - cp -r eitri-cli-v2/tests/fixtures/fake-workspace ~/.eitri/workspaces/workspace
51
58
  - cd eitri-cli-v2
@@ -24,6 +24,7 @@ export declare function eitriLibs(eitriLibsArgs: EitriLibsArguments): Promise<vo
24
24
  export declare function doctor(): Promise<void>
25
25
  export declare function start(args: StartArguments): Promise<void>
26
26
  export declare function create(args: CreateArguments): Promise<void>
27
+ export declare function updateChecker(): void
27
28
  export declare namespace app {
28
29
  export function start(args: StartArguments): Promise<void>
29
30
  export function appLogs(): Promise<void>
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { publish, runTest, eitriLibs, doctor, start, create, app, workspace } = nativeBinding
313
+ const { publish, runTest, eitriLibs, doctor, start, create, updateChecker, app, workspace } = nativeBinding
314
314
 
315
315
  module.exports.publish = publish
316
316
  module.exports.runTest = runTest
@@ -318,5 +318,6 @@ module.exports.eitriLibs = eitriLibs
318
318
  module.exports.doctor = doctor
319
319
  module.exports.start = start
320
320
  module.exports.create = create
321
+ module.exports.updateChecker = updateChecker
321
322
  module.exports.app = app
322
323
  module.exports.workspace = workspace
package/index.js CHANGED
@@ -10,9 +10,26 @@ const VegvisirCommand = require("./src/modules/vegvisir/VegvisirCommand");
10
10
  const AppCommand = require("./src/modules/app/AppCommand");
11
11
  const debug = require("debug")("eitri:run");
12
12
 
13
+ const globalEitriCLIV2 = require("./eitri-cli-v2/index.js");
14
+
15
+ const checkVerbose = () => {
16
+
17
+ const argsList = Array.isArray(process?.argv) && process.argv.length > 0 ? process.argv : [];
18
+
19
+ if (argsList.length > 0) {
20
+ const verboseArgs = argsList.filter(arg => arg === "-v" || arg === "--verbose");
21
+
22
+ if (verboseArgs.length > 0) {
23
+ process.env.RUST_LOG = "info";
24
+ }
25
+
26
+ }
27
+ }
28
+
13
29
  const run = async () => {
14
30
  const NEW_CLI_VERSION = process.env.CLI_VERSION === "v2";
15
31
 
32
+ checkVerbose();
16
33
  debug("Iniciando run()");
17
34
  // Temporariamente necessário por conta de no contexto do Rust não saber o diretório atual, dessa forma exportando o fullPath do config é possível.
18
35
  // Quando se tornar uma CLI somente em rust no processo de instalação podemos declarar o caminho, como é via NPM pode ter caminhos variados de acordo com sistema de versionamento, NVM, Volta, ASDF é necessário a variável abaixo.
@@ -29,6 +46,20 @@ const run = async () => {
29
46
  // Continuando como antes...
30
47
  }
31
48
 
49
+
50
+ try {
51
+ const hasCommandsList = process.argv.length > 2;
52
+ if (hasCommandsList) {
53
+ const command = process.argv[2];
54
+
55
+ const showCheckUpdate = command !== "--version" && command !== "-v";
56
+
57
+ if (showCheckUpdate) globalEitriCLIV2.updateChecker();
58
+ }
59
+ } catch (error) {
60
+ debug("Erro ao verificar atualização", {message: error?.message, error: error});
61
+ }
62
+
32
63
  program.option("-v, --version", "Mostra a versão da CLI").action(() => {
33
64
  const { version } = require("./src/cmd/version");
34
65
  version();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.24.0",
3
+ "version": "1.25.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": {
@@ -68,13 +68,31 @@ class MiniLog {
68
68
  if (event.publish.ok) {
69
69
  resolve(event)
70
70
  } else {
71
- console.error(event.publish.friendlyMessage || event.publish.error)
71
+ this.pushVersionErrorFriendlyMessage(event)
72
72
  return process.exit(1)
73
73
  }
74
74
  })
75
75
  })
76
76
  }
77
77
 
78
+ pushVersionErrorFriendlyMessage(event) {
79
+ const errorMessage = event.publish.friendlyMessage || event.publish.error
80
+
81
+ const withoutOrganizationError = "Request failed with status code 403"
82
+
83
+ console.log("\n\n")
84
+
85
+ if (errorMessage.includes(withoutOrganizationError)) {
86
+ const messages = [
87
+ "Você não faz parte da organização ou não está associado a este Eitri-App",
88
+ "Por favor, entre em contato com o administrador da organização."
89
+ ]
90
+ console.error(messages.join("\n"))
91
+ } else {
92
+ console.error(errorMessage)
93
+ }
94
+ }
95
+
78
96
  awaitForGenerateLoginCredentials() {
79
97
  return new Promise((resolve) => {
80
98
  this.socket.on('onLog', (event) => {