create-catalyst-app 0.0.1-beta.2 → 0.0.1-beta.3
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.
- package/{readme.md → Readme.md} +2 -3
- package/license +10 -0
- package/package.json +20 -18
- package/scripts/cli.cjs +242 -0
- package/templates/common/.babelrc +11 -11
- package/templates/common/README.md +16 -20
- package/templates/common/api.js +9 -11
- package/templates/common/client/styles.js +1 -13
- package/templates/common/config/config.json +13 -16
- package/templates/common/public/favicon.ico +0 -0
- package/templates/{none-js → common}/server/document.js +1 -2
- package/templates/common/server/index.js +2 -0
- package/templates/common/server/server.js +8 -0
- package/templates/common/src/js/containers/Home/Home.js +23 -40
- package/templates/common/src/js/containers/Home/Home.scss +34 -0
- package/templates/common/src/js/routes/index.js +9 -42
- package/templates/common/src/static/css/base/index.scss +0 -7
- package/templates/common/src/static/css/base/styles.scss +0 -160
- package/templates/common/src/static/css/resources/_variables.scss +0 -172
- package/{my-app → templates/common}/webpackConfig.js +2 -2
- package/templates/none-js/client/index.js +9 -13
- package/templates/none-js/package.json +6 -36
- package/templates/none-js/src/js/containers/App/index.js +12 -36
- package/templates/none-js/src/js/routes/utils.js +28 -0
- package/templates/redux-js/client/index.js +6 -5
- package/templates/redux-js/package.json +9 -36
- package/templates/redux-js/src/js/containers/App/actions.js +1 -4
- package/templates/redux-js/src/js/containers/App/index.js +12 -38
- package/templates/redux-js/src/js/containers/App/reducer.js +15 -16
- package/templates/redux-js/src/js/routes/utils.js +28 -0
- package/templates/redux-js/src/js/store/index.js +17 -68
- package/templates/rtk-js/client/index.js +6 -5
- package/templates/rtk-js/package.json +9 -36
- package/templates/rtk-js/src/js/containers/App/index.js +12 -38
- package/templates/rtk-js/src/js/containers/App/reducer.js +1 -9
- package/templates/rtk-js/src/js/routes/utils.js +28 -0
- package/templates/rtk-js/src/js/store/index.js +12 -6
- package/my-app/.babelrc +0 -26
- package/my-app/.eslintignore +0 -6
- package/my-app/.eslintrc +0 -53
- package/my-app/.stylelintrc +0 -35
- package/my-app/README.md +0 -23
- package/my-app/api.js +0 -29
- package/my-app/checkVersion.js +0 -3
- package/my-app/client/index.js +0 -27
- package/my-app/client/styles.js +0 -14
- package/my-app/config/config.json +0 -15
- package/my-app/config/config_template.json +0 -18
- package/my-app/config/index.js +0 -44
- package/my-app/package.json +0 -28
- package/my-app/server/document.js +0 -14
- package/my-app/server/index.js +0 -3
- package/my-app/server/server.js +0 -3
- package/my-app/src/js/containers/App/actions.js +0 -20
- package/my-app/src/js/containers/App/index.js +0 -16
- package/my-app/src/js/containers/App/reducer.js +0 -26
- package/my-app/src/js/containers/DemoPage/DemoPage.js +0 -39
- package/my-app/src/js/containers/DemoPage/DemoPage.scss +0 -3
- package/my-app/src/js/containers/Home/Home.js +0 -25
- package/my-app/src/js/containers/Home/Home.scss +0 -36
- package/my-app/src/js/reducer/index.js +0 -80
- package/my-app/src/js/routes/index.js +0 -43
- package/my-app/src/js/stateManager/stateProvider.js +0 -34
- package/my-app/src/js/store/index.js +0 -22
- package/my-app/src/static/css/base/index.scss +0 -2
- package/my-app/src/static/css/base/styles.scss +0 -3
- package/my-app/src/static/css/base/typography.scss +0 -53
- package/my-app/src/static/css/resources/_variables.scss +0 -0
- package/my-app/src/static/fonts/.gitkeep +0 -0
- package/my-app/src/static/fonts/Inter-Bold-Subset.otf +0 -0
- package/my-app/src/static/fonts/Inter-Italic-Subset.otf +0 -0
- package/my-app/src/static/fonts/Inter-Light-Subset.otf +0 -0
- package/my-app/src/static/fonts/Inter-Medium-Subset.otf +0 -0
- package/my-app/src/static/fonts/Inter-Regular-Subset.otf +0 -0
- package/my-app/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
- package/my-app/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
- package/my-app/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
- package/my-app/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
- package/my-app/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
- package/my-app/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
- package/scripts/cli.mjs +0 -266
- package/templates/common/.editorconfig +0 -12
- package/templates/common/.eslintignore +0 -6
- package/templates/common/.eslintrc +0 -53
- package/templates/common/.prettierrc.json +0 -7
- package/templates/common/.stylelintrc +0 -35
- package/templates/common/checkVersion.js +0 -3
- package/templates/common/client/index.js +0 -39
- package/templates/common/config/config_template.json +0 -18
- package/templates/common/config/index.js +0 -77
- package/templates/common/package.json +0 -56
- package/templates/common/server/CustomDocument.js +0 -14
- package/templates/common/server/customIndex.js +0 -3
- package/templates/common/server/customServer.js +0 -16
- package/templates/common/src/js/containers/App/actions.js +0 -20
- package/templates/common/src/js/containers/App/index.js +0 -46
- package/templates/common/src/js/containers/App/reducer.js +0 -21
- package/templates/common/src/js/containers/PDP/PDP.js +0 -37
- package/templates/common/src/js/reducer/index.js +0 -80
- package/templates/common/src/js/stateManager/stateProvider.js +0 -34
- package/templates/common/src/js/store/index.js +0 -77
- package/templates/common/src/static/css/base/_overrides.scss +0 -81
- package/templates/common/src/static/css/base/animations.js +0 -38
- package/templates/common/src/static/css/base/layout.scss +0 -242
- package/templates/common/src/static/css/base/typography.scss +0 -285
- package/templates/common/src/static/css/resources/_mixins.scss +0 -196
- package/templates/common/src/static/css/resources/_vendors.scss +0 -1
- package/templates/common/src/static/fonts/.gitkeep +0 -0
- package/templates/common/src/static/fonts/Inter-Bold-Subset.otf +0 -0
- package/templates/common/src/static/fonts/Inter-Italic-Subset.otf +0 -0
- package/templates/common/src/static/fonts/Inter-Light-Subset.otf +0 -0
- package/templates/common/src/static/fonts/Inter-Medium-Subset.otf +0 -0
- package/templates/common/src/static/fonts/Inter-Regular-Subset.otf +0 -0
- package/templates/common/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
- package/templates/common/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
- package/templates/common/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
- package/templates/common/src/static/fonts/Poppins-Light-Subset.woff2 +0 -0
- package/templates/common/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
- package/templates/common/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
- package/templates/common/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
- package/templates/none-js/.babelrc +0 -26
- package/templates/none-js/.eslintignore +0 -6
- package/templates/none-js/.eslintrc +0 -53
- package/templates/none-js/.prettierrc.json +0 -7
- package/templates/none-js/.stylelintrc +0 -35
- package/templates/none-js/README.md +0 -22
- package/templates/none-js/api.js +0 -29
- package/templates/none-js/checkVersion.js +0 -3
- package/templates/none-js/client/styles.js +0 -15
- package/templates/none-js/config/config.json +0 -15
- package/templates/none-js/config/config_template.json +0 -18
- package/templates/none-js/config/index.js +0 -44
- package/templates/none-js/server/index.js +0 -3
- package/templates/none-js/server/server.js +0 -16
- package/templates/none-js/src/js/containers/DemoPage/DemoPage.js +0 -39
- package/templates/none-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
- package/templates/none-js/src/js/containers/Home/Home.js +0 -27
- package/templates/none-js/src/js/containers/Home/Home.scss +0 -36
- package/templates/none-js/src/js/routes/index.js +0 -49
- package/templates/none-js/src/js/stateManager/stateProvider.js +0 -19
- package/templates/none-js/src/js/store/index.js +0 -6
- package/templates/none-js/src/static/css/base/index.scss +0 -3
- package/templates/none-js/src/static/css/base/styles.scss +0 -11
- package/templates/none-js/src/static/css/base/typography.scss +0 -53
- package/templates/none-js/src/static/css/resources/_variables.scss +0 -1
- package/templates/none-js/src/static/fonts/.gitkeep +0 -0
- package/templates/none-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
- package/templates/none-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
- package/templates/none-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
- package/templates/none-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
- package/templates/none-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
- package/templates/none-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
- package/templates/none-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
- package/templates/none-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
- package/templates/none-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
- package/templates/none-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
- package/templates/none-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
- package/templates/none-js/webpackConfig.js +0 -5
- package/templates/redux-js/.babelrc +0 -26
- package/templates/redux-js/.eslintignore +0 -6
- package/templates/redux-js/.eslintrc +0 -53
- package/templates/redux-js/.prettierrc.json +0 -7
- package/templates/redux-js/.stylelintrc +0 -35
- package/templates/redux-js/README.md +0 -22
- package/templates/redux-js/api.js +0 -29
- package/templates/redux-js/checkVersion.js +0 -3
- package/templates/redux-js/client/styles.js +0 -15
- package/templates/redux-js/config/config.json +0 -15
- package/templates/redux-js/config/config_template.json +0 -18
- package/templates/redux-js/config/index.js +0 -44
- package/templates/redux-js/server/document.js +0 -14
- package/templates/redux-js/server/index.js +0 -3
- package/templates/redux-js/server/server.js +0 -16
- package/templates/redux-js/src/js/containers/DemoPage/DemoPage.js +0 -39
- package/templates/redux-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
- package/templates/redux-js/src/js/containers/Home/Home.js +0 -27
- package/templates/redux-js/src/js/containers/Home/Home.scss +0 -36
- package/templates/redux-js/src/js/reducer/index.js +0 -80
- package/templates/redux-js/src/js/routes/index.js +0 -49
- package/templates/redux-js/src/js/stateManager/stateProvider.js +0 -34
- package/templates/redux-js/src/static/css/base/index.scss +0 -3
- package/templates/redux-js/src/static/css/base/styles.scss +0 -11
- package/templates/redux-js/src/static/css/base/typography.scss +0 -53
- package/templates/redux-js/src/static/css/resources/_variables.scss +0 -1
- package/templates/redux-js/src/static/fonts/.gitkeep +0 -0
- package/templates/redux-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
- package/templates/redux-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
- package/templates/redux-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
- package/templates/redux-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
- package/templates/redux-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
- package/templates/redux-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
- package/templates/redux-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
- package/templates/redux-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
- package/templates/redux-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
- package/templates/redux-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
- package/templates/redux-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
- package/templates/redux-js/webpackConfig.js +0 -5
- package/templates/rtk-js/.babelrc +0 -26
- package/templates/rtk-js/.eslintignore +0 -6
- package/templates/rtk-js/.eslintrc +0 -53
- package/templates/rtk-js/.prettierrc.json +0 -7
- package/templates/rtk-js/.stylelintrc +0 -35
- package/templates/rtk-js/README.md +0 -23
- package/templates/rtk-js/api.js +0 -29
- package/templates/rtk-js/checkVersion.js +0 -3
- package/templates/rtk-js/client/styles.js +0 -15
- package/templates/rtk-js/config/config.json +0 -15
- package/templates/rtk-js/config/config_template.json +0 -18
- package/templates/rtk-js/config/index.js +0 -44
- package/templates/rtk-js/server/document.js +0 -14
- package/templates/rtk-js/server/index.js +0 -3
- package/templates/rtk-js/server/server.js +0 -16
- package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.js +0 -39
- package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.scss +0 -3
- package/templates/rtk-js/src/js/containers/Home/Home.js +0 -27
- package/templates/rtk-js/src/js/containers/Home/Home.scss +0 -36
- package/templates/rtk-js/src/js/reducer/index.js +0 -80
- package/templates/rtk-js/src/js/routes/index.js +0 -49
- package/templates/rtk-js/src/js/stateManager/stateProvider.js +0 -34
- package/templates/rtk-js/src/static/css/base/index.scss +0 -3
- package/templates/rtk-js/src/static/css/base/styles.scss +0 -11
- package/templates/rtk-js/src/static/css/base/typography.scss +0 -53
- package/templates/rtk-js/src/static/css/resources/_variables.scss +0 -1
- package/templates/rtk-js/src/static/fonts/.gitkeep +0 -0
- package/templates/rtk-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
- package/templates/rtk-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
- package/templates/rtk-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
- package/templates/rtk-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
- package/templates/rtk-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
- package/templates/rtk-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
- package/templates/rtk-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
- package/templates/rtk-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
- package/templates/rtk-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
- package/templates/rtk-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
- package/templates/rtk-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
- package/templates/rtk-js/webpackConfig.js +0 -5
- /package/{my-app/.prettierrc.json → .prettierrc.json} +0 -0
package/{readme.md → Readme.md}
RENAMED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
# Creating a Catalyst App
|
|
3
2
|
|
|
4
3
|
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
4
|
|
|
6
5
|
```bash
|
|
7
|
-
npx create-catalyst-app
|
|
6
|
+
npx create-catalyst-app@latest
|
|
8
7
|
```
|
|
9
8
|
|
|
10
9
|
Upon execution, you'll be prompted to name your project. Once named, a template will be cloned into the specified directory.
|
|
@@ -37,7 +36,7 @@ For running the application in development mode, run:
|
|
|
37
36
|
npm run start
|
|
38
37
|
```
|
|
39
38
|
|
|
40
|
-
For a production build,
|
|
39
|
+
For a production build, change NODE_ENV to "production" in config/config.json, and then run :
|
|
41
40
|
|
|
42
41
|
```bash
|
|
43
42
|
npm run build
|
package/license
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 1mg Healthcare Solutions Private Limited.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
|
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
2
|
+
"name": "create-catalyst-app",
|
|
3
|
+
"bin": "scripts/cli.cjs",
|
|
4
|
+
"version": "0.0.1-beta.3",
|
|
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
|
+
"picocolors": "^0.1.0",
|
|
15
|
+
"prompts": "^2.4.0",
|
|
16
|
+
"tar": "6.1.15"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"prettier": "^3.2.5"
|
|
20
|
+
},
|
|
21
|
+
"license":"MIT"
|
|
20
22
|
}
|
package/scripts/cli.cjs
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
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 } = require("picocolors")
|
|
7
|
+
|
|
8
|
+
const packageJson = require("../package.json")
|
|
9
|
+
const tar = require("tar")
|
|
10
|
+
const path = require("path")
|
|
11
|
+
const fs = require("fs")
|
|
12
|
+
|
|
13
|
+
// Hardcoded branch
|
|
14
|
+
let projectName = null
|
|
15
|
+
const program = new Commander.Command()
|
|
16
|
+
.version(packageJson.version)
|
|
17
|
+
.description("Scaffolding")
|
|
18
|
+
.arguments("[folderName]")
|
|
19
|
+
.usage(`${green("[folderName]")} [options]`)
|
|
20
|
+
.action((name) => (projectName = name))
|
|
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
|
+
// Use options provided through commander or prompt the user
|
|
32
|
+
validateOptions(cmd)
|
|
33
|
+
const projectName = folderName || (await promptProjectName())
|
|
34
|
+
const language = "js"
|
|
35
|
+
const projectDescription = await promptDescription()
|
|
36
|
+
const stateManagement = cmd.stateManagement || (await promptStateManagement())
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// Define mapping of options to repository suffixes
|
|
40
|
+
const repositorySuffixes = {
|
|
41
|
+
js: "js",
|
|
42
|
+
ts: "ts",
|
|
43
|
+
redux: "redux",
|
|
44
|
+
rtk: "rtk",
|
|
45
|
+
none: "none",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const packageName = packageJson.name
|
|
49
|
+
const packageVersion = packageJson.version
|
|
50
|
+
|
|
51
|
+
const commonCodeDirectory = "package/templates/common"
|
|
52
|
+
const selectedTemplateCode = `package/templates/${repositorySuffixes[stateManagement]}-${repositorySuffixes[language]}`
|
|
53
|
+
const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
|
|
54
|
+
const extractionDestination = `/${projectName}/`
|
|
55
|
+
let tempDir
|
|
56
|
+
; (() => {
|
|
57
|
+
try {
|
|
58
|
+
let projectPath = path.join(process.cwd(), projectName);
|
|
59
|
+
|
|
60
|
+
if(fs.existsSync(projectPath)){
|
|
61
|
+
console.log(`${projectName} already exists, try again.`)
|
|
62
|
+
process.exit(1)
|
|
63
|
+
}
|
|
64
|
+
tempDir = createTempDir()
|
|
65
|
+
|
|
66
|
+
const packageFilePath = packNpmPackage(packageName, packageVersion, tempDir)
|
|
67
|
+
|
|
68
|
+
extractSubdirectory(packageFilePath)
|
|
69
|
+
createGitignore(projectName)
|
|
70
|
+
|
|
71
|
+
execSync(
|
|
72
|
+
`cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet`,
|
|
73
|
+
{ stdio: "inherit" }
|
|
74
|
+
)
|
|
75
|
+
deleteDirectory(tempDir)
|
|
76
|
+
} catch (error) {
|
|
77
|
+
deleteDirectory(tempDir)
|
|
78
|
+
console.error(`Error: ${error.message}`)
|
|
79
|
+
process.exit(1)
|
|
80
|
+
}
|
|
81
|
+
})()
|
|
82
|
+
|
|
83
|
+
function packNpmPackage(packageName, packageVersion, tempDir) {
|
|
84
|
+
const tarballFileName = `${packageName}-${packageVersion}.tgz`
|
|
85
|
+
const tarballFilePath = path.join(tempDir, tarballFileName)
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
execSync(`npm pack ${packageName}@${packageVersion} --silent`, {
|
|
89
|
+
cwd: tempDir,
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// to test locally, comment the upper execSync and uncomment this one.
|
|
93
|
+
// execSync(`npm pack --pack-destination=${tempDir} --silent`, {
|
|
94
|
+
// cwd: process.cwd(),
|
|
95
|
+
// });
|
|
96
|
+
|
|
97
|
+
return tarballFilePath
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error(`Error packing npm package: ${error.message}`)
|
|
100
|
+
throw error
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Function to create a temporary directory
|
|
105
|
+
function createTempDir() {
|
|
106
|
+
const tempDir = fs.mkdtempSync(path.join(process.cwd(), "temp-"))
|
|
107
|
+
|
|
108
|
+
return tempDir
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Function to extract subdirectory from npm package and delete tar file
|
|
112
|
+
function extractSubdirectory(packageFilePath) {
|
|
113
|
+
try {
|
|
114
|
+
tar.extract({
|
|
115
|
+
file: packageFilePath,
|
|
116
|
+
sync: true,
|
|
117
|
+
filter: (path, entry) => {
|
|
118
|
+
return subDirectoriesToExtract.reduce((acc, item) => {
|
|
119
|
+
return acc || path.startsWith(item)
|
|
120
|
+
}, false)
|
|
121
|
+
},
|
|
122
|
+
cwd: path.join(process.cwd()),
|
|
123
|
+
onentry: (entry) => {
|
|
124
|
+
if (entry.path.startsWith(commonCodeDirectory)) {
|
|
125
|
+
entry.path = entry.path.replace(commonCodeDirectory, extractionDestination)
|
|
126
|
+
}
|
|
127
|
+
if (entry.path.startsWith(selectedTemplateCode)) {
|
|
128
|
+
entry.path = entry.path.replace(selectedTemplateCode, extractionDestination)
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
})
|
|
132
|
+
} catch (e) {
|
|
133
|
+
console.log("An error occurred", e)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
cyan(`Run cd ${projectName} && npm start to get started.`)
|
|
137
|
+
}
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error(red("An error occurred:"), error.message)
|
|
140
|
+
process.exit(1)
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
.allowUnknownOption()
|
|
144
|
+
|
|
145
|
+
program.parse(process.argv)
|
|
146
|
+
|
|
147
|
+
async function promptStateManagement() {
|
|
148
|
+
const response = await prompts({
|
|
149
|
+
type: "select",
|
|
150
|
+
name: "stateManagement",
|
|
151
|
+
message: "Choose state management:",
|
|
152
|
+
choices: [
|
|
153
|
+
{ title: "Redux", value: "redux" },
|
|
154
|
+
{ title: "Redux Toolkit (RTK)", value: "rtk" },
|
|
155
|
+
{ title: "None", value: "none" },
|
|
156
|
+
],
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
return response.stateManagement
|
|
160
|
+
}
|
|
161
|
+
async function promptProjectName() {
|
|
162
|
+
const res = await prompts({
|
|
163
|
+
type: "text",
|
|
164
|
+
name: "path",
|
|
165
|
+
message: "What is your project named?",
|
|
166
|
+
initial: "my-app",
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
if (typeof res.path === "string") {
|
|
170
|
+
let projectName = res.path.trim()
|
|
171
|
+
return projectName
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!res.path || projectName === "") {
|
|
175
|
+
console.log(
|
|
176
|
+
"\nPlease specify the project directory:\n" +
|
|
177
|
+
` ${cyan(program.name())} ${green("<project-directory>")}\n` +
|
|
178
|
+
"For example:\n" +
|
|
179
|
+
` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
|
|
180
|
+
`Run ${cyan(`${program.name()} --help`)} to see all options.`
|
|
181
|
+
)
|
|
182
|
+
process.exit(1)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function promptDescription() {
|
|
187
|
+
const res = await prompts({
|
|
188
|
+
type: "text",
|
|
189
|
+
name: "path",
|
|
190
|
+
message: "What is your project description?",
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
if (typeof res.path === "string") {
|
|
194
|
+
return res.path.trim()
|
|
195
|
+
} else return null
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function validateOptions(cmd) {
|
|
199
|
+
// Validate language option
|
|
200
|
+
if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
|
|
201
|
+
throw new Error('Invalid language option. Use "js" or "ts".')
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Validate state management option
|
|
205
|
+
if (cmd.stateManagement && !["rtk", "redux", "none"].includes(cmd.stateManagement.toLowerCase())) {
|
|
206
|
+
throw new Error('Invalid state management option. Use "rtk", "redux", or "none".')
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function deleteDirectory(dirPath) {
|
|
211
|
+
if (dirPath && fs.existsSync(dirPath)) {
|
|
212
|
+
fs.readdirSync(dirPath).forEach((file) => {
|
|
213
|
+
const currentPath = path.join(dirPath, file)
|
|
214
|
+
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
215
|
+
deleteDirectory(currentPath)
|
|
216
|
+
} else {
|
|
217
|
+
fs.unlinkSync(currentPath)
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
fs.rmdirSync(dirPath)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Function to create a .gitignore file with the hardcoded patterns
|
|
225
|
+
function createGitignore(projectName) {
|
|
226
|
+
|
|
227
|
+
const gitiIgnorePatterns = [
|
|
228
|
+
'node_modules',
|
|
229
|
+
'build',
|
|
230
|
+
'logs'
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
const gitignorePath = path.join(process.cwd(), projectName, '.gitignore');
|
|
234
|
+
|
|
235
|
+
if (fs.existsSync(gitignorePath)) {
|
|
236
|
+
console.log('.gitignore already exists. Please rename or remove it before running the script.');
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
fs.writeFileSync(gitignorePath, gitiIgnorePatterns.join('\n'));
|
|
241
|
+
}
|
|
242
|
+
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
2
|
+
"presets": [
|
|
3
3
|
[
|
|
4
4
|
"@babel/preset-env",
|
|
5
5
|
{
|
|
6
6
|
"targets": {
|
|
7
7
|
"node": "current"
|
|
8
|
-
}
|
|
9
|
-
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
10
|
],
|
|
11
11
|
"@babel/preset-react"
|
|
12
12
|
],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
20
|
"env": {
|
|
21
21
|
"test": {
|
|
22
22
|
"presets": ["@babel/preset-react"]
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
"ignore": ["__TEST__"]
|
|
26
26
|
}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
## Getting Started
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Commence development by initiating the the following commands:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
For running the application in development mode, run:
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm run start
|
|
9
|
+
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
For a production build, change NODE_ENV to "production" in config/config.json, then run :
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
13
|
+
```bash
|
|
14
|
+
npm run build
|
|
15
|
+
```
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
To serve the production build, execute:
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
```bash
|
|
20
|
+
npm run serve
|
|
21
|
+
```
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
## Documentation
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
* Other community or team contact
|
|
25
|
+
Explore the complete documentation at [https://catalyst.1mg.com](https://catalyst.1mg.com).
|
package/templates/common/api.js
CHANGED
|
@@ -3,27 +3,25 @@ const apiInstance = () => {
|
|
|
3
3
|
let baseURL = process.env.API_URL
|
|
4
4
|
let finalUrl = baseURL + url
|
|
5
5
|
|
|
6
|
-
// Request Interceptor -
|
|
6
|
+
// Request Interceptor - modify request here
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
// Add query params if exist
|
|
8
|
+
// Add query params
|
|
10
9
|
if (Object.keys(options?.params).length > 0) {
|
|
11
10
|
finalUrl = url + "?" + new URLSearchParams(options.params)
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
return fetch(finalUrl, options)
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
13
|
+
return fetch(finalUrl, options).then(async (response) => {
|
|
14
|
+
const parsedResponse = await response.json()
|
|
15
|
+
// Response Interceptor - modify response here
|
|
16
|
+
return parsedResponse
|
|
17
|
+
})
|
|
20
18
|
}
|
|
21
19
|
return {
|
|
22
20
|
get: fetchFunction,
|
|
23
21
|
post: fetchFunction,
|
|
24
22
|
delete: fetchFunction,
|
|
25
23
|
patch: fetchFunction,
|
|
26
|
-
put: fetchFunction
|
|
24
|
+
put: fetchFunction,
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
export default
|
|
27
|
+
export default apiInstance
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
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,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
"NODE_ENV": "development",
|
|
10
|
+
"API_URL": "",
|
|
11
|
+
"ANALYZE_BUNDLE": false,
|
|
12
|
+
"CLIENT_ENV_VARIABLES": [
|
|
13
|
+
"API_URL"
|
|
14
|
+
]
|
|
18
15
|
}
|
|
Binary file
|
|
@@ -1,40 +1,23 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|