@l4yercak3/cli 1.3.1 → 2.0.0-alpha.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.
Files changed (357) hide show
  1. package/README.md +10 -220
  2. package/dist/api/client.d.ts +12 -0
  3. package/dist/api/client.d.ts.map +1 -0
  4. package/dist/api/client.js +37 -0
  5. package/dist/api/client.js.map +1 -0
  6. package/dist/api/platform.d.ts +161 -0
  7. package/dist/api/platform.d.ts.map +1 -0
  8. package/dist/api/platform.js +70 -0
  9. package/dist/api/platform.js.map +1 -0
  10. package/dist/bin/sevenlayers.d.ts +3 -0
  11. package/dist/bin/sevenlayers.d.ts.map +1 -0
  12. package/dist/bin/sevenlayers.js +198 -0
  13. package/dist/bin/sevenlayers.js.map +1 -0
  14. package/dist/commands/agent/catalog.d.ts +5 -0
  15. package/dist/commands/agent/catalog.d.ts.map +1 -0
  16. package/dist/commands/agent/catalog.js +142 -0
  17. package/dist/commands/agent/catalog.js.map +1 -0
  18. package/dist/commands/agent/drift.d.ts +5 -0
  19. package/dist/commands/agent/drift.d.ts.map +1 -0
  20. package/dist/commands/agent/drift.js +113 -0
  21. package/dist/commands/agent/drift.js.map +1 -0
  22. package/dist/commands/agent/init.d.ts +5 -0
  23. package/dist/commands/agent/init.d.ts.map +1 -0
  24. package/dist/commands/agent/init.js +75 -0
  25. package/dist/commands/agent/init.js.map +1 -0
  26. package/dist/commands/agent/permissions.d.ts +5 -0
  27. package/dist/commands/agent/permissions.d.ts.map +1 -0
  28. package/dist/commands/agent/permissions.js +88 -0
  29. package/dist/commands/agent/permissions.js.map +1 -0
  30. package/dist/commands/agent/runner.d.ts +14 -0
  31. package/dist/commands/agent/runner.d.ts.map +1 -0
  32. package/dist/commands/agent/runner.js +59 -0
  33. package/dist/commands/agent/runner.js.map +1 -0
  34. package/dist/commands/agent/shared.d.ts +13 -0
  35. package/dist/commands/agent/shared.d.ts.map +1 -0
  36. package/dist/commands/agent/shared.js +31 -0
  37. package/dist/commands/agent/shared.js.map +1 -0
  38. package/dist/commands/agent/template.d.ts +5 -0
  39. package/dist/commands/agent/template.d.ts.map +1 -0
  40. package/dist/commands/agent/template.js +104 -0
  41. package/dist/commands/agent/template.js.map +1 -0
  42. package/dist/commands/app/connect.d.ts +7 -0
  43. package/dist/commands/app/connect.d.ts.map +1 -0
  44. package/dist/commands/app/connect.js +12 -0
  45. package/dist/commands/app/connect.js.map +1 -0
  46. package/dist/commands/app/init.d.ts +7 -0
  47. package/dist/commands/app/init.d.ts.map +1 -0
  48. package/dist/commands/app/init.js +12 -0
  49. package/dist/commands/app/init.js.map +1 -0
  50. package/dist/commands/app/link.d.ts +3 -0
  51. package/dist/commands/app/link.d.ts.map +1 -0
  52. package/dist/commands/app/link.js +92 -0
  53. package/dist/commands/app/link.js.map +1 -0
  54. package/dist/commands/app/pages.d.ts +15 -0
  55. package/dist/commands/app/pages.d.ts.map +1 -0
  56. package/dist/commands/app/pages.js +180 -0
  57. package/dist/commands/app/pages.js.map +1 -0
  58. package/dist/commands/app/register.d.ts +3 -0
  59. package/dist/commands/app/register.d.ts.map +1 -0
  60. package/dist/commands/app/register.js +120 -0
  61. package/dist/commands/app/register.js.map +1 -0
  62. package/dist/commands/app/remote.d.ts +14 -0
  63. package/dist/commands/app/remote.d.ts.map +1 -0
  64. package/dist/commands/app/remote.js +44 -0
  65. package/dist/commands/app/remote.js.map +1 -0
  66. package/dist/commands/app/setup.d.ts +3 -0
  67. package/dist/commands/app/setup.d.ts.map +1 -0
  68. package/dist/commands/app/setup.js +299 -0
  69. package/dist/commands/app/setup.js.map +1 -0
  70. package/dist/commands/app/shared.d.ts +9 -0
  71. package/dist/commands/app/shared.d.ts.map +1 -0
  72. package/dist/commands/app/shared.js +122 -0
  73. package/dist/commands/app/shared.js.map +1 -0
  74. package/dist/commands/app/sync.d.ts +7 -0
  75. package/dist/commands/app/sync.d.ts.map +1 -0
  76. package/dist/commands/app/sync.js +107 -0
  77. package/dist/commands/app/sync.js.map +1 -0
  78. package/dist/commands/booking/check.d.ts +3 -0
  79. package/dist/commands/booking/check.d.ts.map +1 -0
  80. package/dist/commands/booking/check.js +68 -0
  81. package/dist/commands/booking/check.js.map +1 -0
  82. package/dist/commands/booking/setup.d.ts +3 -0
  83. package/dist/commands/booking/setup.d.ts.map +1 -0
  84. package/dist/commands/booking/setup.js +95 -0
  85. package/dist/commands/booking/setup.js.map +1 -0
  86. package/dist/commands/booking/shared.d.ts +31 -0
  87. package/dist/commands/booking/shared.d.ts.map +1 -0
  88. package/dist/commands/booking/shared.js +112 -0
  89. package/dist/commands/booking/shared.js.map +1 -0
  90. package/dist/commands/booking/smoke.d.ts +3 -0
  91. package/dist/commands/booking/smoke.d.ts.map +1 -0
  92. package/dist/commands/booking/smoke.js +101 -0
  93. package/dist/commands/booking/smoke.js.map +1 -0
  94. package/dist/commands/cms/bind.d.ts +3 -0
  95. package/dist/commands/cms/bind.d.ts.map +1 -0
  96. package/dist/commands/cms/bind.js +212 -0
  97. package/dist/commands/cms/bind.js.map +1 -0
  98. package/dist/commands/cms/content.d.ts +40 -0
  99. package/dist/commands/cms/content.d.ts.map +1 -0
  100. package/dist/commands/cms/content.js +169 -0
  101. package/dist/commands/cms/content.js.map +1 -0
  102. package/dist/commands/cms/doctor.d.ts +3 -0
  103. package/dist/commands/cms/doctor.d.ts.map +1 -0
  104. package/dist/commands/cms/doctor.js +69 -0
  105. package/dist/commands/cms/doctor.js.map +1 -0
  106. package/dist/commands/cms/migrate.d.ts +3 -0
  107. package/dist/commands/cms/migrate.d.ts.map +1 -0
  108. package/dist/commands/cms/migrate.js +78 -0
  109. package/dist/commands/cms/migrate.js.map +1 -0
  110. package/dist/commands/cms/registry.d.ts +3 -0
  111. package/dist/commands/cms/registry.d.ts.map +1 -0
  112. package/dist/commands/cms/registry.js +161 -0
  113. package/dist/commands/cms/registry.js.map +1 -0
  114. package/dist/commands/cms/seed.d.ts +3 -0
  115. package/dist/commands/cms/seed.d.ts.map +1 -0
  116. package/dist/commands/cms/seed.js +102 -0
  117. package/dist/commands/cms/seed.js.map +1 -0
  118. package/dist/commands/cms/shared.d.ts +22 -0
  119. package/dist/commands/cms/shared.d.ts.map +1 -0
  120. package/dist/commands/cms/shared.js +82 -0
  121. package/dist/commands/cms/shared.js.map +1 -0
  122. package/dist/commands/doctor/target.d.ts +3 -0
  123. package/dist/commands/doctor/target.d.ts.map +1 -0
  124. package/dist/commands/doctor/target.js +46 -0
  125. package/dist/commands/doctor/target.js.map +1 -0
  126. package/dist/commands/env/list.d.ts +3 -0
  127. package/dist/commands/env/list.d.ts.map +1 -0
  128. package/dist/commands/env/list.js +28 -0
  129. package/dist/commands/env/list.js.map +1 -0
  130. package/dist/commands/env/set.d.ts +3 -0
  131. package/dist/commands/env/set.d.ts.map +1 -0
  132. package/dist/commands/env/set.js +36 -0
  133. package/dist/commands/env/set.js.map +1 -0
  134. package/dist/commands/env/use.d.ts +3 -0
  135. package/dist/commands/env/use.d.ts.map +1 -0
  136. package/dist/commands/env/use.js +15 -0
  137. package/dist/commands/env/use.js.map +1 -0
  138. package/dist/commands/legacy/connect.d.ts +3 -0
  139. package/dist/commands/legacy/connect.d.ts.map +1 -0
  140. package/dist/commands/legacy/connect.js +8 -0
  141. package/dist/commands/legacy/connect.js.map +1 -0
  142. package/dist/commands/legacy/pages.d.ts +3 -0
  143. package/dist/commands/legacy/pages.d.ts.map +1 -0
  144. package/dist/commands/legacy/pages.js +16 -0
  145. package/dist/commands/legacy/pages.js.map +1 -0
  146. package/dist/commands/legacy/spread.d.ts +3 -0
  147. package/dist/commands/legacy/spread.d.ts.map +1 -0
  148. package/dist/commands/legacy/spread.js +8 -0
  149. package/dist/commands/legacy/spread.js.map +1 -0
  150. package/dist/commands/legacy/sync.d.ts +3 -0
  151. package/dist/commands/legacy/sync.d.ts.map +1 -0
  152. package/dist/commands/legacy/sync.js +8 -0
  153. package/dist/commands/legacy/sync.js.map +1 -0
  154. package/dist/config/env-diff.d.ts +10 -0
  155. package/dist/config/env-diff.d.ts.map +1 -0
  156. package/dist/config/env-diff.js +24 -0
  157. package/dist/config/env-diff.js.map +1 -0
  158. package/dist/config/env-parser.d.ts +20 -0
  159. package/dist/config/env-parser.d.ts.map +1 -0
  160. package/dist/config/env-parser.js +70 -0
  161. package/dist/config/env-parser.js.map +1 -0
  162. package/dist/config/env-writer.d.ts +22 -0
  163. package/dist/config/env-writer.d.ts.map +1 -0
  164. package/dist/config/env-writer.js +172 -0
  165. package/dist/config/env-writer.js.map +1 -0
  166. package/dist/config/profile-store.d.ts +29 -0
  167. package/dist/config/profile-store.d.ts.map +1 -0
  168. package/dist/config/profile-store.js +257 -0
  169. package/dist/config/profile-store.js.map +1 -0
  170. package/dist/core/args.d.ts +11 -0
  171. package/dist/core/args.d.ts.map +1 -0
  172. package/dist/core/args.js +106 -0
  173. package/dist/core/args.js.map +1 -0
  174. package/dist/core/colors.d.ts +6 -0
  175. package/dist/core/colors.d.ts.map +1 -0
  176. package/dist/core/colors.js +29 -0
  177. package/dist/core/colors.js.map +1 -0
  178. package/dist/safety/target-guard.d.ts +16 -0
  179. package/dist/safety/target-guard.d.ts.map +1 -0
  180. package/dist/safety/target-guard.js +55 -0
  181. package/dist/safety/target-guard.js.map +1 -0
  182. package/dist/testing/booking-smoke.d.ts +17 -0
  183. package/dist/testing/booking-smoke.d.ts.map +1 -0
  184. package/dist/testing/booking-smoke.js +43 -0
  185. package/dist/testing/booking-smoke.js.map +1 -0
  186. package/dist/tests/agent-commands.test.d.ts +2 -0
  187. package/dist/tests/agent-commands.test.d.ts.map +1 -0
  188. package/dist/tests/agent-commands.test.js +180 -0
  189. package/dist/tests/agent-commands.test.js.map +1 -0
  190. package/dist/tests/agent-governance.test.d.ts +2 -0
  191. package/dist/tests/agent-governance.test.d.ts.map +1 -0
  192. package/dist/tests/agent-governance.test.js +233 -0
  193. package/dist/tests/agent-governance.test.js.map +1 -0
  194. package/dist/tests/app-commands.test.d.ts +2 -0
  195. package/dist/tests/app-commands.test.d.ts.map +1 -0
  196. package/dist/tests/app-commands.test.js +462 -0
  197. package/dist/tests/app-commands.test.js.map +1 -0
  198. package/dist/tests/booking-commands.test.d.ts +2 -0
  199. package/dist/tests/booking-commands.test.d.ts.map +1 -0
  200. package/dist/tests/booking-commands.test.js +204 -0
  201. package/dist/tests/booking-commands.test.js.map +1 -0
  202. package/dist/tests/booking-smoke.test.d.ts +2 -0
  203. package/dist/tests/booking-smoke.test.d.ts.map +1 -0
  204. package/dist/tests/booking-smoke.test.js +183 -0
  205. package/dist/tests/booking-smoke.test.js.map +1 -0
  206. package/dist/tests/cms-commands.test.d.ts +2 -0
  207. package/dist/tests/cms-commands.test.d.ts.map +1 -0
  208. package/dist/tests/cms-commands.test.js +254 -0
  209. package/dist/tests/cms-commands.test.js.map +1 -0
  210. package/dist/tests/cms-ops.test.d.ts +2 -0
  211. package/dist/tests/cms-ops.test.d.ts.map +1 -0
  212. package/dist/tests/cms-ops.test.js +125 -0
  213. package/dist/tests/cms-ops.test.js.map +1 -0
  214. package/dist/tests/env-writer.test.d.ts +2 -0
  215. package/dist/tests/env-writer.test.d.ts.map +1 -0
  216. package/dist/tests/env-writer.test.js +90 -0
  217. package/dist/tests/env-writer.test.js.map +1 -0
  218. package/dist/tests/profile-store.test.d.ts +2 -0
  219. package/dist/tests/profile-store.test.d.ts.map +1 -0
  220. package/dist/tests/profile-store.test.js +88 -0
  221. package/dist/tests/profile-store.test.js.map +1 -0
  222. package/dist/tests/target-guard.test.d.ts +2 -0
  223. package/dist/tests/target-guard.test.d.ts.map +1 -0
  224. package/dist/tests/target-guard.test.js +132 -0
  225. package/dist/tests/target-guard.test.js.map +1 -0
  226. package/dist/ui/logo.d.ts +2 -0
  227. package/dist/ui/logo.d.ts.map +1 -0
  228. package/dist/ui/logo.js +22 -0
  229. package/dist/ui/logo.js.map +1 -0
  230. package/package.json +17 -53
  231. package/.claude/settings.local.json +0 -36
  232. package/.cursor/rules.md +0 -203
  233. package/.eslintrc.js +0 -31
  234. package/CLAUDE.md +0 -100
  235. package/bin/cli.js +0 -116
  236. package/docs/ADDING_FRAMEWORK_DETECTORS.md +0 -391
  237. package/docs/ADDING_NEW_PROJECT_TYPE.md +0 -156
  238. package/docs/ARCHITECTURE_RELATIONSHIPS.md +0 -411
  239. package/docs/CLI_AUTHENTICATION.md +0 -214
  240. package/docs/CLI_PAGE_DETECTION_REQUIREMENTS.md +0 -519
  241. package/docs/CRM-PIPELINES-SEQUENCES-SPEC.md +0 -429
  242. package/docs/DETECTOR_ARCHITECTURE.md +0 -326
  243. package/docs/DEVELOPMENT.md +0 -194
  244. package/docs/IMPLEMENTATION_PHASES.md +0 -468
  245. package/docs/INTEGRATION_PATHS_ARCHITECTURE.md +0 -1543
  246. package/docs/OAUTH_CLARIFICATION.md +0 -258
  247. package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +0 -211
  248. package/docs/PHASE_0_PROGRESS.md +0 -120
  249. package/docs/PHASE_1_COMPLETE.md +0 -366
  250. package/docs/PHASE_SUMMARY.md +0 -149
  251. package/docs/PLAN.md +0 -511
  252. package/docs/README.md +0 -56
  253. package/docs/STRIPE_INTEGRATION.md +0 -447
  254. package/docs/SUMMARY.md +0 -230
  255. package/docs/UPDATED_PLAN.md +0 -447
  256. package/docs/mcp_server/MCP_EXTENSION_GUIDE.md +0 -1313
  257. package/docs/mcp_server/MCP_SERVER_ARCHITECTURE.md +0 -1481
  258. package/docs/mcp_server/applicationOntology.ts +0 -817
  259. package/docs/mcp_server/cliApplications.ts +0 -639
  260. package/docs/mcp_server/crmOntology.ts +0 -1063
  261. package/docs/mcp_server/eventOntology.ts +0 -1183
  262. package/docs/mcp_server/formsOntology.ts +0 -1401
  263. package/docs/mcp_server/ontologySchemas.ts +0 -185
  264. package/docs/mcp_server/schema.ts +0 -250
  265. package/docs/microsass_production_machine/CLI_API_REFERENCE.md +0 -1197
  266. package/docs/microsass_production_machine/CLI_PRODUCT_VISION.md +0 -676
  267. package/docs/microsass_production_machine/CLI_REQUIREMENTS.md +0 -606
  268. package/docs/microsass_production_machine/CONNECTED_APPLICATIONS_SPEC.md +0 -390
  269. package/docs/microsass_production_machine/IMPLEMENTATION_ROADMAP.md +0 -725
  270. package/docs/microsass_production_machine/OBJECT_MAPPINGS.md +0 -808
  271. package/docs/microsass_production_machine/REFERENCE_IMPLEMENTATION.md +0 -532
  272. package/src/api/backend-client.js +0 -449
  273. package/src/commands/api-keys.js +0 -119
  274. package/src/commands/connect.js +0 -243
  275. package/src/commands/login.js +0 -332
  276. package/src/commands/logout.js +0 -30
  277. package/src/commands/mcp-server.js +0 -85
  278. package/src/commands/mcp-setup.js +0 -686
  279. package/src/commands/pages.js +0 -317
  280. package/src/commands/scaffold.js +0 -409
  281. package/src/commands/spread.js +0 -861
  282. package/src/commands/status.js +0 -62
  283. package/src/commands/sync.js +0 -169
  284. package/src/commands/upgrade.js +0 -48
  285. package/src/config/config-manager.js +0 -206
  286. package/src/detectors/api-client-detector.js +0 -85
  287. package/src/detectors/base-detector.js +0 -77
  288. package/src/detectors/database-detector.js +0 -245
  289. package/src/detectors/expo-detector.js +0 -166
  290. package/src/detectors/github-detector.js +0 -74
  291. package/src/detectors/index.js +0 -106
  292. package/src/detectors/mapping-suggestor.js +0 -119
  293. package/src/detectors/model-detector.js +0 -318
  294. package/src/detectors/nextjs-detector.js +0 -139
  295. package/src/detectors/oauth-detector.js +0 -122
  296. package/src/detectors/page-detector.js +0 -480
  297. package/src/detectors/registry.js +0 -121
  298. package/src/generators/api-client-generator.js +0 -223
  299. package/src/generators/api-only/client.js +0 -683
  300. package/src/generators/api-only/index.js +0 -96
  301. package/src/generators/api-only/types.js +0 -618
  302. package/src/generators/api-only/webhooks.js +0 -377
  303. package/src/generators/env-generator.js +0 -191
  304. package/src/generators/expo-auth-generator.js +0 -1009
  305. package/src/generators/gitignore-generator.js +0 -92
  306. package/src/generators/index.js +0 -166
  307. package/src/generators/manifest-generator.js +0 -154
  308. package/src/generators/mcp-guide-generator.js +0 -256
  309. package/src/generators/nextauth-generator.js +0 -247
  310. package/src/generators/oauth-guide-generator.js +0 -277
  311. package/src/generators/quickstart/components/index.js +0 -1699
  312. package/src/generators/quickstart/components-mobile/index.js +0 -1440
  313. package/src/generators/quickstart/database/convex.js +0 -1257
  314. package/src/generators/quickstart/database/index.js +0 -34
  315. package/src/generators/quickstart/database/supabase.js +0 -1132
  316. package/src/generators/quickstart/hooks/index.js +0 -1065
  317. package/src/generators/quickstart/index.js +0 -191
  318. package/src/generators/quickstart/pages/index.js +0 -1466
  319. package/src/generators/quickstart/screens/index.js +0 -1498
  320. package/src/logo.js +0 -116
  321. package/src/mcp/auth.js +0 -127
  322. package/src/mcp/registry/domains/applications.js +0 -516
  323. package/src/mcp/registry/domains/benefits.js +0 -798
  324. package/src/mcp/registry/domains/codegen.js +0 -894
  325. package/src/mcp/registry/domains/core.js +0 -324
  326. package/src/mcp/registry/domains/crm.js +0 -591
  327. package/src/mcp/registry/domains/events.js +0 -649
  328. package/src/mcp/registry/domains/forms.js +0 -696
  329. package/src/mcp/registry/index.js +0 -164
  330. package/src/mcp/server.js +0 -116
  331. package/src/utils/file-utils.js +0 -117
  332. package/src/utils/init-helpers.js +0 -243
  333. package/src/utils/prompt-utils.js +0 -195
  334. package/templates/CLAUDE.md +0 -86
  335. package/tests/api-client-detector.test.js +0 -214
  336. package/tests/api-client-generator.test.js +0 -176
  337. package/tests/backend-client.test.js +0 -640
  338. package/tests/base-detector.test.js +0 -101
  339. package/tests/commands/login.test.js +0 -143
  340. package/tests/commands/logout.test.js +0 -84
  341. package/tests/commands/status.test.js +0 -167
  342. package/tests/config-manager.test.js +0 -321
  343. package/tests/database-detector.test.js +0 -221
  344. package/tests/detector-index.test.js +0 -209
  345. package/tests/detector-registry.test.js +0 -93
  346. package/tests/env-generator.test.js +0 -278
  347. package/tests/expo-detector.test.js +0 -263
  348. package/tests/file-utils.test.js +0 -194
  349. package/tests/generators-index.test.js +0 -454
  350. package/tests/github-detector.test.js +0 -145
  351. package/tests/gitignore-generator.test.js +0 -109
  352. package/tests/logo.test.js +0 -96
  353. package/tests/nextauth-generator.test.js +0 -255
  354. package/tests/nextjs-detector.test.js +0 -235
  355. package/tests/oauth-detector.test.js +0 -264
  356. package/tests/oauth-guide-generator.test.js +0 -273
  357. package/tests/page-detector.test.js +0 -371
