bbk-cli 1.1.2 → 1.2.0
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +113 -132
- package/dist/cli/wrapper.d.ts +0 -1
- package/dist/cli/wrapper.d.ts.map +1 -1
- package/dist/cli/wrapper.js +19 -54
- package/dist/cli/wrapper.js.map +1 -1
- package/dist/commands/helpers.js +1 -1
- package/dist/commands/runner.d.ts.map +1 -1
- package/dist/commands/runner.js +22 -18
- package/dist/commands/runner.js.map +1 -1
- package/dist/config/constants.d.ts.map +1 -1
- package/dist/config/constants.js +37 -52
- package/dist/config/constants.js.map +1 -1
- package/dist/utils/arg-parser.d.ts.map +1 -1
- package/dist/utils/arg-parser.js +23 -8
- package/dist/utils/arg-parser.js.map +1 -1
- package/dist/utils/bitbucket-client.d.ts +24 -37
- package/dist/utils/bitbucket-client.d.ts.map +1 -1
- package/dist/utils/bitbucket-client.js +38 -52
- package/dist/utils/bitbucket-client.js.map +1 -1
- package/dist/utils/bitbucket-utils.d.ts +48 -68
- package/dist/utils/bitbucket-utils.d.ts.map +1 -1
- package/dist/utils/bitbucket-utils.js +100 -125
- package/dist/utils/bitbucket-utils.js.map +1 -1
- package/dist/utils/config-loader.d.ts +10 -29
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js +277 -51
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -3
- package/tests/integration/cli-integration.test.ts +96 -217
- package/tests/unit/cli/wrapper.test.ts +28 -137
- package/tests/unit/commands/runner.test.ts +69 -197
- package/tests/unit/utils/arg-parser.test.ts +53 -4
- package/tests/unit/utils/config-loader.test.ts +441 -106
|
@@ -25,6 +25,10 @@ vi.mock('../../../src/config/index.js', () => ({
|
|
|
25
25
|
],
|
|
26
26
|
}));
|
|
27
27
|
|
|
28
|
+
vi.mock('../../../src/utils/config-loader.js', () => ({
|
|
29
|
+
setupConfig: vi.fn(),
|
|
30
|
+
}));
|
|
31
|
+
|
|
28
32
|
describe('arg-parser', () => {
|
|
29
33
|
beforeEach(() => {
|
|
30
34
|
vi.clearAllMocks();
|
|
@@ -303,6 +307,51 @@ describe('arg-parser', () => {
|
|
|
303
307
|
|
|
304
308
|
exitSpy.mockRestore();
|
|
305
309
|
});
|
|
310
|
+
|
|
311
|
+
it('should handle config command and call setupConfig', async () => {
|
|
312
|
+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
313
|
+
throw new Error('process.exit called');
|
|
314
|
+
});
|
|
315
|
+
const { setupConfig } = await import('../../../src/utils/config-loader.js');
|
|
316
|
+
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
317
|
+
|
|
318
|
+
vi.mocked(setupConfig).mockResolvedValue(undefined);
|
|
319
|
+
|
|
320
|
+
try {
|
|
321
|
+
await parseArguments(['config']);
|
|
322
|
+
} catch {
|
|
323
|
+
// Expected - process.exit throws
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
expect(setupConfig).toHaveBeenCalled();
|
|
327
|
+
expect(exitSpy).toHaveBeenCalledWith(0);
|
|
328
|
+
|
|
329
|
+
exitSpy.mockRestore();
|
|
330
|
+
consoleErrorSpy.mockRestore();
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('should handle config command errors and exit with code 1', async () => {
|
|
334
|
+
const exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
335
|
+
throw new Error('process.exit called');
|
|
336
|
+
});
|
|
337
|
+
const { setupConfig } = await import('../../../src/utils/config-loader.js');
|
|
338
|
+
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
339
|
+
|
|
340
|
+
vi.mocked(setupConfig).mockRejectedValue(new Error('Write permission denied'));
|
|
341
|
+
|
|
342
|
+
try {
|
|
343
|
+
await parseArguments(['config']);
|
|
344
|
+
} catch {
|
|
345
|
+
// Expected - process.exit throws
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
expect(setupConfig).toHaveBeenCalled();
|
|
349
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith('Configuration setup failed: Write permission denied');
|
|
350
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
351
|
+
|
|
352
|
+
exitSpy.mockRestore();
|
|
353
|
+
consoleErrorSpy.mockRestore();
|
|
354
|
+
});
|
|
306
355
|
});
|
|
307
356
|
|
|
308
357
|
describe('printGeneralHelp', () => {
|
|
@@ -319,8 +368,8 @@ describe('arg-parser', () => {
|
|
|
319
368
|
}
|
|
320
369
|
|
|
321
370
|
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('Bitbucket CLI'));
|
|
322
|
-
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
323
|
-
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
371
|
+
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('bbk-cli'));
|
|
372
|
+
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('bbk-cli --commands'));
|
|
324
373
|
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('list-repos'));
|
|
325
374
|
|
|
326
375
|
exitSpy.mockRestore();
|
|
@@ -340,8 +389,8 @@ describe('arg-parser', () => {
|
|
|
340
389
|
}
|
|
341
390
|
|
|
342
391
|
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('Examples:'));
|
|
343
|
-
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
344
|
-
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('
|
|
392
|
+
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('bbk-cli list-repositories'));
|
|
393
|
+
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('bbk-cli get-repository'));
|
|
345
394
|
|
|
346
395
|
exitSpy.mockRestore();
|
|
347
396
|
consoleLogSpy.mockRestore();
|