diff --git a/README.md b/README.md index ecdbe58..4a78c67 100644 --- a/README.md +++ b/README.md @@ -13,24 +13,28 @@ npm create astro-starter@latest - ✅ Tailwind CSS - ✅ Alpine js +- ✅ Typescript +- ✅ Localization (with astro-i18n-aut) - ✅ Dark/light mode - ✅ Blog - ✅ Discussions (thanks to giscus) - ✅ CMS for editing blog post (thanks to decap CMS) +- ✅ Sitemap (localized) +- ✅ RSS (localized) - ❌ PWA (Follow tutorial below to add it) ### 🧞 Commands All commands are run from the root of the project, from a terminal: -| Command | Action | -| :------------------------- | :----------------------------------------------- | -| `pnpm install` | Installs dependencies | -| `pnpm run dev` | Starts local dev server at `localhost:4321` | -| `pnpm run build` | Build your production site to `./dist/` | -| `pnpm run preview` | Preview your build locally, before deploying | -| `pnpm run astro ...` | Run CLI commands like `astro add`, `astro check` | -| `pnpm run astro -- --help` | Get help using the Astro CLI | +| Command | Action | +| :--------------------- | :----------------------------------------------- | +| `pnpm install` | Installs dependencies | +| `pnpm dev` | Starts local dev server at `localhost:4321` | +| `pnpm build` | Build your production site to `./dist/` | +| `pnpm preview` | Preview your build locally, before deploying | +| `pnpm astro ...` | Run CLI commands like `astro add`, `astro check` | +| `pnpm astro -- --help` | Get help using the Astro CLI | If you want to switch to npm make sure to remove pnpm-lock.yaml and node_modules folder and then run `npm install` @@ -89,8 +93,5 @@ If you use netlify it's actually easier, you will need to change in the file `as ### 👀 Want to learn more? -Check out [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). +Check out [Astro documentation](https://docs.astro.build) or jump into Astro [Discord server](https://astro.build/chat). -### Credit - -This theme is based off of the lovely [Bear Blog](https://github.com/HermanMartinus/bearblog/). diff --git a/bin/cli.js b/bin/cli.js index 6bc1e7a..20dab89 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -39,45 +39,70 @@ function copyRecursive(src, dest) { } } -rl.question('Where would you like to create the new project? (Provide a directory path, use "." for current directory)', (destination) => { - rl.question("Do you want to install the packages now? (y/n) ", (answer) => { - try { - if (!fs.existsSync(destination)) { - fs.mkdirSync(destination, { recursive: true }); - } +function getGitAuthorName() { + try { + const name = execSync("git config user.name", { encoding: "utf8" }).trim(); + return name; + } catch (error) { + console.warn("Failed to get git user name:", error.message); + return "your name"; // or a default value + } +} - // Initialize the package with npm - execSync(`cd ${destination} && npm init -y`, { stdio: "inherit" }); +rl.question("How would you like to name your package? ", (packageName) => { + rl.question('Where would you like to create the new project? (Provide a directory path, use "." for current directory)', (destination) => { + rl.question("Do you want to install the packages now? (y/n) ", (answer) => { + try { + if (!fs.existsSync(destination)) { + fs.mkdirSync(destination, { recursive: true }); + } - // Copy all files and subdirectories from the root directory to the destination, excluding the specified ones - copyRecursive(rootDir, destination); + // Copy all files and subdirectories from the root directory to the destination, excluding the specified ones + copyRecursive(rootDir, destination); - console.log(`Project initialized in ${destination}`); + // Update package.json with the new name and author + const packageJsonPath = path.join(destination, "package.json"); + const packageData = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")); + if (packageName) { + packageData.name = packageName; + } + packageData.varsion = "0.0.1"; + packageData.author = getGitAuthorName(); // Set the author from git config + delete packageData.bin; // Remove the bin property from package.json + delete packageData.files; + delete packageData.main; + delete packageData.repository; + delete packageData.homepage; + delete packageData.bugs; + fs.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2)); - // Check user's answer and run pnpm install if confirmed - if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") { - execSync(`cd ${destination} && pnpm install`, { stdio: "inherit" }); - console.log(`Packages installed successfully in ${destination}`); + console.log(`Project initialized in ${destination}`); - rl.question("Do you want to run the project now? (y/n) ", (answer) => { - try { - if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") { - execSync(`cd ${destination} && pnpm dev`, { stdio: "inherit" }); - } else { - console.log(`You can run 'pnpm dev' in ${destination} whenever you're ready.`); + // Check user's answer and run pnpm install if confirmed + if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") { + execSync(`cd ${destination} && pnpm install`, { stdio: "inherit" }); + console.log(`Packages installed successfully in ${destination}`); + + rl.question("Do you want to run the project now? (y/n) ", (answer) => { + try { + if (answer.toLowerCase() === "y" || answer.toLowerCase() === "yes") { + execSync(`cd ${destination} && pnpm dev`, { stdio: "inherit" }); + } else { + console.log(`You can run 'pnpm dev' in ${destination} whenever you're ready.`); + } + } catch (error) { + console.error("Failed to run the project:", error.message); } - } catch (error) { - console.error("Failed to run the project:", error.message); - } + rl.close(); + }); + } else { + console.log(`You can run 'pnpm install' in ${destination} whenever you're ready.`); rl.close(); - }); - } else { - console.log(`You can run 'pnpm install' in ${destination} whenever you're ready.`); + } + } catch (error) { + console.error("Failed to create the project:", error.message); rl.close(); } - } catch (error) { - console.error("Failed to create the project:", error.message); - rl.close(); - } + }); }); });