create-catalyst-app 0.0.1-beta.2 → 0.0.1-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{readme.md → Readme.md} +7 -4
- package/codemod/new-route/index.js +98 -0
- package/codemod/new-route/template.js +119 -0
- package/codemod/new-route/transformers/createReducer.js +38 -0
- package/codemod/new-route/transformers/createRoute.js +33 -0
- package/codemod/new-route/utils.js +90 -0
- package/license +10 -0
- package/package.json +18 -18
- package/scripts/cli.cjs +359 -0
- package/templates/common/.eslintignore +1 -6
- package/templates/common/.eslintrc +13 -38
- package/templates/common/README.md +16 -20
- package/templates/common/api.js +12 -25
- package/templates/common/client/styles.js +1 -13
- package/templates/common/config/config.json +10 -16
- package/templates/common/public/favicon.ico +0 -0
- package/templates/{redux-js → common}/server/document.js +2 -4
- 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 -48
- 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 +3 -2
- package/templates/mcp-root/mcp/context.md +674 -0
- package/templates/mcp-root/mcp/mcp.js +36 -0
- package/templates/none-js/client/index.js +8 -12
- package/templates/none-js/package.json +13 -35
- package/templates/none-js/src/js/containers/App/index.js +12 -36
- package/templates/none-js/src/js/routes/utils.js +42 -0
- package/templates/none-ts/client/index.js +23 -0
- package/templates/none-ts/package.json +34 -0
- package/templates/none-ts/src/js/containers/App/index.js +16 -0
- package/templates/none-ts/src/js/routes/utils.js +42 -0
- package/templates/none-ts/tsconfig.json +13 -0
- package/templates/none-ts/types.d.ts +4 -0
- package/templates/redux-js/client/index.js +6 -5
- package/templates/redux-js/package.json +16 -35
- 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 -17
- package/templates/redux-js/src/js/routes/utils.js +42 -0
- package/templates/redux-js/src/js/store/index.js +17 -68
- package/{my-app → templates/redux-ts}/client/index.js +4 -3
- package/templates/redux-ts/package.json +37 -0
- package/{my-app → templates/redux-ts}/src/js/containers/App/actions.js +1 -4
- package/templates/redux-ts/src/js/containers/App/index.js +16 -0
- package/templates/redux-ts/src/js/containers/App/reducer.js +19 -0
- package/templates/redux-ts/src/js/routes/utils.js +42 -0
- package/templates/redux-ts/src/js/store/index.js +28 -0
- package/templates/redux-ts/tsconfig.json +13 -0
- package/templates/redux-ts/types.d.ts +4 -0
- package/templates/rtk-js/client/index.js +6 -5
- package/templates/rtk-js/package.json +16 -35
- 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 +42 -0
- package/templates/rtk-js/src/js/store/index.js +12 -6
- package/templates/rtk-ts/client/index.js +28 -0
- package/templates/rtk-ts/package.json +37 -0
- package/templates/rtk-ts/src/js/containers/App/index.js +16 -0
- package/{my-app → templates/rtk-ts}/src/js/containers/App/reducer.js +1 -9
- package/templates/rtk-ts/src/js/routes/utils.js +42 -0
- package/templates/rtk-ts/src/js/store/index.js +28 -0
- package/templates/rtk-ts/tsconfig.json +13 -0
- package/templates/rtk-ts/types.d.ts +4 -0
- package/templates/tailwind/postcss.config.js +5 -0
- package/templates/tailwind/src/static/css/base/index.scss +2 -0
- 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/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/index.js +0 -16
- 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/.babelrc +0 -26
- package/templates/common/.editorconfig +0 -12
- 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/document.js +0 -14
- 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/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/scripts/cli.cjs
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require("child_process")
|
|
3
|
+
const Commander = require("commander")
|
|
4
|
+
const { Option } = require("commander")
|
|
5
|
+
const prompts = require("prompts")
|
|
6
|
+
const { red, green, cyan, bold } = require("picocolors")
|
|
7
|
+
const tar = require("tar")
|
|
8
|
+
const path = require("path")
|
|
9
|
+
const fs = require("fs")
|
|
10
|
+
var validate = require("validate-npm-package-name")
|
|
11
|
+
const packageJson = require("../package.json")
|
|
12
|
+
|
|
13
|
+
let projectName = null
|
|
14
|
+
const program = new Commander.Command()
|
|
15
|
+
.version(packageJson.version)
|
|
16
|
+
.description("Scaffolding")
|
|
17
|
+
.arguments("[folderName]")
|
|
18
|
+
.usage(`${green("[folderName]")} [options]`)
|
|
19
|
+
.action((name) => (projectName = name))
|
|
20
|
+
.addOption(new Option("-y, --yes [yes]", "Use default configuration"))
|
|
21
|
+
.addOption(
|
|
22
|
+
new Option(
|
|
23
|
+
"-s, --state-management [stateManagement]",
|
|
24
|
+
"Specify state management (rtk, redux, or none)",
|
|
25
|
+
/^(rtk|redux|none)$/i,
|
|
26
|
+
"none"
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
.action(async (folderName = null, cmd) => {
|
|
30
|
+
try {
|
|
31
|
+
let config = {
|
|
32
|
+
folderName,
|
|
33
|
+
language: null,
|
|
34
|
+
tailWindSupport: null,
|
|
35
|
+
description: null,
|
|
36
|
+
stateManagement: cmd.stateManagement,
|
|
37
|
+
mcpSupport: null,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (process.argv.includes("new-route")) {
|
|
41
|
+
const createRoutePath = path.join(__dirname, "../codemod/new-route/index.js")
|
|
42
|
+
execSync(`node ${createRoutePath}`, { stdio: "inherit" })
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log(cyan(`Using create-catalyst-app version ${bold(packageJson.version)}`))
|
|
47
|
+
|
|
48
|
+
// Use options provided through commander or prompt the user
|
|
49
|
+
validateOptions(cmd)
|
|
50
|
+
|
|
51
|
+
if (cmd.yes) {
|
|
52
|
+
console.log("Using default configuration.")
|
|
53
|
+
config = {
|
|
54
|
+
folderName: "my-app",
|
|
55
|
+
language: "js",
|
|
56
|
+
tailWindSupport: false,
|
|
57
|
+
description: "Default catalyst app",
|
|
58
|
+
stateManagement: "none",
|
|
59
|
+
mcpSupport: true,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const projectName = config.folderName || (await promptProjectName())
|
|
64
|
+
let isNameValid = validate(projectName)
|
|
65
|
+
if (!isNameValid.validForNewPackages) {
|
|
66
|
+
isNameValid?.warnings?.forEach?.((item) => console.log(red(item)))
|
|
67
|
+
isNameValid?.errors?.forEach?.((item) => console.log(red(item)))
|
|
68
|
+
process.exit(1)
|
|
69
|
+
}
|
|
70
|
+
let projectPath = path.join(process.cwd(), projectName)
|
|
71
|
+
if (fs.existsSync(projectPath)) {
|
|
72
|
+
console.log(red(`${projectName} already exists, try again.`))
|
|
73
|
+
process.exit(1)
|
|
74
|
+
}
|
|
75
|
+
const projectDescription = config.description || (await promptDescription())
|
|
76
|
+
const language = config.language || (await promptTypescript())
|
|
77
|
+
const tailWindSupport = config.tailWindSupport !== null || (await promptTailwind())
|
|
78
|
+
const stateManagement = config.stateManagement || (await promptStateManagement())
|
|
79
|
+
const mcpSupport = config.mcpSupport !== null || (await promptMcp())
|
|
80
|
+
|
|
81
|
+
// Define mapping of options to repository suffixes
|
|
82
|
+
const repositorySuffixes = {
|
|
83
|
+
js: "js",
|
|
84
|
+
ts: "ts",
|
|
85
|
+
redux: "redux",
|
|
86
|
+
rtk: "rtk",
|
|
87
|
+
none: "none",
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const packageName = packageJson.name
|
|
91
|
+
const packageVersion = packageJson.version
|
|
92
|
+
|
|
93
|
+
const commonCodeDirectory = "package/templates/common"
|
|
94
|
+
const selectedTemplateCode = `package/templates/${repositorySuffixes[stateManagement]}-${repositorySuffixes[language]}`
|
|
95
|
+
const tailwindCodeDirectory = "package/templates/tailwind"
|
|
96
|
+
const mcpCodeDirectory = "package/templates/mcp-root"
|
|
97
|
+
|
|
98
|
+
const subDirectoriesToExtract = [commonCodeDirectory, selectedTemplateCode]
|
|
99
|
+
if (tailWindSupport) subDirectoriesToExtract.push(tailwindCodeDirectory)
|
|
100
|
+
if (mcpSupport) subDirectoriesToExtract.push(mcpCodeDirectory)
|
|
101
|
+
|
|
102
|
+
const extractionDestination = `/${projectName}/`
|
|
103
|
+
let tempDir
|
|
104
|
+
;(() => {
|
|
105
|
+
try {
|
|
106
|
+
tempDir = createTempDir()
|
|
107
|
+
|
|
108
|
+
const packageFilePath = packNpmPackage(packageName, packageVersion, tempDir)
|
|
109
|
+
|
|
110
|
+
extractSubdirectory(packageFilePath)
|
|
111
|
+
createGitignore(projectName)
|
|
112
|
+
|
|
113
|
+
execSync(
|
|
114
|
+
`cd ${projectName} && npm i && npm pkg set name=${projectName} ${projectDescription ? `description="${projectDescription}"` : ""} && git init --quiet`,
|
|
115
|
+
{ stdio: "inherit" }
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
if (tailWindSupport) {
|
|
119
|
+
execSync(`cd ${projectName} && npm i tailwindcss@4.1.4 @tailwindcss/postcss@4.1.4`, {
|
|
120
|
+
stdio: "inherit",
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (mcpSupport) {
|
|
125
|
+
execSync(`cd ${projectName} && npm i @modelcontextprotocol/sdk`, { stdio: "inherit" })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
execSync(
|
|
129
|
+
`cd ${projectName} && git add . && git commit -m "initial commit from Create Catalyst App"`,
|
|
130
|
+
{
|
|
131
|
+
stdio: "inherit",
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
console.log(`\n${green(bold("Success!"))} created ${projectName} at ${projectPath}`)
|
|
136
|
+
console.log("Inside this directory, you can run the following commands.")
|
|
137
|
+
|
|
138
|
+
console.log(cyan(bold(" \n npm run start")))
|
|
139
|
+
console.log(" Starts the development server ")
|
|
140
|
+
|
|
141
|
+
console.log(cyan(bold("\n npm run build")))
|
|
142
|
+
console.log(" Bundles the app for production ")
|
|
143
|
+
|
|
144
|
+
console.log(cyan(bold("\n npm run serve")))
|
|
145
|
+
console.log(" Serves the production build ")
|
|
146
|
+
|
|
147
|
+
console.log("\nWe suggest you to begin, by running")
|
|
148
|
+
console.log(` ${cyan("cd")} ${projectName} && ${cyan("npm start")} \n\n`)
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error(`Error: ${error.message}`)
|
|
151
|
+
process.exit(1)
|
|
152
|
+
} finally {
|
|
153
|
+
deleteDirectory(tempDir)
|
|
154
|
+
}
|
|
155
|
+
})()
|
|
156
|
+
function packNpmPackage(packageName, packageVersion, tempDir) {
|
|
157
|
+
const tarballFileName = `${packageName}-${packageVersion}.tgz`
|
|
158
|
+
const tarballFilePath = path.join(tempDir, tarballFileName)
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
execSync(`npm pack ${packageName}@${packageVersion} --silent`, {
|
|
162
|
+
cwd: tempDir,
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
// to test locally, comment the upper execSync and uncomment this one.
|
|
166
|
+
// execSync(`npm pack --pack-destination=${tempDir} --silent`, {
|
|
167
|
+
// cwd: process.cwd(),
|
|
168
|
+
// })
|
|
169
|
+
|
|
170
|
+
return tarballFilePath
|
|
171
|
+
} catch (error) {
|
|
172
|
+
console.error(`Error packing npm package: ${error.message}`)
|
|
173
|
+
throw error
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Function to create a temporary directory
|
|
178
|
+
function createTempDir() {
|
|
179
|
+
const tempDir = fs.mkdtempSync(path.join(process.cwd(), "temp-"))
|
|
180
|
+
|
|
181
|
+
return tempDir
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Function to extract subdirectory from npm package and delete tar file
|
|
185
|
+
function extractSubdirectory(packageFilePath) {
|
|
186
|
+
try {
|
|
187
|
+
tar.extract({
|
|
188
|
+
file: packageFilePath,
|
|
189
|
+
sync: true,
|
|
190
|
+
filter: (path, entry) => {
|
|
191
|
+
return subDirectoriesToExtract.reduce((acc, item) => {
|
|
192
|
+
return acc || path.startsWith(item)
|
|
193
|
+
}, false)
|
|
194
|
+
},
|
|
195
|
+
cwd: path.join(process.cwd()),
|
|
196
|
+
onentry: (entry) => {
|
|
197
|
+
if (entry.path.startsWith(commonCodeDirectory)) {
|
|
198
|
+
entry.path = entry.path.replace(commonCodeDirectory, extractionDestination)
|
|
199
|
+
}
|
|
200
|
+
if (entry.path.startsWith(selectedTemplateCode)) {
|
|
201
|
+
entry.path = entry.path.replace(selectedTemplateCode, extractionDestination)
|
|
202
|
+
}
|
|
203
|
+
if (entry.path.startsWith(tailwindCodeDirectory)) {
|
|
204
|
+
entry.path = entry.path.replace(tailwindCodeDirectory, extractionDestination)
|
|
205
|
+
}
|
|
206
|
+
if (entry.path.startsWith(mcpCodeDirectory)) {
|
|
207
|
+
entry.path = entry.path.replace(mcpCodeDirectory, extractionDestination)
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
})
|
|
211
|
+
} catch (e) {
|
|
212
|
+
console.log("An error occurred", e)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
console.log(cyan(`Run cd ${projectName} && npm start to get started.`))
|
|
216
|
+
}
|
|
217
|
+
} catch (error) {
|
|
218
|
+
console.error(red("An error occurred:"), error.message)
|
|
219
|
+
process.exit(1)
|
|
220
|
+
}
|
|
221
|
+
})
|
|
222
|
+
.allowUnknownOption()
|
|
223
|
+
|
|
224
|
+
program.parse(process.argv)
|
|
225
|
+
|
|
226
|
+
async function promptStateManagement() {
|
|
227
|
+
const response = await prompts({
|
|
228
|
+
type: "select",
|
|
229
|
+
name: "stateManagement",
|
|
230
|
+
message: "Choose state management:",
|
|
231
|
+
choices: [
|
|
232
|
+
{ title: "Redux", value: "redux" },
|
|
233
|
+
{ title: "Redux Toolkit (RTK)", value: "rtk" },
|
|
234
|
+
{ title: "None", value: "none" },
|
|
235
|
+
],
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
return response.stateManagement
|
|
239
|
+
}
|
|
240
|
+
async function promptProjectName() {
|
|
241
|
+
const res = await prompts({
|
|
242
|
+
type: "text",
|
|
243
|
+
name: "path",
|
|
244
|
+
message: "What is your project named?",
|
|
245
|
+
initial: "my-app",
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
if (typeof res.path === "string") {
|
|
249
|
+
let projectName = res.path.trim()
|
|
250
|
+
return projectName
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!res.path || projectName === "") {
|
|
254
|
+
console.log(
|
|
255
|
+
"\nPlease specify the project directory:\n" +
|
|
256
|
+
` ${cyan(program.name())} ${green("<project-directory>")}\n` +
|
|
257
|
+
"For example:\n" +
|
|
258
|
+
` ${cyan(program.name())} ${green("my-next-app")}\n\n` +
|
|
259
|
+
`Run ${cyan(`${program.name()} --help`)} to see all options.`
|
|
260
|
+
)
|
|
261
|
+
process.exit(1)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async function promptDescription() {
|
|
266
|
+
const res = await prompts({
|
|
267
|
+
type: "text",
|
|
268
|
+
name: "path",
|
|
269
|
+
message: "What is your project description?",
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
if (typeof res.path === "string") {
|
|
273
|
+
return res.path.trim()
|
|
274
|
+
} else return null
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function promptTypescript() {
|
|
278
|
+
const response = await prompts({
|
|
279
|
+
type: "select",
|
|
280
|
+
name: "typescript",
|
|
281
|
+
message: "Would you like to use TypeScript?",
|
|
282
|
+
choices: [
|
|
283
|
+
{ title: "Yes", value: "ts" },
|
|
284
|
+
{ title: "No", value: "js" },
|
|
285
|
+
],
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
return response.typescript
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
async function promptTailwind() {
|
|
292
|
+
const response = await prompts({
|
|
293
|
+
type: "select",
|
|
294
|
+
name: "tailwind",
|
|
295
|
+
message: "Would you like to use Tailwind CSS?",
|
|
296
|
+
choices: [
|
|
297
|
+
{ title: "Yes", value: true },
|
|
298
|
+
{ title: "No", value: false },
|
|
299
|
+
],
|
|
300
|
+
})
|
|
301
|
+
return response.tailwind
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function promptMcp() {
|
|
305
|
+
const response = await prompts({
|
|
306
|
+
type: "select",
|
|
307
|
+
name: "mcp",
|
|
308
|
+
message: "Would you like to setup an MCP server?",
|
|
309
|
+
choices: [
|
|
310
|
+
{ title: "Yes", value: true },
|
|
311
|
+
{ title: "No", value: false },
|
|
312
|
+
],
|
|
313
|
+
})
|
|
314
|
+
return response.mcp
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function validateOptions(cmd) {
|
|
318
|
+
// Validate language option
|
|
319
|
+
if (cmd.lang && !["js", "ts"].includes(cmd.lang.toLowerCase())) {
|
|
320
|
+
throw new Error('Invalid language option. Use "js" or "ts".')
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Validate state management option
|
|
324
|
+
if (cmd.stateManagement && !["rtk", "redux", "none"].includes(cmd.stateManagement.toLowerCase())) {
|
|
325
|
+
throw new Error('Invalid state management option. Use "rtk", "redux", or "none".')
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
if (cmd.yes && typeof cmd.yes !== "boolean") {
|
|
329
|
+
throw new Error('Invalid option for "yes". Use "-y" or "--yes" to accept defaults.')
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function deleteDirectory(dirPath) {
|
|
334
|
+
if (dirPath && fs.existsSync(dirPath)) {
|
|
335
|
+
fs.readdirSync(dirPath).forEach((file) => {
|
|
336
|
+
const currentPath = path.join(dirPath, file)
|
|
337
|
+
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
338
|
+
deleteDirectory(currentPath)
|
|
339
|
+
} else {
|
|
340
|
+
fs.unlinkSync(currentPath)
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
fs.rmdirSync(dirPath)
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Function to create a .gitignore file with the hardcoded patterns
|
|
348
|
+
function createGitignore(projectName) {
|
|
349
|
+
const gitiIgnorePatterns = ["node_modules", "build", "logs"]
|
|
350
|
+
|
|
351
|
+
const gitignorePath = path.join(process.cwd(), projectName, ".gitignore")
|
|
352
|
+
|
|
353
|
+
if (fs.existsSync(gitignorePath)) {
|
|
354
|
+
console.log(".gitignore already exists. Please rename or remove it before running the script.")
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
fs.writeFileSync(gitignorePath, gitiIgnorePatterns.join("\n"))
|
|
359
|
+
}
|
|
@@ -1,53 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
"parser": "@babel/eslint-parser",
|
|
3
2
|
"rules": {
|
|
4
|
-
"
|
|
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
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
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
|
-
"
|
|
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": [
|
|
40
|
-
|
|
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
|
-
|
|
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
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
5
|
+
// Request Interceptor - modify request here
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
15
|
+
|
|
16
|
+
export default fetchFunction
|
|
@@ -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,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
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
|
}
|
|
Binary file
|
|
@@ -3,10 +3,8 @@ import { Head, Body } from "catalyst-core"
|
|
|
3
3
|
|
|
4
4
|
function Document(props) {
|
|
5
5
|
return (
|
|
6
|
-
<html 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
|
)
|
|
@@ -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
|