@@ -1,1466 +0,0 @@
1
- /**
2
- * Page Generator
3
- * Generates Next.js App Router pages for L4YERCAK3 features
4
- */
5
-
6
- const fs = require('fs');
7
- const path = require('path');
8
- const { ensureDir, writeFileWithBackup, checkFileOverwrite } = require('../../../utils/file-utils');
9
-
10
- class PageGenerator {
11
- /**
12
- * Generate Next.js pages based on selected features
13
- * @param {Object} options - Generation options
14
- * @returns {Promise<Object>} - Generated file paths
15
- */
16
- async generate(options) {
17
- const { projectPath, features = [], isTypeScript, frameworkType } = options;
18
-
19
- // Only generate pages for Next.js
20
- if (frameworkType !== 'nextjs') {
21
- return {};
22
- }
23
-
24
- const results = {};
25
-
26
- // Determine app directory
27
- let appDir;
28
- if (fs.existsSync(path.join(projectPath, 'src', 'app'))) {
29
- appDir = path.join(projectPath, 'src', 'app');
30
- } else if (fs.existsSync(path.join(projectPath, 'app'))) {
31
- appDir = path.join(projectPath, 'app');
32
- } else {
33
- // Create app directory structure
34
- appDir = path.join(projectPath, 'src', 'app');
35
- ensureDir(appDir);
36
- }
37
-
38
- const ext = isTypeScript ? 'tsx' : 'jsx';
39
-
40
- // Generate CRM pages
41
- if (features.includes('crm')) {
42
- results.contactsPage = await this.generateContactsPage(appDir, ext, isTypeScript);
43
- results.contactDetailPage = await this.generateContactDetailPage(appDir, ext, isTypeScript);
44
- }
45
-
46
- // Generate Events pages
47
- if (features.includes('events')) {
48
- results.eventsPage = await this.generateEventsPage(appDir, ext, isTypeScript);
49
- results.eventDetailPage = await this.generateEventDetailPage(appDir, ext, isTypeScript);
50
- }
51
-
52
- // Generate Products pages
53
- if (features.includes('products') || features.includes('checkout')) {
54
- results.productsPage = await this.generateProductsPage(appDir, ext, isTypeScript);
55
- }
56
-
57
- // Generate dashboard page (if any features selected)
58
- if (features.length > 0) {
59
- results.dashboardPage = await this.generateDashboardPage(appDir, ext, isTypeScript, features);
60
- }
61
-
62
- // Generate providers wrapper
63
- results.providers = await this.generateProviders(appDir, ext, isTypeScript);
64
-
65
- return results;
66
- }
67
-
68
- async generateContactsPage(appDir, ext, isTypeScript) {
69
- const pageDir = path.join(appDir, 'contacts');
70
- ensureDir(pageDir);
71
-
72
- const outputPath = path.join(pageDir, `page.${ext}`);
73
-
74
- const action = await checkFileOverwrite(outputPath);
75
- if (action === 'skip') {
76
- return null;
77
- }
78
-
79
- const content = isTypeScript
80
- ? this.getContactsPageTS()
81
- : this.getContactsPageJS();
82
-
83
- return writeFileWithBackup(outputPath, content, action);
84
- }
85
-
86
- getContactsPageTS() {
87
- return `/**
88
- * Contacts Page
89
- * Lists all contacts with search and filtering
90
- * Auto-generated by @l4yercak3/cli
91
- */
92
-
93
- 'use client';
94
-
95
- import { useState } from 'react';
96
- import { useRouter } from 'next/navigation';
97
- import { ContactList, ContactForm } from '@/components/l4yercak3';
98
- import type { Contact } from '@/lib/l4yercak3/types';
99
-
100
- export default function ContactsPage() {
101
- const router = useRouter();
102
- const [showForm, setShowForm] = useState(false);
103
-
104
- const handleSelectContact = (contact: Contact) => {
105
- router.push(\`/contacts/\${contact.id}\`);
106
- };
107
-
108
- const handleCreateSuccess = (contact: Contact) => {
109
- setShowForm(false);
110
- router.push(\`/contacts/\${contact.id}\`);
111
- };
112
-
113
- return (
114
- <div className="container mx-auto px-4 py-8">
115
- <div className="flex justify-between items-center mb-6">
116
- <h1 className="text-2xl font-bold">Contacts</h1>
117
- <button
118
- onClick={() => setShowForm(!showForm)}
119
- className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
120
- >
121
- {showForm ? 'Cancel' : 'Add Contact'}
122
- </button>
123
- </div>
124
-
125
- {showForm && (
126
- <div className="mb-6 p-4 bg-white border rounded-lg shadow-sm">
127
- <h2 className="text-lg font-semibold mb-4">New Contact</h2>
128
- <ContactForm
129
- onSuccess={handleCreateSuccess}
130
- onCancel={() => setShowForm(false)}
131
- />
132
- </div>
133
- )}
134
-
135
- <ContactList onSelect={handleSelectContact} />
136
- </div>
137
- );
138
- }
139
- `;
140
- }
141
-
142
- getContactsPageJS() {
143
- return `/**
144
- * Contacts Page
145
- * Lists all contacts with search and filtering
146
- * Auto-generated by @l4yercak3/cli
147
- */
148
-
149
- 'use client';
150
-
151
- import { useState } from 'react';
152
- import { useRouter } from 'next/navigation';
153
- import { ContactList, ContactForm } from '@/components/l4yercak3';
154
-
155
- export default function ContactsPage() {
156
- const router = useRouter();
157
- const [showForm, setShowForm] = useState(false);
158
-
159
- const handleSelectContact = (contact) => {
160
- router.push(\`/contacts/\${contact.id}\`);
161
- };
162
-
163
- const handleCreateSuccess = (contact) => {
164
- setShowForm(false);
165
- router.push(\`/contacts/\${contact.id}\`);
166
- };
167
-
168
- return (
169
- <div className="container mx-auto px-4 py-8">
170
- <div className="flex justify-between items-center mb-6">
171
- <h1 className="text-2xl font-bold">Contacts</h1>
172
- <button
173
- onClick={() => setShowForm(!showForm)}
174
- className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
175
- >
176
- {showForm ? 'Cancel' : 'Add Contact'}
177
- </button>
178
- </div>
179
-
180
- {showForm && (
181
- <div className="mb-6 p-4 bg-white border rounded-lg shadow-sm">
182
- <h2 className="text-lg font-semibold mb-4">New Contact</h2>
183
- <ContactForm
184
- onSuccess={handleCreateSuccess}
185
- onCancel={() => setShowForm(false)}
186
- />
187
- </div>
188
- )}
189
-
190
- <ContactList onSelect={handleSelectContact} />
191
- </div>
192
- );
193
- }
194
- `;
195
- }
196
-
197
- async generateContactDetailPage(appDir, ext, isTypeScript) {
198
- const pageDir = path.join(appDir, 'contacts', '[id]');
199
- ensureDir(pageDir);
200
-
201
- const outputPath = path.join(pageDir, `page.${ext}`);
202
-
203
- const action = await checkFileOverwrite(outputPath);
204
- if (action === 'skip') {
205
- return null;
206
- }
207
-
208
- const content = isTypeScript
209
- ? this.getContactDetailPageTS()
210
- : this.getContactDetailPageJS();
211
-
212
- return writeFileWithBackup(outputPath, content, action);
213
- }
214
-
215
- getContactDetailPageTS() {
216
- return `/**
217
- * Contact Detail Page
218
- * Shows details and allows editing of a single contact
219
- * Auto-generated by @l4yercak3/cli
220
- */
221
-
222
- 'use client';
223
-
224
- import { useState } from 'react';
225
- import { useParams, useRouter } from 'next/navigation';
226
- import { useContact, useDeleteContact } from '@/lib/l4yercak3/hooks/use-contacts';
227
- import { ContactForm } from '@/components/l4yercak3';
228
-
229
- export default function ContactDetailPage() {
230
- const params = useParams();
231
- const router = useRouter();
232
- const [isEditing, setIsEditing] = useState(false);
233
-
234
- const contactId = params.id as string;
235
- const { data: contact, isLoading, error } = useContact(contactId);
236
- const deleteContact = useDeleteContact();
237
-
238
- if (isLoading) {
239
- return (
240
- <div className="flex items-center justify-center min-h-screen">
241
- <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
242
- </div>
243
- );
244
- }
245
-
246
- if (error || !contact) {
247
- return (
248
- <div className="container mx-auto px-4 py-8">
249
- <div className="p-4 bg-red-50 text-red-600 rounded-lg">
250
- {error?.message || 'Contact not found'}
251
- </div>
252
- </div>
253
- );
254
- }
255
-
256
- const handleDelete = async () => {
257
- if (confirm('Are you sure you want to delete this contact?')) {
258
- await deleteContact.mutateAsync(contactId);
259
- router.push('/contacts');
260
- }
261
- };
262
-
263
- const handleUpdateSuccess = () => {
264
- setIsEditing(false);
265
- };
266
-
267
- return (
268
- <div className="container mx-auto px-4 py-8">
269
- <button
270
- onClick={() => router.push('/contacts')}
271
- className="mb-4 text-blue-600 hover:underline"
272
- >
273
- &larr; Back to Contacts
274
- </button>
275
-
276
- <div className="bg-white border rounded-lg shadow-sm p-6">
277
- <div className="flex justify-between items-start mb-6">
278
- <div className="flex items-center gap-4">
279
- <div className="w-16 h-16 bg-blue-100 text-blue-600 rounded-full flex items-center justify-center text-2xl font-semibold">
280
- {contact.firstName?.[0]}{contact.lastName?.[0]}
281
- </div>
282
- <div>
283
- <h1 className="text-2xl font-bold">
284
- {contact.firstName} {contact.lastName}
285
- </h1>
286
- {contact.email && (
287
- <p className="text-gray-500">{contact.email}</p>
288
- )}
289
- </div>
290
- </div>
291
-
292
- <div className="flex gap-2">
293
- <button
294
- onClick={() => setIsEditing(!isEditing)}
295
- className="px-4 py-2 border rounded-lg hover:bg-gray-50 transition-colors"
296
- >
297
- {isEditing ? 'Cancel' : 'Edit'}
298
- </button>
299
- <button
300
- onClick={handleDelete}
301
- disabled={deleteContact.isPending}
302
- className="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50"
303
- >
304
- {deleteContact.isPending ? 'Deleting...' : 'Delete'}
305
- </button>
306
- </div>
307
- </div>
308
-
309
- {isEditing ? (
310
- <ContactForm
311
- contact={contact}
312
- onSuccess={handleUpdateSuccess}
313
- onCancel={() => setIsEditing(false)}
314
- />
315
- ) : (
316
- <div className="space-y-4">
317
- {contact.phone && (
318
- <div>
319
- <label className="text-sm text-gray-500">Phone</label>
320
- <p className="font-medium">{contact.phone}</p>
321
- </div>
322
- )}
323
-
324
- {contact.tags && contact.tags.length > 0 && (
325
- <div>
326
- <label className="text-sm text-gray-500">Tags</label>
327
- <div className="flex flex-wrap gap-2 mt-1">
328
- {contact.tags.map((tag) => (
329
- <span
330
- key={tag}
331
- className="px-3 py-1 bg-gray-100 text-gray-600 rounded-full text-sm"
332
- >
333
- {tag}
334
- </span>
335
- ))}
336
- </div>
337
- </div>
338
- )}
339
-
340
- {contact.notes && (
341
- <div>
342
- <label className="text-sm text-gray-500">Notes</label>
343
- <p className="whitespace-pre-wrap">{contact.notes}</p>
344
- </div>
345
- )}
346
- </div>
347
- )}
348
- </div>
349
- </div>
350
- );
351
- }
352
- `;
353
- }
354
-
355
- getContactDetailPageJS() {
356
- return `/**
357
- * Contact Detail Page
358
- * Shows details and allows editing of a single contact
359
- * Auto-generated by @l4yercak3/cli
360
- */
361
-
362
- 'use client';
363
-
364
- import { useState } from 'react';
365
- import { useParams, useRouter } from 'next/navigation';
366
- import { useContact, useDeleteContact } from '@/lib/l4yercak3/hooks/use-contacts';
367
- import { ContactForm } from '@/components/l4yercak3';
368
-
369
- export default function ContactDetailPage() {
370
- const params = useParams();
371
- const router = useRouter();
372
- const [isEditing, setIsEditing] = useState(false);
373
-
374
- const contactId = params.id;
375
- const { data: contact, isLoading, error } = useContact(contactId);
376
- const deleteContact = useDeleteContact();
377
-
378
- if (isLoading) {
379
- return (
380
- <div className="flex items-center justify-center min-h-screen">
381
- <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
382
- </div>
383
- );
384
- }
385
-
386
- if (error || !contact) {
387
- return (
388
- <div className="container mx-auto px-4 py-8">
389
- <div className="p-4 bg-red-50 text-red-600 rounded-lg">
390
- {error?.message || 'Contact not found'}
391
- </div>
392
- </div>
393
- );
394
- }
395
-
396
- const handleDelete = async () => {
397
- if (confirm('Are you sure you want to delete this contact?')) {
398
- await deleteContact.mutateAsync(contactId);
399
- router.push('/contacts');
400
- }
401
- };
402
-
403
- const handleUpdateSuccess = () => {
404
- setIsEditing(false);
405
- };
406
-
407
- return (
408
- <div className="container mx-auto px-4 py-8">
409
- <button
410
- onClick={() => router.push('/contacts')}
411
- className="mb-4 text-blue-600 hover:underline"
412
- >
413
- &larr; Back to Contacts
414
- </button>
415
-
416
- <div className="bg-white border rounded-lg shadow-sm p-6">
417
- <div className="flex justify-between items-start mb-6">
418
- <div className="flex items-center gap-4">
419
- <div className="w-16 h-16 bg-blue-100 text-blue-600 rounded-full flex items-center justify-center text-2xl font-semibold">
420
- {contact.firstName?.[0]}{contact.lastName?.[0]}
421
- </div>
422
- <div>
423
- <h1 className="text-2xl font-bold">
424
- {contact.firstName} {contact.lastName}
425
- </h1>
426
- {contact.email && (
427
- <p className="text-gray-500">{contact.email}</p>
428
- )}
429
- </div>
430
- </div>
431
-
432
- <div className="flex gap-2">
433
- <button
434
- onClick={() => setIsEditing(!isEditing)}
435
- className="px-4 py-2 border rounded-lg hover:bg-gray-50 transition-colors"
436
- >
437
- {isEditing ? 'Cancel' : 'Edit'}
438
- </button>
439
- <button
440
- onClick={handleDelete}
441
- disabled={deleteContact.isPending}
442
- className="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors disabled:opacity-50"
443
- >
444
- {deleteContact.isPending ? 'Deleting...' : 'Delete'}
445
- </button>
446
- </div>
447
- </div>
448
-
449
- {isEditing ? (
450
- <ContactForm
451
- contact={contact}
452
- onSuccess={handleUpdateSuccess}
453
- onCancel={() => setIsEditing(false)}
454
- />
455
- ) : (
456
- <div className="space-y-4">
457
- {contact.phone && (
458
- <div>
459
- <label className="text-sm text-gray-500">Phone</label>
460
- <p className="font-medium">{contact.phone}</p>
461
- </div>
462
- )}
463
-
464
- {contact.tags && contact.tags.length > 0 && (
465
- <div>
466
- <label className="text-sm text-gray-500">Tags</label>
467
- <div className="flex flex-wrap gap-2 mt-1">
468
- {contact.tags.map((tag) => (
469
- <span
470
- key={tag}
471
- className="px-3 py-1 bg-gray-100 text-gray-600 rounded-full text-sm"
472
- >
473
- {tag}
474
- </span>
475
- ))}
476
- </div>
477
- </div>
478
- )}
479
-
480
- {contact.notes && (
481
- <div>
482
- <label className="text-sm text-gray-500">Notes</label>
483
- <p className="whitespace-pre-wrap">{contact.notes}</p>
484
- </div>
485
- )}
486
- </div>
487
- )}
488
- </div>
489
- </div>
490
- );
491
- }
492
- `;
493
- }
494
-
495
- async generateEventsPage(appDir, ext, isTypeScript) {
496
- const pageDir = path.join(appDir, 'events');
497
- ensureDir(pageDir);
498
-
499
- const outputPath = path.join(pageDir, `page.${ext}`);
500
-
501
- const action = await checkFileOverwrite(outputPath);
502
- if (action === 'skip') {
503
- return null;
504
- }
505
-
506
- const content = isTypeScript
507
- ? this.getEventsPageTS()
508
- : this.getEventsPageJS();
509
-
510
- return writeFileWithBackup(outputPath, content, action);
511
- }
512
-
513
- getEventsPageTS() {
514
- return `/**
515
- * Events Page
516
- * Lists all events with filtering
517
- * Auto-generated by @l4yercak3/cli
518
- */
519
-
520
- 'use client';
521
-
522
- import { useRouter } from 'next/navigation';
523
- import { EventList } from '@/components/l4yercak3';
524
- import type { Event } from '@/lib/l4yercak3/types';
525
-
526
- export default function EventsPage() {
527
- const router = useRouter();
528
-
529
- const handleSelectEvent = (event: Event) => {
530
- router.push(\`/events/\${event.id}\`);
531
- };
532
-
533
- return (
534
- <div className="container mx-auto px-4 py-8">
535
- <h1 className="text-2xl font-bold mb-6">Events</h1>
536
- <EventList onSelect={handleSelectEvent} />
537
- </div>
538
- );
539
- }
540
- `;
541
- }
542
-
543
- getEventsPageJS() {
544
- return `/**
545
- * Events Page
546
- * Lists all events with filtering
547
- * Auto-generated by @l4yercak3/cli
548
- */
549
-
550
- 'use client';
551
-
552
- import { useRouter } from 'next/navigation';
553
- import { EventList } from '@/components/l4yercak3';
554
-
555
- export default function EventsPage() {
556
- const router = useRouter();
557
-
558
- const handleSelectEvent = (event) => {
559
- router.push(\`/events/\${event.id}\`);
560
- };
561
-
562
- return (
563
- <div className="container mx-auto px-4 py-8">
564
- <h1 className="text-2xl font-bold mb-6">Events</h1>
565
- <EventList onSelect={handleSelectEvent} />
566
- </div>
567
- );
568
- }
569
- `;
570
- }
571
-
572
- async generateEventDetailPage(appDir, ext, isTypeScript) {
573
- const pageDir = path.join(appDir, 'events', '[id]');
574
- ensureDir(pageDir);
575
-
576
- const outputPath = path.join(pageDir, `page.${ext}`);
577
-
578
- const action = await checkFileOverwrite(outputPath);
579
- if (action === 'skip') {
580
- return null;
581
- }
582
-
583
- const content = isTypeScript
584
- ? this.getEventDetailPageTS()
585
- : this.getEventDetailPageJS();
586
-
587
- return writeFileWithBackup(outputPath, content, action);
588
- }
589
-
590
- getEventDetailPageTS() {
591
- return `/**
592
- * Event Detail Page
593
- * Shows event details and registration
594
- * Auto-generated by @l4yercak3/cli
595
- */
596
-
597
- 'use client';
598
-
599
- import { useParams, useRouter } from 'next/navigation';
600
- import { useEvent, useEventAttendees } from '@/lib/l4yercak3/hooks/use-events';
601
-
602
- export default function EventDetailPage() {
603
- const params = useParams();
604
- const router = useRouter();
605
-
606
- const eventId = params.id as string;
607
- const { data: event, isLoading, error } = useEvent(eventId);
608
- const { data: attendees } = useEventAttendees(eventId);
609
-
610
- if (isLoading) {
611
- return (
612
- <div className="flex items-center justify-center min-h-screen">
613
- <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
614
- </div>
615
- );
616
- }
617
-
618
- if (error || !event) {
619
- return (
620
- <div className="container mx-auto px-4 py-8">
621
- <div className="p-4 bg-red-50 text-red-600 rounded-lg">
622
- {error?.message || 'Event not found'}
623
- </div>
624
- </div>
625
- );
626
- }
627
-
628
- const startDate = event.startDate ? new Date(event.startDate) : null;
629
- const endDate = event.endDate ? new Date(event.endDate) : null;
630
-
631
- const formatDate = (date: Date) => {
632
- return date.toLocaleDateString('en-US', {
633
- weekday: 'long',
634
- year: 'numeric',
635
- month: 'long',
636
- day: 'numeric',
637
- hour: 'numeric',
638
- minute: '2-digit',
639
- });
640
- };
641
-
642
- return (
643
- <div className="container mx-auto px-4 py-8">
644
- <button
645
- onClick={() => router.push('/events')}
646
- className="mb-4 text-blue-600 hover:underline"
647
- >
648
- &larr; Back to Events
649
- </button>
650
-
651
- <div className="bg-white border rounded-lg shadow-sm overflow-hidden">
652
- {/* Header */}
653
- <div className="p-6 border-b">
654
- <div className="flex justify-between items-start">
655
- <div>
656
- <h1 className="text-2xl font-bold">{event.name}</h1>
657
- {startDate && (
658
- <p className="text-gray-500 mt-1">{formatDate(startDate)}</p>
659
- )}
660
- </div>
661
- <span
662
- className={\`px-3 py-1 rounded-full text-sm \${
663
- event.status === 'published'
664
- ? 'bg-green-100 text-green-700'
665
- : event.status === 'draft'
666
- ? 'bg-gray-100 text-gray-600'
667
- : 'bg-red-100 text-red-700'
668
- }\`}
669
- >
670
- {event.status}
671
- </span>
672
- </div>
673
- </div>
674
-
675
- {/* Content */}
676
- <div className="p-6 space-y-6">
677
- {event.description && (
678
- <div>
679
- <h2 className="text-lg font-semibold mb-2">About</h2>
680
- <p className="text-gray-600 whitespace-pre-wrap">{event.description}</p>
681
- </div>
682
- )}
683
-
684
- <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
685
- {/* Date & Time */}
686
- <div>
687
- <h2 className="text-lg font-semibold mb-2">Date & Time</h2>
688
- <div className="space-y-1 text-gray-600">
689
- {startDate && <p>Starts: {formatDate(startDate)}</p>}
690
- {endDate && <p>Ends: {formatDate(endDate)}</p>}
691
- </div>
692
- </div>
693
-
694
- {/* Location */}
695
- {event.location && (
696
- <div>
697
- <h2 className="text-lg font-semibold mb-2">Location</h2>
698
- <p className="text-gray-600">{event.location}</p>
699
- </div>
700
- )}
701
- </div>
702
-
703
- {/* Attendees */}
704
- {attendees && attendees.length > 0 && (
705
- <div>
706
- <h2 className="text-lg font-semibold mb-2">
707
- Attendees ({attendees.length})
708
- </h2>
709
- <div className="flex -space-x-2">
710
- {attendees.slice(0, 10).map((attendee, i) => (
711
- <div
712
- key={attendee.id || i}
713
- className="w-8 h-8 bg-blue-100 text-blue-600 rounded-full border-2 border-white flex items-center justify-center text-xs font-medium"
714
- >
715
- {attendee.contact?.firstName?.[0] || '?'}
716
- </div>
717
- ))}
718
- {attendees.length > 10 && (
719
- <div className="w-8 h-8 bg-gray-100 text-gray-600 rounded-full border-2 border-white flex items-center justify-center text-xs">
720
- +{attendees.length - 10}
721
- </div>
722
- )}
723
- </div>
724
- </div>
725
- )}
726
- </div>
727
-
728
- {/* Actions */}
729
- <div className="p-6 border-t bg-gray-50">
730
- <button
731
- className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
732
- >
733
- Register for Event
734
- </button>
735
- </div>
736
- </div>
737
- </div>
738
- );
739
- }
740
- `;
741
- }
742
-
743
- getEventDetailPageJS() {
744
- return `/**
745
- * Event Detail Page
746
- * Shows event details and registration
747
- * Auto-generated by @l4yercak3/cli
748
- */
749
-
750
- 'use client';
751
-
752
- import { useParams, useRouter } from 'next/navigation';
753
- import { useEvent, useEventAttendees } from '@/lib/l4yercak3/hooks/use-events';
754
-
755
- export default function EventDetailPage() {
756
- const params = useParams();
757
- const router = useRouter();
758
-
759
- const eventId = params.id;
760
- const { data: event, isLoading, error } = useEvent(eventId);
761
- const { data: attendees } = useEventAttendees(eventId);
762
-
763
- if (isLoading) {
764
- return (
765
- <div className="flex items-center justify-center min-h-screen">
766
- <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900" />
767
- </div>
768
- );
769
- }
770
-
771
- if (error || !event) {
772
- return (
773
- <div className="container mx-auto px-4 py-8">
774
- <div className="p-4 bg-red-50 text-red-600 rounded-lg">
775
- {error?.message || 'Event not found'}
776
- </div>
777
- </div>
778
- );
779
- }
780
-
781
- const startDate = event.startDate ? new Date(event.startDate) : null;
782
- const endDate = event.endDate ? new Date(event.endDate) : null;
783
-
784
- const formatDate = (date) => {
785
- return date.toLocaleDateString('en-US', {
786
- weekday: 'long',
787
- year: 'numeric',
788
- month: 'long',
789
- day: 'numeric',
790
- hour: 'numeric',
791
- minute: '2-digit',
792
- });
793
- };
794
-
795
- return (
796
- <div className="container mx-auto px-4 py-8">
797
- <button
798
- onClick={() => router.push('/events')}
799
- className="mb-4 text-blue-600 hover:underline"
800
- >
801
- &larr; Back to Events
802
- </button>
803
-
804
- <div className="bg-white border rounded-lg shadow-sm overflow-hidden">
805
- {/* Header */}
806
- <div className="p-6 border-b">
807
- <div className="flex justify-between items-start">
808
- <div>
809
- <h1 className="text-2xl font-bold">{event.name}</h1>
810
- {startDate && (
811
- <p className="text-gray-500 mt-1">{formatDate(startDate)}</p>
812
- )}
813
- </div>
814
- <span
815
- className={\`px-3 py-1 rounded-full text-sm \${
816
- event.status === 'published'
817
- ? 'bg-green-100 text-green-700'
818
- : event.status === 'draft'
819
- ? 'bg-gray-100 text-gray-600'
820
- : 'bg-red-100 text-red-700'
821
- }\`}
822
- >
823
- {event.status}
824
- </span>
825
- </div>
826
- </div>
827
-
828
- {/* Content */}
829
- <div className="p-6 space-y-6">
830
- {event.description && (
831
- <div>
832
- <h2 className="text-lg font-semibold mb-2">About</h2>
833
- <p className="text-gray-600 whitespace-pre-wrap">{event.description}</p>
834
- </div>
835
- )}
836
-
837
- <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
838
- {/* Date & Time */}
839
- <div>
840
- <h2 className="text-lg font-semibold mb-2">Date & Time</h2>
841
- <div className="space-y-1 text-gray-600">
842
- {startDate && <p>Starts: {formatDate(startDate)}</p>}
843
- {endDate && <p>Ends: {formatDate(endDate)}</p>}
844
- </div>
845
- </div>
846
-
847
- {/* Location */}
848
- {event.location && (
849
- <div>
850
- <h2 className="text-lg font-semibold mb-2">Location</h2>
851
- <p className="text-gray-600">{event.location}</p>
852
- </div>
853
- )}
854
- </div>
855
-
856
- {/* Attendees */}
857
- {attendees && attendees.length > 0 && (
858
- <div>
859
- <h2 className="text-lg font-semibold mb-2">
860
- Attendees ({attendees.length})
861
- </h2>
862
- <div className="flex -space-x-2">
863
- {attendees.slice(0, 10).map((attendee, i) => (
864
- <div
865
- key={attendee.id || i}
866
- className="w-8 h-8 bg-blue-100 text-blue-600 rounded-full border-2 border-white flex items-center justify-center text-xs font-medium"
867
- >
868
- {attendee.contact?.firstName?.[0] || '?'}
869
- </div>
870
- ))}
871
- {attendees.length > 10 && (
872
- <div className="w-8 h-8 bg-gray-100 text-gray-600 rounded-full border-2 border-white flex items-center justify-center text-xs">
873
- +{attendees.length - 10}
874
- </div>
875
- )}
876
- </div>
877
- </div>
878
- )}
879
- </div>
880
-
881
- {/* Actions */}
882
- <div className="p-6 border-t bg-gray-50">
883
- <button
884
- className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
885
- >
886
- Register for Event
887
- </button>
888
- </div>
889
- </div>
890
- </div>
891
- );
892
- }
893
- `;
894
- }
895
-
896
- async generateProductsPage(appDir, ext, isTypeScript) {
897
- const pageDir = path.join(appDir, 'products');
898
- ensureDir(pageDir);
899
-
900
- const outputPath = path.join(pageDir, `page.${ext}`);
901
-
902
- const action = await checkFileOverwrite(outputPath);
903
- if (action === 'skip') {
904
- return null;
905
- }
906
-
907
- const content = isTypeScript
908
- ? this.getProductsPageTS()
909
- : this.getProductsPageJS();
910
-
911
- return writeFileWithBackup(outputPath, content, action);
912
- }
913
-
914
- getProductsPageTS() {
915
- return `/**
916
- * Products Page
917
- * Displays a grid of products with cart functionality
918
- * Auto-generated by @l4yercak3/cli
919
- */
920
-
921
- 'use client';
922
-
923
- import { useState } from 'react';
924
- import { ProductGrid } from '@/components/l4yercak3';
925
- import { useCreateCheckoutSession } from '@/lib/l4yercak3/hooks/use-products';
926
- import type { Product } from '@/lib/l4yercak3/types';
927
-
928
- interface CartItem {
929
- product: Product;
930
- quantity: number;
931
- }
932
-
933
- export default function ProductsPage() {
934
- const [cart, setCart] = useState<CartItem[]>([]);
935
- const createCheckout = useCreateCheckoutSession();
936
-
937
- const handleAddToCart = (product: Product) => {
938
- setCart((prev) => {
939
- const existing = prev.find((item) => item.product.id === product.id);
940
- if (existing) {
941
- return prev.map((item) =>
942
- item.product.id === product.id
943
- ? { ...item, quantity: item.quantity + 1 }
944
- : item
945
- );
946
- }
947
- return [...prev, { product, quantity: 1 }];
948
- });
949
- };
950
-
951
- const handleRemoveFromCart = (productId: string) => {
952
- setCart((prev) => prev.filter((item) => item.product.id !== productId));
953
- };
954
-
955
- const handleCheckout = async () => {
956
- const lineItems = cart.map((item) => ({
957
- productId: item.product.id,
958
- quantity: item.quantity,
959
- }));
960
-
961
- const session = await createCheckout.mutateAsync({
962
- lineItems,
963
- successUrl: \`\${window.location.origin}/checkout/success\`,
964
- cancelUrl: \`\${window.location.origin}/products\`,
965
- });
966
-
967
- if (session.url) {
968
- window.location.href = session.url;
969
- }
970
- };
971
-
972
- const cartTotal = cart.reduce(
973
- (total, item) => total + item.product.price * item.quantity,
974
- 0
975
- );
976
-
977
- const formatPrice = (price: number) => {
978
- return new Intl.NumberFormat('en-US', {
979
- style: 'currency',
980
- currency: 'USD',
981
- }).format(price / 100);
982
- };
983
-
984
- return (
985
- <div className="container mx-auto px-4 py-8">
986
- <div className="flex justify-between items-center mb-6">
987
- <h1 className="text-2xl font-bold">Products</h1>
988
-
989
- {/* Cart Summary */}
990
- {cart.length > 0 && (
991
- <div className="flex items-center gap-4">
992
- <span className="text-gray-600">
993
- {cart.reduce((sum, item) => sum + item.quantity, 0)} items
994
- </span>
995
- <span className="font-bold">{formatPrice(cartTotal)}</span>
996
- <button
997
- onClick={handleCheckout}
998
- disabled={createCheckout.isPending}
999
- className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50"
1000
- >
1001
- {createCheckout.isPending ? 'Processing...' : 'Checkout'}
1002
- </button>
1003
- </div>
1004
- )}
1005
- </div>
1006
-
1007
- {/* Cart Items */}
1008
- {cart.length > 0 && (
1009
- <div className="mb-6 p-4 bg-white border rounded-lg">
1010
- <h2 className="font-semibold mb-3">Cart</h2>
1011
- <div className="space-y-2">
1012
- {cart.map((item) => (
1013
- <div key={item.product.id} className="flex justify-between items-center">
1014
- <span>
1015
- {item.product.name} x {item.quantity}
1016
- </span>
1017
- <div className="flex items-center gap-3">
1018
- <span>{formatPrice(item.product.price * item.quantity)}</span>
1019
- <button
1020
- onClick={() => handleRemoveFromCart(item.product.id)}
1021
- className="text-red-600 hover:underline text-sm"
1022
- >
1023
- Remove
1024
- </button>
1025
- </div>
1026
- </div>
1027
- ))}
1028
- </div>
1029
- </div>
1030
- )}
1031
-
1032
- <ProductGrid onAddToCart={handleAddToCart} />
1033
- </div>
1034
- );
1035
- }
1036
- `;
1037
- }
1038
-
1039
- getProductsPageJS() {
1040
- return `/**
1041
- * Products Page
1042
- * Displays a grid of products with cart functionality
1043
- * Auto-generated by @l4yercak3/cli
1044
- */
1045
-
1046
- 'use client';
1047
-
1048
- import { useState } from 'react';
1049
- import { ProductGrid } from '@/components/l4yercak3';
1050
- import { useCreateCheckoutSession } from '@/lib/l4yercak3/hooks/use-products';
1051
-
1052
- export default function ProductsPage() {
1053
- const [cart, setCart] = useState([]);
1054
- const createCheckout = useCreateCheckoutSession();
1055
-
1056
- const handleAddToCart = (product) => {
1057
- setCart((prev) => {
1058
- const existing = prev.find((item) => item.product.id === product.id);
1059
- if (existing) {
1060
- return prev.map((item) =>
1061
- item.product.id === product.id
1062
- ? { ...item, quantity: item.quantity + 1 }
1063
- : item
1064
- );
1065
- }
1066
- return [...prev, { product, quantity: 1 }];
1067
- });
1068
- };
1069
-
1070
- const handleRemoveFromCart = (productId) => {
1071
- setCart((prev) => prev.filter((item) => item.product.id !== productId));
1072
- };
1073
-
1074
- const handleCheckout = async () => {
1075
- const lineItems = cart.map((item) => ({
1076
- productId: item.product.id,
1077
- quantity: item.quantity,
1078
- }));
1079
-
1080
- const session = await createCheckout.mutateAsync({
1081
- lineItems,
1082
- successUrl: \`\${window.location.origin}/checkout/success\`,
1083
- cancelUrl: \`\${window.location.origin}/products\`,
1084
- });
1085
-
1086
- if (session.url) {
1087
- window.location.href = session.url;
1088
- }
1089
- };
1090
-
1091
- const cartTotal = cart.reduce(
1092
- (total, item) => total + item.product.price * item.quantity,
1093
- 0
1094
- );
1095
-
1096
- const formatPrice = (price) => {
1097
- return new Intl.NumberFormat('en-US', {
1098
- style: 'currency',
1099
- currency: 'USD',
1100
- }).format(price / 100);
1101
- };
1102
-
1103
- return (
1104
- <div className="container mx-auto px-4 py-8">
1105
- <div className="flex justify-between items-center mb-6">
1106
- <h1 className="text-2xl font-bold">Products</h1>
1107
-
1108
- {/* Cart Summary */}
1109
- {cart.length > 0 && (
1110
- <div className="flex items-center gap-4">
1111
- <span className="text-gray-600">
1112
- {cart.reduce((sum, item) => sum + item.quantity, 0)} items
1113
- </span>
1114
- <span className="font-bold">{formatPrice(cartTotal)}</span>
1115
- <button
1116
- onClick={handleCheckout}
1117
- disabled={createCheckout.isPending}
1118
- className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors disabled:opacity-50"
1119
- >
1120
- {createCheckout.isPending ? 'Processing...' : 'Checkout'}
1121
- </button>
1122
- </div>
1123
- )}
1124
- </div>
1125
-
1126
- {/* Cart Items */}
1127
- {cart.length > 0 && (
1128
- <div className="mb-6 p-4 bg-white border rounded-lg">
1129
- <h2 className="font-semibold mb-3">Cart</h2>
1130
- <div className="space-y-2">
1131
- {cart.map((item) => (
1132
- <div key={item.product.id} className="flex justify-between items-center">
1133
- <span>
1134
- {item.product.name} x {item.quantity}
1135
- </span>
1136
- <div className="flex items-center gap-3">
1137
- <span>{formatPrice(item.product.price * item.quantity)}</span>
1138
- <button
1139
- onClick={() => handleRemoveFromCart(item.product.id)}
1140
- className="text-red-600 hover:underline text-sm"
1141
- >
1142
- Remove
1143
- </button>
1144
- </div>
1145
- </div>
1146
- ))}
1147
- </div>
1148
- </div>
1149
- )}
1150
-
1151
- <ProductGrid onAddToCart={handleAddToCart} />
1152
- </div>
1153
- );
1154
- }
1155
- `;
1156
- }
1157
-
1158
- async generateDashboardPage(appDir, ext, isTypeScript, features) {
1159
- const pageDir = path.join(appDir, 'dashboard');
1160
- ensureDir(pageDir);
1161
-
1162
- const outputPath = path.join(pageDir, `page.${ext}`);
1163
-
1164
- const action = await checkFileOverwrite(outputPath);
1165
- if (action === 'skip') {
1166
- return null;
1167
- }
1168
-
1169
- const content = isTypeScript
1170
- ? this.getDashboardPageTS(features)
1171
- : this.getDashboardPageJS(features);
1172
-
1173
- return writeFileWithBackup(outputPath, content, action);
1174
- }
1175
-
1176
- getDashboardPageTS(features) {
1177
- const imports = [];
1178
- const cards = [];
1179
-
1180
- if (features.includes('crm')) {
1181
- imports.push("import { useContacts } from '@/lib/l4yercak3/hooks/use-contacts';");
1182
- cards.push(`
1183
- {/* Contacts Card */}
1184
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1185
- <h2 className="text-lg font-semibold mb-2">Contacts</h2>
1186
- <div className="text-3xl font-bold text-blue-600">
1187
- {contactsLoading ? '...' : contacts?.length || 0}
1188
- </div>
1189
- <p className="text-gray-500 text-sm mt-1">Total contacts</p>
1190
- <a href="/contacts" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
1191
- View all &rarr;
1192
- </a>
1193
- </div>`);
1194
- }
1195
-
1196
- if (features.includes('events')) {
1197
- imports.push("import { useEvents } from '@/lib/l4yercak3/hooks/use-events';");
1198
- cards.push(`
1199
- {/* Events Card */}
1200
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1201
- <h2 className="text-lg font-semibold mb-2">Upcoming Events</h2>
1202
- <div className="text-3xl font-bold text-green-600">
1203
- {eventsLoading ? '...' : events?.length || 0}
1204
- </div>
1205
- <p className="text-gray-500 text-sm mt-1">Events scheduled</p>
1206
- <a href="/events" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
1207
- View all &rarr;
1208
- </a>
1209
- </div>`);
1210
- }
1211
-
1212
- if (features.includes('products') || features.includes('checkout')) {
1213
- imports.push("import { useProducts, useOrders } from '@/lib/l4yercak3/hooks/use-products';");
1214
- cards.push(`
1215
- {/* Products Card */}
1216
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1217
- <h2 className="text-lg font-semibold mb-2">Products</h2>
1218
- <div className="text-3xl font-bold text-purple-600">
1219
- {productsLoading ? '...' : products?.length || 0}
1220
- </div>
1221
- <p className="text-gray-500 text-sm mt-1">Active products</p>
1222
- <a href="/products" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
1223
- View all &rarr;
1224
- </a>
1225
- </div>`);
1226
- cards.push(`
1227
- {/* Orders Card */}
1228
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1229
- <h2 className="text-lg font-semibold mb-2">Recent Orders</h2>
1230
- <div className="text-3xl font-bold text-orange-600">
1231
- {ordersLoading ? '...' : orders?.length || 0}
1232
- </div>
1233
- <p className="text-gray-500 text-sm mt-1">Orders this month</p>
1234
- </div>`);
1235
- }
1236
-
1237
- const hookCalls = [];
1238
- if (features.includes('crm')) {
1239
- hookCalls.push("const { data: contacts, isLoading: contactsLoading } = useContacts();");
1240
- }
1241
- if (features.includes('events')) {
1242
- hookCalls.push("const { data: events, isLoading: eventsLoading } = useEvents({ status: 'upcoming' });");
1243
- }
1244
- if (features.includes('products') || features.includes('checkout')) {
1245
- hookCalls.push("const { data: products, isLoading: productsLoading } = useProducts();");
1246
- hookCalls.push("const { data: orders, isLoading: ordersLoading } = useOrders();");
1247
- }
1248
-
1249
- return `/**
1250
- * Dashboard Page
1251
- * Overview of L4YERCAK3 data
1252
- * Auto-generated by @l4yercak3/cli
1253
- */
1254
-
1255
- 'use client';
1256
-
1257
- ${imports.join('\n')}
1258
-
1259
- export default function DashboardPage() {
1260
- ${hookCalls.join('\n ')}
1261
-
1262
- return (
1263
- <div className="container mx-auto px-4 py-8">
1264
- <h1 className="text-2xl font-bold mb-6">Dashboard</h1>
1265
-
1266
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
1267
- ${cards.join('\n ')}
1268
- </div>
1269
- </div>
1270
- );
1271
- }
1272
- `;
1273
- }
1274
-
1275
- getDashboardPageJS(features) {
1276
- const imports = [];
1277
- const cards = [];
1278
-
1279
- if (features.includes('crm')) {
1280
- imports.push("import { useContacts } from '@/lib/l4yercak3/hooks/use-contacts';");
1281
- cards.push(`
1282
- {/* Contacts Card */}
1283
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1284
- <h2 className="text-lg font-semibold mb-2">Contacts</h2>
1285
- <div className="text-3xl font-bold text-blue-600">
1286
- {contactsLoading ? '...' : contacts?.length || 0}
1287
- </div>
1288
- <p className="text-gray-500 text-sm mt-1">Total contacts</p>
1289
- <a href="/contacts" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
1290
- View all &rarr;
1291
- </a>
1292
- </div>`);
1293
- }
1294
-
1295
- if (features.includes('events')) {
1296
- imports.push("import { useEvents } from '@/lib/l4yercak3/hooks/use-events';");
1297
- cards.push(`
1298
- {/* Events Card */}
1299
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1300
- <h2 className="text-lg font-semibold mb-2">Upcoming Events</h2>
1301
- <div className="text-3xl font-bold text-green-600">
1302
- {eventsLoading ? '...' : events?.length || 0}
1303
- </div>
1304
- <p className="text-gray-500 text-sm mt-1">Events scheduled</p>
1305
- <a href="/events" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
1306
- View all &rarr;
1307
- </a>
1308
- </div>`);
1309
- }
1310
-
1311
- if (features.includes('products') || features.includes('checkout')) {
1312
- imports.push("import { useProducts, useOrders } from '@/lib/l4yercak3/hooks/use-products';");
1313
- cards.push(`
1314
- {/* Products Card */}
1315
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1316
- <h2 className="text-lg font-semibold mb-2">Products</h2>
1317
- <div className="text-3xl font-bold text-purple-600">
1318
- {productsLoading ? '...' : products?.length || 0}
1319
- </div>
1320
- <p className="text-gray-500 text-sm mt-1">Active products</p>
1321
- <a href="/products" className="text-blue-600 text-sm hover:underline mt-4 inline-block">
1322
- View all &rarr;
1323
- </a>
1324
- </div>`);
1325
- cards.push(`
1326
- {/* Orders Card */}
1327
- <div className="bg-white p-6 rounded-lg border shadow-sm">
1328
- <h2 className="text-lg font-semibold mb-2">Recent Orders</h2>
1329
- <div className="text-3xl font-bold text-orange-600">
1330
- {ordersLoading ? '...' : orders?.length || 0}
1331
- </div>
1332
- <p className="text-gray-500 text-sm mt-1">Orders this month</p>
1333
- </div>`);
1334
- }
1335
-
1336
- const hookCalls = [];
1337
- if (features.includes('crm')) {
1338
- hookCalls.push("const { data: contacts, isLoading: contactsLoading } = useContacts();");
1339
- }
1340
- if (features.includes('events')) {
1341
- hookCalls.push("const { data: events, isLoading: eventsLoading } = useEvents({ status: 'upcoming' });");
1342
- }
1343
- if (features.includes('products') || features.includes('checkout')) {
1344
- hookCalls.push("const { data: products, isLoading: productsLoading } = useProducts();");
1345
- hookCalls.push("const { data: orders, isLoading: ordersLoading } = useOrders();");
1346
- }
1347
-
1348
- return `/**
1349
- * Dashboard Page
1350
- * Overview of L4YERCAK3 data
1351
- * Auto-generated by @l4yercak3/cli
1352
- */
1353
-
1354
- 'use client';
1355
-
1356
- ${imports.join('\n')}
1357
-
1358
- export default function DashboardPage() {
1359
- ${hookCalls.join('\n ')}
1360
-
1361
- return (
1362
- <div className="container mx-auto px-4 py-8">
1363
- <h1 className="text-2xl font-bold mb-6">Dashboard</h1>
1364
-
1365
- <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
1366
- ${cards.join('\n ')}
1367
- </div>
1368
- </div>
1369
- );
1370
- }
1371
- `;
1372
- }
1373
-
1374
- async generateProviders(appDir, ext, isTypeScript) {
1375
- const outputPath = path.join(appDir, `providers.${ext}`);
1376
-
1377
- const action = await checkFileOverwrite(outputPath);
1378
- if (action === 'skip') {
1379
- return null;
1380
- }
1381
-
1382
- const content = isTypeScript
1383
- ? this.getProvidersTS()
1384
- : this.getProvidersJS();
1385
-
1386
- return writeFileWithBackup(outputPath, content, action);
1387
- }
1388
-
1389
- getProvidersTS() {
1390
- return `/**
1391
- * App Providers
1392
- * Wraps the app with necessary providers (React Query, etc.)
1393
- * Auto-generated by @l4yercak3/cli
1394
- */
1395
-
1396
- 'use client';
1397
-
1398
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
1399
- import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
1400
- import { useState, type ReactNode } from 'react';
1401
-
1402
- interface ProvidersProps {
1403
- children: ReactNode;
1404
- }
1405
-
1406
- export function Providers({ children }: ProvidersProps) {
1407
- const [queryClient] = useState(
1408
- () =>
1409
- new QueryClient({
1410
- defaultOptions: {
1411
- queries: {
1412
- staleTime: 60 * 1000, // 1 minute
1413
- refetchOnWindowFocus: false,
1414
- },
1415
- },
1416
- })
1417
- );
1418
-
1419
- return (
1420
- <QueryClientProvider client={queryClient}>
1421
- {children}
1422
- <ReactQueryDevtools initialIsOpen={false} />
1423
- </QueryClientProvider>
1424
- );
1425
- }
1426
- `;
1427
- }
1428
-
1429
- getProvidersJS() {
1430
- return `/**
1431
- * App Providers
1432
- * Wraps the app with necessary providers (React Query, etc.)
1433
- * Auto-generated by @l4yercak3/cli
1434
- */
1435
-
1436
- 'use client';
1437
-
1438
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
1439
- import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
1440
- import { useState } from 'react';
1441
-
1442
- export function Providers({ children }) {
1443
- const [queryClient] = useState(
1444
- () =>
1445
- new QueryClient({
1446
- defaultOptions: {
1447
- queries: {
1448
- staleTime: 60 * 1000, // 1 minute
1449
- refetchOnWindowFocus: false,
1450
- },
1451
- },
1452
- })
1453
- );
1454
-
1455
- return (
1456
- <QueryClientProvider client={queryClient}>
1457
- {children}
1458
- <ReactQueryDevtools initialIsOpen={false} />
1459
- </QueryClientProvider>
1460
- );
1461
- }
1462
- `;
1463
- }
1464
- }
1465
-
1466
- module.exports = new PageGenerator();