create-catalyst-app 0.0.1-beta.2 → 0.0.1-beta.20

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 (266) hide show
  1. package/{readme.md → Readme.md} +7 -4
  2. package/codemod/new-route/index.js +98 -0
  3. package/codemod/new-route/template.js +119 -0
  4. package/codemod/new-route/transformers/createReducer.js +38 -0
  5. package/codemod/new-route/transformers/createRoute.js +33 -0
  6. package/codemod/new-route/utils.js +90 -0
  7. package/license +10 -0
  8. package/package.json +18 -18
  9. package/scripts/cli.cjs +359 -0
  10. package/templates/common/.eslintignore +1 -6
  11. package/templates/common/.eslintrc +13 -38
  12. package/templates/common/README.md +16 -20
  13. package/templates/common/api.js +12 -25
  14. package/templates/common/client/styles.js +1 -13
  15. package/templates/common/config/config.json +10 -16
  16. package/templates/common/public/favicon.ico +0 -0
  17. package/templates/{redux-js → common}/server/document.js +2 -4
  18. package/templates/common/server/index.js +2 -0
  19. package/templates/common/server/server.js +8 -0
  20. package/templates/common/src/js/containers/Home/Home.js +23 -40
  21. package/templates/common/src/js/containers/Home/Home.scss +34 -0
  22. package/templates/common/src/js/routes/index.js +9 -48
  23. package/templates/common/src/static/css/base/index.scss +0 -7
  24. package/templates/common/src/static/css/base/styles.scss +0 -160
  25. package/templates/common/src/static/css/resources/_variables.scss +0 -172
  26. package/{my-app → templates/common}/webpackConfig.js +3 -2
  27. package/templates/mcp-root/mcp/context.md +509 -0
  28. package/templates/mcp-root/mcp/mcp.js +36 -0
  29. package/templates/none-js/client/index.js +8 -12
  30. package/templates/none-js/package.json +13 -35
  31. package/templates/none-js/src/js/containers/App/index.js +12 -36
  32. package/templates/none-js/src/js/routes/utils.js +42 -0
  33. package/templates/none-ts/client/index.js +23 -0
  34. package/templates/none-ts/package.json +34 -0
  35. package/templates/none-ts/src/js/containers/App/index.js +16 -0
  36. package/templates/none-ts/src/js/routes/utils.js +42 -0
  37. package/templates/none-ts/tsconfig.json +13 -0
  38. package/templates/none-ts/types.d.ts +4 -0
  39. package/templates/redux-js/client/index.js +6 -5
  40. package/templates/redux-js/package.json +16 -35
  41. package/templates/redux-js/src/js/containers/App/actions.js +1 -4
  42. package/templates/redux-js/src/js/containers/App/index.js +12 -38
  43. package/templates/redux-js/src/js/containers/App/reducer.js +15 -17
  44. package/templates/redux-js/src/js/routes/utils.js +42 -0
  45. package/templates/redux-js/src/js/store/index.js +17 -68
  46. package/{my-app → templates/redux-ts}/client/index.js +4 -3
  47. package/templates/redux-ts/package.json +37 -0
  48. package/{my-app → templates/redux-ts}/src/js/containers/App/actions.js +1 -4
  49. package/templates/redux-ts/src/js/containers/App/index.js +16 -0
  50. package/templates/redux-ts/src/js/containers/App/reducer.js +19 -0
  51. package/templates/redux-ts/src/js/routes/utils.js +42 -0
  52. package/templates/redux-ts/src/js/store/index.js +28 -0
  53. package/templates/redux-ts/tsconfig.json +13 -0
  54. package/templates/redux-ts/types.d.ts +4 -0
  55. package/templates/rtk-js/client/index.js +6 -5
  56. package/templates/rtk-js/package.json +16 -35
  57. package/templates/rtk-js/src/js/containers/App/index.js +12 -38
  58. package/templates/rtk-js/src/js/containers/App/reducer.js +1 -9
  59. package/templates/rtk-js/src/js/routes/utils.js +42 -0
  60. package/templates/rtk-js/src/js/store/index.js +12 -6
  61. package/templates/rtk-ts/client/index.js +28 -0
  62. package/templates/rtk-ts/package.json +37 -0
  63. package/templates/rtk-ts/src/js/containers/App/index.js +16 -0
  64. package/{my-app → templates/rtk-ts}/src/js/containers/App/reducer.js +1 -9
  65. package/templates/rtk-ts/src/js/routes/utils.js +42 -0
  66. package/templates/rtk-ts/src/js/store/index.js +28 -0
  67. package/templates/rtk-ts/tsconfig.json +13 -0
  68. package/templates/rtk-ts/types.d.ts +4 -0
  69. package/templates/tailwind/postcss.config.js +5 -0
  70. package/templates/tailwind/src/static/css/base/index.scss +2 -0
  71. package/my-app/.babelrc +0 -26
  72. package/my-app/.eslintignore +0 -6
  73. package/my-app/.eslintrc +0 -53
  74. package/my-app/.stylelintrc +0 -35
  75. package/my-app/README.md +0 -23
  76. package/my-app/api.js +0 -29
  77. package/my-app/checkVersion.js +0 -3
  78. package/my-app/client/styles.js +0 -14
  79. package/my-app/config/config.json +0 -15
  80. package/my-app/config/config_template.json +0 -18
  81. package/my-app/config/index.js +0 -44
  82. package/my-app/package.json +0 -28
  83. package/my-app/server/document.js +0 -14
  84. package/my-app/server/index.js +0 -3
  85. package/my-app/server/server.js +0 -3
  86. package/my-app/src/js/containers/App/index.js +0 -16
  87. package/my-app/src/js/containers/DemoPage/DemoPage.js +0 -39
  88. package/my-app/src/js/containers/DemoPage/DemoPage.scss +0 -3
  89. package/my-app/src/js/containers/Home/Home.js +0 -25
  90. package/my-app/src/js/containers/Home/Home.scss +0 -36
  91. package/my-app/src/js/reducer/index.js +0 -80
  92. package/my-app/src/js/routes/index.js +0 -43
  93. package/my-app/src/js/stateManager/stateProvider.js +0 -34
  94. package/my-app/src/js/store/index.js +0 -22
  95. package/my-app/src/static/css/base/index.scss +0 -2
  96. package/my-app/src/static/css/base/styles.scss +0 -3
  97. package/my-app/src/static/css/base/typography.scss +0 -53
  98. package/my-app/src/static/css/resources/_variables.scss +0 -0
  99. package/my-app/src/static/fonts/.gitkeep +0 -0
  100. package/my-app/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  101. package/my-app/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  102. package/my-app/src/static/fonts/Inter-Light-Subset.otf +0 -0
  103. package/my-app/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  104. package/my-app/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  105. package/my-app/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  106. package/my-app/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  107. package/my-app/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  108. package/my-app/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  109. package/my-app/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  110. package/my-app/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  111. package/scripts/cli.mjs +0 -266
  112. package/templates/common/.babelrc +0 -26
  113. package/templates/common/.editorconfig +0 -12
  114. package/templates/common/.prettierrc.json +0 -7
  115. package/templates/common/.stylelintrc +0 -35
  116. package/templates/common/checkVersion.js +0 -3
  117. package/templates/common/client/index.js +0 -39
  118. package/templates/common/config/config_template.json +0 -18
  119. package/templates/common/config/index.js +0 -77
  120. package/templates/common/package.json +0 -56
  121. package/templates/common/server/CustomDocument.js +0 -14
  122. package/templates/common/server/customIndex.js +0 -3
  123. package/templates/common/server/customServer.js +0 -16
  124. package/templates/common/src/js/containers/App/actions.js +0 -20
  125. package/templates/common/src/js/containers/App/index.js +0 -46
  126. package/templates/common/src/js/containers/App/reducer.js +0 -21
  127. package/templates/common/src/js/containers/PDP/PDP.js +0 -37
  128. package/templates/common/src/js/reducer/index.js +0 -80
  129. package/templates/common/src/js/stateManager/stateProvider.js +0 -34
  130. package/templates/common/src/js/store/index.js +0 -77
  131. package/templates/common/src/static/css/base/_overrides.scss +0 -81
  132. package/templates/common/src/static/css/base/animations.js +0 -38
  133. package/templates/common/src/static/css/base/layout.scss +0 -242
  134. package/templates/common/src/static/css/base/typography.scss +0 -285
  135. package/templates/common/src/static/css/resources/_mixins.scss +0 -196
  136. package/templates/common/src/static/css/resources/_vendors.scss +0 -1
  137. package/templates/common/src/static/fonts/.gitkeep +0 -0
  138. package/templates/common/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  139. package/templates/common/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  140. package/templates/common/src/static/fonts/Inter-Light-Subset.otf +0 -0
  141. package/templates/common/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  142. package/templates/common/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  143. package/templates/common/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  144. package/templates/common/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  145. package/templates/common/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  146. package/templates/common/src/static/fonts/Poppins-Light-Subset.woff2 +0 -0
  147. package/templates/common/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  148. package/templates/common/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  149. package/templates/common/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  150. package/templates/none-js/.babelrc +0 -26
  151. package/templates/none-js/.eslintignore +0 -6
  152. package/templates/none-js/.eslintrc +0 -53
  153. package/templates/none-js/.prettierrc.json +0 -7
  154. package/templates/none-js/.stylelintrc +0 -35
  155. package/templates/none-js/README.md +0 -22
  156. package/templates/none-js/api.js +0 -29
  157. package/templates/none-js/checkVersion.js +0 -3
  158. package/templates/none-js/client/styles.js +0 -15
  159. package/templates/none-js/config/config.json +0 -15
  160. package/templates/none-js/config/config_template.json +0 -18
  161. package/templates/none-js/config/index.js +0 -44
  162. package/templates/none-js/server/document.js +0 -14
  163. package/templates/none-js/server/index.js +0 -3
  164. package/templates/none-js/server/server.js +0 -16
  165. package/templates/none-js/src/js/containers/DemoPage/DemoPage.js +0 -39
  166. package/templates/none-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
  167. package/templates/none-js/src/js/containers/Home/Home.js +0 -27
  168. package/templates/none-js/src/js/containers/Home/Home.scss +0 -36
  169. package/templates/none-js/src/js/routes/index.js +0 -49
  170. package/templates/none-js/src/js/stateManager/stateProvider.js +0 -19
  171. package/templates/none-js/src/js/store/index.js +0 -6
  172. package/templates/none-js/src/static/css/base/index.scss +0 -3
  173. package/templates/none-js/src/static/css/base/styles.scss +0 -11
  174. package/templates/none-js/src/static/css/base/typography.scss +0 -53
  175. package/templates/none-js/src/static/css/resources/_variables.scss +0 -1
  176. package/templates/none-js/src/static/fonts/.gitkeep +0 -0
  177. package/templates/none-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  178. package/templates/none-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  179. package/templates/none-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  180. package/templates/none-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  181. package/templates/none-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  182. package/templates/none-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  183. package/templates/none-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  184. package/templates/none-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  185. package/templates/none-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  186. package/templates/none-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  187. package/templates/none-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  188. package/templates/none-js/webpackConfig.js +0 -5
  189. package/templates/redux-js/.babelrc +0 -26
  190. package/templates/redux-js/.eslintignore +0 -6
  191. package/templates/redux-js/.eslintrc +0 -53
  192. package/templates/redux-js/.prettierrc.json +0 -7
  193. package/templates/redux-js/.stylelintrc +0 -35
  194. package/templates/redux-js/README.md +0 -22
  195. package/templates/redux-js/api.js +0 -29
  196. package/templates/redux-js/checkVersion.js +0 -3
  197. package/templates/redux-js/client/styles.js +0 -15
  198. package/templates/redux-js/config/config.json +0 -15
  199. package/templates/redux-js/config/config_template.json +0 -18
  200. package/templates/redux-js/config/index.js +0 -44
  201. package/templates/redux-js/server/index.js +0 -3
  202. package/templates/redux-js/server/server.js +0 -16
  203. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.js +0 -39
  204. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
  205. package/templates/redux-js/src/js/containers/Home/Home.js +0 -27
  206. package/templates/redux-js/src/js/containers/Home/Home.scss +0 -36
  207. package/templates/redux-js/src/js/reducer/index.js +0 -80
  208. package/templates/redux-js/src/js/routes/index.js +0 -49
  209. package/templates/redux-js/src/js/stateManager/stateProvider.js +0 -34
  210. package/templates/redux-js/src/static/css/base/index.scss +0 -3
  211. package/templates/redux-js/src/static/css/base/styles.scss +0 -11
  212. package/templates/redux-js/src/static/css/base/typography.scss +0 -53
  213. package/templates/redux-js/src/static/css/resources/_variables.scss +0 -1
  214. package/templates/redux-js/src/static/fonts/.gitkeep +0 -0
  215. package/templates/redux-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  216. package/templates/redux-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  217. package/templates/redux-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  218. package/templates/redux-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  219. package/templates/redux-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  220. package/templates/redux-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  221. package/templates/redux-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  222. package/templates/redux-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  223. package/templates/redux-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  224. package/templates/redux-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  225. package/templates/redux-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  226. package/templates/redux-js/webpackConfig.js +0 -5
  227. package/templates/rtk-js/.babelrc +0 -26
  228. package/templates/rtk-js/.eslintignore +0 -6
  229. package/templates/rtk-js/.eslintrc +0 -53
  230. package/templates/rtk-js/.prettierrc.json +0 -7
  231. package/templates/rtk-js/.stylelintrc +0 -35
  232. package/templates/rtk-js/README.md +0 -23
  233. package/templates/rtk-js/api.js +0 -29
  234. package/templates/rtk-js/checkVersion.js +0 -3
  235. package/templates/rtk-js/client/styles.js +0 -15
  236. package/templates/rtk-js/config/config.json +0 -15
  237. package/templates/rtk-js/config/config_template.json +0 -18
  238. package/templates/rtk-js/config/index.js +0 -44
  239. package/templates/rtk-js/server/document.js +0 -14
  240. package/templates/rtk-js/server/index.js +0 -3
  241. package/templates/rtk-js/server/server.js +0 -16
  242. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.js +0 -39
  243. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
  244. package/templates/rtk-js/src/js/containers/Home/Home.js +0 -27
  245. package/templates/rtk-js/src/js/containers/Home/Home.scss +0 -36
  246. package/templates/rtk-js/src/js/reducer/index.js +0 -80
  247. package/templates/rtk-js/src/js/routes/index.js +0 -49
  248. package/templates/rtk-js/src/js/stateManager/stateProvider.js +0 -34
  249. package/templates/rtk-js/src/static/css/base/index.scss +0 -3
  250. package/templates/rtk-js/src/static/css/base/styles.scss +0 -11
  251. package/templates/rtk-js/src/static/css/base/typography.scss +0 -53
  252. package/templates/rtk-js/src/static/css/resources/_variables.scss +0 -1
  253. package/templates/rtk-js/src/static/fonts/.gitkeep +0 -0
  254. package/templates/rtk-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  255. package/templates/rtk-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  256. package/templates/rtk-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  257. package/templates/rtk-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  258. package/templates/rtk-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  259. package/templates/rtk-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  260. package/templates/rtk-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  261. package/templates/rtk-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  262. package/templates/rtk-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  263. package/templates/rtk-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  264. package/templates/rtk-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  265. package/templates/rtk-js/webpackConfig.js +0 -5
  266. /package/{my-app/.prettierrc.json → .prettierrc.json} +0 -0
