@codefast/cli 0.3.1-canary.11 ā 0.3.1-canary.13
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/CHANGELOG.md +24 -0
- package/dist/index.cjs +166 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +166 -144
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -25,9 +25,38 @@ function runCommand(command) {
|
|
|
25
25
|
stdio: "inherit"
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const FileUtils = {
|
|
29
|
+
exists (filePath) {
|
|
30
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(filePath);
|
|
31
|
+
},
|
|
32
|
+
readFile (filePath) {
|
|
33
|
+
try {
|
|
34
|
+
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, "utf8");
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new Error(`Failed to read file ${filePath}: ${getErrorMessage(error)}`);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
writeFile (filePath, content) {
|
|
40
|
+
try {
|
|
41
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(filePath, content);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new Error(`Failed to write to file ${filePath}: ${getErrorMessage(error)}`);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
writeConfigFile (filePath, content) {
|
|
47
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(filePath, content);
|
|
48
|
+
console.log(`š Created ${filePath}`);
|
|
49
|
+
},
|
|
50
|
+
validatePath (filePath, filename) {
|
|
51
|
+
if (!this.exists(filePath)) {
|
|
52
|
+
console.warn(`ā ļø ${filename} not found, skipping update.`);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function getErrorMessage(error) {
|
|
59
|
+
return error instanceof Error ? error.message : "Unknown error occurred";
|
|
31
60
|
}
|
|
32
61
|
function validateProjectName(name) {
|
|
33
62
|
if (!name || /^\s*$/.test(name)) return {
|
|
@@ -266,7 +295,6 @@ yarn-error.log*
|
|
|
266
295
|
package-lock.json
|
|
267
296
|
yarn.lock
|
|
268
297
|
pnpm-lock.yaml
|
|
269
|
-
src/app/globals.css
|
|
270
298
|
`,
|
|
271
299
|
description: ""
|
|
272
300
|
}
|
|
@@ -292,6 +320,7 @@ export default config;
|
|
|
292
320
|
{
|
|
293
321
|
path: "eslint.config.mjs",
|
|
294
322
|
content: `import { config } from "@codefast/eslint-config/next";
|
|
323
|
+
|
|
295
324
|
/**
|
|
296
325
|
* @see https://eslint.org/docs/latest/use/configure/configuration-files
|
|
297
326
|
* @type {import('eslint').Linter.Config[]}
|
|
@@ -366,6 +395,7 @@ export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
|
|
|
366
395
|
:root {
|
|
367
396
|
--font-sans: var(--font-geist-sans);
|
|
368
397
|
--font-mono: var(--font-geist-mono);
|
|
398
|
+
|
|
369
399
|
--input: var(--color-neutral-200);
|
|
370
400
|
--border: var(--color-neutral-200);
|
|
371
401
|
--ring: var(--color-neutral-400);
|
|
@@ -399,6 +429,7 @@ export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
|
|
|
399
429
|
--chart-4: var(--color-amber-600);
|
|
400
430
|
--chart-5: var(--color-amber-500);
|
|
401
431
|
}
|
|
432
|
+
|
|
402
433
|
.dark {
|
|
403
434
|
--input: var(--color-neutral-700);
|
|
404
435
|
--border: --alpha(var(--color-neutral-700) / 50%);
|
|
@@ -439,87 +470,87 @@ export const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);
|
|
|
439
470
|
}
|
|
440
471
|
]
|
|
441
472
|
};
|
|
473
|
+
function updateFileIfNeeded(filePath, filename, checkFn, updateFn, successMessage, alreadyUpdatedMessage) {
|
|
474
|
+
if (!FileUtils.validatePath(filePath, filename)) return;
|
|
475
|
+
const content = FileUtils.readFile(filePath);
|
|
476
|
+
if (checkFn(content)) return void console.log(`š ${alreadyUpdatedMessage}`);
|
|
477
|
+
try {
|
|
478
|
+
const updatedContent = updateFn(content);
|
|
479
|
+
FileUtils.writeFile(filePath, updatedContent);
|
|
480
|
+
console.log(`š ${successMessage}`);
|
|
481
|
+
} catch (error) {
|
|
482
|
+
console.warn(`ā ļø Failed to update ${filename}: ${getErrorMessage(error)}`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
442
485
|
function updatePostcssConfig(projectDir) {
|
|
443
486
|
const postcssConfigPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "postcss.config.mjs");
|
|
444
|
-
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(postcssConfigPath)) return void console.warn(`ā ļø postcss.config.mjs not found, skipping update.`);
|
|
445
|
-
let content = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(postcssConfigPath, "utf8");
|
|
446
487
|
const typeComment = `/** @type {import('postcss-load-config').Config} */\n`;
|
|
447
|
-
|
|
448
|
-
else {
|
|
449
|
-
content = content.replace("const config = {", `${typeComment}const config = {`);
|
|
450
|
-
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(postcssConfigPath, content);
|
|
451
|
-
console.log(`š Updated postcss.config.mjs with type comment.`);
|
|
452
|
-
}
|
|
488
|
+
updateFileIfNeeded(postcssConfigPath, "postcss.config.mjs", (content)=>content.includes(typeComment), (content)=>content.replace("const config = {", `${typeComment}const config = {`), "Updated postcss.config.mjs with type comment.", "postcss.config.mjs already contains type comment, no changes made.");
|
|
453
489
|
}
|
|
454
490
|
function updateLayoutFile(projectDir) {
|
|
455
491
|
const layoutPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "src/app/layout.tsx");
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
492
|
+
const htmlTarget = '<html className={cn(fontVariables, "antialiased")} lang="en">';
|
|
493
|
+
updateFileIfNeeded(layoutPath, "src/app/layout.tsx", (content)=>content.includes(htmlTarget), (content)=>{
|
|
494
|
+
const newImports = `import type { Metadata } from "next";
|
|
495
|
+
import type { JSX, ReactNode } from "react";
|
|
461
496
|
import { cn } from "@codefast/ui";
|
|
462
|
-
|
|
463
497
|
import { fontVariables } from "@/lib/fonts";
|
|
464
498
|
import "@/app/globals.css";`;
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
try {
|
|
475
|
-
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(layoutPath, content);
|
|
476
|
-
console.log(`š Updated src/app/layout.tsx to use fontVariables in html tag and removed className from body`);
|
|
477
|
-
} catch (error) {
|
|
478
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
479
|
-
console.warn(`ā ļø Failed to update src/app/layout.tsx: ${errorMessage}`);
|
|
480
|
-
}
|
|
499
|
+
let result = content;
|
|
500
|
+
result = result.replaceAll(/import\s+{[^}]+}\s+from\s+["']next\/font\/google["'];\s*/g, "");
|
|
501
|
+
result = result.replace(/const\s+geistSans\s*=[^;]+;\s*const\s+geistMono\s*=[^;]+;\s*/, "");
|
|
502
|
+
result = result.replace(/import\s+type\s+{[^}]+}\s+from\s+["']next["'];\s*import\s+["']\.\/globals\.css["'];\s*/, newImports);
|
|
503
|
+
result = result.replace(/export default function RootLayout\({\s*children,\s*}\s*:\s*Readonly<{\s*children:\s*React\.ReactNode;\s*}>\)\s*{/, "export default function RootLayout({ children }: Readonly<{ children: ReactNode }>): JSX.Element {");
|
|
504
|
+
result = result.replace(/<html\s+lang="en"\s*>/, htmlTarget);
|
|
505
|
+
result = result.replace(/<body\s+className={`[^`]*`}\s*>/, "<body>");
|
|
506
|
+
return result;
|
|
507
|
+
}, "Updated src/app/layout.tsx to use fontVariables in html tag, removed className from body, modified ReactNode import, and added return type to RootLayout", "src/app/layout.tsx already uses fontVariables in html tag, no changes made.");
|
|
481
508
|
}
|
|
482
509
|
function updatePackageJson(projectDir) {
|
|
483
510
|
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "package.json");
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
511
|
+
if (!FileUtils.validatePath(packageJsonPath, "package.json")) return;
|
|
512
|
+
try {
|
|
513
|
+
const packageJson = JSON.parse(FileUtils.readFile(packageJsonPath));
|
|
514
|
+
packageJson.scripts = {
|
|
515
|
+
...packageJson.scripts,
|
|
516
|
+
"check-types": "tsc --noEmit",
|
|
517
|
+
"deploy:preview": "vercel deploy --archive=tgz",
|
|
518
|
+
"deploy:prod": "vercel deploy --archive=tgz --prod",
|
|
519
|
+
format: "prettier --write --ignore-unknown .",
|
|
520
|
+
"format:check": "prettier --check --ignore-unknown .",
|
|
521
|
+
lint: "next lint --fix --max-warnings 0",
|
|
522
|
+
"lint:check": "next lint --max-warnings 0",
|
|
523
|
+
"package:install": "pnpm install",
|
|
524
|
+
"package:outdated": "pnpm outdated",
|
|
525
|
+
"package:upgrade": "pnpm update --latest",
|
|
526
|
+
preview: "pnpm build && pnpm start"
|
|
527
|
+
};
|
|
528
|
+
packageJson["simple-git-hooks"] = {
|
|
529
|
+
"pre-commit": "pnpm lint-staged",
|
|
530
|
+
"commit-msg": "pnpm commitlint --edit"
|
|
531
|
+
};
|
|
532
|
+
FileUtils.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
533
|
+
console.log(`š Updated package.json`);
|
|
534
|
+
} catch (error) {
|
|
535
|
+
console.warn(`ā ļø Failed to update package.json: ${getErrorMessage(error)}`);
|
|
536
|
+
}
|
|
504
537
|
}
|
|
505
538
|
function updateNextConfig(projectDir) {
|
|
506
539
|
const nextConfigPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "next.config.ts");
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (content.includes('optimizePackageImports: ["@codefast/ui"]')) return void console.log(`š next.config.ts already contains optimizePackageImports configuration, no changes made.`);
|
|
510
|
-
const configPattern = /const nextConfig: NextConfig = \{/;
|
|
511
|
-
const experimentalConfig = `const nextConfig: NextConfig = {
|
|
540
|
+
const optimizePackagesConfig = 'optimizePackageImports: ["@codefast/ui"]';
|
|
541
|
+
updateFileIfNeeded(nextConfigPath, "next.config.ts", (content)=>content.includes(optimizePackagesConfig), (content)=>content.replace(/const nextConfig: NextConfig = \{/, `const nextConfig: NextConfig = {
|
|
512
542
|
experimental: {
|
|
513
543
|
optimizePackageImports: ["@codefast/ui"],
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
544
|
+
},`), "Updated next.config.ts with optimizePackageImports configuration.", "next.config.ts already contains optimizePackageImports configuration, no changes made.");
|
|
545
|
+
}
|
|
546
|
+
function updatePageFile(projectDir) {
|
|
547
|
+
const pagePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "src/app/page.tsx");
|
|
548
|
+
updateFileIfNeeded(pagePath, "src/app/page.tsx", (content)=>content.includes("): JSX.Element"), (content)=>{
|
|
549
|
+
let result = content;
|
|
550
|
+
if (!result.includes("import type { JSX }")) result = result.includes("import type {") ? result.replace(/import type {(?<types>[^}]+)} from "react";/, 'import type {$1, JSX } from "react";') : result.includes("import {") ? result.replace(/import {/, 'import type { JSX } from "react";\n\nimport {') : `import type { JSX } from "react";\n\n${result}`;
|
|
551
|
+
result = result.replace(/export default function Home\(\) {/, "export default function Home(): JSX.Element {");
|
|
552
|
+
return result;
|
|
553
|
+
}, "Updated src/app/page.tsx to add JSX.Element return type to Home component", "src/app/page.tsx already has JSX.Element return type, no changes made.");
|
|
523
554
|
}
|
|
524
555
|
function createConfigFiles(projectDir) {
|
|
525
556
|
console.log(`\nš Creating configuration files...`);
|
|
@@ -528,10 +559,10 @@ function createConfigFiles(projectDir) {
|
|
|
528
559
|
for (const { path: filePath, content, description } of configs){
|
|
529
560
|
const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, filePath);
|
|
530
561
|
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(fullPath);
|
|
531
|
-
if (!
|
|
562
|
+
if (!FileUtils.exists(dir)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].mkdirSync(dir, {
|
|
532
563
|
recursive: true
|
|
533
564
|
});
|
|
534
|
-
writeConfigFile(fullPath, content);
|
|
565
|
+
FileUtils.writeConfigFile(fullPath, content);
|
|
535
566
|
if (description) console.log(` ā¹ļø ${filePath}: ${description}`);
|
|
536
567
|
}
|
|
537
568
|
}
|
|
@@ -550,8 +581,7 @@ function cleanupPackages() {
|
|
|
550
581
|
try {
|
|
551
582
|
packageJson = JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.readFileSync(packageJsonPath, "utf8"));
|
|
552
583
|
} catch (error) {
|
|
553
|
-
|
|
554
|
-
console.warn(`ā ļø Error reading package.json: ${errorMessage}, skipping cleanup.`);
|
|
584
|
+
console.warn(`ā ļø Error reading package.json: ${getErrorMessage(error)}, skipping cleanup.`);
|
|
555
585
|
return;
|
|
556
586
|
}
|
|
557
587
|
const dependencies = packageJson.dependencies ?? {};
|
|
@@ -575,46 +605,47 @@ function createNextProject(projectName) {
|
|
|
575
605
|
const flags = '--ts --tailwind --eslint --app --turbo --use-pnpm --src-dir --turbopack --import-alias "@/*"';
|
|
576
606
|
runCommand(`npx create-next-app@latest ${projectName} ${flags}`);
|
|
577
607
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
console.log(`š Moved to ${projectName}`);
|
|
588
|
-
}
|
|
589
|
-
updateLayoutFile(process.cwd());
|
|
590
|
-
updatePostcssConfig(process.cwd());
|
|
591
|
-
installDependencies();
|
|
592
|
-
cleanupPackages();
|
|
593
|
-
createConfigFiles(process.cwd());
|
|
594
|
-
updateNextConfig(process.cwd());
|
|
595
|
-
updatePackageJson(process.cwd());
|
|
596
|
-
console.log(`\nš Activating git hooks...`);
|
|
597
|
-
runCommand("pnpm simple-git-hooks");
|
|
598
|
-
console.log(`\nš Formatting files with Prettier...`);
|
|
599
|
-
runCommand("pnpm format");
|
|
600
|
-
console.log(`\nā
Project ${packageJsonExists ? "configured" : "created"} successfully!`);
|
|
601
|
-
console.log(`- Project: ${projectName}`);
|
|
602
|
-
console.log("- Next.js with TypeScript");
|
|
603
|
-
console.log("- TailwindCSS and @codefast/ui");
|
|
604
|
-
console.log("- ESLint, Prettier, Commitlint, and Git Hooks");
|
|
605
|
-
console.log("- Lint-staged for pre-commit checks");
|
|
606
|
-
console.log(`\nš Project directory: ${process.cwd()}`);
|
|
607
|
-
console.log(`\nš To start development:`);
|
|
608
|
-
console.log(`cd ${projectName} && pnpm dev`);
|
|
609
|
-
} catch (error) {
|
|
610
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
611
|
-
console.error(`\nā An error occurred: ${errorMessage}`);
|
|
612
|
-
process.exit(1);
|
|
613
|
-
} finally{
|
|
614
|
-
rl.close();
|
|
608
|
+
const createProjectCommand = new __WEBPACK_EXTERNAL_MODULE_commander__.Command().name("create-project [name]").description("Create a new Next.js project with recommended setup").action(async (projectNameArg)=>{
|
|
609
|
+
try {
|
|
610
|
+
checkEnvironment();
|
|
611
|
+
const { projectName, packageJsonExists } = await checkExistingProject(projectNameArg);
|
|
612
|
+
if (!packageJsonExists) {
|
|
613
|
+
console.log(`\nš Starting project creation for ${projectName}...\n`);
|
|
614
|
+
createNextProject(projectName);
|
|
615
|
+
process.chdir(projectName);
|
|
616
|
+
console.log(`š Moved to ${projectName}`);
|
|
615
617
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
+
updateLayoutFile(process.cwd());
|
|
619
|
+
updatePageFile(process.cwd());
|
|
620
|
+
updatePostcssConfig(process.cwd());
|
|
621
|
+
installDependencies();
|
|
622
|
+
cleanupPackages();
|
|
623
|
+
createConfigFiles(process.cwd());
|
|
624
|
+
updateNextConfig(process.cwd());
|
|
625
|
+
updatePackageJson(process.cwd());
|
|
626
|
+
console.log(`\nš Activating git hooks...`);
|
|
627
|
+
runCommand("pnpm simple-git-hooks");
|
|
628
|
+
console.log(`\nš Formatting files with Prettier...`);
|
|
629
|
+
runCommand("pnpm format");
|
|
630
|
+
console.log(`\nš Running ESLint to check code style...`);
|
|
631
|
+
runCommand("pnpm lint");
|
|
632
|
+
console.log(`\nā
Project ${packageJsonExists ? "configured" : "created"} successfully!`);
|
|
633
|
+
console.log(`- Project: ${projectName}`);
|
|
634
|
+
console.log("- Next.js with TypeScript");
|
|
635
|
+
console.log("- TailwindCSS and @codefast/ui");
|
|
636
|
+
console.log("- ESLint, Prettier, Commitlint, and Git Hooks");
|
|
637
|
+
console.log("- Lint-staged for pre-commit checks");
|
|
638
|
+
console.log(`\nš Project directory: ${process.cwd()}`);
|
|
639
|
+
console.log(`\nš To start development:`);
|
|
640
|
+
console.log(`cd ${projectName} && pnpm dev`);
|
|
641
|
+
} catch (error) {
|
|
642
|
+
console.error(`\nā An error occurred: ${getErrorMessage(error)}`);
|
|
643
|
+
process.exit(1);
|
|
644
|
+
} finally{
|
|
645
|
+
rl.close();
|
|
646
|
+
process.exit(0);
|
|
647
|
+
}
|
|
648
|
+
});
|
|
618
649
|
function makeRegexPrefixesToRemove(prefixes) {
|
|
619
650
|
const prefixPattern = prefixes.join("|");
|
|
620
651
|
return new RegExp(`^.?\\/?(?:${prefixPattern})\\/(.*)$`);
|
|
@@ -743,7 +774,7 @@ const EXPORTS_PREVIEW_FILE = "exports-preview.json";
|
|
|
743
774
|
const EXPORTS_ANALYSIS_FILE = "exports-analysis.json";
|
|
744
775
|
const ENCODING = "utf8";
|
|
745
776
|
const JSON_INDENT = 2;
|
|
746
|
-
const
|
|
777
|
+
const file_utils_FileUtils = {
|
|
747
778
|
exists (filePath) {
|
|
748
779
|
return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(filePath);
|
|
749
780
|
},
|
|
@@ -781,19 +812,19 @@ const FileUtils = {
|
|
|
781
812
|
}
|
|
782
813
|
};
|
|
783
814
|
function fileExists(filePath) {
|
|
784
|
-
return
|
|
815
|
+
return file_utils_FileUtils.exists(filePath);
|
|
785
816
|
}
|
|
786
817
|
function readPackageJson(filePath) {
|
|
787
|
-
return
|
|
818
|
+
return file_utils_FileUtils.readJsonFile(filePath);
|
|
788
819
|
}
|
|
789
820
|
function backupPackageJson(filePath) {
|
|
790
821
|
try {
|
|
791
822
|
const content = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, ENCODING);
|
|
792
823
|
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(filePath);
|
|
793
824
|
const backupDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, EXPORTS_ANALYSIS_DIR);
|
|
794
|
-
|
|
825
|
+
file_utils_FileUtils.ensureDirectoryExists(backupDir);
|
|
795
826
|
const baseName = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
796
|
-
const backupPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(backupDir,
|
|
827
|
+
const backupPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(backupDir, file_utils_FileUtils.createBackupFilename(baseName));
|
|
797
828
|
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(backupPath, content, ENCODING);
|
|
798
829
|
return true;
|
|
799
830
|
} catch (error) {
|
|
@@ -802,11 +833,11 @@ function backupPackageJson(filePath) {
|
|
|
802
833
|
}
|
|
803
834
|
}
|
|
804
835
|
function savePackageJson(filePath, content) {
|
|
805
|
-
return
|
|
836
|
+
return file_utils_FileUtils.writeJsonFile(filePath, content);
|
|
806
837
|
}
|
|
807
838
|
function saveJsonToFile(packageDir, fileName, content) {
|
|
808
|
-
const outputDir =
|
|
809
|
-
|
|
839
|
+
const outputDir = file_utils_FileUtils.getAnalysisDir(packageDir);
|
|
840
|
+
file_utils_FileUtils.writeJsonFile(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(outputDir, fileName), content);
|
|
810
841
|
}
|
|
811
842
|
function saveExportsAnalysis(packageDir, analysis) {
|
|
812
843
|
saveJsonToFile(packageDir, EXPORTS_ANALYSIS_FILE, analysis);
|
|
@@ -936,21 +967,21 @@ async function processAllPackages(options) {
|
|
|
936
967
|
throw error;
|
|
937
968
|
}
|
|
938
969
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}
|
|
953
|
-
}
|
|
970
|
+
const updateExportsCommand = new __WEBPACK_EXTERNAL_MODULE_commander__.Command().name("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)=>{
|
|
971
|
+
const processorOptions = {
|
|
972
|
+
packageFilter: options.package,
|
|
973
|
+
dryRun: Boolean(options.dryRun),
|
|
974
|
+
configPath: options.config
|
|
975
|
+
};
|
|
976
|
+
try {
|
|
977
|
+
await processAllPackages(processorOptions);
|
|
978
|
+
} catch (error) {
|
|
979
|
+
console.error("Error processing packages:", error);
|
|
980
|
+
process.exit(1);
|
|
981
|
+
} finally{
|
|
982
|
+
process.exit(0);
|
|
983
|
+
}
|
|
984
|
+
});
|
|
954
985
|
function getPackageInfo() {
|
|
955
986
|
const __filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url);
|
|
956
987
|
const __dirname = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(__filename);
|
|
@@ -962,16 +993,7 @@ function getPackageVersion() {
|
|
|
962
993
|
}
|
|
963
994
|
function main() {
|
|
964
995
|
const program = new __WEBPACK_EXTERNAL_MODULE_commander__.Command();
|
|
965
|
-
program.name("codefast").description("CodeFast CLI - A development toolkit for CodeFast.").version(getPackageVersion(), "-v, --version", "display CLI version");
|
|
966
|
-
createUpdateExportsCommand(program);
|
|
967
|
-
createProjectCommand(program);
|
|
968
|
-
program.action(()=>{
|
|
969
|
-
console.log('Use "codefast create-project" to create a new Next.js project.');
|
|
970
|
-
console.log('Use "codefast update-exports" to update exports.');
|
|
971
|
-
console.log('Run "codefast --help" to see all available commands.');
|
|
972
|
-
program.help();
|
|
973
|
-
});
|
|
974
|
-
program.parse(process.argv);
|
|
996
|
+
program.name("codefast").description("CodeFast CLI - A development toolkit for CodeFast.").version(getPackageVersion(), "-v, --version", "display CLI version").addCommand(updateExportsCommand).addCommand(createProjectCommand).parse(process.argv);
|
|
975
997
|
}
|
|
976
998
|
main();
|
|
977
999
|
|