create-catalyst-app 0.0.1-beta.1 → 0.0.1-beta.11

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 (197) 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 +259 -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/templates/{redux-js → common}/webpackConfig.js +2 -2
  27. package/templates/none-js/client/index.js +8 -12
  28. package/templates/none-js/package.json +13 -36
  29. package/templates/none-js/src/js/containers/App/index.js +12 -36
  30. package/templates/none-js/src/js/routes/utils.js +42 -0
  31. package/templates/redux-js/client/index.js +6 -5
  32. package/templates/redux-js/package.json +16 -36
  33. package/templates/redux-js/src/js/containers/App/actions.js +1 -4
  34. package/templates/redux-js/src/js/containers/App/index.js +12 -38
  35. package/templates/redux-js/src/js/containers/App/reducer.js +15 -17
  36. package/templates/redux-js/src/js/routes/utils.js +42 -0
  37. package/templates/redux-js/src/js/store/index.js +17 -68
  38. package/templates/rtk-js/client/index.js +6 -5
  39. package/templates/rtk-js/package.json +16 -36
  40. package/templates/rtk-js/src/js/containers/App/index.js +12 -38
  41. package/templates/rtk-js/src/js/containers/App/reducer.js +1 -9
  42. package/templates/rtk-js/src/js/routes/utils.js +42 -0
  43. package/templates/rtk-js/src/js/store/index.js +12 -6
  44. package/scripts/cli.mjs +0 -266
  45. package/templates/common/.babelrc +0 -26
  46. package/templates/common/.editorconfig +0 -12
  47. package/templates/common/.stylelintrc +0 -35
  48. package/templates/common/checkVersion.js +0 -3
  49. package/templates/common/client/index.js +0 -39
  50. package/templates/common/config/config_template.json +0 -18
  51. package/templates/common/config/index.js +0 -77
  52. package/templates/common/package.json +0 -57
  53. package/templates/common/server/CustomDocument.js +0 -14
  54. package/templates/common/server/customIndex.js +0 -3
  55. package/templates/common/server/customServer.js +0 -16
  56. package/templates/common/src/js/containers/App/actions.js +0 -20
  57. package/templates/common/src/js/containers/App/index.js +0 -46
  58. package/templates/common/src/js/containers/App/reducer.js +0 -21
  59. package/templates/common/src/js/containers/PDP/PDP.js +0 -37
  60. package/templates/common/src/js/reducer/index.js +0 -80
  61. package/templates/common/src/js/stateManager/stateProvider.js +0 -34
  62. package/templates/common/src/js/store/index.js +0 -77
  63. package/templates/common/src/static/css/base/_overrides.scss +0 -81
  64. package/templates/common/src/static/css/base/animations.js +0 -38
  65. package/templates/common/src/static/css/base/layout.scss +0 -242
  66. package/templates/common/src/static/css/base/typography.scss +0 -285
  67. package/templates/common/src/static/css/resources/_mixins.scss +0 -196
  68. package/templates/common/src/static/css/resources/_vendors.scss +0 -1
  69. package/templates/common/src/static/fonts/.gitkeep +0 -0
  70. package/templates/common/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  71. package/templates/common/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  72. package/templates/common/src/static/fonts/Inter-Light-Subset.otf +0 -0
  73. package/templates/common/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  74. package/templates/common/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  75. package/templates/common/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  76. package/templates/common/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  77. package/templates/common/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  78. package/templates/common/src/static/fonts/Poppins-Light-Subset.woff2 +0 -0
  79. package/templates/common/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  80. package/templates/common/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  81. package/templates/common/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  82. package/templates/none-js/.babelrc +0 -26
  83. package/templates/none-js/.eslintignore +0 -6
  84. package/templates/none-js/.eslintrc +0 -53
  85. package/templates/none-js/.prettierrc.json +0 -7
  86. package/templates/none-js/.stylelintrc +0 -35
  87. package/templates/none-js/README.md +0 -22
  88. package/templates/none-js/api.js +0 -29
  89. package/templates/none-js/checkVersion.js +0 -3
  90. package/templates/none-js/client/styles.js +0 -15
  91. package/templates/none-js/config/config.json +0 -15
  92. package/templates/none-js/config/config_template.json +0 -18
  93. package/templates/none-js/config/index.js +0 -44
  94. package/templates/none-js/server/document.js +0 -14
  95. package/templates/none-js/server/index.js +0 -3
  96. package/templates/none-js/server/server.js +0 -16
  97. package/templates/none-js/src/js/containers/DemoPage/DemoPage.js +0 -39
  98. package/templates/none-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
  99. package/templates/none-js/src/js/containers/Home/Home.js +0 -27
  100. package/templates/none-js/src/js/containers/Home/Home.scss +0 -36
  101. package/templates/none-js/src/js/routes/index.js +0 -49
  102. package/templates/none-js/src/js/stateManager/stateProvider.js +0 -19
  103. package/templates/none-js/src/js/store/index.js +0 -6
  104. package/templates/none-js/src/static/css/base/index.scss +0 -3
  105. package/templates/none-js/src/static/css/base/styles.scss +0 -11
  106. package/templates/none-js/src/static/css/base/typography.scss +0 -53
  107. package/templates/none-js/src/static/css/resources/_variables.scss +0 -1
  108. package/templates/none-js/src/static/fonts/.gitkeep +0 -0
  109. package/templates/none-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  110. package/templates/none-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  111. package/templates/none-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  112. package/templates/none-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  113. package/templates/none-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  114. package/templates/none-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  115. package/templates/none-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  116. package/templates/none-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  117. package/templates/none-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  118. package/templates/none-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  119. package/templates/none-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  120. package/templates/none-js/webpackConfig.js +0 -5
  121. package/templates/redux-js/.babelrc +0 -26
  122. package/templates/redux-js/.eslintignore +0 -6
  123. package/templates/redux-js/.eslintrc +0 -53
  124. package/templates/redux-js/.prettierrc.json +0 -7
  125. package/templates/redux-js/.stylelintrc +0 -35
  126. package/templates/redux-js/README.md +0 -22
  127. package/templates/redux-js/api.js +0 -29
  128. package/templates/redux-js/checkVersion.js +0 -3
  129. package/templates/redux-js/client/styles.js +0 -15
  130. package/templates/redux-js/config/config.json +0 -15
  131. package/templates/redux-js/config/config_template.json +0 -18
  132. package/templates/redux-js/config/index.js +0 -44
  133. package/templates/redux-js/server/index.js +0 -3
  134. package/templates/redux-js/server/server.js +0 -16
  135. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.js +0 -39
  136. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
  137. package/templates/redux-js/src/js/containers/Home/Home.js +0 -27
  138. package/templates/redux-js/src/js/containers/Home/Home.scss +0 -36
  139. package/templates/redux-js/src/js/reducer/index.js +0 -80
  140. package/templates/redux-js/src/js/routes/index.js +0 -49
  141. package/templates/redux-js/src/js/stateManager/stateProvider.js +0 -34
  142. package/templates/redux-js/src/static/css/base/index.scss +0 -3
  143. package/templates/redux-js/src/static/css/base/styles.scss +0 -11
  144. package/templates/redux-js/src/static/css/base/typography.scss +0 -53
  145. package/templates/redux-js/src/static/css/resources/_variables.scss +0 -1
  146. package/templates/redux-js/src/static/fonts/.gitkeep +0 -0
  147. package/templates/redux-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  148. package/templates/redux-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  149. package/templates/redux-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  150. package/templates/redux-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  151. package/templates/redux-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  152. package/templates/redux-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  153. package/templates/redux-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  154. package/templates/redux-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  155. package/templates/redux-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  156. package/templates/redux-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  157. package/templates/redux-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  158. package/templates/rtk-js/.babelrc +0 -26
  159. package/templates/rtk-js/.eslintignore +0 -6
  160. package/templates/rtk-js/.eslintrc +0 -53
  161. package/templates/rtk-js/.prettierrc.json +0 -7
  162. package/templates/rtk-js/.stylelintrc +0 -35
  163. package/templates/rtk-js/README.md +0 -23
  164. package/templates/rtk-js/api.js +0 -29
  165. package/templates/rtk-js/checkVersion.js +0 -3
  166. package/templates/rtk-js/client/styles.js +0 -15
  167. package/templates/rtk-js/config/config.json +0 -15
  168. package/templates/rtk-js/config/config_template.json +0 -18
  169. package/templates/rtk-js/config/index.js +0 -44
  170. package/templates/rtk-js/server/document.js +0 -14
  171. package/templates/rtk-js/server/index.js +0 -3
  172. package/templates/rtk-js/server/server.js +0 -16
  173. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.js +0 -39
  174. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
  175. package/templates/rtk-js/src/js/containers/Home/Home.js +0 -27
  176. package/templates/rtk-js/src/js/containers/Home/Home.scss +0 -36
  177. package/templates/rtk-js/src/js/reducer/index.js +0 -80
  178. package/templates/rtk-js/src/js/routes/index.js +0 -49
  179. package/templates/rtk-js/src/js/stateManager/stateProvider.js +0 -34
  180. package/templates/rtk-js/src/static/css/base/index.scss +0 -3
  181. package/templates/rtk-js/src/static/css/base/styles.scss +0 -11
  182. package/templates/rtk-js/src/static/css/base/typography.scss +0 -53
  183. package/templates/rtk-js/src/static/css/resources/_variables.scss +0 -1
  184. package/templates/rtk-js/src/static/fonts/.gitkeep +0 -0
  185. package/templates/rtk-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  186. package/templates/rtk-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  187. package/templates/rtk-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  188. package/templates/rtk-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  189. package/templates/rtk-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  190. package/templates/rtk-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  191. package/templates/rtk-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  192. package/templates/rtk-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  193. package/templates/rtk-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  194. package/templates/rtk-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  195. package/templates/rtk-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  196. package/templates/rtk-js/webpackConfig.js +0 -5
  197. /package/{templates/common/.prettierrc.json → .prettierrc.json} +0 -0
