diff --git a/package-lock.json b/package-lock.json index 5cfd0504..2cac1839 100644 --- a/package-lock.json +++ b/package-lock.json @@ -144,6 +144,46 @@ "to-fast-properties": "^2.0.0" } }, + "@hapi/address": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz", + "integrity": "sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ==" + }, + "@hapi/formula": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@hapi/formula/-/formula-1.2.0.tgz", + "integrity": "sha512-UFbtbGPjstz0eWHb+ga/GM3Z9EzqKXFWIbSOFURU0A/Gku0Bky4bCk9/h//K2Xr3IrCfjFNhMm4jyZ5dbCewGA==" + }, + "@hapi/hoek": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.5.1.tgz", + "integrity": "sha512-yN7kbciD87WzLGc5539Tn0sApjyiGHAJgKvG9W8C7O+6c7qmoQMfVs0W4bX17eqz6C78QJqqFrtgdK5EWf6Qow==" + }, + "@hapi/joi": { + "version": "16.1.8", + "resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-16.1.8.tgz", + "integrity": "sha512-wAsVvTPe+FwSrsAurNt5vkg3zo+TblvC5Bb1zMVK6SJzZqw9UrJnexxR+76cpePmtUZKHAPxcQ2Bf7oVHyahhg==", + "requires": { + "@hapi/address": "^2.1.2", + "@hapi/formula": "^1.2.0", + "@hapi/hoek": "^8.2.4", + "@hapi/pinpoint": "^1.0.2", + "@hapi/topo": "^3.1.3" + } + }, + "@hapi/pinpoint": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@hapi/pinpoint/-/pinpoint-1.0.2.tgz", + "integrity": "sha512-dtXC/WkZBfC5vxscazuiJ6iq4j9oNx1SHknmIr8hofarpKUZKmlUVYVIhNVzIEgK5Wrc4GMHL5lZtt1uS2flmQ==" + }, + "@hapi/topo": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.6.tgz", + "integrity": "sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ==", + "requires": { + "@hapi/hoek": "^8.3.0" + } + }, "@krlwlfrt/async-pool": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/@krlwlfrt/async-pool/-/async-pool-0.2.0.tgz", @@ -606,6 +646,11 @@ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.7.tgz", "integrity": "sha512-C2j2FWgQkF1ru12SjZJyMaTPxs/f6n90+5G5qNakBxKXjTBc/YTSelHh4Pz1HUDwxFXD9WvpQhOGCDC+/Y4mIQ==" }, + "@types/wait-on": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/wait-on/-/wait-on-4.0.0.tgz", + "integrity": "sha512-Cj2jcMOzrdvWMP+Vl+qlz942eQfJk96S9kRnB1ejVMl+w9/9mUn0+pF4J+v0Iv+6zCrmBBODZAXKsRo6Y91Cfw==" + }, "@types/yaml": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@types/yaml/-/yaml-1.2.0.tgz", @@ -4188,6 +4233,24 @@ } } }, + "request-promise-core": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.3.tgz", + "integrity": "sha512-QIs2+ArIGQVp5ZYbWD5ZLCY29D5CfWizP8eWnm8FoGD1TX61veauETVQbrV60662V0oFBkrDOuaBI8XgtuyYAQ==", + "requires": { + "lodash": "^4.17.15" + } + }, + "request-promise-native": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.8.tgz", + "integrity": "sha512-dapwLGqkHtwL5AEbfenuzjTYg35Jd6KPytsC2/TLkVMz8rm+tNt72MGUWT1RP/aYawMpN6HqbNGBQaRcBtjQMQ==", + "requires": { + "request-promise-core": "1.1.3", + "stealthy-require": "^1.1.1", + "tough-cookie": "^2.3.3" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -4231,6 +4294,14 @@ "glob": "^7.1.3" } }, + "rxjs": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.4.tgz", + "integrity": "sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==", + "requires": { + "tslib": "^1.9.0" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -4485,6 +4556,11 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, + "stealthy-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", + "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=" + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -4774,8 +4850,7 @@ "tslib": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz", - "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==", - "dev": true + "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==" }, "tslint": { "version": "5.20.1", @@ -5017,6 +5092,26 @@ "extsprintf": "^1.2.0" } }, + "wait-on": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-4.0.0.tgz", + "integrity": "sha512-QrW3J8LzS5ADPfD9Rx5S6KJck66xkqyiFKQs9jmUTkIhiEOmkzU7WRZc+MjsnmkrgjitS2xQ4bb13hnlQnKBUQ==", + "requires": { + "@hapi/joi": "^16.1.8", + "lodash": "^4.17.15", + "minimist": "^1.2.0", + "request": "^2.88.0", + "request-promise-native": "^1.0.8", + "rxjs": "^6.5.4" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/package.json b/package.json index 82fab555..2ac8b872 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@types/request": "2.48.4", "@types/traverse": "0.6.32", "@types/uuid": "3.4.7", + "@types/wait-on": "4.0.0", "cli-progress": "3.6.0", "commander": "4.1.1", "express": "4.17.1", @@ -36,7 +37,8 @@ "morgan": "1.9.1", "request": "2.88.2", "traverse": "0.6.6", - "uuid": "3.4.0" + "uuid": "3.4.0", + "wait-on": "4.0.0" }, "license": "GPL-3.0-only", "devDependencies": { @@ -69,7 +71,7 @@ "Anselm Stordeur ", "Jovan Krunić ", "Michel Jonathan Schmitz", - "Rainer Killinger", + "Rainer Killinger ", "Roman Klopsch", "Wieland Schöbl " ], diff --git a/src/cli.ts b/src/cli.ts index 3120144c..922efdf3 100755 --- a/src/cli.ts +++ b/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 ') .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 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