refactor: consolidate CLI entry points into dedicated cli/ directory

Move `database` and `setup` CLI scripts from their respective feature
directories into a unified `src/cli/` directory. Update `tsup.config.js`
build entries and `package.json` bin paths to reflect the new locations.
This commit is contained in:
2026-04-12 14:39:17 -04:00
parent 54c4ad058d
commit 390133808b
4 changed files with 16 additions and 18 deletions
+2 -2
View File
@@ -23,8 +23,8 @@
"prepublishOnly": "npm run build"
},
"bin": {
"zen-db": "./dist/core/database/cli.js",
"zen-setup": "./dist/features/setup/cli.js"
"zen-db": "./dist/cli/database.js",
"zen-setup": "./dist/cli/setup.js"
},
"dependencies": {
"@headlessui/react": "^2.0.0",
@@ -16,7 +16,7 @@ dotenv.config({ path: resolve(process.cwd(), '.env.local') });
// The CLI always runs locally, so default to development to use ZEN_DATABASE_URL_DEV if set
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
import { initDatabase, dropAuthTables, testConnection, closePool } from './index.js';
import { initDatabase, dropAuthTables, testConnection, closePool } from '../core/database/index.js';
import readline from 'readline';
async function runCLI() {
@@ -63,13 +63,12 @@ Example:
case 'drop':
console.log('⚠️ WARNING: This will delete all authentication tables!\n');
console.log('Type "yes" to confirm or Ctrl+C to cancel...');
// Simple confirmation (in production, you'd use a proper readline)
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Confirm (yes/no): ', async (answer) => {
if (answer.toLowerCase() === 'yes') {
await dropAuthTables();
@@ -124,4 +123,3 @@ if (isMainModule) {
}
export { runCLI };
@@ -90,7 +90,7 @@ const files = [
async function createFile(filePath, content, force = false) {
const fullPath = resolve(process.cwd(), filePath);
// Check if file already exists
if (existsSync(fullPath) && !force) {
console.log(`⏭️ Skipped (already exists): ${filePath}`);
@@ -104,13 +104,13 @@ async function createFile(filePath, content, force = false) {
// Write the file
await writeFile(fullPath, content, 'utf-8');
console.log(`✅ Created: ${filePath}`);
return { created: true, skipped: false };
}
async function setupZen(options = {}) {
const { force = false } = options;
console.log('🚀 Setting up Zen for your Next.js project...\n');
let created = 0;
@@ -122,7 +122,7 @@ async function setupZen(options = {}) {
templates[file.template],
force
);
if (result.created) created++;
if (result.skipped) skipped++;
}
@@ -134,7 +134,7 @@ async function setupZen(options = {}) {
// Check if next.config.js needs updating
const nextConfigPath = resolve(process.cwd(), 'next.config.js');
const nextConfigExists = existsSync(nextConfigPath);
if (!nextConfigExists) {
console.log('\n⚠️ Note: next.config.js not found.');
console.log(' Make sure to enable instrumentation in your Next.js config:');
@@ -153,14 +153,14 @@ async function setupZen(options = {}) {
async function listFiles() {
console.log('📋 Files that will be created:\n');
for (const file of files) {
const exists = existsSync(resolve(process.cwd(), file.path));
const status = exists ? '✓ exists' : '✗ missing';
console.log(` ${status} ${file.path}`);
console.log(` ${file.description}`);
}
console.log('\nRun "npx zen-setup init" to create missing files.');
}
@@ -198,12 +198,12 @@ Examples:
if (force) {
console.log('⚠️ WARNING: --force flag will overwrite existing files!\n');
console.log('Type "yes" to confirm or Ctrl+C to cancel...');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question('Confirm (yes/no): ', async (answer) => {
if (answer.toLowerCase() === 'yes') {
await setupZen({ force: true });
+2 -2
View File
@@ -16,9 +16,9 @@ export default defineConfig([
'src/core/api/index.js',
'src/core/api/nx-route.js',
'src/core/database/index.js',
'src/core/database/cli.js',
'src/features/setup/index.js',
'src/features/setup/cli.js',
'src/cli/database.js',
'src/cli/setup.js',
'src/core/email/index.js',
'src/core/email/templates/index.js',
'src/core/storage/index.js',