mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
feat: add option to wait on resource to e2e script
This commit is contained in:
26
src/cli.ts
26
src/cli.ts
@@ -18,6 +18,7 @@ import {Command} from 'commander';
|
||||
import {readFileSync} from 'fs';
|
||||
import {join} from 'path';
|
||||
import {URL} from 'url';
|
||||
import waitOn from 'wait-on';
|
||||
import {copy} from './copy';
|
||||
import {e2eRun} from './e2e';
|
||||
import {HttpClient} from './http-client';
|
||||
@@ -38,26 +39,35 @@ commander
|
||||
.command('e2e <to>')
|
||||
.description('Run in end to end test mode. Indexing and afterwards retrieving all test files from @openstapp/core to the backend')
|
||||
.option('-s --samples [path]', 'Path to @openstapp/core test files', './node_modules/@openstapps/core/test/resources')
|
||||
.option('-w --waiton [resource]', 'wait-on resource parameter see "www.npmjs.com/wait-on"')
|
||||
.action(async (to, e2eCommand) => {
|
||||
let toURL = '';
|
||||
// validate url
|
||||
try {
|
||||
toURL = (new URL(to)).toString();
|
||||
} catch (err) {
|
||||
await Logger.error('expected parameter "to" to be valid url', err);
|
||||
await Logger.error('expected parameter <to> to be valid url', err);
|
||||
e2eCommand.outputHelp();
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
actionDone = true;
|
||||
|
||||
e2eRun(client, {to: toURL, samplesLocation: e2eCommand.samples})
|
||||
.then(() => {
|
||||
Logger.ok('Done');
|
||||
})
|
||||
.catch(async (reason) => {
|
||||
await Logger.error(reason);
|
||||
});
|
||||
try {
|
||||
if (typeof e2eCommand.waiton === 'string') {
|
||||
Logger.info(`Waiting for availibilty of resource: ${e2eCommand.waiton}`);
|
||||
await waitOn({
|
||||
resources: [e2eCommand.waiton],
|
||||
timeout: 300000,
|
||||
});
|
||||
Logger.info(`Resource became available`);
|
||||
}
|
||||
await e2eRun(client, {to: toURL, samplesLocation: e2eCommand.samples});
|
||||
Logger.ok('Done');
|
||||
|
||||
} catch (error) {
|
||||
await Logger.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
commander
|
||||
|
||||
Reference in New Issue
Block a user