@onexapis/cli 1.1.38 → 1.1.40

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 (60) hide show
  1. package/dist/cli.js +384 -380
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +381 -376
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/index.js +258 -293
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +255 -289
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/preview/preview-app.tsx +13 -5
  10. package/package.json +1 -3
  11. package/templates/default/AUTH_AND_PROFILE.md +167 -0
  12. package/templates/default/CLAUDE.md +435 -6
  13. package/templates/default/LAYOUT.md +195 -0
  14. package/templates/default/bundle-entry.ts +5 -0
  15. package/templates/default/esbuild.config.js +20 -0
  16. package/templates/default/hooks/index.ts +26 -0
  17. package/templates/default/hooks/use-forgot-password-form.ts +90 -0
  18. package/templates/default/hooks/use-login-form.ts +102 -0
  19. package/templates/default/hooks/use-profile-form.ts +255 -0
  20. package/templates/default/hooks/use-register-form.ts +154 -0
  21. package/templates/default/hooks/use-verify-code-form.ts +224 -0
  22. package/templates/default/index.ts +21 -1
  23. package/templates/default/pages/about.ts +2 -2
  24. package/templates/default/pages/forgot-password.ts +39 -0
  25. package/templates/default/pages/home.ts +4 -4
  26. package/templates/default/pages/login.ts +39 -0
  27. package/templates/default/pages/profile.ts +39 -0
  28. package/templates/default/pages/register.ts +39 -0
  29. package/templates/default/pages/showcase.ts +7 -7
  30. package/templates/default/pages/verify-code.ts +39 -0
  31. package/templates/default/sections/about/about.schema.ts +1 -1
  32. package/templates/default/sections/auth-forgot-password/auth-forgot-password-default.tsx +192 -0
  33. package/templates/default/sections/auth-forgot-password/auth-forgot-password.schema.ts +150 -0
  34. package/templates/default/sections/auth-forgot-password/index.ts +14 -0
  35. package/templates/default/sections/auth-login/auth-login-default.tsx +238 -0
  36. package/templates/default/sections/auth-login/auth-login.schema.ts +171 -0
  37. package/templates/default/sections/auth-login/index.ts +14 -0
  38. package/templates/default/sections/auth-register/auth-register-default.tsx +327 -0
  39. package/templates/default/sections/auth-register/auth-register.schema.ts +188 -0
  40. package/templates/default/sections/auth-register/index.ts +14 -0
  41. package/templates/default/sections/auth-verify-code/auth-verify-code-default.tsx +209 -0
  42. package/templates/default/sections/auth-verify-code/auth-verify-code.schema.ts +150 -0
  43. package/templates/default/sections/auth-verify-code/index.ts +14 -0
  44. package/templates/default/sections/cta/cta.schema.ts +1 -1
  45. package/templates/default/sections/features/features.schema.ts +1 -1
  46. package/templates/default/sections/footer/footer-default.tsx +214 -0
  47. package/templates/default/sections/footer/footer.schema.ts +170 -0
  48. package/templates/default/sections/footer/index.ts +14 -0
  49. package/templates/default/sections/gallery/gallery.schema.ts +1 -1
  50. package/templates/default/sections/header/header-default.tsx +322 -0
  51. package/templates/default/sections/header/header.schema.ts +168 -0
  52. package/templates/default/sections/header/index.ts +14 -0
  53. package/templates/default/sections/hero/hero.schema.ts +1 -1
  54. package/templates/default/sections/profile/index.ts +14 -0
  55. package/templates/default/sections/profile/profile-default.tsx +522 -0
  56. package/templates/default/sections/profile/profile.schema.ts +228 -0
  57. package/templates/default/sections/stats/stats.schema.ts +1 -1
  58. package/templates/default/sections/testimonials/testimonials.schema.ts +1 -1
  59. package/templates/default/sections-registry.ts +28 -0
  60. package/templates/default/theme.layout.ts +71 -2
