@svton/cli 1.2.5 → 1.3.0
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 +94 -30
- package/dist/index.mjs +94 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -729,21 +729,53 @@ function collectEnvVars(features, config) {
|
|
|
729
729
|
}
|
|
730
730
|
async function generateEnvExample(features, config, targetPath) {
|
|
731
731
|
const envVars = collectEnvVars(features, config);
|
|
732
|
+
if (envVars.length === 0) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
732
735
|
const content = [
|
|
736
|
+
"# ========================================",
|
|
733
737
|
"# Environment Variables",
|
|
738
|
+
"# ========================================",
|
|
734
739
|
"# Copy this file to .env and fill in the values",
|
|
740
|
+
"#",
|
|
741
|
+
"# IMPORTANT: Never commit .env file to version control!",
|
|
742
|
+
"# Add .env to your .gitignore file",
|
|
743
|
+
"#",
|
|
735
744
|
"",
|
|
736
|
-
|
|
737
|
-
|
|
745
|
+
"# ========================================",
|
|
746
|
+
"# Application Configuration",
|
|
747
|
+
"# ========================================",
|
|
748
|
+
"NODE_ENV=development",
|
|
749
|
+
"PORT=3000",
|
|
750
|
+
"",
|
|
751
|
+
"# ========================================",
|
|
752
|
+
"# Database Configuration",
|
|
753
|
+
"# ========================================",
|
|
754
|
+
"DATABASE_URL=mysql://root:root123456@localhost:3306/{{PROJECT_NAME}}",
|
|
755
|
+
""
|
|
756
|
+
];
|
|
757
|
+
const featureGroups = {};
|
|
758
|
+
for (const featureKey of features) {
|
|
759
|
+
const feature = config.features[featureKey];
|
|
760
|
+
if (feature && feature.envVars.length > 0) {
|
|
761
|
+
featureGroups[feature.name] = feature.envVars;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
for (const [featureName, vars] of Object.entries(featureGroups)) {
|
|
765
|
+
content.push("# ========================================");
|
|
766
|
+
content.push(`# ${featureName} Configuration`);
|
|
767
|
+
content.push("# ========================================");
|
|
768
|
+
for (const envVar of vars) {
|
|
738
769
|
if (envVar.description) {
|
|
739
|
-
|
|
770
|
+
content.push(`# ${envVar.description}`);
|
|
740
771
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
await import_fs_extra4.default.
|
|
772
|
+
content.push(`${envVar.key}=${envVar.default}`);
|
|
773
|
+
content.push("");
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
const envPath = import_path3.default.join(targetPath, "apps/backend/.env.example");
|
|
777
|
+
await import_fs_extra4.default.ensureDir(import_path3.default.dirname(envPath));
|
|
778
|
+
await import_fs_extra4.default.writeFile(envPath, content.join("\n"));
|
|
747
779
|
logger.info("Generated .env.example");
|
|
748
780
|
}
|
|
749
781
|
async function copyConfigFiles(features, config, templateDir, targetPath) {
|
|
@@ -884,30 +916,62 @@ function generateModuleRegistrations(features, config) {
|
|
|
884
916
|
return registrations.join("\n");
|
|
885
917
|
}
|
|
886
918
|
async function updateAppModule(features, config, targetPath) {
|
|
887
|
-
|
|
888
|
-
if (!await import_fs_extra4.default.pathExists(appModulePath)) {
|
|
889
|
-
logger.warn("app.module.ts not found, skipping module injection");
|
|
919
|
+
if (features.length === 0) {
|
|
890
920
|
return;
|
|
891
921
|
}
|
|
892
|
-
let content = await import_fs_extra4.default.readFile(appModulePath, "utf-8");
|
|
893
922
|
const imports = generateModuleImports(features, config);
|
|
894
923
|
const registrations = generateModuleRegistrations(features, config);
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
924
|
+
const content = `# \u529F\u80FD\u6A21\u5757\u96C6\u6210\u8BF4\u660E
|
|
925
|
+
|
|
926
|
+
\u672C\u6587\u6863\u8BF4\u660E\u5982\u4F55\u5C06\u9009\u4E2D\u7684\u529F\u80FD\u6A21\u5757\u96C6\u6210\u5230 app.module.ts \u4E2D\u3002
|
|
927
|
+
|
|
928
|
+
## 1. \u6DFB\u52A0\u5BFC\u5165\u8BED\u53E5
|
|
929
|
+
|
|
930
|
+
\u5728 \`apps/backend/src/app.module.ts\` \u6587\u4EF6\u9876\u90E8\u6DFB\u52A0\u4EE5\u4E0B\u5BFC\u5165\uFF1A
|
|
931
|
+
|
|
932
|
+
\`\`\`typescript
|
|
933
|
+
${imports}
|
|
934
|
+
\`\`\`
|
|
935
|
+
|
|
936
|
+
## 2. \u6CE8\u518C\u6A21\u5757
|
|
937
|
+
|
|
938
|
+
\u5728 \`@Module\` \u88C5\u9970\u5668\u7684 \`imports\` \u6570\u7EC4\u4E2D\u6DFB\u52A0\u4EE5\u4E0B\u6A21\u5757\uFF1A
|
|
939
|
+
|
|
940
|
+
\`\`\`typescript
|
|
941
|
+
@Module({
|
|
942
|
+
imports: [
|
|
943
|
+
// ... \u5176\u4ED6\u6A21\u5757
|
|
944
|
+
${registrations}
|
|
945
|
+
],
|
|
946
|
+
// ...
|
|
947
|
+
})
|
|
948
|
+
export class AppModule {}
|
|
949
|
+
\`\`\`
|
|
950
|
+
|
|
951
|
+
## 3. \u914D\u7F6E\u6587\u4EF6
|
|
952
|
+
|
|
953
|
+
\u6BCF\u4E2A\u529F\u80FD\u7684\u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210\u5728 \`apps/backend/src/config/\` \u76EE\u5F55\u4E0B\uFF1A
|
|
954
|
+
|
|
955
|
+
${features.map((key) => {
|
|
956
|
+
const feature = config.features[key];
|
|
957
|
+
return `- **${feature.name}**: \`src/config/${key}.config.ts\``;
|
|
958
|
+
}).join("\n")}
|
|
959
|
+
|
|
960
|
+
## 4. \u793A\u4F8B\u4EE3\u7801
|
|
961
|
+
|
|
962
|
+
\u793A\u4F8B\u4EE3\u7801\u5DF2\u751F\u6210\u5728 \`apps/backend/src/examples/\` \u76EE\u5F55\u4E0B\uFF0C\u53EF\u4EE5\u53C2\u8003\u4F7F\u7528\u3002
|
|
963
|
+
|
|
964
|
+
## 5. \u73AF\u5883\u53D8\u91CF
|
|
965
|
+
|
|
966
|
+
\u8BF7\u590D\u5236 \`.env.example\` \u4E3A \`.env\` \u5E76\u586B\u5199\u76F8\u5E94\u7684\u914D\u7F6E\u503C\u3002
|
|
967
|
+
|
|
968
|
+
## 6. \u66F4\u591A\u6587\u6863
|
|
969
|
+
|
|
970
|
+
\u67E5\u770B \`.kiro/skills/\` \u76EE\u5F55\u4E0B\u7684\u8BE6\u7EC6\u6587\u6863\u4E86\u89E3\u6BCF\u4E2A\u529F\u80FD\u7684\u4F7F\u7528\u65B9\u6CD5\u3002
|
|
971
|
+
`;
|
|
972
|
+
const docPath = import_path3.default.join(targetPath, "apps/backend/FEATURE_INTEGRATION.md");
|
|
973
|
+
await import_fs_extra4.default.writeFile(docPath, content);
|
|
974
|
+
logger.info("Generated feature integration guide: apps/backend/FEATURE_INTEGRATION.md");
|
|
911
975
|
}
|
|
912
976
|
|
|
913
977
|
// src/commands/create.ts
|
|
@@ -1115,7 +1179,7 @@ async function createProjectFromTemplate(config) {
|
|
|
1115
1179
|
}
|
|
1116
1180
|
|
|
1117
1181
|
// package.json
|
|
1118
|
-
var version = "1.
|
|
1182
|
+
var version = "1.3.0";
|
|
1119
1183
|
|
|
1120
1184
|
// src/index.ts
|
|
1121
1185
|
async function cli() {
|
package/dist/index.mjs
CHANGED
|
@@ -702,21 +702,53 @@ function collectEnvVars(features, config) {
|
|
|
702
702
|
}
|
|
703
703
|
async function generateEnvExample(features, config, targetPath) {
|
|
704
704
|
const envVars = collectEnvVars(features, config);
|
|
705
|
+
if (envVars.length === 0) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
705
708
|
const content = [
|
|
709
|
+
"# ========================================",
|
|
706
710
|
"# Environment Variables",
|
|
711
|
+
"# ========================================",
|
|
707
712
|
"# Copy this file to .env and fill in the values",
|
|
713
|
+
"#",
|
|
714
|
+
"# IMPORTANT: Never commit .env file to version control!",
|
|
715
|
+
"# Add .env to your .gitignore file",
|
|
716
|
+
"#",
|
|
708
717
|
"",
|
|
709
|
-
|
|
710
|
-
|
|
718
|
+
"# ========================================",
|
|
719
|
+
"# Application Configuration",
|
|
720
|
+
"# ========================================",
|
|
721
|
+
"NODE_ENV=development",
|
|
722
|
+
"PORT=3000",
|
|
723
|
+
"",
|
|
724
|
+
"# ========================================",
|
|
725
|
+
"# Database Configuration",
|
|
726
|
+
"# ========================================",
|
|
727
|
+
"DATABASE_URL=mysql://root:root123456@localhost:3306/{{PROJECT_NAME}}",
|
|
728
|
+
""
|
|
729
|
+
];
|
|
730
|
+
const featureGroups = {};
|
|
731
|
+
for (const featureKey of features) {
|
|
732
|
+
const feature = config.features[featureKey];
|
|
733
|
+
if (feature && feature.envVars.length > 0) {
|
|
734
|
+
featureGroups[feature.name] = feature.envVars;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
for (const [featureName, vars] of Object.entries(featureGroups)) {
|
|
738
|
+
content.push("# ========================================");
|
|
739
|
+
content.push(`# ${featureName} Configuration`);
|
|
740
|
+
content.push("# ========================================");
|
|
741
|
+
for (const envVar of vars) {
|
|
711
742
|
if (envVar.description) {
|
|
712
|
-
|
|
743
|
+
content.push(`# ${envVar.description}`);
|
|
713
744
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
await fs4.
|
|
745
|
+
content.push(`${envVar.key}=${envVar.default}`);
|
|
746
|
+
content.push("");
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
const envPath = path3.join(targetPath, "apps/backend/.env.example");
|
|
750
|
+
await fs4.ensureDir(path3.dirname(envPath));
|
|
751
|
+
await fs4.writeFile(envPath, content.join("\n"));
|
|
720
752
|
logger.info("Generated .env.example");
|
|
721
753
|
}
|
|
722
754
|
async function copyConfigFiles(features, config, templateDir, targetPath) {
|
|
@@ -857,30 +889,62 @@ function generateModuleRegistrations(features, config) {
|
|
|
857
889
|
return registrations.join("\n");
|
|
858
890
|
}
|
|
859
891
|
async function updateAppModule(features, config, targetPath) {
|
|
860
|
-
|
|
861
|
-
if (!await fs4.pathExists(appModulePath)) {
|
|
862
|
-
logger.warn("app.module.ts not found, skipping module injection");
|
|
892
|
+
if (features.length === 0) {
|
|
863
893
|
return;
|
|
864
894
|
}
|
|
865
|
-
let content = await fs4.readFile(appModulePath, "utf-8");
|
|
866
895
|
const imports = generateModuleImports(features, config);
|
|
867
896
|
const registrations = generateModuleRegistrations(features, config);
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
897
|
+
const content = `# \u529F\u80FD\u6A21\u5757\u96C6\u6210\u8BF4\u660E
|
|
898
|
+
|
|
899
|
+
\u672C\u6587\u6863\u8BF4\u660E\u5982\u4F55\u5C06\u9009\u4E2D\u7684\u529F\u80FD\u6A21\u5757\u96C6\u6210\u5230 app.module.ts \u4E2D\u3002
|
|
900
|
+
|
|
901
|
+
## 1. \u6DFB\u52A0\u5BFC\u5165\u8BED\u53E5
|
|
902
|
+
|
|
903
|
+
\u5728 \`apps/backend/src/app.module.ts\` \u6587\u4EF6\u9876\u90E8\u6DFB\u52A0\u4EE5\u4E0B\u5BFC\u5165\uFF1A
|
|
904
|
+
|
|
905
|
+
\`\`\`typescript
|
|
906
|
+
${imports}
|
|
907
|
+
\`\`\`
|
|
908
|
+
|
|
909
|
+
## 2. \u6CE8\u518C\u6A21\u5757
|
|
910
|
+
|
|
911
|
+
\u5728 \`@Module\` \u88C5\u9970\u5668\u7684 \`imports\` \u6570\u7EC4\u4E2D\u6DFB\u52A0\u4EE5\u4E0B\u6A21\u5757\uFF1A
|
|
912
|
+
|
|
913
|
+
\`\`\`typescript
|
|
914
|
+
@Module({
|
|
915
|
+
imports: [
|
|
916
|
+
// ... \u5176\u4ED6\u6A21\u5757
|
|
917
|
+
${registrations}
|
|
918
|
+
],
|
|
919
|
+
// ...
|
|
920
|
+
})
|
|
921
|
+
export class AppModule {}
|
|
922
|
+
\`\`\`
|
|
923
|
+
|
|
924
|
+
## 3. \u914D\u7F6E\u6587\u4EF6
|
|
925
|
+
|
|
926
|
+
\u6BCF\u4E2A\u529F\u80FD\u7684\u914D\u7F6E\u6587\u4EF6\u5DF2\u751F\u6210\u5728 \`apps/backend/src/config/\` \u76EE\u5F55\u4E0B\uFF1A
|
|
927
|
+
|
|
928
|
+
${features.map((key) => {
|
|
929
|
+
const feature = config.features[key];
|
|
930
|
+
return `- **${feature.name}**: \`src/config/${key}.config.ts\``;
|
|
931
|
+
}).join("\n")}
|
|
932
|
+
|
|
933
|
+
## 4. \u793A\u4F8B\u4EE3\u7801
|
|
934
|
+
|
|
935
|
+
\u793A\u4F8B\u4EE3\u7801\u5DF2\u751F\u6210\u5728 \`apps/backend/src/examples/\` \u76EE\u5F55\u4E0B\uFF0C\u53EF\u4EE5\u53C2\u8003\u4F7F\u7528\u3002
|
|
936
|
+
|
|
937
|
+
## 5. \u73AF\u5883\u53D8\u91CF
|
|
938
|
+
|
|
939
|
+
\u8BF7\u590D\u5236 \`.env.example\` \u4E3A \`.env\` \u5E76\u586B\u5199\u76F8\u5E94\u7684\u914D\u7F6E\u503C\u3002
|
|
940
|
+
|
|
941
|
+
## 6. \u66F4\u591A\u6587\u6863
|
|
942
|
+
|
|
943
|
+
\u67E5\u770B \`.kiro/skills/\` \u76EE\u5F55\u4E0B\u7684\u8BE6\u7EC6\u6587\u6863\u4E86\u89E3\u6BCF\u4E2A\u529F\u80FD\u7684\u4F7F\u7528\u65B9\u6CD5\u3002
|
|
944
|
+
`;
|
|
945
|
+
const docPath = path3.join(targetPath, "apps/backend/FEATURE_INTEGRATION.md");
|
|
946
|
+
await fs4.writeFile(docPath, content);
|
|
947
|
+
logger.info("Generated feature integration guide: apps/backend/FEATURE_INTEGRATION.md");
|
|
884
948
|
}
|
|
885
949
|
|
|
886
950
|
// src/commands/create.ts
|
|
@@ -1088,7 +1152,7 @@ async function createProjectFromTemplate(config) {
|
|
|
1088
1152
|
}
|
|
1089
1153
|
|
|
1090
1154
|
// package.json
|
|
1091
|
-
var version = "1.
|
|
1155
|
+
var version = "1.3.0";
|
|
1092
1156
|
|
|
1093
1157
|
// src/index.ts
|
|
1094
1158
|
async function cli() {
|