@@ -0,0 +1,42 @@
1
+ import React from "react"
2
+ import { RouterDataProvider, MetaTag } from "@tata1mg/router"
3
+ import App from "@containers/App"
4
+ import routes from "./index.js"
5
+
6
+ /**
7
+ * Making the routes array compatible with the format accepted by createBrowserRouter
8
+ * API on the client side
9
+ * https://reactrouter.com/en/main/routers/create-browser-router
10
+ */
11
+
12
+ export const preparedRoutes = ({ store, routerInitialState }) => {
13
+ const getPreparedRoutes = (routes) => {
14
+ return routes.map((route, index) => {
15
+ const Component = route.component
16
+ const routeToRender = {
17
+ ...route,
18
+ element: <Component key={index} />,
19
+ }
20
+ if (route.children) {
21
+ routeToRender.children = getPreparedRoutes(route.children)
22
+ }
23
+ return routeToRender
24
+ })
25
+ }
26
+
27
+ return [
28
+ {
29
+ element: (
30
+ <RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{ store }}>
31
+ <MetaTag />
32
+ <App />
33
+ </RouterDataProvider>
34
+ ),
35
+ children: getPreparedRoutes(routes),
36
+ },
37
+ ]
38
+ }
39
+
40
+ export const getRoutes = () => {
41
+ return routes
42
+ }
@@ -0,0 +1,28 @@
1
+ import { configureStore as createStore } from "@reduxjs/toolkit"
2
+ import { combineReducers } from "redux"
3
+ import { shellReducer } from "@containers/App/reducer.js"
4
+ import fetchInstance from "@api"
5
+
6
+ /**
7
+ * Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
8
+ * @param {object} initialState Default state
9
+ * @param {object} request Request object that we recieve on server, this is only recieved when store is initialized on the server.
10
+ * @return {object} The store itself
11
+ */
12
+
13
+ const configureStore = (initialState) => {
14
+ const api = fetchInstance
15
+ const store = createStore({
16
+ reducer: combineReducers({ shellReducer }),
17
+ middleware: (getDefaultMiddleware) =>
18
+ getDefaultMiddleware({
19
+ thunk: {
20
+ extraArgument: { api },
21
+ },
22
+ }),
23
+ preloadedState: initialState,
24
+ })
25
+ return store
26
+ }
27
+
28
+ export default configureStore
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2016",
4
+ "module": "CommonJS",
5
+ "esModuleInterop": true,
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "jsx": "react",
9
+ "noEmit": true
10
+ },
11
+ "include": ["src", "types.d.ts"],
12
+ "exclude": ["node_modules"]
13
+ }
@@ -0,0 +1,4 @@
1
+ declare module "*.scss" {
2
+ const classes: { [key: string]: string }
3
+ export default classes
4
+ }
@@ -1,17 +1,18 @@
1
1
  import React from "react"
