Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions celtix-cli/bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

const { program } = require('commander');
const createCommand = require('../commands/create');

// Define the main program
program
.version('1.0.0')
.description('A CLI tool for creating project structures');

// Define the 'create' command
program
.command('create <project-name>')
.description('Create a new project from a template')
.action(createCommand);

// Parse the arguments from the command line
program.parse(process.argv);
51 changes: 51 additions & 0 deletions celtix-cli/commands/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const fs = require('fs-extra');
const path = require('path');
const chalk = require('chalk');
const inquirer = require('inquirer');

async function createProject(projectName) {
const targetDir = path.join(process.cwd(), projectName);

// Check if the directory already exists
if (fs.existsSync(targetDir)) {
const { overwrite } = await inquirer.prompt([
{
type: 'confirm',
name: 'overwrite',
message: chalk.yellow(`Directory "${projectName}" already exists. Overwrite?`),
default: false,
},
]);

if (!overwrite) {
console.log(chalk.red('Operation cancelled.'));
return;
}
console.log(chalk.yellow(`Overwriting directory: ${targetDir}...`));
await fs.remove(targetDir);
}

// Create the project directory
await fs.mkdir(targetDir);

// Define the source of the template
const templateDir = path.join(__dirname, '..', 'templates', 'default-backend');

try {
// Copy the template files to the new project directory
await fs.copy(templateDir, targetDir);

console.log(chalk.green('\n✅ Project created successfully!'));
console.log(chalk.cyan('Next steps:'));
console.log(chalk.gray(` 1. cd ${projectName}`));
console.log(chalk.gray(' 2. npm install'));
console.log(chalk.gray(' 3. cp .env.example .env (and edit it)'));
console.log(chalk.gray(' 4. npm start\n'));
} catch (error) {
console.error(chalk.red('Error creating project:', error));
// Clean up created directory on failure
await fs.remove(targetDir);
}
}

module.exports = createProject;
2 changes: 2 additions & 0 deletions celtix-cli/commands/templates/ default-backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT=8080
MESSAGE="Hello from Celtrix!"
13 changes: 13 additions & 0 deletions celtix-cli/commands/templates/ default-backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "new-celtrix-app",
"version": "1.0.0",
"description": "A backend project generated by Celtrix CLI.",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js"
},
"dependencies": {
"express": "^4.19.2",
"dotenv": "^16.4.5"
}
}
13 changes: 13 additions & 0 deletions celtix-cli/commands/templates/ default-backend/src/index,js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require('dotenv').config();
const express = require('express');

const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
res.send(process.env.MESSAGE || 'Hello, World!');
});

app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
1 change: 1 addition & 0 deletions celtix-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//raunak
import inquirer from "inquirer";
import chalk from "chalk";
import gradient from "gradient-string";
Expand Down
71 changes: 17 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,25 @@
{
"name": "celtrix",
"version": "2.0.4",
"description": "CLI to create MERN apps quickly",
"type": "module",
"main": "./bin/celtrix.js",

{
"name": "celtrix-cli",
"version": "1.0.0",
"description": "A CLI tool to scaffold new projects.",
"main": "index.js",
"bin": {
"celtrix": "./bin/celtrix.js"
"celtrix": "bin/index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"files": [
"bin/",
"index.js",
"commands/",
"utils/",
"templates/"
],
"keywords": [
"mern",
"cli",
"react",
"express",
"mongodb",
"fullstack"
"scaffolding"
],
"author": "Joe Celaster",
"license": "ISC",
"author": "Your Name",
"license": "MIT",
"dependencies": {
"@octokit/rest": "^22.0.0",
"@pinecone-database/pinecone": "^6.1.2",
"boxen": "^8.0.1",
"chalk": "^5.6.0",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"figlet": "^1.8.2",
"fs-extra": "^11.3.1",
"gradient-string": "^3.0.0",
"inquirer": "^12.9.4",
"log-symbols": "^7.0.1",
"node-fetch": "^3.3.2",
"ora": "^8.2.0"
},
"scripts": {
"release:patch": "npm version patch && npm publish --access public",
"release:minor": "npm version minor && npm publish --access public",
"release:major": "npm version major && npm publish --access public",
"validate": "node scripts/validate-apis.js",
"validate:pinecone": "node scripts/validate-apis.js pinecone",
"validate:github": "node scripts/validate-apis.js github",
"validate:gemini": "node scripts/validate-apis.js gemini",
"populate-issues": "node scripts/populate-existing-issues.js",
"cleanup-issue": "node scripts/cleanup-closed-issue.js",
"cleanup-specific": "node scripts/cleanup-specific-issue.js",
"cleanup-duplicates": "node scripts/cleanup-duplicates.js --force",
"debug-db": "node scripts/debug-pinecone.js",
"clear-all": "echo '⚠️ Use: npm run clear-all:force' && exit 1",
"clear-all:force": "node scripts/clear-all-vectors.js --force",
"check-duplicates": "node scripts/check-duplicates.js"
},
"devDependencies": {
"typescript": "^5.9.3"
"chalk": "^4.1.2",
"commander": "^12.1.0",
"fs-extra": "^11.2.0",
"inquirer": "^8.2.4"
}
}