create-next-pro-cli 0.1.13 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/create-next-pro-completion.sh +9 -1
- package/dist/{bin.js → bin.bun.js} +124 -9
- package/dist/bin.node.js +681 -0
- package/dist/bin.node.js.map +1 -0
- package/dist/create-next-pro +9 -0
- package/package.json +27 -9
- package/templates/Projects/default/README.md +36 -0
- package/.github/workflows/ci.yml +0 -38
- package/bin.ts +0 -3
- package/commitlint.config.cjs +0 -12
- package/install.sh +0 -73
- package/src/index.ts +0 -67
- package/src/lib/addComponent.ts +0 -139
- package/src/lib/addPage.ts +0 -201
- package/src/lib/createProject.ts +0 -18
- package/src/lib/createProjectWithPrompt.ts +0 -79
- package/src/lib/rmPage.ts +0 -52
- package/src/lib/utils.test.ts +0 -23
- package/src/lib/utils.ts +0 -60
- package/src/scaffold-dev.ts +0 -89
- package/src/scaffold.ts +0 -86
- package/tsconfig.json +0 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/addComponent.ts","../src/lib/utils.ts","../src/lib/addPage.ts","../src/lib/rmPage.ts","../src/scaffold.ts","../src/lib/createProject.ts","../src/lib/createProjectWithPrompt.ts","../bin.node.ts"],"sourcesContent":["// src/index.ts\n\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport prompts from \"prompts\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { addComponent } from \"./lib/addComponent\";\nimport { addPage } from \"./lib/addPage\";\nimport { rmPage } from \"./lib/rmPage\";\nimport { createProject } from \"./lib/createProject\";\nimport { createProjectWithPrompt } from \"./lib/createProjectWithPrompt\";\n\ntype Cfg = {\n version: 1;\n shell: \"bash\" | \"zsh\";\n completionInstalled: boolean;\n createdAt: string;\n updatedAt: string;\n};\n\nconst CONFIG_DIR = process.env.XDG_CONFIG_HOME\n ? path.join(process.env.XDG_CONFIG_HOME, \"create-next-pro\")\n : path.join(os.homedir(), \".config\", \"create-next-pro\");\nconst CONFIG_FILE = path.join(CONFIG_DIR, \"config.json\");\n\nfunction readCfg(): Cfg | null {\n try {\n return JSON.parse(fs.readFileSync(CONFIG_FILE, \"utf8\")) as Cfg;\n } catch {\n return null;\n }\n}\nfunction writeCfg(cfg: Cfg) {\n fs.mkdirSync(CONFIG_DIR, { recursive: true });\n fs.writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2));\n}\nfunction rcFile(shell: \"bash\" | \"zsh\") {\n return path.join(os.homedir(), shell === \"zsh\" ? \".zshrc\" : \".bashrc\");\n}\nfunction ensureLineInRc(file: string, line: string) {\n try {\n const cur = fs.existsSync(file) ? fs.readFileSync(file, \"utf8\") : \"\";\n if (!cur.includes(line)) fs.appendFileSync(file, `\\n${line}\\n`);\n } catch {\n /* ignore */\n }\n}\nasync function installCompletion(shell: \"bash\" | \"zsh\") {\n // Lit le script d’auto-complétion depuis le package (racine du package)\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n const completionSrc = path.resolve(\n __dirname,\n \"../create-next-pro-completion.sh\",\n );\n const completionDst = path.join(CONFIG_DIR, \"completion.sh\");\n fs.mkdirSync(CONFIG_DIR, { recursive: true });\n fs.copyFileSync(completionSrc, completionDst);\n ensureLineInRc(rcFile(shell), `source \"${completionDst}\"`);\n}\nasync function onboarding(): Promise<Cfg> {\n const pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, \"../package.json\"), \"utf8\"),\n );\n console.log(`🚀 Welcome to create-next-pro v${pkg.version}\\n`);\n const res = await prompts(\n [\n {\n type: \"select\",\n name: \"shell\",\n message: \"Which shell do you use?\",\n choices: [\n { title: \"zsh\", value: \"zsh\" },\n { title: \"bash\", value: \"bash\" },\n ],\n initial: (os.userInfo().shell || \"\").includes(\"zsh\") ? 0 : 1,\n },\n {\n type: \"toggle\",\n name: \"completion\",\n message: \"Install autocompletion?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n ],\n { onCancel: () => process.exit(1) },\n );\n\n const cfg: Cfg = {\n version: 1,\n shell: res.shell,\n completionInstalled: !!res.completion,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n };\n if (cfg.completionInstalled) await installCompletion(cfg.shell);\n writeCfg(cfg);\n console.log(\"\\n✅ Configuration saved.\");\n console.log(\"you can now use the CLI ! ex : create-next-pro <project-name>\");\n console.log(\n \"For more information, visit: https://github.com/Rising-Corporation/create-next-pro-cli\",\n );\n console.log(\"Happy coding! 🎉\");\n return cfg;\n}\nfunction showHelp() {\n console.log(`create-next-pro\n\nUsage:\n create-next-pro <project-name> [--force]\n create-next-pro addpage [options]\n create-next-pro addcomponent [options]\n create-next-pro rmpage [options]\n\nOptions:\n --help Show this help message\n --reconfigure Run the configuration assistant again\n`);\n}\n\nfunction showVersion() {\n const pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, \"../package.json\"), \"utf8\"),\n );\n console.log(`v${pkg.version}`);\n}\n\n/**\n * Main CLI entry point for create-next-pro.\n *\n * Note: For now, the project behaves as if --force is always enabled and no creation prompt is taken into account.\n * All actions are performed directly without confirmation.\n */\nexport async function main() {\n let args: string[];\n if (typeof Bun !== \"undefined\") {\n args = Bun.argv.slice(2);\n } else if (typeof process !== \"undefined\" && process.argv) {\n args = process.argv.slice(2);\n } else {\n args = [];\n }\n\n if (args.includes(\"--help\")) return showHelp();\n if (args.includes(\"--version\") || args.includes(\"-v\")) return showVersion();\n if (args.includes(\"--reconfigure\") || !readCfg()) {\n await onboarding();\n return;\n }\n\n const force = args.includes(\"--force\");\n // For now, --force is always considered enabled but do not overwrite existing projects\n // WARNING: if you enable --force it will overwrite existing projects. This is a temporary setting for development purposes.\n // const force = true;\n\n // If addpage is called without options, add default flags -LPl\n if (args[0] === \"addpage\" && args.length === 1) {\n args.push(\"-LPl\");\n }\n\n /**\n * Handle addcomponent command: create a component in the correct location and update translation JSON.\n */\n if (args[0] === \"addcomponent\") {\n addComponent(args);\n return;\n }\n\n /**\n * Handle addpage command: create a page (nested or not) and update translation JSON.\n */\n if (args[0] === \"addpage\") {\n addPage(args);\n return;\n }\n\n /**\n * Handle rmpage command: remove a page and all related files/folders.\n */\n if (args[0] === \"rmpage\") {\n rmPage(args);\n return;\n }\n\n /**\n * Handle direct project creation if a name argument is provided.\n */\n const nameArg = args.find((arg) => !arg.startsWith(\"--\"));\n\n if (nameArg) {\n createProject(nameArg, force);\n return;\n }\n\n /**\n * Interactive prompt for project creation (not currently used, see note above).\n */\n await createProjectWithPrompt();\n}\n","import { join } from \"node:path\";\nimport { mkdir, readFile, writeFile, readdir } from \"node:fs/promises\";\nimport prompts from \"prompts\";\n\nimport { capitalize, loadConfig } from \"./utils\";\n\nimport { existsSync, statSync } from \"node:fs\";\n\nexport async function addComponent(args: string[]) {\n let componentName = args[1];\n let pageScope = null;\n let pageIndex = args.findIndex((arg) => arg === \"-P\" || arg === \"--page\");\n if (pageIndex !== -1 && args[pageIndex + 1]) {\n pageScope = args[pageIndex + 1];\n }\n\n // Handle nested pageScope (e.g. ParentPage.ChildPage)\n let nestedPath = null;\n if (pageScope && pageScope.includes(\".\")) {\n nestedPath = join(...pageScope.split(\".\"));\n }\n\n if (!componentName || componentName.startsWith(\"-\")) {\n // Si le nom n'est pas fourni ou est une option, demander via prompt\n const response = await prompts.prompt({\n type: \"text\",\n name: \"componentName\",\n message: \"🧩 Component name to add:\",\n validate: (name: string) => (name ? true : \"Component name is required\"),\n });\n componentName = response.componentName;\n }\n\n const config = await loadConfig();\n if (!config) {\n console.error(\n \"❌ Configuration file cnp.config.json not found. Run this command from the project root.\"\n );\n return;\n }\n const useI18n = !!config.useI18n;\n\n const componentNameUpper = capitalize(componentName);\n const templatePath = join(\n import.meta.dir,\n \"..\",\n \"..\",\n \"templates\",\n \"Component\"\n );\n let messagesPath: string | null = null;\n if (useI18n) {\n messagesPath = join(process.cwd(), \"messages\");\n if (!existsSync(messagesPath)) {\n console.error(\"❌ Messages directory missing. Ensure i18n was configured.\");\n return;\n }\n }\n\n // Determine target path for the component\n let componentTargetPath;\n let translationKey;\n if (pageScope) {\n if (nestedPath) {\n componentTargetPath = join(process.cwd(), \"src\", \"ui\", nestedPath);\n translationKey = pageScope;\n } else {\n componentTargetPath = join(process.cwd(), \"src\", \"ui\", pageScope);\n translationKey = pageScope;\n }\n } else {\n componentTargetPath = join(process.cwd(), \"src\", \"ui\", \"_global\");\n translationKey = \"_global_ui\";\n }\n if (!existsSync(componentTargetPath)) {\n await mkdir(componentTargetPath, { recursive: true });\n }\n const componentFile = join(componentTargetPath, `${componentNameUpper}.tsx`);\n\n // Read and adapt the TSX template\n const templateComponentPath = join(templatePath, \"Component.tsx\");\n if (existsSync(templateComponentPath)) {\n let content = await readFile(templateComponentPath, \"utf-8\");\n // Remplacement du nom du component et de la clé de traduction\n content = content\n .replace(/Component/g, componentNameUpper)\n .replace(/componentPage/g, translationKey);\n await writeFile(componentFile, content);\n console.log(`📄 File created: ${componentFile}`);\n } else {\n console.error(\n \"❌ Template Component.tsx introuvable :\",\n templateComponentPath\n );\n }\n\n\n if (useI18n && messagesPath) {\n const entries = await readdir(messagesPath, { withFileTypes: true });\n const langDirs = entries.filter((e) => e.isDirectory()).map((e) => e.name);\n const jsonTemplate = join(templatePath, \"component.json\");\n if (!existsSync(jsonTemplate)) {\n console.error(\"❌ Template component.json not found:\", jsonTemplate);\n return;\n\n }\n const jsonContent = await readFile(jsonTemplate, \"utf-8\");\n const parsed = JSON.parse(jsonContent);\n\n for (const locale of langDirs) {\n // Only process if messages/<locale> is a directory\n const localeDir = join(messagesPath, locale);\n if (!existsSync(localeDir) || !statSync(localeDir).isDirectory())\n continue;\n let jsonTarget;\n if (pageScope) {\n jsonTarget = join(messagesPath, locale, `${pageScope}.json`);\n } else {\n jsonTarget = join(messagesPath, locale, `_global_ui.json`);\n }\n\n let current: Record<string, any> = {};\n if (existsSync(jsonTarget)) {\n const jsonFile = await readFile(jsonTarget, \"utf-8\");\n current = JSON.parse(jsonFile) as Record<string, any>;\n }\n current[componentNameUpper] = parsed;\n await writeFile(jsonTarget, JSON.stringify(current, null, 2));\n }\n } else {\n console.log(\"ℹ️ Skipping translation entries; next-intl not enabled.\");\n }\n\n console.log(\n `✅ Component \"${componentNameUpper}\" added ${\n pageScope ? `to page ${pageScope}` : \"globally\"\n }${useI18n ? \" with localized messages\" : \"\"}.`\n );\n}\n","import { readFile } from \"node:fs/promises\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/**\n * Capitalize the first letter of a string.\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nexport interface CNPConfig {\n useI18n?: boolean;\n [key: string]: any;\n}\n\n/**\n * Load CLI configuration from the project root.\n * Returns null if the configuration file is missing or invalid.\n */\nexport async function loadConfig(): Promise<CNPConfig | null> {\n const configPath = join(process.cwd(), \"cnp.config.json\");\n if (!existsSync(configPath)) return null;\n try {\n const raw = await readFile(configPath, \"utf-8\");\n return JSON.parse(raw) as CNPConfig;\n } catch {\n return null;\n }\n}\n\n/**\n * Map a key to its corresponding file name for page/component templates.\n * @param key string\n * @returns file name string\n */\nexport function toFileName(key: string): string {\n switch (key) {\n case \"layout\":\n return \"layout.tsx\";\n case \"page\":\n return \"page.tsx\";\n case \"loading\":\n return \"loading.tsx\";\n case \"not-found\":\n return \"not-found.tsx\";\n case \"error\":\n return \"error.tsx\";\n case \"global-error\":\n return \"global-error.tsx\";\n case \"route\":\n return \"route.ts\";\n case \"template\":\n return \"template.tsx\";\n case \"default\":\n return \"default.tsx\";\n default:\n return `${key}.tsx`;\n }\n}\n","import { join } from \"node:path\";\nimport { mkdir, readFile, writeFile, readdir } from \"node:fs/promises\";\nimport prompts from \"prompts\";\n\nimport { capitalize, toFileName, loadConfig } from \"./utils\";\n\nimport { existsSync, statSync } from \"node:fs\";\n\nexport async function addPage(args: string[]) {\n let pageName = args[1];\n if (!pageName || pageName.startsWith(\"-\")) {\n const response = await prompts.prompt({\n type: \"text\",\n name: \"pageName\",\n message: \"📝 Page name to add:\",\n validate: (name: string) => (name ? true : \"Page name is required\"),\n });\n pageName = response.pageName;\n }\n\n // Handle nested pages\n let parentName = null;\n let childName = null;\n if (pageName.includes(\".\")) {\n [parentName, childName] = pageName.split(\".\");\n }\n\n let shortFlags = args.find((arg) => /^-[A-Za-z]+$/.test(arg));\n let longFlags = new Set(args.filter((a) => a.startsWith(\"--\")));\n const flags = new Set<string>();\n\n if (!shortFlags && Array.from(longFlags).length === 0) {\n shortFlags = \"-LPl\";\n }\n\n if (shortFlags) {\n for (const char of shortFlags.slice(1)) {\n switch (char) {\n case \"L\":\n flags.add(\"layout\");\n break;\n case \"P\":\n flags.add(\"page\");\n break;\n case \"l\":\n flags.add(\"loading\");\n break;\n case \"n\":\n flags.add(\"not-found\");\n break;\n case \"e\":\n flags.add(\"error\");\n break;\n case \"g\":\n flags.add(\"global-error\");\n break;\n case \"r\":\n flags.add(\"route\");\n break;\n case \"t\":\n flags.add(\"template\");\n break;\n case \"d\":\n flags.add(\"default\");\n break;\n }\n }\n }\n\n for (const flag of [\n \"layout\",\n \"page\",\n \"loading\",\n \"not-found\",\n \"error\",\n \"global-error\",\n \"route\",\n \"template\",\n \"default\",\n ]) {\n if (longFlags.has(\"--\" + flag)) flags.add(flag);\n }\n\n const config = await loadConfig();\n if (!config) {\n console.error(\"❌ Configuration file cnp.config.json not found. Run this command from the project root.\");\n return;\n }\n const useI18n = !!config.useI18n;\n\n const srcSegments = [\"src\", \"app\"];\n if (useI18n) srcSegments.push(\"[locale]\");\n const srcPath = join(process.cwd(), ...srcSegments);\n if (!existsSync(srcPath)) {\n console.error(`❌ Expected directory not found: ${srcPath}`);\n return;\n }\n\n let messagesPath: string | null = null;\n let locales: string[] = [];\n if (useI18n) {\n messagesPath = join(process.cwd(), \"messages\");\n if (!existsSync(messagesPath)) {\n console.error(\"❌ Messages directory missing. Ensure i18n was configured.\");\n return;\n }\n const entries = await readdir(messagesPath, { withFileTypes: true });\n locales = entries.filter((e) => e.isDirectory()).map((e) => e.name);\n }\n\n const templatePath = join(import.meta.dir, \"..\", \"..\", \"templates\", \"Page\");\n\n // Create folders/files for nested or simple page\n let uiPageDir, localePagePath, jsonFileName;\n if (parentName && childName) {\n uiPageDir = join(process.cwd(), \"src\", \"ui\", parentName, childName);\n localePagePath = join(srcPath, parentName, childName);\n jsonFileName = parentName;\n } else {\n uiPageDir = join(process.cwd(), \"src\", \"ui\", pageName);\n localePagePath = join(srcPath, pageName);\n jsonFileName = pageName;\n }\n if (!existsSync(uiPageDir)) {\n await mkdir(uiPageDir, { recursive: true });\n }\n const uiPageFile = join(uiPageDir, \"page-ui.tsx\");\n const uiPageTemplate = join(templatePath, \"page-ui.tsx\");\n if (existsSync(uiPageTemplate)) {\n let uiContent = await readFile(uiPageTemplate, \"utf-8\");\n uiContent = uiContent\n .replace(/template/g, childName || pageName)\n .replace(/Template/g, capitalize(childName || pageName));\n await writeFile(uiPageFile, uiContent);\n console.log(`📄 File created: ${uiPageFile}`);\n } else {\n console.warn(\"⚠️ Template page-ui.tsx manquant.\");\n }\n if (!existsSync(localePagePath)) {\n await mkdir(localePagePath, { recursive: true });\n }\n for (const flag of flags) {\n const filename = toFileName(flag);\n const src = join(templatePath, filename);\n const dst = join(localePagePath, filename);\n if (!existsSync(src)) {\n console.warn(`⚠️ Missing template file: ${filename}`);\n continue;\n }\n const content = await readFile(src, \"utf-8\");\n const replaced = content\n .replace(/template/g, childName || pageName)\n .replace(/Template/g, capitalize(childName || pageName));\n await writeFile(dst, replaced);\n console.log(`📄 File created: ${dst}`);\n }\n\n if (useI18n && messagesPath) {\n const jsonTemplate = join(templatePath, \"page.json\");\n if (!existsSync(jsonTemplate)) {\n console.warn(\"⚠️ Missing template page.json.\");\n\n } else {\n const content = await readFile(jsonTemplate, \"utf-8\");\n const replaced = content\n .replace(/template/g, childName || pageName)\n .replace(/Template/g, capitalize(childName || pageName));\n for (const locale of locales) {\n // Only process if messages/<locale> is a directory\n const localeDir = join(messagesPath, locale);\n if (!existsSync(localeDir) || !statSync(localeDir).isDirectory())\n continue;\n const jsonTarget = join(messagesPath, locale, `${jsonFileName}.json`);\n let current: Record<string, any> = {};\n if (existsSync(jsonTarget)) {\n const jsonFile = await readFile(jsonTarget, \"utf-8\");\n try {\n current = JSON.parse(jsonFile) as Record<string, any>;\n } catch {\n current = {};\n }\n }\n if (parentName && childName) {\n current[childName] = JSON.parse(replaced);\n } else {\n // fichier simple\n current = JSON.parse(replaced);\n }\n await writeFile(jsonTarget, JSON.stringify(current, null, 2));\n }\n }\n } else {\n console.log(\"ℹ️ Skipping translation templates; next-intl not enabled.\");\n }\n\n console.log(\n `✅ Page \"${pageName}\" with templates added${\n useI18n ? \" for each locale\" : \"\"\n }.`\n );\n}\n","import { join } from \"node:path\";\nimport { writeFile, readdir } from \"node:fs/promises\";\nimport prompts from \"prompts\";\nimport { existsSync } from \"node:fs\";\n\nexport async function rmPage(args: string[]) {\n let pageName = args[1];\n if (!pageName || pageName.startsWith(\"-\")) {\n const response = await prompts.prompt({\n type: \"text\",\n name: \"pageName\",\n message: \"🗑️ Page name to remove:\",\n validate: (name: string) => (name ? true : \"Page name is required\"),\n });\n pageName = response.pageName;\n }\n\n // Remove translation files messages/<lang>/<PageName>.json\n const messagesPath = join(process.cwd(), \"messages\");\n const entries = await readdir(messagesPath, { withFileTypes: true });\n const langDirs = entries.filter((e) => e.isDirectory()).map((e) => e.name);\n for (const locale of langDirs) {\n const jsonTarget = join(messagesPath, locale, `${pageName}.json`);\n if (existsSync(jsonTarget)) {\n await writeFile(jsonTarget, \"\");\n await import(\"node:child_process\").then((cp) =>\n cp.execSync(`rm -f '${jsonTarget}'`)\n );\n console.log(`🗑️ Deleted: ${jsonTarget}`);\n }\n }\n\n // Remove folder src/ui/<PageName>\n const uiPageDir = join(process.cwd(), \"src\", \"ui\", pageName);\n if (existsSync(uiPageDir)) {\n await import(\"node:child_process\").then((cp) =>\n cp.execSync(`rm -rf '${uiPageDir}'`)\n );\n console.log(`🗑️ Deleted: ${uiPageDir}`);\n }\n\n // Remove folder src/app/[locale]/<PageName>\n const appLocaleDir = join(process.cwd(), \"src\", \"app\", \"[locale]\", pageName);\n if (existsSync(appLocaleDir)) {\n await import(\"node:child_process\").then((cp) =>\n cp.execSync(`rm -rf '${appLocaleDir}'`)\n );\n console.log(`🗑️ Deleted: ${appLocaleDir}`);\n }\n\n console.log(`✅ Page \"${pageName}\" deleted.`);\n}\n","// src/scaffold.ts\n\nimport { cp, mkdir, rm, writeFile, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { existsSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Options for scaffolding a Next.js project.\n */\ninterface ScaffoldOptions {\n projectName: string;\n useTypescript: boolean;\n useEslint: boolean;\n useTailwind: boolean;\n useSrcDir: boolean;\n useTurbopack: boolean;\n useI18n: boolean;\n customAlias: boolean;\n importAlias: string;\n force?: boolean;\n}\n\n/**\n * Scaffold a new Next.js project based on provided options.\n *\n * - Copies the default template to the target directory\n * - Removes the target directory if it exists and --force is set\n * - Optionally customizes the structure in future (e.g. remove unused files)\n *\n * @param options ScaffoldOptions for the project\n */\nexport async function scaffoldProject(options: ScaffoldOptions) {\n const targetPath = join(process.cwd(), options.projectName);\n\n const __dirname = new URL(\".\", import.meta.url); // or :\n // const __dirname = path.dirname(fileURLToPath(import.meta.url));\n const templatePath = join(\n fileURLToPath(__dirname),\n \"..\",\n \"templates\",\n \"Projects\",\n \"default\",\n );\n\n // Check if target directory exists\n if (existsSync(targetPath)) {\n if (options.force) {\n console.warn(\"⚠️ Target directory already exists, removing...\");\n await rm(targetPath, { recursive: true, force: true });\n } else {\n console.error(\n \"❌ Target directory already exists. Use --force to overwrite.\",\n );\n process.exit(1);\n }\n }\n\n try {\n console.log(\"📁 Creating project directory...\");\n await mkdir(targetPath, { recursive: true });\n\n console.log(\"📦 Copying files from template...\");\n await cp(templatePath, targetPath, { recursive: true });\n\n // Apply configuration: add dependencies or files based on prompt choices\n const pkgPath = join(targetPath, \"package.json\");\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(await readFile(pkgPath, \"utf-8\"));\n pkg.dependencies = pkg.dependencies || {};\n if (options.useI18n) {\n pkg.dependencies[\"next-intl\"] =\n pkg.dependencies[\"next-intl\"] || \"^4.3.5\";\n }\n await writeFile(pkgPath, JSON.stringify(pkg, null, 2));\n }\n\n // Write CLI configuration to project root\n await writeFile(\n join(targetPath, \"cnp.config.json\"),\n JSON.stringify(options, null, 2),\n );\n\n console.log(\"✅ Project scaffolded successfully!\");\n console.log(`➡️ cd ${options.projectName} && bun install && bun dev`);\n } catch (err) {\n console.error(\"❌ Error during scaffolding:\", err);\n process.exit(1);\n }\n}\n","import { scaffoldProject } from \"../scaffold\";\nexport async function createProject(nameArg: string, force: boolean) {\n const response = {\n projectName: nameArg,\n useTypescript: true,\n useEslint: true,\n useTailwind: true,\n useSrcDir: true,\n useTurbopack: true,\n useI18n: true,\n customAlias: true,\n importAlias: \"@/*\",\n force,\n };\n\n console.log(`📦 Creating project \"${response.projectName}\"...`);\n await scaffoldProject(response);\n}\n","import { scaffoldProject } from \"../scaffold\";\nimport prompts from \"prompts\";\nexport async function createProjectWithPrompt() {\n const response = await prompts.prompt([\n {\n type: \"text\",\n name: \"projectName\",\n message: \"🧱 Project name:\",\n initial: \"my-next-app\",\n },\n {\n type: \"toggle\",\n name: \"useTypescript\",\n message: \"✔ Use TypeScript?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n {\n type: \"toggle\",\n name: \"useEslint\",\n message: \"✔ Use ESLint?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n {\n type: \"toggle\",\n name: \"useTailwind\",\n message: \"✔ Use Tailwind CSS?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n {\n type: \"toggle\",\n name: \"useSrcDir\",\n message: \"✔ Use `src/` directory?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n {\n type: \"toggle\",\n name: \"useTurbopack\",\n message: \"✔ Use Turbopack for `next dev`?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n {\n type: \"toggle\",\n name: \"useI18n\",\n message: \"✔ Use i18n with next-intl for translations?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n {\n type: \"toggle\",\n name: \"customAlias\",\n message: \"✔ Customize import alias (`@/*` by default)?\",\n initial: true,\n active: \"Yes\",\n inactive: \"No\",\n },\n {\n type: (prev: boolean) => (prev ? \"text\" : null),\n name: \"importAlias\",\n message: \"✔ What import alias would you like?\",\n initial: \"@core/*\",\n },\n ]);\n\n console.log(\"\\n✅ Your choices:\");\n console.log(response);\n\n await scaffoldProject(response);\n}\n","#!/usr/bin/env node\nimport { main } from \"./src/index\";\nmain();\n"],"mappings":";;;AAEA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAOA,cAAa;AACpB,SAAS,iBAAAC,sBAAqB;;;ACN9B,SAAS,QAAAC,aAAY;AACrB,SAAS,OAAO,YAAAC,WAAU,WAAW,eAAe;AACpD,OAAO,aAAa;;;ACFpB,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAKd,SAAS,WAAW,KAAqB;AAC9C,SAAO,IAAI,OAAO,CAAC,EAAE,YAAY,IAAI,IAAI,MAAM,CAAC;AAClD;AAWA,eAAsB,aAAwC;AAC5D,QAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,iBAAiB;AACxD,MAAI,CAAC,WAAW,UAAU,EAAG,QAAO;AACpC,MAAI;AACF,UAAM,MAAM,MAAM,SAAS,YAAY,OAAO;AAC9C,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOO,SAAS,WAAW,KAAqB;AAC9C,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO;AAAA,IACT,KAAK;A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,KAAK;AAAA,IACf,GAAG,aAAa,KAAK,QAAQ,WAAW,iBAAiB,GAAG,MAAM;AAAA,EACpE;AACA,UAAQ,IAAI,IAAI,IAAI,OAAO,EAAE;AAC/B;AAQA,eAAsB,OAAO;AAC3B,MAAI;AACJ,MAAI,OAAO,QAAQ,aAAa;AAC9B,WAAO,IAAI,KAAK,MAAM,CAAC;AAAA,EACzB,WAAW,OAAO,YAAY,eAAe,QAAQ,MAAM;AACzD,WAAO,QAAQ,KAAK,MAAM,CAAC;AAAA,EAC7B,OAAO;AACL,WAAO,CAAC;AAAA,EACV;AAEA,MAAI,KAAK,SAAS,QAAQ,EAAG,QAAO,SAAS;AAC7C,MAAI,KAAK,SAAS,WAAW,KAAK,KAAK,SAAS,IAAI,EAAG,QAAO,YAAY;AAC1E,MAAI,KAAK,SAAS,eAAe,KAAK,CAAC,QAAQ,GAAG;AAChD,UAAM,WAAW;AACjB;AAAA,EACF;AAEA,QAAM,QAAQ,KAAK,SAAS,SAAS;AAMrC,MAAI,KAAK,CAAC,MAAM,aAAa,KAAK,WAAW,GAAG;AAC9C,SAAK,KAAK,MAAM;AAAA,EAClB;AAKA,MAAI,KAAK,CAAC,MAAM,gBAAgB;AAC9B,iBAAa,IAAI;AACjB;AAAA,EACF;AAKA,MAAI,KAAK,CAAC,MAAM,WAAW;AACzB,YAAQ,IAAI;AACZ;AAAA,EACF;AAKA,MAAI,KAAK,CAAC,MAAM,UAAU;AACxB,WAAO,IAAI;AACX;AAAA,EACF;AAKA,QAAM,UAAU,KAAK,KAAK,CAAC,QAAQ,CAAC,IAAI,WAAW,IAAI,CAAC;AAExD,MAAI,SAAS;AACX,kBAAc,SAAS,KAAK;AAC5B;AAAA,EACF;AAKA,QAAM,wBAAwB;AAChC;;;AQtMA,KAAK;","names":["prompts","fileURLToPath","join","readFile","existsSync","join","readFile","join","mkdir","readFile","writeFile","readdir","prompts","existsSync","statSync","prompts","join","readdir","mkdir","readFile","writeFile","join","writeFile","readdir","prompts","existsSync","cp","mkdir","writeFile","readFile","join","existsSync","__dirname","prompts","__dirname","fileURLToPath","prompts"]}
|
package/package.json
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-next-pro-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Advanced Next.js project scaffolder with i18n, Tailwind, App Router and more.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/Rising-Corporation/create-next-pro-cli.git"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"create-next-pro": "./
|
|
10
|
+
"create-next-pro": "./dist/create-next-pro"
|
|
11
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"templates",
|
|
15
|
+
"create-next-pro-completion.sh",
|
|
16
|
+
"public/cnp-banner.svg",
|
|
17
|
+
"public/logo.svg",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
12
21
|
"author": "MrRise",
|
|
13
22
|
"license": "MIT",
|
|
14
23
|
"type": "module",
|
|
15
24
|
"scripts": {
|
|
16
|
-
"dev": "bun run bin.ts",
|
|
25
|
+
"dev": "bun run bin.bun.ts",
|
|
17
26
|
"scaffold-dev": "bun run src/scaffold-dev.ts",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"build": "bun build
|
|
21
|
-
"
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"build": "bun run clean && bun run build:node && bun run build:bun && cp scripts/create-next-pro dist/create-next-pro && chmod +x dist/create-next-pro",
|
|
30
|
+
"build:node": "tsup",
|
|
31
|
+
"build:bun": "bun build bin.bun.ts --outdir dist --target=bun",
|
|
32
|
+
"prepublishOnly": "bun run clean && bun run build",
|
|
22
33
|
"commit": "cz",
|
|
23
34
|
"release": "bunx --bun standard-version",
|
|
24
35
|
"prepare-husky": "husky",
|
|
25
|
-
"version-patch": "npm version patch"
|
|
36
|
+
"version-patch": "npm version patch",
|
|
37
|
+
"git-fullpush": "bun run build && git add -A && bun commit && git push origin master && bun version-patch"
|
|
26
38
|
},
|
|
27
39
|
"config": {
|
|
28
40
|
"commitizen": {
|
|
@@ -49,12 +61,18 @@
|
|
|
49
61
|
"devDependencies": {
|
|
50
62
|
"@commitlint/cli": "^19.8.1",
|
|
51
63
|
"@commitlint/config-conventional": "^19.8.1",
|
|
64
|
+
"@types/node": "^22",
|
|
52
65
|
"@types/prompts": "^2.4.9",
|
|
53
66
|
"commitizen": "^4.3.1",
|
|
67
|
+
"csstype": "^3.1.3",
|
|
54
68
|
"cz-conventional-changelog": "^3.3.0",
|
|
55
69
|
"husky": "^9.1.7",
|
|
70
|
+
"kleur": "^4.1.5",
|
|
56
71
|
"lint-staged": "^16.1.5",
|
|
57
72
|
"prettier": "^3.6.2",
|
|
58
|
-
"standard-version": "^9.5.0"
|
|
73
|
+
"standard-version": "^9.5.0",
|
|
74
|
+
"tsup": "^8.5.0",
|
|
75
|
+
"undici-types": "^6",
|
|
76
|
+
"vitest": "^3.2.4"
|
|
59
77
|
}
|
|
60
78
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// README.mdThis is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-pro`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
First, run the development server:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run dev
|
|
9
|
+
# or
|
|
10
|
+
yarn dev
|
|
11
|
+
# or
|
|
12
|
+
pnpm dev
|
|
13
|
+
# or
|
|
14
|
+
bun dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
18
|
+
|
|
19
|
+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
|
20
|
+
|
|
21
|
+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
|
22
|
+
|
|
23
|
+
## Learn More
|
|
24
|
+
|
|
25
|
+
To learn more about Next.js, take a look at the following resources:
|
|
26
|
+
|
|
27
|
+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
28
|
+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
29
|
+
|
|
30
|
+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
|
31
|
+
|
|
32
|
+
## Deploy on Vercel
|
|
33
|
+
|
|
34
|
+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
35
|
+
|
|
36
|
+
Check out [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: ["master"]
|
|
6
|
-
pull_request:
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
test-build:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v4
|
|
13
|
-
- uses: oven-sh/setup-bun@v1
|
|
14
|
-
- run: bun install
|
|
15
|
-
- run: bun test
|
|
16
|
-
- run: bun run build
|
|
17
|
-
publish:
|
|
18
|
-
needs: test-build
|
|
19
|
-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
environment:
|
|
22
|
-
name: ENV
|
|
23
|
-
steps:
|
|
24
|
-
- uses: actions/checkout@v4
|
|
25
|
-
- uses: oven-sh/setup-bun@v2
|
|
26
|
-
with:
|
|
27
|
-
bun-version: latest
|
|
28
|
-
- name: Configure Git
|
|
29
|
-
run: |
|
|
30
|
-
git config user.name "GitHub Actions"
|
|
31
|
-
git config user.email "actions@github.com"
|
|
32
|
-
- run: bun install
|
|
33
|
-
- run: bun run version-patch
|
|
34
|
-
- run: bun run build
|
|
35
|
-
- name: Set up .npmrc
|
|
36
|
-
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
|
37
|
-
- name: Publish package
|
|
38
|
-
run: npm publish
|
package/bin.ts
DELETED
package/commitlint.config.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** @type {import('@commitlint/types').UserConfig} */
|
|
2
|
-
module.exports = {
|
|
3
|
-
extends: ["@commitlint/config-conventional"],
|
|
4
|
-
rules: {
|
|
5
|
-
// subject free (no Upper/Start/Pascal)
|
|
6
|
-
"subject-case": [
|
|
7
|
-
2,
|
|
8
|
-
"never",
|
|
9
|
-
["sentence-case", "start-case", "pascal-case", "upper-case"],
|
|
10
|
-
],
|
|
11
|
-
},
|
|
12
|
-
};
|
package/install.sh
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Installation script for create-next-pro
|
|
3
|
-
|
|
4
|
-
# Detect runtimes
|
|
5
|
-
bun_path=$(command -v bun)
|
|
6
|
-
deno_path=$(command -v deno)
|
|
7
|
-
node_path=$(command -v node)
|
|
8
|
-
|
|
9
|
-
if [ -n "$bun_path" ]; then
|
|
10
|
-
echo "Bun detected at $bun_path. Using Bun shebang."
|
|
11
|
-
sed -i '1s|.*|#!/usr/bin/env bun|' dist/bin.js
|
|
12
|
-
elif [ -n "$deno_path" ]; then
|
|
13
|
-
echo "Deno detected at $deno_path. Using Deno shebang."
|
|
14
|
-
sed -i '1s|.*|#!/usr/bin/env deno|' dist/bin.js
|
|
15
|
-
elif [ -n "$node_path" ]; then
|
|
16
|
-
echo "Node.js detected at $node_path. Using Node shebang."
|
|
17
|
-
sed -i '1s|.*|#!/usr/bin/env node|' dist/bin.js
|
|
18
|
-
else
|
|
19
|
-
echo "No compatible runtime (Bun, Deno, Node.js) found."
|
|
20
|
-
read -p "Do you want to install Bun? [Y/n] " yn
|
|
21
|
-
case $yn in
|
|
22
|
-
[Nn]*)
|
|
23
|
-
echo "Installation cancelled. Do you want to delete the parent folder? [Y/n] "
|
|
24
|
-
read delyn
|
|
25
|
-
case $delyn in
|
|
26
|
-
[Nn]*) echo "Folder kept."; exit 1;;
|
|
27
|
-
*)
|
|
28
|
-
parent_dir="$(dirname $(pwd))"
|
|
29
|
-
echo "Deleting folder $parent_dir..."
|
|
30
|
-
rm -rf "$parent_dir"
|
|
31
|
-
echo "Folder deleted."
|
|
32
|
-
exit 1
|
|
33
|
-
;;
|
|
34
|
-
esac
|
|
35
|
-
;;
|
|
36
|
-
*)
|
|
37
|
-
echo "Please install Bun, node or Deno!"
|
|
38
|
-
echo "Installation instructions:"
|
|
39
|
-
echo "Bun: https://bun.com/"
|
|
40
|
-
echo "Node.js: https://nodejs.org/"
|
|
41
|
-
echo "Deno: https://deno.land/"
|
|
42
|
-
exit 1
|
|
43
|
-
;;
|
|
44
|
-
esac
|
|
45
|
-
fi
|
|
46
|
-
|
|
47
|
-
COMPLETION_SCRIPT="$(pwd)/create-next-pro-completion.sh"
|
|
48
|
-
|
|
49
|
-
# Choose shell for autocompletion
|
|
50
|
-
read -p "Which shell do you use? [1] zsh, [2] bash (default: bash): " shell_choice
|
|
51
|
-
case $shell_choice in
|
|
52
|
-
1|zsh|Zsh)
|
|
53
|
-
RC_FILE="$HOME/.zshrc"
|
|
54
|
-
SHELL_NAME="zsh"
|
|
55
|
-
;;
|
|
56
|
-
*)
|
|
57
|
-
RC_FILE="$HOME/.bashrc"
|
|
58
|
-
SHELL_NAME="bash"
|
|
59
|
-
;;
|
|
60
|
-
esac
|
|
61
|
-
|
|
62
|
-
read -p "Do you want to add create-next-pro autocompletion to your $SHELL_NAME rc file? [Y/n] " yn
|
|
63
|
-
case $yn in
|
|
64
|
-
[Nn]*) echo "ℹ️ Autocompletion not added"; exit;;
|
|
65
|
-
*)
|
|
66
|
-
if ! grep -q "$COMPLETION_SCRIPT" "$RC_FILE"; then
|
|
67
|
-
echo "source $COMPLETION_SCRIPT" >> "$RC_FILE"
|
|
68
|
-
echo "✅ Autocompletion script added to $RC_FILE"
|
|
69
|
-
else
|
|
70
|
-
echo "ℹ️ Script already present in $RC_FILE"
|
|
71
|
-
fi
|
|
72
|
-
;;
|
|
73
|
-
esac
|
package/src/index.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
|
|
3
|
-
import { addComponent } from "./lib/addComponent";
|
|
4
|
-
import { addPage } from "./lib/addPage";
|
|
5
|
-
import { rmPage } from "./lib/rmPage";
|
|
6
|
-
import { createProject } from "./lib/createProject";
|
|
7
|
-
import { createProjectWithPrompt } from "./lib/createProjectWithPrompt";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Main CLI entry point for create-next-pro.
|
|
11
|
-
*
|
|
12
|
-
* Note: For now, the project behaves as if --force is always enabled and no creation prompt is taken into account.
|
|
13
|
-
* All actions are performed directly without confirmation.
|
|
14
|
-
*/
|
|
15
|
-
export async function main() {
|
|
16
|
-
console.log("🚀 Welcome to create-next-pro\n");
|
|
17
|
-
|
|
18
|
-
let args = Bun.argv.slice(2);
|
|
19
|
-
const force = args.includes("--force");
|
|
20
|
-
// For now, --force is always considered enabled but do not overwrite existing projects
|
|
21
|
-
// WARNING: if you enable --force it will overwrite existing projects. This is a temporary setting for development purposes.
|
|
22
|
-
// const force = true;
|
|
23
|
-
|
|
24
|
-
// If addpage is called without options, add default flags -LPl
|
|
25
|
-
if (args[0] === "addpage" && args.length === 1) {
|
|
26
|
-
args.push("-LPl");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Handle addcomponent command: create a component in the correct location and update translation JSON.
|
|
31
|
-
*/
|
|
32
|
-
if (args[0] === "addcomponent") {
|
|
33
|
-
addComponent(args);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Handle addpage command: create a page (nested or not) and update translation JSON.
|
|
39
|
-
*/
|
|
40
|
-
if (args[0] === "addpage") {
|
|
41
|
-
addPage(args);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Handle rmpage command: remove a page and all related files/folders.
|
|
47
|
-
*/
|
|
48
|
-
if (args[0] === "rmpage") {
|
|
49
|
-
rmPage(args);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Handle direct project creation if a name argument is provided.
|
|
55
|
-
*/
|
|
56
|
-
const nameArg = args.find((arg) => !arg.startsWith("--"));
|
|
57
|
-
|
|
58
|
-
if (nameArg) {
|
|
59
|
-
createProject(nameArg, force);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Interactive prompt for project creation (not currently used, see note above).
|
|
65
|
-
*/
|
|
66
|
-
await createProjectWithPrompt();
|
|
67
|
-
}
|
package/src/lib/addComponent.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { mkdir, readFile, writeFile, readdir } from "node:fs/promises";
|
|
3
|
-
import prompts from "prompts";
|
|
4
|
-
|
|
5
|
-
import { capitalize, loadConfig } from "./utils";
|
|
6
|
-
|
|
7
|
-
import { existsSync, statSync } from "node:fs";
|
|
8
|
-
|
|
9
|
-
export async function addComponent(args: string[]) {
|
|
10
|
-
let componentName = args[1];
|
|
11
|
-
let pageScope = null;
|
|
12
|
-
let pageIndex = args.findIndex((arg) => arg === "-P" || arg === "--page");
|
|
13
|
-
if (pageIndex !== -1 && args[pageIndex + 1]) {
|
|
14
|
-
pageScope = args[pageIndex + 1];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Handle nested pageScope (e.g. ParentPage.ChildPage)
|
|
18
|
-
let nestedPath = null;
|
|
19
|
-
if (pageScope && pageScope.includes(".")) {
|
|
20
|
-
nestedPath = join(...pageScope.split("."));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!componentName || componentName.startsWith("-")) {
|
|
24
|
-
// Si le nom n'est pas fourni ou est une option, demander via prompt
|
|
25
|
-
const response = await prompts.prompt({
|
|
26
|
-
type: "text",
|
|
27
|
-
name: "componentName",
|
|
28
|
-
message: "🧩 Component name to add:",
|
|
29
|
-
validate: (name: string) => (name ? true : "Component name is required"),
|
|
30
|
-
});
|
|
31
|
-
componentName = response.componentName;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const config = await loadConfig();
|
|
35
|
-
if (!config) {
|
|
36
|
-
console.error(
|
|
37
|
-
"❌ Configuration file cnp.config.json not found. Run this command from the project root."
|
|
38
|
-
);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const useI18n = !!config.useI18n;
|
|
42
|
-
|
|
43
|
-
const componentNameUpper = capitalize(componentName);
|
|
44
|
-
const templatePath = join(
|
|
45
|
-
import.meta.dir,
|
|
46
|
-
"..",
|
|
47
|
-
"..",
|
|
48
|
-
"templates",
|
|
49
|
-
"Component"
|
|
50
|
-
);
|
|
51
|
-
let messagesPath: string | null = null;
|
|
52
|
-
if (useI18n) {
|
|
53
|
-
messagesPath = join(process.cwd(), "messages");
|
|
54
|
-
if (!existsSync(messagesPath)) {
|
|
55
|
-
console.error("❌ Messages directory missing. Ensure i18n was configured.");
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Determine target path for the component
|
|
61
|
-
let componentTargetPath;
|
|
62
|
-
let translationKey;
|
|
63
|
-
if (pageScope) {
|
|
64
|
-
if (nestedPath) {
|
|
65
|
-
componentTargetPath = join(process.cwd(), "src", "ui", nestedPath);
|
|
66
|
-
translationKey = pageScope;
|
|
67
|
-
} else {
|
|
68
|
-
componentTargetPath = join(process.cwd(), "src", "ui", pageScope);
|
|
69
|
-
translationKey = pageScope;
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
componentTargetPath = join(process.cwd(), "src", "ui", "_global");
|
|
73
|
-
translationKey = "_global_ui";
|
|
74
|
-
}
|
|
75
|
-
if (!existsSync(componentTargetPath)) {
|
|
76
|
-
await mkdir(componentTargetPath, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
const componentFile = join(componentTargetPath, `${componentNameUpper}.tsx`);
|
|
79
|
-
|
|
80
|
-
// Read and adapt the TSX template
|
|
81
|
-
const templateComponentPath = join(templatePath, "Component.tsx");
|
|
82
|
-
if (existsSync(templateComponentPath)) {
|
|
83
|
-
let content = await readFile(templateComponentPath, "utf-8");
|
|
84
|
-
// Remplacement du nom du component et de la clé de traduction
|
|
85
|
-
content = content
|
|
86
|
-
.replace(/Component/g, componentNameUpper)
|
|
87
|
-
.replace(/componentPage/g, translationKey);
|
|
88
|
-
await writeFile(componentFile, content);
|
|
89
|
-
console.log(`📄 File created: ${componentFile}`);
|
|
90
|
-
} else {
|
|
91
|
-
console.error(
|
|
92
|
-
"❌ Template Component.tsx introuvable :",
|
|
93
|
-
templateComponentPath
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (useI18n && messagesPath) {
|
|
99
|
-
const entries = await readdir(messagesPath, { withFileTypes: true });
|
|
100
|
-
const langDirs = entries.filter((e) => e.isDirectory()).map((e) => e.name);
|
|
101
|
-
const jsonTemplate = join(templatePath, "component.json");
|
|
102
|
-
if (!existsSync(jsonTemplate)) {
|
|
103
|
-
console.error("❌ Template component.json not found:", jsonTemplate);
|
|
104
|
-
return;
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
const jsonContent = await readFile(jsonTemplate, "utf-8");
|
|
108
|
-
const parsed = JSON.parse(jsonContent);
|
|
109
|
-
|
|
110
|
-
for (const locale of langDirs) {
|
|
111
|
-
// Only process if messages/<locale> is a directory
|
|
112
|
-
const localeDir = join(messagesPath, locale);
|
|
113
|
-
if (!existsSync(localeDir) || !statSync(localeDir).isDirectory())
|
|
114
|
-
continue;
|
|
115
|
-
let jsonTarget;
|
|
116
|
-
if (pageScope) {
|
|
117
|
-
jsonTarget = join(messagesPath, locale, `${pageScope}.json`);
|
|
118
|
-
} else {
|
|
119
|
-
jsonTarget = join(messagesPath, locale, `_global_ui.json`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
let current: Record<string, any> = {};
|
|
123
|
-
if (existsSync(jsonTarget)) {
|
|
124
|
-
const jsonFile = await readFile(jsonTarget, "utf-8");
|
|
125
|
-
current = JSON.parse(jsonFile) as Record<string, any>;
|
|
126
|
-
}
|
|
127
|
-
current[componentNameUpper] = parsed;
|
|
128
|
-
await writeFile(jsonTarget, JSON.stringify(current, null, 2));
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
console.log("ℹ️ Skipping translation entries; next-intl not enabled.");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
console.log(
|
|
135
|
-
`✅ Component "${componentNameUpper}" added ${
|
|
136
|
-
pageScope ? `to page ${pageScope}` : "globally"
|
|
137
|
-
}${useI18n ? " with localized messages" : ""}.`
|
|
138
|
-
);
|
|
139
|
-
}
|