@@ -0,0 +1,259 @@
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(
21
+ new Option(
22
+ "-s, --state-management [stateManagement]",
23
+ "Specify state management (rtk, redux, or none)",
24
+ /^(rtk|redux|none)$/i,
25
+ "none"
26
+ )
27
+ )
28
+ .action(async (folderName = null, cmd) => {
29
+ try {
30
+ if (process.argv.includes("new-route")) {
31
+ const createRoutePath = path.join(__dirname, "../codemod/new-route/index.js")
32
+ execSync(`node ${createRoutePath}`, { stdio: "inherit" })
33
+ return
34
+ }
35
+
36
+ // Use options provided through commander or prompt the user
37
+ validateOptions(cmd)
38
+ const projectName = folderName || (await promptProjectName())
39
+ let isNameValid = validate(projectName)
40
+ if (!isNameValid.validForNewPackages) {
41
+ isNameValid?.warnings?.forEach?.((item) => console.log(red(item)))
42
+ isNameValid?.errors?.forEach?.((item) => console.log(red(item)))
43
+ process.exit(1)
44
+ }
45
+ let projectPath = path.join(process.cwd(), projectName)
46
+ if (fs.existsSync(projectPath)) {
47
+ console.log(red(`${projectName} already exists, try again.`))
48
+ process.exit(1)
49
+ }
50
+ const language = "js"
51
+ const projectDescription = await promptDescription()
52
+ const stateManagement = cmd.stateManagement || (await promptStateManagement())
53
+
54
+ // Define mapping of options to repository suffixes
55
+ const repositorySuffixes = {
56
+ js: "js",
57
+ ts: "ts",
58
+ redux: "redux",
59
+ rtk: "rtk",
60
+ none: "none",
61
+ }
62
+
63
+ const packageName = packageJson.name
64
+ const packageVersion = packageJson.version
65
+
66
+ const commonCodeDirectory = "package/templates/common"
67
+ const selectedTemplateCode = `package/templates/${repositorySuffixes[stateManagement]}-${repositorySuffixes[language]}`
68
+ const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
69
+ const extractionDestination = `/${projectName}/`
70
+ let tempDir
71
+ ;(() => {
72
+ try {
73
+ tempDir = createTempDir()
74
+
75
+ const packageFilePath = packNpmPackage(packageName, packageVersion, tempDir)
76
+
77
+ extractSubdirectory(packageFilePath)
78
+ createGitignore(projectName)
79
+
80
+ execSync(
81
+ `cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet && git add . && git commit -m "initial commit from Create Catalyst App"`,
82
+ { stdio: "inherit" }
83
+ )
84
+
85
+ console.log(`\n${green(bold("Success!"))} created ${projectName} at ${projectPath}`)
86
+ console.log("Inside this directory, you can run the following commands.")
87
+
88
+ console.log(cyan(bold(" \n npm run start")))
89
+ console.log(" Starts the development server ")
90
+
91
+ console.log(cyan(bold("\n npm run build")))
92
+ console.log(" Bundles the app for production ")
93
+
94
+ console.log(cyan(bold("\n npm run serve")))
95
+ console.log(" Serves the production build ")
96
+
97
+ console.log("\nWe suggest you to begin, by running")
98
+ console.log(` ${cyan("cd")} ${projectName} && ${cyan("npm start")} \n\n`)
99
+ } catch (error) {
100
+ console.error(`Error: ${error.message}`)
101
+ process.exit(1)
102
+ } finally {
103
+ deleteDirectory(tempDir)
104
+ }
105
+ })()
106
+ function packNpmPackage(packageName, packageVersion, tempDir) {
107
+ const tarballFileName = `${packageName}-${packageVersion}.tgz`
108
+ const tarballFilePath = path.join(tempDir, tarballFileName)
109
+
110
+ try {
111
+ execSync(`npm pack ${packageName}@${packageVersion} --silent`, {
112
+ cwd: tempDir,
113
+ })
114
+
115
+ // to test locally, comment the upper execSync and uncomment this one.
116
+ // execSync(`npm pack --pack-destination=${tempDir} --silent`, {
117
+ // cwd: process.cwd(),
118
+ // });
119
+
120
+ return tarballFilePath
121
+ } catch (error) {
122
+ console.error(`Error packing npm package: ${error.message}`)
123
+ throw error
124
+ }
125
+ }
126
+
127
+ // Function to create a temporary directory
128
+ function createTempDir() {
129
+ const tempDir = fs.mkdtempSync(path.join(process.cwd(), "temp-"))
130
+
131
+ return tempDir
132
+ }
133
+
134
+ // Function to extract subdirectory from npm package and delete tar file
135
+ function extractSubdirectory(packageFilePath) {
136
+ try {
137
+ tar.extract({
138
+ file: packageFilePath,
139
+ sync: true,
140
+ filter: (path, entry) => {
141
+ return subDirectoriesToExtract.reduce((acc, item) => {
142
+ return acc || path.startsWith(item)
143
+ }, false)
144
+ },
145
+ cwd: path.join(process.cwd()),
146
+ onentry: (entry) => {
147
+ if (entry.path.startsWith(commonCodeDirectory)) {
148
+ entry.path = entry.path.replace(commonCodeDirectory, extractionDestination)
149
+ }
150
+ if (entry.path.startsWith(selectedTemplateCode)) {
151
+ entry.path = entry.path.replace(selectedTemplateCode, extractionDestination)
152
+ }
153
+ },
154
+ })
155
+ } catch (e) {
156
+ console.log("An error occurred", e)
157
+ }
158
+
159
+ cyan(`Run cd ${projectName} && npm start to get started.`)
160
+ }
161
+ } catch (error) {
162
+ console.error(red("An error occurred:"), error.message)
163
+ process.exit(1)
164
+ }
165
+ })
166
+ .allowUnknownOption()
167
+
168
+ program.parse(process.argv)
169
+
170
+ async function promptStateManagement() {
171
+ const response = await prompts({
172
+ type: "select",
173
+ name: "stateManagement",
174
+ message: "Choose state management:",
175
+ choices: [
176
+ { title: "Redux", value: "redux" },
177
+ { title: "Redux Toolkit (RTK)", value: "rtk" },
178
+ { title: "None", value: "none" },
179
+ ],
180
+ })
181
+
182
+ return response.stateManagement
183
+ }
184
+ async function promptProjectName() {
185
+ const res = await prompts({
186
+ type: "text",
187
+ name: "path",
188
+ message: "What is your project named?",
189
+ initial: "my-app",
190
+ })
191
+
192
+ if (typeof res.path === "string") {
193
+ let projectName = res.path.trim()
194
+ return projectName
195
+ }
196
+
197
+ if (!res.path || projectName === "") {
198
+ console.log(
199
+ "\nPlease specify the project directory:\n" +
200
+ ` ${cyan(program.name())} ${green("<project-directory>")}\n` +
201
+ "For example:\n" +
202
+ ` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
203
+ `Run ${cyan(`${program.name()} --help`)} to see all options.`
204
+ )
205
+ process.exit(1)
206
+ }
207
+ }
208
+
209
+ async function promptDescription() {
210
+ const res = await prompts({
211
+ type: "text",
212
+ name: "path",
213
+ message: "What is your project description?",
214
+ })
215
+
216
+ if (typeof res.path === "string") {
217
+ return res.path.trim()
218
+ } else return null
219
+ }
220
+
221
+ function validateOptions(cmd) {
222
+ // Validate language option
223
+ if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
224
+ throw new Error('Invalid language option. Use "js" or "ts".')
225
+ }
226
+
227
+ // Validate state management option
228
+ if (cmd.stateManagement && !["rtk", "redux", "none"].includes(cmd.stateManagement.toLowerCase())) {
229
+ throw new Error('Invalid state management option. Use "rtk", "redux", or "none".')
230
+ }
231
+ }
232
+
233
+ function deleteDirectory(dirPath) {
234
+ if (dirPath && fs.existsSync(dirPath)) {
235
+ fs.readdirSync(dirPath).forEach((file) => {
236
+ const currentPath = path.join(dirPath, file)
237
+ if (fs.lstatSync(currentPath).isDirectory()) {
238
+ deleteDirectory(currentPath)
239
+ } else {
240
+ fs.unlinkSync(currentPath)
241
+ }
242
+ })
243
+ fs.rmdirSync(dirPath)
244
+ }
245
+ }
246
+
247
+ // Function to create a .gitignore file with the hardcoded patterns
248
+ function createGitignore(projectName) {
249
+ const gitiIgnorePatterns = ["node_modules", "build", "logs"]
250
+
251
+ const gitignorePath = path.join(process.cwd(), projectName, ".gitignore")
252
+
253
+ if (fs.existsSync(gitignorePath)) {
254
+ console.log(".gitignore already exists. Please rename or remove it before running the script.")
255
+ return
256
+ }
257
+
258
+ fs.writeFileSync(gitignorePath, gitiIgnorePatterns.join("\n"))
259
+ }
@@ -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
@@ -0,0 +1,34 @@
1
+ body {
2
+ margin: 0;
3
+ }
4
+
5
+ .app {
6
+ text-align: center;
7
+ margin: 0;
8
+ }
9
+
10
+ .appLogo {
11
+ height: 40vmin;
12
+ pointer-events: none;
13
+ }
14
+
15
+ @media (prefers-reduced-motion: no-preference) {
16
+ .appLogo {
17
+ animation: App-logo-spin infinite 20s linear;
18
+ }
19
+ }
20
+
21
+ .appHeader {
22
+ background-color: #282c34;
23
+ min-height: 100vh;
24
+ display: flex;
25
+ flex-direction: column;
26
+ align-items: center;
27
+ justify-content: center;
28
+ font-size: calc(10px + 2vmin);
29
+ color: white;
30
+ }
31
+
32
+ .appLink {
33
+ color: #61dafb;
34
+ }
@@ -1,50 +1,11 @@
1
- import React from "react";
2
- import { RouterDataProvider } from "@tata1mg/router";
3
- import Home from "@containers/Home/Home";
4
- import PDP from "@containers/PDP/PDP";
5
- import App from "@containers/App";
1
+ import Home from "@containers/Home/Home"
6
2
 
7
3
  const routes = [
8
- {
9
- path: "/",
10
- end: true,
11
- component: Home,
12
- },
13
- {
14
- path: "/pdp",
15
- end: true,
16
- component: PDP,
17
- },
18
- ];
19
- const getRoutes = () => {
20
- return routes;
21
- };
22
-
23
- /**
24
- * Making the routes array compatible with the format accepted by createBrowserRouter
25
- * API on the client side
26
- */
27
- export const preparedRoutes = ({store,routerInitialState}) => {
28
-
29
- return ([
30
- {
31
- element: (
32
- <RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{store}} >
33
-
34
- <App />
35
-
36
- </RouterDataProvider>
37
- ),
38
- children: getRoutes()?.map((route, index) => {
39
- const Component = route.component;
40
- // const pageType = route.staticPageType ? route.staticPageType : null
41
- return {
42
- ...route,
43
- element: <Component key={index} />,
44
- };
45
- }),
46
- },
47
- ])
48
- }
49
-
50
- export default getRoutes;
4
+ {
5
+ path: "/",
6
+ end: true,
7
+ component: Home,
8
+ },
9
+ ]
10
+
11
+ export default routes
@@ -1,8 +1 @@
1
- @import "typography";
2
- @import "layout";
3
1
  @import "styles";
4
- @import "overrides";
5
-
6
-
7
- @import "../resources/variables";
8
- @import "../resources/mixins";