@codefast/cli 0.3.1-canary.14 โ 0.3.1-canary.15
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 +6 -0
- package/dist/index.cjs +48 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -36
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @codefast/cli
|
|
2
2
|
|
|
3
|
+
## 0.3.1-canary.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3567101`](https://github.com/codefastlabs/codefast/commit/35671017419adc327528a7fe3fdf3cfa06328fac) Thanks [@thevuong](https://github.com/thevuong)! - chore(dependencies): update eslint and related dependencies to latest versions across packages
|
|
8
|
+
|
|
3
9
|
## 0.3.1-canary.14
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -118,7 +118,8 @@ UpdateExportsCommand = update_exports_command_ts_decorate([
|
|
|
118
118
|
], UpdateExportsCommand);
|
|
119
119
|
function handleError(error, defaultMessage) {
|
|
120
120
|
const message = error instanceof Error ? error.message : defaultMessage;
|
|
121
|
-
console.error(
|
|
121
|
+
console.error(`
|
|
122
|
+
\u{274C} ${message}`);
|
|
122
123
|
}
|
|
123
124
|
function config_service_ts_decorate(decorators, target, key, desc) {
|
|
124
125
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -488,10 +489,11 @@ class create_project_use_case_CreateProjectUseCase {
|
|
|
488
489
|
}
|
|
489
490
|
createOrConfigureProject(project, configGroups) {
|
|
490
491
|
if (!project.packageJsonExists) {
|
|
491
|
-
console.log(
|
|
492
|
+
console.log(`
|
|
493
|
+
\u{1F680} Starting project creation for ${project.name}...\n`);
|
|
492
494
|
this.projectRepository.createNextProject(project.name);
|
|
493
495
|
process.chdir(project.name);
|
|
494
|
-
console.log(
|
|
496
|
+
console.log(`\u{1F4C2} Moved to ${project.name}`);
|
|
495
497
|
}
|
|
496
498
|
this.updateProjectFiles(project.directory);
|
|
497
499
|
this.commandExecutorPort.installDependencies();
|
|
@@ -509,14 +511,17 @@ class create_project_use_case_CreateProjectUseCase {
|
|
|
509
511
|
this.projectRepository.updatePostcssConfig(projectDir);
|
|
510
512
|
}
|
|
511
513
|
displaySuccessMessage(project) {
|
|
512
|
-
console.log(
|
|
514
|
+
console.log(`
|
|
515
|
+
\u{2705} Project ${project.packageJsonExists ? "configured" : "created"} successfully!`);
|
|
513
516
|
console.log(`- Project: ${project.name}`);
|
|
514
517
|
console.log("- Next.js with TypeScript");
|
|
515
518
|
console.log("- TailwindCSS and @codefast/ui");
|
|
516
519
|
console.log("- ESLint, Prettier, Commitlint, and Git Hooks");
|
|
517
520
|
console.log("- Lint-staged for pre-commit checks");
|
|
518
|
-
console.log(
|
|
519
|
-
|
|
521
|
+
console.log(`
|
|
522
|
+
\u{1F4C1} Project directory: ${process.cwd()}`);
|
|
523
|
+
console.log(`
|
|
524
|
+
\u{1F680} To start development:`);
|
|
520
525
|
console.log(`${project.packageJsonExists ? `cd ${project.name} && ` : ""}pnpm dev`);
|
|
521
526
|
}
|
|
522
527
|
}
|
|
@@ -556,7 +561,7 @@ class update_exports_use_case_UpdateExportsUseCase {
|
|
|
556
561
|
}
|
|
557
562
|
async execute(options) {
|
|
558
563
|
try {
|
|
559
|
-
console.info("
|
|
564
|
+
console.info("\u2662\u2012 Searching for packages...");
|
|
560
565
|
const packageJsonPaths = await this.packageRepository.findAllPackages(options.configPath);
|
|
561
566
|
if (0 === packageJsonPaths.length) return void console.warn("No packages found.");
|
|
562
567
|
console.log(` Found ${packageJsonPaths.length} packages.`);
|
|
@@ -569,7 +574,7 @@ class update_exports_use_case_UpdateExportsUseCase {
|
|
|
569
574
|
else if (options.packageFilter) skipCount++;
|
|
570
575
|
else errorCount++;
|
|
571
576
|
}
|
|
572
|
-
console.log("
|
|
577
|
+
console.log("\u2662\u2012 Completed exports update.\n");
|
|
573
578
|
console.info(`Stats: ${successCount} succeeded, ${skipCount} skipped, ${errorCount} failed`);
|
|
574
579
|
} catch (error) {
|
|
575
580
|
handleError(error, "Error processing packages");
|
|
@@ -701,7 +706,8 @@ class NodeCommandExecutorAdapter {
|
|
|
701
706
|
}
|
|
702
707
|
}
|
|
703
708
|
installDependencies() {
|
|
704
|
-
console.log(
|
|
709
|
+
console.log(`
|
|
710
|
+
\u{1F4DA} Installing dependencies...`);
|
|
705
711
|
const mainDependencies = this.dependencyConfigService.getMainDependencies();
|
|
706
712
|
if (mainDependencies.length > 0) this.runCommand(`pnpm add ${mainDependencies.join(" ")}`);
|
|
707
713
|
const devDependencies = this.dependencyConfigService.getDevDependencies();
|
|
@@ -709,32 +715,36 @@ class NodeCommandExecutorAdapter {
|
|
|
709
715
|
if (allDevDependencies) this.runCommand(`pnpm add -D ${allDevDependencies}`);
|
|
710
716
|
}
|
|
711
717
|
cleanupPackages() {
|
|
712
|
-
console.log(
|
|
718
|
+
console.log(`
|
|
719
|
+
\u{1F9F9} Cleaning up unnecessary packages...`);
|
|
713
720
|
const packageJsonPath = external_node_path_default().join(process.cwd(), "package.json");
|
|
714
|
-
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(
|
|
721
|
+
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(`\u{26A0}\u{FE0F} package.json not found, skipping cleanup.`);
|
|
715
722
|
let packageJson;
|
|
716
723
|
try {
|
|
717
724
|
packageJson = packageJsonSchema.parse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
718
725
|
} catch (error) {
|
|
719
|
-
console.warn(
|
|
726
|
+
console.warn(`\u{26A0}\u{FE0F} Error reading package.json: ${error instanceof Error ? error.message : "Unknown error"}, skipping cleanup.`);
|
|
720
727
|
return;
|
|
721
728
|
}
|
|
722
729
|
const dependencies = packageJson.dependencies ?? {};
|
|
723
730
|
const devDependencies = packageJson.devDependencies ?? {};
|
|
724
731
|
const packagesToRemove = this.dependencyConfigService.getPackagesToRemove().filter((pkg)=>pkg in dependencies || pkg in devDependencies);
|
|
725
732
|
if (packagesToRemove.length > 0) this.runCommand(`pnpm remove ${packagesToRemove.join(" ")}`);
|
|
726
|
-
else console.log(
|
|
733
|
+
else console.log(`\u{2139}\u{FE0F} No unnecessary packages found in package.json to remove.`);
|
|
727
734
|
}
|
|
728
735
|
enableGitHooks() {
|
|
729
|
-
console.log(
|
|
736
|
+
console.log(`
|
|
737
|
+
\u{1F504} Activating git hooks...`);
|
|
730
738
|
this.runCommand("pnpm simple-git-hooks");
|
|
731
739
|
}
|
|
732
740
|
runFormatter() {
|
|
733
|
-
console.log(
|
|
741
|
+
console.log(`
|
|
742
|
+
\u{1F4DD} Formatting files with Prettier...`);
|
|
734
743
|
this.runCommand("pnpm format");
|
|
735
744
|
}
|
|
736
745
|
runLinter() {
|
|
737
|
-
console.log(
|
|
746
|
+
console.log(`
|
|
747
|
+
\u{1F50D} Running ESLint to check code style...`);
|
|
738
748
|
this.runCommand("pnpm lint");
|
|
739
749
|
}
|
|
740
750
|
}
|
|
@@ -786,16 +796,18 @@ class NodeFileSystemAdapter {
|
|
|
786
796
|
}
|
|
787
797
|
writeConfigFile(filePath, content) {
|
|
788
798
|
this.writeFile(filePath, content);
|
|
789
|
-
console.log(
|
|
799
|
+
console.log(`\u{1F4DD} Created ${filePath}`);
|
|
790
800
|
}
|
|
791
801
|
createConfigFiles(projectDir, configGroups) {
|
|
792
|
-
console.log(
|
|
802
|
+
console.log(`
|
|
803
|
+
\u{1F4DD} Creating configuration files...`);
|
|
793
804
|
for (const [category, configs] of Object.entries(configGroups)){
|
|
794
|
-
console.log(
|
|
805
|
+
console.log(`
|
|
806
|
+
\u{1F4C2} Setting up ${category} configurations:`);
|
|
795
807
|
for (const config of configs){
|
|
796
808
|
const fullPath = external_node_path_default().join(projectDir, config.path);
|
|
797
809
|
this.writeConfigFile(fullPath, config.content);
|
|
798
|
-
if (config.description) console.log(
|
|
810
|
+
if (config.description) console.log(`\u{2139}\u{FE0F} ${config.path}: ${config.description}`);
|
|
799
811
|
}
|
|
800
812
|
}
|
|
801
813
|
}
|
|
@@ -963,40 +975,40 @@ class FileSystemPackageRepository {
|
|
|
963
975
|
console.debug(`Skipping ${packageName} (does not match filter)`);
|
|
964
976
|
return false;
|
|
965
977
|
}
|
|
966
|
-
console.info(
|
|
978
|
+
console.info(`\u{2662}\u{2012} Processing package: ${packageName}`);
|
|
967
979
|
const config = this.getConfig(options.configPath);
|
|
968
980
|
const packageConfig = this.getPackageConfig(packageName, config);
|
|
969
981
|
const srcIndexPath = external_node_path_default().join(packageDir, packageConfig.srcIndexPath);
|
|
970
982
|
if (!this.fileSystemPort.exists(srcIndexPath)) {
|
|
971
|
-
console.error(
|
|
983
|
+
console.error(`\u{23B9} \u{26D4}\u{FE0E} Source file not found at ${srcIndexPath}`);
|
|
972
984
|
return false;
|
|
973
985
|
}
|
|
974
|
-
console.info(
|
|
986
|
+
console.info(`\u{23B9} Analyzing imports from ${srcIndexPath}...`);
|
|
975
987
|
const analysis = this.analyzeImports(srcIndexPath, packageConfig);
|
|
976
988
|
if (0 === analysis.imports.length) {
|
|
977
|
-
console.warn(
|
|
989
|
+
console.warn(`\u{23B9} \u{26D4}\u{FE0E} No imports found to analyze in ${packageName}`);
|
|
978
990
|
return false;
|
|
979
991
|
}
|
|
980
|
-
console.log(
|
|
992
|
+
console.log(`\u{23B9} Analysis complete. Found ${analysis.imports.length} subpath exports.`);
|
|
981
993
|
this.saveExportsAnalysis(packageDir, analysis);
|
|
982
994
|
const newExports = this.generateExports(packageName, analysis.imports, packageJson.exports ?? {}, config);
|
|
983
995
|
const currentExportsCount = packageJson.exports ? Object.keys(packageJson.exports).length : 0;
|
|
984
996
|
const newExportsCount = Object.keys(newExports).length;
|
|
985
|
-
console.info(
|
|
997
|
+
console.info(`\u{23B9} Exports: ${currentExportsCount} -> ${newExportsCount}`);
|
|
986
998
|
if (options.dryRun) {
|
|
987
999
|
this.saveExportsPreview(packageDir, newExports);
|
|
988
|
-
console.warn(
|
|
989
|
-
console.warn(
|
|
1000
|
+
console.warn(`\u{23B9} Saved exports preview to .exports-analysis`);
|
|
1001
|
+
console.warn(`\u{23B9} Dry run: no changes saved for ${packageName}`);
|
|
990
1002
|
return true;
|
|
991
1003
|
}
|
|
992
1004
|
this.fileSystemUtility.backupFile(packageJsonPath, ".exports-analysis");
|
|
993
|
-
console.log(
|
|
1005
|
+
console.log(`\u{23B9} Backed up ${packageJsonPath}`);
|
|
994
1006
|
const updatedPackageJson = {
|
|
995
1007
|
...packageJson,
|
|
996
1008
|
exports: newExports
|
|
997
1009
|
};
|
|
998
1010
|
this.fileSystemPort.writeFile(packageJsonPath, `${JSON.stringify(updatedPackageJson, null, 2)}\n`);
|
|
999
|
-
console.log(
|
|
1011
|
+
console.log(`\u{23B9} Updated exports for ${packageName}`);
|
|
1000
1012
|
return true;
|
|
1001
1013
|
}
|
|
1002
1014
|
analyzeImports(indexFilePath, packageConfig) {
|
|
@@ -1189,7 +1201,7 @@ import "@/app/globals.css";`;
|
|
|
1189
1201
|
}
|
|
1190
1202
|
updatePackageJson(projectDir) {
|
|
1191
1203
|
const packageJsonPath = external_node_path_default().join(projectDir, "package.json");
|
|
1192
|
-
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(
|
|
1204
|
+
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(`\u{26A0}\u{FE0F} package.json not found, skipping update.`);
|
|
1193
1205
|
let packageJson;
|
|
1194
1206
|
try {
|
|
1195
1207
|
packageJson = packageJsonSchema.parse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
@@ -1216,7 +1228,7 @@ import "@/app/globals.css";`;
|
|
|
1216
1228
|
"commit-msg": "pnpm commitlint --edit"
|
|
1217
1229
|
};
|
|
1218
1230
|
this.fileSystemPort.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
1219
|
-
console.log(
|
|
1231
|
+
console.log(`\u{1F4DD} Updated ${packageJsonPath}`);
|
|
1220
1232
|
}
|
|
1221
1233
|
async getValidProjectName(initialName, attempts = 0, maxAttempts = 3) {
|
|
1222
1234
|
const projectName = initialName ?? await this.promptPort.prompt("Enter project name: ");
|
|
@@ -1236,7 +1248,7 @@ import "@/app/globals.css";`;
|
|
|
1236
1248
|
return projectName;
|
|
1237
1249
|
}
|
|
1238
1250
|
if (attempts >= maxAttempts - 1) throw new Error("Exceeded maximum attempts to enter a valid project name.");
|
|
1239
|
-
console.error(
|
|
1251
|
+
console.error(`\u{274C} ${result.error.message} (${maxAttempts - attempts - 1} attempts remaining)`);
|
|
1240
1252
|
return this.getValidProjectName(void 0, attempts + 1, maxAttempts);
|
|
1241
1253
|
}
|
|
1242
1254
|
}
|
|
@@ -1369,13 +1381,13 @@ class file_system_utility_FileSystemUtility {
|
|
|
1369
1381
|
updateFileIfNeeded(filePath, checkFn, updateFn) {
|
|
1370
1382
|
if (!this.fileSystemPort.exists(filePath)) return;
|
|
1371
1383
|
const currentContent = this.fileSystemPort.readFile(filePath);
|
|
1372
|
-
if (checkFn(currentContent)) return void console.log(
|
|
1384
|
+
if (checkFn(currentContent)) return void console.log(`\u{2139}\u{FE0F} ${filePath} is already up to date`);
|
|
1373
1385
|
try {
|
|
1374
1386
|
const updatedContent = updateFn(currentContent);
|
|
1375
1387
|
this.fileSystemPort.writeFile(filePath, updatedContent);
|
|
1376
|
-
console.log(
|
|
1388
|
+
console.log(`\u{1F4DD} Updated ${filePath}`);
|
|
1377
1389
|
} catch (error) {
|
|
1378
|
-
console.warn(
|
|
1390
|
+
console.warn(`\u{26A0}\u{FE0F} Failed to update ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1379
1391
|
}
|
|
1380
1392
|
}
|
|
1381
1393
|
backupFile(filePath, backupDir) {
|