eitri-cli 1.4.0-beta.3 → 1.4.0-beta.5

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.
package/index.js CHANGED
@@ -77,6 +77,7 @@ const run = async () => {
77
77
  )
78
78
  .option("-l, --local", "Aponta para o servidor local")
79
79
  .option("-v, --verbose", "Exibe mais logs")
80
+ .option("-r, --release", "Gera uma nova release baseado nos commits. Um arquivo CHANGELOG.md será gerado automaticamente.")
80
81
  .option(
81
82
  "-c, --components",
82
83
  "Publica o Eitri-App como biblioteca de components"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eitri-cli",
3
- "version": "1.4.0-beta.3",
3
+ "version": "1.4.0-beta.5",
4
4
  "description": "Command Line Interface to make \"Eitri-App\" with code and fire.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -57,6 +57,7 @@
57
57
  "semver": "^7.1.3",
58
58
  "slugify": "^1.4.0",
59
59
  "socket.io-client": "^4.5.2",
60
+ "standard-version": "^9.5.0",
60
61
  "temp-dir": "^2.0.0",
61
62
  "tmp": "^0.1.0",
62
63
  "tough-cookie": "^3.0.1",
@@ -11,11 +11,12 @@ const TrackingEitriAnalytics = require('../service/TrackingEitriAnalytics')
11
11
  const UserLocalCredential = require('../util/UserLocalCredential')
12
12
  const VegvisirService = require('../modules/vegvisir/VegvisirService')
13
13
  const {randomUUID} = require('crypto')
14
-
14
+ const childProcess = require('child_process')
15
15
  const blindGuardian = workspace.blindGuardian
16
16
  const trackingService = new TrackingService(blindGuardian)
17
17
  const targetService = new TargetService(workspace)
18
18
  const vegvisirService = new VegvisirService()
19
+ const standardVersion = require('standard-version')
19
20
 
20
21
  module.exports = async function pushVersion(cmdObj) {
21
22
  try {
@@ -40,6 +41,24 @@ module.exports = async function pushVersion(cmdObj) {
40
41
  workspace.publishing = true
41
42
  const miniConf = workspace.getMiniConf()
42
43
 
44
+ if (cmdObj?.release) {
45
+ try {
46
+ await releaseGenerator(cmdObj)
47
+ const lastTag = childProcess.execSync('git describe --tags --abbrev=0').toString().trim();
48
+ const newVersion = lastTag?.replace(/^v/, "");
49
+
50
+ miniConf.version = newVersion
51
+ const newMiniConf = {
52
+ ...miniConf,
53
+ version: newVersion
54
+ }
55
+ workspace.setMiniConf(newMiniConf)
56
+ console.log(`Versão [${newVersion}] atualizada no eitri-app.conf.js`)
57
+ } catch (error) {
58
+ console.error("Erro ao gerar a nova versão: ", error?.message)
59
+ }
60
+ }
61
+
43
62
  let validateResult = checkErros(miniConf)
44
63
 
45
64
  if (!validateResult.isSuccess()) {
@@ -85,9 +104,8 @@ ${await targetService.getAppConfExampleSnippet()}
85
104
  const tempWorkspaceId = randomUUID()
86
105
  vegvisirService.setWorkspaceId(tempWorkspaceId)
87
106
  await workspace.initPushVersion(tempWorkspaceId)
88
- const userWorkspace = await vegvisirService.getWorkspace()
89
107
 
90
- await miniLog.connect(userWorkspace.id)
108
+ await miniLog.connect(tempWorkspaceId)
91
109
  console.log(separator)
92
110
  console.log("Analisando versões...");
93
111
 
@@ -195,3 +213,22 @@ async function logPermissionsAndOpenPrompt(addedPermissions, removedPermissions,
195
213
  }
196
214
  }
197
215
  }
216
+
217
+
218
+ async function releaseGenerator(cmdObj) {
219
+ return new Promise((resolve, reject) => {
220
+ standardVersion({
221
+ noVerify: true,
222
+ silent: true,
223
+ }).then(() => {
224
+ resolve()
225
+ }).catch(err => {
226
+ if (cmdObj?.verbose) {
227
+ console.error(`standard-version failed with message: ${err?.message}`)
228
+ }
229
+ const errorMessage = "Ocorreu um erro ao gerar a versão. Por favor, verifique se a versão foi gerada no Console."
230
+ reject(errorMessage)
231
+ })
232
+
233
+ })
234
+ }
@@ -189,22 +189,41 @@ class Workspace {
189
189
  setMiniConf(miniConf) {
190
190
  this._miniConf = miniConf;
191
191
  return new Promise((resolve, reject) => {
192
- const miniAppConfPath = path.resolve(
192
+ const eitriAppConfPath = path.resolve(
193
193
  this.folder2watch,
194
- "../miniapp.conf.js"
194
+ "../eitri-app.conf.js"
195
195
  );
196
- const jsonContent = JSON.stringify(miniConf, null, 4);
197
- fs.writeFile(
198
- miniAppConfPath,
199
- `module.exports = ${jsonContent}`,
200
- (err) => {
201
- if (err) {
202
- console.log(err);
203
- return reject(err);
196
+ if (fs.existsSync(eitriAppConfPath)) {
197
+ const jsonContent = JSON.stringify(miniConf, null, 4);
198
+ fs.writeFile(
199
+ eitriAppConfPath,
200
+ `module.exports = ${jsonContent}`,
201
+ (err) => {
202
+ if (err) {
203
+ console.log(err);
204
+ return reject(err);
205
+ }
206
+ resolve();
204
207
  }
205
- resolve();
206
- }
207
- );
208
+ );
209
+ } else {
210
+ const miniAppConfPath = path.resolve(
211
+ this.folder2watch,
212
+ "../miniapp.conf.js"
213
+ );
214
+ const jsonContent = JSON.stringify(miniConf, null, 4);
215
+ fs.writeFile(
216
+ miniAppConfPath,
217
+ `module.exports = ${jsonContent}`,
218
+ (err) => {
219
+ if (err) {
220
+ console.log(err);
221
+ return reject(err);
222
+ }
223
+ resolve();
224
+ }
225
+ );
226
+ }
208
227
  });
209
228
  }
210
229
 
@@ -117,7 +117,7 @@ describe("eitri-cli", () => {
117
117
  inputPassword.type(String(loginVars.EITRI_TEST_LOGIN_PASSWORD));
118
118
 
119
119
  const buttonElement = await page.waitForXPath(
120
- "/html/body/div/div/div[2]/div[2]/div/div/div/form/div/button"
120
+ '//*[@id="root"]/div/div/div[2]/div/div/div/form/div/button'
121
121
  );
122
122
  console.log("Clicando no botão");
123
123
  buttonElement.click();