biz-a-cli 2.3.26 → 2.3.28

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/bin/app.js CHANGED
@@ -312,7 +312,7 @@ yargs(process.argv.slice(2))
312
312
  })()
313
313
  }
314
314
  )
315
- .command('$0', 'the default command', () => {}, () => {
316
- console.error('Command not found. Please make sure the commands use all lowercase letters.')
317
- })
315
+ .recommendCommands()
316
+ .demandCommand(1, 'You need at least one command before moving on')
317
+ .strict()
318
318
  .parse();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "biz-a-cli",
3
3
  "nameDev": "biz-a-cli-dev",
4
- "version": "2.3.26",
4
+ "version": "2.3.28",
5
5
  "versionDev": "0.0.30",
6
6
  "description": "",
7
7
  "main": "bin/index.js",
package/readme.md CHANGED
@@ -23,7 +23,7 @@
23
23
  BizA add -s [Domain] -i [dbindex] -d [full or relative path to app folder]
24
24
 
25
25
  Example:
26
- BizA add-s https://my.domain.com -i 2 -d “c:\biza templates\imamatek”
26
+ BizA add -s https://my.domain.com -i 2 -d “c:\biza templates\imamatek”
27
27
 
28
28
  > [!TIP]
29
29
  > BizA add --help
package/tests/app.test.js CHANGED
@@ -4,6 +4,7 @@ import { Duplex } from 'node:stream'
4
4
  import { finished } from 'node:stream/promises'
5
5
  import { createDecipheriv } from 'node:crypto'
6
6
  import * as tar from "tar"
7
+ import { env } from "../envs/env.js"
7
8
 
8
9
  describe('Biz-A Apps CLI', ()=>{
9
10
 
@@ -162,7 +163,7 @@ describe('Biz-A Apps CLI', ()=>{
162
163
  expect(axios.get.mock.calls).toHaveLength(1)
163
164
  const getArgs = axios.get.mock.calls[0]
164
165
  expect(getArgs).toHaveLength(2)
165
- expect(getArgs[0]).toBe('http://localhost:3000/api/issuerKey')
166
+ expect(getArgs[0]).toBe(`${env.BIZA_SERVER_LINK}/api/issuerKey`)
166
167
  expect(getArgs[1]).toHaveProperty('params')
167
168
  const params = getArgs[1].params
168
169
  expect(params).toHaveProperty('data')
@@ -333,7 +334,7 @@ describe('Biz-A Apps CLI', ()=>{
333
334
  expectedFn()
334
335
  })
335
336
 
336
- it.only('Shall not allow empty app', async ()=>{
337
+ it('Shall not allow empty app', async ()=>{
337
338
  mockValidTemplates({})
338
339
  mockIssuerKeyResponse()
339
340
  await runCommand('add', '-s', 'https://a.b.c', '-p', '1205', '-i', '2', '-d', appFolderName, "-v")
@@ -344,17 +345,29 @@ describe('Biz-A Apps CLI', ()=>{
344
345
  expect(errorSpy.mock.calls[0][0]).toBe('Nothing to upload. Please recheck your app folder.')
345
346
  })
346
347
 
347
- it.only('Shall use lowercase letters for commands', async ()=>{
348
- mockValidTemplates({})
349
- mockIssuerKeyResponse()
348
+ it('Shall recommend command', async ()=>{
349
+ const exitSpy = jest.spyOn(process, 'exit').mockImplementation(()=>{})
350
350
  await runCommand('Add', '-s', 'https://a.b.c', '-p', '1205', '-i', '2', '-d', appFolderName, "-v")
351
-
352
351
  expect(logSpy.mock.calls.length).toBe(0)
352
+ expect(exitSpy).toHaveBeenCalledWith(1) // exit code = 1
353
+ expect(errorSpy.mock.calls[errorSpy.mock.calls.length-1][0]).toBe('Did you mean add?')
354
+ })
353
355
 
354
- expect(errorSpy.mock.calls.length).toBe(1)
355
- expect(errorSpy.mock.calls[0][0]).toBe('Command not found. Please make sure the commands use all lowercase letters.')
356
+ it('Shall have minimun one command', async ()=>{
357
+ const exitSpy = jest.spyOn(process, 'exit').mockImplementation()
358
+ await runCommand('-s', 'https://a.b.c', '-i', 2)
359
+ expect(logSpy.mock.calls.length).toBe(0)
360
+ expect(exitSpy).toHaveBeenCalledWith(1)
361
+ expect(errorSpy.mock.calls[errorSpy.mock.calls.length-1][0]).toBe('You need at least one command before moving on')
356
362
  })
357
363
 
364
+ it('Shall use strict command and options', async ()=>{
365
+ const exitSpy = jest.spyOn(process, 'exit').mockImplementation()
366
+ await runCommand('Unknown Command', '-s', 'https://a.b.c', '-i', 2)
367
+ expect(logSpy.mock.calls.length).toBe(0)
368
+ expect(exitSpy).toHaveBeenCalledWith(1)
369
+ expect(errorSpy.mock.calls[errorSpy.mock.calls.length-1][0]).toBe('Unknown argument: Unknown Command')
370
+ })
358
371
  })
359
372
 
360
373
  describe('Remove App', ()=>{