deploy-bbc 1.2.1 → 1.2.2
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/README.md +253 -266
- package/dist/index.js +16870 -0
- package/dist/templates/base/.env.example +3 -0
- package/dist/templates/base/package.json +20 -0
- package/dist/templates/base/src/config/index.ts +8 -0
- package/dist/templates/base/src/routes/index.ts +12 -0
- package/dist/templates/base/src/types/index.ts +2 -0
- package/dist/templates/base-bun-native/.env.example +3 -0
- package/dist/templates/base-bun-native/package.json +19 -0
- package/dist/templates/base-bun-native/src/config/index.ts +8 -0
- package/dist/templates/base-bun-native/src/index.ts +50 -0
- package/dist/templates/base-bun-native/src/routes/index.ts +21 -0
- package/dist/templates/base-bun-native/src/types/index.ts +2 -0
- package/dist/templates/base-express/.env.example +3 -0
- package/dist/templates/base-express/package.json +21 -0
- package/dist/templates/base-express/src/config/index.ts +8 -0
- package/dist/templates/base-express/src/routes/index.ts +12 -0
- package/dist/templates/base-express/src/types/index.ts +2 -0
- package/dist/templates/templates/base/README.md +31 -0
- package/dist/templates/templates/base/src/index.ts +26 -0
- package/dist/templates/templates/base/src/middleware/error.ts +13 -0
- package/dist/templates/templates/base/src/middleware/logger.ts +8 -0
- package/dist/templates/templates/base/src/utils/env.ts +5 -0
- package/dist/templates/templates/base/tsconfig.json +20 -0
- package/dist/templates/templates/base-bun-native/README.md +31 -0
- package/dist/templates/templates/base-bun-native/src/middleware/error.ts +20 -0
- package/dist/templates/templates/base-bun-native/src/middleware/logger.ts +6 -0
- package/dist/templates/templates/base-bun-native/src/utils/env.ts +5 -0
- package/dist/templates/templates/base-bun-native/tsconfig.json +20 -0
- package/dist/templates/templates/base-express/README.md +31 -0
- package/dist/templates/templates/base-express/src/index.ts +27 -0
- package/dist/templates/templates/base-express/src/middleware/error.ts +15 -0
- package/dist/templates/templates/base-express/src/middleware/logger.ts +12 -0
- package/dist/templates/templates/base-express/src/utils/env.ts +5 -0
- package/dist/templates/templates/base-express/tsconfig.json +20 -0
- package/dist/templates/templates/extras/ai/anthropic/src/services/ai/anthropic.ts +0 -0
- package/dist/templates/templates/extras/ai/gemini/src/services/ai/gemini.ts +0 -0
- package/dist/templates/templates/extras/ai/openai/src/routes/ai/chat.ts +0 -0
- package/dist/templates/templates/extras/ai/openai/src/services/ai/openai.ts +0 -0
- package/dist/templates/templates/extras/ai/vercel-ai/src/routes/ai/generate.ts +0 -0
- package/dist/templates/templates/extras/ai/vercel-ai/src/routes/ai/stream.ts +0 -0
- package/dist/templates/templates/extras/ai/vercel-ai/src/services/ai/index.ts +0 -0
- package/dist/templates/templates/extras/auth/jwt/src/middleware/auth.ts +0 -0
- package/dist/templates/templates/extras/auth/jwt/src/routes/auth.ts +0 -0
- package/dist/templates/templates/extras/auth/jwt/src/utils/jwt.ts +0 -0
- package/dist/templates/templates/extras/auth/oauth/src/config/oauth.ts +0 -0
- package/dist/templates/templates/extras/auth/oauth/src/routes/auth.ts +0 -0
- package/dist/templates/templates/extras/auth/session/src/config/session.ts +0 -0
- package/dist/templates/templates/extras/auth/session/src/middleware/session.ts +0 -0
- package/dist/templates/templates/extras/cloud/aws/src/services/aws/s3.ts +0 -0
- package/dist/templates/templates/extras/cloud/aws/src/services/aws/ses.ts +0 -0
- package/dist/templates/templates/extras/cloud/azure/src/services/azure/blob.ts +0 -0
- package/dist/templates/templates/extras/cloud/cloudflare-r2/src/services/cloudflare/r2.ts +0 -0
- package/dist/templates/templates/extras/cloud/gcp/src/services/gcp/storage.ts +0 -0
- package/dist/templates/templates/extras/database/mongodb/src/db/index.ts +0 -0
- package/dist/templates/templates/extras/database/mongodb/src/db/models/user.model.ts +0 -0
- package/dist/templates/templates/extras/database/mysql/drizzle.config.ts +0 -0
- package/dist/templates/templates/extras/database/postgres/src/db/index.ts +0 -0
- package/dist/templates/templates/extras/database/redis/src/db/redis.ts +0 -0
- package/dist/templates/templates/extras/docs/scalar/src/openapi/index.ts +0 -0
- package/dist/templates/templates/extras/docs/scalar/src/routes/docs.ts +0 -0
- package/dist/templates/templates/extras/docs/swagger/src/openapi/index.ts +0 -0
- package/dist/templates/templates/extras/docs/swagger/src/routes/docs.ts +0 -0
- package/dist/templates/templates/extras/email/nodemailer/src/services/email/nodemailer.ts +0 -0
- package/dist/templates/templates/extras/email/resend/src/services/email/resend.ts +0 -0
- package/dist/templates/templates/extras/email/resend/src/templates/email/welcome.ts +0 -0
- package/dist/templates/templates/extras/email/sendgrid/src/services/email/sendgrid.ts +0 -0
- package/dist/templates/templates/extras/observability/logtail/src/config/logger.ts +0 -0
- package/dist/templates/templates/extras/observability/sentry/src/config/sentry.ts +0 -0
- package/dist/templates/templates/extras/observability/sentry/src/middleware/sentry.ts +0 -0
- package/dist/templates/templates/extras/queue/bullmq/src/queue/index.ts +0 -0
- package/dist/templates/templates/extras/queue/bullmq/src/queue/jobs/email.job.ts +0 -0
- package/dist/templates/templates/extras/queue/bullmq/src/queue/processors/email.processor.ts +0 -0
- package/dist/templates/templates/extras/queue/bullmq/src/routes/queue.ts +0 -0
- package/dist/templates/templates/extras/queue/inngest/src/inngest/client.ts +0 -0
- package/dist/templates/templates/extras/queue/inngest/src/inngest/functions/email.ts +0 -0
- package/dist/templates/templates/extras/queue/inngest/src/routes/inngest.ts +0 -0
- package/dist/templates/templates/extras/realtime/socketio/src/socket/handlers.ts +0 -0
- package/dist/templates/templates/extras/realtime/socketio/src/socket/index.ts +0 -0
- package/dist/templates/templates/extras/realtime/sse/src/routes/sse.ts +0 -0
- package/dist/templates/templates/extras/testing/vitest/src/__tests__/example.test.ts +0 -0
- package/dist/templates/templates/extras/testing/vitest/src/__tests__/setup.ts +0 -0
- package/dist/templates/templates/extras/testing/vitest/vitest.config.ts +0 -0
- package/dist/templates/templates/extras/validation/yup/src/middleware/index.ts +1 -0
- package/dist/templates/templates/extras/validation/yup/src/middleware/validate.ts +83 -0
- package/dist/templates/templates/extras/validation/yup/src/routes/users.ts +132 -0
- package/dist/templates/templates/extras/validation/zod/src/middleware/index.ts +1 -0
- package/dist/templates/templates/extras/validation/zod/src/middleware/validate.ts +80 -0
- package/dist/templates/templates/extras/validation/zod/src/routes/users.ts +128 -0
- package/package.json +43 -9
- package/.cspell.json +0 -38
- package/CLAUDE.md +0 -403
- package/cli/README.md +0 -345
- package/cli/package.json +0 -54
- package/cli/src/cli/index.ts +0 -454
- package/cli/src/helpers/create-project.ts +0 -66
- package/cli/src/helpers/generate-docker-compose.ts +0 -133
- package/cli/src/helpers/generate-dockerfile.ts +0 -45
- package/cli/src/helpers/init-git.ts +0 -33
- package/cli/src/helpers/install-dependencies.ts +0 -28
- package/cli/src/helpers/log-next-steps.ts +0 -87
- package/cli/src/helpers/scaffold-project.ts +0 -88
- package/cli/src/index.ts +0 -18
- package/cli/src/installers/ai.ts +0 -123
- package/cli/src/installers/auth.ts +0 -132
- package/cli/src/installers/base.ts +0 -16
- package/cli/src/installers/cloud.ts +0 -127
- package/cli/src/installers/database.ts +0 -212
- package/cli/src/installers/docs.ts +0 -93
- package/cli/src/installers/email.ts +0 -119
- package/cli/src/installers/env-variables.ts +0 -27
- package/cli/src/installers/index.ts +0 -145
- package/cli/src/installers/observability.ts +0 -103
- package/cli/src/installers/queue.ts +0 -103
- package/cli/src/installers/ratelimit.ts +0 -98
- package/cli/src/installers/realtime.ts +0 -79
- package/cli/src/installers/testing.ts +0 -88
- package/cli/src/installers/validation.ts +0 -85
- package/cli/src/types/index.ts +0 -126
- package/cli/src/utils/add-package-dependency.ts +0 -56
- package/cli/src/utils/dependency-version-map.ts +0 -85
- package/cli/src/utils/logger.ts +0 -19
- package/cli/src/utils/parse-name-and-path.ts +0 -71
- package/cli/src/utils/render-title.ts +0 -11
- package/cli/tsconfig.json +0 -35
- package/test-cli.sh +0 -56
- package/tsconfig.json +0 -15
- /package/{cli/src → dist}/templates/base/README.md +0 -0
- /package/{cli/src → dist}/templates/base/src/index.ts +0 -0
- /package/{cli/src → dist}/templates/base/src/middleware/error.ts +0 -0
- /package/{cli/src → dist}/templates/base/src/middleware/logger.ts +0 -0
- /package/{cli/src → dist}/templates/base/src/utils/env.ts +0 -0
- /package/{cli/src → dist}/templates/base/tsconfig.json +0 -0
- /package/{cli/src → dist}/templates/base-bun-native/README.md +0 -0
- /package/{cli/src → dist}/templates/base-bun-native/src/middleware/error.ts +0 -0
- /package/{cli/src → dist}/templates/base-bun-native/src/middleware/logger.ts +0 -0
- /package/{cli/src → dist}/templates/base-bun-native/src/utils/env.ts +0 -0
- /package/{cli/src → dist}/templates/base-bun-native/tsconfig.json +0 -0
- /package/{cli/src → dist}/templates/base-express/README.md +0 -0
- /package/{cli/src → dist}/templates/base-express/src/index.ts +0 -0
- /package/{cli/src → dist}/templates/base-express/src/middleware/error.ts +0 -0
- /package/{cli/src → dist}/templates/base-express/src/middleware/logger.ts +0 -0
- /package/{cli/src → dist}/templates/base-express/src/utils/env.ts +0 -0
- /package/{cli/src → dist}/templates/base-express/tsconfig.json +0 -0
- /package/{cli/src → dist}/templates/extras/ai/anthropic/src/routes/ai/claude.ts +0 -0
- /package/{cli/src → dist}/templates/extras/ai/anthropic/src/services/ai/anthropic.ts +0 -0
- /package/{cli/src → dist}/templates/extras/ai/gemini/src/services/ai/gemini.ts +0 -0
- /package/{cli/src → dist}/templates/extras/ai/openai/src/routes/ai/chat.ts +0 -0
- /package/{cli/src → dist}/templates/extras/ai/openai/src/services/ai/openai.ts +0 -0
- /package/{cli/src → dist}/templates/extras/ai/vercel-ai/src/routes/ai/generate.ts +0 -0
- /package/{cli/src → dist}/templates/extras/ai/vercel-ai/src/routes/ai/stream.ts +0 -0
- /package/{cli/src → dist}/templates/extras/ai/vercel-ai/src/services/ai/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/auth/jwt/src/middleware/auth.ts +0 -0
- /package/{cli/src → dist}/templates/extras/auth/jwt/src/routes/auth.ts +0 -0
- /package/{cli/src → dist}/templates/extras/auth/jwt/src/utils/jwt.ts +0 -0
- /package/{cli/src → dist}/templates/extras/auth/oauth/src/config/oauth.ts +0 -0
- /package/{cli/src → dist}/templates/extras/auth/oauth/src/routes/auth.ts +0 -0
- /package/{cli/src → dist}/templates/extras/auth/session/src/config/session.ts +0 -0
- /package/{cli/src → dist}/templates/extras/auth/session/src/middleware/session.ts +0 -0
- /package/{cli/src → dist}/templates/extras/cloud/aws/src/services/aws/s3.ts +0 -0
- /package/{cli/src → dist}/templates/extras/cloud/aws/src/services/aws/ses.ts +0 -0
- /package/{cli/src → dist}/templates/extras/cloud/azure/src/services/azure/blob.ts +0 -0
- /package/{cli/src → dist}/templates/extras/cloud/cloudflare-r2/src/services/cloudflare/r2.ts +0 -0
- /package/{cli/src → dist}/templates/extras/cloud/gcp/src/services/gcp/storage.ts +0 -0
- /package/{cli/src → dist}/templates/extras/database/mongodb/src/db/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/database/mongodb/src/db/models/user.model.ts +0 -0
- /package/{cli/src → dist}/templates/extras/database/mysql/drizzle.config.ts +0 -0
- /package/{cli/src → dist}/templates/extras/database/postgres/src/db/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/database/redis/src/db/redis.ts +0 -0
- /package/{cli/src → dist}/templates/extras/docs/scalar/src/openapi/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/docs/scalar/src/routes/docs.ts +0 -0
- /package/{cli/src → dist}/templates/extras/docs/swagger/src/openapi/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/docs/swagger/src/routes/docs.ts +0 -0
- /package/{cli/src → dist}/templates/extras/email/nodemailer/src/services/email/nodemailer.ts +0 -0
- /package/{cli/src → dist}/templates/extras/email/resend/src/services/email/resend.ts +0 -0
- /package/{cli/src → dist}/templates/extras/email/resend/src/templates/email/welcome.ts +0 -0
- /package/{cli/src → dist}/templates/extras/email/sendgrid/src/services/email/sendgrid.ts +0 -0
- /package/{cli/src → dist}/templates/extras/observability/logtail/src/config/logger.ts +0 -0
- /package/{cli/src → dist}/templates/extras/observability/sentry/src/config/sentry.ts +0 -0
- /package/{cli/src → dist}/templates/extras/observability/sentry/src/middleware/sentry.ts +0 -0
- /package/{cli/src → dist}/templates/extras/queue/bullmq/src/queue/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/queue/bullmq/src/queue/jobs/email.job.ts +0 -0
- /package/{cli/src → dist}/templates/extras/queue/bullmq/src/queue/processors/email.processor.ts +0 -0
- /package/{cli/src → dist}/templates/extras/queue/bullmq/src/routes/queue.ts +0 -0
- /package/{cli/src → dist}/templates/extras/queue/inngest/src/inngest/client.ts +0 -0
- /package/{cli/src → dist}/templates/extras/queue/inngest/src/inngest/functions/email.ts +0 -0
- /package/{cli/src → dist}/templates/extras/queue/inngest/src/routes/inngest.ts +0 -0
- /package/{cli/src → dist}/templates/extras/realtime/socketio/src/socket/handlers.ts +0 -0
- /package/{cli/src → dist}/templates/extras/realtime/socketio/src/socket/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/realtime/sse/src/routes/sse.ts +0 -0
- /package/{cli/src → dist}/templates/extras/testing/vitest/src/__tests__/example.test.ts +0 -0
- /package/{cli/src → dist}/templates/extras/testing/vitest/src/__tests__/setup.ts +0 -0
- /package/{cli/src → dist}/templates/extras/testing/vitest/vitest.config.ts +0 -0
- /package/{cli/src → dist}/templates/extras/validation/yup/src/middleware/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/validation/yup/src/middleware/validate.ts +0 -0
- /package/{cli/src → dist}/templates/extras/validation/yup/src/routes/users.ts +0 -0
- /package/{cli/src → dist}/templates/extras/validation/zod/src/middleware/index.ts +0 -0
- /package/{cli/src → dist}/templates/extras/validation/zod/src/middleware/validate.ts +0 -0
- /package/{cli/src → dist}/templates/extras/validation/zod/src/routes/users.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/.env.example +0 -0
- /package/{cli/src → dist/templates}/templates/base/package.json +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/config/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/controllers/user/create-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/controllers/user/delete-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/controllers/user/get-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/controllers/user/get-users.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/controllers/user/update-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/models/user.model.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/routes/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/routes/user.route.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/types/common/api-response.types.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/types/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base/src/types/models/user.types.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/.env.example +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/package.json +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/config/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/create-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/delete-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/get-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/get-users.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/controllers/user/update-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/models/user.model.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/routes/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/routes/user.route.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/types/common/api-response.types.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/types/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-bun-native/src/types/models/user.types.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/.env.example +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/package.json +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/config/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/create-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/delete-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/get-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/get-users.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/controllers/user/update-user.controller.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/models/user.model.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/routes/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/routes/user.route.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/types/common/api-response.types.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/types/index.ts +0 -0
- /package/{cli/src → dist/templates}/templates/base-express/src/types/models/user.types.ts +0 -0
- /package/{prettier.config.mjs → dist/templates/templates/extras/ai/anthropic/src/routes/ai/claude.ts} +0 -0
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { type InstallerOptions, AvailablePackages } from "../types/index.js";
|
|
5
|
-
import { add_package_dependency } from "../utils/add-package-dependency.js";
|
|
6
|
-
import { DEPENDENCY_VERSION_MAP } from "../utils/dependency-version-map.js";
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Database installer - handles postgres, mysql, mongodb, and redis setup.
|
|
13
|
-
* Copies template files and adds necessary dependencies.
|
|
14
|
-
*
|
|
15
|
-
* @param options - Installer options with selected packages
|
|
16
|
-
*/
|
|
17
|
-
export async function database_installer(
|
|
18
|
-
options: InstallerOptions
|
|
19
|
-
): Promise<void> {
|
|
20
|
-
const { projectDir, packages } = options;
|
|
21
|
-
|
|
22
|
-
// Handle each database type
|
|
23
|
-
for (const pkg of packages) {
|
|
24
|
-
switch (pkg) {
|
|
25
|
-
case AvailablePackages.postgres:
|
|
26
|
-
await install_postgres(projectDir);
|
|
27
|
-
break;
|
|
28
|
-
case AvailablePackages.mysql:
|
|
29
|
-
await install_mysql(projectDir);
|
|
30
|
-
break;
|
|
31
|
-
case AvailablePackages.mongodb:
|
|
32
|
-
await install_mongodb(projectDir);
|
|
33
|
-
break;
|
|
34
|
-
case AvailablePackages.redis:
|
|
35
|
-
await install_redis(projectDir);
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function install_postgres(projectDir: string): Promise<void> {
|
|
42
|
-
// Copy template files
|
|
43
|
-
const templateDir = path.resolve(
|
|
44
|
-
__dirname,
|
|
45
|
-
"templates/extras/database/postgres"
|
|
46
|
-
);
|
|
47
|
-
await copy_template_files(templateDir, projectDir);
|
|
48
|
-
|
|
49
|
-
// Add dependencies
|
|
50
|
-
await add_package_dependency(projectDir, {
|
|
51
|
-
postgres: DEPENDENCY_VERSION_MAP["postgres"],
|
|
52
|
-
"drizzle-orm": DEPENDENCY_VERSION_MAP["drizzle-orm"],
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
await add_package_dependency(
|
|
56
|
-
projectDir,
|
|
57
|
-
{},
|
|
58
|
-
{
|
|
59
|
-
"drizzle-kit": DEPENDENCY_VERSION_MAP["drizzle-kit"],
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// Append to .env.example
|
|
64
|
-
await append_env_example(
|
|
65
|
-
projectDir,
|
|
66
|
-
"\n# PostgreSQL Configuration\nDATABASE_URL=postgresql://user:password@localhost:5432/dbname\n"
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
// Add db scripts to package.json
|
|
70
|
-
await add_db_scripts(projectDir, "postgres");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function install_mysql(projectDir: string): Promise<void> {
|
|
74
|
-
// Copy template files
|
|
75
|
-
const templateDir = path.resolve(
|
|
76
|
-
__dirname,
|
|
77
|
-
"templates/extras/database/mysql"
|
|
78
|
-
);
|
|
79
|
-
await copy_template_files(templateDir, projectDir);
|
|
80
|
-
|
|
81
|
-
// Add dependencies
|
|
82
|
-
await add_package_dependency(projectDir, {
|
|
83
|
-
mysql2: DEPENDENCY_VERSION_MAP["mysql2"],
|
|
84
|
-
"drizzle-orm": DEPENDENCY_VERSION_MAP["drizzle-orm"],
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
await add_package_dependency(
|
|
88
|
-
projectDir,
|
|
89
|
-
{},
|
|
90
|
-
{
|
|
91
|
-
"drizzle-kit": DEPENDENCY_VERSION_MAP["drizzle-kit"],
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
// Append to .env.example
|
|
96
|
-
await append_env_example(
|
|
97
|
-
projectDir,
|
|
98
|
-
"\n# MySQL Configuration\nDATABASE_URL=mysql://user:password@localhost:3306/dbname\n"
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// Add db scripts to package.json
|
|
102
|
-
await add_db_scripts(projectDir, "mysql");
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function install_mongodb(projectDir: string): Promise<void> {
|
|
106
|
-
// Copy template files
|
|
107
|
-
const templateDir = path.resolve(
|
|
108
|
-
__dirname,
|
|
109
|
-
"templates/extras/database/mongodb"
|
|
110
|
-
);
|
|
111
|
-
await copy_template_files(templateDir, projectDir);
|
|
112
|
-
|
|
113
|
-
// Add dependencies
|
|
114
|
-
await add_package_dependency(projectDir, {
|
|
115
|
-
mongoose: DEPENDENCY_VERSION_MAP["mongoose"],
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// Append to .env.example
|
|
119
|
-
await append_env_example(
|
|
120
|
-
projectDir,
|
|
121
|
-
"\n# MongoDB Configuration\nMONGODB_URI=mongodb://localhost:27017/dbname\n"
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async function install_redis(projectDir: string): Promise<void> {
|
|
126
|
-
// Copy template files
|
|
127
|
-
const templateDir = path.resolve(
|
|
128
|
-
__dirname,
|
|
129
|
-
"templates/extras/database/redis"
|
|
130
|
-
);
|
|
131
|
-
await copy_template_files(templateDir, projectDir);
|
|
132
|
-
|
|
133
|
-
// Add dependencies
|
|
134
|
-
await add_package_dependency(projectDir, {
|
|
135
|
-
redis: DEPENDENCY_VERSION_MAP["redis"],
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
// Append to .env.example
|
|
139
|
-
await append_env_example(
|
|
140
|
-
projectDir,
|
|
141
|
-
"\n# Redis Configuration\nREDIS_URL=redis://localhost:6379\n"
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Copies template files from source to destination.
|
|
147
|
-
* Copies both src/ directory and root config files.
|
|
148
|
-
*/
|
|
149
|
-
async function copy_template_files(
|
|
150
|
-
templateDir: string,
|
|
151
|
-
projectDir: string
|
|
152
|
-
): Promise<void> {
|
|
153
|
-
if (!(await fs.pathExists(templateDir))) {
|
|
154
|
-
console.warn(`Template directory not found: ${templateDir}`);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Copy src files
|
|
159
|
-
const srcDir = path.join(templateDir, "src");
|
|
160
|
-
if (await fs.pathExists(srcDir)) {
|
|
161
|
-
const targetSrcDir = path.join(projectDir, "src");
|
|
162
|
-
await fs.copy(srcDir, targetSrcDir, {
|
|
163
|
-
overwrite: false,
|
|
164
|
-
errorOnExist: false,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Copy root config files (e.g., drizzle.config.ts)
|
|
169
|
-
const templateFiles = await fs.readdir(templateDir);
|
|
170
|
-
for (const file of templateFiles) {
|
|
171
|
-
if (file !== "src" && (file.endsWith(".ts") || file.endsWith(".json"))) {
|
|
172
|
-
const srcFile = path.join(templateDir, file);
|
|
173
|
-
const destFile = path.join(projectDir, file);
|
|
174
|
-
|
|
175
|
-
// Only copy if file doesn't exist
|
|
176
|
-
if (!(await fs.pathExists(destFile))) {
|
|
177
|
-
await fs.copy(srcFile, destFile);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Appends environment variables to .env.example
|
|
185
|
-
*/
|
|
186
|
-
async function append_env_example(
|
|
187
|
-
projectDir: string,
|
|
188
|
-
content: string
|
|
189
|
-
): Promise<void> {
|
|
190
|
-
const envPath = path.join(projectDir, ".env.example");
|
|
191
|
-
await fs.appendFile(envPath, content);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Adds database migration scripts to package.json
|
|
196
|
-
*/
|
|
197
|
-
async function add_db_scripts(
|
|
198
|
-
projectDir: string,
|
|
199
|
-
dbType: "postgres" | "mysql"
|
|
200
|
-
): Promise<void> {
|
|
201
|
-
const packageJsonPath = path.join(projectDir, "package.json");
|
|
202
|
-
const packageJson = await fs.readJson(packageJsonPath);
|
|
203
|
-
|
|
204
|
-
packageJson.scripts = {
|
|
205
|
-
...packageJson.scripts,
|
|
206
|
-
"db:generate": "drizzle-kit generate",
|
|
207
|
-
"db:migrate": "drizzle-kit migrate",
|
|
208
|
-
"db:studio": "drizzle-kit studio",
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
212
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { type InstallerOptions, AvailablePackages } from "../types/index.js";
|
|
5
|
-
import { add_package_dependency } from "../utils/add-package-dependency.js";
|
|
6
|
-
import { DEPENDENCY_VERSION_MAP } from "../utils/dependency-version-map.js";
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Docs installer - handles Swagger and Scalar API documentation.
|
|
13
|
-
*
|
|
14
|
-
* @param options - Installer options with selected packages
|
|
15
|
-
*/
|
|
16
|
-
export async function docs_installer(
|
|
17
|
-
options: InstallerOptions
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
const { projectDir, packages } = options;
|
|
20
|
-
|
|
21
|
-
for (const pkg of packages) {
|
|
22
|
-
switch (pkg) {
|
|
23
|
-
case AvailablePackages.swagger:
|
|
24
|
-
await install_swagger(projectDir);
|
|
25
|
-
break;
|
|
26
|
-
case AvailablePackages.scalar:
|
|
27
|
-
await install_scalar(projectDir);
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function install_swagger(projectDir: string): Promise<void> {
|
|
34
|
-
const templateDir = path.resolve(
|
|
35
|
-
__dirname,
|
|
36
|
-
"templates/extras/docs/swagger"
|
|
37
|
-
);
|
|
38
|
-
await copy_template_files(templateDir, projectDir);
|
|
39
|
-
|
|
40
|
-
await add_package_dependency(projectDir, {
|
|
41
|
-
"@hono/swagger": DEPENDENCY_VERSION_MAP["@hono/swagger"],
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async function install_scalar(projectDir: string): Promise<void> {
|
|
46
|
-
const templateDir = path.resolve(
|
|
47
|
-
__dirname,
|
|
48
|
-
"templates/extras/docs/scalar"
|
|
49
|
-
);
|
|
50
|
-
await copy_template_files(templateDir, projectDir);
|
|
51
|
-
|
|
52
|
-
await add_package_dependency(projectDir, {
|
|
53
|
-
"@scalar/hono-api-reference": DEPENDENCY_VERSION_MAP["@scalar/hono-api-reference"],
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function copy_template_files(
|
|
58
|
-
templateDir: string,
|
|
59
|
-
projectDir: string
|
|
60
|
-
): Promise<void> {
|
|
61
|
-
if (!(await fs.pathExists(templateDir))) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const srcDir = path.join(templateDir, "src");
|
|
66
|
-
if (await fs.pathExists(srcDir)) {
|
|
67
|
-
const targetSrcDir = path.join(projectDir, "src");
|
|
68
|
-
await fs.copy(srcDir, targetSrcDir, {
|
|
69
|
-
overwrite: false,
|
|
70
|
-
errorOnExist: false,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const templateFiles = await fs.readdir(templateDir);
|
|
75
|
-
for (const file of templateFiles) {
|
|
76
|
-
if (file !== "src" && (file.endsWith(".ts") || file.endsWith(".json"))) {
|
|
77
|
-
const srcFile = path.join(templateDir, file);
|
|
78
|
-
const destFile = path.join(projectDir, file);
|
|
79
|
-
|
|
80
|
-
if (!(await fs.pathExists(destFile))) {
|
|
81
|
-
await fs.copy(srcFile, destFile);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function append_env_example(
|
|
88
|
-
projectDir: string,
|
|
89
|
-
content: string
|
|
90
|
-
): Promise<void> {
|
|
91
|
-
const envPath = path.join(projectDir, ".env.example");
|
|
92
|
-
await fs.appendFile(envPath, content);
|
|
93
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { type InstallerOptions, AvailablePackages } from "../types/index.js";
|
|
5
|
-
import { add_package_dependency } from "../utils/add-package-dependency.js";
|
|
6
|
-
import { DEPENDENCY_VERSION_MAP } from "../utils/dependency-version-map.js";
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Email installer - handles Resend, SendGrid, and Nodemailer.
|
|
13
|
-
*
|
|
14
|
-
* @param options - Installer options with selected packages
|
|
15
|
-
*/
|
|
16
|
-
export async function email_installer(
|
|
17
|
-
options: InstallerOptions
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
const { projectDir, packages } = options;
|
|
20
|
-
|
|
21
|
-
for (const pkg of packages) {
|
|
22
|
-
switch (pkg) {
|
|
23
|
-
case AvailablePackages.resend:
|
|
24
|
-
await install_resend(projectDir);
|
|
25
|
-
break;
|
|
26
|
-
case AvailablePackages.sendgrid:
|
|
27
|
-
await install_sendgrid(projectDir);
|
|
28
|
-
break;
|
|
29
|
-
case AvailablePackages.nodemailer:
|
|
30
|
-
await install_nodemailer(projectDir);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function install_resend(projectDir: string): Promise<void> {
|
|
37
|
-
const templateDir = path.resolve(
|
|
38
|
-
__dirname,
|
|
39
|
-
"templates/extras/email/resend"
|
|
40
|
-
);
|
|
41
|
-
await copy_template_files(templateDir, projectDir);
|
|
42
|
-
|
|
43
|
-
await add_package_dependency(projectDir, {
|
|
44
|
-
resend: DEPENDENCY_VERSION_MAP["resend"],
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
await append_env_example(
|
|
48
|
-
projectDir,
|
|
49
|
-
"\n# Resend Configuration\nRESEND_API_KEY=your-resend-api-key\n"
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function install_sendgrid(projectDir: string): Promise<void> {
|
|
54
|
-
const templateDir = path.resolve(
|
|
55
|
-
__dirname,
|
|
56
|
-
"templates/extras/email/sendgrid"
|
|
57
|
-
);
|
|
58
|
-
await copy_template_files(templateDir, projectDir);
|
|
59
|
-
|
|
60
|
-
await add_package_dependency(projectDir, {
|
|
61
|
-
"@sendgrid/mail": DEPENDENCY_VERSION_MAP["@sendgrid/mail"],
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
await append_env_example(
|
|
65
|
-
projectDir,
|
|
66
|
-
"\n# SendGrid Configuration\nSENDGRID_API_KEY=your-sendgrid-api-key\nSENDGRID_FROM_EMAIL=noreply@yourdomain.com\n"
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function install_nodemailer(projectDir: string): Promise<void> {
|
|
71
|
-
const templateDir = path.resolve(
|
|
72
|
-
__dirname,
|
|
73
|
-
"templates/extras/email/nodemailer"
|
|
74
|
-
);
|
|
75
|
-
await copy_template_files(templateDir, projectDir);
|
|
76
|
-
|
|
77
|
-
await add_package_dependency(projectDir, {
|
|
78
|
-
nodemailer: DEPENDENCY_VERSION_MAP["nodemailer"],
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
await add_package_dependency(
|
|
82
|
-
projectDir,
|
|
83
|
-
{},
|
|
84
|
-
{
|
|
85
|
-
"@types/nodemailer": DEPENDENCY_VERSION_MAP["@types/nodemailer"],
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
await append_env_example(
|
|
90
|
-
projectDir,
|
|
91
|
-
"\n# Nodemailer Configuration\nSMTP_HOST=smtp.example.com\nSMTP_PORT=587\nSMTP_USER=your-smtp-username\nSMTP_PASS=your-smtp-password\nSMTP_FROM=noreply@yourdomain.com\n"
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function copy_template_files(
|
|
96
|
-
templateDir: string,
|
|
97
|
-
projectDir: string
|
|
98
|
-
): Promise<void> {
|
|
99
|
-
if (!(await fs.pathExists(templateDir))) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const srcDir = path.join(templateDir, "src");
|
|
104
|
-
if (await fs.pathExists(srcDir)) {
|
|
105
|
-
const targetSrcDir = path.join(projectDir, "src");
|
|
106
|
-
await fs.copy(srcDir, targetSrcDir, {
|
|
107
|
-
overwrite: false,
|
|
108
|
-
errorOnExist: false,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async function append_env_example(
|
|
114
|
-
projectDir: string,
|
|
115
|
-
content: string
|
|
116
|
-
): Promise<void> {
|
|
117
|
-
const envPath = path.join(projectDir, ".env.example");
|
|
118
|
-
await fs.appendFile(envPath, content);
|
|
119
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import { type InstallerOptions } from "../types/index.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Environment variables installer - creates an empty .env file.
|
|
7
|
-
* The .env.example file is populated by individual installers as they run.
|
|
8
|
-
* This installer ensures a .env file exists for local development.
|
|
9
|
-
*
|
|
10
|
-
* @param options - Installer options
|
|
11
|
-
*/
|
|
12
|
-
export async function env_variables_installer(
|
|
13
|
-
options: InstallerOptions
|
|
14
|
-
): Promise<void> {
|
|
15
|
-
const { projectDir } = options;
|
|
16
|
-
|
|
17
|
-
// Create empty .env file (will be git-ignored)
|
|
18
|
-
const envPath = path.join(projectDir, ".env");
|
|
19
|
-
|
|
20
|
-
// Only create if it doesn't exist
|
|
21
|
-
if (!(await fs.pathExists(envPath))) {
|
|
22
|
-
await fs.writeFile(
|
|
23
|
-
envPath,
|
|
24
|
-
"# Copy values from .env.example and fill in your actual credentials\n"
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type InstallerOptions,
|
|
3
|
-
type PkgInstallerMap,
|
|
4
|
-
type Installer,
|
|
5
|
-
AvailablePackages,
|
|
6
|
-
} from "../types/index.js";
|
|
7
|
-
import { base_installer } from "./base.js";
|
|
8
|
-
import { database_installer } from "./database.js";
|
|
9
|
-
import { auth_installer } from "./auth.js";
|
|
10
|
-
import { ai_installer } from "./ai.js";
|
|
11
|
-
import { email_installer } from "./email.js";
|
|
12
|
-
import { cloud_installer } from "./cloud.js";
|
|
13
|
-
import { realtime_installer } from "./realtime.js";
|
|
14
|
-
import { queue_installer } from "./queue.js";
|
|
15
|
-
import { ratelimit_installer } from "./ratelimit.js";
|
|
16
|
-
import { observability_installer } from "./observability.js";
|
|
17
|
-
import { docs_installer } from "./docs.js";
|
|
18
|
-
import { testing_installer } from "./testing.js";
|
|
19
|
-
import { validation_installer } from "./validation.js";
|
|
20
|
-
import { env_variables_installer } from "./env-variables.js";
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Builds a map of installers based on selected packages.
|
|
24
|
-
* Each installer is marked as inUse if any of its related packages are selected.
|
|
25
|
-
*
|
|
26
|
-
* @param options - Installer options with selected packages
|
|
27
|
-
* @returns Map of installers with usage flags
|
|
28
|
-
*/
|
|
29
|
-
export function build_installer_map(
|
|
30
|
-
options: InstallerOptions
|
|
31
|
-
): PkgInstallerMap {
|
|
32
|
-
const { packages } = options;
|
|
33
|
-
|
|
34
|
-
// Helper to check if any package in a category is selected
|
|
35
|
-
const has_package = (...pkgs: AvailablePackages[]): boolean => {
|
|
36
|
-
return pkgs.some((pkg) => packages.includes(pkg));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
base: {
|
|
41
|
-
inUse: true, // Always run base installer
|
|
42
|
-
installer: base_installer,
|
|
43
|
-
},
|
|
44
|
-
database: {
|
|
45
|
-
inUse: has_package(
|
|
46
|
-
AvailablePackages.postgres,
|
|
47
|
-
AvailablePackages.mysql,
|
|
48
|
-
AvailablePackages.mongodb,
|
|
49
|
-
AvailablePackages.redis
|
|
50
|
-
),
|
|
51
|
-
installer: database_installer,
|
|
52
|
-
},
|
|
53
|
-
auth: {
|
|
54
|
-
inUse: has_package(
|
|
55
|
-
AvailablePackages.jwt,
|
|
56
|
-
AvailablePackages.oauth,
|
|
57
|
-
AvailablePackages.session
|
|
58
|
-
),
|
|
59
|
-
installer: auth_installer,
|
|
60
|
-
},
|
|
61
|
-
ai: {
|
|
62
|
-
inUse: has_package(
|
|
63
|
-
AvailablePackages.openai,
|
|
64
|
-
AvailablePackages.anthropic,
|
|
65
|
-
AvailablePackages.gemini,
|
|
66
|
-
AvailablePackages.vercelAI
|
|
67
|
-
),
|
|
68
|
-
installer: ai_installer,
|
|
69
|
-
},
|
|
70
|
-
email: {
|
|
71
|
-
inUse: has_package(
|
|
72
|
-
AvailablePackages.resend,
|
|
73
|
-
AvailablePackages.sendgrid,
|
|
74
|
-
AvailablePackages.nodemailer
|
|
75
|
-
),
|
|
76
|
-
installer: email_installer,
|
|
77
|
-
},
|
|
78
|
-
cloud: {
|
|
79
|
-
inUse: has_package(
|
|
80
|
-
AvailablePackages.aws,
|
|
81
|
-
AvailablePackages.gcp,
|
|
82
|
-
AvailablePackages.azure,
|
|
83
|
-
AvailablePackages.cloudflareR2
|
|
84
|
-
),
|
|
85
|
-
installer: cloud_installer,
|
|
86
|
-
},
|
|
87
|
-
realtime: {
|
|
88
|
-
inUse: has_package(AvailablePackages.socketio, AvailablePackages.sse),
|
|
89
|
-
installer: realtime_installer,
|
|
90
|
-
},
|
|
91
|
-
queue: {
|
|
92
|
-
inUse: has_package(AvailablePackages.bullmq, AvailablePackages.inngest),
|
|
93
|
-
installer: queue_installer,
|
|
94
|
-
},
|
|
95
|
-
ratelimit: {
|
|
96
|
-
inUse: has_package(
|
|
97
|
-
AvailablePackages.upstashRateLimit,
|
|
98
|
-
AvailablePackages.customRateLimit
|
|
99
|
-
),
|
|
100
|
-
installer: ratelimit_installer,
|
|
101
|
-
},
|
|
102
|
-
observability: {
|
|
103
|
-
inUse: has_package(AvailablePackages.sentry, AvailablePackages.logtail),
|
|
104
|
-
installer: observability_installer,
|
|
105
|
-
},
|
|
106
|
-
docs: {
|
|
107
|
-
inUse: has_package(AvailablePackages.swagger, AvailablePackages.scalar),
|
|
108
|
-
installer: docs_installer,
|
|
109
|
-
},
|
|
110
|
-
testing: {
|
|
111
|
-
inUse: has_package(AvailablePackages.vitest),
|
|
112
|
-
installer: testing_installer,
|
|
113
|
-
},
|
|
114
|
-
validation: {
|
|
115
|
-
inUse: has_package(AvailablePackages.zod, AvailablePackages.yup),
|
|
116
|
-
installer: validation_installer,
|
|
117
|
-
},
|
|
118
|
-
envVariables: {
|
|
119
|
-
inUse: true, // Always run to create .env files
|
|
120
|
-
installer: env_variables_installer,
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Executes all installers marked as inUse sequentially.
|
|
127
|
-
* Each installer is responsible for copying templates and adding dependencies.
|
|
128
|
-
*
|
|
129
|
-
* @param installerMap - Map of installers with usage flags
|
|
130
|
-
* @param options - Installer options
|
|
131
|
-
*/
|
|
132
|
-
export async function run_installers(
|
|
133
|
-
installerMap: PkgInstallerMap,
|
|
134
|
-
options: InstallerOptions
|
|
135
|
-
): Promise<void> {
|
|
136
|
-
// Get list of active installers
|
|
137
|
-
const installers = Object.entries(installerMap)
|
|
138
|
-
.filter(([_, config]) => config.inUse)
|
|
139
|
-
.map(([_, config]) => config.installer);
|
|
140
|
-
|
|
141
|
-
// Run each installer sequentially
|
|
142
|
-
for (const installer of installers) {
|
|
143
|
-
await installer(options);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { type InstallerOptions, AvailablePackages } from "../types/index.js";
|
|
5
|
-
import { add_package_dependency } from "../utils/add-package-dependency.js";
|
|
6
|
-
import { DEPENDENCY_VERSION_MAP } from "../utils/dependency-version-map.js";
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Observability installer - handles Sentry and Logtail.
|
|
13
|
-
*
|
|
14
|
-
* @param options - Installer options with selected packages
|
|
15
|
-
*/
|
|
16
|
-
export async function observability_installer(
|
|
17
|
-
options: InstallerOptions
|
|
18
|
-
): Promise<void> {
|
|
19
|
-
const { projectDir, packages } = options;
|
|
20
|
-
|
|
21
|
-
for (const pkg of packages) {
|
|
22
|
-
switch (pkg) {
|
|
23
|
-
case AvailablePackages.sentry:
|
|
24
|
-
await install_sentry(projectDir);
|
|
25
|
-
break;
|
|
26
|
-
case AvailablePackages.logtail:
|
|
27
|
-
await install_logtail(projectDir);
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function install_sentry(projectDir: string): Promise<void> {
|
|
34
|
-
const templateDir = path.resolve(
|
|
35
|
-
__dirname,
|
|
36
|
-
"templates/extras/observability/sentry"
|
|
37
|
-
);
|
|
38
|
-
await copy_template_files(templateDir, projectDir);
|
|
39
|
-
|
|
40
|
-
await add_package_dependency(projectDir, {
|
|
41
|
-
"@sentry/node": DEPENDENCY_VERSION_MAP["@sentry/node"],
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
await append_env_example(
|
|
45
|
-
projectDir,
|
|
46
|
-
"\n# Sentry Configuration\nSENTRY_DSN=your-sentry-dsn-here\nSENTRY_ENVIRONMENT=production\n"
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async function install_logtail(projectDir: string): Promise<void> {
|
|
51
|
-
const templateDir = path.resolve(
|
|
52
|
-
__dirname,
|
|
53
|
-
"templates/extras/observability/logtail"
|
|
54
|
-
);
|
|
55
|
-
await copy_template_files(templateDir, projectDir);
|
|
56
|
-
|
|
57
|
-
await add_package_dependency(projectDir, {
|
|
58
|
-
"@logtail/node": DEPENDENCY_VERSION_MAP["@logtail/node"],
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
await append_env_example(
|
|
62
|
-
projectDir,
|
|
63
|
-
"\n# Logtail Configuration\nLOGTAIL_SOURCE_TOKEN=your-logtail-source-token-here\n"
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function copy_template_files(
|
|
68
|
-
templateDir: string,
|
|
69
|
-
projectDir: string
|
|
70
|
-
): Promise<void> {
|
|
71
|
-
if (!(await fs.pathExists(templateDir))) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const srcDir = path.join(templateDir, "src");
|
|
76
|
-
if (await fs.pathExists(srcDir)) {
|
|
77
|
-
const targetSrcDir = path.join(projectDir, "src");
|
|
78
|
-
await fs.copy(srcDir, targetSrcDir, {
|
|
79
|
-
overwrite: false,
|
|
80
|
-
errorOnExist: false,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const templateFiles = await fs.readdir(templateDir);
|
|
85
|
-
for (const file of templateFiles) {
|
|
86
|
-
if (file !== "src" && (file.endsWith(".ts") || file.endsWith(".json"))) {
|
|
87
|
-
const srcFile = path.join(templateDir, file);
|
|
88
|
-
const destFile = path.join(projectDir, file);
|
|
89
|
-
|
|
90
|
-
if (!(await fs.pathExists(destFile))) {
|
|
91
|
-
await fs.copy(srcFile, destFile);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function append_env_example(
|
|
98
|
-
projectDir: string,
|
|
99
|
-
content: string
|
|
100
|
-
): Promise<void> {
|
|
101
|
-
const envPath = path.join(projectDir, ".env.example");
|
|
102
|
-
await fs.appendFile(envPath, content);
|
|
103
|
-
}
|