2020-09-25 11:22:49 +02:00
|
|
|
const prompt = require('prompt');
|
2020-09-25 11:50:57 +02:00
|
|
|
const fs = require('fs');
|
2020-09-25 11:22:49 +02:00
|
|
|
|
|
|
|
|
const properties = [
|
|
|
|
|
{
|
2020-09-25 11:50:57 +02:00
|
|
|
name: 'username'
|
2020-09-25 11:22:49 +02:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-25 11:50:57 +02:00
|
|
|
name: 'password',
|
2020-09-25 11:22:49 +02:00
|
|
|
hidden: true
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
2020-09-25 11:50:57 +02:00
|
|
|
|
|
|
|
|
const configPath = './cypress.env.json'
|
|
|
|
|
|
|
|
|
|
console.log("Configure your test enviroment")
|
|
|
|
|
console.log("Enter CMS superadmin credentials:")
|
2020-09-25 11:36:28 +02:00
|
|
|
|
2020-09-25 11:22:49 +02:00
|
|
|
prompt.start();
|
|
|
|
|
|
|
|
|
|
prompt.get(properties, function (error, result) {
|
|
|
|
|
if (error) { return onError(error); }
|
|
|
|
|
|
|
|
|
|
var fileContent = `{
|
|
|
|
|
"username": "${result.username}",
|
|
|
|
|
"password": "${result.password}"
|
|
|
|
|
}`;
|
|
|
|
|
|
2020-09-25 11:50:57 +02:00
|
|
|
fs.writeFile(configPath, fileContent, function (error) {
|
2020-09-25 11:22:49 +02:00
|
|
|
if (error) return console.error(error);
|
2020-09-25 11:36:28 +02:00
|
|
|
console.log('Configuration saved');
|
2020-09-25 11:50:57 +02:00
|
|
|
});
|
2020-09-25 11:22:49 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function onError(error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
return true;
|
|
|
|
|
}
|