@@ -455,6 +455,14 @@ function PreviewApp() {
455
455
  >("disconnected");
456
456
  const [error, setError] = useState<string | null>(null);
457
457
  const wsRef = useRef<WebSocket | null>(null);
458
+ const [isEditing, setIsEditing] = useState(() => {
459
+ if (typeof window !== "undefined") {
460
+ return (
461
+ new URLSearchParams(window.location.search).get("editing") === "true"
462
+ );
463
+ }
464
+ return false;
465
+ });
458
466
 
459
467
  // Load theme bundle
460
468
  const loadTheme = useCallback(async (timestamp?: number) => {
@@ -701,7 +709,7 @@ function PreviewApp() {
701
709
  section={section}
702
710
  schema={schema}
703
711
  template={template}
704
- isEditing={false}
712
+ isEditing={isEditing}
705
713
  data={sectionData}
706
714
  />
707
715
  );
@@ -712,16 +720,16 @@ function PreviewApp() {
712
720
  {/* Inject theme CSS variables (Gap 2) */}
713
721
  {themeCSS && <style dangerouslySetInnerHTML={{ __html: themeCSS }} />}
714
722
 
715
- {/* Header (Gap 1) */}
716
- {headerSections.length > 0 && (
723
+ {/* Header hidden if page config sets hideHeader: true */}
724
+ {headerSections.length > 0 && !currentPage.config?.hideHeader && (
717
725
  <header>{headerSections.map(renderSection)}</header>
718
726
  )}
719
727
 
720
728
  {/* Page sections */}
721
729
  <main>{pageSections.map(renderSection)}</main>
722
730
 
723
- {/* Footer (Gap 1) */}
724
- {footerSections.length > 0 && (
731
+ {/* Footer hidden if page config sets hideFooter: true */}
732
+ {footerSections.length > 0 && !currentPage.config?.hideFooter && (
725
733
  <footer>{footerSections.map(renderSection)}</footer>
726
734
  )}
727
735
  </>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onexapis/cli",
3
- "version": "1.1.38",
3
+ "version": "1.1.40",
4
4
  "description": "CLI tool for OneX theme development - scaffolds themes using @onexapis/core",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -57,7 +57,6 @@
57
57
  "chalk": "^5.3.0",
58
58
  "chokidar": "^4.0.0",
59
59
  "commander": "^12.1.0",
60
- "cross-spawn": "^7.0.6",
61
60
  "dotenv": "^17.3.1",
62
61
  "ejs": "^3.1.10",
63
62
  "esbuild": "^0.25.0",
@@ -78,7 +77,6 @@
78
77
  "devDependencies": {
79
78
  "@types/adm-zip": "^0.5.7",
80
79
  "@types/archiver": "^7.0.0",
81
- "@types/cross-spawn": "^6.0.6",
82
80
  "@types/ejs": "^3.1.5",
83
81
  "@types/fs-extra": "^11.0.4",
84
82
  "@types/inquirer": "^9.0.7",
@@ -0,0 +1,167 @@
1
+ # Authentication & Profile — Default Theme
2
+
3
+ This document covers the built-in authentication and profile sections included in the default theme template.
4
+
5
+ ## Overview
6
+
7
+ When you initialize a theme with `onexthm init`, it comes with 5 auth/profile sections and their corresponding hooks ready to use:
8
+
9
+ | Section | Path | Description |
10
+ | -------------------- | ------------------ | -------------------------------------------- |
11
+ | Auth Login | `/login` | Username/email + password sign-in |
12
+ | Auth Register | `/register` | Email, username, password, confirm password |
13
+ | Auth Forgot Password | `/forgot-password` | Request verification code via email/username |
14
+ | Auth Verify Code | `/verify-code` | 6-digit OTP input with resend + countdown |
15
+ | Profile | `/profile` | View/edit profile + change password |
16
+
17
+ ## Architecture
18
+
19
+ ```
20
+ Theme Section (UI only)
21
+ └── Theme Hook (form state, validation)
22
+ └── useAuth() from @onexapis/core/hooks (Zustand store)
23
+ └── AuthService (API calls)
24
+ └── ApiClient (HTTP client with token management)
25
+ ```
26
+
27
+ ### Hooks
28
+
29
+ All hooks live in `hooks/` and use `useAuth` from `@onexapis/core/hooks`:
30
+
31
+ | Hook | Uses | Manages |
32
+ | ----------------------- | ------------------------------------------------------------- | ---------------------------------------------------- |
33
+ | `useLoginForm` | `useAuth().login()` | Username, password, show/hide toggle, validation |
34
+ | `useRegisterForm` | `useAuth().signup()` | Email, username, password, confirm, validation |
35
+ | `useForgotPasswordForm` | `useAuth().forgotPassword()` | Username/email input, validation |
36
+ | `useVerifyCodeForm` | `useAuth().verifyCode()`, `verifyCodeReset()`, `resendCode()` | 6-digit OTP, auto-focus, paste, countdown |
37
+ | `useProfileForm` | `useAuth().updateProfile()`, `changePassword()`, `logout()` | Profile fields, dirty tracking, change password form |
38
+
39
+ ### API Endpoints
40
+
41
+ The `AuthService` in `@onexapis/core` handles all API calls:
42
+
43
+ | Action | Method | Endpoint |
44
+ | ------------------- | ------ | ----------------------------------- |
45
+ | Login | POST | `/auth/login` |
46
+ | Register | POST | `/auth/register` |
47
+ | Forgot Password | POST | `/auth/forgot` |
48
+ | Verify Code | POST | `/auth/confirm` |
49
+ | Verify Code (reset) | POST | `/auth/confirm_reset_password_code` |
50
+ | Resend Code | POST | `/auth/resend_code` |
51
+ | Reset Password | POST | `/auth/new_password` |
52
+ | Change Password | POST | `/auth/change_password` |
53
+ | Get User Info | GET | `/auth/user_info` |
54
+ | Update Profile | POST | `/auth/user_info` |
55
+
56
+ ### Token Handling
57
+
58
+ - **IdToken** → `Authorization: Bearer {IdToken}` header
59
+ - **AccessToken** → `?access_token={AccessToken}` query parameter
60
+ - **Tokens stored** in `localStorage` under key `auth_tokens`
61
+ - **Signup** auto-injects `company_id` (from `initializeOnex()` config) and `is_customer: true`
62
+
63
+ ## Editable Settings
64
+
65
+ All sections expose these layout settings via the editor sidebar:
66
+
67
+ | Setting | Type | Default | Description |
68
+ | ------------------ | ------ | --------- | ------------------------------------ |
69
+ | `backgroundColor` | color | `#F9FAFB` | Page background |
70
+ | `cardBackground` | color | `#FFFFFF` | Card/form container background |
71
+ | `primaryColor` | color | `#2563EB` | Buttons and links |
72
+ | `textColor` | color | `#111827` | Heading text color |
73
+ | `cardBorderRadius` | select | `2xl` | Card corner rounding (lg/xl/2xl/3xl) |
74
+
75
+ Plus all text labels, placeholders, button text, and URLs are customizable per section.
76
+
77
+ ## Auth Flow
78
+
79
+ ```
80
+ Register → Verify Code → Login → Profile
81
+ ↑ │
82
+ Forgot Password → Verify Code (reset) → Reset Password
83
+ ```
84
+
85
+ 1. **Register**: User fills email, username, password → `signup()` → redirects to `/verify-code?username=...`
86
+ 2. **Verify Code**: User enters 6-digit OTP → `verifyCode()` → redirects to `/login`
87
+ 3. **Login**: User signs in → `login()` → tokens stored → redirects to `/`
88
+ 4. **Forgot Password**: User enters email → `forgotPassword()` → redirects to `/verify-code?mode=reset&username=...`
89
+ 5. **Verify Code (reset)**: OTP → `verifyCodeReset()` → returns session → redirects to `/reset-password?session=...`
90
+ 6. **Profile**: View/edit name, phone, address → `updateProfile()`. Change password → `changePassword()`
91
+
92
+ ## Configuration
93
+
94
+ ### Required Environment Variables
95
+
96
+ ```env
97
+ NEXT_PUBLIC_API_URL=https://api-dev.onexeos.com
98
+ NEXT_PUBLIC_COMPANY_ID=your-company-id
99
+ ```
100
+
101
+ These are read by `initializeOnex()` which creates the `AuthService` and registers it with the `useAuth` Zustand store.
102
+
103
+ ## Testing Locally
104
+
105
+ ### Preview mode (UI only)
106
+
107
+ ```bash
108
+ onexthm dev
109
+ # Visit http://localhost:3456/login
110
+ ```
111
+
112
+ ### Preview with editing mode
113
+
114
+ ```bash
115
+ onexthm dev
116
+ # Visit http://localhost:3456/login?editing=true
117
+ ```
118
+
119
+ ### Preview with real API (requires .env)
120
+
121
+ Create `.env` in your theme directory:
122
+
123
+ ```env
124
+ NEXT_PUBLIC_API_URL=https://api-dev.onexeos.com
125
+ NEXT_PUBLIC_COMPANY_ID=your-company-id
126
+ ```
127
+
128
+ Then run `onexthm dev` — login/register/verify will make real API calls.
129
+
130
+ ## File Structure
131
+
132
+ ```
133
+ hooks/
134
+ index.ts
135
+ use-login-form.ts
136
+ use-register-form.ts
137
+ use-forgot-password-form.ts
138
+ use-verify-code-form.ts
139
+ use-profile-form.ts
140
+ sections/
141
+ auth-login/
142
+ auth-login-default.tsx # Login form UI
143
+ auth-login.schema.ts # Editable settings
144
+ index.ts
145
+ auth-register/
146
+ auth-register-default.tsx
147
+ auth-register.schema.ts
148
+ index.ts
149
+ auth-forgot-password/
150
+ auth-forgot-password-default.tsx
151
+ auth-forgot-password.schema.ts
152
+ index.ts
153
+ auth-verify-code/
154
+ auth-verify-code-default.tsx
155
+ auth-verify-code.schema.ts
156
+ index.ts
157
+ profile/
158
+ profile-default.tsx
159
+ profile.schema.ts
160
+ index.ts
161
+ pages/
162
+ login.ts
163
+ register.ts
164
+ forgot-password.ts
165
+ verify-code.ts
166
+ profile.ts
167
+ ```