@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/dist/index.js
CHANGED
|
@@ -100,7 +100,8 @@ UpdateExportsCommand = update_exports_command_ts_decorate([
|
|
|
100
100
|
], UpdateExportsCommand);
|
|
101
101
|
function handleError(error, defaultMessage) {
|
|
102
102
|
const message = error instanceof Error ? error.message : defaultMessage;
|
|
103
|
-
console.error(
|
|
103
|
+
console.error(`
|
|
104
|
+
\u{274C} ${message}`);
|
|
104
105
|
}
|
|
105
106
|
function config_service_ts_decorate(decorators, target, key, desc) {
|
|
106
107
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -470,10 +471,11 @@ class create_project_use_case_CreateProjectUseCase {
|
|
|
470
471
|
}
|
|
471
472
|
createOrConfigureProject(project, configGroups) {
|
|
472
473
|
if (!project.packageJsonExists) {
|
|
473
|
-
console.log(
|
|
474
|
+
console.log(`
|
|
475
|
+
\u{1F680} Starting project creation for ${project.name}...\n`);
|
|
474
476
|
this.projectRepository.createNextProject(project.name);
|
|
475
477
|
process.chdir(project.name);
|
|
476
|
-
console.log(
|
|
478
|
+
console.log(`\u{1F4C2} Moved to ${project.name}`);
|
|
477
479
|
}
|
|
478
480
|
this.updateProjectFiles(project.directory);
|
|
479
481
|
this.commandExecutorPort.installDependencies();
|
|
@@ -491,14 +493,17 @@ class create_project_use_case_CreateProjectUseCase {
|
|
|
491
493
|
this.projectRepository.updatePostcssConfig(projectDir);
|
|
492
494
|
}
|
|
493
495
|
displaySuccessMessage(project) {
|
|
494
|
-
console.log(
|
|
496
|
+
console.log(`
|
|
497
|
+
\u{2705} Project ${project.packageJsonExists ? "configured" : "created"} successfully!`);
|
|
495
498
|
console.log(`- Project: ${project.name}`);
|
|
496
499
|
console.log("- Next.js with TypeScript");
|
|
497
500
|
console.log("- TailwindCSS and @codefast/ui");
|
|
498
501
|
console.log("- ESLint, Prettier, Commitlint, and Git Hooks");
|
|
499
502
|
console.log("- Lint-staged for pre-commit checks");
|
|
500
|
-
console.log(
|
|
501
|
-
|
|
503
|
+
console.log(`
|
|
504
|
+
\u{1F4C1} Project directory: ${process.cwd()}`);
|
|
505
|
+
console.log(`
|
|
506
|
+
\u{1F680} To start development:`);
|
|
502
507
|
console.log(`${project.packageJsonExists ? `cd ${project.name} && ` : ""}pnpm dev`);
|
|
503
508
|
}
|
|
504
509
|
}
|
|
@@ -538,7 +543,7 @@ class update_exports_use_case_UpdateExportsUseCase {
|
|
|
538
543
|
}
|
|
539
544
|
async execute(options) {
|
|
540
545
|
try {
|
|
541
|
-
console.info("
|
|
546
|
+
console.info("\u2662\u2012 Searching for packages...");
|
|
542
547
|
const packageJsonPaths = await this.packageRepository.findAllPackages(options.configPath);
|
|
543
548
|
if (0 === packageJsonPaths.length) return void console.warn("No packages found.");
|
|
544
549
|
console.log(` Found ${packageJsonPaths.length} packages.`);
|
|
@@ -551,7 +556,7 @@ class update_exports_use_case_UpdateExportsUseCase {
|
|
|
551
556
|
else if (options.packageFilter) skipCount++;
|
|
552
557
|
else errorCount++;
|
|
553
558
|
}
|
|
554
|
-
console.log("
|
|
559
|
+
console.log("\u2662\u2012 Completed exports update.\n");
|
|
555
560
|
console.info(`Stats: ${successCount} succeeded, ${skipCount} skipped, ${errorCount} failed`);
|
|
556
561
|
} catch (error) {
|
|
557
562
|
handleError(error, "Error processing packages");
|
|
@@ -679,7 +684,8 @@ class NodeCommandExecutorAdapter {
|
|
|
679
684
|
}
|
|
680
685
|
}
|
|
681
686
|
installDependencies() {
|
|
682
|
-
console.log(
|
|
687
|
+
console.log(`
|
|
688
|
+
\u{1F4DA} Installing dependencies...`);
|
|
683
689
|
const mainDependencies = this.dependencyConfigService.getMainDependencies();
|
|
684
690
|
if (mainDependencies.length > 0) this.runCommand(`pnpm add ${mainDependencies.join(" ")}`);
|
|
685
691
|
const devDependencies = this.dependencyConfigService.getDevDependencies();
|
|
@@ -687,32 +693,36 @@ class NodeCommandExecutorAdapter {
|
|
|
687
693
|
if (allDevDependencies) this.runCommand(`pnpm add -D ${allDevDependencies}`);
|
|
688
694
|
}
|
|
689
695
|
cleanupPackages() {
|
|
690
|
-
console.log(
|
|
696
|
+
console.log(`
|
|
697
|
+
\u{1F9F9} Cleaning up unnecessary packages...`);
|
|
691
698
|
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), "package.json");
|
|
692
|
-
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(
|
|
699
|
+
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(`\u{26A0}\u{FE0F} package.json not found, skipping cleanup.`);
|
|
693
700
|
let packageJson;
|
|
694
701
|
try {
|
|
695
702
|
packageJson = packageJsonSchema.parse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
696
703
|
} catch (error) {
|
|
697
|
-
console.warn(
|
|
704
|
+
console.warn(`\u{26A0}\u{FE0F} Error reading package.json: ${error instanceof Error ? error.message : "Unknown error"}, skipping cleanup.`);
|
|
698
705
|
return;
|
|
699
706
|
}
|
|
700
707
|
const dependencies = packageJson.dependencies ?? {};
|
|
701
708
|
const devDependencies = packageJson.devDependencies ?? {};
|
|
702
709
|
const packagesToRemove = this.dependencyConfigService.getPackagesToRemove().filter((pkg)=>pkg in dependencies || pkg in devDependencies);
|
|
703
710
|
if (packagesToRemove.length > 0) this.runCommand(`pnpm remove ${packagesToRemove.join(" ")}`);
|
|
704
|
-
else console.log(
|
|
711
|
+
else console.log(`\u{2139}\u{FE0F} No unnecessary packages found in package.json to remove.`);
|
|
705
712
|
}
|
|
706
713
|
enableGitHooks() {
|
|
707
|
-
console.log(
|
|
714
|
+
console.log(`
|
|
715
|
+
\u{1F504} Activating git hooks...`);
|
|
708
716
|
this.runCommand("pnpm simple-git-hooks");
|
|
709
717
|
}
|
|
710
718
|
runFormatter() {
|
|
711
|
-
console.log(
|
|
719
|
+
console.log(`
|
|
720
|
+
\u{1F4DD} Formatting files with Prettier...`);
|
|
712
721
|
this.runCommand("pnpm format");
|
|
713
722
|
}
|
|
714
723
|
runLinter() {
|
|
715
|
-
console.log(
|
|
724
|
+
console.log(`
|
|
725
|
+
\u{1F50D} Running ESLint to check code style...`);
|
|
716
726
|
this.runCommand("pnpm lint");
|
|
717
727
|
}
|
|
718
728
|
}
|
|
@@ -762,16 +772,18 @@ class NodeFileSystemAdapter {
|
|
|
762
772
|
}
|
|
763
773
|
writeConfigFile(filePath, content) {
|
|
764
774
|
this.writeFile(filePath, content);
|
|
765
|
-
console.log(
|
|
775
|
+
console.log(`\u{1F4DD} Created ${filePath}`);
|
|
766
776
|
}
|
|
767
777
|
createConfigFiles(projectDir, configGroups) {
|
|
768
|
-
console.log(
|
|
778
|
+
console.log(`
|
|
779
|
+
\u{1F4DD} Creating configuration files...`);
|
|
769
780
|
for (const [category, configs] of Object.entries(configGroups)){
|
|
770
|
-
console.log(
|
|
781
|
+
console.log(`
|
|
782
|
+
\u{1F4C2} Setting up ${category} configurations:`);
|
|
771
783
|
for (const config of configs){
|
|
772
784
|
const fullPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, config.path);
|
|
773
785
|
this.writeConfigFile(fullPath, config.content);
|
|
774
|
-
if (config.description) console.log(
|
|
786
|
+
if (config.description) console.log(`\u{2139}\u{FE0F} ${config.path}: ${config.description}`);
|
|
775
787
|
}
|
|
776
788
|
}
|
|
777
789
|
}
|
|
@@ -934,40 +946,40 @@ class FileSystemPackageRepository {
|
|
|
934
946
|
console.debug(`Skipping ${packageName} (does not match filter)`);
|
|
935
947
|
return false;
|
|
936
948
|
}
|
|
937
|
-
console.info(
|
|
949
|
+
console.info(`\u{2662}\u{2012} Processing package: ${packageName}`);
|
|
938
950
|
const config = this.getConfig(options.configPath);
|
|
939
951
|
const packageConfig = this.getPackageConfig(packageName, config);
|
|
940
952
|
const srcIndexPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(packageDir, packageConfig.srcIndexPath);
|
|
941
953
|
if (!this.fileSystemPort.exists(srcIndexPath)) {
|
|
942
|
-
console.error(
|
|
954
|
+
console.error(`\u{23B9} \u{26D4}\u{FE0E} Source file not found at ${srcIndexPath}`);
|
|
943
955
|
return false;
|
|
944
956
|
}
|
|
945
|
-
console.info(
|
|
957
|
+
console.info(`\u{23B9} Analyzing imports from ${srcIndexPath}...`);
|
|
946
958
|
const analysis = this.analyzeImports(srcIndexPath, packageConfig);
|
|
947
959
|
if (0 === analysis.imports.length) {
|
|
948
|
-
console.warn(
|
|
960
|
+
console.warn(`\u{23B9} \u{26D4}\u{FE0E} No imports found to analyze in ${packageName}`);
|
|
949
961
|
return false;
|
|
950
962
|
}
|
|
951
|
-
console.log(
|
|
963
|
+
console.log(`\u{23B9} Analysis complete. Found ${analysis.imports.length} subpath exports.`);
|
|
952
964
|
this.saveExportsAnalysis(packageDir, analysis);
|
|
953
965
|
const newExports = this.generateExports(packageName, analysis.imports, packageJson.exports ?? {}, config);
|
|
954
966
|
const currentExportsCount = packageJson.exports ? Object.keys(packageJson.exports).length : 0;
|
|
955
967
|
const newExportsCount = Object.keys(newExports).length;
|
|
956
|
-
console.info(
|
|
968
|
+
console.info(`\u{23B9} Exports: ${currentExportsCount} -> ${newExportsCount}`);
|
|
957
969
|
if (options.dryRun) {
|
|
958
970
|
this.saveExportsPreview(packageDir, newExports);
|
|
959
|
-
console.warn(
|
|
960
|
-
console.warn(
|
|
971
|
+
console.warn(`\u{23B9} Saved exports preview to .exports-analysis`);
|
|
972
|
+
console.warn(`\u{23B9} Dry run: no changes saved for ${packageName}`);
|
|
961
973
|
return true;
|
|
962
974
|
}
|
|
963
975
|
this.fileSystemUtility.backupFile(packageJsonPath, ".exports-analysis");
|
|
964
|
-
console.log(
|
|
976
|
+
console.log(`\u{23B9} Backed up ${packageJsonPath}`);
|
|
965
977
|
const updatedPackageJson = {
|
|
966
978
|
...packageJson,
|
|
967
979
|
exports: newExports
|
|
968
980
|
};
|
|
969
981
|
this.fileSystemPort.writeFile(packageJsonPath, `${JSON.stringify(updatedPackageJson, null, 2)}\n`);
|
|
970
|
-
console.log(
|
|
982
|
+
console.log(`\u{23B9} Updated exports for ${packageName}`);
|
|
971
983
|
return true;
|
|
972
984
|
}
|
|
973
985
|
analyzeImports(indexFilePath, packageConfig) {
|
|
@@ -1160,7 +1172,7 @@ import "@/app/globals.css";`;
|
|
|
1160
1172
|
}
|
|
1161
1173
|
updatePackageJson(projectDir) {
|
|
1162
1174
|
const packageJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(projectDir, "package.json");
|
|
1163
|
-
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(
|
|
1175
|
+
if (!this.fileSystemPort.exists(packageJsonPath)) return void console.warn(`\u{26A0}\u{FE0F} package.json not found, skipping update.`);
|
|
1164
1176
|
let packageJson;
|
|
1165
1177
|
try {
|
|
1166
1178
|
packageJson = packageJsonSchema.parse(JSON.parse(this.fileSystemPort.readFile(packageJsonPath)));
|
|
@@ -1187,7 +1199,7 @@ import "@/app/globals.css";`;
|
|
|
1187
1199
|
"commit-msg": "pnpm commitlint --edit"
|
|
1188
1200
|
};
|
|
1189
1201
|
this.fileSystemPort.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
1190
|
-
console.log(
|
|
1202
|
+
console.log(`\u{1F4DD} Updated ${packageJsonPath}`);
|
|
1191
1203
|
}
|
|
1192
1204
|
async getValidProjectName(initialName, attempts = 0, maxAttempts = 3) {
|
|
1193
1205
|
const projectName = initialName ?? await this.promptPort.prompt("Enter project name: ");
|
|
@@ -1207,7 +1219,7 @@ import "@/app/globals.css";`;
|
|
|
1207
1219
|
return projectName;
|
|
1208
1220
|
}
|
|
1209
1221
|
if (attempts >= maxAttempts - 1) throw new Error("Exceeded maximum attempts to enter a valid project name.");
|
|
1210
|
-
console.error(
|
|
1222
|
+
console.error(`\u{274C} ${result.error.message} (${maxAttempts - attempts - 1} attempts remaining)`);
|
|
1211
1223
|
return this.getValidProjectName(void 0, attempts + 1, maxAttempts);
|
|
1212
1224
|
}
|
|
1213
1225
|
}
|
|
@@ -1339,13 +1351,13 @@ class file_system_utility_FileSystemUtility {
|
|
|
1339
1351
|
updateFileIfNeeded(filePath, checkFn, updateFn) {
|
|
1340
1352
|
if (!this.fileSystemPort.exists(filePath)) return;
|
|
1341
1353
|
const currentContent = this.fileSystemPort.readFile(filePath);
|
|
1342
|
-
if (checkFn(currentContent)) return void console.log(
|
|
1354
|
+
if (checkFn(currentContent)) return void console.log(`\u{2139}\u{FE0F} ${filePath} is already up to date`);
|
|
1343
1355
|
try {
|
|
1344
1356
|
const updatedContent = updateFn(currentContent);
|
|
1345
1357
|
this.fileSystemPort.writeFile(filePath, updatedContent);
|
|
1346
|
-
console.log(
|
|
1358
|
+
console.log(`\u{1F4DD} Updated ${filePath}`);
|
|
1347
1359
|
} catch (error) {
|
|
1348
|
-
console.warn(
|
|
1360
|
+
console.warn(`\u{26A0}\u{FE0F} Failed to update ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1349
1361
|
}
|
|
1350
1362
|
}
|
|
1351
1363
|
backupFile(filePath, backupDir) {
|