@expressots/cli 3.0.0 → 4.0.0-preview.3

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.
Files changed (194) hide show
  1. package/README.md +41 -95
  2. package/bin/cicd/cli.d.ts +6 -0
  3. package/bin/cicd/cli.js +128 -0
  4. package/bin/cicd/form.d.ts +29 -0
  5. package/bin/cicd/form.js +346 -0
  6. package/bin/cicd/generators/azure-devops.d.ts +2 -0
  7. package/bin/cicd/generators/azure-devops.js +370 -0
  8. package/bin/cicd/generators/bitbucket.d.ts +2 -0
  9. package/bin/cicd/generators/bitbucket.js +217 -0
  10. package/bin/cicd/generators/circleci.d.ts +2 -0
  11. package/bin/cicd/generators/circleci.js +274 -0
  12. package/bin/cicd/generators/github-actions.d.ts +14 -0
  13. package/bin/cicd/generators/github-actions.js +426 -0
  14. package/bin/cicd/generators/gitlab-ci.d.ts +2 -0
  15. package/bin/cicd/generators/gitlab-ci.js +237 -0
  16. package/bin/cicd/generators/index.d.ts +6 -0
  17. package/bin/cicd/generators/index.js +15 -0
  18. package/bin/cicd/generators/jenkins.d.ts +2 -0
  19. package/bin/cicd/generators/jenkins.js +248 -0
  20. package/bin/cicd/generators/template-loader.d.ts +17 -0
  21. package/bin/cicd/generators/template-loader.js +128 -0
  22. package/bin/cicd/index.d.ts +1 -0
  23. package/bin/cicd/index.js +5 -0
  24. package/bin/cli.d.ts +1 -5
  25. package/bin/cli.js +72 -7
  26. package/bin/commands/project.commands.d.ts +19 -6
  27. package/bin/commands/project.commands.js +602 -66
  28. package/bin/config/index.d.ts +5 -0
  29. package/bin/config/index.js +10 -0
  30. package/bin/config/manager.d.ts +98 -0
  31. package/bin/config/manager.js +222 -0
  32. package/bin/containerize/analyzers/bootstrap-analyzer.d.ts +46 -0
  33. package/bin/containerize/analyzers/bootstrap-analyzer.js +187 -0
  34. package/bin/containerize/analyzers/project-analyzer.d.ts +20 -0
  35. package/bin/containerize/analyzers/project-analyzer.js +150 -0
  36. package/bin/containerize/cli.d.ts +4 -0
  37. package/bin/containerize/cli.js +113 -0
  38. package/bin/containerize/form.d.ts +15 -0
  39. package/bin/containerize/form.js +152 -0
  40. package/bin/containerize/generators/ci-generator.d.ts +31 -0
  41. package/bin/containerize/generators/ci-generator.js +940 -0
  42. package/bin/containerize/generators/docker-compose-generator.d.ts +8 -0
  43. package/bin/containerize/generators/docker-compose-generator.js +187 -0
  44. package/bin/containerize/generators/dockerfile-generator.d.ts +8 -0
  45. package/bin/containerize/generators/dockerfile-generator.js +657 -0
  46. package/bin/containerize/generators/kubernetes-generator.d.ts +8 -0
  47. package/bin/containerize/generators/kubernetes-generator.js +134 -0
  48. package/bin/containerize/generators/template-loader.d.ts +36 -0
  49. package/bin/containerize/generators/template-loader.js +129 -0
  50. package/bin/containerize/index.d.ts +4 -0
  51. package/bin/containerize/index.js +13 -0
  52. package/bin/containerize/presets/preset-registry.d.ts +20 -0
  53. package/bin/containerize/presets/preset-registry.js +102 -0
  54. package/bin/costs/cli.d.ts +5 -0
  55. package/bin/costs/cli.js +185 -0
  56. package/bin/costs/form.d.ts +44 -0
  57. package/bin/costs/form.js +412 -0
  58. package/bin/costs/index.d.ts +4 -0
  59. package/bin/costs/index.js +25 -0
  60. package/bin/costs/pricing-manager.d.ts +84 -0
  61. package/bin/costs/pricing-manager.js +342 -0
  62. package/bin/costs/providers/index.d.ts +32 -0
  63. package/bin/costs/providers/index.js +153 -0
  64. package/bin/costs/sources/api-source.d.ts +10 -0
  65. package/bin/costs/sources/api-source.js +32 -0
  66. package/bin/costs/sources/index.d.ts +6 -0
  67. package/bin/costs/sources/index.js +15 -0
  68. package/bin/costs/sources/local-json-source.d.ts +23 -0
  69. package/bin/costs/sources/local-json-source.js +59 -0
  70. package/bin/costs/sources/remote-json-source.d.ts +11 -0
  71. package/bin/costs/sources/remote-json-source.js +53 -0
  72. package/bin/costs/types.d.ts +53 -0
  73. package/bin/costs/types.js +5 -0
  74. package/bin/dev/cli.d.ts +4 -0
  75. package/bin/dev/cli.js +136 -0
  76. package/bin/dev/form.d.ts +36 -0
  77. package/bin/dev/form.js +254 -0
  78. package/bin/dev/index.d.ts +1 -0
  79. package/bin/dev/index.js +5 -0
  80. package/bin/generate/cli.d.ts +1 -1
  81. package/bin/generate/cli.js +29 -2
  82. package/bin/generate/form.d.ts +5 -1
  83. package/bin/generate/form.js +3 -3
  84. package/bin/generate/templates/nonopinionated/config.tpl +12 -0
  85. package/bin/generate/templates/nonopinionated/event.tpl +10 -0
  86. package/bin/generate/templates/nonopinionated/guard.tpl +18 -0
  87. package/bin/generate/templates/nonopinionated/handler.tpl +12 -0
  88. package/bin/generate/templates/nonopinionated/interceptor.tpl +27 -0
  89. package/bin/generate/templates/opinionated/config.tpl +47 -0
  90. package/bin/generate/templates/opinionated/entity.tpl +1 -8
  91. package/bin/generate/templates/opinionated/event.tpl +15 -0
  92. package/bin/generate/templates/opinionated/guard.tpl +41 -0
  93. package/bin/generate/templates/opinionated/handler.tpl +23 -0
  94. package/bin/generate/templates/opinionated/interceptor.tpl +50 -0
  95. package/bin/generate/utils/command-utils.d.ts +20 -5
  96. package/bin/generate/utils/command-utils.js +145 -48
  97. package/bin/generate/utils/nonopininated-cmd.d.ts +10 -1
  98. package/bin/generate/utils/nonopininated-cmd.js +100 -1
  99. package/bin/generate/utils/opinionated-cmd.d.ts +10 -1
  100. package/bin/generate/utils/opinionated-cmd.js +128 -16
  101. package/bin/generate/utils/string-utils.d.ts +6 -0
  102. package/bin/generate/utils/string-utils.js +13 -1
  103. package/bin/help/cli.d.ts +1 -1
  104. package/bin/help/command-help-registry.d.ts +23 -0
  105. package/bin/help/command-help-registry.js +303 -0
  106. package/bin/help/command-help.d.ts +36 -0
  107. package/bin/help/command-help.js +56 -0
  108. package/bin/help/form.js +127 -22
  109. package/bin/help/main-help.d.ts +8 -0
  110. package/bin/help/main-help.js +126 -0
  111. package/bin/help/render.d.ts +32 -0
  112. package/bin/help/render.js +46 -0
  113. package/bin/info/cli.d.ts +1 -1
  114. package/bin/info/form.d.ts +1 -1
  115. package/bin/info/form.js +11 -11
  116. package/bin/migrate/analyzers/platform-detector.d.ts +14 -0
  117. package/bin/migrate/analyzers/platform-detector.js +116 -0
  118. package/bin/migrate/cli.d.ts +6 -0
  119. package/bin/migrate/cli.js +98 -0
  120. package/bin/migrate/form.d.ts +25 -0
  121. package/bin/migrate/form.js +348 -0
  122. package/bin/migrate/generators/compose-to-k8s.d.ts +2 -0
  123. package/bin/migrate/generators/compose-to-k8s.js +324 -0
  124. package/bin/migrate/generators/compose-to-railway.d.ts +2 -0
  125. package/bin/migrate/generators/compose-to-railway.js +138 -0
  126. package/bin/migrate/generators/compose-to-render.d.ts +2 -0
  127. package/bin/migrate/generators/compose-to-render.js +148 -0
  128. package/bin/migrate/generators/generic-migration.d.ts +9 -0
  129. package/bin/migrate/generators/generic-migration.js +221 -0
  130. package/bin/migrate/generators/heroku-to-fly.d.ts +2 -0
  131. package/bin/migrate/generators/heroku-to-fly.js +291 -0
  132. package/bin/migrate/generators/heroku-to-railway.d.ts +2 -0
  133. package/bin/migrate/generators/heroku-to-railway.js +283 -0
  134. package/bin/migrate/generators/heroku-to-render.d.ts +2 -0
  135. package/bin/migrate/generators/heroku-to-render.js +148 -0
  136. package/bin/migrate/generators/index.d.ts +7 -0
  137. package/bin/migrate/generators/index.js +17 -0
  138. package/bin/migrate/generators/template-loader.d.ts +21 -0
  139. package/bin/migrate/generators/template-loader.js +59 -0
  140. package/bin/migrate/index.d.ts +1 -0
  141. package/bin/migrate/index.js +5 -0
  142. package/bin/new/cli.d.ts +5 -1
  143. package/bin/new/cli.js +77 -14
  144. package/bin/new/form.d.ts +27 -4
  145. package/bin/new/form.js +605 -75
  146. package/bin/profile/analyzers/dockerfile-analyzer.d.ts +27 -0
  147. package/bin/profile/analyzers/dockerfile-analyzer.js +122 -0
  148. package/bin/profile/analyzers/image-analyzer.d.ts +19 -0
  149. package/bin/profile/analyzers/image-analyzer.js +85 -0
  150. package/bin/profile/cli.d.ts +4 -0
  151. package/bin/profile/cli.js +94 -0
  152. package/bin/profile/form.d.ts +56 -0
  153. package/bin/profile/form.js +401 -0
  154. package/bin/profile/index.d.ts +1 -0
  155. package/bin/profile/index.js +5 -0
  156. package/bin/profile/optimizers/index.d.ts +19 -0
  157. package/bin/profile/optimizers/index.js +137 -0
  158. package/bin/providers/add/form.d.ts +1 -1
  159. package/bin/providers/add/form.js +27 -6
  160. package/bin/providers/create/form.js +53 -3
  161. package/bin/scripts/form.js +27 -5
  162. package/bin/studio/cli.d.ts +15 -0
  163. package/bin/studio/cli.js +172 -0
  164. package/bin/studio/index.d.ts +5 -0
  165. package/bin/studio/index.js +9 -0
  166. package/bin/templates/cache.d.ts +54 -0
  167. package/bin/templates/cache.js +180 -0
  168. package/bin/templates/cli.d.ts +8 -0
  169. package/bin/templates/cli.js +294 -0
  170. package/bin/templates/fetcher.d.ts +49 -0
  171. package/bin/templates/fetcher.js +208 -0
  172. package/bin/templates/index.d.ts +11 -0
  173. package/bin/templates/index.js +37 -0
  174. package/bin/templates/manager.d.ts +116 -0
  175. package/bin/templates/manager.js +323 -0
  176. package/bin/templates/renderer.d.ts +49 -0
  177. package/bin/templates/renderer.js +204 -0
  178. package/bin/templates/types.d.ts +51 -0
  179. package/bin/templates/types.js +5 -0
  180. package/bin/utils/add-module-to-container.d.ts +14 -3
  181. package/bin/utils/add-module-to-container.js +327 -98
  182. package/bin/utils/cli-ui.d.ts +49 -3
  183. package/bin/utils/cli-ui.js +133 -13
  184. package/bin/utils/index.d.ts +4 -0
  185. package/bin/utils/index.js +4 -0
  186. package/bin/utils/input-validation.d.ts +50 -0
  187. package/bin/utils/input-validation.js +143 -0
  188. package/bin/utils/package-manager-commands.d.ts +24 -0
  189. package/bin/utils/package-manager-commands.js +50 -0
  190. package/bin/utils/safe-spawn.d.ts +35 -0
  191. package/bin/utils/safe-spawn.js +51 -0
  192. package/bin/utils/update-tsconfig-paths.d.ts +35 -0
  193. package/bin/utils/update-tsconfig-paths.js +326 -0
  194. package/package.json +165 -156
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateHerokuToRender = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const template_loader_1 = require("./template-loader");
11
+ async function generateHerokuToRender(outputDir, options) {
12
+ console.log(chalk_1.default.yellow(" Generating Heroku → Render migration..."));
13
+ const vars = (0, template_loader_1.buildMigrationVars)(options);
14
+ // Generate render.yaml
15
+ const renderConfig = `# Render Blueprint
16
+ # Generated by ExpressoTS CLI
17
+
18
+ services:
19
+ - type: web
20
+ name: expressots-app
21
+ env: node
22
+ region: oregon
23
+ plan: starter
24
+ buildCommand: npm install && npm run build
25
+ startCommand: npm start
26
+ healthCheckPath: /health
27
+ envVars:
28
+ - key: NODE_ENV
29
+ value: production
30
+ - key: PORT
31
+ value: 3000
32
+ # Add your environment variables below
33
+ # - key: DATABASE_URL
34
+ # fromDatabase:
35
+ # name: expressots-db
36
+ # property: connectionString
37
+
38
+ # Uncomment to add a PostgreSQL database
39
+ # databases:
40
+ # - name: expressots-db
41
+ # plan: starter
42
+ # databaseName: expressots
43
+ # user: expressots
44
+ `;
45
+ fs_1.default.writeFileSync(path_1.default.join(outputDir, "render.yaml"), renderConfig, "utf-8");
46
+ console.log(chalk_1.default.green(" ✓ Created render.yaml"));
47
+ // Generate migration checklist
48
+ const checklist = generateRenderChecklist();
49
+ fs_1.default.writeFileSync(path_1.default.join(outputDir, "MIGRATION_CHECKLIST.md"), checklist, "utf-8");
50
+ console.log(chalk_1.default.green(" ✓ Created MIGRATION_CHECKLIST.md"));
51
+ // Generate environment mapping
52
+ if (options.includeSecrets) {
53
+ const envMapping = generateRenderEnvMapping();
54
+ fs_1.default.writeFileSync(path_1.default.join(outputDir, "env-mapping.md"), envMapping, "utf-8");
55
+ console.log(chalk_1.default.green(" ✓ Created env-mapping.md"));
56
+ }
57
+ }
58
+ exports.generateHerokuToRender = generateHerokuToRender;
59
+ function generateRenderChecklist() {
60
+ return `# Migration Checklist: Heroku → Render
61
+
62
+ ## Pre-Migration
63
+
64
+ - [ ] Export Heroku environment variables
65
+ - [ ] Backup database
66
+ - [ ] Document Heroku add-ons
67
+
68
+ ## Render Setup
69
+
70
+ - [ ] Create Render account at https://render.com
71
+ - [ ] Copy \`render.yaml\` to project root
72
+ - [ ] Connect GitHub/GitLab repository
73
+
74
+ ## Deployment Options
75
+
76
+ ### Option 1: Blueprint (Recommended)
77
+ - [ ] Push \`render.yaml\` to repository
78
+ - [ ] In Render dashboard, click "New" → "Blueprint"
79
+ - [ ] Select your repository
80
+ - [ ] Render will create all services defined in render.yaml
81
+
82
+ ### Option 2: Manual Setup
83
+ - [ ] Create Web Service in Render dashboard
84
+ - [ ] Connect repository
85
+ - [ ] Configure build and start commands
86
+ - [ ] Set environment variables
87
+
88
+ ## Database Migration
89
+
90
+ - [ ] Create PostgreSQL in Render
91
+ - [ ] Export Heroku database: \`heroku pg:backups:capture\`
92
+ - [ ] Download backup: \`heroku pg:backups:download\`
93
+ - [ ] Import to Render PostgreSQL
94
+
95
+ ## Environment Variables
96
+
97
+ - [ ] Set all required environment variables in Render dashboard
98
+ - [ ] Configure \`DATABASE_URL\` from Render PostgreSQL
99
+
100
+ ## Custom Domain
101
+
102
+ - [ ] Add custom domain in Render
103
+ - [ ] Update DNS records (CNAME to *.onrender.com)
104
+ - [ ] Wait for SSL certificate provisioning
105
+
106
+ ## Post-Migration
107
+
108
+ - [ ] Verify all endpoints work
109
+ - [ ] Monitor logs in Render dashboard
110
+ - [ ] Disable Heroku app after verification
111
+ `;
112
+ }
113
+ function generateRenderEnvMapping() {
114
+ return `# Environment Variable Mapping: Heroku → Render
115
+
116
+ ## Automatic Variables
117
+
118
+ | Heroku | Render | Notes |
119
+ |--------|--------|-------|
120
+ | \`PORT\` | \`PORT\` | Render sets this automatically |
121
+ | \`DATABASE_URL\` | \`DATABASE_URL\` | Use fromDatabase in render.yaml |
122
+
123
+ ## Manual Configuration
124
+
125
+ Set these in Render dashboard or render.yaml:
126
+
127
+ \`\`\`yaml
128
+ envVars:
129
+ - key: NODE_ENV
130
+ value: production
131
+ - key: API_KEY
132
+ sync: false # Prompt during deploy
133
+ - key: DATABASE_URL
134
+ fromDatabase:
135
+ name: your-db
136
+ property: connectionString
137
+ \`\`\`
138
+
139
+ ## Heroku Add-on Equivalents
140
+
141
+ | Heroku Add-on | Render Alternative |
142
+ |---------------|-------------------|
143
+ | Heroku Postgres | Render PostgreSQL |
144
+ | Heroku Redis | Render Redis |
145
+ | Papertrail | Render Logs (built-in) |
146
+ | SendGrid | External service |
147
+ `;
148
+ }
@@ -0,0 +1,7 @@
1
+ export { generateHerokuToRailway } from "./heroku-to-railway";
2
+ export { generateHerokuToRender } from "./heroku-to-render";
3
+ export { generateHerokuToFly } from "./heroku-to-fly";
4
+ export { generateComposeToK8s } from "./compose-to-k8s";
5
+ export { generateComposeToRailway } from "./compose-to-railway";
6
+ export { generateComposeToRender } from "./compose-to-render";
7
+ export { generateGenericMigration } from "./generic-migration";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateGenericMigration = exports.generateComposeToRender = exports.generateComposeToRailway = exports.generateComposeToK8s = exports.generateHerokuToFly = exports.generateHerokuToRender = exports.generateHerokuToRailway = void 0;
4
+ var heroku_to_railway_1 = require("./heroku-to-railway");
5
+ Object.defineProperty(exports, "generateHerokuToRailway", { enumerable: true, get: function () { return heroku_to_railway_1.generateHerokuToRailway; } });
6
+ var heroku_to_render_1 = require("./heroku-to-render");
7
+ Object.defineProperty(exports, "generateHerokuToRender", { enumerable: true, get: function () { return heroku_to_render_1.generateHerokuToRender; } });
8
+ var heroku_to_fly_1 = require("./heroku-to-fly");
9
+ Object.defineProperty(exports, "generateHerokuToFly", { enumerable: true, get: function () { return heroku_to_fly_1.generateHerokuToFly; } });
10
+ var compose_to_k8s_1 = require("./compose-to-k8s");
11
+ Object.defineProperty(exports, "generateComposeToK8s", { enumerable: true, get: function () { return compose_to_k8s_1.generateComposeToK8s; } });
12
+ var compose_to_railway_1 = require("./compose-to-railway");
13
+ Object.defineProperty(exports, "generateComposeToRailway", { enumerable: true, get: function () { return compose_to_railway_1.generateComposeToRailway; } });
14
+ var compose_to_render_1 = require("./compose-to-render");
15
+ Object.defineProperty(exports, "generateComposeToRender", { enumerable: true, get: function () { return compose_to_render_1.generateComposeToRender; } });
16
+ var generic_migration_1 = require("./generic-migration");
17
+ Object.defineProperty(exports, "generateGenericMigration", { enumerable: true, get: function () { return generic_migration_1.generateGenericMigration; } });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Template loader for migration generators
3
+ * Handles remote template fetching with fallback to embedded templates
4
+ */
5
+ import type { MigrationOptions } from "../form";
6
+ export interface TemplateResult {
7
+ content: string;
8
+ source: "remote" | "embedded";
9
+ }
10
+ /**
11
+ * Load migration template with fallback
12
+ */
13
+ export declare function loadMigrationTemplate(from: string, to: string, file: string, variables: Record<string, unknown>, embeddedGenerator: () => string): Promise<TemplateResult>;
14
+ /**
15
+ * Build migration template variables
16
+ */
17
+ export declare function buildMigrationVars(options: MigrationOptions): Record<string, unknown>;
18
+ /**
19
+ * Log template source for debugging
20
+ */
21
+ export declare function logTemplateSource(templateName: string, source: "remote" | "embedded"): void;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * Template loader for migration generators
4
+ * Handles remote template fetching with fallback to embedded templates
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.logTemplateSource = exports.buildMigrationVars = exports.loadMigrationTemplate = void 0;
8
+ const templates_1 = require("../../templates");
9
+ /**
10
+ * Load migration template with fallback
11
+ */
12
+ async function loadMigrationTemplate(from, to, file, variables, embeddedGenerator) {
13
+ const manager = (0, templates_1.getTemplateManager)();
14
+ try {
15
+ // Try to fetch from remote template repository
16
+ const result = await manager.fetchMigrationTemplate(from, to, file);
17
+ if (result.data) {
18
+ // Template found, render with variables
19
+ const renderOptions = {
20
+ variables: variables,
21
+ };
22
+ const rendered = manager.render(result.data, renderOptions);
23
+ return { content: rendered, source: "remote" };
24
+ }
25
+ }
26
+ catch {
27
+ // Remote fetch failed, fall back to embedded
28
+ }
29
+ // Fall back to embedded template generator
30
+ return {
31
+ content: embeddedGenerator(),
32
+ source: "embedded",
33
+ };
34
+ }
35
+ exports.loadMigrationTemplate = loadMigrationTemplate;
36
+ /**
37
+ * Build migration template variables
38
+ */
39
+ function buildMigrationVars(options) {
40
+ return {
41
+ from: options.from,
42
+ to: options.to,
43
+ includeSecrets: options.includeSecrets,
44
+ includeData: options.includeData,
45
+ dryRun: options.dryRun,
46
+ outputDir: options.outputDir,
47
+ };
48
+ }
49
+ exports.buildMigrationVars = buildMigrationVars;
50
+ /**
51
+ * Log template source for debugging
52
+ */
53
+ function logTemplateSource(templateName, source) {
54
+ if (process.env.EXPRESSOTS_DEBUG) {
55
+ const sourceLabel = source === "remote" ? "remote template" : "embedded template";
56
+ console.log(` [DEBUG] ${templateName}: Using ${sourceLabel}`);
57
+ }
58
+ }
59
+ exports.logTemplateSource = logTemplateSource;
@@ -0,0 +1 @@
1
+ export { migrateCommand } from "./cli";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateCommand = void 0;
4
+ var cli_1 = require("./cli");
5
+ Object.defineProperty(exports, "migrateCommand", { enumerable: true, get: function () { return cli_1.migrateCommand; } });
package/bin/new/cli.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import { CommandModule } from "yargs";
2
2
  type CommandModuleArgs = object;
