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 12:45:45 +02:00
|
|
|
description: 'Enter your superadmin username/email',
|
2020-09-25 14:02:22 +02:00
|
|
|
name: 'username',
|
|
|
|
|
required: true
|
2020-09-25 11:22:49 +02:00
|
|
|
},
|
|
|
|
|
{
|
2020-09-25 12:45:45 +02:00
|
|
|
description: 'Enter your superadmin password',
|
2020-09-25 11:50:57 +02:00
|
|
|
name: 'password',
|
2020-09-25 14:02:22 +02:00
|
|
|
hidden: true,
|
|
|
|
|
required: true
|
2020-09-25 12:45:45 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
description: 'Enter CMS URL, or leave empty for default(https://localhost:44331)',
|
|
|
|
|
name: 'baseUrl'
|
2020-09-25 11:22:49 +02:00
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
2020-09-25 11:50:57 +02:00
|
|
|
|
|
|
|
|
const configPath = './cypress.env.json'
|
|
|
|
|
|
|
|
|
|
console.log("Configure your test enviroment")
|
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}",
|
2020-09-25 12:45:45 +02:00
|
|
|
"password": "${result.password}"${
|
|
|
|
|
result.baseUrl && `,
|
|
|
|
|
"baseUrl": "${result.baseUrl}"`
|
|
|
|
|
}
|
2020-09-25 11:22:49 +02:00
|
|
|
}`;
|
|
|
|
|
|
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;
|
|
|
|
|
}
|