@codefast/cli 0.3.1-canary.3 → 0.3.1-canary.5

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/dist/index.js CHANGED
@@ -1,13 +1,394 @@
1
1
  #!/usr/bin/env node
2
2
  import * as __WEBPACK_EXTERNAL_MODULE_commander__ from "commander";
3
- import * as __WEBPACK_EXTERNAL_MODULE_glob__ from "glob";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
4
5
  import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__ from "node:readline";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_glob__ from "glob";
5
8
  import * as __WEBPACK_EXTERNAL_MODULE_ts_morph_07c7ce60__ from "ts-morph";
6
9
  import * as __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__ from "lodash-es";
7
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
8
10
  import * as __WEBPACK_EXTERNAL_MODULE_zod__ from "zod";
9
- import * as __WEBPACK_EXTERNAL_MODULE_chalk__ from "chalk";
10
11
  import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
12
+ const MAIN_DEPENDENCIES = [
13
+ "@codefast/ui",
14
+ "@codefast/hooks"
15
+ ];
16
+ const DEV_DEPENDENCIES = {
17
+ commitLint: [
18
+ "@commitlint/cli",
19
+ "@commitlint/config-conventional",
20
+ "@commitlint/types"
21
+ ],
22
+ gitTools: [
23
+ "simple-git-hooks"
24
+ ],
25
+ formatting: [
26
+ "prettier",
27
+ "prettier-plugin-packagejson",
28
+ "prettier-plugin-tailwindcss",
29
+ "lint-staged"
30
+ ],
31
+ linting: [
32
+ "@codefast/eslint-config"
33
+ ]
34
+ };
35
+ const rl = __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__.createInterface({
36
+ input: process.stdin,
37
+ output: process.stdout
38
+ });
39
+ function create_project_prompt(question) {
40
+ return new Promise((resolve)=>{
41
+ rl.question(question, (answer)=>{
42
+ resolve(answer.trim());
43
+ });
44
+ });
45
+ }
46
+ function checkEnvironment() {
47
+ try {
48
+ (0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.execSync)("pnpm --version", {
49
+ stdio: "ignore"
50
+ });
51
+ } catch {
52
+ console.error("❌ PNPM chưa được cài đặt. Vui lòng cài đặt PNPM trước.");
53
+ process.exit(1);
54
+ }
55
+ }
56
+ function validateProjectName(name) {
57
+ if (!name || /^\s*$/.test(name)) return {
58
+ valid: false,
59
+ error: "Project name cannot be empty or contain only whitespace."
60
+ };
61
+ if (name.length > 100) return {
62
+ valid: false,
63
+ error: "Project name is too long (maximum 100 characters)."
64
+ };
65
+ const npmNameRegex = /^[a-z0-9-~][a-z0-9-._~]*$/;
66
+ if (!npmNameRegex.test(name)) return {
67
+ valid: false,
68
+ error: "Project name must be URL-friendly (letters, numbers, hyphens, underscores, dots; no @ or scoped packages)."
69
+ };
70
+ if ("." === name || ".." === name) return {
71
+ valid: false,
72
+ error: "Project name cannot be '.' or '..'."
73
+ };
74
+ const reservedNames = /^(?<reserved>CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
75
+ if (reservedNames.test(name)) return {
76
+ valid: false,
77
+ error: `Project name "${name}" is a reserved system name.`
78
+ };
79
+ const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.resolve(process.cwd(), name);
80
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync(fullPath)) return {
81
+ valid: false,
82
+ error: `A directory named "${name}" already exists.`
83
+ };
84
+ try {
85
+ __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.accessSync(process.cwd(), __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.constants.W_OK);
86
+ } catch {
87
+ return {
88
+ valid: false,
89
+ error: "Cannot create project: No write permission in current directory."
90
+ };
91
+ }
92
+ return {
93
+ valid: true
94
+ };
95
+ }
96
+ async function getValidProjectName(initialName, attempts = 0, maxAttempts = 3) {
97
+ const projectName = initialName ?? await create_project_prompt("Enter project name: ");
98
+ const validation = validateProjectName(projectName);
99
+ if (validation.valid) return projectName;
100
+ if (attempts >= maxAttempts - 1) throw new Error("❌ Exceeded maximum attempts to enter a valid project name.");
101
+ console.error(`❌ ${validation.error} (${maxAttempts - attempts - 1} attempts remaining)`);
102
+ return getValidProjectName(void 0, attempts + 1, maxAttempts);
103
+ }
104
+ function runCommand(command) {
105
+ (0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.execSync)(command, {
106
+ stdio: "inherit"
107
+ });
108
+ }
109
+ function writeConfigFile(filePath, content) {
110
+ __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.writeFileSync(filePath, content);
111
+ console.log(`📝 Created ${filePath}`);
112
+ }
113
+ function updatePostcssConfig(projectDir) {
114
+ const postcssConfigPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join(projectDir, "postcss.config.mjs");
115
+ if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync(postcssConfigPath)) return void console.warn("⚠️ postcss.config.mjs not found, skipping update.");
116
+ let content = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.readFileSync(postcssConfigPath, "utf8");
117
+ const typeComment = `/** @type {import('postcss-load-config').Config} */\n`;
118
+ if (content.includes(typeComment)) console.log("📝 postcss.config.mjs already contains type comment, no changes made.");
119
+ else {
120
+ content = content.replace("const config = {", `${typeComment}const config = {`);
121
+ __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.writeFileSync(postcssConfigPath, content);
122
+ console.log("📝 Updated postcss.config.mjs with type comment.");
123
+ }
124
+ }
125
+ const configFiles = {
126
+ "commitlint.config.mjs": `/**
127
+ * @see https://commitlint.js.org/reference/configuration.html
128
+ * @type {import('@commitlint/types').UserConfig}
129
+ */
130
+ const config = {
131
+ extends: ["@commitlint/config-conventional"],
132
+ rules: {
133
+ "body-max-line-length": [2, "always", 350],
134
+ },
135
+ };
136
+
137
+ export default config;
138
+ `,
139
+ "prettier.config.mjs": `/**
140
+ * @see https://prettier.io/docs/en/configuration.html
141
+ * @type {import('prettier').Config}
142
+ */
143
+ const config = {
144
+ plugins: ["prettier-plugin-packagejson", "prettier-plugin-tailwindcss"],
145
+ printWidth: 100,
146
+ tailwindAttributes: ["classNames"],
147
+ tailwindFunctions: ["tv"],
148
+ };
149
+
150
+ export default config;
151
+ `,
152
+ "lint-staged.config.mjs": `import { relative } from "node:path";
153
+
154
+ /**
155
+ * Builds an ESLint command with the given filenames.
156
+ *
157
+ * @param {string[]} filenames - An array of filenames to be passed to the
158
+ * ESLint command.
159
+ * @returns {string} - The generated ESLint command.
160
+ */
161
+ function buildEslintCommand(filenames) {
162
+ return \`next lint --fix --max-warnings 0 --file \${filenames.map((file) => relative(import.meta.dirname, file)).
163
+ join(" --file ")}\`;
164
+ }
165
+
166
+ /**
167
+ * @see https://www.npmjs.com/package/lint-staged
168
+ * @type {import('lint-staged').Configuration}
169
+ */
170
+ const config = {
171
+ "*.{js,mjs,jsx,ts,tsx}": [buildEslintCommand, "prettier --list-different --write"],
172
+ "*.{json,css,md,mdx}": ["prettier --list-different --write"],
173
+ };
174
+
175
+ export default config;
176
+ `,
177
+ "eslint.config.mjs": `import { config } from "@codefast/eslint-config/next";
178
+ /**
179
+ * @see https://eslint.org/docs/latest/use/configure/configuration-files
180
+ * @type {import('eslint').Linter.Config[]}
181
+ */
182
+ const eslintConfig = [...config];
183
+
184
+ export default eslintConfig;
185
+ `,
186
+ "src/lib/fonts.ts": `import { cn } from "@codefast/ui";
187
+ import { Geist, Geist_Mono as GeistMono } from "next/font/google";
188
+
189
+ const fontGeistSans = Geist({
190
+ subsets: ["latin"],
191
+ variable: "--font-geist-sans",
192
+ });
193
+
194
+ const fontGeistMono = GeistMono({
195
+ subsets: ["latin"],
196
+ variable: "--font-geist-mono",
197
+ });
198
+
199
+ export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
200
+ `,
201
+ "src/app/globals.css": `@import "tailwindcss";
202
+
203
+ @import "@codefast/ui/styles.css";
204
+
205
+ @source '../../node_modules/@codefast/ui';
206
+
207
+ @custom-variant dark (&:where(.dark, .dark *));
208
+
209
+ @theme inline {
210
+ --font-sans: var(--font-geist-sans);
211
+ --font-mono: var(--font-geist-mono);
212
+ }
213
+
214
+ @layer base {
215
+ :root {
216
+ --input: var(--color-neutral-200);
217
+ --border: var(--color-neutral-200);
218
+
219
+ --ring: var(--color-neutral-400);
220
+
221
+ --background: var(--color-white);
222
+ --foreground: var(--color-neutral-950);
223
+
224
+ --primary: var(--color-sky-500);
225
+ --primary-foreground: var(--color-neutral-50);
226
+
227
+ --secondary: var(--color-neutral-100);
228
+ --secondary-foreground: var(--color-neutral-900);
229
+
230
+ --destructive: var(--color-red-600);
231
+
232
+ --accent: var(--color-neutral-100);
233
+ --accent-foreground: var(--color-neutral-900);
234
+
235
+ --muted: var(--color-neutral-100);
236
+ --muted-foreground: var(--color-neutral-500);
237
+
238
+ --popover: var(--color-white);
239
+ --popover-foreground: var(--color-neutral-950);
240
+ --popover-overlay: --alpha(var(--color-neutral-900) / 20%);
241
+
242
+ --card: var(--color-white);
243
+ --card-foreground: var(--color-neutral-950);
244
+
245
+ --sidebar: var(--color-neutral-50);
246
+ --sidebar-foreground: var(--color-neutral-950);
247
+
248
+ --sidebar-primary: var(--color-sky-500);
249
+ --sidebar-primary-foreground: var(--color-neutral-50);
250
+
251
+ --sidebar-accent: var(--color-neutral-100);
252
+ --sidebar-accent-foreground: var(--color-neutral-900);
253
+
254
+ --sidebar-border: var(--color-neutral-200);
255
+ --sidebar-ring: var(--color-neutral-400);
256
+
257
+ --chart-1: var(--color-orange-600);
258
+ --chart-2: var(--color-teal-600);
259
+ --chart-3: var(--color-cyan-600);
260
+ --chart-4: var(--color-amber-600);
261
+ --chart-5: var(--color-amber-500);
262
+ }
263
+
264
+ @variant dark {
265
+ --input: var(--color-neutral-700);
266
+ --border: --alpha(var(--color-neutral-700) / 50%);
267
+
268
+ --ring: var(--color-neutral-500);
269
+
270
+ --background: var(--color-neutral-950);
271
+ --foreground: var(--color-neutral-50);
272
+
273
+ --primary: var(--color-sky-700);
274
+ --primary-foreground: var(--color-neutral-50);
275
+
276
+ --secondary: var(--color-neutral-800);
277
+ --secondary-foreground: var(--color-neutral-50);
278
+
279
+ --destructive: var(--color-red-400);
280
+
281
+ --accent: var(--color-neutral-700);
282
+ --accent-foreground: var(--color-neutral-50);
283
+
284
+ --muted: var(--color-neutral-800);
285
+ --muted-foreground: var(--color-neutral-400);
286
+
287
+ --popover: var(--color-neutral-800);
288
+ --popover-foreground: var(--color-neutral-50);
289
+ --popover-overlay: --alpha(var(--color-neutral-900) / 80%);
290
+
291
+ --card: var(--color-neutral-900);
292
+ --card-foreground: var(--color-neutral-50);
293
+
294
+ --sidebar: var(--color-neutral-900);
295
+ --sidebar-foreground: var(--color-neutral-50);
296
+
297
+ --sidebar-primary: var(--color-sky-700);
298
+ --sidebar-primary-foreground: var(--color-neutral-50);
299
+
300
+ --sidebar-accent: var(--color-neutral-800);
301
+ --sidebar-accent-foreground: var(--color-neutral-50);
302
+
303
+ --sidebar-border: var(--color-neutral-800);
304
+ --sidebar-ring: var(--color-neutral-600);
305
+
306
+ --chart-1: var(--color-blue-700);
307
+ --chart-2: var(--color-emerald-500);
308
+ --chart-3: var(--color-amber-500);
309
+ --chart-4: var(--color-purple-500);
310
+ --chart-5: var(--color-rose-500);
311
+ }
312
+ }
313
+ `
314
+ };
315
+ function updatePackageJson(projectDir) {
316
+ const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join(projectDir, "package.json");
317
+ const packageJson = JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.readFileSync(packageJsonPath, "utf8"));
318
+ packageJson.scripts = {
319
+ ...packageJson.scripts,
320
+ format: 'prettier --write "**/*.{js,mjs,jsx,ts,tsx,json,css,md,mdx}"',
321
+ "format:check": 'prettier --check "**/*.{js,mjs,jsx,ts,tsx,json,css,md,mdx}"',
322
+ "lint:check": "next lint --max-warnings 0"
323
+ };
324
+ packageJson["simple-git-hooks"] = {
325
+ "pre-commit": "pnpm lint-staged",
326
+ "commit-msg": "pnpm commitlint --edit"
327
+ };
328
+ __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
329
+ console.log("📝 Updated package.json");
330
+ }
331
+ function createNextProject(projectName) {
332
+ console.log("📦 Creating Next.js project...");
333
+ const flags = '--ts --tailwind --eslint --app --turbo --use-pnpm --src-dir --turbopack --import-alias "@/*"';
334
+ runCommand(`npx create-next-app@latest ${projectName} ${flags}`);
335
+ }
336
+ function installDependencies() {
337
+ console.log("📚 Installing dependencies...");
338
+ if (MAIN_DEPENDENCIES.length > 0) runCommand(`pnpm add ${MAIN_DEPENDENCIES.join(" ")}`);
339
+ const allDevDependencies = Object.values(DEV_DEPENDENCIES).flat().join(" ");
340
+ if (allDevDependencies) runCommand(`pnpm add -D ${allDevDependencies}`);
341
+ }
342
+ function createConfigFiles(projectDir) {
343
+ console.log(`\n📝 Creating configuration files...`);
344
+ for (const [filePath, content] of Object.entries(configFiles)){
345
+ const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join(projectDir, filePath);
346
+ const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname(fullPath);
347
+ if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync(dir)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.mkdirSync(dir, {
348
+ recursive: true
349
+ });
350
+ writeConfigFile(fullPath, content);
351
+ }
352
+ }
353
+ function createProjectCommand(program) {
354
+ program.command("create-project [name]").description("Create a new Next.js project with recommended setup").action(async (projectNameArg)=>{
355
+ try {
356
+ checkEnvironment();
357
+ const projectName = await getValidProjectName(projectNameArg);
358
+ console.log(`\n🚀 Starting project creation for ${projectName}...\n`);
359
+ const packageJsonExists = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join(process.cwd(), "package.json"));
360
+ if (packageJsonExists) console.log(`📦 A package.json file has been detected. Skipping the Next.js project creation step.`);
361
+ else {
362
+ createNextProject(projectName);
363
+ process.chdir(projectName);
364
+ console.log(`📂 Moved to ${projectName}`);
365
+ }
366
+ updatePostcssConfig(process.cwd());
367
+ installDependencies();
368
+ createConfigFiles(process.cwd());
369
+ updatePackageJson(process.cwd());
370
+ console.log(`\n🔄 Activating git hooks...`);
371
+ runCommand("pnpm simple-git-hooks");
372
+ console.log(`\n📝 Formatting files with Prettier...`);
373
+ runCommand("pnpm format");
374
+ console.log(`\n✅ Project created successfully!`);
375
+ console.log(`- Project: ${projectName}`);
376
+ console.log("- Next.js with TypeScript");
377
+ console.log("- TailwindCSS and @codefast/ui");
378
+ console.log("- ESLint, Prettier, Commitlint, and Git Hooks");
379
+ console.log("- Lint-staged for pre-commit checks");
380
+ console.log(`\n📁 Project directory: ${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.resolve(process.cwd())}`);
381
+ console.log(`\n🚀 To start development:`);
382
+ console.log(`cd ${projectName} && pnpm dev`);
383
+ rl.close();
384
+ } catch (error) {
385
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
386
+ console.error(`\n❌ An error occurred: ${errorMessage}`);
387
+ rl.close();
388
+ process.exit(1);
389
+ }
390
+ });
391
+ }
11
392
  function makeRegexPrefixesToRemove(prefixes) {
12
393
  const prefixPattern = prefixes.join("|");
13
394
  return new RegExp(`^.?\\/?(?:${prefixPattern})\\/(.*)$`);
@@ -254,120 +635,92 @@ async function findAllPackages(config) {
254
635
  ignore: DEFAULT_IGNORE_PATTERN
255
636
  });