2
+ import "./styles"
2
3
  import { hydrateRoot } from "react-dom/client"
3
4
  import { loadableReady } from "@loadable/component"
4
5
  import { Provider } from "react-redux"
5
- import { createBrowserRouter, RouterProvider } from "@tata1mg/router"
6
- import { preparedRoutes } from "../src/js/routes/index.js"
7
- import configureStore from "../src/js/store/index.js"
8
- import "./styles"
6
+ import { RouterProvider } from "@tata1mg/router"
7
+ import clientRouter from "catalyst-core/router/ClientRouter"
8
+ import configureStore from "@store"
9
9
 
10
10
  window.addEventListener("load", () => {
11
11
  loadableReady(() => {
12
12
  const { __ROUTER_INITIAL_DATA__: routerInitialData, __INITIAL_STATE__ } = window
13
13
  const store = configureStore(__INITIAL_STATE__ || {})
14
- const router = createBrowserRouter(preparedRoutes({ store, routerInitialState: routerInitialData }))
14
+
15
+ const router = clientRouter({ store, routerInitialState: routerInitialData })
15
16
 
16
17
  const Application = (
17
18
  <Provider store={store} serverState={__INITIAL_STATE__}>
@@ -1,52 +1,33 @@
1
1
  {
2
2
  "name": "create-catalyst-app-starter",
3
3
  "version": "1.0.0",
4
- "description": "This README would normally document whatever steps are necessary to get your application up and running.",
5
- "main": "index.js",
6
- "bin": "scripts/cli.mjs",
7
4
  "scripts": {
8
5
  "start": "catalyst start",
9
6
  "build": "catalyst build",
10
- "serve": "catalyst serve"
7
+ "serve": "catalyst serve",
8
+ "lint": "eslint .",
9
+ "devBuild": "catalyst devBuild",
10
+ "devServe": "catalyst devServe"
11
11
  },
12
12
  "_moduleAliases": {
13
+ "@api": "api.js",
13
14
  "@containers": "src/js/containers",
14
- "@lib": "src/js/lib",
15
- "$server": "server",
16
- "@constants": "src/js/constants",
15
+ "@server": "server",
17
16
  "@config": "config",
18
- "@components": "src/js/components",
19
- "@css": "src/static/css"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "https://github.com/tata1mg/catalyst"
17
+ "@css": "src/static/css",
18
+ "@routes": "src/js/routes/",
19
+ "@store": "src/js/store/index.js"
24
20
  },
25
21
  "dependencies": {
26
22
  "@loadable/component": "^5.16.3",
27
- "@tata1mg/router": "^0.0.1-alpha.13",
28
- "catalyst-core":"0.0.1-beta.1",
29
- "event-source-polyfill": "^1.0.31",
30
- "express-static-gzip": "^2.1.7",
31
- "framer-motion": "^10.18.0",
32
- "isomorphic-dompurify": "^2.2.0",
33
- "normalize.css": "^8.0.1",
34
- "prop-types": "^15.8.1",
35
- "react-dfp": "^0.21.0",
36
- "react-helmet-async":"^1.3.0",
37
- "react-intersection-observer": "^9.5.3",
38
- "react-loadable-visibility": "^3.0.2",
39
- "react-redux": "^8.1.3",
40
- "@reduxjs/toolkit": "1.9.3"
41
- },
42
- "author": "",
43
- "license": "ISC",
44
- "bugs": {
45
- "url": "https://github.com/tata1mg/catalyst/issues"
23
+ "@tata1mg/router": "^0.0.1-beta.7",
24
+ "catalyst-core": "0.0.1-beta.14",
25
+ "@reduxjs/toolkit": "1.9.3",
26
+ "react-redux": "^8.1.3"
46
27
  },
47
- "homepage": "https://github.com/tata1mg/catalyst#readme",
48
28
  "devDependencies": {
49
- "@babel/core": "^7.23.7",
50
- "@babel/node": "^7.22.19"
29
+ "eslint": "^8.26.0",
30
+ "eslint-plugin-react": "^7.34.1",
31
+ "eslint-plugin-react-hooks": "^4.6.0"
51
32
  }
52
33
  }
@@ -1,42 +1,16 @@
1
- import React, { useState } from "react";
2
- import {
3
- useLocation,
4
- useOutlet,
5
- UNSAFE_LocationContext,
6
- } from "react-router-dom";
7
- import {reduxTest} from "./reducer.js"
8
- import "@css/base/index.scss";
1
+ import React from "react"
2
+ import { Outlet } from "@tata1mg/router"
9
3
 
10
-
11
- export const BaseOutlet = () => {
12
- const o = useOutlet();
13
- const [outlet] = useState(o);
14
-
15
- return <>{outlet}</>;
16
- };
17
4
  const App = () => {
18
-
19
- const location = useLocation();
20
- const page = (
21
- <div key={location.pathname.includes("/auth") ? "" : location.pathname}>
22
- <UNSAFE_LocationContext.Provider value={{ location }}>
23
- <BaseOutlet />
24
- </UNSAFE_LocationContext.Provider>
25
- </div>
26
- );
27
- return (
28
- <div className={"flexColumn"}>
29
- <>
30
- {/* <ShellLocusHeader /> */}
31
- </>
32
- <div>{page}</div>
33
- </div>
34
- );
35
- };
5
+ return (
6
+ <>
7
+ <Outlet />
8
+ </>
9
+ )
10
+ }
36
11
 
37
- App.serverSideFunction = ({store}) => {
38
- store.dispatch(reduxTest())
39
- return new Promise((resolve) => resolve());
40
- };
12
+ App.serverSideFunction = () => {
13
+ return new Promise((resolve) => resolve())
14
+ }
41
15
 
42
- export default App;
16
+ export default App
@@ -8,7 +8,7 @@ export const appSlice = createSlice({
8
8
  name: "shellReducer",
9
9
  initialState: initialState,
10
10
  reducers: {
11
- reduxTest: (state, action) => {
11
+ reduxTest: (state) => {
12
12
  state.testActionDispatched = true
13
13
  },
14
14
  },
@@ -16,11 +16,3 @@ export const appSlice = createSlice({
16
16
 
17
17
  export const { reduxTest } = appSlice.actions
18
18
  export const shellReducer = appSlice.reducer
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
@@ -0,0 +1,42 @@
1
+ import React from "react"
2
+ import { RouterDataProvider, MetaTag } from "@tata1mg/router"
3
+ import App from "@containers/App"
4
+ import routes from "./index.js"
5
+
6
+ /**
7
+ * Making the routes array compatible with the format accepted by createBrowserRouter
8
+ * API on the client side
9
+ * https://reactrouter.com/en/main/routers/create-browser-router
10
+ */
11
+
12
+ export const preparedRoutes = ({ store, routerInitialState }) => {
13
+ const getPreparedRoutes = (routes) => {
14
+ return routes.map((route, index) => {
15
+ const Component = route.component
16
+ const routeToRender = {
17
+ ...route,
18
+ element: <Component key={index} />,
19
+ }
20
+ if (route.children) {
21
+ routeToRender.children = getPreparedRoutes(route.children)
22
+ }
23
+ return routeToRender
24
+ })
25
+ }
26
+
27
+ return [
28
+ {
29
+ element: (
30
+ <RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{ store }}>
31
+ <MetaTag />
32
+ <App />
33
+ </RouterDataProvider>
34
+ ),
35
+ children: getPreparedRoutes(routes),
36
+ },
37
+ ]
38
+ }
39
+
40
+ export const getRoutes = () => {
41
+ return routes
42
+ }
@@ -1,12 +1,19 @@
1
1
  import { configureStore as createStore } from "@reduxjs/toolkit"
2
- import {combineReducers} from "redux"
3
- import {shellReducer} from "@containers/App/reducer.js"
4
- import fetchInstance from "../../../api"
2
+ import { combineReducers } from "redux"
3
+ import { shellReducer } from "@containers/App/reducer.js"
4
+ import fetchInstance from "@api"
5
5
 
6
- const configureStore = (initialState,request) => {
6
+ /**
7
+ * Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
8
+ * @param {object} initialState Default state
9
+ * @param {object} request Request object that we recieve on server, this is only recieved when store is initialized on the server.
10
+ * @return {object} The store itself
11
+ */
12
+
13
+ const configureStore = (initialState) => {
7
14
  const api = fetchInstance
8
15
  const store = createStore({
9
- reducer: combineReducers({shellReducer}),
16
+ reducer: combineReducers({ shellReducer }),
10
17
  middleware: (getDefaultMiddleware) =>
11
18
  getDefaultMiddleware({
12
19
  thunk: {
@@ -18,5 +25,4 @@ const configureStore = (initialState,request) => {
18
25
  return store
19
26
  }
20
27
 
21
-
22
28
  export default configureStore
@@ -0,0 +1,28 @@
1
+ import React from "react"
2
+ import "./styles"
3
+ import { hydrateRoot } from "react-dom/client"
4
+ import { loadableReady } from "@loadable/component"
5
+ import { Provider } from "react-redux"
6
+ import { RouterProvider } from "@tata1mg/router"
7
+ import clientRouter from "catalyst-core/router/ClientRouter"
8
+ import configureStore from "@store"
9
+
10
+ window.addEventListener("load", () => {
11
+ loadableReady(() => {
12
+ const { __ROUTER_INITIAL_DATA__: routerInitialData, __INITIAL_STATE__ } = window
13
+ const store = configureStore(__INITIAL_STATE__ || {})
14
+
15
+ const router = clientRouter({ store, routerInitialState: routerInitialData })
16
+
17
+ const Application = (
18
+ <Provider store={store} serverState={__INITIAL_STATE__}>
19
+ <React.StrictMode>
20
+ <RouterProvider router={router} />
21
+ </React.StrictMode>
22
+ </Provider>
23
+ )
24
+
25
+ const container = document.getElementById("app")
26
+ hydrateRoot(container, Application)
27
+ })
28
+ })
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "create-catalyst-app-starter",
3
+ "version": "1.0.0",
4
+ "scripts": {
5
+ "start": "catalyst start",
6
+ "build": "npm run typecheck && catalyst build",
7
+ "serve": "catalyst serve",
8
+ "lint": "eslint .",
9
+ "devBuild": "catalyst devBuild",
10
+ "devServe": "catalyst devServe",
11
+ "typecheck": "tsc --noEmit"
12
+ },
13
+ "_moduleAliases": {
14
+ "@api": "api.js",
15
+ "@containers": "src/js/containers",
16
+ "@server": "server",
17
+ "@config": "config",
18
+ "@css": "src/static/css",
19
+ "@routes": "src/js/routes/",
20
+ "@store": "src/js/store/index.js"
21
+ },
22
+ "dependencies": {
23
+ "@loadable/component": "^5.16.3",
24
+ "@tata1mg/router": "^0.0.1-beta.7",
25
+ "catalyst-core": "0.0.1-beta.14",
26
+ "@reduxjs/toolkit": "1.9.3",
27
+ "react-redux": "^8.1.3"
28
+ },
29
+ "devDependencies": {
30
+ "eslint": "^8.26.0",
31
+ "typescript": "^5.8.3",
32
+ "@types/react": "^18.2.0",
33
+ "@types/react-dom": "^18.2.0",
34
+ "eslint-plugin-react": "^7.34.1",
35
+ "eslint-plugin-react-hooks": "^4.6.0"
36
+ }
37
+ }
@@ -0,0 +1,16 @@
1
+ import React from "react"
2
+ import { Outlet } from "@tata1mg/router"
3
+
4
+ const App = () => {
5
+ return (
6
+ <>
7
+ <Outlet />
8
+ </>
9
+ )
10
+ }
11
+
12
+ App.serverSideFunction = () => {
13
+ return new Promise((resolve) => resolve())
14
+ }
15
+
16
+ export default App
@@ -8,7 +8,7 @@ export const appSlice = createSlice({
8
8
  name: "shellReducer",
9
9
  initialState: initialState,
10
10
  reducers: {
11
- reduxTest: (state, action) => {
11
+ reduxTest: (state) => {
12
12
  state.testActionDispatched = true
13
13
  },
14
14
  },
@@ -16,11 +16,3 @@ export const appSlice = createSlice({
16
16
 
17
17
  export const { reduxTest } = appSlice.actions
18
18
  export const shellReducer = appSlice.reducer
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
@@ -0,0 +1,42 @@
1
+ import React from "react"
2
+ import { RouterDataProvider, MetaTag } from "@tata1mg/router"
3
+ import App from "@containers/App"
4
+ import routes from "./index.js"
5
+
6
+ /**
7
+ * Making the routes array compatible with the format accepted by createBrowserRouter
8
+ * API on the client side
9
+ * https://reactrouter.com/en/main/routers/create-browser-router
10
+ */
11
+
12
+ export const preparedRoutes = ({ store, routerInitialState }) => {
13
+ const getPreparedRoutes = (routes) => {
14
+ return routes.map((route, index) => {
15
+ const Component = route.component
16
+ const routeToRender = {
17
+ ...route,
18
+ element: <Component key={index} />,
19
+ }
20
+ if (route.children) {
21
+ routeToRender.children = getPreparedRoutes(route.children)
22
+ }
23
+ return routeToRender
24
+ })
25
+ }
26
+
27
+ return [
28
+ {
29
+ element: (
30
+ <RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{ store }}>
31
+ <MetaTag />
32
+ <App />
33
+ </RouterDataProvider>
34
+ ),
35
+ children: getPreparedRoutes(routes),
36
+ },
37
+ ]
38
+ }
39
+
40
+ export const getRoutes = () => {
41
+ return routes
42
+ }
@@ -0,0 +1,28 @@
1
+ import { configureStore as createStore } from "@reduxjs/toolkit"
2
+ import { combineReducers } from "redux"
3
+ import { shellReducer } from "@containers/App/reducer.js"
4
+ import fetchInstance from "@api"
5
+
6
+ /**
7
+ * Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
8
+ * @param {object} initialState Default state
9
+ * @param {object} request Request object that we recieve on server, this is only recieved when store is initialized on the server.
10
+ * @return {object} The store itself
11
+ */
12
+
13
+ const configureStore = (initialState) => {
14
+ const api = fetchInstance
15
+ const store = createStore({
16
+ reducer: combineReducers({ shellReducer }),
17
+ middleware: (getDefaultMiddleware) =>
18
+ getDefaultMiddleware({
19
+ thunk: {
20
+ extraArgument: { api },
21
+ },
22
+ }),
23
+ preloadedState: initialState,
24
+ })
25
+ return store
26
+ }
27
+
28
+ export default configureStore
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2016",
4
+ "module": "CommonJS",
5
+ "esModuleInterop": true,
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "jsx": "react",
9
+ "noEmit": true
10
+ },
11
+ "include": ["src", "types.d.ts"],
12
+ "exclude": ["node_modules"]
13
+ }
@@ -0,0 +1,4 @@
1
+ declare module "*.scss" {
2
+ const classes: { [key: string]: string }
3
+ export default classes
4
+ }
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ },
5
+ }
@@ -0,0 +1,2 @@
1
+ @import "styles";
2
+ @import "tailwindcss";
package/my-app/.babelrc DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- },
9
- },
10
- ],
11
- "@babel/preset-react"
12
- ],
13
- "plugins": [
14
- "@babel/plugin-proposal-object-rest-spread",
15
- "transform-es2015-modules-commonjs",
16
- "transform-class-properties",
17
- "dynamic-import-node",
18
- "@loadable/babel-plugin"
19
- ],
20
- "env": {
21
- "test": {
22
- "presets": ["@babel/preset-react"]
23
- }
24
- },
25
- "ignore": ["__TEST__"]
26
- }
@@ -1,6 +0,0 @@
1
- **/node_modules/*
2
- **/dist/*
3
- **/build/*
4
- **/coverage/*
5
- **/eventScripts/*
6
- **/docs/*
package/my-app/.eslintrc DELETED
@@ -1,53 +0,0 @@
1
- {
2
- "parser": "@babel/eslint-parser",
3
- "rules": {
4
- "prettier/prettier": "error",
5
- "no-console": "warn",
6
- "react/prop-types": 1,
7
- "react/display-name": [0, { "ignoreTranspilerName": true }],
8
- "react-hooks/exhaustive-deps": "warn", // Checks effect dependencies
9
- "no-prototype-builtins": "off",
10
- "jam3/no-sanitizer-with-danger": 2,
11
- "react/jsx-no-target-blank": [0, {
12
- "enforceDynamicLinks": "never"
13
- }]
14
- },
15
- "env": {
16
- "browser": true,
17
- "es6": true,
18
- "jest": true,
19
- "node": true
20
- },
21
- "globals": {
22
- "expect": true,
23
- "__non_webpack_require__": true,
24
- "logger": "readonly",
25
- "AppCallbacks": "readonly"
26
- },
27
- "extends": ["eslint:recommended", "plugin:react/recommended"],
28
- "parserOptions": {
29
- "sourceType": "module",
30
- "ecmaFeatures": {
31
- "experimentalObjectRestSpread": true,
32
- "jsx": true
33
- },
34
- "babelOptions": {
35
- "configFile": "./babel.config.js"
36
- },
37
- "ecmaVersion": 6
38
- },
39
- "plugins": ["babel", "react", "react-hooks", "prettier", "jam3"],
40
- "settings": {
41
- "react": {
42
- "createClass": "createReactClass",
43
- "pragma": "React",
44
- "version": "detect"
45
- },
46
- "propWrapperFunctions": [
47
- "forbidExtraProps",
48
- { "property": "freeze", "object": "Object" },
49
- { "property": "myFavoriteWrapper" }
50
- ],
51
- "linkComponents": ["Hyperlink", { "name": "Link", "linkAttribute": "to" }]
52
- }
53
- }