3
+ export declare const PACKAGE_MANAGER_CHOICES: readonly ["npm", "yarn", "pnpm", ...string[]];
4
+ export declare const TEMPLATE_CHOICES: readonly ["application", "micro"];
5
+ export declare const MIDDLEWARE_PRESET_CHOICES: readonly ["api", "web", "graphql", "microservice", "minimal"];
6
+ declare const NEW_COMMAND_EPILOG: string;
3
7
  declare const createProject: () => CommandModule<CommandModuleArgs, any>;
4
- export { createProject };
8
+ export { createProject, NEW_COMMAND_EPILOG };
package/bin/new/cli.js CHANGED
@@ -3,49 +3,110 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createProject = void 0;
7
- const form_1 = require("./form");
6
+ exports.NEW_COMMAND_EPILOG = exports.createProject = exports.MIDDLEWARE_PRESET_CHOICES = exports.TEMPLATE_CHOICES = exports.PACKAGE_MANAGER_CHOICES = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
8
  const semver_1 = __importDefault(require("semver"));
9
+ const form_1 = require("./form");
9
10
  const cli_ui_1 = require("../utils/cli-ui");
10
- const chalk_1 = __importDefault(require("chalk"));
11
- const packageManagers = [
11
+ exports.PACKAGE_MANAGER_CHOICES = [
12
12
  "npm",
13
13
  "yarn",
14
14
  "pnpm",
15
15
  ...(process.platform !== "win32" ? ["bun"] : []),
16
16
  ];
17
+ exports.TEMPLATE_CHOICES = ["application", "micro"];
18
+ exports.MIDDLEWARE_PRESET_CHOICES = [
19
+ "api",
20
+ "web",
21
+ "graphql",
22
+ "microservice",
23
+ "minimal",
24
+ ];
25
+ const formatInlineChoices = (choices) => choices.join(", ");
26
+ const NEW_COMMAND_EPILOG = [
27
+ chalk_1.default.bold("Available choices"),
28
+ "",
29
+ chalk_1.default.bold("Templates") + ` (${formatInlineChoices(exports.TEMPLATE_CHOICES)})`,
30
+ " application Full REST/GraphQL API (DI, controllers, lifecycle, presets)",
31
+ " micro Single-file HTTP service via micro(), no DI container",
32
+ chalk_1.default.dim(" Tip: add -e / --events with application to scaffold application-with-events"),
33
+ "",
34
+ chalk_1.default.bold("Package managers") +
35
+ ` (${formatInlineChoices(exports.PACKAGE_MANAGER_CHOICES)})`,
36
+ ...(process.platform === "win32"
37
+ ? [chalk_1.default.dim(" bun is not available on Windows")]
38
+ : []),
39
+ "",
40
+ chalk_1.default.bold("Middleware presets") +
41
+ ` (${formatInlineChoices(exports.MIDDLEWARE_PRESET_CHOICES)})` +
42
+ chalk_1.default.dim(" (application template only)"),
43
+ " api REST API: security, compression, rate limit (default)",
44
+ " web api + cookies and session",
45
+ " graphql GraphQL stack + Apollo scaffold",
46
+ " microservice Minimal parsing + compression",
47
+ " minimal parse() only; wire the rest yourself",
48
+ "",
49
+ chalk_1.default.bold("Flags"),
50
+ " -e, --events boolean: use application-with-events (not a separate -t value)",
51
+ "",
52
+ chalk_1.default.bold("Provider packages") +
53
+ chalk_1.default.dim(" (not expressots new): expressots create --provider <name>"),
54
+ "",
55
+ chalk_1.default.bold("Silent vs interactive"),
56
+ " Pass -t and -p together for non-interactive scaffold (CI-friendly).",
57
+ " Omit both for prompts (template, package manager, preset, events).",
58
+ ].join("\n");
59
+ exports.NEW_COMMAND_EPILOG = NEW_COMMAND_EPILOG;
17
60
  const commandOptions = (yargs) => {
61
+ const terminalWidth = typeof process.stdout.columns === "number" && process.stdout.columns > 0
62
+ ? Math.max(process.stdout.columns, 100)
63
+ : 120;
18
64
  return yargs
65
+ .wrap(terminalWidth)
19
66
  .positional("project-name", {
20
67
  describe: "The name of the project",
21
68
  type: "string",
22
69
  })
23
70
  .option("template", {
24
- describe: "The project template to use",
71
+ describe: "Project template",
25
72
  type: "string",
26
- choices: ["opinionated", "non-opinionated", "micro"],
73
+ choices: [...exports.TEMPLATE_CHOICES],
27
74
  alias: "t",
28
75
  })
29
76
  .option("package-manager", {
30
- describe: "The package manager to use",
77
+ describe: "Package manager",
31
78
  type: "string",
32
- choices: packageManagers,
79
+ choices: [...exports.PACKAGE_MANAGER_CHOICES],
33
80
  alias: "p",
81
+ })
82
+ .option("preset", {
83
+ describe: "Middleware preset (application template only)",
84
+ type: "string",
85
+ choices: [...exports.MIDDLEWARE_PRESET_CHOICES],
86
+ alias: "s",
87
+ })
88
+ .option("events", {
89
+ describe: "Scaffold application-with-events (boolean flag; do not pass a value)",
90
+ type: "boolean",
91
+ alias: "e",
34
92
  })
35
93
  .option("directory", {
36
- describe: "The directory for new project",
94
+ describe: "Parent directory for the new project",
37
95
  type: "string",
38
96
  alias: "d",
39
97
  })
40
98
  .implies("package-manager", "template")
41
- .implies("template", "package-manager");
99
+ .implies("template", "package-manager")
100
+ .implies("preset", "template")
101
+ .implies("events", "template")
102
+ .epilog(NEW_COMMAND_EPILOG);
42
103
  };
43
104
  const checkNodeVersion = () => {
44
- const minVersion = "18.0.0";
45
- const maxVersion = "22.5.1";
105
+ const minVersion = "20.0.0";
106
+ const maxVersion = "24.0.0";
46
107
  const currentVersion = process.version;
47
108
  if (!semver_1.default.satisfies(currentVersion, `>=${minVersion} <=${maxVersion}`)) {
48
- const msg = `Node.js version [${chalk_1.default.bold(chalk_1.default.white(currentVersion))}] is not tested. Please use a version between ${minVersion} and ${maxVersion}.`;
109
+ const msg = `Node.js version [${chalk_1.default.bold(chalk_1.default.white(currentVersion))}] is not fully tested. Recommended: v20.x or v22.x LTS.`;
49
110
  (0, cli_ui_1.printWarning)(msg);
50
111
  }
51
112
  };
@@ -54,12 +115,14 @@ const createProject = () => {
54
115
  command: "new <project-name> [package-manager] [template] [directory]",
55
116
  describe: "Create ExpressoTS application.",
56
117
  builder: commandOptions,
57
- handler: async ({ projectName, packageManager, template, directory, }) => {
118
+ handler: async ({ projectName, packageManager, template, directory, preset, events, }) => {
58
119
  checkNodeVersion();
59
120
  return await (0, form_1.projectForm)(projectName, [
60
121
  packageManager,
61
122
  template,
62
123
  directory,
124
+ preset,
125
+ events,
63
126
  ]);
64
127
  },
65
128
  };
package/bin/new/form.d.ts CHANGED
@@ -1,7 +1,10 @@
1
+ /**
2
+ * Template definitions for v4.0
3
+ */
1
4
  declare enum Template {
2
- nonopinionated = "Non-Opinionated :: Start with a clean slate and build your project from scratch.",
3
- opinionated = "Opinionated :: Automatically scaffolds resources into a preset project structure. (Recommended)",
4
- micro = "Micro :: A minimalistic template for building micro api's."
5
+ application = "Application :: Full-featured ExpressoTS application. (Recommended)",
6
+ applicationWithEvents = "Application with Events :: Application template pre-wired with the type-safe Event Bus example.",
7
+ micro = "Micro :: A minimalistic template for building micro APIs and serverless functions."
5
8
  }
6
9
  declare const enum PackageManager {
7
10
  npm = "npm",
@@ -9,7 +12,27 @@ declare const enum PackageManager {
9
12
  pnpm = "pnpm",
10
13
  bun = "bun"
11
14
  }
15
+ /**
16
+ * Middleware presets for Application template
17
+ */
18
+ declare enum MiddlewarePreset {
19
+ api = "API :: REST API with security, compression, and auto-logging. (Recommended)",
20
+ web = "Web :: Full web app with cookies and session support.",
21
+ graphql = "GraphQL :: Optimized for GraphQL APIs.",
22
+ microservice = "Microservice :: Minimal setup for microservices.",
23
+ minimal = "Minimal :: Just request parsing, customize everything yourself."
24
+ }
12
25
  type TemplateKeys = keyof typeof Template;
13
- type ProjectFormArgs = [PackageManager, TemplateKeys, string];
26
+ type MiddlewarePresetKeys = keyof typeof MiddlewarePreset;
27
+ type ProjectFormArgs = [
28
+ PackageManager,
29
+ TemplateKeys,
30
+ string,
31
+ MiddlewarePresetKeys,
32
+ boolean | undefined
33
+ ];
34
+ /**
35
+ * Main project creation form
36
+ */
14
37
  declare const projectForm: (projectName: string, args: ProjectFormArgs) => Promise<void>;
15
38
  export { projectForm };