catalyst-core-internal 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/.eslintignore +9 -0
- package/.eslintrc +91 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/README.md +45 -43
- package/babel.config.json +2 -5
- package/bin/catalyst.js +33 -35
- package/caching.js +1 -16
- package/changelog.md +12 -0
- package/commitlint.config.js +11 -0
- package/config.json +1 -1
- package/index.js +1 -16
- package/license +10 -0
- package/logger.js +3 -89
- package/package.json +89 -83
- package/router/ClientRouter.js +2 -18
- package/router/ServerRouter.js +1 -19
- package/router.js +1 -16
- package/scripts/build.js +9 -28
- package/scripts/checkVersion.js +1 -5
- package/scripts/devBuild.js +10 -0
- package/scripts/devServe.js +5 -0
- package/scripts/loadEnvironmentVariables.js +4 -23
- package/scripts/loadScriptsBeforeServerStarts.js +5 -47
- package/scripts/resiterAliases.js +29 -0
- package/scripts/scriptUtils.js +2 -0
- package/scripts/serve.js +4 -29
- package/scripts/start.js +5 -25
- package/scripts/validator.js +1 -130
- package/server/expressServer.js +8 -49
- package/server/renderer/document/Body.js +6 -28
- package/server/renderer/document/Head.js +5 -39
- package/server/renderer/document/index.js +1 -27
- package/server/renderer/extract.js +6 -72
- package/server/renderer/handler.js +14 -241
- package/server/renderer/index.js +1 -12
- package/server/renderer/render.js +8 -60
- package/server/startServer.js +6 -65
- package/server/utils/userAgentUtil.js +3 -49
- package/server/utils/validator.js +1 -130
- package/webpack/babel-plugins/remove-client.plugin.js +3 -29
- package/webpack/babel-plugins/remove-ssr.plugin.js +3 -19
- package/webpack/babel.config.client.js +1 -24
- package/webpack/babel.config.ssr.js +1 -24
- package/webpack/base.babel.js +8 -167
- package/webpack/development.client.babel.js +4 -82
- package/webpack/production.client.babel.js +4 -78
- package/webpack/production.ssr.babel.js +4 -61
- package/webpack/scssParams.js +5 -31
- 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/router/index.js +0 -32
- package/scripts/prepare.js +0 -19
- package/scripts/registerAliases.js +0 -30
- package/server/mainIndex.js +0 -65
- package/server/mainServer.js +0 -70
- package/server/renderer/userAgentUtil.js +0 -55
- 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/webpack/babel.config.js +0 -20
- package/webpack/plugins/mime-types.js +0 -82
- package/webpack/plugins/route-manifest-copy.js +0 -122
- package/webpack/plugins/route-manifest-plugin.js +0 -122
- package/webpack/plugins/upload-assets-plugin.js +0 -181
package/package.json
CHANGED
|
@@ -1,85 +1,91 @@
|
|
|
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
|
-
|
|
2
|
+
"name": "catalyst-core-internal",
|
|
3
|
+
"version": "0.0.1-beta.21",
|
|
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
|
+
"prepublishOnly": "npm i && npm run prepare",
|
|
12
|
+
"lint": "eslint .",
|
|
13
|
+
"prettify": "prettier . --write",
|
|
14
|
+
"lint-staged": "lint-staged"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@babel/cli": "^7.23.0",
|
|
19
|
+
"@babel/core": "^7.23.2",
|
|
20
|
+
"@babel/node": "^7.22.19",
|
|
21
|
+
"@babel/preset-env": "^7.23.2",
|
|
22
|
+
"@babel/preset-react": "^7.22.15",
|
|
23
|
+
"@babel/register": "^7.22.15",
|
|
24
|
+
"@dr.pogodin/css-modules-require-hook": "^4.7.3",
|
|
25
|
+
"@loadable/babel-plugin": "^5.16.1",
|
|
26
|
+
"@loadable/component": "^5.15.3",
|
|
27
|
+
"@loadable/server": "^5.16.1",
|
|
28
|
+
"@loadable/webpack-plugin": "^5.15.2",
|
|
29
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
30
|
+
"@svgr/webpack": "^8.1.0",
|
|
31
|
+
"@tata1mg/router": "^0.0.1-beta.1",
|
|
32
|
+
"app-root-path": "^3.1.0",
|
|
33
|
+
"babel-loader": "^9.1.3",
|
|
34
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
35
|
+
"body-parser": "^1.20.2",
|
|
36
|
+
"chokidar": "^3.6.0",
|
|
37
|
+
"compression": "^1.7.4",
|
|
38
|
+
"cookie-parser": "^1.4.6",
|
|
39
|
+
"css-hot-loader": "^1.4.4",
|
|
40
|
+
"css-loader": "^6.8.1",
|
|
41
|
+
"express": "^4.18.2",
|
|
42
|
+
"express-static-gzip": "^2.1.7",
|
|
43
|
+
"file-loader": "^6.2.0",
|
|
44
|
+
"html-loader": "^4.2.0",
|
|
45
|
+
"img-loader": "^4.0.0",
|
|
46
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
47
|
+
"module-alias": "^2.2.3",
|
|
48
|
+
"picocolors": "^1.0.0",
|
|
49
|
+
"postcss-loader": "^7.3.3",
|
|
50
|
+
"react": "^18.2.0",
|
|
51
|
+
"react-dom": "^18.2.0",
|
|
52
|
+
"react-redux": "^8.1.3",
|
|
53
|
+
"react-refresh": "^0.14.0",
|
|
54
|
+
"react-router-dom": "^6.16.0",
|
|
55
|
+
"redux": "^4.2.1",
|
|
56
|
+
"sass": "^1.69.5",
|
|
57
|
+
"sass-loader": "^13.3.2",
|
|
58
|
+
"sass-resources-loader": "^2.2.5",
|
|
59
|
+
"ua-parser-js": "^1.0.37",
|
|
60
|
+
"url": "^0.11.3",
|
|
61
|
+
"url-loader": "^4.1.1",
|
|
62
|
+
"webpack": "^5.88.2",
|
|
63
|
+
"webpack-bundle-analyzer": "^4.9.1",
|
|
64
|
+
"webpack-cli": "^5.1.4",
|
|
65
|
+
"webpack-dev-server": "^4.15.2",
|
|
66
|
+
"webpack-merge": "^5.9.0",
|
|
67
|
+
"webpack-node-externals": "^3.0.0",
|
|
68
|
+
"winston": "^3.11.0",
|
|
69
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
73
|
+
"@commitlint/cli": "^19.3.0",
|
|
74
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
75
|
+
"eslint": "^8.26.0",
|
|
76
|
+
"eslint-plugin-babel": "^5.3.1",
|
|
77
|
+
"eslint-plugin-react": "^7.34.1",
|
|
78
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
79
|
+
"eslint-plugin-risxss": "^2.1.0",
|
|
80
|
+
"eslint-plugin-security": "^3.0.0",
|
|
81
|
+
"husky": "^9.0.11",
|
|
82
|
+
"lint-staged": "^15.2.2",
|
|
83
|
+
"prettier": "^3.2.5"
|
|
84
|
+
},
|
|
85
|
+
"lint-staged": {
|
|
86
|
+
"*.{js,jsx}": [
|
|
87
|
+
"eslint .",
|
|
88
|
+
"prettier . --write"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
85
91
|
}
|
package/router/ClientRouter.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _router = require("@tata1mg/router");
|
|
8
|
-
var _utils = require("@routes/utils.js");
|
|
9
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _router=require("@tata1mg/router");var _utils=require("@routes/utils.js");/**
|
|
10
2
|
* @returns returns browsers routers (client routes)
|
|
11
|
-
*/
|
|
12
|
-
const clientRouter = ({
|
|
13
|
-
store,
|
|
14
|
-
routerInitialState
|
|
15
|
-
}) => (0, _router.createBrowserRouter)((0, _utils.preparedRoutes)({
|
|
16
|
-
store,
|
|
17
|
-
routerInitialState
|
|
18
|
-
}));
|
|
19
|
-
var _default = exports.default = clientRouter;
|
|
3
|
+
*/const clientRouter=({store,routerInitialState})=>(0,_router.createBrowserRouter)((0,_utils.preparedRoutes)({store,routerInitialState}));var _default=exports.default=clientRouter;
|
package/router/ServerRouter.js
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _router = require("@tata1mg/router");
|
|
8
|
-
var _utils = require("@routes/utils.js");
|
|
9
|
-
const ServerRouter = reduxData => {
|
|
10
|
-
const {
|
|
11
|
-
store,
|
|
12
|
-
intialData
|
|
13
|
-
} = reduxData;
|
|
14
|
-
return (0, _router.useRoutes)((0, _utils.preparedRoutes)({
|
|
15
|
-
store,
|
|
16
|
-
routerInitialState: intialData
|
|
17
|
-
}));
|
|
18
|
-
};
|
|
19
|
-
var _default = exports.default = ServerRouter;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _router=require("@tata1mg/router");var _utils=require("@routes/utils.js");const ServerRouter=reduxData=>{const{store,intialData}=reduxData;return(0,_router.useRoutes)((0,_utils.preparedRoutes)({store,routerInitialState:intialData}));};var _default=exports.default=ServerRouter;
|
package/router.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _router = require("@tata1mg/router");
|
|
7
|
-
Object.keys(_router).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _router[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _router[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _router=require("@tata1mg/router");Object.keys(_router).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_router[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _router[key];}});});
|
package/scripts/build.js
CHANGED
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
const {
|
|
9
|
-
spawnSync
|
|
10
|
-
} = require("child_process");
|
|
11
|
-
const path = require("path");
|
|
12
|
-
const {
|
|
13
|
-
name
|
|
14
|
-
} = require(`${process.env.PWD}/package.json`);
|
|
15
|
-
|
|
16
|
-
/**
|
|
1
|
+
"use strict";const path=require("path");const{spawnSync}=require("child_process");const{green,cyan,yellow}=require("picocolors");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);const{arrayToObject,printBundleInformation}=require("./scriptUtils.js");/**
|
|
17
2
|
* @description - creates a production build of the application.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
start();
|
|
3
|
+
*/function build(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
|
|
4
|
+
node ./scripts/checkVersion
|
|
5
|
+
rm -rf ${process.env.PWD}/${BUILD_OUTPUT_PATH} & node ./scripts/loadScriptsBeforeServerStarts.js
|
|
6
|
+
APPLICATION=${name||"catalyst_app"} webpack --config ./webpack/production.client.babel.js --progress
|
|
7
|
+
APPLICATION=${name||"catalyst_app"} SSR=true webpack --config ./webpack/production.ssr.babel.js
|
|
8
|
+
APPLICATION=${name||"catalyst_app"} npx babel ./server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --ignore '**/*.test.js,./server/renderer/handler.js' --quiet
|
|
9
|
+
APPLICATION=${name||"catalyst_app"} npx babel ${process.env.PWD}/server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --quiet
|
|
10
|
+
`;console.log("Creating an optimized production build...");const result=spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:false,...argumentsObject}});if(result.error){console.error("Error occurred:",result.error);}else{console.log(green("Compiled successfully."));console.log("\nFile sizes after gzip:\n");printBundleInformation();console.log(`\nThe ${cyan(BUILD_OUTPUT_PATH)} folder is ready to be deployed.`);console.log("You may serve it with a serve command:");console.log(cyan("\n npm run serve"));console.log("\nFind out more about deployment here:");console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));}}build();
|
package/scripts/checkVersion.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";const path=require("path");const{spawnSync}=require("child_process");const{green,cyan,yellow}=require("picocolors");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);const{arrayToObject,printBundleInformation}=require("./scriptUtils.js");/**
|
|
2
|
+
* @description - creates a production build of the application.
|
|
3
|
+
*/function devBuild(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
|
|
4
|
+
node ./scripts/checkVersion
|
|
5
|
+
rm -rf ${process.env.PWD}/${BUILD_OUTPUT_PATH} & node ./scripts/loadScriptsBeforeServerStarts.js
|
|
6
|
+
APPLICATION=${name||"catalyst_app"} webpack --config ./webpack/production.client.babel.js --progress
|
|
7
|
+
APPLICATION=${name||"catalyst_app"} SSR=true webpack --config ./webpack/production.ssr.babel.js
|
|
8
|
+
APPLICATION=${name||"catalyst_app"} npx babel ./server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --ignore '**/*.test.js,./server/renderer/handler.js' --quiet
|
|
9
|
+
APPLICATION=${name||"catalyst_app"} npx babel ${process.env.PWD}/server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --quiet
|
|
10
|
+
`;console.log("Creating an optimized local build...");const result=spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,...argumentsObject}});if(result.error){console.error("Error occurred:",result.error);}else{console.log(green("Compiled successfully."));console.log("\nFile sizes after gzip:\n");printBundleInformation();console.log(`\nThe ${cyan(BUILD_OUTPUT_PATH)} folder is ready to be deployed.`);console.log("You may serve it with a serve command:");console.log(cyan("\n npm run devServe"));console.log("\nFind out more about deployment here:");console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));}}devBuild();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);/**
|
|
2
|
+
* @description - Serves production build of the application.
|
|
3
|
+
*/function devServe(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
|
|
4
|
+
APPLICATION=${name||"catalyst_app"} node -r ./scripts/loadScriptsBeforeServerStarts.js ${process.env.PWD}/${BUILD_OUTPUT_PATH}/startServer.js
|
|
5
|
+
`;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,...argumentsObject}});}devServe();
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
const appConfig = require(`${process.env.src_path}/config/config.json`);
|
|
8
|
-
const {
|
|
9
|
-
validateConfigFile
|
|
10
|
-
} = require("./validator.js");
|
|
11
|
-
|
|
12
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;const appConfig=require(`${process.env.src_path}/config/config.json`);const{validateConfigFile}=require("./validator.js");/**
|
|
13
2
|
* @description stores all config.json key value into process.env before server starts.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
for (let k in appConfig) {
|
|
18
|
-
// below code provides support for object handling present in config.
|
|
19
|
-
// However, for usage on client the client logic in define plugin needs to be checked and updated
|
|
20
|
-
process.env[k] = typeof appConfig[k] === "object" ? JSON.stringify(appConfig[k]) : appConfig[k];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
var _default = exports.default = loadEnvironmentVariables;
|
|
3
|
+
*/const loadEnvironmentVariables=()=>{if(validateConfigFile(appConfig)){for(let k in appConfig){// below code provides support for object handling present in config.
|
|
4
|
+
// However, for usage on client the client logic in define plugin needs to be checked and updated
|
|
5
|
+
process.env[k]=typeof appConfig[k]==="object"?JSON.stringify(appConfig[k]):appConfig[k];}}};var _default=exports.default=loadEnvironmentVariables;
|
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _loadEnvironmentVariables = _interopRequireDefault(require("./loadEnvironmentVariables"));
|
|
7
|
-
var _logger = require("../logger.js");
|
|
8
|
-
var _validator = require("./validator.js");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const {
|
|
11
|
-
cssModulesIdentifierDev
|
|
12
|
-
} = require(`${__dirname}/../config.json`);
|
|
13
|
-
const {
|
|
14
|
-
_moduleAliases
|
|
15
|
-
} = require(`${process.env.src_path}/package.json`);
|
|
16
|
-
// stores your config keys in enviorments variables
|
|
17
|
-
(0, _loadEnvironmentVariables.default)();
|
|
18
|
-
|
|
19
|
-
// creates logger instance with provided config and stores them at global level.
|
|
20
|
-
(0, _logger.configureLogger)({
|
|
21
|
-
enableDebugLogs: process.env.ENABLE_DEBUG_LOGS,
|
|
22
|
-
enableFileLogging: process.env.ENABLE_FILE_LOGGING,
|
|
23
|
-
enableConsoleLogging: process.env.ENABLE_CONSOLE_LOGGING
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// resolves module alias imports
|
|
27
|
-
if ((0, _validator.validateModuleAlias)(_moduleAliases)) {
|
|
28
|
-
_moduleAlias.default.addAliases(Object.keys(_moduleAliases || []).reduce((resultMap, aliasName) => {
|
|
29
|
-
const aliasPath = _moduleAliases[aliasName];
|
|
30
|
-
if (aliasPath.includes("server")) {
|
|
31
|
-
if (process.env.NODE_ENV !== "production") {
|
|
32
|
-
resultMap[aliasName] = _path.default.join(process.env.src_path, aliasPath);
|
|
33
|
-
} else {
|
|
34
|
-
resultMap[aliasName] = _path.default.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH);
|
|
35
|
-
}
|
|
36
|
-
} else resultMap[aliasName] = _path.default.join(process.env.src_path, aliasPath);
|
|
37
|
-
return resultMap;
|
|
38
|
-
}, {}));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// compile css-variables in realtime in dev mode.
|
|
42
|
-
if (process.env.NODE_ENV === "development") (0, _cssModulesRequireHook.default)({
|
|
43
|
-
extensions: [".scss", ".css"],
|
|
44
|
-
generateScopedName: cssModulesIdentifierDev,
|
|
45
|
-
devMode: true,
|
|
46
|
-
ignore: _path.default.join(process.env.src_path, "/src/static/css/base/(?!.*.scss$).*")
|
|
47
|
-
});
|
|
1
|
+
"use strict";var _cssModulesRequireHook=_interopRequireDefault(require("@dr.pogodin/css-modules-require-hook"));var _path=_interopRequireDefault(require("path"));var _moduleAlias=_interopRequireDefault(require("module-alias"));var _loadEnvironmentVariables=_interopRequireDefault(require("./loadEnvironmentVariables"));var _logger=require("../logger.js");var _validator=require("./validator.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{cssModulesIdentifierDev}=require(`${__dirname}/../config.json`);const{_moduleAliases}=require(`${process.env.src_path}/package.json`);// stores your config keys in enviorments variables
|
|
2
|
+
(0,_loadEnvironmentVariables.default)();// creates logger instance with provided config and stores them at global level.
|
|
3
|
+
(0,_logger.configureLogger)({enableDebugLogs:process.env.ENABLE_DEBUG_LOGS,enableFileLogging:process.env.ENABLE_FILE_LOGGING,enableConsoleLogging:process.env.ENABLE_CONSOLE_LOGGING});// resolves module alias imports
|
|
4
|
+
if((0,_validator.validateModuleAlias)(_moduleAliases)){_moduleAlias.default.addAliases(Object.keys(_moduleAliases||[]).reduce((resultMap,aliasName)=>{const aliasPath=_moduleAliases[aliasName];if(aliasPath.includes("server")){if(process.env.NODE_ENV!=="production"){resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);}else{resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}}else resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);return resultMap;},{}));}// compile css-variables in realtime in dev mode.
|
|
5
|
+
if(process.env.NODE_ENV==="development")(0,_cssModulesRequireHook.default)({extensions:[".scss",".css"],generateScopedName:cssModulesIdentifierDev,devMode:true,ignore:_path.default.join(process.env.src_path,"/src/static/css/base/(?!.*.scss$).*")});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import moduleAlias from "module-alias"
|
|
3
|
+
import { _moduleAliases } from "../../package.json"
|
|
4
|
+
|
|
5
|
+
export const getTemplatePath = (file) => {
|
|
6
|
+
if (file) return path.resolve(__dirname, process.env.src_path, file)
|
|
7
|
+
else return path.resolve(__dirname, process.env.src_path)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getCatalystPath = (file) => {
|
|
11
|
+
if (file) return path.resolve(__dirname, "../", file)
|
|
12
|
+
else return path.resolve(__dirname, "..")
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
moduleAlias.addAliases(
|
|
16
|
+
Object.keys(_moduleAliases || []).reduce((resultMap, aliasName) => {
|
|
17
|
+
const aliasPath = _moduleAliases[aliasName]
|
|
18
|
+
|
|
19
|
+
if (aliasName.includes("@template")) {
|
|
20
|
+
resultMap[aliasName] = path.join(__dirname, process.env.src_path, aliasPath)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (aliasName.includes("@catalyst")) {
|
|
24
|
+
resultMap[aliasName] = path.join(__dirname, "../", aliasPath)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return resultMap
|
|
28
|
+
}, {})
|
|
29
|
+
)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.arrayToObject=arrayToObject;exports.printBundleInformation=void 0;const fs=require("fs");const path=require("path");const util=require("node:util");const{gray,cyan}=require("picocolors");const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);// Function to get file size synchronously
|
|
2
|
+
function getFileSizeSync(filePath){try{const stats=fs.statSync(filePath);return stats.size;}catch(err){console.error(`Error getting bundle information for file ${filePath}: ${err}`);return null;}}const printBundleInformation=()=>{let bundleList=[];const directoryPath=path.join(process.env.PWD,`${BUILD_OUTPUT_PATH}/public`);try{const files=fs.readdirSync(directoryPath);files.forEach(file=>{if(!file.includes("txt")&&!file.includes("json")){const filePath=path.join(directoryPath,file);const fileSize=getFileSizeSync(filePath);if(fileSize!==null){bundleList.push({file,fileSize});}}});}catch(err){console.error("Unable to scan build folder: "+err);}bundleList.sort((a,b)=>b.fileSize-a.fileSize);bundleList.forEach(({file,fileSize})=>{const fileName=`${gray(`${BUILD_OUTPUT_PATH}/public/`)}${cyan(file)}`;const fileSizeInKb=(fileSize/1024).toFixed(2);const size=`\t${fileSizeInKb} kB`.padEnd(16);console.log(util.format(size,fileName));});};exports.printBundleInformation=printBundleInformation;function arrayToObject(array){const obj={};array.forEach(item=>{const[key,value]=item.split("=");if(value)obj[key]=value;});return obj;}
|
package/scripts/serve.js
CHANGED
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
const {
|
|
9
|
-
spawnSync
|
|
10
|
-
} = require("child_process");
|
|
11
|
-
const path = require("path");
|
|
12
|
-
const {
|
|
13
|
-
name
|
|
14
|
-
} = require(`${process.env.PWD}/package.json`);
|
|
15
|
-
|
|
16
|
-
/**
|
|
1
|
+
"use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);/**
|
|
17
2
|
* @description - Serves production build of the application.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const dirname = path.resolve(__dirname, "../");
|
|
22
|
-
spawnSync("npm", ["run", "serve", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
|
|
23
|
-
cwd: dirname,
|
|
24
|
-
stdio: "inherit",
|
|
25
|
-
env: _objectSpread(_objectSpread({}, process.env), {}, {
|
|
26
|
-
src_path: process.env.PWD
|
|
27
|
-
})
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
start();
|
|
3
|
+
*/function serve(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
|
|
4
|
+
APPLICATION=${name||"catalyst_app"} node -r ./scripts/loadScriptsBeforeServerStarts.js ${process.env.PWD}/${BUILD_OUTPUT_PATH}/startServer.js
|
|
5
|
+
`;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:false,...argumentsObject}});}serve();
|
package/scripts/start.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
const {
|
|
9
|
-
spawnSync
|
|
10
|
-
} = require("child_process");
|
|
11
|
-
const path = require("path");
|
|
12
|
-
|
|
13
|
-
/**
|
|
1
|
+
"use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.env.PWD}/package.json`);/**
|
|
14
2
|
* @description - starts webpack dev server and node server.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
cwd: dirname,
|
|
20
|
-
stdio: "inherit",
|
|
21
|
-
env: _objectSpread(_objectSpread({}, process.env), {}, {
|
|
22
|
-
src_path: process.env.PWD
|
|
23
|
-
})
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
start();
|
|
3
|
+
*/function start(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
|
|
4
|
+
node ./scripts/checkVersion
|
|
5
|
+
npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js webpack/development.client.babel --no-warnings=ExperimentalWarning --no-warnings=BABEL & npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js ./server/startServer.js --watch-path=${process.env.PWD}/server --watch-path=${process.env.PWD}/src --ignore='__IGNORE__' --no-warnings=ExperimentalWarning --no-warnings=BABEL
|
|
6
|
+
`;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,NODE_ENV:"development",IS_DEV_COMMAND:false,APPLICATION:name||"catalyst_app",...argumentsObject}});}start();
|