biz-a-cli 2.3.68 → 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 +15 -3
- package/envs/env.dev.js +1 -1
- package/package.json +1 -1
- package/tests/app.test.js +60 -3
package/bin/app.js
CHANGED
|
@@ -138,8 +138,18 @@ Object
|
|
|
138
138
|
}
|
|
139
139
|
process.chdir(workDir);
|
|
140
140
|
|
|
141
|
-
const child =
|
|
142
|
-
|
|
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
|
+
});
|
|
143
153
|
child.on('close', async code => {
|
|
144
154
|
console.log('====================');
|
|
145
155
|
console.log(output);
|
|
@@ -253,4 +263,6 @@ Object
|
|
|
253
263
|
.strict()
|
|
254
264
|
.parse();
|
|
255
265
|
|
|
256
|
-
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
|
@@ -418,7 +418,11 @@ describe('Biz-A Apps CLI', () => {
|
|
|
418
418
|
|
|
419
419
|
function continueExpect(args) {
|
|
420
420
|
expect(process.cwd()).toBe(absoluteFullTestPath);
|
|
421
|
-
|
|
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
|
+
}
|
|
422
426
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL - 2][0]).toBe('====================');
|
|
423
427
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL - 1][0]).toBe(jestMessage);
|
|
424
428
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL][0]).toBe('====================');
|
|
@@ -427,7 +431,11 @@ describe('Biz-A Apps CLI', () => {
|
|
|
427
431
|
|
|
428
432
|
function abortExpect(args) {
|
|
429
433
|
expect(process.cwd()).toBe(absoluteFullTestPath);
|
|
430
|
-
|
|
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
|
+
}
|
|
431
439
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL][0]).toBe('====================');
|
|
432
440
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL + 1][0]).toBe(jestMessage);
|
|
433
441
|
expect(logSpy.mock.calls[logSpy.mock.calls.length - JEST_MESSAGE_TOTAL + 2][0]).toBe('====================');
|
|
@@ -536,6 +544,51 @@ describe('Biz-A Apps CLI', () => {
|
|
|
536
544
|
|
|
537
545
|
continueExpect(jestArgsWithPassNoTest);
|
|
538
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
|
+
})
|
|
539
592
|
})
|
|
540
593
|
})
|
|
541
594
|
|
|
@@ -643,4 +696,8 @@ describe('Biz-A Apps CLI', () => {
|
|
|
643
696
|
}
|
|
644
697
|
})
|
|
645
698
|
})
|
|
646
|
-
})
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|