eitri-cli 1.1.4-beta.1 → 1.1.7-alpha.3

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.
@@ -0,0 +1,35 @@
1
+ {
2
+ "branches": [
3
+ "master",
4
+ {
5
+ "name": "beta",
6
+ "prerelease": true
7
+ },
8
+ {
9
+ "name": "alpha",
10
+ "prerelease": true
11
+ }
12
+ ],
13
+ "plugins": [
14
+ "@semantic-release/commit-analyzer",
15
+ "@semantic-release/release-notes-generator",
16
+ "@semantic-release/npm",
17
+ "@semantic-release/git",
18
+ [
19
+ "@semantic-release/changelog",
20
+ {
21
+ "changelogFile": "CHANGELOG.md"
22
+ }
23
+ ],
24
+ [
25
+ "@semantic-release/git",
26
+ {
27
+ "assets": [
28
+ "CHANGELOG.md",
29
+ "package.json"
30
+ ],
31
+ "message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
32
+ }
33
+ ]
34
+ ]
35
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,57 @@
1
+ ## [1.1.7-alpha.3](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.7-alpha.2...v1.1.7-alpha.3) (2023-10-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Adicionado release/npm ao .releaserc ([15a7e7d](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/15a7e7d2e0648d10cf3c6f409a81ef3fc00dd383))
7
+
8
+ ## [1.1.7-alpha.2](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.7-alpha.1...v1.1.7-alpha.2) (2023-10-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * teste de log de versão em novo step ([27f715d](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/27f715d2709484b4c33627413f2974bfa433e2d0))
14
+
15
+ ## [1.1.7-alpha.1](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.6...v1.1.7-alpha.1) (2023-10-04)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * Log da versão do process.env ([716b4f6](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/716b4f6f41238f0a69f6ac587e8d5171c4051dcf))
21
+
22
+ ## [1.1.6](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.5...v1.1.6) (2023-10-04)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Alterada ordem de escrita ([eafbec7](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/eafbec783aa5bc6f8fdb20ff35d2a343b411f2db))
28
+
29
+ ## [1.1.5](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.4...v1.1.5) (2023-10-04)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * alterado log ([0ec103a](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/0ec103a44311bfae3044d0816ec4d9cae07a78e9))
35
+
36
+ ## [1.1.4](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.3...v1.1.4) (2023-10-04)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * Alterada alpha para testar se irá alterar versão no package.json (ou se muda somente na master) ([75f659b](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/75f659ba6bc156e539eb7d8344f5584569ce016d))
42
+ * Log para verificar versão gerada ([31dff20](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/31dff2006c704a3f58fad1d941b7daa07537b3bb))
43
+ * Teste para alteração de versão automaticamente. ([4913e12](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/4913e12d605d2814d7ec387a01285a21fee6af1d))
44
+
45
+ ## [1.1.4-alpha.2](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.4-alpha.1...v1.1.4-alpha.2) (2023-10-04)
46
+
47
+
48
+ ### Bug Fixes
49
+
50
+ * Log para verificar versão gerada ([31dff20](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/31dff2006c704a3f58fad1d941b7daa07537b3bb))
51
+
52
+ ## [1.1.4-alpha.1](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.3...v1.1.4-alpha.1) (2023-10-04)
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * Teste para alteração de versão automaticamente. ([4913e12](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/4913e12d605d2814d7ec387a01285a21fee6af1d))
@@ -1,15 +1,17 @@
1
1
  image: node:18
2
2
  pipelines:
3
- default:
4
- - step: &npmPublish
5
- name: Publicação no NPM
6
- caches:
7
- - node
8
- script:
9
- - yarn
10
- - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
11
- - node publisher.js
12
-
13
3
  branches:
14
- master:
15
- - step: *npmPublish
4
+ alpha:
5
+ - step:
6
+ name: "Alteração de versão automaticamente (teste para validar fluxo na alpha)"
7
+ caches:
8
+ - node
9
+ script:
10
+ - echo 'Start release'
11
+ - yarn
12
+ - yarn run release
13
+ - RELEASE_VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
14
+ - node -e "const fs = require('fs'); const packageJson = JSON.parse(fs.readFileSync('package.json')); packageJson.version = process.env.RELEASE_VERSION; fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 4));"
15
+ - echo 'New release'
16
+ - echo process.env.RELEASE_VERSION
17
+ - node -e "const fs = require('fs'); const packageJson = JSON.parse(fs.readFileSync('package.json')); packageJson.version = process.env.RELEASE_VERSION; fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 4));"
@@ -2,7 +2,7 @@
2
2
  const HOST = "prod.eitri.calindra.com.br";
3
3
  const packageJson = require("../package.json");
4
4
  const path = require("path");
5
- const HOST_MINIAPPS = "prod.eitri.calindra.com.br";
5
+ const FOUNDRY_CONTEXT_PATH = process.env.FOUNDRY_CONTEXT_PATH ?? 'foundry'
6
6
 
7
7
  const config = {
8
8
  userAgent: packageJson.name,
@@ -15,17 +15,17 @@ const config = {
15
15
  .replace(".js", ".")}conf.js`,
16
16
  },
17
17
  doc: {
18
- createUrl: `https://admin.${HOST_MINIAPPS}/docs`,
18
+ createUrl: `https://admin.${HOST}/docs`,
19
19
  },
20
20
  blindGuardian: {
21
- url: `https://${HOST_MINIAPPS}/blind-guardian-api`,
21
+ url: `https://${HOST}/blind-guardian-api`,
22
22
  },
23
23
  shareApi: {
24
- url: `https://${HOST_MINIAPPS}/share-api/share`,
24
+ url: `https://${HOST}/share-api/share`,
25
25
  },
26
26
  workspace: {
27
27
  url: `https://${HOST}`,
28
- basePath: "foundry",
28
+ basePath: FOUNDRY_CONTEXT_PATH,
29
29
  targetPath: "/foundry/targets",
30
30
  target: {
31
31
  knownTargets: [
@@ -42,8 +42,6 @@ const config = {
42
42
  v2Header: "application/vnd.workspace.api.v2+json",
43
43
  },
44
44
  colossus: {
45
- // url: 'https://colossus.lab.calindra.com.br/colossus-api/v1',
46
- // url: 'https://a32bcb528a6a.ngrok.io/colossus-api/v1',
47
45
  url: `https://${HOST}/workspace/server`,
48
46
 
49
47
  // pasta do miniapp dentro de src
@@ -62,11 +60,11 @@ const config = {
62
60
  url: "https://prod.eitri.calindra.com.br/workspace/share",
63
61
  },
64
62
  miniLog: {
65
- url: `https://${HOST_MINIAPPS}/mini-log/rooms`,
63
+ url: `https://${HOST}/mini-log/rooms`,
66
64
  path: "/mini-log/socket.io",
67
65
  },
68
66
  managerApi: {
69
- url: `https://${HOST_MINIAPPS}/miniapp-manager-api`,
67
+ url: `https://${HOST}/miniapp-manager-api`,
70
68
  invites: {
71
69
  send: "/p/invites",
72
70
  slug: "/p/invites/s/:slug",
@@ -79,10 +77,10 @@ const config = {
79
77
  },
80
78
  },
81
79
  eitriManager: {
82
- url: `https://${HOST_MINIAPPS}/eitri-manager-api`,
80
+ url: `https://${HOST}/eitri-manager-api`,
83
81
  },
84
82
  workspaceManager: {
85
- url: `https://${HOST_MINIAPPS}`,
83
+ url: `https://${HOST}`,
86
84
  path: "/workspace-manager/socket.io",
87
85
  contextPath: "/workspace-manager",
88
86
  },
package/index.js CHANGED
@@ -20,12 +20,10 @@ const run = async () => {
20
20
  // Continuando como antes...
21
21
  }
22
22
 
23
- program
24
- .option('-v, --version', 'Mostra a versao da CLI')
25
- .action(() => {
26
- const {version} = require('./src/cmd/version')
27
- version()
28
- })
23
+ program.option("-v, --version", "Mostra a versao da CLI").action(() => {
24
+ const { version } = require("./src/cmd/version");
25
+ version();
26
+ });
29
27
 
30
28
  program
31
29
  .command("login")
@@ -38,9 +36,7 @@ const run = async () => {
38
36
 
39
37
  program
40
38
  .command("create <project-name>")
41
- .description(
42
- `Cria um projeto com um mini app totalmente funcional. Mais detalhes em ${config?.doc?.createUrl}`
43
- )
39
+ .description(`Cria um projeto com um eitri app totalmente funcional.`)
44
40
  .option(
45
41
  "--yes",
46
42
  "Aceita os valores default para nome titulo e organizacao"
@@ -49,7 +45,7 @@ const run = async () => {
49
45
  "--template <template-name>",
50
46
  "Define um boilerplate para a criação do projeto"
51
47
  )
52
- .option("--target", "Define a plataforma de execução do Mini App")
48
+ .option("--target", "Define o application de execução do eitri app")
53
49
  .option("-v, --verbose", "Exibe mais logs")
54
50
  .action((projectName, cmdObj) => {
55
51
  require("./src/cmd/create")(projectName, cmdObj);
@@ -115,40 +111,16 @@ const run = async () => {
115
111
  require("./src/cmd/start")(cmdObj);
116
112
  });
117
113
 
118
- // program
119
- // .command('test-initialization-params <initializationParams>')
120
- // .description('Passa parâmetros em querystring para a inicialização do mini app. ex: "stringChave1=stringValor1&stringChave2=stringValor2..."')
121
- // .option('-Q, --old-qrcode', 'QR Code legado')
122
- // .option('-N, --new-qrcode', '(Obsoleto) Novo qrcode')
123
- // .option('-S, --show-deeplink', 'Exibe o deep link do workspace')
124
- // .option('-V, --verbose', 'Exibe mais logs')
125
- // .action((initializationParams, cmdObj) => {
126
- // if (cmdObj.newQrcode) {
127
- // console.log('Uso de -N ou --new-qrcode é redundante. O "eitri" já otimiza o Qr Code.')
128
- // }
129
-
130
- // require('./src/cmd/test-initialization-params')(initializationParams, cmdObj)
131
- // })
132
-
133
- // program
134
- // .command('order-details <orderId>')
135
- // .description('Abre o mini app na tela de detalhes da ordem')
136
- // .option('-l, --local', 'Aponta para o servidor local')
137
- // .option('-A, --upload-all', 'Sobe todos os arquivos')
138
- // .action((orderId, cmdObj) => {
139
- // require('./src/cmd/order-details')(orderId, cmdObj)
140
- // })
141
-
142
114
  program
143
115
  .command("push-version")
144
116
  .description(
145
- "Cria e envia um build do mini app para ser avaliado por um revisor antes de ser publicado"
117
+ "Cria e envia um build do eitri app para ser avaliado por um revisor antes de ser publicado"
146
118
  )
147
119
  .option("-l, --local", "Aponta para o servidor local")
148
120
  .option("-v, --verbose", "Exibe mais logs")
149
121
  .option(
150
122
  "-c, --components",
151
- "Publica o Eitri-App como biblioteca de components"
123
+ "Publica o eitri app como biblioteca de components"
152
124
  )
153
125
  .option(
154
126
  "-m, --message <revision-message>",
@@ -159,61 +131,27 @@ const run = async () => {
159
131
  require("./src/cmd/push-version")(cmdObj);
160
132
  });
161
133
 
162
- // program
163
- // .command('clean')
164
- // .description(
165
- // 'Realiza a limpeza do workspace remoto do desenvolvedor. Útil quando há mal fucionamento na compilação em nuvem do eitri-app.'
166
- // )
167
- // .option('-v, --verbose', 'Exibe mais logs')
168
- // .action(cmdObj => {
169
- // require('./src/cmd/clean')(cmdObj)
170
- // })
134
+ program
135
+ .command('clean')
136
+ .description(
137
+ 'Realiza a limpeza do workspace remoto do desenvolvedor. Útil quando há mal fucionamento na compilação em nuvem do eitri app.'
138
+ )
139
+ .option('-v, --verbose', 'Exibe mais logs')
140
+ .action(cmdObj => {
141
+ require('./src/cmd/clean')(cmdObj)
142
+ })
171
143
 
172
144
  program
173
145
  .command("self-update")
174
146
  .description("Desinstala a versao antiga e instala a mais nova")
175
147
  .action(() => {
176
- require('child_process').execSync(
177
- 'npm uninstall -g eitri-cli && npm i eitri-cli -g',
178
- {stdio: 'inherit'}
179
- )
180
- })
148
+ require("child_process").execSync(
149
+ "npm uninstall -g eitri-cli && npm i eitri-cli -g",
150
+ { stdio: "inherit" }
151
+ );
152
+ });
181
153
 
182
- // program
183
- // .command('open-share <share-id>')
184
- // .description('Abre um compartilhamento do share-api')
185
- // .action((shareId, cmdObj) =>
186
- // require('./src/cmd/open-share')(shareId, cmdObj)
187
- // )
188
-
189
- // program
190
- // .command('tail-logs <email>')
191
- // .description('Para ler logs de prod do email')
192
- // .action((email, cmdObj) => {
193
- // require('./src/cmd/tail-logs')(email, cmdObj)
194
- // })
195
-
196
- // program
197
- // .command('invite [email]')
198
- // .option('--remove', 'Remove o desenvolvedor')
199
- // .option('--list', 'Lista todos os desenvolvedores')
200
- // .option('--accept', 'Aceita um convite')
201
- // .option('-v, --verbose', 'Exibe mais logs')
202
- // .description('Convida um desenvolvedor para contribuir com o seu miniapp')
203
- // .action((email, cmdObj) => require('./src/cmd/invite')(email, cmdObj))
204
-
205
- // program
206
- // .command('list')
207
- // .description('Lista as opções de um determinado comando')
208
- // .option('--template', 'exibe os tipos de templates disponíveis, para gerar um exemplo de projeto.')
209
- // .action((cmdObj) =>
210
- // require('./src/cmd/list')(cmdObj))
211
-
212
- // if (!process.argv.slice(2).length) {
213
- // program.outputHelp()
214
- // }
215
-
216
- program.addCommand(VegvisirCommand());
154
+ program.addCommand(VegvisirCommand())
217
155
 
218
156
  if (
219
157
  process.argv.length > 2 &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.1.4-beta.1",
3
+ "version": "1.1.7-alpha.3",
4
4
  "description": "Command Line Interface to make \"eitri app\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -10,7 +10,9 @@
10
10
  "test-eitri": "NODE_APP_INSTANCE=eitri jest --detectOpenHandles",
11
11
  "linter": "./node_modules/.bin/eslint --fix ./src/**/*.js",
12
12
  "docsify:run": "cd docsify && docsify serve",
13
- "build": "echo \"no build\""
13
+ "build": "echo \"no build\"",
14
+ "release": "semantic-release",
15
+ "release:dry": "semantic-release --dry-run"
14
16
  },
15
17
  "engines": {
16
18
  "node": ">=16.0.0",
@@ -68,7 +70,10 @@
68
70
  "husky": "^3.1.0",
69
71
  "jest": "^24.9.0",
70
72
  "lint-staged": "^9.5.0",
71
- "nock": "^13.3.0"
73
+ "nock": "^13.3.0",
74
+ "semantic-release": "^22.0.5",
75
+ "@semantic-release/changelog": "^6.0.3",
76
+ "@semantic-release/git": "^10.0.1"
72
77
  },
73
78
  "resolutions": {
74
79
  "lodash": "4.17.21",
package/publisher.js CHANGED
@@ -1,48 +1,54 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
- const { execSync, exec } = require('child_process');
3
+ const {execSync, exec} = require('child_process');
4
4
 
5
5
  publishAsNeeded();
6
6
 
7
7
  function publishAsNeeded() {
8
8
  fs.readFile(path.join(__dirname, 'package.json'), 'utf8', (err, data) => {
9
+
9
10
  if (err) {
10
11
  console.error('Error:', err);
11
12
  return;
12
13
  }
13
- let packageJson = JSON.parse(data);
14
- let localVersion = packageJson.version;
15
- let publishedVersions = JSON.parse(execSync('npm show ' + packageJson.name + ' versions --json').toString());
16
- if (publishedVersions.includes(localVersion)) {
17
- console.log('published version is the same of package.json:', localVersion);
18
- return;
19
- }
20
14
 
21
- console.log('publishing new version', localVersion, '...');
15
+ const _BRANCHS = {
16
+ MASTER: "master",
17
+ BETA: "beta",
18
+ }
22
19
 
23
20
  const branch = process.env.BITBUCKET_BRANCH
24
- console.log('current branch on build', branch);
21
+ console.log('Current branch on build: ', branch);
25
22
 
26
- //apenas beta e alpha pode ser publicado fora da master
27
- if("master" !== branch && !(/beta|alpha/.test(localVersion))){
28
- console.log('main channel out of master branch SKIPPED...');
23
+ const allowedBranchs = [_BRANCHS.MASTER, _BRANCHS.BETA]
24
+ if(!allowedBranchs?.includes(branch)){
25
+ console.log(`${branch} is different from ${JSON.stringify(allowedBranchs)}. Skipping...`);
29
26
  return;
30
27
  }
31
28
 
32
- let commandSuffix = "";
29
+ const packageJson = JSON.parse(data);
30
+ const localVersion = packageJson.version;
31
+
32
+ if (branch === _BRANCHS.BETA && !(/beta/.test(localVersion))) {
33
+ console.log(`${localVersion} version does not contain the "beta" suffix in the version name. Skipping...`);
34
+ return;
35
+ }
33
36
 
34
- if(/beta/.test(localVersion)) {
35
- commandSuffix = "--tag beta";
36
- } else if(/alpha/.test(localVersion)) {
37
- commandSuffix = "--tag alpha";
37
+ const publishedVersions = JSON.parse(execSync('npm show ' + packageJson.name + ' versions --json').toString());
38
+ if (publishedVersions.includes(localVersion)) {
39
+ console.log('There is a published version identical to the one in package.json: ', localVersion);
40
+ return;
38
41
  }
39
42
 
43
+ console.log('Previously unpublished version. Allowed version name for publishing: ', localVersion);
44
+
45
+ const commandSuffix = branch === _BRANCHS.BETA ? "--tag beta" : "";
46
+
40
47
  exec('npm run build && npm publish ' + commandSuffix, (err, stdout, stderr) => {
41
48
  if (err) {
42
49
  // node couldn't execute the command
43
50
  console.log('Error:', err);
44
51
  process.exit(2);
45
- return;
46
52
  }
47
53
 
48
54
  // the *entire* stdout and stderr (buffered)
package/src/cmd/clean.js CHANGED
@@ -12,46 +12,7 @@ const targetService = new TargetService(workspace)
12
12
 
13
13
  module.exports = async function clean(cmdObj) {
14
14
  try {
15
- const start = Date.now()
16
15
  await validator.assertCommandNotRunning('clean')
17
- let miniConf = workspace.getMiniConf()
18
- let validateResult = checkErros(miniConf)
19
-
20
- if (!validateResult.isSuccess()) {
21
- console.log(
22
- 'Por favor, verifique atentamente os erros exibidos acima. Siga o exemplo abaixo: ' +
23
- `
24
- module.exports = {
25
-
26
- // Dados da sua empresa
27
- organization: {
28
- "name": "Minha Empresa"
29
- },
30
-
31
- // Nome do seu mini app
32
- "name": "Meu Mini App",
33
-
34
- // Titulo do mini app, que vai em baixo do botao na pagina de transacoes
35
- "title": "Meu super mini app",
36
-
37
- // Chave para gerar a ordem/qrcode de pagamento (opcional)
38
- "public-key": "",
39
-
40
- // Identificador amigavel para colocar em uma url
41
- "slug": "com.eitri.loja",
42
-
43
- // Versao do mini app
44
- "version": "1.0.0",
45
-
46
- ${await targetService.getAppConfExampleSnippet()}
47
- };
48
-
49
-
50
- `
51
- )
52
-
53
- return
54
- }
55
16
 
56
17
  blindGuardian.readConf()
57
18
  workspace.setServerUrl(config.get('workspace').url)
@@ -63,7 +24,6 @@ ${await targetService.getAppConfExampleSnippet()}
63
24
 
64
25
  console.log('[1] Limpo.')
65
26
 
66
- await track(miniConf, start)
67
27
  TrackingEitriAnalytics.sendEvent({
68
28
  command: "clean",
69
29
  success: true,
package/src/cmd/login.js CHANGED
@@ -6,13 +6,13 @@ 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
10
 
11
11
  const {openPortalAnwser} = await inquirer.prompt([
12
12
  {
13
13
  type: 'confirm',
14
14
  name: 'openPortalAnwser',
15
- message: ' Podemos guiá-lo até o nosso sagrado portal?',
15
+ message: ' Podemos redirecioná-lo para o login?',
16
16
  },
17
17
  ])
18
18
 
@@ -24,19 +24,19 @@ module.exports = async function login(args) {
24
24
  let portalOpenMessage = ""
25
25
 
26
26
  if (openPortalAnwser) {
27
- console.log("\n", "Abrindo o portal...")
27
+ console.log("\n", "Redirecionando...")
28
28
  try {
29
29
  open(urlAdminManagerCredentialWithParams)
30
- portalOpenMessage = "Portal aberto em seu navegador padrão"
30
+ portalOpenMessage = "Aberto em seu navegador padrão"
31
31
  } catch (error) {
32
- portalOpenMessage = "Não foi possível abrir o portal. Você terá que fazer isso dessa vez. Copie o link e cole em seu navegador para fazer o login na Eitri CLI. " + urlAdminManagerCredentialWithParams
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
33
33
  }
34
34
  } else {
35
35
  portalOpenMessage = "Copie o link e cole em seu navegador para fazer o login na Eitri CLI. " + urlAdminManagerCredentialWithParams
36
36
  }
37
37
 
38
38
  console.log("\n", portalOpenMessage)
39
- console.log("\n\n Aguardando pela autenticação...")
39
+ console.log("\n\n Aguardando autenticação...")
40
40
  } catch (error) {
41
41
  await TrackingEitriAnalytics.sendEvent({
42
42
  command: "login",
@@ -72,7 +72,7 @@ ${await targetService.getAppConfExampleSnippet()}
72
72
  const separator = '======================================================================='
73
73
  blindGuardian.readConf()
74
74
  workspace.setServerUrl(config.get('workspace').url)
75
- console.log('Conectando à forja de Eitri')
75
+ console.log('Conectando ao Eitri...')
76
76
  await workspace.init()
77
77
  const userWorkspace = await getWorkspace()
78
78
  await miniLog.connect(userWorkspace.id)
@@ -101,16 +101,20 @@ ${await targetService.getAppConfExampleSnippet()}
101
101
  console.log(separator)
102
102
  console.log('\x1b[1m\x1b[32mSucesso!!\x1b[0m');
103
103
  console.log(`\x1b[1mA versão [${miniConf.version}] do seu eitri-app foi gerada e está\x1b[0m`);
104
- console.log('\x1b[1mdisponível no Eitri-console para aprovação\x1b[0m');
104
+ console.log('\x1b[1mdisponível no Eitri Console para aprovação\x1b[0m');
105
105
  console.log(separator)
106
106
 
107
+ const organization = miniConf?.organization ? Object.keys(miniConf?.organization).length !== 0 ? miniConf?.organization : "-" : {
108
+ id: miniConf?.organizationId
109
+ }
110
+
107
111
  await TrackingEitriAnalytics.sendEvent({
108
112
  command: "push-version",
109
113
  success: true,
110
114
  data: {
111
115
  eitriApp: {
112
116
  ...miniConf,
113
- organization: Object.keys(miniConf?.organization).length !== 0 ? miniConf?.organization : "-"
117
+ organization
114
118
  },
115
119
  target,
116
120
  startDate: `${start}`,
@@ -125,7 +129,7 @@ ${await targetService.getAppConfExampleSnippet()}
125
129
  } else if (e && e.message) {
126
130
  console.log(`\x1b[1m\x1b[31m${e.message}\x1b[0m`);
127
131
  } else {
128
- console.log(`\x1b[1m\x1b[31mNão será possível continuar por enquanto. A forja encontrou um erro.\x1b[0m`);
132
+ console.log(`\x1b[1m\x1b[31mNão será possível continuar por enquanto. Ocorreu um erro.\x1b[0m`);
129
133
  }
130
134
 
131
135
  await TrackingEitriAnalytics.sendEvent({
@@ -73,12 +73,6 @@ module.exports.validate = function (miniConf) {
73
73
  let isversionvalid = checkAmeVersion(miniConf)
74
74
 
75
75
 
76
- if (!miniConf.organization) {
77
- validateResult.addError(
78
- 'Por Favor, preencha o campo \'organization\' (Utilize apenas caracteres maiusculo, minusculo e espaco. Ex: \'Minha Empresa\').'
79
- )
80
- }
81
-
82
76
  if (!miniConf.name) {
83
77
  validateResult.addError(
84
78
  'Por Favor, preencha o campo \'name\' (Utilize apenas caracteres maiusculo, minusculo e espaco. Ex: \'Meu Mini App\').'
@@ -1,6 +1,6 @@
1
1
  const path = require('path')
2
2
  const { execSync } = require('child_process')
3
-
3
+ const semver = require('semver')
4
4
 
5
5
  /**
6
6
  * Loga a versao de um pacote npm
@@ -8,13 +8,13 @@ const { execSync } = require('child_process')
8
8
  function version() {
9
9
  let packageJson = require(path.resolve(__dirname, '..', '..', 'package.json'))
10
10
  let publishedVersion = getVersion(packageJson.name)
11
- if (packageJson.version !== publishedVersion) {
11
+ if (semver.lt(packageJson.version, publishedVersion)) {
12
12
  console.log(packageJson.version)
13
13
  console.log(
14
14
  `\n> Você está usando a versão ${packageJson.version}, temos uma nova versão: ${publishedVersion}!`
15
15
  )
16
16
  console.log(
17
- `> Para atualizar use o comando: ${packageJson.name} self-update`
17
+ `> Para atualizar use o comando: eitri self-update`
18
18
  )
19
19
  } else {
20
20
  console.log(packageJson.version)
@@ -1,7 +1,9 @@
1
1
  const commander = require("commander");
2
2
 
3
3
  module.exports = function VegvisirCommand() {
4
- const workspaceCommand = commander.command("workspace");
4
+ const workspaceCommand = commander.command("workspace")
5
+ .description("Gerencia os workspaces do desenvolvedor, para mais informações execute 'eitri workspace --help'")
6
+
5
7
  workspaceCommand
6
8
  .command("list")
7
9
  .description("Lista os workspaces do usuário")
@@ -0,0 +1,49 @@
1
+ const { writeFile, rename } = require("fs/promises");
2
+ const chalk = require("chalk");
3
+ const path = require('path')
4
+ const {existsSync} = require('fs')
5
+ module.exports = class EitriAppService {
6
+ validEitriConf(eitriConf) {
7
+ const requiredFields = ["id", "applicationId", "organizationId"];
8
+ let isValid = true;
9
+ for (const field of requiredFields) {
10
+ if (!eitriConf[field]) isValid = false;
11
+ }
12
+ return isValid;
13
+ }
14
+
15
+ async writeEitriConf(remoteEitriConf, localEitriConf, folder2WatchPath) {
16
+ if (!remoteEitriConf) return;
17
+
18
+ const eitriAppConfPath = path.resolve(
19
+ folder2WatchPath,
20
+ "../eitri-app.conf.js"
21
+ );
22
+
23
+ if (!existsSync(eitriAppConfPath)) {
24
+ console.warn(
25
+ chalk.yellow.underline.bold(
26
+ "Renomeando arquivo de configuração de miniapp.conf.js -> eitri-app.conf.js",
27
+ )
28
+ );
29
+ const miniAppConfPath = path.resolve(
30
+ folder2WatchPath,
31
+ "../miniapp.conf.js"
32
+ );
33
+ await rename(miniAppConfPath, eitriAppConfPath);
34
+ }
35
+
36
+ let updatedEitriConf = {
37
+ ...localEitriConf,
38
+ ...remoteEitriConf,
39
+ };
40
+
41
+ const eitriConf = `module.exports = ${JSON.stringify(
42
+ updatedEitriConf,
43
+ null,
44
+ '\t'
45
+ )}`;
46
+
47
+ await writeFile(eitriAppConfPath, eitriConf, "utf8");
48
+ }
49
+ }
@@ -50,7 +50,7 @@ class Http {
50
50
 
51
51
  getCookieSession(url) {
52
52
  return new Promise((resolve, reject) => {
53
- jar.getCookies(url, function (err, cookies) {
53
+ jar.getCookies(url, { allPaths: true }, function (err, cookies) {
54
54
  if (err) return reject(err)
55
55
  resolve(cookies.find((cookie) => cookie))
56
56
  })
@@ -121,12 +121,29 @@ class MiniLog {
121
121
  console.log(chalk.cyan(msg))
122
122
  } else {
123
123
  // A propriedade userFriendlyMessage deve ser tratada pelo miniapp. Logaremos da forma como o miniapp nos fornecer o objeto.
124
- console.log(`\x1b[34meitri:\x1b[0m\x1b[97m${data.msg}\x1b[0m`);
124
+ if(!data.method) {
125
+ console.log(`\x1b[34meitri:\x1b[0m\x1b[97m${data.msg}\x1b[0m`);
126
+ } else {
127
+ const message = this._colorizeMessage(data.msg, data.method)
128
+ console[data.method](`\x1b[34meitri:\x1b[0m${message}`);
129
+ }
125
130
  }
126
131
  if (data.stopCLI) {
127
132
  process.exit(1)
128
133
  }
129
134
  }
135
+
136
+ _colorizeMessage(message, method) {
137
+ const colorizedMessage = {
138
+ log: chalk.hex("#95DB00")(message),
139
+ warn: chalk.yellow(message),
140
+ error: chalk.red(message),
141
+ info: chalk.green(message),
142
+ debug: chalk.blue(message),
143
+ };
144
+
145
+ return colorizedMessage[method] || colorizedMessage.log
146
+ }
130
147
  }
131
148
 
132
149
  module.exports = MiniLog
@@ -18,7 +18,6 @@ const packageJson = require(path.resolve(
18
18
  const tempFolderPath = require("../util/os").OS_MAPPER;
19
19
  const TargetService = require("../service/TargetService");
20
20
  const WatcherOpts = require("../enum/WatcherOpts");
21
- const { default: axios } = require("../../node_modules/axios/index");
22
21
  const ipv4 = require("../util/ipv4");
23
22
  const { compressToBase64 } = require("lz-string");
24
23
  const Buffer = require("buffer");
@@ -26,7 +25,10 @@ const DEFAULT_ENV = "dev";
26
25
  const cliProgress = require("cli-progress");
27
26
  const EitriAppManager = require("./EitriAppManager");
28
27
  const getWorkspace = require("../util/getWorkspace");
28
+ const EitriAppService = require("./EitriAppService");
29
+
29
30
  class Workspace {
31
+
30
32
  constructor(blindGuardian, hashFolder) {
31
33
  this.config = config.get("workspace");
32
34
  this.basePath = this.config.basePath;
@@ -51,6 +53,11 @@ class Workspace {
51
53
  */
52
54
  this.progressBar;
53
55
  this.progressBarCounter = 0;
56
+ /**
57
+ * @type {EitriAppService}
58
+ * @private
59
+ */
60
+ this.eitriAppService = new EitriAppService();
54
61
  }
55
62
 
56
63
  getTargets() {
@@ -211,7 +218,11 @@ class Workspace {
211
218
 
212
219
  const setupData = setupResponse.data;
213
220
 
214
- const { state, target: remoteTarget } = setupData;
221
+ const { state, target: remoteTarget, eitriConf: remoteEitriConf } = setupData;
222
+
223
+ if(!this.eitriAppService.validEitriConf(miniConf)) {
224
+ await this.eitriAppService.writeEitriConf(remoteEitriConf, miniConf, this.folder2watch);
225
+ }
215
226
 
216
227
  this.printLibsVersion(state);
217
228
 
@@ -952,77 +963,6 @@ class Workspace {
952
963
  return results;
953
964
  }
954
965
 
955
- //TODO: ESSE MÉTODO DEVE SER APAGADO, QUANDO NÃO EXISTIR MAIS O COMANDO PUBLISH
956
- async publish(publishMessage) {
957
- const miniConf = this.getMiniConf();
958
- const formData = new FormData();
959
-
960
- formData.append("miniAppName", miniConf.name || "sem nome");
961
- formData.append("miniAppSlug", miniConf.slug || "sem-slug");
962
- formData.append("miniAppTitle", miniConf.title || "Sem Titulo");
963
- formData.append(
964
- "miniAppVersion",
965
- miniConf.miniAppVersion || miniConf.version || "0.1.0"
966
- );
967
- formData.append("organizationName", miniConf.organization.name);
968
- formData.append("publishMessage", publishMessage || "");
969
-
970
- const url = `${this.serverUrl}/${this.basePath}/publish?async=true`;
971
- await this.http.postForm(url, formData);
972
- }
973
-
974
- async build(buildMessage) {
975
- const miniConf = this.getMiniConf();
976
- const formData = new FormData();
977
-
978
- formData.append("miniAppName", miniConf.name || "sem nome");
979
- formData.append("miniAppSlug", miniConf.slug || "sem-slug");
980
- formData.append("miniAppTitle", miniConf.title || "Sem Titulo");
981
- formData.append(
982
- "miniAppVersion",
983
- miniConf.miniAppVersion || miniConf.version || "v1"
984
- );
985
- formData.append("organizationName", miniConf.organization.name);
986
- formData.append("publishMessage", buildMessage || "");
987
-
988
- const url = `${this.serverUrl}/${this.basePath}/publish?async=true`;
989
- await this.http.postForm(url, formData);
990
- }
991
-
992
- /**
993
- * @deprecated Prefira {@link Workspace#pushVersionAsJson}
994
- */
995
- async pushVersionAsForm(buildMessage) {
996
- const miniConf = this.getMiniConf();
997
- const formData = new FormData();
998
-
999
- let attrValue;
1000
-
1001
- formData.append("miniAppName", miniConf.name || "sem nome");
1002
- formData.append("miniAppSlug", miniConf.slug || "sem-slug");
1003
- formData.append("miniAppTitle", miniConf.title || "Sem Titulo");
1004
- formData.append(
1005
- "miniAppVersion",
1006
- miniConf.miniAppVersion || miniConf.version || "v1"
1007
- );
1008
- formData.append("organizationName", miniConf.organization.name);
1009
- formData.append("miniAppSubSetName", miniConf.name);
1010
- formData.append("miniAppSubSetTitle", miniConf.title);
1011
- if ((attrValue = miniConf["eitri-app-components"]))
1012
- formData.append("cliComponentsVersion", attrValue);
1013
- if ((attrValue = miniConf["eitri-app-client"]))
1014
- formData.append("cliSuperAppClientVersion", attrValue);
1015
- if ((attrValue = packageJson.version))
1016
- formData.append("cliVersion", attrValue);
1017
- if ((attrValue = buildMessage))
1018
- formData.append("publishMessage", attrValue);
1019
- if ((attrValue = miniConf.privacy))
1020
- formData.append("privacy", JSON.stringify(attrValue));
1021
-
1022
- const url = `${this.serverUrl}/${this.basePath}/publish?async=true`;
1023
- await this.http.postForm(url, formData);
1024
- }
1025
-
1026
966
  async pushVersionAsJson(args) {
1027
967
  let headers = {};
1028
968
  if (this.config.apiVersion && this.config.apiVersion.v2Header) {