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.
Files changed (110) hide show
  1. package/.eslintignore +9 -0
  2. package/.eslintrc +91 -0
  3. package/.husky/commit-msg +1 -0
  4. package/.husky/pre-commit +1 -0
  5. package/README.md +45 -43
  6. package/babel.config.json +2 -5
  7. package/bin/catalyst.js +33 -35
  8. package/caching.js +1 -16
  9. package/changelog.md +12 -0
  10. package/commitlint.config.js +11 -0
  11. package/config.json +1 -1
  12. package/index.js +1 -16
  13. package/license +10 -0
  14. package/logger.js +3 -89
  15. package/package.json +89 -83
  16. package/router/ClientRouter.js +2 -18
  17. package/router/ServerRouter.js +1 -19
  18. package/router.js +1 -16
  19. package/scripts/build.js +9 -28
  20. package/scripts/checkVersion.js +1 -5
  21. package/scripts/devBuild.js +10 -0
  22. package/scripts/devServe.js +5 -0
  23. package/scripts/loadEnvironmentVariables.js +4 -23
  24. package/scripts/loadScriptsBeforeServerStarts.js +5 -47
  25. package/scripts/resiterAliases.js +29 -0
  26. package/scripts/scriptUtils.js +2 -0
  27. package/scripts/serve.js +4 -29
  28. package/scripts/start.js +5 -25
  29. package/scripts/validator.js +1 -130
  30. package/server/expressServer.js +8 -49
  31. package/server/renderer/document/Body.js +6 -28
  32. package/server/renderer/document/Head.js +5 -39
  33. package/server/renderer/document/index.js +1 -27
  34. package/server/renderer/extract.js +6 -72
  35. package/server/renderer/handler.js +14 -241
  36. package/server/renderer/index.js +1 -12
  37. package/server/renderer/render.js +8 -60
  38. package/server/startServer.js +6 -65
  39. package/server/utils/userAgentUtil.js +3 -49
  40. package/server/utils/validator.js +1 -130
  41. package/webpack/babel-plugins/remove-client.plugin.js +3 -29
  42. package/webpack/babel-plugins/remove-ssr.plugin.js +3 -19
  43. package/webpack/babel.config.client.js +1 -24
  44. package/webpack/babel.config.ssr.js +1 -24
  45. package/webpack/base.babel.js +8 -167
  46. package/webpack/development.client.babel.js +4 -82
  47. package/webpack/production.client.babel.js +4 -78
  48. package/webpack/production.ssr.babel.js +4 -61
  49. package/webpack/scssParams.js +5 -31
  50. package/packages/create-framework-app/templates/redux-js/node_modules/@babel/core/lib/config/caching.js +0 -261
  51. package/packages/create-framework-app/templates/redux-js/node_modules/@remix-run/router/dist/router.js +0 -4327
  52. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/router.js +0 -15
  53. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/src/router.js +0 -1
  54. package/packages/create-framework-app/templates/redux-js/node_modules/http-proxy-middleware/dist/router.js +0 -46
  55. package/router/index.js +0 -32
  56. package/scripts/prepare.js +0 -19
  57. package/scripts/registerAliases.js +0 -30
  58. package/server/mainIndex.js +0 -65
  59. package/server/mainServer.js +0 -70
  60. package/server/renderer/userAgentUtil.js +0 -55
  61. package/types/caching.d.ts +0 -1
  62. package/types/config/config.d.ts +0 -19
  63. package/types/index.d.ts +0 -1
  64. package/types/logger/index.d.ts +0 -14
  65. package/types/reducer/index.d.ts +0 -22
  66. package/types/reducer/loadableConfigReducer.d.ts +0 -9
  67. package/types/router/ClientRouter.d.ts +0 -5
  68. package/types/router/ServerRouter.d.ts +0 -7
  69. package/types/router/index.d.ts +0 -8
  70. package/types/router.d.ts +0 -1
  71. package/types/scripts/build.d.ts +0 -1
  72. package/types/scripts/loadEnvironmentVariables.d.ts +0 -5
  73. package/types/scripts/loadScriptsBeforeServerStarts.d.ts +0 -1
  74. package/types/scripts/prepare.d.ts +0 -1
  75. package/types/scripts/registerAliases.d.ts +0 -1
  76. package/types/scripts/serve.d.ts +0 -1
  77. package/types/scripts/start.d.ts +0 -1
  78. package/types/scripts/validator.d.ts +0 -9
  79. package/types/scripts/verifyConfig.d.ts +0 -1
  80. package/types/server/mainIndex.d.ts +0 -1
  81. package/types/server/mainServer.d.ts +0 -2
  82. package/types/server/renderer/document/Body.d.ts +0 -11
  83. package/types/server/renderer/document/Head.d.ts +0 -11
  84. package/types/server/renderer/document/index.d.ts +0 -2
  85. package/types/server/renderer/extract.d.ts +0 -18
  86. package/types/server/renderer/handler.d.ts +0 -6
  87. package/types/server/renderer/index.d.ts +0 -2
  88. package/types/server/renderer/render.d.ts +0 -38
  89. package/types/server/renderer/userAgentUtil.d.ts +0 -1
  90. package/types/store/index.d.ts +0 -11
  91. package/types/store/index.dev.d.ts +0 -8
  92. package/types/store/index.prod.d.ts +0 -8
  93. package/types/webpack/babel-plugins/remove-client.plugin.d.ts +0 -10
  94. package/types/webpack/babel-plugins/remove-ssr.plugin.d.ts +0 -10
  95. package/types/webpack/babel.config.client.d.ts +0 -21
  96. package/types/webpack/babel.config.d.ts +0 -16
  97. package/types/webpack/babel.config.ssr.d.ts +0 -21
  98. package/types/webpack/base.babel.d.ts +0 -184
  99. package/types/webpack/development.client.babel.d.ts +0 -1
  100. package/types/webpack/plugins/mime-types.d.ts +0 -78
  101. package/types/webpack/plugins/route-manifest-plugin.d.ts +0 -1
  102. package/types/webpack/plugins/upload-assets-plugin.d.ts +0 -1
  103. package/types/webpack/production.client.babel.d.ts +0 -174
  104. package/types/webpack/production.ssr.babel.d.ts +0 -2
  105. package/types/webpack/scssParams.d.ts +0 -2
  106. package/webpack/babel.config.js +0 -20
  107. package/webpack/plugins/mime-types.js +0 -82
  108. package/webpack/plugins/route-manifest-copy.js +0 -122
  109. package/webpack/plugins/route-manifest-plugin.js +0 -122
  110. package/webpack/plugins/upload-assets-plugin.js +0 -181
