create-catalyst-app 0.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/package.json +20 -0
  2. package/readme.md +53 -0
  3. package/scripts/cli.mjs +267 -0
  4. package/templates/common/.babelrc +26 -0
  5. package/templates/common/.editorconfig +12 -0
  6. package/templates/common/.eslintignore +6 -0
  7. package/templates/common/.eslintrc +53 -0
  8. package/templates/common/.prettierrc.json +7 -0
  9. package/templates/common/.stylelintrc +35 -0
  10. package/templates/common/README.md +29 -0
  11. package/templates/common/api.js +29 -0
  12. package/templates/common/checkVersion.js +3 -0
  13. package/templates/common/client/index.js +39 -0
  14. package/templates/common/client/styles.js +15 -0
  15. package/templates/common/config/config.json +18 -0
  16. package/templates/common/config/config_template.json +18 -0
  17. package/templates/common/config/index.js +77 -0
  18. package/templates/common/package.json +57 -0
  19. package/templates/common/server/CustomDocument.js +14 -0
  20. package/templates/common/server/customIndex.js +3 -0
  21. package/templates/common/server/customServer.js +16 -0
  22. package/templates/common/src/js/containers/App/actions.js +20 -0
  23. package/templates/common/src/js/containers/App/index.js +46 -0
  24. package/templates/common/src/js/containers/App/reducer.js +21 -0
  25. package/templates/common/src/js/containers/Home/Home.js +40 -0
  26. package/templates/common/src/js/containers/PDP/PDP.js +37 -0
  27. package/templates/common/src/js/reducer/index.js +80 -0
  28. package/templates/common/src/js/routes/index.js +50 -0
  29. package/templates/common/src/js/stateManager/stateProvider.js +34 -0
  30. package/templates/common/src/js/store/index.js +77 -0
  31. package/templates/common/src/static/css/base/_overrides.scss +81 -0
  32. package/templates/common/src/static/css/base/animations.js +38 -0
  33. package/templates/common/src/static/css/base/index.scss +8 -0
  34. package/templates/common/src/static/css/base/layout.scss +242 -0
  35. package/templates/common/src/static/css/base/styles.scss +163 -0
  36. package/templates/common/src/static/css/base/typography.scss +285 -0
  37. package/templates/common/src/static/css/resources/_mixins.scss +196 -0
  38. package/templates/common/src/static/css/resources/_variables.scss +172 -0
  39. package/templates/common/src/static/css/resources/_vendors.scss +1 -0
  40. package/templates/common/src/static/fonts/.gitkeep +0 -0
  41. package/templates/common/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  42. package/templates/common/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  43. package/templates/common/src/static/fonts/Inter-Light-Subset.otf +0 -0
  44. package/templates/common/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  45. package/templates/common/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  46. package/templates/common/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  47. package/templates/common/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  48. package/templates/common/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  49. package/templates/common/src/static/fonts/Poppins-Light-Subset.woff2 +0 -0
  50. package/templates/common/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  51. package/templates/common/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  52. package/templates/common/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  53. package/templates/none-js/.babelrc +26 -0
  54. package/templates/none-js/.eslintignore +6 -0
  55. package/templates/none-js/.eslintrc +53 -0
  56. package/templates/none-js/.prettierrc.json +7 -0
  57. package/templates/none-js/.stylelintrc +35 -0
  58. package/templates/none-js/README.md +22 -0
  59. package/templates/none-js/api.js +29 -0
  60. package/templates/none-js/checkVersion.js +3 -0
  61. package/templates/none-js/client/index.js +27 -0
  62. package/templates/none-js/client/styles.js +15 -0
  63. package/templates/none-js/config/config.json +15 -0
  64. package/templates/none-js/config/config_template.json +18 -0
  65. package/templates/none-js/config/index.js +44 -0
  66. package/templates/none-js/package.json +53 -0
  67. package/templates/none-js/server/document.js +14 -0
  68. package/templates/none-js/server/index.js +3 -0
  69. package/templates/none-js/server/server.js +16 -0
  70. package/templates/none-js/src/js/containers/App/index.js +40 -0
  71. package/templates/none-js/src/js/containers/DemoPage/DemoPage.js +39 -0
  72. package/templates/none-js/src/js/containers/DemoPage/DemoPage.scss +3 -0
  73. package/templates/none-js/src/js/containers/Home/Home.js +27 -0
  74. package/templates/none-js/src/js/containers/Home/Home.scss +36 -0
  75. package/templates/none-js/src/js/routes/index.js +49 -0
  76. package/templates/none-js/src/js/stateManager/stateProvider.js +19 -0
  77. package/templates/none-js/src/js/store/index.js +6 -0
  78. package/templates/none-js/src/static/css/base/index.scss +3 -0
  79. package/templates/none-js/src/static/css/base/styles.scss +11 -0
  80. package/templates/none-js/src/static/css/base/typography.scss +53 -0
  81. package/templates/none-js/src/static/css/resources/_variables.scss +1 -0
  82. package/templates/none-js/src/static/fonts/.gitkeep +0 -0
  83. package/templates/none-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  84. package/templates/none-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  85. package/templates/none-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  86. package/templates/none-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  87. package/templates/none-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  88. package/templates/none-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  89. package/templates/none-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  90. package/templates/none-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  91. package/templates/none-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  92. package/templates/none-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  93. package/templates/none-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  94. package/templates/none-js/webpackConfig.js +5 -0
  95. package/templates/redux-js/.babelrc +26 -0
  96. package/templates/redux-js/.eslintignore +6 -0
  97. package/templates/redux-js/.eslintrc +53 -0
  98. package/templates/redux-js/.prettierrc.json +7 -0
  99. package/templates/redux-js/.stylelintrc +35 -0
  100. package/templates/redux-js/README.md +22 -0
  101. package/templates/redux-js/api.js +29 -0
  102. package/templates/redux-js/checkVersion.js +3 -0
  103. package/templates/redux-js/client/index.js +27 -0
  104. package/templates/redux-js/client/styles.js +15 -0
  105. package/templates/redux-js/config/config.json +15 -0
  106. package/templates/redux-js/config/config_template.json +18 -0
  107. package/templates/redux-js/config/index.js +44 -0
  108. package/templates/redux-js/package.json +53 -0
  109. package/templates/redux-js/server/document.js +14 -0
  110. package/templates/redux-js/server/index.js +3 -0
  111. package/templates/redux-js/server/server.js +16 -0
  112. package/templates/redux-js/src/js/containers/App/actions.js +20 -0
  113. package/templates/redux-js/src/js/containers/App/index.js +42 -0
  114. package/templates/redux-js/src/js/containers/App/reducer.js +21 -0
  115. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.js +39 -0
  116. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.scss +3 -0
  117. package/templates/redux-js/src/js/containers/Home/Home.js +27 -0
  118. package/templates/redux-js/src/js/containers/Home/Home.scss +36 -0
  119. package/templates/redux-js/src/js/reducer/index.js +80 -0
  120. package/templates/redux-js/src/js/routes/index.js +49 -0
  121. package/templates/redux-js/src/js/stateManager/stateProvider.js +34 -0
  122. package/templates/redux-js/src/js/store/index.js +79 -0
  123. package/templates/redux-js/src/static/css/base/index.scss +3 -0
  124. package/templates/redux-js/src/static/css/base/styles.scss +11 -0
  125. package/templates/redux-js/src/static/css/base/typography.scss +53 -0
  126. package/templates/redux-js/src/static/css/resources/_variables.scss +1 -0
  127. package/templates/redux-js/src/static/fonts/.gitkeep +0 -0
  128. package/templates/redux-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  129. package/templates/redux-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  130. package/templates/redux-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  131. package/templates/redux-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  132. package/templates/redux-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  133. package/templates/redux-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  134. package/templates/redux-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  135. package/templates/redux-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  136. package/templates/redux-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  137. package/templates/redux-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  138. package/templates/redux-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  139. package/templates/redux-js/webpackConfig.js +5 -0
  140. package/templates/rtk-js/.babelrc +26 -0
  141. package/templates/rtk-js/.eslintignore +6 -0
  142. package/templates/rtk-js/.eslintrc +53 -0
  143. package/templates/rtk-js/.prettierrc.json +7 -0
  144. package/templates/rtk-js/.stylelintrc +35 -0
  145. package/templates/rtk-js/README.md +23 -0
  146. package/templates/rtk-js/api.js +29 -0
  147. package/templates/rtk-js/checkVersion.js +3 -0
  148. package/templates/rtk-js/client/index.js +27 -0
  149. package/templates/rtk-js/client/styles.js +15 -0
  150. package/templates/rtk-js/config/config.json +15 -0
  151. package/templates/rtk-js/config/config_template.json +18 -0
  152. package/templates/rtk-js/config/index.js +44 -0
  153. package/templates/rtk-js/package.json +53 -0
  154. package/templates/rtk-js/server/document.js +14 -0
  155. package/templates/rtk-js/server/index.js +3 -0
  156. package/templates/rtk-js/server/server.js +16 -0
  157. package/templates/rtk-js/src/js/containers/App/index.js +42 -0
  158. package/templates/rtk-js/src/js/containers/App/reducer.js +26 -0
  159. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.js +39 -0
  160. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.scss +3 -0
  161. package/templates/rtk-js/src/js/containers/Home/Home.js +27 -0
  162. package/templates/rtk-js/src/js/containers/Home/Home.scss +36 -0
  163. package/templates/rtk-js/src/js/reducer/index.js +80 -0
  164. package/templates/rtk-js/src/js/routes/index.js +49 -0
  165. package/templates/rtk-js/src/js/stateManager/stateProvider.js +34 -0
  166. package/templates/rtk-js/src/js/store/index.js +22 -0
  167. package/templates/rtk-js/src/static/css/base/index.scss +3 -0
  168. package/templates/rtk-js/src/static/css/base/styles.scss +11 -0
  169. package/templates/rtk-js/src/static/css/base/typography.scss +53 -0
  170. package/templates/rtk-js/src/static/css/resources/_variables.scss +1 -0
  171. package/templates/rtk-js/src/static/fonts/.gitkeep +0 -0
  172. package/templates/rtk-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  173. package/templates/rtk-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  174. package/templates/rtk-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  175. package/templates/rtk-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  176. package/templates/rtk-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  177. package/templates/rtk-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  178. package/templates/rtk-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  179. package/templates/rtk-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  180. package/templates/rtk-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  181. package/templates/rtk-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  182. package/templates/rtk-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  183. package/templates/rtk-js/webpackConfig.js +5 -0
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "create-catalyst-app",
3
+ "bin": "scripts/cli.mjs",
4
+ "version": "0.0.1-beta.0",
5
+ "description": "cli package to scaffold Catalyst application",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "start": "node index.js"
9
+ },
10
+ "dependencies": {
11
+ "commander": "^8.2.0",
12
+ "fs": "^0.0.1-security",
13
+ "https": "^1.0.0",
14
+ "node-fetch": "^3.3.2",
15
+ "ora": "^8.0.1",
16
+ "picocolors": "^0.1.0",
17
+ "prompts": "^2.4.0",
18
+ "tar": "6.1.15"
19
+ }
20
+ }
package/readme.md ADDED
@@ -0,0 +1,53 @@
1
+
2
+ # Creating a Catalyst App
3
+
4
+ Scaffold your Catalyst app swiftly with `create-catalyst-app`. This tool expedites the process by initializing your project with predefined configurations. To kickstart your project, execute the following command:
5
+
6
+ ```bash
7
+ npx create-catalyst-app
8
+ ```
9
+
10
+ Upon execution, you'll be prompted to name your project. Once named, a template will be cloned into the specified directory.
11
+
12
+ ```bash
13
+ ✔ What is your project named? my-app
14
+ ```
15
+
16
+ Next, select your preferred state management tool from the provided options.
17
+
18
+ ```bash
19
+ ? Choose state management: › - Use arrow-keys. Return to submit .
20
+ ❯ Redux
21
+ Redux Toolkit (RTK)
22
+ None
23
+ ```
24
+
25
+ Following your selection, a default template will be cloned into the directory, and all necessary packages will be installed.
26
+
27
+ ## Getting Started
28
+ Commence development by initiating the application in development mode with the following commands:
29
+
30
+ Navigate into the directory
31
+
32
+ ```bash
33
+ cd my-app
34
+ ```
35
+ For running the application in development mode, run:
36
+ ```bash
37
+ npm run start
38
+ ```
39
+
40
+ For a production build, utilize:
41
+
42
+ ```bash
43
+ npm run build
44
+ ```
45
+
46
+ To serve the production build, execute:
47
+
48
+ ```bash
49
+ npm run serve
50
+ ```
51
+
52
+ ## Documentation
53
+ Explore the complete documentation at [https://catalyst.1mg.com](https://catalyst.1mg.com).
@@ -0,0 +1,267 @@
1
+ #!/usr/bin/env node
2
+ import { exec, execSync } from "child_process";
3
+ import Commander, { Option } from "commander";
4
+ import prompts from "prompts";
5
+ import { red, green, cyan, yellow } from "picocolors";
6
+ import ora from "ora";
7
+ import packageJson from "../package.json" assert { type: "json" };
8
+ import tar from "tar";
9
+ import path from "path";
10
+ import fs from "fs";
11
+
12
+
13
+
14
+ // Hardcoded branch
15
+ let projectName = null;
16
+ const program = new Commander.Command(packageJson.name)
17
+ .version(packageJson.version)
18
+ .description("Copy code from a specific branch of a GitHub repository.")
19
+ .arguments("[folderName]")
20
+ .usage(`${green("[folderName]")} [options]`)
21
+ .action((name) => (projectName = name))
22
+ // .addOption(
23
+ // new Option(
24
+ // "-l, --lang <lang>",
25
+ // "Specify the language (js or ts)",
26
+ // /^(js|ts)$/i
27
+ // )
28
+ // )
29
+ .addOption(
30
+ new Option(
31
+ "-s, --state-management [stateManagement]",
32
+ "Specify state management (rtk, redux, or none)",
33
+ /^(rtk|redux|none)$/i,
34
+ "none"
35
+ )
36
+ )
37
+ .action(async (folderName = null, cmd) => {
38
+ try {
39
+ // Use options provided through commander or prompt the user
40
+ validateOptions(cmd);
41
+ const projectName = folderName || (await promptProjectName());
42
+ const language = "js"
43
+ const stateManagement =
44
+ cmd.stateManagement || (await promptStateManagement());
45
+
46
+ const resolvedProjectPath = path.resolve(projectName.trim());
47
+ const projectPath = path.basename(resolvedProjectPath);
48
+ const root = path.resolve(projectPath);
49
+ console.log("project path is ====>", root);
50
+
51
+ // Define mapping of options to repository suffixes
52
+ const repositorySuffixes = {
53
+ js: "js",
54
+ ts: "ts",
55
+ redux: "redux",
56
+ rtk: "rtk",
57
+ none: "none",
58
+ };
59
+
60
+
61
+ const packageName = packageJson.name;
62
+ const packageVersion = packageJson.version;
63
+
64
+ const subdirectoryToExtract = `package/templates/${repositorySuffixes[stateManagement]}-${repositorySuffixes[language]}`;
65
+
66
+ const extractionDestination = `/${projectName}/`;
67
+ const spinner = ora(
68
+ `Cloning.....`
69
+ ).start();
70
+ (() => {
71
+ try {
72
+
73
+
74
+ const tempDir = createTempDir();
75
+
76
+ console.log(`\nPacking npm package: ${packageName}@${packageVersion}`);
77
+ const packageFilePath = packNpmPackage(
78
+ packageName,
79
+ packageVersion,
80
+ tempDir
81
+ );
82
+
83
+ console.log(cyan(`Extracting`));
84
+ extractSubdirectory(packageFilePath);
85
+ console.log(green(`Extraction Complete`));
86
+ console.log(cyan("generating npmrc"))
87
+ generateNPMRC(projectName)
88
+ console.log(cyan(`Installing Packages`));
89
+ execSync(
90
+ `cd ${projectName} && npm i`
91
+ ,{stdio:"inherit"})
92
+ spinner.stop()
93
+
94
+ // Optionally, you can delete the temporary directory
95
+ // fs.rmdirSync(tempDir, { recursive: true });
96
+ deleteDirectory(tempDir)
97
+ } catch (error) {
98
+ spinner.stop()
99
+ console.error(`Error: ${error.message}`);
100
+ process.exit(1);
101
+ }
102
+ })();
103
+
104
+
105
+ function packNpmPackage (packageName, packageVersion, tempDir) {
106
+ const tarballFileName = `${packageName
107
+ .substring(1)
108
+ .replace("/", "-")}-${packageVersion}.tgz`;
109
+ const tarballFilePath = path.join(tempDir, tarballFileName);
110
+
111
+ try {
112
+ execSync(`npm pack ${packageName}@${packageVersion} --silent`, {
113
+ cwd: tempDir,
114
+ })
115
+
116
+ return tarballFilePath;
117
+ } catch (error) {
118
+ console.error(`Error packing npm package: ${error.message}`);
119
+ throw error;
120
+ }
121
+ }
122
+
123
+ // Function to create a temporary directory
124
+ function createTempDir() {
125
+ const tempDir = fs.mkdtempSync(path.join(process.cwd(), "temp-"));
126
+ return tempDir;
127
+ }
128
+
129
+ // Function to extract subdirectory from npm package and delete tar file
130
+ function extractSubdirectory(packageFilePath) {
131
+ tar.extract({
132
+ file: packageFilePath,
133
+ sync: true,
134
+ filter: (path, entry) => {
135
+ return path.startsWith(`${subdirectoryToExtract}/`);
136
+ },
137
+ cwd: path.join(process.cwd()),
138
+ onentry: (entry) => {
139
+ // Modify entry path to remove the initial 'package/' prefix
140
+ entry.path = entry.path.replace(
141
+ `${subdirectoryToExtract}/`,
142
+ extractionDestination
143
+ );
144
+ },
145
+ });
146
+
147
+
148
+
149
+ if (stateManagement !== "none") {
150
+ console.log(
151
+ cyan(
152
+ `You chose ${language}, ${stateManagement}. You can now start working on your project!`
153
+ )
154
+ );
155
+ } else {
156
+ console.log(
157
+ cyan(
158
+ `You chose ${language} without state management. You can now start working on your project!`
159
+ )
160
+ );
161
+ }
162
+
163
+
164
+
165
+ }
166
+ } catch (error) {
167
+
168
+ console.error(red("An error occurred:"), error.message);
169
+ process.exit(1);
170
+ }
171
+ })
172
+ .allowUnknownOption();
173
+
174
+ program.parse(process.argv);
175
+
176
+ async function promptLanguage() {
177
+ const response = await prompts({
178
+ type: "select",
179
+ name: "lang",
180
+ message: "Choose the language:",
181
+ choices: [
182
+ { title: "js", value: "js" },
183
+ { title: "ts", value: "ts" },
184
+ ],
185
+ });
186
+
187
+ return response.lang;
188
+ }
189
+
190
+ async function promptStateManagement() {
191
+ const response = await prompts({
192
+ type: "select",
193
+ name: "stateManagement",
194
+ message: "Choose state management:",
195
+ choices: [
196
+ { title: "Redux", value: "redux" },
197
+ { title: "Redux Toolkit (RTK)", value: "rtk" },
198
+ { title: "None", value: "none" },
199
+ ],
200
+ });
201
+
202
+ return response.stateManagement;
203
+ }
204
+ async function promptProjectName() {
205
+ const res = await prompts({
206
+ type: "text",
207
+ name: "path",
208
+ message: "What is your project named?",
209
+ initial: "my-app",
210
+ });
211
+
212
+ if (typeof res.path === "string") {
213
+ projectName = res.path.trim();
214
+ return res.path;
215
+ }
216
+
217
+ if (!res.path || projectName === "") {
218
+ console.log(
219
+ "\nPlease specify the project directory:\n" +
220
+ ` ${cyan(program.name())} ${green("<project-directory>")}\n` +
221
+ "For example:\n" +
222
+ ` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
223
+ `Run ${cyan(`${program.name()} --help`)} to see all options.`
224
+ );
225
+ process.exit(1);
226
+ }
227
+ }
228
+
229
+ function validateOptions(cmd) {
230
+ // Validate language option
231
+ if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
232
+ throw new Error('Invalid language option. Use "js" or "ts".');
233
+ }
234
+
235
+ // Validate state management option
236
+ if (
237
+ cmd.stateManagement &&
238
+ !["rtk", "redux", "none"].includes(cmd.stateManagement.toLowerCase())
239
+ ) {
240
+ throw new Error(
241
+ 'Invalid state management option. Use "rtk", "redux", or "none".'
242
+ );
243
+ }
244
+ }
245
+
246
+ function deleteDirectory(dirPath) {
247
+ if (fs.existsSync(dirPath)) {
248
+ fs.readdirSync(dirPath).forEach((file) => {
249
+ const currentPath = path.join(dirPath, file);
250
+ if (fs.lstatSync(currentPath).isDirectory()) {
251
+ deleteDirectory(currentPath);
252
+ } else {
253
+ fs.unlinkSync(currentPath);
254
+ }
255
+ });
256
+ fs.rmdirSync(dirPath);
257
+ }
258
+ }
259
+
260
+ function generateNPMRC (projectName) {
261
+
262
+
263
+ const npmrcContent = "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
264
+
265
+ fs.writeFileSync(process.cwd()+`/${projectName}/.npmrc`,npmrcContent);
266
+
267
+ }
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 4
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
@@ -0,0 +1,6 @@
1
+ **/node_modules/*
2
+ **/dist/*
3
+ **/build/*
4
+ **/coverage/*
5
+ **/eventScripts/*
6
+ **/docs/*
@@ -0,0 +1,53 @@
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", "plugin:prettier/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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "trailingComma": "es5",
3
+ "tabWidth": 4,
4
+ "semi": false,
5
+ "arrowParens": "always",
6
+ "printWidth": 110
7
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "extends": [
3
+ "stylelint-config-standard-scss",
4
+ "stylelint-config-prettier-scss",
5
+ "stylelint-config-css-modules"
6
+ ],
7
+ "plugins": ["stylelint-prettier"],
8
+ "rules": {
9
+ "property-no-vendor-prefix":null,
10
+ "scss/function-no-unknown": null,
11
+ "selector-class-pattern": null,
12
+ "prettier/prettier": true,
13
+ "color-no-invalid-hex": true,
14
+ "comment-empty-line-before": ["always", { "ignore": ["stylelint-commands", "after-comment"] }],
15
+ "indentation": 4,
16
+ "number-leading-zero": null,
17
+ "max-empty-lines": 2,
18
+ "declaration-no-important": true,
19
+ "block-no-empty": true,
20
+ "no-empty-source": null,
21
+ "selector-pseudo-class-no-unknown": null,
22
+ "selector-type-no-unknown": null,
23
+ "rule-empty-line-before": ["always", { "except": ["first-nested"], "ignore": ["after-comment"] }],
24
+ "declaration-property-unit-allowed-list": {
25
+ "/.*/": ["em", "rem", "%", "s", "vh", "vw", "px", "deg", "ms", "dpi", "dvh", "fr"]
26
+ },
27
+ "at-rule-no-unknown": null,
28
+ "scss/double-slash-comment-whitespace-inside": null,
29
+ "scss/at-mixin-pattern": null,
30
+ "scss/dollar-variable-pattern": null,
31
+ "selector-id-pattern": null,
32
+ "keyframes-name-pattern": null,
33
+ "selector-pseudo-element-no-unknown": null
34
+ }
35
+ }
@@ -0,0 +1,29 @@
1
+ # README #
2
+
3
+ This README would normally document whatever steps are necessary to get your application up and running.
4
+
5
+ ### What is this repository for? ###
6
+
7
+ * Quick summary
8
+ * Version
9
+ * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
+
11
+ ### How do I get set up? ###
12
+
13
+ * Summary of set up
14
+ * Configuration
15
+ * Dependencies
16
+ * Database configuration
17
+ * How to run tests
18
+ * Deployment instructions
19
+
20
+ ### Contribution guidelines ###
21
+
22
+ * Writing tests
23
+ * Code review
24
+ * Other guidelines
25
+
26
+ ### Who do I talk to? ###
27
+
28
+ * Repo owner or admin
29
+ * Other community or team contact
@@ -0,0 +1,29 @@
1
+ const apiInstance = () => {
2
+ const fetchFunction = async (url, options) => {
3
+ let baseURL = process.env.API_URL
4
+ let finalUrl = baseURL + url
5
+
6
+ // Request Interceptor - you can modify request here
7
+
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
18
+ return parsedResponse
19
+ });
20
+ }
21
+ return {
22
+ get: fetchFunction,
23
+ post: fetchFunction,
24
+ delete: fetchFunction,
25
+ patch: fetchFunction,
26
+ put: fetchFunction
27
+ }
28
+ }
29
+ export default { apiInstance }
@@ -0,0 +1,3 @@
1
+ if(process.versions.node.split(".")[0]<20){
2
+ console.error('\x1b[31m%s\x1b[0m', 'use node version >=20');
3
+ }
@@ -0,0 +1,39 @@
1
+ import React from "react"
2
+ // import "./styles"
3
+ import { hydrateRoot } from "react-dom/client"
4
+ import { loadableReady } from "@loadable/component"
5
+ import {createBrowserRouter,RouterProvider } from "@tata1mg/router"
6
+ import {ClientProvider} from "../src/js/stateManager/stateProvider.js"
7
+ import { preparedRoutes } from "../src/js/routes/index.js"
8
+ import configureStore from "../src/js/store/index.js"
9
+ window.addEventListener("load", () => {
10
+ loadableReady(() => {
11
+
12
+
13
+ // Hydrate the redux store from server state.
14
+ // visitor id is sent with ga track events but we observed multiple cases where visitor id was not being passed. It could be due to the case that maybe cookie is not accessible in some cases. Hence, setting it here as a fallback in case gtmUtility.js is not able to get it any other way.
15
+ // window.visitorId = store.getState()?.shellReducer?.visitorId
16
+ // const platform = store.getState()?.shellReducer?.webviewPlatform
17
+ // const store = {}
18
+
19
+
20
+ const {__ROUTER_INITIAL_DATA__:routerInitialData,__INITIAL_STATE__ } = window
21
+ // console.log("router initila data is ====>",routerInitialData)
22
+ const store = configureStore(__INITIAL_STATE__||{})
23
+ const router = createBrowserRouter(
24
+ preparedRoutes({ store, routerInitialState:(routerInitialData) })
25
+ )
26
+
27
+ const Application = (
28
+ <ClientProvider>
29
+ <React.StrictMode>
30
+ <RouterProvider router={router}/>
31
+ </React.StrictMode>
32
+ </ClientProvider>
33
+ )
34
+ // localStorage.setItem("isWebview", window.__INITIAL_STATE__?.shellReducer?.isWebview)
35
+
36
+ const container = document.getElementById("app")
37
+ hydrateRoot(container, Application)
38
+ })
39
+ })
@@ -0,0 +1,15 @@
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
+ */
12
+
13
+ // Include initial base styles.
14
+ import "normalize.css"
15
+ import "@css/base/index.scss"
@@ -0,0 +1,18 @@
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": ""
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "S3_BUCKET": "",
3
+ "S3_FOLDER": "",
4
+ "CDN_ASSET_PATH": "",
5
+ "APPLICATION_PORT": "",
6
+ "APPLICATION_BASE_URL": "",
7
+ "SERVER_PATH": "",
8
+ "OUTPUT_PATH": "",
9
+ "PUBLIC_OUTPUT_PATH": "",
10
+ "PUBLIC_ASSET_PATH": "",
11
+ "LOCAL_ASSET_PATH": "",
12
+ "EXTERNAL_BASE_URL": "",
13
+ "DEV_SERVER_PORT": 0,
14
+ "DEV_SERVER_HOSTNAME": "",
15
+ "DEV_SERVER_HOST_URL": "",
16
+ "ENV_NAME": "",
17
+ "BUILD_ENV": ""
18
+ }