+30
-9
@@ -45,8 +45,28 @@ impelented are:
|
|||||||
See https://github.com/krgamestudios/MERN-template/wiki for help.
|
See https://github.com/krgamestudios/MERN-template/wiki for help.
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
//determine local computer address for mac user vs everyone else
|
||||||
|
let macQuestion = '';
|
||||||
|
while (macQuestion !== true && macQuestion !== false) {
|
||||||
|
macQuestion = await question('Will the MERN Template be running locally on a MacOS system? (yes or no)', '');
|
||||||
|
if (macQuestion.toLowerCase() === 'yes') {
|
||||||
|
macQuestion = true;
|
||||||
|
}
|
||||||
|
else if (macQuestion.toLowerCase() === 'no') {
|
||||||
|
macQuestion = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//project configuration
|
const macUser = macQuestion;
|
||||||
|
|
||||||
|
let localComputerAddress = '%';
|
||||||
|
if (macUser === true) {
|
||||||
|
localComputerAddress = 'localhost';
|
||||||
|
}
|
||||||
|
|
||||||
|
const localAddress = localComputerAddress;
|
||||||
|
|
||||||
|
//project configuration
|
||||||
const projectName = await question('Project Name', 'template');
|
const projectName = await question('Project Name', 'template');
|
||||||
const projectWebAddress = await question('Project Web Address', 'example.com');
|
const projectWebAddress = await question('Project Web Address', 'example.com');
|
||||||
|
|
||||||
@@ -284,24 +304,25 @@ CMD ["sleep 10 && npm start"]
|
|||||||
|
|
||||||
const sqlfile = `
|
const sqlfile = `
|
||||||
CREATE DATABASE IF NOT EXISTS ${projectName};
|
CREATE DATABASE IF NOT EXISTS ${projectName};
|
||||||
CREATE USER IF NOT EXISTS '${projectDBUser}'@'%' IDENTIFIED BY '${projectDBPass}';
|
CREATE USER IF NOT EXISTS '${projectDBUser}'@'${localAddress}' IDENTIFIED BY '${projectDBPass}';
|
||||||
GRANT ALL PRIVILEGES ON ${projectName}.* TO '${projectDBUser}'@'%';
|
GRANT ALL PRIVILEGES ON ${projectName}.* TO '${projectDBUser}'@'${localAddress}';
|
||||||
|
|
||||||
CREATE DATABASE IF NOT EXISTS ${newsName};
|
CREATE DATABASE IF NOT EXISTS ${newsName};
|
||||||
CREATE USER IF NOT EXISTS '${newsDBUser}'@'%' IDENTIFIED BY '${newsDBPass}';
|
CREATE USER IF NOT EXISTS '${newsDBUser}'@'${localAddress}' IDENTIFIED BY '${newsDBPass}';
|
||||||
GRANT ALL PRIVILEGES ON ${newsName}.* TO '${newsDBUser}'@'%';
|
GRANT ALL PRIVILEGES ON ${newsName}.* TO '${newsDBUser}'@'${localAddress}';
|
||||||
|
|
||||||
CREATE DATABASE IF NOT EXISTS ${authName};
|
CREATE DATABASE IF NOT EXISTS ${authName};
|
||||||
CREATE USER IF NOT EXISTS '${authDBUser}'@'%' IDENTIFIED BY '${authDBPass}';
|
CREATE USER IF NOT EXISTS '${authDBUser}'@'${localAddress}' IDENTIFIED BY '${authDBPass}';
|
||||||
GRANT ALL PRIVILEGES ON ${authName}.* TO '${authDBUser}'@'%';
|
GRANT ALL PRIVILEGES ON ${authName}.* TO '${authDBUser}'@'${localAddress}';
|
||||||
|
|
||||||
CREATE DATABASE IF NOT EXISTS ${chatName};
|
CREATE DATABASE IF NOT EXISTS ${chatName};
|
||||||
CREATE USER IF NOT EXISTS '${chatDBUser}'@'%' IDENTIFIED BY '${chatDBPass}';
|
CREATE USER IF NOT EXISTS '${chatDBUser}'@'${localAddress}' IDENTIFIED BY '${chatDBPass}';
|
||||||
GRANT ALL PRIVILEGES ON ${chatName}.* TO '${chatDBUser}'@'%';
|
GRANT ALL PRIVILEGES ON ${chatName}.* TO '${chatDBUser}'@'${localAddress}';
|
||||||
|
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
fs.writeFileSync('docker-compose.yml', ymlfile);
|
fs.writeFileSync('docker-compose.yml', ymlfile);
|
||||||
fs.writeFileSync('Dockerfile', dockerfile);
|
fs.writeFileSync('Dockerfile', dockerfile);
|
||||||
fs.writeFileSync('startup.sql', sqlfile);
|
fs.writeFileSync('startup.sql', sqlfile);
|
||||||
|
|||||||
Reference in New Issue
Block a user