Skip to content

Commit

Permalink
Create setup.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Nov 20, 2024
1 parent bf39981 commit 0740817
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions scripts/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// setup.js
const fs = require('fs');
const path = require('path');
const inquirer = require('inquirer');

/**
* Set up the project by creating necessary directories and files.
*/
async function setup() {
try {
// Create the necessary directories
const dirsToCreate = ['src', 'public', 'deployments'];
dirsToCreate.forEach((dir) => {
fs.mkdirSync(path.join(__dirname, `../${dir}`), { recursive: true });
});

// Create the necessary files
const filesToCreate = ['index.html', 'styles.css', 'script.js'];
filesToCreate.forEach((file) => {
fs.writeFileSync(path.join(__dirname, `../${file}`), '');
});

// Prompt the user for project information
const answers = await inquirer.prompt([
{
type: 'input',
name: 'projectName',
message: 'What is the name of your project?',
},
{
type: 'input',
name: 'projectDescription',
message: 'What is the description of your project?',
},
]);

// Create a package.json file with the project information
const packageJson = {
name: answers.projectName,
description: answers.projectDescription,
version: '1.0.0',
scripts: {
start: 'node script.js',
},
};
fs.writeFileSync(path.join(__dirname, '../package.json'), JSON.stringify(packageJson, null, 2));

console.log('Project setup complete!');
} catch (error) {
console.error('Error setting up project:', error);
}
}

module.exports = setup;

0 comments on commit 0740817

Please sign in to comment.