alfresco-content-app/scripts/app-config-replace.js
Maurizio Vitale 9b0c31073a
ACA Run the test against the remote env (#1669)
* Run the test against the remote env

* Use remote user

* exclude e2e and raise issue

* Exlude more

* small change to trigger travis

* add api method to get totalItems of various endpoints

* lint fix

* remove tests from excluded to see what fails

* - fix some issues with the screenshot plugin
- add methods to get total items for some endpoints
- fix some waitForApi calls to consider initial total items number
- sortByModified descending in order to find the item needed by the test when having items on multiple pages

* Try to fix screenshots

* a few more fixes

* Upload screenshots

* a few more fixes

* Delete e2e-output-${retry} at the end

* delete unused variable

* some changes

* lint

* try one more fix

* Try to fix retry

* a few more fixes

* Try to fix retry

* some more fixes

* Fix "on Recent Files" suite

* Move "on Search Results" at the beginning of the class in order to avoid waitForApi:catch

* Empty commit

* Empty commit

* Empty commit

* Run e2e with lite-server

* Exclude protractor report folder

* Remove useless config

* change browser size

* no message

* one more try

* Empty commit

* try to maximize

* fix upload Recent files tests

* revert maximizing the browser

* don't "Run e2e with lite-server"

* fix mark-favorite tests

* few more fixes

* fix viewer and share tests

* test the lite server with retry

* Verify suites with lite server

* some final fixes

* Try to use httpserver

* Print the file and use http server

* Use http-server to fix protractor retry

* more fixes

* forgot a space :|

* remove extra job not needed anymore
rename test data into more specific

* play with the screenshots

* try new run

* trigger one more run

* a few more little fixes

* Fix comments

* Remove comment

* Fix lint error

Co-authored-by: Adina Parpalita <Adina.Parpalita@ness.com>
Co-authored-by: Cristina Jalba <cristina.jalba@ness.com>
Co-authored-by: iuliaib <iulia.burca@ness.com>
2020-09-18 12:01:55 +01:00

78 lines
2.5 KiB
JavaScript
Executable File

#!/usr/bin/env node
const program = require('commander');
require('dotenv').config({ path: process.env.ENV_FILE });
const fs = require('fs');
const API_HOST = process.env.API_HOST || null;
const API_CONTENT_HOST = process.env.API_CONTENT_HOST || API_HOST;
const API_PROCESS_HOST = process.env.API_PROCESS_HOST || API_HOST;
const API_AOS_HOST = process.env.API_AOS_HOST || API_HOST;
const OAUTH_HOST = process.env.OAUTH_HOST || 'oauth-host-default-replaced-value';
const IDENTITY_HOST = process.env.IDENTITY_HOST || 'identity-host-default-replaced-value';
const NOTIFICATION_LAST = parseInt(process.env.NOTIFICATION_LAST, 10) || 2000;
const options = {
apiHost: {
flags: '-a, --api-host',
description:
'set apiHost=API_HOST, bpmHost=API_PROCESS_HOST, ecmHost=API_CONTENT_HOST, aosHost = API_AOS_HOST if present or fall back to API_HOST in each case',
set: (appConfig) => {
appConfig.apiHost = API_HOST;
appConfig.bpmHost = API_PROCESS_HOST;
appConfig.ecmHost = API_CONTENT_HOST;
appConfig.baseShareUrl = API_CONTENT_HOST + '/#/preview/s';
appConfig.aosHost = API_AOS_HOST;
}
},
indentityHost: {
flags: '-i, --indentity-host',
description: "set identityHost's value with IDENTITY_HOST",
set: (appConfig) => {
appConfig.authType = 'OAUTH';
appConfig.identityHost = IDENTITY_HOST;
}
},
oauthHost: {
flags: '-o, --oauth-host',
description: "set oauth2.host's value with OAUTH_HOST",
set: (appConfig) => {
appConfig.authType = 'OAUTH';
appConfig.oauth2.host = OAUTH_HOST;
}
},
notification: {
flags: '-n, --notification',
description: "set notificationDefaultDuration's value with <duration> and switch on showNotificationHistory",
set: (appConfig) => {
appConfig.showNotificationHistory = true;
appConfig.notificationDefaultDuration = NOTIFICATION_LAST;
}
}
};
program.version('0.0.1').requiredOption('-c, --config <path>', 'path to the app.config.json to reset its values with env vars');
Object.keys(options).forEach((option) => {
program.option(options[option].flags, options[option].description);
});
program.parse(process.argv);
fs.readFile(program.config, (err, appConfigString) => {
if (err) {
throw err;
}
const appConfig = JSON.parse(appConfigString);
Object.keys(options).forEach((option) => {
if (program[option]) {
options[option].set(appConfig);
}
});
const appConfigReplacedJson = JSON.stringify(appConfig, null, 4);
fs.writeFileSync(program.config, appConfigReplacedJson);
});