package/package.json CHANGED
@@ -1,85 +1,91 @@
1
1
  {
2
- "name": "catalyst-core-internal",
3
- "version": "0.0.1-beta.2",
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",
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",
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 & node ./scripts/loadScriptsBeforeServerStarts.js",
16
- "build:client": "APPLICATION=${npm_config_app_name} NODE_ENV=production webpack --config ./webpack/production.client.babel.js --progress",
17
- "build:ssr": "APPLICATION=${npm_config_app_name} NODE_ENV=production SSR=true webpack --config ./webpack/production.ssr.babel.js --progress",
18
- "build:server": "APPLICATION=${npm_config_app_name} NODE_ENV=production npx babel ./server --out-dir ${npm_config_src_path}/build --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",
19
- "serve": "APPLICATION=${npm_config_app_name} NODE_ENV=production node -r ./scripts/loadScriptsBeforeServerStarts.js ${npm_config_src_path}/build/startServer.js",
20
- "prepublishOnly": "npm i && npm run prepare"
21
- },
22
- "license": "ISC",
23
- "dependencies": {
24
- "@babel/cli": "^7.23.0",
25
- "@babel/core": "^7.23.2",
26
- "@babel/node": "^7.22.19",
27
- "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
28
- "@babel/plugin-transform-react-jsx": "^7.22.15",
29
- "@babel/preset-env": "^7.23.2",
30
- "@babel/preset-react": "^7.22.15",
31
- "@babel/register": "^7.22.15",
32
- "@loadable/babel-plugin": "^5.16.1",
33
- "@loadable/component": "^5.15.3",
34
- "@loadable/server": "^5.16.1",
35
- "@loadable/webpack-plugin": "^5.15.2",
36
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
37
- "@svgr/webpack": "^8.1.0",
38
- "@tata1mg/router": "^0.0.1-beta.0",
39
- "app-root-path": "^3.1.0",
40
- "babel-loader": "^9.1.3",
41
- "babel-plugin-dynamic-import-node": "^2.3.3",
42
- "babel-plugin-syntax-dynamic-import": "^6.18.0",
43
- "babel-plugin-transform-class-properties": "^6.24.1",
44
- "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
45
- "babel-plugin-transform-export-extensions": "^6.22.0",
46
- "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
47
- "body-parser": "^1.20.2",
48
- "chokidar": "^3.6.0",
49
- "compression": "^1.7.4",
50
- "cookie-parser": "^1.4.6",
51
- "css-hot-loader": "^1.4.4",
52
- "css-loader": "^6.8.1",
53
- "css-modules-require-hook": "^4.2.3",
54
- "express": "^4.18.2",
55
- "express-static-gzip": "^2.1.7",
56
- "file-loader": "^6.2.0",
57
- "html-loader": "^4.2.0",
58
- "img-loader": "^4.0.0",
59
- "isomorphic-dompurify": "^1.13.0",
60
- "mini-css-extract-plugin": "^2.7.6",
61
- "module-alias": "^2.2.3",
62
- "picocolors": "^1.0.0",
63
- "postcss-loader": "^7.3.3",
64
- "react": "^18.2.0",
65
- "react-dom": "^18.2.0",
66
- "react-redux": "^8.1.3",
67
- "react-refresh": "^0.14.0",
68
- "react-router-dom": "^6.16.0",
69
- "redux": "^4.2.1",
70
- "sass": "^1.69.5",
71
- "sass-loader": "^13.3.2",
72
- "sass-resources-loader": "^2.2.5",
73
- "ua-parser-js": "^1.0.37",
74
- "url": "^0.11.3",
75
- "url-loader": "^4.1.1",
76
- "webpack": "^5.88.2",
77
- "webpack-bundle-analyzer": "^4.9.1",
78
- "webpack-cli": "^5.1.4",
79
- "webpack-dev-server": "^4.15.1",
80
- "webpack-merge": "^5.9.0",
81
- "webpack-node-externals": "^3.0.0",
82
- "winston": "^3.11.0",
83
- "winston-daily-rotate-file": "^5.0.0"
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
  }
@@ -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;
@@ -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
- function start() {
20
- const dirname = path.resolve(__dirname, "../");
21
- spawnSync("npm", ["run", "build", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
22
- cwd: dirname,
23
- stdio: "inherit",
24
- env: _objectSpread(_objectSpread({}, process.env), {}, {
25
- src_path: process.env.PWD
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();
@@ -1,5 +1 @@
1
- "use strict";
2
-
3
- if (process.versions.node.split(".")[0] < 20) {
4
- console.error("\x1b[31m%s\x1b[0m", "use node version >=20");
5
- }
1
+ "use strict";if(process.versions.node.split(".")[0]<20){console.error("\x1b[31m%s\x1b[0m","use node version >=20");}
@@ -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
- const loadEnvironmentVariables = () => {
16
- if (validateConfigFile(appConfig)) {
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
- var _cssModulesRequireHook = _interopRequireDefault(require("css-modules-require-hook"));
4
- var _path = _interopRequireDefault(require("path"));
5
- var _moduleAlias = _interopRequireDefault(require("module-alias"));
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
- function start() {
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
- function start() {
17
- const dirname = path.resolve(__dirname, "../");
18
- spawnSync("npm", ["run", "start", `--src_path=${process.env.PWD}`], {
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();