@hszrdm/create-commerce 0.0.0-stage → 1.0.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 (68) hide show
  1. package/README.md +50 -2
  2. package/bin/create-commerce.mjs +51 -0
  3. package/package.json +23 -4
  4. package/src/cli.mjs +585 -0
  5. package/templates/backend/.env.example +113 -0
  6. package/templates/backend/README.md +7 -0
  7. package/templates/backend/instrumentation.ts +24 -0
  8. package/templates/backend/medusa-config.ts +11 -0
  9. package/templates/backend/package.json +42 -0
  10. package/templates/backend/scripts/prepare-project.mjs +49 -0
  11. package/templates/backend/src/project/README.md +13 -0
  12. package/templates/backend/src/project/api/.gitkeep +0 -0
  13. package/templates/backend/src/project/jobs/.gitkeep +0 -0
  14. package/templates/backend/src/project/modules/.gitkeep +0 -0
  15. package/templates/backend/src/project/subscribers/.gitkeep +0 -0
  16. package/templates/backend/src/project/workflows/.gitkeep +0 -0
  17. package/templates/backend/src/scripts/core-init.ts +21 -0
  18. package/templates/backend/src/scripts/create-storefront-key.ts +12 -0
  19. package/templates/backend/src/scripts/verify-bootstrap.ts +1 -0
  20. package/templates/backend/tsconfig.json +33 -0
  21. package/templates/storefront/.env.example +5 -0
  22. package/templates/storefront/README.md +108 -0
  23. package/templates/storefront/next-env.d.ts +4 -0
  24. package/templates/storefront/next.config.ts +8 -0
  25. package/templates/storefront/package.json +24 -0
  26. package/templates/storefront/src/app/[countryCode]/categories/[handle]/page.tsx +38 -0
  27. package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +51 -0
  28. package/templates/storefront/src/app/[countryCode]/products/page.tsx +47 -0
  29. package/templates/storefront/src/app/account/orders/[id]/page.tsx +8 -0
  30. package/templates/storefront/src/app/account/page.tsx +11 -0
  31. package/templates/storefront/src/app/cart/page.tsx +12 -0
  32. package/templates/storefront/src/app/checkout/page.tsx +15 -0
  33. package/templates/storefront/src/app/checkout/success/page.tsx +72 -0
  34. package/templates/storefront/src/app/error.tsx +14 -0
  35. package/templates/storefront/src/app/globals.css +250 -0
  36. package/templates/storefront/src/app/layout.tsx +59 -0
  37. package/templates/storefront/src/app/legal/page.tsx +26 -0
  38. package/templates/storefront/src/app/loading.tsx +3 -0
  39. package/templates/storefront/src/app/not-found.tsx +14 -0
  40. package/templates/storefront/src/app/page.tsx +47 -0
  41. package/templates/storefront/src/app/reset-password/page.tsx +14 -0
  42. package/templates/storefront/src/app/robots.txt/route.ts +13 -0
  43. package/templates/storefront/src/app/sitemap.xml/route.ts +13 -0
  44. package/templates/storefront/src/components/account-dashboard.tsx +325 -0
  45. package/templates/storefront/src/components/add-to-cart.tsx +71 -0
  46. package/templates/storefront/src/components/analytics.tsx +90 -0
  47. package/templates/storefront/src/components/cart-provider.tsx +236 -0
  48. package/templates/storefront/src/components/cart-view.tsx +135 -0
  49. package/templates/storefront/src/components/checkout-flow.tsx +534 -0
  50. package/templates/storefront/src/components/consent-banner.tsx +131 -0
  51. package/templates/storefront/src/components/order-detail.tsx +273 -0
  52. package/templates/storefront/src/components/product-card.tsx +38 -0
  53. package/templates/storefront/src/components/product-view-tracker.tsx +37 -0
  54. package/templates/storefront/src/components/reset-password-form.tsx +65 -0
  55. package/templates/storefront/src/components/storefront-header.tsx +42 -0
  56. package/templates/storefront/src/components/stripe-payment.tsx +90 -0
  57. package/templates/storefront/src/lib/core/account.ts +170 -0
  58. package/templates/storefront/src/lib/core/after-sales.ts +50 -0
  59. package/templates/storefront/src/lib/core/catalog.ts +56 -0
  60. package/templates/storefront/src/lib/core/checkout.ts +330 -0
  61. package/templates/storefront/src/lib/core/client.ts +107 -0
  62. package/templates/storefront/src/lib/core/commerce.ts +148 -0
  63. package/templates/storefront/src/lib/core/consent.ts +111 -0
  64. package/templates/storefront/src/lib/core/legal.ts +33 -0
  65. package/templates/storefront/src/lib/core/seo.ts +88 -0
  66. package/templates/storefront/src/lib/core/tracking.ts +584 -0
  67. package/templates/storefront/src/lib/core/types.ts +123 -0
  68. package/templates/storefront/tsconfig.json +23 -0
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # Temporary Holding Version
1
+ # @hszrdm/create-commerce
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Creates a complete standalone HSZRDM Commerce webshop project.
4
+
5
+ ```bash
6
+ npx @hszrdm/create-commerce my-shop
7
+ ```
8
+
9
+ The generator creates:
10
+
11
+ - a Medusa backend powered by `@hszrdm/core`;
12
+ - a client-owned Next.js storefront;
13
+ - random application and integration secrets;
14
+ - Medusa + Core migrations;
15
+ - Store / Region / Sales Channel / Stock Location bootstrap;
16
+ - a publishable storefront API key linked to the Sales Channel;
17
+ - the first Medusa admin user;
18
+ - backend/storefront typecheck, test and build verification;
19
+ - Git initialization with generated build artifacts ignored.
20
+
21
+ ## PostgreSQL and Redis
22
+
23
+ Docker is optional.
24
+
25
+ Use an existing PostgreSQL + Redis pair:
26
+
27
+ ```bash
28
+ npx @hszrdm/create-commerce my-shop \
29
+ --database-url "postgres://user@localhost:5432/my_shop" \
30
+ --redis-url "redis://localhost:6379"
31
+ ```
32
+
33
+ When both URLs are provided, Docker is not used.
34
+
35
+ If no external URLs are provided, Docker Compose is the convenience fallback and starts isolated PostgreSQL and Redis services when Docker is available.
36
+
37
+ The two external connection options must always be supplied together.
38
+
39
+ ## Non-interactive example
40
+
41
+ ```bash
42
+ npx @hszrdm/create-commerce my-shop \
43
+ --database-url "postgres://user@localhost:5432/my_shop" \
44
+ --redis-url "redis://localhost:6379" \
45
+ --admin-email "admin@example.com" \
46
+ --non-interactive
47
+ ```
48
+
49
+ If no admin password is supplied, the generator creates a random password and prints it once at the end. It is not written to project metadata.
50
+
51
+ Use `--help` for all options.
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync, statfsSync } from "node:fs"
4
+ import { dirname, resolve } from "node:path"
5
+ import { main } from "../src/cli.mjs"
6
+
7
+ const argv = process.argv.slice(2)
8
+
9
+ try {
10
+ ensureFreeDiskSpace(argv)
11
+ await main(argv)
12
+ } catch (error) {
13
+ console.error(`\n❌ ${error instanceof Error ? error.message : String(error)}`)
14
+ process.exitCode = 1
15
+ }
16
+
17
+ function ensureFreeDiskSpace(args) {
18
+ if (args.includes("--help") || args.includes("-h")) return
19
+
20
+ const minFreeGb = Number(process.env.HSZRDM_MIN_FREE_GB || "8")
21
+ if (!Number.isFinite(minFreeGb) || minFreeGb <= 0) return
22
+
23
+ const target = resolveTarget(args)
24
+ let probe = target
25
+ while (!existsSync(probe)) {
26
+ const parent = dirname(probe)
27
+ if (parent === probe) break
28
+ probe = parent
29
+ }
30
+
31
+ const fs = statfsSync(probe)
32
+ const availableBytes = Number(fs.bavail) * Number(fs.bsize)
33
+ const requiredBytes = minFreeGb * 1024 ** 3
34
+ if (availableBytes >= requiredBytes) return
35
+
36
+ const availableGb = availableBytes / 1024 ** 3
37
+ throw new Error(
38
+ `Nincs elég szabad tárhely a projekt létrehozásához. Elérhető: ${availableGb.toFixed(1)} GB, szükséges minimum: ${minFreeGb.toFixed(1)} GB. Szabadíts fel helyet, majd futtasd újra a create-commerce parancsot.`,
39
+ )
40
+ }
41
+
42
+ function resolveTarget(args) {
43
+ const inlineDir = args.find((arg) => arg.startsWith("--dir="))
44
+ if (inlineDir) return resolve(inlineDir.slice("--dir=".length))
45
+
46
+ const dirIndex = args.indexOf("--dir")
47
+ if (dirIndex >= 0 && args[dirIndex + 1]) return resolve(args[dirIndex + 1])
48
+
49
+ const projectName = args[0] && !args[0].startsWith("-") ? args[0] : "."
50
+ return resolve(projectName)
51
+ }
package/package.json CHANGED
@@ -1,6 +1,25 @@
1
1
  {
2
2
  "name": "@hszrdm/create-commerce",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Create a complete HSZRDM Commerce webshop project.",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "bin": {
8
+ "create-commerce": "bin/create-commerce.mjs"
9
+ },
10
+ "files": [
11
+ "bin/",
12
+ "src/",
13
+ "templates/",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "prepare:templates": "node ./scripts/prepare-templates.mjs",
18
+ "prepack": "npm run prepare:templates",
19
+ "test": "node --test"
20
+ },
21
+ "engines": {
22
+ "node": ">=22"
23
+ },
24
+ "packageManager": "npm@10.9.4"
25
+ }