eitri-cli 1.1.3 → 1.1.5-alpha.1

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,10 @@
1
+ ## [1.1.5-alpha.1](http://bitbucket.org/smartsolutionteam/eitri-cli/compare/v1.1.4...v1.1.5-alpha.1) (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
+ * Alterada ordem de escrita ([eafbec7](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/eafbec783aa5bc6f8fdb20ff35d2a343b411f2db))
8
+ * alterado log ([0ec103a](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/0ec103a44311bfae3044d0816ec4d9cae07a78e9))
9
+ * Log da versão do process.env ([716b4f6](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/716b4f6f41238f0a69f6ac587e8d5171c4051dcf))
10
+ * teste de log de versão em novo step ([27f715d](http://bitbucket.org/smartsolutionteam/eitri-cli/commits/27f715d2709484b4c33627413f2974bfa433e2d0))
@@ -1,15 +1,17 @@
1
- image: node:14
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,beta,master}':
5
+ - step:
6
+ name: "Generation of a new version: alpha, beta, or stable."
7
+ caches:
8
+ - node
9
+ script:
10
+ - echo 'Start release'
11
+ - echo 'If there is a new version, it will be automatically published on NPM according to the channel/branch (alpha, beta or master (stable)).'
12
+ - yarn
13
+ - yarn run release
14
+ - RELEASE_VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
15
+ - 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));"
16
+ - echo 'New release'
17
+ - echo $RELEASE_VERSION
package/check-version.js CHANGED
@@ -1,12 +1,13 @@
1
1
  const semver = require('semver')
2
2
  const packageJson = require('./package')
3
3
 
4
- var minVersion = packageJson.engines.node
4
+ const minVersion = packageJson.engines.node
5
5
 
6
6
  const systemVersion = semver.clean(process.version)
7
7
 
8
8
  if (!semver.satisfies(systemVersion, minVersion)){
9
- console.error('Versão não suportada do node', systemVersion)
10
- console.error('Por favor, considere atualizar', minVersion)
9
+ console.error(' O Eitri-CLI requer uma versão mais recente do Node.js')
10
+ console.error(' Por favor, atualize o Node.js para a versão mínima necessária: ', minVersion)
11
+ console.error(' Versão atual em seu dispositivo: ', systemVersion)
11
12
  process.exit(1)
12
13
  }
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5-alpha.1",
4
4
  "description": "Command Line Interface to make \"eitri app\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -10,10 +10,12 @@
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
- "node": ">=10.0.0",
18
+ "node": ">=16.0.0",
17
19
  "npm": ">=3.0.0"
18
20
  },
19
21
  "keywords": [],
