kawkab-frontend
Version:
Kawkab frontend is a frontend library for the Kawkab framework
20 lines (19 loc) • 774 B
JavaScript
import { generateFile } from '../utils/stub.js';
import path from 'path';
export function makePageCommand(program) {
program
.command('make:page <name> [module]')
.description('Create a new page component in a specific module')
.action((name, module = 'main') => {
const pageDir = path.dirname(name);
const pageBase = path.basename(name);
const pagePath = pageDir === '.' ? `${pageBase}` : `${pageDir}/${pageBase}`;
const targetPath = `app/${module}/${pagePath}/page.tsx`;
const pageName = pageBase.charAt(0).toUpperCase() + pageBase.slice(1);
generateFile('page.stub', targetPath, {
PageName: pageName,
ModuleName: module,
PagePath: name,
});
});
}