catalyst-core-internal 0.0.1-beta.6 → 0.0.1-beta.8
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/.eslintignore +9 -0
- package/.eslintrc +92 -0
- package/README.md +45 -43
- package/babel.config.json +1 -5
- package/bin/catalyst.js +35 -34
- package/config.json +1 -1
- package/license +10 -0
- package/logger.js +3 -0
- package/package.json +88 -84
- package/scripts/build.js +21 -8
- package/scripts/devBuild.js +42 -0
- package/scripts/devServe.js +43 -0
- package/scripts/loadScriptsBeforeServerStarts.js +1 -1
- package/scripts/serve.js +21 -8
- package/scripts/start.js +17 -8
- package/scripts/validator.js +0 -1
- package/server/renderer/document/Head.js +2 -2
- package/server/renderer/handler.js +29 -41
- package/server/renderer/render.js +14 -3
- package/server/startServer.js +2 -1
- package/server/utils/metaTags.js +13 -0
- package/server/utils/userAgentUtil.js +3 -7
- package/server/utils/validator.js +0 -1
- package/webpack/babel.config.client.js +1 -1
- package/webpack/babel.config.ssr.js +1 -1
- package/webpack/base.babel.js +9 -1
- package/webpack/development.client.babel.js +6 -3
- package/webpack/scssParams.js +18 -2
- package/packages/create-framework-app/templates/redux-js/node_modules/@babel/core/lib/config/caching.js +0 -261
- package/packages/create-framework-app/templates/redux-js/node_modules/@remix-run/router/dist/router.js +0 -4327
- package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/router.js +0 -15
- package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/src/router.js +0 -1
- package/packages/create-framework-app/templates/redux-js/node_modules/http-proxy-middleware/dist/router.js +0 -46
- package/types/caching.d.ts +0 -1
- package/types/config/config.d.ts +0 -19
- package/types/index.d.ts +0 -1
- package/types/logger/index.d.ts +0 -14
- package/types/reducer/index.d.ts +0 -22
- package/types/reducer/loadableConfigReducer.d.ts +0 -9
- package/types/router/ClientRouter.d.ts +0 -5
- package/types/router/ServerRouter.d.ts +0 -7
- package/types/router/index.d.ts +0 -8
- package/types/router.d.ts +0 -1
- package/types/scripts/build.d.ts +0 -1
- package/types/scripts/loadEnvironmentVariables.d.ts +0 -5
- package/types/scripts/loadScriptsBeforeServerStarts.d.ts +0 -1
- package/types/scripts/prepare.d.ts +0 -1
- package/types/scripts/registerAliases.d.ts +0 -1
- package/types/scripts/serve.d.ts +0 -1
- package/types/scripts/start.d.ts +0 -1
- package/types/scripts/validator.d.ts +0 -9
- package/types/scripts/verifyConfig.d.ts +0 -1
- package/types/server/mainIndex.d.ts +0 -1
- package/types/server/mainServer.d.ts +0 -2
- package/types/server/renderer/document/Body.d.ts +0 -11
- package/types/server/renderer/document/Head.d.ts +0 -11
- package/types/server/renderer/document/index.d.ts +0 -2
- package/types/server/renderer/extract.d.ts +0 -18
- package/types/server/renderer/handler.d.ts +0 -6
- package/types/server/renderer/index.d.ts +0 -2
- package/types/server/renderer/render.d.ts +0 -38
- package/types/server/renderer/userAgentUtil.d.ts +0 -1
- package/types/store/index.d.ts +0 -11
- package/types/store/index.dev.d.ts +0 -8
- package/types/store/index.prod.d.ts +0 -8
- package/types/webpack/babel-plugins/remove-client.plugin.d.ts +0 -10
- package/types/webpack/babel-plugins/remove-ssr.plugin.d.ts +0 -10
- package/types/webpack/babel.config.client.d.ts +0 -21
- package/types/webpack/babel.config.d.ts +0 -16
- package/types/webpack/babel.config.ssr.d.ts +0 -21
- package/types/webpack/base.babel.d.ts +0 -184
- package/types/webpack/development.client.babel.d.ts +0 -1
- package/types/webpack/plugins/mime-types.d.ts +0 -78
- package/types/webpack/plugins/route-manifest-plugin.d.ts +0 -1
- package/types/webpack/plugins/upload-assets-plugin.d.ts +0 -1
- package/types/webpack/production.client.babel.d.ts +0 -174
- package/types/webpack/production.ssr.babel.d.ts +0 -2
- package/types/webpack/scssParams.d.ts +0 -2
package/.eslintignore
ADDED
package/.eslintrc
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@babel/eslint-parser",
|
|
3
|
+
"rules": {
|
|
4
|
+
"no-console": "error",
|
|
5
|
+
"react/prop-types": 1,
|
|
6
|
+
"react/display-name": [
|
|
7
|
+
0,
|
|
8
|
+
{
|
|
9
|
+
"ignoreTranspilerName": true
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"react-hooks/exhaustive-deps": "error", // Checks effect dependencies
|
|
13
|
+
"no-prototype-builtins": "off",
|
|
14
|
+
"security/detect-possible-timing-attacks": "error",
|
|
15
|
+
"security/detect-child-process": "error",
|
|
16
|
+
"security/detect-eval-with-expression": "error",
|
|
17
|
+
"security/detect-new-buffer": "error",
|
|
18
|
+
"security/detect-no-csrf-before-method-override": "error",
|
|
19
|
+
"risxss/catch-potential-xss-react": [
|
|
20
|
+
"error",
|
|
21
|
+
{
|
|
22
|
+
"trustedLibraries": [
|
|
23
|
+
"@commonUtils"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"react/jsx-no-target-blank": [
|
|
28
|
+
0,
|
|
29
|
+
{
|
|
30
|
+
"enforceDynamicLinks": "never"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"env": {
|
|
35
|
+
"browser": true,
|
|
36
|
+
"es6": true,
|
|
37
|
+
"jest": true,
|
|
38
|
+
"node": true
|
|
39
|
+
},
|
|
40
|
+
"globals": {
|
|
41
|
+
"expect": true,
|
|
42
|
+
"__non_webpack_require__": true,
|
|
43
|
+
"logger": "readonly",
|
|
44
|
+
"AppCallbacks": "readonly"
|
|
45
|
+
},
|
|
46
|
+
"extends": [
|
|
47
|
+
"eslint:recommended",
|
|
48
|
+
"plugin:react/recommended"
|
|
49
|
+
],
|
|
50
|
+
"parserOptions": {
|
|
51
|
+
"sourceType": "module",
|
|
52
|
+
"ecmaFeatures": {
|
|
53
|
+
"experimentalObjectRestSpread": true,
|
|
54
|
+
"jsx": true
|
|
55
|
+
},
|
|
56
|
+
"babelOptions": {
|
|
57
|
+
"configFile": "./babel.config.json"
|
|
58
|
+
},
|
|
59
|
+
"ecmaVersion": 6
|
|
60
|
+
},
|
|
61
|
+
"plugins": [
|
|
62
|
+
"babel",
|
|
63
|
+
"react",
|
|
64
|
+
"react-hooks",
|
|
65
|
+
"security",
|
|
66
|
+
"risxss"
|
|
67
|
+
],
|
|
68
|
+
"settings": {
|
|
69
|
+
"react": {
|
|
70
|
+
"createClass": "createReactClass",
|
|
71
|
+
"pragma": "React",
|
|
72
|
+
"version": "detect"
|
|
73
|
+
},
|
|
74
|
+
"propWrapperFunctions": [
|
|
75
|
+
"forbidExtraProps",
|
|
76
|
+
{
|
|
77
|
+
"property": "freeze",
|
|
78
|
+
"object": "Object"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"property": "myFavoriteWrapper"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"linkComponents": [
|
|
85
|
+
"Hyperlink",
|
|
86
|
+
{
|
|
87
|
+
"name": "Link",
|
|
88
|
+
"linkAttribute": "to"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
package/README.md
CHANGED
|
@@ -2,32 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
Frontend framework with server rendering support for web applications.
|
|
4
4
|
|
|
5
|
-
## Table of Contents
|
|
5
|
+
## Table of Contents
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
- Overview
|
|
8
|
+
- Installation
|
|
9
|
+
- Data Fetching with Catalyst
|
|
10
|
+
- serverFetcher
|
|
11
|
+
- clientFetcher
|
|
12
|
+
- refetch (for data revalidation)
|
|
13
|
+
- State Management
|
|
14
14
|
|
|
15
|
-
## Overview
|
|
15
|
+
## Overview
|
|
16
16
|
|
|
17
17
|
This package provides a way to proxy your request through your server. It allows you to cache your incoming request to improve your server response time.
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
## Installation
|
|
21
20
|
|
|
22
21
|
**System Requirements**
|
|
23
22
|
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
23
|
+
- Node version 20.4.0 or later
|
|
24
|
+
- macOS and Linux are supported
|
|
27
25
|
|
|
28
26
|
**Automatic Installation**
|
|
29
27
|
|
|
30
|
-
-
|
|
28
|
+
- Run the following commands in the directory where you want to set up the Catalyst app.
|
|
31
29
|
|
|
32
30
|
```js
|
|
33
31
|
npx create-catalyst-app@latest
|
|
@@ -35,24 +33,22 @@ npx create-catalyst-app@latest
|
|
|
35
33
|
|
|
36
34
|
If successful, you will see the following prompts in your terminal.
|
|
37
35
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
36
|
+
- Enter the name of your Catalyst application.
|
|
37
|
+
- Choose state management.
|
|
38
|
+
- Once packages are installed,start the development server by running the following command.
|
|
41
39
|
|
|
42
40
|
```js
|
|
43
|
-
npm run start
|
|
41
|
+
cd project-name && npm run start
|
|
44
42
|
```
|
|
45
43
|
|
|
46
|
-
-
|
|
44
|
+
- Navigate to http://localhost:3005
|
|
47
45
|
|
|
48
46
|
The dev server should be running now.
|
|
49
47
|
|
|
50
|
-
Visit our official documentation:
|
|
48
|
+
Visit our official documentation:
|
|
51
49
|
https://catalyst.1mg.com/public_docs/content/installation
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## Data Fetching with Catalyst
|
|
51
|
+
## Data Fetching with Catalyst
|
|
56
52
|
|
|
57
53
|
we have serverFetcher function for fetching with SSR and clientFetcher function for fetching during client side rendering and navigations.
|
|
58
54
|
|
|
@@ -61,18 +57,22 @@ we have serverFetcher function for fetching with SSR and clientFetcher function
|
|
|
61
57
|
server fetcher will get request, request params, search params and store (if project is setup with redux or rtk) as arguments. We can declare it as an async function and use await for fetching or use then chaining for data fetching.
|
|
62
58
|
|
|
63
59
|
if server fetcher is called for a route then client fetcher will not be called for that route, unless called with refetch.
|
|
60
|
+
|
|
64
61
|
```js
|
|
65
|
-
Home.serverFetcher = async ({ req,params,searchParams }, { store }) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
62
|
+
Home.serverFetcher = async ({ req, params, searchParams }, { store }) => {
|
|
63
|
+
store.dispatch(someAction())
|
|
64
|
+
const res = await fetch("some_url")
|
|
65
|
+
const json = await res.json()
|
|
66
|
+
return json
|
|
67
|
+
}
|
|
71
68
|
```
|
|
69
|
+
|
|
72
70
|
data returned from fetcher function will be accessible through useCurrentRouteData() hook provided by router.
|
|
71
|
+
|
|
73
72
|
```js
|
|
74
|
-
const [data,error,isFetched] = useCurrentRouteData()
|
|
73
|
+
const [data, error, isFetched] = useCurrentRouteData()
|
|
75
74
|
```
|
|
75
|
+
|
|
76
76
|
error and loading state would be handled by router.
|
|
77
77
|
|
|
78
78
|
**clientFetcher**
|
|
@@ -80,24 +80,25 @@ error and loading state would be handled by router.
|
|
|
80
80
|
client fetcher would be called on client side rendering and client side navigations. `store` would be available as a param in client side for dispatching redux/rtk actions.
|
|
81
81
|
|
|
82
82
|
```js
|
|
83
|
-
Home.clientFetcher = async ({route,location,params,searchParams,navigate},{store}) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
83
|
+
Home.clientFetcher = async ({ route, location, params, searchParams, navigate }, { store }) => {
|
|
84
|
+
store.dispatch(someAction())
|
|
85
|
+
const res = await fetch("some_url")
|
|
86
|
+
const json = await res.json()
|
|
87
|
+
return json
|
|
88
|
+
}
|
|
89
89
|
```
|
|
90
|
-
|
|
90
|
+
|
|
91
|
+
data returned from client fetcher function will be accessible through useCurrentRouteData() hook provided by router (hook for data access through client is same).
|
|
92
|
+
|
|
91
93
|
```js
|
|
92
|
-
const [data,error,isFetched] = useCurrentRouteData()
|
|
94
|
+
const [data, error, isFetched] = useCurrentRouteData()
|
|
93
95
|
```
|
|
94
96
|
|
|
95
|
-
|
|
96
97
|
**refetch (for data revalidation)**
|
|
97
98
|
|
|
98
99
|
refetch function can be used were we need to execute clientFetcher based on some condition(such as for infinite scroll or some state change inside container or onClick.)
|
|
99
100
|
|
|
100
|
-
We can pass arguments in refetch function which would
|
|
101
|
+
We can pass arguments in refetch function which would
|
|
101
102
|
|
|
102
103
|
```js
|
|
103
104
|
const [data,error,isFetched,refetch] = useCurrentRouteData()
|
|
@@ -107,20 +108,20 @@ useEffect(()=>{
|
|
|
107
108
|
},[arg])
|
|
108
109
|
|
|
109
110
|
clientFetcher = ({},{refetchArgument}) => {
|
|
110
|
-
|
|
111
|
+
|
|
111
112
|
const res = await api_call // refetchArg can be used as a param in api call
|
|
112
113
|
return res
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
```
|
|
116
117
|
|
|
117
|
-
|
|
118
118
|
## State Management
|
|
119
|
+
|
|
119
120
|
state management wrappers are defined in stateProvider.js file
|
|
120
121
|
|
|
121
122
|
store can be configured by manipulating store/index.js as per user requirements (custom middlewares etc can be added in this way.
|
|
122
123
|
|
|
123
|
-
initial state and request object would be provided in createStore function which will be called on server and client, we use the params to add additional arguments and middlewares in redux store.
|
|
124
|
+
initial state and request object would be provided in createStore function which will be called on server and client, we use the params to add additional arguments and middlewares in redux store.
|
|
124
125
|
|
|
125
126
|
```js
|
|
126
127
|
const configureStore = (initialState, cookies, requestObj, customHeaders) => {
|
|
@@ -142,4 +143,5 @@ export default configureStore
|
|
|
142
143
|
```
|
|
143
144
|
|
|
144
145
|
## Documentation
|
|
146
|
+
|
|
145
147
|
Visit https://catalyst.1mg.com to view the full documentation.
|
package/babel.config.json
CHANGED
|
@@ -10,11 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"@babel/preset-react"
|
|
12
12
|
],
|
|
13
|
-
"plugins": [
|
|
14
|
-
"@babel/plugin-proposal-object-rest-spread",
|
|
15
|
-
"transform-class-properties",
|
|
16
|
-
"@loadable/babel-plugin"
|
|
17
|
-
],
|
|
13
|
+
"plugins": ["@loadable/babel-plugin"],
|
|
18
14
|
"env": {
|
|
19
15
|
"test": {
|
|
20
16
|
"presets": ["@babel/preset-react"]
|
package/bin/catalyst.js
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
process.on(
|
|
4
|
-
throw err
|
|
5
|
-
})
|
|
6
|
-
const { spawnSync } = require(
|
|
7
|
-
const args = process.argv.slice(2)
|
|
2
|
+
"use strict"
|
|
3
|
+
process.on("unhandledRejection", (err) => {
|
|
4
|
+
throw err
|
|
5
|
+
})
|
|
6
|
+
const { spawnSync } = require("node:child_process")
|
|
7
|
+
const args = process.argv.slice(2)
|
|
8
8
|
const scriptIndex = args.findIndex(
|
|
9
|
-
|
|
10
|
-
)
|
|
11
|
-
const script = scriptIndex === -1 ? args[0] : args[scriptIndex]
|
|
12
|
-
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []
|
|
13
|
-
if ([
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
(x) => x === "build" || x === "start" || x === "serve" || x === "devBuild" || x === "devServe"
|
|
10
|
+
)
|
|
11
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex]
|
|
12
|
+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []
|
|
13
|
+
if (["build", "start", "serve", "devBuild", "devServe"].includes(script)) {
|
|
14
|
+
const result = spawnSync(
|
|
15
|
+
process.execPath,
|
|
16
|
+
nodeArgs.concat(require.resolve("../scripts/" + script)).concat(args.slice(scriptIndex + 1)),
|
|
17
|
+
{ stdio: "inherit" }
|
|
18
|
+
)
|
|
19
|
+
if (result.signal) {
|
|
20
|
+
if (result.signal === "SIGKILL") {
|
|
21
|
+
/* eslint-disable no-console */
|
|
22
|
+
console.log(
|
|
23
|
+
"The build failed because the process exited too early. " +
|
|
24
|
+
"This probably means the system ran out of memory or someone called " +
|
|
25
|
+
"`kill -9` on the process."
|
|
26
|
+
)
|
|
27
|
+
} else if (result.signal === "SIGTERM") {
|
|
28
|
+
/* eslint-disable no-console */
|
|
29
|
+
console.log(
|
|
30
|
+
"The build failed because the process exited too early. " +
|
|
31
|
+
"Someone might have called `kill` or `killall`, or the system could " +
|
|
32
|
+
"be shutting down."
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
process.exit(1)
|
|
34
36
|
}
|
|
35
|
-
process.exit(
|
|
36
|
-
}
|
|
37
|
-
process.exit(result.status);
|
|
37
|
+
process.exit(result.status)
|
|
38
38
|
} else {
|
|
39
|
+
/* eslint-disable no-console */
|
|
39
40
|
console.log('Unknown script "' + script + '".');
|
|
40
41
|
}
|
package/config.json
CHANGED
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/logger.js
CHANGED
|
@@ -74,16 +74,19 @@ const configureLogger = (config = {}) => {
|
|
|
74
74
|
const Logger = {
|
|
75
75
|
debug: () => {},
|
|
76
76
|
error: msg => {
|
|
77
|
+
/* eslint-disable no-console */
|
|
77
78
|
console.log(pc.red(pc.bold("ERROR: " + JSON.stringify(msg))));
|
|
78
79
|
errorLogger.error(msg);
|
|
79
80
|
},
|
|
80
81
|
info: msg => {
|
|
82
|
+
/* eslint-disable no-console */
|
|
81
83
|
console.log(pc.green(pc.bold("INFO: " + JSON.stringify(msg))));
|
|
82
84
|
infoLogger.info(msg);
|
|
83
85
|
}
|
|
84
86
|
};
|
|
85
87
|
if (enableDebugLogs && JSON.parse(enableDebugLogs)) {
|
|
86
88
|
Logger.debug = msg => {
|
|
89
|
+
/* eslint-disable no-console */
|
|
87
90
|
console.log(pc.yellow(pc.bold("DEBUG: " + JSON.stringify(msg))));
|
|
88
91
|
debugLogger.debug(msg);
|
|
89
92
|
};
|
package/package.json
CHANGED
|
@@ -1,85 +1,89 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
2
|
+
"name": "catalyst-core-internal",
|
|
3
|
+
"version": "0.0.1-beta.8",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"description": "Web framework that provides great performance out of the box",
|
|
6
|
+
"bin": {
|
|
7
|
+
"catalyst": "bin/catalyst.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"prepare": "babel src --out-dir .",
|
|
11
|
+
"start": "node ./scripts/checkVersion && npm run start:client & npm run start:server",
|
|
12
|
+
"start:client": "npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js webpack/development.client.babel --no-warnings=ExperimentalWarning --no-warnings=BABEL",
|
|
13
|
+
"start:server": "npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js ./server/startServer.js --watch-path=${npm_config_src_path}/server --watch-path=${npm_config_src_path}/src --ignore='__IGNORE__' --no-warnings=ExperimentalWarning --no-warnings=BABEL",
|
|
14
|
+
"build": "node ./scripts/checkVersion && npm run build:prepare && npm run build:client && npm run build:ssr && npm run build:server",
|
|
15
|
+
"build:prepare": "rm -rf ${npm_config_src_path}/${build_output_path} & node ./scripts/loadScriptsBeforeServerStarts.js",
|
|
16
|
+
"build:client": "APPLICATION=${npm_config_app_name} webpack --config ./webpack/production.client.babel.js --progress",
|
|
17
|
+
"build:ssr": "APPLICATION=${npm_config_app_name} SSR=true webpack --config ./webpack/production.ssr.babel.js --progress",
|
|
18
|
+
"build:server": "APPLICATION=${npm_config_app_name} npx babel ./server --out-dir ${npm_config_src_path}/${build_output_path} --ignore '**/*.test.js,./server/renderer/handler.js' && APPLICATION=${npm_config_app_name} npx babel ${npm_config_src_path}/server --out-dir ${npm_config_src_path}/${build_output_path}",
|
|
19
|
+
"serve": "APPLICATION=${npm_config_app_name} node -r ./scripts/loadScriptsBeforeServerStarts.js ${npm_config_src_path}/${build_output_path}/startServer.js",
|
|
20
|
+
"prepublishOnly": "npm i && npm run prepare",
|
|
21
|
+
"lint": "eslint .",
|
|
22
|
+
"prettify": "prettier . --write"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@babel/cli": "^7.23.0",
|
|
27
|
+
"@babel/core": "^7.23.2",
|
|
28
|
+
"@babel/node": "^7.22.19",
|
|
29
|
+
"@babel/preset-env": "^7.23.2",
|
|
30
|
+
"@babel/preset-react": "^7.22.15",
|
|
31
|
+
"@babel/register": "^7.22.15",
|
|
32
|
+
"@dr.pogodin/css-modules-require-hook": "^4.7.3",
|
|
33
|
+
"@loadable/babel-plugin": "^5.16.1",
|
|
34
|
+
"@loadable/component": "^5.15.3",
|
|
35
|
+
"@loadable/server": "^5.16.1",
|
|
36
|
+
"@loadable/webpack-plugin": "^5.15.2",
|
|
37
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
38
|
+
"@svgr/webpack": "^8.1.0",
|
|
39
|
+
"@tata1mg/router": "^0.0.2-alpha.0",
|
|
40
|
+
"app-root-path": "^3.1.0",
|
|
41
|
+
"babel-loader": "^9.1.3",
|
|
42
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
43
|
+
"body-parser": "^1.20.2",
|
|
44
|
+
"chokidar": "^3.6.0",
|
|
45
|
+
"compression": "^1.7.4",
|
|
46
|
+
"cookie-parser": "^1.4.6",
|
|
47
|
+
"css-hot-loader": "^1.4.4",
|
|
48
|
+
"css-loader": "^6.8.1",
|
|
49
|
+
"express": "^4.18.2",
|
|
50
|
+
"express-static-gzip": "^2.1.7",
|
|
51
|
+
"file-loader": "^6.2.0",
|
|
52
|
+
"html-loader": "^4.2.0",
|
|
53
|
+
"img-loader": "^4.0.0",
|
|
54
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
55
|
+
"module-alias": "^2.2.3",
|
|
56
|
+
"picocolors": "^1.0.0",
|
|
57
|
+
"postcss-loader": "^7.3.3",
|
|
58
|
+
"react": "^18.2.0",
|
|
59
|
+
"react-dom": "^18.2.0",
|
|
60
|
+
"react-redux": "^8.1.3",
|
|
61
|
+
"react-refresh": "^0.14.0",
|
|
62
|
+
"react-router-dom": "^6.16.0",
|
|
63
|
+
"redux": "^4.2.1",
|
|
64
|
+
"sass": "^1.69.5",
|
|
65
|
+
"sass-loader": "^13.3.2",
|
|
66
|
+
"sass-resources-loader": "^2.2.5",
|
|
67
|
+
"ua-parser-js": "^1.0.37",
|
|
68
|
+
"url": "^0.11.3",
|
|
69
|
+
"url-loader": "^4.1.1",
|
|
70
|
+
"webpack": "^5.88.2",
|
|
71
|
+
"webpack-bundle-analyzer": "^4.9.1",
|
|
72
|
+
"webpack-cli": "^5.1.4",
|
|
73
|
+
"webpack-dev-server": "^4.15.2",
|
|
74
|
+
"webpack-merge": "^5.9.0",
|
|
75
|
+
"webpack-node-externals": "^3.0.0",
|
|
76
|
+
"winston": "^3.11.0",
|
|
77
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
81
|
+
"eslint": "^8.26.0",
|
|
82
|
+
"eslint-plugin-babel": "^5.3.1",
|
|
83
|
+
"eslint-plugin-react": "^7.34.1",
|
|
84
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
85
|
+
"eslint-plugin-risxss": "^2.1.0",
|
|
86
|
+
"eslint-plugin-security": "^3.0.0",
|
|
87
|
+
"prettier": "^3.2.5"
|
|
88
|
+
}
|
|
89
|
+
}
|
package/scripts/build.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
7
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
3
|
const {
|
|
9
4
|
spawnSync
|
|
10
5
|
} = require("child_process");
|
|
@@ -12,18 +7,36 @@ const path = require("path");
|
|
|
12
7
|
const {
|
|
13
8
|
name
|
|
14
9
|
} = require(`${process.env.PWD}/package.json`);
|
|
10
|
+
const {
|
|
11
|
+
BUILD_OUTPUT_PATH
|
|
12
|
+
} = require(`${process.env.PWD}/config/config.json`);
|
|
13
|
+
function arrayToObject(array) {
|
|
14
|
+
const obj = {};
|
|
15
|
+
array.forEach(item => {
|
|
16
|
+
const [key, value] = item.split("=");
|
|
17
|
+
if (value) obj[key] = value;
|
|
18
|
+
});
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* @description - creates a production build of the application.
|
|
18
24
|
*/
|
|
19
25
|
function start() {
|
|
26
|
+
const commandLineArguments = process.argv.slice(2);
|
|
27
|
+
const argumentsObject = arrayToObject(commandLineArguments);
|
|
20
28
|
const dirname = path.resolve(__dirname, "../");
|
|
21
29
|
spawnSync("npm", ["run", "build", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
|
|
22
30
|
cwd: dirname,
|
|
23
31
|
stdio: "inherit",
|
|
24
|
-
env:
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
env: {
|
|
33
|
+
...process.env,
|
|
34
|
+
src_path: process.env.PWD,
|
|
35
|
+
build_output_path: BUILD_OUTPUT_PATH,
|
|
36
|
+
NODE_ENV: "production",
|
|
37
|
+
IS_DEV_COMMAND: false,
|
|
38
|
+
...argumentsObject
|
|
39
|
+
}
|
|
27
40
|
});
|
|
28
41
|
}
|
|
29
42
|
start();
|