@@ -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)
@@ -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,7 +8,7 @@ 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}!`
@@ -27,8 +27,6 @@ class CliLogin {
27
27
  process.exit(1)
28
28
  }
29
29
 
30
- console.log("\n", "Eis que a jornada tem início...")
31
-
32
30
  await new UserLocalCredential().asyncSaveContent({devUser, devKey})
33
31
  TrackingEitriAnalytics.sendEvent({
34
32
  command: "login",
@@ -38,7 +36,7 @@ class CliLogin {
38
36
  devUser
39
37
  }
40
38
  })
41
- console.log("\n", `✔ Triunfo! O acesso foi concedido! Você está logado como ${email}.`)
39
+ console.log("\n", `✔ Credencial gerada! Você está logado como ${email}.`)
42
40
  process.exit(0)
43
41
  }
44
42
 
@@ -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
  })
@@ -1,15 +1,29 @@
1
1
  const tmp = require('tmp')
2
2
  const qrcode = require('qrcode')
3
+ const GenericUtils = require('../util/GenericUtils')
4
+ const qrcodeTerminal = require('qrcode-terminal')
5
+ const open = require('open')
3
6
 
4
7
  // Fabrica de QR code :-)
5
8
  class QRCodeFactory {
6
- async create(data) {
9
+
10
+ generate(args) {
11
+ if (args?.qrPrinter) {
12
+ console.log(`Abrindo QR-Code no ${args?.qrPrinter}`)
13
+ open(args?.qrCodePath, {app: args?.qrPrinter})
14
+ return
15
+ }
16
+
17
+ qrcodeTerminal.generate(args?.fullUrl ?? "", {small: true})
18
+ }
19
+
20
+ async create(data, eitriAppSlug = "") {
7
21
  console.log('==================================================')
8
22
  console.log('Utilize o QR-Code para iniciar o seu eitri-app')
9
23
  console.log('É importante utilizar o leitor de QR-Code do')
10
24
  console.log('aplicativo à qual destina-se o seu eitri-app')
11
25
  console.log('==================================================')
12
- let qrCodeTempPath = await this.tempFile()
26
+ const qrCodeTempPath = await this.tempFile(eitriAppSlug)
13
27
  await this.createQRCodeImage(qrCodeTempPath, data)
14
28
  return qrCodeTempPath
15
29
  }
@@ -25,10 +39,12 @@ class QRCodeFactory {
25
39
  })
26
40
  }
27
41
 
28
- tempFile() {
42
+ tempFile(eitriAppSlug = "") {
29
43
  return new Promise((resolve, reject) => {
44
+ const currentDateTime = GenericUtils.formatQrCodeCurrentDateTime()
45
+ const qrCodeName = `[eitri] ${eitriAppSlug} ${currentDateTime}.png`
30
46
  tmp.file(
31
- { prefix: 'eitri-qrcode-', postfix: '.png', keep: true },
47
+ { name: qrCodeName, keep: true },
32
48
  function (err, tempPath) {
33
49
  if (err) {
34
50
  return reject(err)
@@ -1,8 +1,4 @@
1
1
  const QRCodeFactory = require('../QRCodeFactory')
2
- const TrackService = require('../TrackService')
3
- const Server = require('../Server')
4
- const qrcodeTerminal = require('qrcode-terminal')
5
- const TERMINAL_PRINTER_NAME = 'terminal'
6
2
 
7
3
  function QRCodeStarter(args, trackingService, watcher, workspace, targetConfig ) {
8
4
  this.args = args
@@ -23,22 +19,8 @@ function QRCodeStarter(args, trackingService, watcher, workspace, targetConfig )
23
19
  if (this.args.verbose) {
24
20
  console.log(`QrCodeUrl: ${fullUrl}`)
25
21
  }
26
- const qrCodePath = await new QRCodeFactory().create(fullUrl)
27
-
28
- if (this.args.verbose) {
29
- console.log(`QrCode Path: ${qrCodePath}`)
30
- }
31
-
32
- if(process.env.AAT_QRCODE_PRINTER === TERMINAL_PRINTER_NAME || this.args.qrPrinter === TERMINAL_PRINTER_NAME) {
33
- qrcodeTerminal.generate(fullUrl, {small: true})
34
- }
35
-
36
- const libsInfoForGA = this.args.libsInfoForGA
37
22
 
38
23
  this.watcher.start()
39
- let miniConf = this.workspace.getMiniConf()
40
- TrackService.track(miniConf, this.trackingService, libsInfoForGA)
41
- // tryToOpenAndroidEmulator(fullUrl, this.args)
42
24
  if(this.args.showDeeplink){
43
25
  console.log('######################################')
44
26
  console.log('########### Deep Link URL ############')
@@ -46,7 +28,17 @@ function QRCodeStarter(args, trackingService, watcher, workspace, targetConfig )
46
28
  console.log(`${fullUrl}`)
47
29
  console.log('######################################')
48
30
  }
49
- Server.startServer({ ...this.args, qrCodePath})
31
+
32
+ const _QRCodeFactory = new QRCodeFactory()
33
+
34
+ const eitriAppSlug = this.workspace?._miniConf?.slug ?? ""
35
+ const qrCodePath = await _QRCodeFactory.create(fullUrl, eitriAppSlug)
36
+
37
+ if (this.args.verbose) {
38
+ console.log(`QrCode Path: ${qrCodePath}`)
39
+ }
40
+
41
+ _QRCodeFactory.generate({...this.args, qrCodePath, fullUrl})
50
42
  }
51
43
  }
52
44
 
@@ -0,0 +1,19 @@
1
+ class GenericUtils {
2
+
3
+ static formatQrCodeCurrentDateTime = () => {
4
+ const now = new Date();
5
+
6
+ const year = now.getFullYear();
7
+ const month = String(now.getMonth() + 1).padStart(2, '0'); // Mês começa em 0, então adicionamos 1 e formatamos com zero à esquerda, se necessário.
8
+ const day = String(now.getDate()).padStart(2, '0');
9
+ const hours = String(now.getHours()).padStart(2, '0');
10
+ const minutes = String(now.getMinutes()).padStart(2, '0');
11
+ const seconds = String(now.getSeconds()).padStart(2, '0');
12
+
13
+ const formattedDateTime = `${hours}:${minutes}:${seconds} ${day}-${month}-${year}`;
14
+ return formattedDateTime;
15
+ }
16
+
17
+ }
18
+
19
+ module.exports = GenericUtils