create-blitzpack 0.1.11 → 0.1.12
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 +50 -119
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -525,6 +525,43 @@ var TESTING_ROOT_DEVDEPS = [
|
|
|
525
525
|
];
|
|
526
526
|
var TESTING_APP_DEVDEPS = ["vitest", "vite-tsconfig-paths"];
|
|
527
527
|
var UPLOADS_API_DEPS = ["@aws-sdk/client-s3", "sharp"];
|
|
528
|
+
var MARKER_FILES = [
|
|
529
|
+
"apps/api/src/app.ts",
|
|
530
|
+
"apps/api/src/plugins/services.ts",
|
|
531
|
+
"apps/api/prisma/schema.prisma"
|
|
532
|
+
];
|
|
533
|
+
function stripFeatureBlocks(content, disabledFeatures) {
|
|
534
|
+
const lines = content.split("\n");
|
|
535
|
+
const result = [];
|
|
536
|
+
let skipUntilEnd = false;
|
|
537
|
+
let currentFeature = null;
|
|
538
|
+
for (const line of lines) {
|
|
539
|
+
const featureStart = line.match(/\/\/\s*@feature\s+(\w+)/);
|
|
540
|
+
const featureEnd = line.match(/\/\/\s*@endfeature/);
|
|
541
|
+
if (featureStart) {
|
|
542
|
+
const feature = featureStart[1];
|
|
543
|
+
if (disabledFeatures.includes(feature)) {
|
|
544
|
+
skipUntilEnd = true;
|
|
545
|
+
currentFeature = feature;
|
|
546
|
+
}
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
if (featureEnd) {
|
|
550
|
+
if (skipUntilEnd) {
|
|
551
|
+
skipUntilEnd = false;
|
|
552
|
+
currentFeature = null;
|
|
553
|
+
}
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
if (!skipUntilEnd) {
|
|
557
|
+
result.push(line);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return result.join("\n");
|
|
561
|
+
}
|
|
562
|
+
function cleanEmptyLines(content) {
|
|
563
|
+
return content.replace(/\n{3,}/g, "\n\n");
|
|
564
|
+
}
|
|
528
565
|
function transformPackageJson(content, vars, filePath, features) {
|
|
529
566
|
const pkg = JSON.parse(content);
|
|
530
567
|
if (filePath === "package.json") {
|
|
@@ -656,15 +693,22 @@ async function transformFiles(targetDir, vars, features) {
|
|
|
656
693
|
await applyFeatureTransforms(targetDir, features);
|
|
657
694
|
}
|
|
658
695
|
async function applyFeatureTransforms(targetDir, features) {
|
|
696
|
+
const disabledFeatures = [];
|
|
697
|
+
if (!features.testing) disabledFeatures.push("testing");
|
|
698
|
+
if (!features.admin) disabledFeatures.push("admin");
|
|
699
|
+
if (!features.uploads) disabledFeatures.push("uploads");
|
|
700
|
+
for (const relativePath of MARKER_FILES) {
|
|
701
|
+
const filePath = path3.join(targetDir, relativePath);
|
|
702
|
+
if (await fs2.pathExists(filePath)) {
|
|
703
|
+
let content = await fs2.readFile(filePath, "utf-8");
|
|
704
|
+
content = stripFeatureBlocks(content, disabledFeatures);
|
|
705
|
+
content = cleanEmptyLines(content);
|
|
706
|
+
await fs2.writeFile(filePath, content);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
659
709
|
if (!features.testing) {
|
|
660
710
|
await transformForNoTesting(targetDir);
|
|
661
711
|
}
|
|
662
|
-
if (!features.admin) {
|
|
663
|
-
await transformForNoAdmin(targetDir);
|
|
664
|
-
}
|
|
665
|
-
if (!features.uploads) {
|
|
666
|
-
await transformForNoUploads(targetDir);
|
|
667
|
-
}
|
|
668
712
|
}
|
|
669
713
|
async function transformForNoTesting(targetDir) {
|
|
670
714
|
const turboPath = path3.join(targetDir, "turbo.json");
|
|
@@ -683,119 +727,6 @@ async function transformForNoTesting(targetDir) {
|
|
|
683
727
|
await fs2.writeFile(huskyPath, "pnpm typecheck\n");
|
|
684
728
|
}
|
|
685
729
|
}
|
|
686
|
-
async function transformForNoAdmin(targetDir) {
|
|
687
|
-
const appPath = path3.join(targetDir, "apps/api/src/app.ts");
|
|
688
|
-
if (await fs2.pathExists(appPath)) {
|
|
689
|
-
let content = await fs2.readFile(appPath, "utf-8");
|
|
690
|
-
content = content.replace(
|
|
691
|
-
/import { metricsService } from '@\/services\/metrics\.service';\n/,
|
|
692
|
-
""
|
|
693
|
-
);
|
|
694
|
-
content = content.replace(
|
|
695
|
-
/const { default: statsRoutes } = await import\('@\/routes\/stats\.js'\);\n/,
|
|
696
|
-
""
|
|
697
|
-
);
|
|
698
|
-
content = content.replace(
|
|
699
|
-
/const { default: metricsRoutes } = await import\('@\/routes\/metrics\.js'\);\n/,
|
|
700
|
-
""
|
|
701
|
-
);
|
|
702
|
-
content = content.replace(
|
|
703
|
-
/const { default: adminSessionsRoutes } = await import\(\n\s*'@\/routes\/admin-sessions\.js'\n\s*\);\n/,
|
|
704
|
-
""
|
|
705
|
-
);
|
|
706
|
-
content = content.replace(/metricsService\.start\(\);\n\n/, "");
|
|
707
|
-
content = content.replace(
|
|
708
|
-
/\s*metricsService\.recordRequest\(responseTime, reply\.statusCode\);\n/,
|
|
709
|
-
""
|
|
710
|
-
);
|
|
711
|
-
content = content.replace(/\s*await app\.register\(statsRoutes\);/g, "");
|
|
712
|
-
content = content.replace(/\s*await app\.register\(metricsRoutes\);/g, "");
|
|
713
|
-
content = content.replace(
|
|
714
|
-
/\s*await app\.register\(adminSessionsRoutes\);/g,
|
|
715
|
-
""
|
|
716
|
-
);
|
|
717
|
-
await fs2.writeFile(appPath, content);
|
|
718
|
-
}
|
|
719
|
-
const servicesPath = path3.join(targetDir, "apps/api/src/plugins/services.ts");
|
|
720
|
-
if (await fs2.pathExists(servicesPath)) {
|
|
721
|
-
let content = await fs2.readFile(servicesPath, "utf-8");
|
|
722
|
-
content = content.replace(
|
|
723
|
-
/import { StatsService } from '@\/services\/stats\.service';\n/,
|
|
724
|
-
""
|
|
725
|
-
);
|
|
726
|
-
content = content.replace(
|
|
727
|
-
/\s*const statsService = new StatsService\(app\.prisma, app\.logger\);/,
|
|
728
|
-
""
|
|
729
|
-
);
|
|
730
|
-
content = content.replace(
|
|
731
|
-
/\s*app\.decorate\('statsService', statsService\);/,
|
|
732
|
-
""
|
|
733
|
-
);
|
|
734
|
-
content = content.replace(/\s*statsService: StatsService;/, "");
|
|
735
|
-
await fs2.writeFile(servicesPath, content);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
async function transformForNoUploads(targetDir) {
|
|
739
|
-
const appPath = path3.join(targetDir, "apps/api/src/app.ts");
|
|
740
|
-
if (await fs2.pathExists(appPath)) {
|
|
741
|
-
let content = await fs2.readFile(appPath, "utf-8");
|
|
742
|
-
content = content.replace(
|
|
743
|
-
/const { default: uploadsRoutes } = await import\('@\/routes\/uploads\.js'\);\n/,
|
|
744
|
-
""
|
|
745
|
-
);
|
|
746
|
-
content = content.replace(
|
|
747
|
-
/const { default: uploadsServeRoutes } = await import\(\n\s*'@\/routes\/uploads-serve\.js'\n\s*\);\n/,
|
|
748
|
-
""
|
|
749
|
-
);
|
|
750
|
-
content = content.replace(
|
|
751
|
-
/await app\.register\(uploadsServeRoutes\);\n\n/,
|
|
752
|
-
""
|
|
753
|
-
);
|
|
754
|
-
content = content.replace(/\s*await app\.register\(uploadsRoutes\);/g, "");
|
|
755
|
-
await fs2.writeFile(appPath, content);
|
|
756
|
-
}
|
|
757
|
-
const servicesPath = path3.join(targetDir, "apps/api/src/plugins/services.ts");
|
|
758
|
-
if (await fs2.pathExists(servicesPath)) {
|
|
759
|
-
let content = await fs2.readFile(servicesPath, "utf-8");
|
|
760
|
-
content = content.replace(
|
|
761
|
-
/import { FileStorageService } from '@\/services\/file-storage\.service';\n/,
|
|
762
|
-
""
|
|
763
|
-
);
|
|
764
|
-
content = content.replace(
|
|
765
|
-
/import { UploadsService } from '@\/services\/uploads\.service';\n/,
|
|
766
|
-
""
|
|
767
|
-
);
|
|
768
|
-
content = content.replace(
|
|
769
|
-
/\s*const fileStorageService = new FileStorageService\(env, app\.logger\);/,
|
|
770
|
-
""
|
|
771
|
-
);
|
|
772
|
-
content = content.replace(
|
|
773
|
-
/\s*const uploadsService = new UploadsService\(\n\s*app\.prisma,\n\s*fileStorageService,\n\s*app\.logger\n\s*\);/,
|
|
774
|
-
""
|
|
775
|
-
);
|
|
776
|
-
content = content.replace(
|
|
777
|
-
/\s*app\.decorate\('fileStorageService', fileStorageService\);/,
|
|
778
|
-
""
|
|
779
|
-
);
|
|
780
|
-
content = content.replace(
|
|
781
|
-
/\s*app\.decorate\('uploadsService', uploadsService\);/,
|
|
782
|
-
""
|
|
783
|
-
);
|
|
784
|
-
content = content.replace(/\s*fileStorageService: FileStorageService;/, "");
|
|
785
|
-
content = content.replace(/\s*uploadsService: UploadsService;/, "");
|
|
786
|
-
await fs2.writeFile(servicesPath, content);
|
|
787
|
-
}
|
|
788
|
-
const schemaPath = path3.join(targetDir, "apps/api/prisma/schema.prisma");
|
|
789
|
-
if (await fs2.pathExists(schemaPath)) {
|
|
790
|
-
let content = await fs2.readFile(schemaPath, "utf-8");
|
|
791
|
-
content = content.replace(/\s*uploads\s+Upload\[\]/, "");
|
|
792
|
-
content = content.replace(
|
|
793
|
-
/\n\nmodel Upload \{[\s\S]*?@@map\("uploads"\)\n\}/,
|
|
794
|
-
""
|
|
795
|
-
);
|
|
796
|
-
await fs2.writeFile(schemaPath, content);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
730
|
|
|
800
731
|
// src/commands/create.ts
|
|
801
732
|
var ENV_FILES = [
|