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

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 +674 -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,359 @@
1
+ #!/usr/bin/env node
2
+ const { execSync } = require("child_process")
3
+ const Commander = require("commander")
4
+ const { Option } = require("commander")
5
+ const prompts = require("prompts")
6
+ const { red, green, cyan, bold } = require("picocolors")
7
+ const tar = require("tar")
8
+ const path = require("path")
9
+ const fs = require("fs")
10
+ var validate = require("validate-npm-package-name")
11
+ const packageJson = require("../package.json")
12
+
13
+ let projectName = null
14
+ const program = new Commander.Command()
15
+ .version(packageJson.version)
16
+ .description("Scaffolding")
17
+ .arguments("[folderName]")
18
+ .usage(`${green("[folderName]")} [options]`)
19
+ .action((name) => (projectName = name))
20
+ .addOption(new Option("-y, --yes [yes]", "Use default configuration"))
21
+ .addOption(
22
+ new Option(
23
+ "-s, --state-management [stateManagement]",
24
+ "Specify state management (rtk, redux, or none)",
25
+ /^(rtk|redux|none)$/i,
26
+ "none"
27
+ )
28
+ )
29
+ .action(async (folderName = null, cmd) => {
30
+ try {
31
+ let config = {
32
+ folderName,
33
+ language: null,
34
+ tailWindSupport: null,
35
+ description: null,
36
+ stateManagement: cmd.stateManagement,
37
+ mcpSupport: null,
38
+ }
39
+
40
+ if (process.argv.includes("new-route")) {
41
+ const createRoutePath = path.join(__dirname, "../codemod/new-route/index.js")
42
+ execSync(`node ${createRoutePath}`, { stdio: "inherit" })
43
+ return
44
+ }
45
+
46
+ console.log(cyan(`Using create-catalyst-app version ${bold(packageJson.version)}`))
47
+
48
+ // Use options provided through commander or prompt the user
49
+ validateOptions(cmd)
50
+
51
+ if (cmd.yes) {
52
+ console.log("Using default configuration.")
53
+ config = {
54
+ folderName: "my-app",
55
+ language: "js",
56
+ tailWindSupport: false,
57
+ description: "Default catalyst app",
58
+ stateManagement: "none",
59
+ mcpSupport: true,
60
+ }
61
+ }
62
+
63
+ const projectName = config.folderName || (await promptProjectName())
64
+ let isNameValid = validate(projectName)
65
+ if (!isNameValid.validForNewPackages) {
66
+ isNameValid?.warnings?.forEach?.((item) => console.log(red(item)))
67
+ isNameValid?.errors?.forEach?.((item) => console.log(red(item)))
68
+ process.exit(1)
69
+ }
70
+ let projectPath = path.join(process.cwd(), projectName)
71
+ if (fs.existsSync(projectPath)) {
72
+ console.log(red(`${projectName} already exists, try again.`))
73
+ process.exit(1)
74
+ }
75
+ const projectDescription = config.description || (await promptDescription())
76
+ const language = config.language || (await promptTypescript())
77
+ const tailWindSupport = config.tailWindSupport !== null || (await promptTailwind())
78
+ const stateManagement = config.stateManagement || (await promptStateManagement())
79
+ const mcpSupport = config.mcpSupport !== null || (await promptMcp())
80
+
81
+ // Define mapping of options to repository suffixes
82
+ const repositorySuffixes = {
83
+ js: "js",
84
+ ts: "ts",
85
+ redux: "redux",
86
+ rtk: "rtk",
87
+ none: "none",
88
+ }
89
+
90
+ const packageName = packageJson.name
91
+ const packageVersion = packageJson.version
92
+
93
+ const commonCodeDirectory = "package/templates/common"
94
+ const selectedTemplateCode = `package/templates/${repositorySuffixes[stateManagement]}-${repositorySuffixes[language]}`
95
+ const tailwindCodeDirectory = "package/templates/tailwind"
96
+ const mcpCodeDirectory = "package/templates/mcp-root"
97
+
98
+ const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
99
+ if (tailWindSupport) subDirectoriesToExtract.push(tailwindCodeDirectory)
100
+ if (mcpSupport) subDirectoriesToExtract.push(mcpCodeDirectory)
101
+
102
+ const extractionDestination = `/${projectName}/`
103
+ let tempDir
104
+ ;(() => {
105
+ try {
106
+ tempDir = createTempDir()
107
+
108
+ const packageFilePath = packNpmPackage(packageName, packageVersion, tempDir)
109
+
110
+ extractSubdirectory(packageFilePath)
111
+ createGitignore(projectName)
112
+
113
+ execSync(
114
+ `cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet`,
115
+ { stdio: "inherit" }
116
+ )
117
+
118
+ if (tailWindSupport) {
119
+ execSync(`cd ${projectName} && npm i tailwindcss@4.1.4 @tailwindcss/postcss@4.1.4`, {
120
+ stdio: "inherit",
121
+ })
122
+ }
123
+
124
+ if (mcpSupport) {
125
+ execSync(`cd ${projectName} && npm i @modelcontextprotocol/sdk`, { stdio: "inherit" })
126
+ }
127
+
128
+ execSync(
129
+ `cd ${projectName} && git add . && git commit -m "initial commit from Create Catalyst App"`,
130
+ {
131
+ stdio: "inherit",
132
+ }
133
+ )
134
+
135
+ console.log(`\n${green(bold("Success!"))} created ${projectName} at ${projectPath}`)
136
+ console.log("Inside this directory, you can run the following commands.")
137
+
138
+ console.log(cyan(bold(" \n npm run start")))
139
+ console.log(" Starts the development server ")
140
+
141
+ console.log(cyan(bold("\n npm run build")))
142
+ console.log(" Bundles the app for production ")
143
+
144
+ console.log(cyan(bold("\n npm run serve")))
145
+ console.log(" Serves the production build ")
146
+
147
+ console.log("\nWe suggest you to begin, by running")
148
+ console.log(` ${cyan("cd")} ${projectName} && ${cyan("npm start")} \n\n`)
149
+ } catch (error) {
150
+ console.error(`Error: ${error.message}`)
151
+ process.exit(1)
152
+ } finally {
153
+ deleteDirectory(tempDir)
154
+ }
155
+ })()
156
+ function packNpmPackage(packageName, packageVersion, tempDir) {
157
+ const tarballFileName = `${packageName}-${packageVersion}.tgz`
158
+ const tarballFilePath = path.join(tempDir, tarballFileName)
159
+
160
+ try {
161
+ execSync(`npm pack ${packageName}@${packageVersion} --silent`, {
162
+ cwd: tempDir,
163
+ })
164
+
165
+ // to test locally, comment the upper execSync and uncomment this one.
166
+ // execSync(`npm pack --pack-destination=${tempDir} --silent`, {
167
+ // cwd: process.cwd(),
168
+ // })
169
+
170
+ return tarballFilePath
171
+ } catch (error) {
172
+ console.error(`Error packing npm package: ${error.message}`)
173
+ throw error
174
+ }
175
+ }
176
+
177
+ // Function to create a temporary directory
178
+ function createTempDir() {
179
+ const tempDir = fs.mkdtempSync(path.join(process.cwd(), "temp-"))
180
+
181
+ return tempDir
182
+ }
183
+
184
+ // Function to extract subdirectory from npm package and delete tar file
185
+ function extractSubdirectory(packageFilePath) {
186
+ try {
187
+ tar.extract({
188
+ file: packageFilePath,
189
+ sync: true,
190
+ filter: (path, entry) => {
191
+ return subDirectoriesToExtract.reduce((acc, item) => {
192
+ return acc || path.startsWith(item)
193
+ }, false)
194
+ },
195
+ cwd: path.join(process.cwd()),
196
+ onentry: (entry) => {
197
+ if (entry.path.startsWith(commonCodeDirectory)) {
198
+ entry.path = entry.path.replace(commonCodeDirectory, extractionDestination)
199
+ }
200
+ if (entry.path.startsWith(selectedTemplateCode)) {
201
+ entry.path = entry.path.replace(selectedTemplateCode, extractionDestination)
202
+ }
203
+ if (entry.path.startsWith(tailwindCodeDirectory)) {
204
+ entry.path = entry.path.replace(tailwindCodeDirectory, extractionDestination)
205
+ }
206
+ if (entry.path.startsWith(mcpCodeDirectory)) {
207
+ entry.path = entry.path.replace(mcpCodeDirectory, extractionDestination)
208
+ }
209
+ },
210
+ })
211
+ } catch (e) {
212
+ console.log("An error occurred", e)
213
+ }
214
+
215
+ console.log(cyan(`Run cd ${projectName} && npm start to get started.`))
216
+ }
217
+ } catch (error) {
218
+ console.error(red("An error occurred:"), error.message)
219
+ process.exit(1)
220
+ }
221
+ })
222
+ .allowUnknownOption()
223
+
224
+ program.parse(process.argv)
225
+
226
+ async function promptStateManagement() {
227
+ const response = await prompts({
228
+ type: "select",
229
+ name: "stateManagement",
230
+ message: "Choose state management:",
231
+ choices: [
232
+ { title: "Redux", value: "redux" },
233
+ { title: "Redux Toolkit (RTK)", value: "rtk" },
234
+ { title: "None", value: "none" },
235
+ ],
236
+ })
237
+
238
+ return response.stateManagement
239
+ }
240
+ async function promptProjectName() {
241
+ const res = await prompts({
242
+ type: "text",
243
+ name: "path",
244
+ message: "What is your project named?",
245
+ initial: "my-app",
246
+ })
247
+
248
+ if (typeof res.path === "string") {
249
+ let projectName = res.path.trim()
250
+ return projectName
251
+ }
252
+
253
+ if (!res.path || projectName === "") {
254
+ console.log(
255
+ "\nPlease specify the project directory:\n" +
256
+ ` ${cyan(program.name())} ${green("<project-directory>")}\n` +
257
+ "For example:\n" +
258
+ ` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
259
+ `Run ${cyan(`${program.name()} --help`)} to see all options.`
260
+ )
261
+ process.exit(1)
262
+ }
263
+ }
264
+
265
+ async function promptDescription() {
266
+ const res = await prompts({
267
+ type: "text",
268
+ name: "path",
269
+ message: "What is your project description?",
270
+ })
271
+
272
+ if (typeof res.path === "string") {
273
+ return res.path.trim()
274
+ } else return null
275
+ }
276
+
277
+ async function promptTypescript() {
278
+ const response = await prompts({
279
+ type: "select",
280
+ name: "typescript",
281
+ message: "Would you like to use TypeScript?",
282
+ choices: [
283
+ { title: "Yes", value: "ts" },
284
+ { title: "No", value: "js" },
285
+ ],
286
+ })
287
+
288
+ return response.typescript
289
+ }
290
+
291
+ async function promptTailwind() {
292
+ const response = await prompts({
293
+ type: "select",
294
+ name: "tailwind",
295
+ message: "Would you like to use Tailwind CSS?",
296
+ choices: [
297
+ { title: "Yes", value: true },
298
+ { title: "No", value: false },
299
+ ],
300
+ })
301
+ return response.tailwind
302
+ }
303
+
304
+ async function promptMcp() {
305
+ const response = await prompts({
306
+ type: "select",
307
+ name: "mcp",
308
+ message: "Would you like to setup an MCP server?",
309
+ choices: [
310
+ { title: "Yes", value: true },
311
+ { title: "No", value: false },
312
+ ],
313
+ })
314
+ return response.mcp
315
+ }
316
+
317
+ function validateOptions(cmd) {
318
+ // Validate language option
319
+ if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
320
+ throw new Error('Invalid language option. Use "js" or "ts".')
321
+ }
322
+
323
+ // Validate state management option
324
+ if (cmd.stateManagement && !["rtk", "redux", "none"].includes(cmd.stateManagement.toLowerCase())) {
325
+ throw new Error('Invalid state management option. Use "rtk", "redux", or "none".')
326
+ }
327
+
328
+ if (cmd.yes && typeof cmd.yes !== "boolean") {
329
+ throw new Error('Invalid option for "yes". Use "-y" or "--yes" to accept defaults.')
330
+ }
331
+ }
332
+
333
+ function deleteDirectory(dirPath) {
334
+ if (dirPath && fs.existsSync(dirPath)) {
335
+ fs.readdirSync(dirPath).forEach((file) => {
336
+ const currentPath = path.join(dirPath, file)
337
+ if (fs.lstatSync(currentPath).isDirectory()) {
338
+ deleteDirectory(currentPath)
339
+ } else {
340
+ fs.unlinkSync(currentPath)
341
+ }
342
+ })
343
+ fs.rmdirSync(dirPath)
344
+ }
345
+ }
346
+
347
+ // Function to create a .gitignore file with the hardcoded patterns
348
+ function createGitignore(projectName) {
349
+ const gitiIgnorePatterns = ["node_modules", "build", "logs"]
350
+
351
+ const gitignorePath = path.join(process.cwd(), projectName, ".gitignore")
352
+
353
+ if (fs.existsSync(gitignorePath)) {
354
+ console.log(".gitignore already exists. Please rename or remove it before running the script.")
355
+ return
356
+ }
357
+
358
+ fs.writeFileSync(gitignorePath, gitiIgnorePatterns.join("\n"))
359
+ }
@@ -1,6 +1 @@
1
- **/node_modules/*
2
- **/dist/*
3
- **/build/*
4
- **/coverage/*
5
- **/eventScripts/*
6
- **/docs/*
1
+ **/build/*
@@ -1,53 +1,28 @@
1
1
  {
2
- "parser": "@babel/eslint-parser",
3
2
  "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
- }]
3
+ "react-hooks/exhaustive-deps": "error" // Checks effect dependencies
14
4
  },
15
5
  "env": {
16
6
  "browser": true,
17
7
  "es6": true,
18
- "jest": true,
19
8
  "node": true
20
9
  },
21
- "globals": {
22
- "expect": true,
23
- "__non_webpack_require__": true,
24
- "logger": "readonly",
25
- "AppCallbacks": "readonly"
26
- },
27
- "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended"],
10
+ "extends": [
11
+ "eslint:recommended",
12
+ "plugin:react/recommended",
13
+ ],
28
14
  "parserOptions": {
29
15
  "sourceType": "module",
30
- "ecmaFeatures": {
31
- "experimentalObjectRestSpread": true,
32
- "jsx": true
33
- },
34
- "babelOptions": {
35
- "configFile": "./babel.config.js"
36
- },
37
- "ecmaVersion": 6
16
+ "ecmaVersion": "latest"
38
17
  },
39
- "plugins": ["babel", "react", "react-hooks", "prettier", "jam3"],
40
- "settings": {
18
+ "plugins": [
19
+ "react",
20
+ "react-hooks"
21
+ ],
22
+ "settings": {
41
23
  "react": {
42
- "createClass": "createReactClass",
43
24
  "pragma": "React",
44
25
  "version": "detect"
45
- },
46
- "propWrapperFunctions": [
47
- "forbidExtraProps",
48
- { "property": "freeze", "object": "Object" },
49
- { "property": "myFavoriteWrapper" }
50
- ],
51
- "linkComponents": ["Hyperlink", { "name": "Link", "linkAttribute": "to" }]
26
+ }
52
27
  }
53
- }
28
+ }
@@ -1,29 +1,25 @@
1
- # README #
1
+ ## Getting Started
2
2
 
3
- This README would normally document whatever steps are necessary to get your application up and running.
3
+ Commence development by initiating the the following commands:
4
4
 
5
- ### What is this repository for? ###
5
+ For running the application in development mode, run:
6
6
 
7
- * Quick summary
8
- * Version
9
- * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
7
+ ```bash
8
+ npm run start
9
+ ```
10
10
 
11
- ### How do I get set up? ###
11
+ For a production build, change NODE_ENV to "production" in config/config.json, then run :
12
12
 
13
- * Summary of set up
14
- * Configuration
15
- * Dependencies
16
- * Database configuration
17
- * How to run tests
18
- * Deployment instructions
13
+ ```bash
14
+ npm run build
15
+ ```
19
16
 
20
- ### Contribution guidelines ###
17
+ To serve the production build, execute:
21
18
 
22
- * Writing tests
23
- * Code review
24
- * Other guidelines
19
+ ```bash
20
+ npm run serve
21
+ ```
25
22
 
26
- ### Who do I talk to? ###
23
+ ## Documentation
27
24
 
28
- * Repo owner or admin
29
- * Other community or team contact
25
+ Explore the complete documentation at [https://catalyst.1mg.com](https://catalyst.1mg.com).
@@ -1,29 +1,16 @@
1
- const apiInstance = () => {
2
- const fetchFunction = async (url, options) => {
3
- let baseURL = process.env.API_URL
4
- let finalUrl = baseURL + url
1
+ const fetchFunction = (url, options) => {
2
+ let baseURL = process.env.API_URL
3
+ let finalUrl = baseURL + url
5
4
 
6
- // Request Interceptor - you can modify request here
5
+ // Request Interceptor - modify request here
7
6
 
8
-
9
- // Add query params if exist
10
- if (Object.keys(options?.params).length > 0) {
11
- finalUrl = url + "?" + new URLSearchParams(options.params)
12
- }
13
-
14
- return fetch(finalUrl, options)
15
- .then(async (response) => {
16
- const parsedResponse = await response.json()
17
- // Response Interceptor - you can modify response here
7
+ return fetch(finalUrl, options)
8
+ .then(response => {
9
+ return response.json().then(parsedResponse => {
10
+ // Response Interceptor - modify response here
18
11
  return parsedResponse
19
- });
20
- }
21
- return {
22
- get: fetchFunction,
23
- post: fetchFunction,
24
- delete: fetchFunction,
25
- patch: fetchFunction,
26
- put: fetchFunction
27
- }
12
+ })
13
+ })
28
14
  }
29
- export default { apiInstance }
15
+
16
+ export default fetchFunction
@@ -1,15 +1,3 @@
1
- /* Style Loader
2
- *
3
- * Anything imported in here will either be added to the vendor CSS chunk, or
4
- * the main app CSS chunk. Where they will go depends on its location or its
5
- * extension.
6
- *
7
- * Files will be added to the vendor.css chunk if:
8
- * - they are located inside `node_modules`, or
9
- * - they are plain .css files.
10
- * Otherwise, files will be added to the main app.css chunk.
11
- */
1
+ // Include initial base styles. Global styles will come here.
12
2
 
13
- // Include initial base styles.
14
- import "normalize.css"
15
3
  import "@css/base/index.scss"
@@ -1,18 +1,12 @@
1
1
  {
2
- "S3_BUCKET": "stagassets.1mg.com",
3
- "S3_FOLDER": "pwa-app",
4
- "CDN_ASSET_PATH": "https://stagstatic.1mg.com",
5
- "APPLICATION_PORT": "3005",
6
- "APPLICATION_BASE_URL": "http://localhost:3005",
7
- "SERVER_PATH": "http://localhost:3005",
8
- "OUTPUT_PATH": "build",
9
- "PUBLIC_OUTPUT_PATH": "build/public",
10
- "PUBLIC_ASSET_PATH": "http://localhost:3006/assets/",
11
- "LOCAL_ASSET_PATH": "/assets/",
12
- "EXTERNAL_BASE_URL": "http://localhost:3005",
13
- "DEV_SERVER_PORT": 3006,
14
- "DEV_SERVER_HOSTNAME": "localhost",
15
- "DEV_SERVER_HOST_URL": "http://localhost:3006",
16
- "ENV_NAME": "local",
17
- "BUILD_ENV": ""
2
+ "NODE_SERVER_HOSTNAME": "localhost",
3
+ "NODE_SERVER_PORT": 3005,
4
+ "WEBPACK_DEV_SERVER_HOSTNAME": "localhost",
5
+ "WEBPACK_DEV_SERVER_PORT": 3006,
6
+ "BUILD_OUTPUT_PATH": "build",
7
+ "PUBLIC_STATIC_ASSET_PATH": "/assets/",
8
+ "PUBLIC_STATIC_ASSET_URL": "http://localhost:3005",
9
+ "API_URL": "",
10
+ "ANALYZE_BUNDLE": false,
11
+ "CLIENT_ENV_VARIABLES": ["API_URL"]
18
12
  }
@@ -3,10 +3,8 @@ import { Head, Body } from "catalyst-core"
3
3
 
4
4
  function Document(props) {
5
5
  return (
6
- <html lang={props.lang}>
7
- <Head {...props}>
8
- <meta charset="final-order" />
9
- </Head>
6
+ <html lang="en">
7
+ <Head {...props}></Head>
10
8
  <Body {...props} />
11
9
  </html>
12
10
  )
@@ -0,0 +1,2 @@
1
+ // This function is executed before server starts.
2
+ export const preServerInit = () => {}
@@ -0,0 +1,8 @@
1
+ const express = require("express")
2
+ const path = require("path")
3
+
4
+ // Server middlewares are added here.
5
+
6
+ export function addMiddlewares(app) {
7
+ app.use("/favicon.ico", express.static(path.join(__dirname, "../public/favicon.ico")))
8
+ }
@@ -1,40 +1,23 @@
1
- import React,{useEffect} from "react";
2
- import { useCurrentRouteData,Link } from "@tata1mg/router";
3
- const Home = () => {
4
- const {data,isFetched,loading} = useCurrentRouteData() || {}
5
-
6
-
7
- useEffect(()=>{
8
- console.log("data is =>",data)
9
- })
10
-
11
-
12
- return (
13
-
14
- <div>
15
- <>Welcome to catalyst</>
16
- <Link to={"/pdp"}>pdp</Link>
17
- </div>
18
- );
19
- };
20
-
21
- Home.serverFetcher = async ({ req }, { store }) => {
22
- console.log("server fetcher called!!")
23
- const res = await fetch("https://jsonblob.com/api/1206830251241234432");
24
- const json = await res.json();
25
- return json;
26
- };
27
-
28
- Home.clientFetcher = async ({ }, { store },{}) => {
29
-
30
- console.log("client fetcher called",pageNo)
31
- const res = await fetch("https://jsonblob.com/api/1206830251241234432");
32
- const json = await res.json();
33
- return json;
34
- };
35
-
36
- Home.MetaTagFunction = () => {
37
- return [<title key="PDP">Home</title>]
38
- };
39
-
40
- export default Home;
1
+ import React from "react"
2
+ import css from "./Home.scss"
3
+
4
+ function Home() {
5
+ return (
6
+ <div className={css.app}>
7
+ <header className={css.appHeader}>
8
+ <h1 className={css.heading}>Catalyst</h1>
9
+ <p>Edit files inside src directory and save to reload.</p>
10
+ <a
11
+ className={css.appLink}
12
+ href="https://catalyst.1mg.com"
13
+ target="_blank"
14
+ rel="noopener noreferrer"
15
+ >
16
+ Learn Catalyst
17
+ </a>
18
+ </header>
19
+ </div>
20
+ )
21
+ }
22
+
23
+ export default Home