256
637
  }
257
- function processPackage(packageJsonPath, options, logger) {
638
+ function processPackage(packageJsonPath, options) {
258
639
  const packageDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(packageJsonPath);
259
640
  const packageJson = readPackageJson(packageJsonPath);
260
641
  if (!packageJson) {
261
- logger.error(`Failed to read ${packageJsonPath}`);
642
+ console.error(`Failed to read ${packageJsonPath}`);
262
643
  return false;
263
644
  }
264
645
  const packageName = packageJson.name;
265
646
  if (options.packageFilter && packageName !== options.packageFilter) {
266
- logger.debug(`Skipping ${packageName} (does not match filter)`);
647
+ console.debug(`Skipping ${packageName} (does not match filter)`);
267
648
  return false;
268
649
  }
269
- logger.info(`\n📦 Processing package: ${packageName}`);
650
+ console.info(`Processing package: ${packageName}`);
270
651
  const config = getConfig(options.configPath);
271
652
  const packageConfig = getPackageConfig(packageName, config);
272
653
  const srcIndexPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(packageDir, packageConfig.srcIndexPath);
273
654
  if (!fileExists(srcIndexPath)) {
274
- logger.error(`Source file not found at ${srcIndexPath}`);
655
+ console.error(`Source file not found at ${srcIndexPath}`);
275
656
  return false;
276
657
  }
277
- logger.info(`🔍 Analyzing imports from ${srcIndexPath}...`);
658
+ console.info(`Analyzing imports from ${srcIndexPath}...`);
278
659
  const { imports } = analyzeImports(srcIndexPath, packageConfig);
279
660
  if (0 === imports.length) {
280
- logger.warn(`No imports found to analyze in ${packageName}`);
661
+ console.warn(`No imports found to analyze in ${packageName}`);
281
662
  return false;
282
663
  }
283
- logger.success(`Analysis complete. Found ${imports.length} subpath exports.`);
664
+ console.log(`Analysis complete. Found ${imports.length} subpath exports.`);
284
665
  saveExportsAnalysis(packageDir, {
285
666
  imports
286
667
  });
287
668
  const newExports = generateExports(packageName, imports, packageJson.exports, config);
288
669
  const currentExportsCount = packageJson.exports ? Object.keys(packageJson.exports).length : 0;
289
670
  const newExportsCount = Object.keys(newExports).length;
290
- logger.info(`📊 Exports: ${currentExportsCount} -> ${newExportsCount}`);
671
+ console.info(`Exports: ${currentExportsCount} -> ${newExportsCount}`);
291
672
  if (options.dryRun) {
292
673
  saveExportsPreview(packageDir, newExports);
293
- logger.warn(`🧪 📄 Saved exports preview to .exports-analysis`);
294
- logger.warn(`🧪 🚫 Dry run: no changes saved for ${packageName}`);
674
+ console.warn("Saved exports preview to .exports-analysis");
675
+ console.warn(`Dry run: no changes saved for ${packageName}`);
295
676
  return true;
296
677
  }
297
- if (backupPackageJson(packageJsonPath)) logger.success(`Backed up ${packageJsonPath}`);
678
+ if (backupPackageJson(packageJsonPath)) console.log(`Backed up ${packageJsonPath}`);
298
679
  const updatedPackageJson = {
299
680
  ...packageJson,
300
681
  exports: newExports
301
682
  };
302
683
  if (savePackageJson(packageJsonPath, updatedPackageJson)) {
303
- logger.success(`Updated exports for ${packageName}`);
684
+ console.log(`Updated exports for ${packageName}`);
304
685
  return true;
305
686
  }
306
- logger.error(`Failed to update ${packageJsonPath}`);
687
+ console.error(`Failed to update ${packageJsonPath}`);
307
688
  return false;
308
689
  }
309
- async function processAllPackages(options, logger) {
690
+ async function processAllPackages(options) {
310
691
  try {
311
- logger.info("🔍 Searching for packages...");
692
+ console.info("Searching for packages...");
312
693
  const config = getConfig(options.configPath);
313
694
  const packageJsonPaths = await findAllPackages(config);
314
- if (0 === packageJsonPaths.length) return void logger.warn("⚠️ No packages found.");
315
- logger.success(`✅ Found ${packageJsonPaths.length} packages.`);
695
+ if (0 === packageJsonPaths.length) return void console.warn("No packages found.");
696
+ console.log(`Found ${packageJsonPaths.length} packages.`);
316
697
  let successCount = 0;
317
698
  let skipCount = 0;
318
699
  let errorCount = 0;
319
700
  for (const packageJsonPath of packageJsonPaths){
320
- const result = processPackage(packageJsonPath, options, logger);
701
+ const result = processPackage(packageJsonPath, options);
321
702
  if (result) successCount++;
322
703
  else if (options.packageFilter) skipCount++;
323
704
  else errorCount++;
324
705
  }
325
- logger.success("\n✅ Completed exports update.");
326
- logger.info(`📊 Stats: ${successCount} succeeded, ${skipCount} skipped, ${errorCount} failed`);
706
+ console.log("Completed exports update.");
707
+ console.info(`Stats: ${successCount} succeeded, ${skipCount} skipped, ${errorCount} failed`);
327
708
  } catch (error) {
328
- logger.error("❌ Error processing packages:", error);
709
+ console.error("Error processing packages:", error);
329
710
  throw error;
330
711
  }
331
712
  }
332
- class Logger {
333
- verbose;
334
- constructor(options = {}){
335
- this.verbose = options.verbose ?? false;
336
- }
337
- info(message, ...args) {
338
- console.log(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].blue(message), ...args);
339
- }
340
- success(message, ...args) {
341
- console.log(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].green(message), ...args);
342
- }
343
- warn(message, ...args) {
344
- console.log(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].yellow(message), ...args);
345
- }
346
- error(message, ...args) {
347
- console.error(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].red(message), ...args);
348
- }
349
- debug(message, ...args) {
350
- if (this.verbose) console.log(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].gray(message), ...args);
351
- }
352
- table(data) {
353
- console.table(data);
354
- }
355
- }
356
713
  function createUpdateExportsCommand(program) {
357
- program.command("update-exports").description("Updates exports for all packages").option("-p, --package <package>", "Filter by package name").option("-d, --dry-run", "Run without making changes").option("-v, --verbose", "Show detailed output").option("-c, --config <path>", "Path to configuration file").action(async (options)=>{
714
+ program.command("update-exports").description("Updates exports for all packages").option("-p, --package <package>", "Filter by package name").option("-d, --dry-run", "Run without making changes").option("-c, --config <path>", "Path to configuration file").action(async (options)=>{
358
715
  const processorOptions = {
359
716
  packageFilter: options.package,
360
717
  dryRun: Boolean(options.dryRun),
361
- verbose: Boolean(options.verbose),
362
718
  configPath: options.config
363
719
  };
364
- const logger = new Logger({
365
- verbose: processorOptions.verbose
366
- });
367
720
  try {
368
- await processAllPackages(processorOptions, logger);
721
+ await processAllPackages(processorOptions);
369
722
  } catch (error) {
370
- logger.error("Error processing packages:", error);
723
+ console.error("Error processing packages:", error);
371
724
  process.exit(1);
372
725
  }
373
726
  });
@@ -385,7 +738,9 @@ function main() {
385
738
  const program = new __WEBPACK_EXTERNAL_MODULE_commander__.Command();
386
739
  program.name("codefast").description("CodeFast CLI - A development toolkit for CodeFast.").version(getPackageVersion(), "-v, --version", "display CLI version");
387
740
  createUpdateExportsCommand(program);
741
+ createProjectCommand(program);
388
742
  program.action(()=>{
743
+ console.log('Use "codefast create-project" to create a new Next.js project.');
389
744
  console.log('Use "codefast update-exports" to update exports.');
390
745
  console.log('Run "codefast --help" to see all available commands.');
391
746
  program.help();