saafe-redirection-flow 2.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 (225) hide show
  1. package/.github/workflows/build-and-deploy.yml +41 -0
  2. package/.gitlab-ci.yml +108 -0
  3. package/.releaserc.json +18 -0
  4. package/.storybook/main.ts +28 -0
  5. package/.storybook/preview.ts +16 -0
  6. package/.storybook/vitest.setup.ts +9 -0
  7. package/.vite/deps/@radix-ui_react-avatar.js +230 -0
  8. package/.vite/deps/@radix-ui_react-avatar.js.map +7 -0
  9. package/.vite/deps/@radix-ui_react-slot.js +12 -0
  10. package/.vite/deps/@radix-ui_react-slot.js.map +7 -0
  11. package/.vite/deps/_metadata.json +79 -0
  12. package/.vite/deps/chunk-5VGQBUCU.js +597 -0
  13. package/.vite/deps/chunk-5VGQBUCU.js.map +7 -0
  14. package/.vite/deps/chunk-DC5AMYBS.js +38 -0
  15. package/.vite/deps/chunk-DC5AMYBS.js.map +7 -0
  16. package/.vite/deps/chunk-HUIEPYH7.js +11265 -0
  17. package/.vite/deps/chunk-HUIEPYH7.js.map +7 -0
  18. package/.vite/deps/chunk-TKHB4QMX.js +281 -0
  19. package/.vite/deps/chunk-TKHB4QMX.js.map +7 -0
  20. package/.vite/deps/chunk-YLDSBLSF.js +1139 -0
  21. package/.vite/deps/chunk-YLDSBLSF.js.map +7 -0
  22. package/.vite/deps/class-variance-authority.js +63 -0
  23. package/.vite/deps/class-variance-authority.js.map +7 -0
  24. package/.vite/deps/lucide-react.js +36984 -0
  25. package/.vite/deps/lucide-react.js.map +7 -0
  26. package/.vite/deps/package.json +3 -0
  27. package/.vite/deps/react-dom_client.js +17917 -0
  28. package/.vite/deps/react-dom_client.js.map +7 -0
  29. package/.vite/deps/react-router-dom.js +452 -0
  30. package/.vite/deps/react-router-dom.js.map +7 -0
  31. package/.vite/deps/react-router.js +234 -0
  32. package/.vite/deps/react-router.js.map +7 -0
  33. package/.vite/deps/react.js +5 -0
  34. package/.vite/deps/react.js.map +7 -0
  35. package/.vite/deps/react_jsx-dev-runtime.js +470 -0
  36. package/.vite/deps/react_jsx-dev-runtime.js.map +7 -0
  37. package/CHANGELOG.md +420 -0
  38. package/LICENSE +21 -0
  39. package/README.md +129 -0
  40. package/RELEASE_CHEATSHEET.md +93 -0
  41. package/RELEASE_NOTES.md +120 -0
  42. package/components.json +21 -0
  43. package/docs/DEPLOYMENT_WORKFLOW.md +262 -0
  44. package/docs/RELEASE_GUIDE.md +591 -0
  45. package/docs/architecture.md +432 -0
  46. package/docs/components.md +199 -0
  47. package/docs/index.md +69 -0
  48. package/docs/local-release-workflow.md +234 -0
  49. package/docs/routes.md +118 -0
  50. package/docs/sdk-integration.md +325 -0
  51. package/docs/semantic-release.md +124 -0
  52. package/docs/user-flow.md +206 -0
  53. package/eslint.config.js +28 -0
  54. package/index.html +19 -0
  55. package/install.sh +198 -0
  56. package/package.json +115 -0
  57. package/public/images/bank-logo.png +0 -0
  58. package/public/saafe-icon.svg +9 -0
  59. package/src/App.tsx +171 -0
  60. package/src/__tests__/url-parameters.test.ts +82 -0
  61. package/src/assets/brand/applestore.svg +13 -0
  62. package/src/assets/brand/playstore.svg +23 -0
  63. package/src/assets/brand/saafe-color-white-logo.svg +14 -0
  64. package/src/assets/brand/saafe-icon.svg +9 -0
  65. package/src/assets/brand/saafe-logo.svg +18 -0
  66. package/src/assets/icons/check-icon-dark.svg +27 -0
  67. package/src/assets/icons/check-icon.svg +23 -0
  68. package/src/components/ErrorBoundary.tsx +132 -0
  69. package/src/components/alert/alert.tsx +27 -0
  70. package/src/components/auth/AuthGuard.tsx +76 -0
  71. package/src/components/cards/BankCard.stories.tsx +69 -0
  72. package/src/components/cards/BankCard.tsx +227 -0
  73. package/src/components/cards/OuterCard.tsx +109 -0
  74. package/src/components/cards/WrapperCard.tsx +64 -0
  75. package/src/components/documents/PrivacyContent.tsx +1 -0
  76. package/src/components/dummyFooter.tsx +29 -0
  77. package/src/components/icons/github.tsx +12 -0
  78. package/src/components/language/LanguageSwitcher.tsx +44 -0
  79. package/src/components/layouts/FrostedLayout.stories.tsx +42 -0
  80. package/src/components/layouts/FrostedLayout.tsx +333 -0
  81. package/src/components/layouts/MobileLayout.tsx +403 -0
  82. package/src/components/mobile-background.tsx +136 -0
  83. package/src/components/mobileAppDownload.tsx +30 -0
  84. package/src/components/modal/ModalComp.tsx +27 -0
  85. package/src/components/mode-toggle.tsx +36 -0
  86. package/src/components/page-header.tsx +50 -0
  87. package/src/components/session/SessionTimeoutScreen.tsx +134 -0
  88. package/src/components/session/SessionTimer.tsx +173 -0
  89. package/src/components/step-navigation.tsx +87 -0
  90. package/src/components/title/AppBar.stories.tsx +50 -0
  91. package/src/components/title/AppBar.tsx +150 -0
  92. package/src/components/title/SectionTitle.tsx +31 -0
  93. package/src/components/ui/AnimatedButton.module.css +13 -0
  94. package/src/components/ui/alert.tsx +66 -0
  95. package/src/components/ui/animatedButton.tsx +111 -0
  96. package/src/components/ui/avatar.tsx +51 -0
  97. package/src/components/ui/badge.tsx +36 -0
  98. package/src/components/ui/bottom-sheet.tsx +122 -0
  99. package/src/components/ui/button.tsx +59 -0
  100. package/src/components/ui/calendar.tsx +86 -0
  101. package/src/components/ui/card.tsx +92 -0
  102. package/src/components/ui/checkbox.stories.tsx +49 -0
  103. package/src/components/ui/checkbox.tsx +67 -0
  104. package/src/components/ui/collapsible.tsx +45 -0
  105. package/src/components/ui/dialog.tsx +134 -0
  106. package/src/components/ui/document-link.tsx +26 -0
  107. package/src/components/ui/dot-stepper.tsx +57 -0
  108. package/src/components/ui/dropdown-menu.tsx +255 -0
  109. package/src/components/ui/form.tsx +165 -0
  110. package/src/components/ui/frosted-panel.stories.tsx +86 -0
  111. package/src/components/ui/frosted-panel.tsx +276 -0
  112. package/src/components/ui/input.tsx +39 -0
  113. package/src/components/ui/label.stories.tsx +67 -0
  114. package/src/components/ui/label.tsx +23 -0
  115. package/src/components/ui/mobile-footer.tsx +54 -0
  116. package/src/components/ui/modal.tsx +90 -0
  117. package/src/components/ui/otp-input.stories.tsx +62 -0
  118. package/src/components/ui/otp-input.tsx +221 -0
  119. package/src/components/ui/platform-specific-behavior.tsx +28 -0
  120. package/src/components/ui/popover.tsx +46 -0
  121. package/src/components/ui/progress.tsx +103 -0
  122. package/src/components/ui/radio-group.tsx +45 -0
  123. package/src/components/ui/scroll-area.tsx +56 -0
  124. package/src/components/ui/sdk-params-docs.tsx +53 -0
  125. package/src/components/ui/select.tsx +159 -0
  126. package/src/components/ui/separator.tsx +28 -0
  127. package/src/components/ui/sheet.tsx +137 -0
  128. package/src/components/ui/sidebar.tsx +724 -0
  129. package/src/components/ui/skeleton.stories.tsx +50 -0
  130. package/src/components/ui/skeleton.tsx +15 -0
  131. package/src/components/ui/sonner.tsx +23 -0
  132. package/src/components/ui/step.stories.tsx +132 -0
  133. package/src/components/ui/step.tsx +234 -0
  134. package/src/components/ui/stepper-progress.tsx +136 -0
  135. package/src/components/ui/stepper.tsx +259 -0
  136. package/src/components/ui/tabs.tsx +55 -0
  137. package/src/components/ui/tooltip.tsx +61 -0
  138. package/src/components/ui/url-decode-loader.tsx +36 -0
  139. package/src/components/ui/version-display.tsx +104 -0
  140. package/src/components/ui/web-footer.tsx +36 -0
  141. package/src/config/environments.ts +99 -0
  142. package/src/config/urls.ts +53 -0
  143. package/src/const/fiTypeCategoryMap.ts +19 -0
  144. package/src/contexts/LanguageContext.tsx +41 -0
  145. package/src/contexts/RTLContext.tsx +42 -0
  146. package/src/contexts/ThemeContext.tsx +93 -0
  147. package/src/hooks/use-account-discovery.ts +205 -0
  148. package/src/hooks/use-auth-query.ts +141 -0
  149. package/src/hooks/use-fip-query.ts +72 -0
  150. package/src/hooks/use-media-query.ts +32 -0
  151. package/src/hooks/use-mobile.ts +24 -0
  152. package/src/hooks/use-page-title.tsx +48 -0
  153. package/src/hooks/use-platform.ts +52 -0
  154. package/src/hooks/use-trusted-count.ts +21 -0
  155. package/src/hooks/use-url-decode.ts +90 -0
  156. package/src/hooks/useStep.ts +170 -0
  157. package/src/index.css +154 -0
  158. package/src/interfaces/app.interfaces.ts +39 -0
  159. package/src/interfaces/services.interfaces.ts +65 -0
  160. package/src/lib/i18n.ts +68 -0
  161. package/src/lib/utils.ts +6 -0
  162. package/src/locales/en/common.json +167 -0
  163. package/src/locales/hi/common.json +137 -0
  164. package/src/locales/kn/common.json +137 -0
  165. package/src/locales/ml/common.json +137 -0
  166. package/src/locales/ta/common.json +137 -0
  167. package/src/locales/te/common.json +137 -0
  168. package/src/locales/ur/common.json +138 -0
  169. package/src/main.tsx +46 -0
  170. package/src/pages/Login.tsx +363 -0
  171. package/src/pages/accounts/AccountsToProceed.tsx +396 -0
  172. package/src/pages/accounts/Discover.tsx +76 -0
  173. package/src/pages/accounts/DiscoverAccount.tsx +751 -0
  174. package/src/pages/accounts/LinkSelectedAccounts.tsx +638 -0
  175. package/src/pages/accounts/OldUser.tsx +329 -0
  176. package/src/pages/accounts/link-accounts.tsx +913 -0
  177. package/src/pages/consent/ReviewConsent.tsx +836 -0
  178. package/src/pages/consent/rejected.tsx +253 -0
  179. package/src/pages/consent/success.tsx +220 -0
  180. package/src/providers/query-provider.tsx +24 -0
  181. package/src/providers/toast-provider.tsx +26 -0
  182. package/src/services/api/account.service.ts +296 -0
  183. package/src/services/api/auth.service.ts +206 -0
  184. package/src/services/api/axios.ts +138 -0
  185. package/src/services/api/consent.service.ts +142 -0
  186. package/src/services/api/decode.service.ts +53 -0
  187. package/src/services/api/feedback.service.ts +34 -0
  188. package/src/services/api/fip.service.ts +187 -0
  189. package/src/services/api/index.ts +9 -0
  190. package/src/services/api/public.service.ts +18 -0
  191. package/src/services/api.ts +2 -0
  192. package/src/services/postMessage.service.ts +179 -0
  193. package/src/store/NavigationBlockContext.tsx +34 -0
  194. package/src/store/auth.store.ts +79 -0
  195. package/src/store/fip.store.ts +396 -0
  196. package/src/store/mandatoryConsent.store.ts +24 -0
  197. package/src/store/redirect.store.ts +73 -0
  198. package/src/store/step.store.ts +124 -0
  199. package/src/stories/Button.stories.ts +53 -0
  200. package/src/stories/Button.tsx +37 -0
  201. package/src/stories/Configure.mdx +364 -0
  202. package/src/stories/Header.stories.ts +33 -0
  203. package/src/stories/Header.tsx +56 -0
  204. package/src/stories/Page.stories.ts +32 -0
  205. package/src/stories/Page.tsx +73 -0
  206. package/src/stories/button.css +30 -0
  207. package/src/stories/header.css +32 -0
  208. package/src/stories/page.css +68 -0
  209. package/src/styles/rtl-utils.css +90 -0
  210. package/src/styles/rtl.css +105 -0
  211. package/src/utils/api-error.ts +26 -0
  212. package/src/utils/cn.ts +10 -0
  213. package/src/utils/error-callback.ts +116 -0
  214. package/src/utils/formatAccountNumber.ts +9 -0
  215. package/src/utils/handleIdentifiers.ts +90 -0
  216. package/src/utils/posthog.ts +67 -0
  217. package/src/utils/toast-helpers.ts +61 -0
  218. package/src/vite-env.d.ts +1 -0
  219. package/stage-aa-2506251021.zip +0 -0
  220. package/tsconfig.app.json +33 -0
  221. package/tsconfig.json +13 -0
  222. package/tsconfig.node.json +24 -0
  223. package/vite.config.ts +45 -0
  224. package/vitest.shims.d.ts +1 -0
  225. package/vitest.workspace.ts +46 -0
