biz-a-cli 2.3.67 → 2.3.69
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 +17 -4
- package/envs/env.dev.js +1 -1
- package/package.json +1 -1
- package/tests/app.test.js +65 -3
package/bin/app.js
CHANGED
|
@@ -136,8 +136,20 @@ Object
|
|
|
136
136
|
jestCommand.push('--passWithNoTests')
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
process.chdir(workDir);
|
|
140
|
+
|
|
141
|
+
const child = process.platform === 'win32'
|
|
142
|
+
? spawn('cmd.exe', ['/d', '/s', '/c', 'npx', ...jestCommand])
|
|
143
|
+
: spawn('npx', jestCommand)
|
|
144
|
+
const collectOutput = data => {
|
|
145
|
+
output += data?.toString() || ''
|
|
146
|
+
}
|
|
147
|
+
child.stderr?.on('data', collectOutput)
|
|
148
|
+
child.stdout?.on('data', () => { }) // SCY BZ 4363, ref : https://nodejs.org/download/release/v22.19.0/docs/api/child_process.html
|
|
149
|
+
|
|
150
|
+
child.on('error', e => {
|
|
151
|
+
output += e?.message ? `\n${e.message}` : ''
|
|
152
|
+
});
|
|
141
153
|
child.on('close', async code => {
|
|
142
154
|
console.log('====================');
|
|
143
155
|
console.log(output);
|
|
@@ -149,7 +161,6 @@ Object
|
|
|
149
161
|
if ((code == 0) ||
|
|
150
162
|
((code == 1) && noTestsFound) ||
|
|
151
163
|
((code == 1) && missingJest && passWithNoTests)) {
|
|
152
|
-
process.chdir(workDir)
|
|
153
164
|
await addApp()
|
|
154
165
|
} else {
|
|
155
166
|
console.error('Biz-A Add aborted');
|
|
@@ -252,4 +263,6 @@ Object
|
|
|
252
263
|
.strict()
|
|
253
264
|
.parse();
|
|
254
265
|
|
|
255
|
-
export { options, addCommandOptions, removeCommandOptions }
|
|
266
|
+
export { options, addCommandOptions, removeCommandOptions }
|
|
267
|
+
|
|
268
|
+
|
package/envs/env.dev.js
CHANGED
|
@@ -5,6 +5,6 @@ export const envDev = {
|
|
|
5
5
|
CDM_MONGO_LINK: 'mongodb+srv://imm_cdm:' +
|
|
6
6
|
encodeURIComponent('imm@2019') + '@imm-cdm-dev.rf6wr.mongodb.net/?retryWrites=true&w=majority',
|
|
7
7
|
COMPANY_REGISTER: 'companyregister-dev',
|
|
8
|
-
BIZA_SERVER_LINK: 'https://biz-a
|
|
8
|
+
BIZA_SERVER_LINK: 'https://devserver.biz-a.id',
|
|
9
9
|
BIZA_HUB_SERVER_LINK: 'https://hub.biz-a.id'
|
|
10
10
|
};
|
package/package.json
CHANGED
package/tests/app.test.js
CHANGED
|
@@ -5,6 +5,7 @@ import { finished } from 'node:stream/promises'
|
|
|
5
5
|
import { createDecipheriv } from 'node:crypto'
|
|
6
6
|
import * as tar from "tar"
|
|
7
7
|
import { env } from "../envs/env.js"
|
|
8
|
+
import path from "node:path"
|
|
8
9
|
|
|
9
10
|
describe('Biz-A Apps CLI', () => {
|
|
10
11
|
let originalOptions, originalCWD, axios, child_process;
|
|
@@ -404,6 +405,8 @@ describe('Biz-A Apps CLI', () => {
|
|
|
404
405
|
}
|
|
405
406
|
const appName = 'compressStressTest1';
|
|
406
407
|
const fullTestPath = mockDataFolder + appName;
|
|
408
|
+
const absoluteFullTestPath = path.resolve(fullTestPath);
|
|
409
|
+
|
|
407
410
|
let jestArgs = ['--no-install', 'jest', '--json'];
|
|
408
411
|
let jestArgsWithPassNoTest = jestArgs.slice();
|
|
409
412
|
jestArgsWithPassNoTest.push('--passWithNoTests');
|
|
@@ -414,7 +417,12 @@ describe('Biz-A Apps CLI', () => {
|
|
|
414
417
|
}
|
|
415
418
|
|
|
416
419
|
function continueExpect(args) {
|
|
417
|
-
expect(
|
|
420
|
+
expect(process.cwd()).toBe(absoluteFullTestPath);
|
|
421
|
+
if (process.platform === "win32") {
|
|
422
|
+
expect(child_process.spawn).toBeCalledWith("cmd.exe", ["/d", "/s", "/c", "npx", ...args]);
|
|
423
|
+
} else {
|
|
424
|
+
expect(child_process.spawn).toBeCalledWith("npx", args);
|
|
425
|
+
}
|
|
418
426
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL - 2][0]).toBe('====================');
|
|
419
427
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL - 1][0]).toBe(jestMessage);
|
|
420
428
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL][0]).toBe('====================');
|
|
@@ -422,7 +430,12 @@ describe('Biz-A Apps CLI', () => {
|
|
|
422
430
|
}
|
|
423
431
|
|
|
424
432
|
function abortExpect(args) {
|
|
425
|
-
expect(
|
|
433
|
+
expect(process.cwd()).toBe(absoluteFullTestPath);
|
|
434
|
+
if (process.platform === "win32") {
|
|
435
|
+
expect(child_process.spawn).toBeCalledWith("cmd.exe", ["/d", "/s", "/c", "npx", ...args]);
|
|
436
|
+
} else {
|
|
437
|
+
expect(child_process.spawn).toBeCalledWith("npx", args);
|
|
438
|
+
}
|
|
426
439
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL][0]).toBe('====================');
|
|
427
440
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL + 1][0]).toBe(jestMessage);
|
|
428
441
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL + 2][0]).toBe('====================');
|
|
@@ -531,6 +544,51 @@ describe('Biz-A Apps CLI', () => {
|
|
|
531
544
|
|
|
532
545
|
continueExpect(jestArgsWithPassNoTest);
|
|
533
546
|
})
|
|
547
|
+
|
|
548
|
+
it('Shall continue add biz a template, stdout exists and must be consumed for many unit test outputs', async () => {
|
|
549
|
+
returnedCode = 0;
|
|
550
|
+
const stdoutChunks = Array(300).fill('Passed');
|
|
551
|
+
let stdoutConsumed = false;
|
|
552
|
+
|
|
553
|
+
child_process.spawn.mockImplementationOnce(() => ({
|
|
554
|
+
on: jest.fn((event, callback) => {
|
|
555
|
+
if ((event === 'close') && stdoutConsumed) callback(returnedCode)
|
|
556
|
+
}),
|
|
557
|
+
stderr: {
|
|
558
|
+
on: jest.fn()
|
|
559
|
+
},
|
|
560
|
+
stdout: {
|
|
561
|
+
on: jest.fn((event, callback) => {
|
|
562
|
+
if (event === 'data') {
|
|
563
|
+
stdoutConsumed = true;
|
|
564
|
+
for (const chunk of stdoutChunks) {
|
|
565
|
+
callback(chunk)
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
})
|
|
569
|
+
}
|
|
570
|
+
}))
|
|
571
|
+
|
|
572
|
+
mockValidTemplates(appName, mockScripts);
|
|
573
|
+
fs.mkdirSync(fullTestPath + '/test', { recursive: true })
|
|
574
|
+
fs.writeFileSync(fullTestPath + '/test/a.test.js', `it('dummy test', () => {
|
|
575
|
+
expect(true).toBe(true);
|
|
576
|
+
})`)
|
|
577
|
+
|
|
578
|
+
await runJest();
|
|
579
|
+
|
|
580
|
+
expect(stdoutConsumed).toBe(true);
|
|
581
|
+
expect(process.cwd()).toBe(absoluteFullTestPath);
|
|
582
|
+
if (process.platform === "win32") {
|
|
583
|
+
expect(child_process.spawn).toBeCalledWith("cmd.exe", ["/d", "/s", "/c", "npx", ...jestArgs]);
|
|
584
|
+
} else {
|
|
585
|
+
expect(child_process.spawn).toBeCalledWith("npx", jestArgs);
|
|
586
|
+
}
|
|
587
|
+
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL - 2][0]).toBe('====================');
|
|
588
|
+
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL - 1][0]).toBe('');
|
|
589
|
+
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL][0]).toBe('====================');
|
|
590
|
+
expect(errorSpy.mock.calls.length).toBe(0);
|
|
591
|
+
})
|
|
534
592
|
})
|
|
535
593
|
})
|
|
536
594
|
|
|
@@ -638,4 +696,8 @@ describe('Biz-A Apps CLI', () => {
|
|
|
638
696
|
}
|
|
639
697
|
})
|
|
640
698
|
})
|
|
641
|
-
})
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|