create-dylan-app
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -18,28 +18,13 @@ #!/usr/bin/env node | ||
// where this script lives at (e.g /bin/index.js) | ||
// Where this script lives at (e.g /bin/index.js) | ||
const __dirname = fileURLToPath(new URL('.', import.meta.url)); | ||
// where this script is being called from | ||
// Where this script is being called from | ||
const cwd = process.cwd(); | ||
const configs = { | ||
javascript: { | ||
contentPath: resolve(__dirname, '../content/javascript'), | ||
dependencies: { | ||
save: ['react@18', 'react-dom@18'], | ||
saveDev: ['vite@4', '@vitejs/plugin-react@4'], | ||
}, | ||
const baseConfig = { | ||
contentPath: resolve(__dirname, '../content/javascript'), | ||
dependencies: { | ||
save: ['react@18', 'react-dom@18'], | ||
saveDev: ['vite@4', '@vitejs/plugin-react@4'], | ||
}, | ||
typescript: { | ||
contentPath: resolve(__dirname, '../content/typescript'), | ||
dependencies: { | ||
save: ['react@18', 'react-dom@18'], | ||
saveDev: [ | ||
'vite@4', | ||
'@vitejs/plugin-react@4', | ||
'@types/react@18', | ||
'@types/react-dom@18', | ||
'@types/node@18', | ||
], | ||
}, | ||
}, | ||
}; | ||
@@ -79,3 +64,3 @@ | ||
const path = resolve(cwd, value); | ||
// check if a directory with the same name exists | ||
// Check if a directory with the same name exists | ||
if (existsSync(path) && !isDirectoryEmpty(path)) { | ||
@@ -89,9 +74,2 @@ return `Cannot use name "${value}"; this directory already exists and is not empty`; | ||
{ | ||
type: 'confirm', | ||
name: 'useTypeScript', | ||
message: 'Do you want to use TypeScript?', | ||
default: false, | ||
transformer: (answer) => (answer ? 'Yes' : 'No'), | ||
}, | ||
{ | ||
type: 'list', | ||
@@ -105,3 +83,3 @@ name: 'styleLibrary', | ||
async function main() { | ||
// log create-dylan-app letters | ||
// Log create-dylan-app letters | ||
[ | ||
@@ -118,3 +96,3 @@ ' ___ ___ ___ ', | ||
// start the prompt | ||
// Start the prompt | ||
const answers = await inquirer.prompt(questions); | ||
@@ -129,3 +107,3 @@ | ||
// create the project directory if needed | ||
// Create the project directory if needed | ||
if (!existsSync(projectPaths.root)) { | ||
@@ -135,10 +113,10 @@ mkdirSync(projectPaths.root); | ||
// copy common folder | ||
await extra.copy(resolve(__dirname, '../content/common'), projectPaths.root); | ||
// Copy the base folder | ||
await extra.copy(resolve(__dirname, '../content/base'), projectPaths.root); | ||
// read and update the package name | ||
// Read and update the package name | ||
const packageJSON = JSON.parse(readFileSync(projectPaths.package, 'utf-8')); | ||
packageJSON.name = answers.name; | ||
// write the updated package | ||
// Write the updated package | ||
writeFileSync( | ||
@@ -149,11 +127,6 @@ projectPaths.package, | ||
// main setup | ||
const isTypeScript = answers.useTypeScript === 'Yes'; | ||
const config = isTypeScript ? configs.typescript : configs.javascript; | ||
// Get style config | ||
const styleConfig = styleConfigs[answers.styleLibrary]; | ||
// copy main content | ||
await extra.copy(config.contentPath, projectPaths.root); | ||
// copy style content if any | ||
// Copy style content if any | ||
if (styleConfig.contentPath) { | ||
@@ -165,10 +138,10 @@ await extra.copy(styleConfig.contentPath, projectPaths.root); | ||
// change directory to the project | ||
// Change directory to the project | ||
process.chdir(projectPaths.root); | ||
// install dependencies | ||
install(config.dependencies.save); | ||
install(config.dependencies.saveDev, { isDev: true }); | ||
// Install dependencies | ||
install(baseConfig.dependencies.save); | ||
install(baseConfig.dependencies.saveDev, { isDev: true }); | ||
// install style dependencies if any | ||
// Install style dependencies if any | ||
if (styleConfig.dependencies) { | ||
@@ -175,0 +148,0 @@ install(styleConfig.dependencies.saveDev, { isDev: true }); |
{ | ||
"name": "create-dylan-app", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
# Create Dylan App | ||
An easy way to scaffold React projects using Vite as a build tool | ||
A quick way to spin-up React projects using Vite as a build tool | ||
![gif](https://github.com/dtgreene/create-dylan-app/assets/24302976/2ac636ba-a7fa-435b-8fbd-370528f9a40a) |
7364
11
173