@@ -0,0 +1,93 @@
1
+ # 🚀 Quick Release Commands
2
+
3
+ ## 📋 Branch Strategy
4
+ - **sandbox** → **stage** → **prod** (Production)
5
+ - main branch is protected, use `prod` for production releases
6
+
7
+ ## ⚡ Quick Commands
8
+
9
+ ### 🎯 Create Release
10
+ ```bash
11
+ # Create release on current branch
12
+ npm run release:real
13
+
14
+ # Quick production release
15
+ npm run release:prod # switches to prod and releases
16
+ ```
17
+
18
+ ### 🏗️ Build Commands
19
+ ```bash
20
+ npm run build:production # Production build
21
+ npm run build:stage # Stage build
22
+ npm run build:sandbox # Sandbox build
23
+ npm run build:all # Build all environments
24
+ ```
25
+
26
+ ### 📊 Information
27
+ ```bash
28
+ npm run version:check # Show current version
29
+ npm run env:check # Show environment info
30
+ git tag --list # List all releases
31
+ ```
32
+
33
+ ## 🔄 Standard Workflow
34
+
35
+ ### 1. Sandbox Release
36
+ ```bash
37
+ git checkout sandbox
38
+ # Make changes with conventional commits
39
+ npm run release:real
40
+ # Creates: v1.0.0-sandbox.X
41
+ ```
42
+
43
+ ### 2. Stage Release
44
+ ```bash
45
+ git checkout stage
46
+ git merge sandbox
47
+ npm run release:real
48
+ # Creates: v1.0.0-stage.X
49
+ ```
50
+
51
+ ### 3. Production Release
52
+ ```bash
53
+ git checkout prod
54
+ git merge stage
55
+ npm run release:real
56
+ # Creates: v1.0.1 (production version!)
57
+ ```
58
+
59
+ ## 🌍 Environments
60
+
61
+ | Branch | Environment | Version Format | API |
62
+ |--------|-------------|----------------|-----|
63
+ | prod | Production | `v1.0.1` | api.saafe.in |
64
+ | stage | Stage | `v1.0.0-stage.1` | stage-api.saafe.in |
65
+ | sandbox | Sandbox | `v1.0.0-sandbox.1` | sandbox-api.saafe.in |
66
+
67
+ ## 📝 Commit Types
68
+ - `feat:` → Minor version bump
69
+ - `fix:` → Patch version bump
70
+ - `BREAKING CHANGE:` → Major version bump
71
+
72
+ ## 🆘 Emergency
73
+ - **Hotfix**: Create on `prod` branch, then merge back to `stage` and `sandbox`
74
+ - **Debug**: Use `npm run release:dry` to test releases
75
+
76
+ ## 🚨 Common Issues
77
+
78
+ **Release in dry-run mode:**
79
+ ```bash
80
+ npm run release:real # Use this instead of npm run release
81
+ ```
82
+
83
+ **No version bump on prerelease:**
84
+ - This is expected behavior
85
+ - Main version only bumps on `prod` branch
86
+
87
+ **Environment variables not loading:**
88
+ ```bash
89
+ npm run env:check # Verify environment detection
90
+ npm run env:list # Check .env files exist
91
+ ```
92
+
93
+ 📖 **Full Guide**: `docs/RELEASE_GUIDE.md`
@@ -0,0 +1,120 @@
1
+ # Release Notes
2
+
3
+ ## Version 1.0.2 - Enhanced Error Handling & Parent Communication
4
+
5
+ ### 🚀 New Features
6
+
7
+ #### Comprehensive Error Callback System
8
+ - **Real-time Error Reporting**: Implemented comprehensive error callback system that automatically notifies parent applications of any errors
9
+ - **Structured Error Data**: All error callbacks include detailed context including error type, status codes, stack traces, and consent flow information
10
+ - **Global Error Boundary**: Added React Error Boundary component to catch unhandled errors and ensure parent applications are always notified
11
+
12
+ #### Enhanced Parent Window Communication
13
+ - **Detailed Success Callbacks**: Success page now sends comprehensive data including user ratings, consent handles, and redirect information
14
+ - **Rich Rejection Callbacks**: Rejection page provides detailed feedback including specific FIP rejection reasons and user feedback
15
+ - **Consistent Message Format**: All parent communications follow a standardized structure with type, status, and contextual data
16
+
17
+ #### Improved User Experience
18
+ - **Cancel Functionality**: Users can now deselect all selected accounts by clicking the cancel button in account selection
19
+ - **Better Error Recovery**: Application gracefully handles errors while maintaining communication with parent applications
20
+
21
+ ### 📊 Error Callback Data Structure
22
+
23
+ #### Comprehensive Error Information
24
+ All error callbacks include the following structured data:
25
+
26
+ | Field | Type | Description |
27
+ |-------|------|-------------|
28
+ | `type` | string | Always 'error' for error callbacks |
29
+ | `status` | string | Always 'error' for error callbacks |
30
+ | `flowCompleted` | boolean | Indicates if the consent flow was completed |
31
+ | `errorMessage` | string | Human-readable error description |
32
+ | `errorType` | string | Categorized error type (api, auth, network, validation, unknown) |
33
+ | `errorCode` | string | API error code if available |
34
+ | `statusCode` | number | HTTP status code for API errors |
35
+ | `timestamp` | string | ISO timestamp of when error occurred |
36
+ | `userAgent` | string | Browser/device information |
37
+ | `url` | string | Current page URL where error occurred |
38
+ | `stack` | string | Error stack trace for debugging |
39
+ | `consentHandle` | string | Consent tracking identifier |
40
+ | `redirectUrl` | string | Intended redirect URL if available |
41
+
42
+ #### Enhanced Success/Rejection Callbacks
43
+ - **Success Callbacks**: Include user ratings, consent handles, redirect URLs, and timestamps
44
+ - **Rejection Callbacks**: Include rejection reasons, affected FIPs, user feedback, and detailed context
45
+ - **Consistent Format**: All callbacks follow the same structured approach for easy parsing
46
+
47
+ ### 🔧 Technical Improvements
48
+
49
+ #### New Components & Utilities
50
+ - **Error Callback Utility**: Created `src/utils/error-callback.ts` with comprehensive error handling functions
51
+ - **Error Boundary Component**: Implemented `src/components/ErrorBoundary.tsx` for global error catching
52
+ - **Enhanced State Management**: Improved account selection state management with proper cancel functionality
53
+
54
+ #### Implementation Details
55
+ - **Error Handling Integration**: Added error callbacks to consent flow, login, and account discovery pages
56
+ - **PostMessage API**: Standardized parent window communication with structured message formats
57
+ - **Type Safety**: Proper TypeScript interfaces for all callback data structures
58
+ - **Non-blocking Design**: Errors don't interrupt user flow, just notify parent applications
59
+
60
+ ### 🔄 Migration Guide
61
+
62
+ #### For Parent Applications
63
+ Update your message event listeners to handle the new comprehensive callback data:
64
+
65
+ **Error Callback Example:**
66
+ ```javascript
67
+ window.addEventListener('message', (event) => {
68
+ if (event.data.type === 'error') {
69
+ const { errorMessage, errorType, statusCode, consentHandle } = event.data;
70
+ // Handle error with detailed context
71
+ console.error('Consent flow error:', event.data);
72
+ }
73
+ });
74
+ ```
75
+
76
+ **Enhanced Success/Rejection Callbacks:**
77
+ ```javascript
78
+ window.addEventListener('message', (event) => {
79
+ if (event.data.type === 'AA') {
80
+ if (event.data.status === 'success') {
81
+ // New fields: userRating, consentHandle, redirectUrl, timestamp
82
+ const { userRating, consentHandle } = event.data;
83
+ } else if (event.data.status === 'rejected') {
84
+ // New fields: rejectionReason, rejectedByFips, userFeedback, customFeedback
85
+ const { rejectedByFips, userFeedback } = event.data;
86
+ }
87
+ }
88
+ });
89
+ ```
90
+
91
+ #### Breaking Changes
92
+ - Rejected callback status changed from `'failed'` to `'rejected'` for consistency
93
+ - All callbacks now include additional context fields (backward compatible)
94
+
95
+ ### 📈 Impact
96
+
97
+ #### For Parent Applications
98
+ - **Better Error Visibility**: Real-time notification of all errors with detailed context for faster debugging
99
+ - **Enhanced Analytics**: Rich callback data enables better user journey analysis and conversion tracking
100
+ - **Improved Support**: Detailed error information helps customer support teams resolve issues quickly
101
+
102
+ #### For End Users
103
+ - **Seamless Experience**: Error handling doesn't interrupt user flow while ensuring proper error reporting
104
+ - **Better Functionality**: Cancel button now properly clears selections for improved usability
105
+ - **Reliable Communication**: Consistent message format ensures parent applications receive proper notifications
106
+
107
+ #### For Development Teams
108
+ - **Comprehensive Error Handling**: Centralized error callback system reduces boilerplate code
109
+ - **Better Debugging**: Detailed error context including stack traces and environment information
110
+ - **Type Safety**: Proper TypeScript interfaces for all callback structures
111
+
112
+ ### 🐛 Bug Fixes
113
+ - Fixed account selection cancel functionality to properly clear all selected items
114
+ - Improved error handling consistency across all pages
115
+ - Enhanced TypeScript type safety for callback data structures
116
+
117
+ ---
118
+
119
+ **Full Changelog**: Compare changes since last release
120
+ **Documentation**: Updated tracking guidelines in developer documentation
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/index.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils",
16
+ "ui": "@/components/ui",
17
+ "lib": "@/lib",
18
+ "hooks": "@/hooks"
19
+ },
20
+ "iconLibrary": "lucide"
21
+ }
@@ -0,0 +1,262 @@
1
+ # 🚀 Deployment Workflow Guide
2
+
3
+ ## 🎯 Overview
4
+
5
+ This guide explains the **conflict-free deployment workflow** for multiple environments without semantic release conflicts.
6
+
7
+ ## 🏗️ Branch Strategy
8
+
9
+ ```
10
+ feature/branch → sandbox → stage → prod
11
+ ↓ ↓ ↓
12
+ Testing QA RELEASE
13
+ ```
14
+
15
+ **Key Principle**: Only `prod` branch creates actual releases. Other branches are deployment targets.
16
+
17
+ ## ✅ Correct Workflow
18
+
19
+ ### **Step 1: Feature Development**
20
+
21
+ ```bash
22
+ # Create feature branch
23
+ git checkout -b feature/user-auth
24
+ git add .
25
+ git commit -m "feat: implement user authentication"
26
+ git push origin feature/user-auth
27
+ ```
28
+
29
+ ### **Step 2: Deploy to Sandbox**
30
+
31
+ ```bash
32
+ # Merge to sandbox (NO RELEASE)
33
+ git checkout sandbox
34
+ git merge feature/user-auth
35
+ npm run build:sandbox
36
+ # Deploy sandbox build to sandbox environment
37
+ ```
38
+
39
+ ### **Step 3: Deploy to Stage**
40
+
41
+ ```bash
42
+ # Merge to stage (NO RELEASE)
43
+ git checkout stage
44
+ git merge sandbox # or git merge feature/user-auth
45
+ npm run build:stage
46
+ # Deploy stage build to stage environment
47
+ ```
48
+
49
+ ### **Step 4: Deploy to Production**
50
+
51
+ ```bash
52
+ # Merge to prod and RELEASE
53
+ git checkout prod
54
+ git merge stage # or git merge feature/user-auth
55
+ npm run release:real # Creates v1.0.1
56
+ npm run build:production
57
+ # Deploy production build to production environment
58
+ ```
59
+
60
+ ## 🔄 Daily Development Cycle
61
+
62
+ ### **Multiple Features**
63
+
64
+ ```bash
65
+ # Feature A
66
+ git checkout -b feature/dashboard
67
+ git commit -m "feat: add user dashboard"
68
+ git checkout sandbox
69
+ git merge feature/dashboard
70
+ npm run build:sandbox
71
+
72
+ # Feature B
73
+ git checkout -b feature/notifications
74
+ git commit -m "feat: add push notifications"
75
+ git checkout sandbox
76
+ git merge feature/notifications
77
+ npm run build:sandbox
78
+
79
+ # Deploy both to stage
80
+ git checkout stage
81
+ git merge sandbox
82
+ npm run build:stage
83
+
84
+ # Deploy both to production
85
+ git checkout prod
86
+ git merge stage
87
+ npm run release:real # Creates v1.1.0 (minor bump for 2 features)
88
+ ```
89
+
90
+ ### **Hotfix Process**
91
+
92
+ ```bash
93
+ # Critical bug fix
94
+ git checkout prod
95
+ git checkout -b hotfix/security-fix
96
+ git commit -m "fix: resolve critical security vulnerability"
97
+
98
+ # Deploy directly to prod
99
+ git checkout prod
100
+ git merge hotfix/security-fix
101
+ npm run release:real # Creates v1.0.1 (patch)
102
+ npm run build:production
103
+
104
+ # Merge back to other branches
105
+ git checkout stage
106
+ git merge prod
107
+ git checkout sandbox
108
+ git merge prod
109
+ ```
110
+
111
+ ## 📋 Branch Responsibilities
112
+
113
+ | Branch | Purpose | Release | Build Command | Deploy To |
114
+ |--------|---------|---------|---------------|-----------|
115
+ | **sandbox** | Integration testing | ❌ No | `npm run build:sandbox` | Sandbox servers |
116
+ | **stage** | QA testing | ❌ No | `npm run build:stage` | Stage servers |
117
+ | **prod** | Production releases | ✅ Yes | `npm run build:production` | Production servers |
118
+
119
+ ## 🚫 What NOT to Do
120
+
121
+ ```bash
122
+ # ❌ DON'T run releases on sandbox/stage
123
+ git checkout sandbox
124
+ npm run release:real # This causes conflicts!
125
+
126
+ git checkout stage
127
+ npm run release:real # This causes conflicts!
128
+
129
+ # ❌ DON'T merge in wrong direction
130
+ git checkout sandbox
131
+ git merge stage # Wrong direction!
132
+ ```
133
+
134
+ ## ✅ Conflict Resolution
135
+
136
+ If you accidentally created conflicting releases, here's how to fix:
137
+
138
+ ### **Reset Branch Strategy**
139
+
140
+ ```bash
141
+ # 1. Create clean branches from prod
142
+ git checkout prod
143
+ git checkout -b sandbox-clean
144
+ git checkout -b stage-clean
145
+
146
+ # 2. Replace old branches
147
+ git branch -D sandbox
148
+ git branch -D stage
149
+ git branch -m sandbox-clean sandbox
150
+ git branch -m stage-clean stage
151
+
152
+ # 3. Push new branches
153
+ git push -f origin sandbox
154
+ git push -f origin stage
155
+ ```
156
+
157
+ ## 🎯 Version Strategy
158
+
159
+ ### **Current Setup (After Fix)**
160
+
161
+ - **Production**: `v1.0.0`, `v1.0.1`, `v1.1.0`, `v2.0.0`
162
+ - **Stage**: Same code as prod, no separate versions
163
+ - **Sandbox**: Same code as stage, no separate versions
164
+
165
+ ### **Version Display**
166
+
167
+ The `VersionDisplay` component automatically shows:
168
+ - **Production**: `v1.0.1`
169
+ - **Stage**: `v1.0.1 | STAGE`
170
+ - **Sandbox**: `v1.0.1 | SANDBOX`
171
+
172
+ ## 🛠️ Commands Reference
173
+
174
+ ### **Development Commands**
175
+
176
+ ```bash
177
+ # Check current setup
178
+ npm run version:check
179
+ git branch -a
180
+ git log --oneline -5
181
+
182
+ # Build for environments
183
+ npm run build:sandbox
184
+ npm run build:stage
185
+ npm run build:production
186
+
187
+ # Preview builds
188
+ npm run preview:sandbox
189
+ npm run preview:stage
190
+ npm run preview:production
191
+ ```
192
+
193
+ ### **Release Commands**
194
+
195
+ ```bash
196
+ # Only run on prod branch
197
+ git checkout prod
198
+ npm run release:real
199
+
200
+ # Test release (dry run)
201
+ npm run release:dry
202
+ ```
203
+
204
+ ### **Environment Commands**
205
+
206
+ ```bash
207
+ # Check environment config
208
+ npm run env:check
209
+ npm run env:list
210
+
211
+ # Check build differences
212
+ npm run build:stage -- --debug
213
+ npm run build:production -- --debug
214
+ ```
215
+
216
+ ## 📊 Benefits of This Workflow
217
+
218
+ ### **✅ Advantages**
219
+
220
+ - ✅ **No merge conflicts** in package.json/CHANGELOG.md
221
+ - ✅ **Clean git history** with linear releases
222
+ - ✅ **Easier rollbacks** with single version source
223
+ - ✅ **Clear environment separation**
224
+ - ✅ **Simplified deployment pipeline**
225
+
226
+ ### **📈 Before vs After**
227
+
228
+ #### **Before (Problematic)**
229
+ ```
230
+ sandbox: v1.0.0-sandbox.1 → v1.0.0-sandbox.2 → v1.0.0-sandbox.3
231
+ stage: v1.0.0-stage.1 → v1.0.0-stage.2 → CONFLICTS!
232
+ prod: v1.0.0 → v1.0.1 → CONFLICTS!
233
+ ```
234
+
235
+ #### **After (Clean)**
236
+ ```
237
+ sandbox: code deployment only (no versions)
238
+ stage: code deployment only (no versions)
239
+ prod: v1.0.0 → v1.0.1 → v1.1.0 → v2.0.0 (clean releases)
240
+ ```
241
+
242
+ ## 🎓 Training Checklist
243
+
244
+ - [ ] Understand branch flow: feature → sandbox → stage → prod
245
+ - [ ] Only release from `prod` branch
246
+ - [ ] Use `build:environment` commands for deployment
247
+ - [ ] Merge in correct direction (forward only)
248
+ - [ ] Test workflow with `npm run release:dry`
249
+ - [ ] Know how to resolve conflicts if they occur
250
+
251
+ ## 📞 Support
252
+
253
+ If you encounter issues:
254
+
255
+ 1. **Check branch**: `git branch` (should be on `prod` for releases)
256
+ 2. **Check conflicts**: `git status` (resolve before releasing)
257
+ 3. **Test first**: `npm run release:dry`
258
+ 4. **Check docs**: This guide and `docs/RELEASE_GUIDE.md`
259
+
260
+ ---
261
+
262
+ **�� Happy Deploying!**