catalyst-core 0.0.1-beta.2 → 0.0.1-beta.4

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 (101) hide show
  1. package/.eslintignore +9 -0
  2. package/.eslintrc +92 -0
  3. package/README.md +58 -43
  4. package/babel.config.json +1 -5
  5. package/bin/catalyst.js +35 -35
  6. package/changelog.md +26 -0
  7. package/config.json +1 -2
  8. package/{LICENSE → license} +2 -1
  9. package/{logger/index.js → logger.js} +13 -10
  10. package/package.json +87 -85
  11. package/router/ClientRouter.js +10 -6
  12. package/router/ServerRouter.js +2 -11
  13. package/scripts/build.js +26 -11
  14. package/scripts/checkVersion.js +5 -0
  15. package/scripts/devBuild.js +42 -0
  16. package/scripts/devServe.js +43 -0
  17. package/scripts/loadEnvironmentVariables.js +8 -21
  18. package/scripts/loadScriptsBeforeServerStarts.js +13 -21
  19. package/scripts/serve.js +27 -11
  20. package/scripts/start.js +19 -12
  21. package/scripts/validator.js +39 -11
  22. package/server/expressServer.js +50 -0
  23. package/server/renderer/document/Body.js +17 -18
  24. package/server/renderer/document/Head.js +7 -8
  25. package/server/renderer/document/index.js +2 -0
  26. package/server/renderer/extract.js +25 -24
  27. package/server/renderer/handler.js +220 -208
  28. package/server/renderer/index.js +6 -7
  29. package/server/renderer/render.js +32 -19
  30. package/server/startServer.js +66 -0
  31. package/server/utils/metaTags.js +13 -0
  32. package/server/utils/userAgentUtil.js +51 -0
  33. package/server/utils/validator.js +39 -10
  34. package/webpack/babel-plugins/remove-client.plugin.js +1 -1
  35. package/webpack/babel-plugins/remove-ssr.plugin.js +1 -1
  36. package/webpack/babel.config.client.js +3 -3
  37. package/webpack/babel.config.ssr.js +1 -1
  38. package/webpack/base.babel.js +37 -36
  39. package/webpack/development.client.babel.js +11 -8
  40. package/webpack/production.client.babel.js +1 -2
  41. package/webpack/production.ssr.babel.js +3 -3
  42. package/webpack/scssParams.js +35 -15
  43. package/.prettierignore +0 -2
  44. package/.prettierrc.json +0 -7
  45. package/checkVersion.js +0 -3
  46. package/config/config.js +0 -24
  47. package/packages/create-framework-app/node_modules/.package-lock.json +0 -249
  48. package/packages/create-framework-app/templates/redux-js/node_modules/@babel/core/lib/config/caching.js +0 -261
  49. package/packages/create-framework-app/templates/redux-js/node_modules/@remix-run/router/dist/router.js +0 -4327
  50. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/router.js +0 -15
  51. package/packages/create-framework-app/templates/redux-js/node_modules/http-proxy-middleware/dist/router.js +0 -46
  52. package/reducer/index.js +0 -88
  53. package/reducer/loadableConfigReducer.js +0 -19
  54. package/store/index.dev.js +0 -73
  55. package/store/index.js +0 -25
  56. package/store/index.prod.js +0 -66
  57. package/types/caching.d.ts +0 -1
  58. package/types/config/config.d.ts +0 -19
  59. package/types/index.d.ts +0 -1
  60. package/types/logger/index.d.ts +0 -14
  61. package/types/reducer/index.d.ts +0 -22
  62. package/types/reducer/loadableConfigReducer.d.ts +0 -9
  63. package/types/router/ClientRouter.d.ts +0 -5
  64. package/types/router/ServerRouter.d.ts +0 -7
  65. package/types/router/index.d.ts +0 -8
  66. package/types/router.d.ts +0 -1
  67. package/types/scripts/build.d.ts +0 -1
  68. package/types/scripts/loadEnvironmentVariables.d.ts +0 -5
  69. package/types/scripts/loadScriptsBeforeServerStarts.d.ts +0 -1
  70. package/types/scripts/prepare.d.ts +0 -1
  71. package/types/scripts/registerAliases.d.ts +0 -1
  72. package/types/scripts/serve.d.ts +0 -1
  73. package/types/scripts/start.d.ts +0 -1
  74. package/types/scripts/validator.d.ts +0 -9
  75. package/types/scripts/verifyConfig.d.ts +0 -1
  76. package/types/server/mainIndex.d.ts +0 -1
  77. package/types/server/mainServer.d.ts +0 -2
  78. package/types/server/renderer/document/Body.d.ts +0 -11
  79. package/types/server/renderer/document/Head.d.ts +0 -11
  80. package/types/server/renderer/document/index.d.ts +0 -2
  81. package/types/server/renderer/extract.d.ts +0 -18
  82. package/types/server/renderer/handler.d.ts +0 -6
  83. package/types/server/renderer/index.d.ts +0 -2
  84. package/types/server/renderer/render.d.ts +0 -38
  85. package/types/server/renderer/userAgentUtil.d.ts +0 -1
  86. package/types/store/index.d.ts +0 -11
  87. package/types/store/index.dev.d.ts +0 -8
  88. package/types/store/index.prod.d.ts +0 -8
  89. package/types/webpack/babel-plugins/remove-client.plugin.d.ts +0 -10
  90. package/types/webpack/babel-plugins/remove-ssr.plugin.d.ts +0 -10
  91. package/types/webpack/babel.config.client.d.ts +0 -21
  92. package/types/webpack/babel.config.d.ts +0 -16
  93. package/types/webpack/babel.config.ssr.d.ts +0 -21
  94. package/types/webpack/base.babel.d.ts +0 -184
  95. package/types/webpack/development.client.babel.d.ts +0 -1
  96. package/types/webpack/plugins/mime-types.d.ts +0 -78
  97. package/types/webpack/plugins/route-manifest-plugin.d.ts +0 -1
  98. package/types/webpack/plugins/upload-assets-plugin.d.ts +0 -1
  99. package/types/webpack/production.client.babel.d.ts +0 -174
  100. package/types/webpack/production.ssr.babel.d.ts +0 -2
  101. package/types/webpack/scssParams.d.ts +0 -2
package/package.json CHANGED
@@ -1,87 +1,89 @@
1
1
  {
2
- "name": "catalyst-core",
3
- "version": "0.0.1-beta.2",
4
- "main": "index.js",
5
- "description": "1mg framework around react",
6
- "bin": {
7
- "catalyst": "./bin/catalyst.js"
8
- },
9
- "scripts": {
10
- "prepare": "babel src --out-dir . ",
11
- "start": "npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js ./webpack/development.client.babel & npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js ./server/mainIndex.js --watch-path=${npm_config_src_path}/server --watch-path=${npm_config_src_path}/src --ignore=' '",
12
- "build": "rm -rf ${npm_config_src_path}/build & node ./scripts/loadScriptsBeforeServerStarts.js & APPLICATION=${npm_config_app_name} NODE_ENV=production webpack --config ./webpack/production.client.babel.js --progress && APPLICATION=${npm_config_app_name} NODE_ENV=production SSR=true webpack --config ./webpack/production.ssr.babel.js --progress && 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 ",
13
- "serve": "APPLICATION=${npm_config_app_name} NODE_ENV=production node -r ./scripts/loadScriptsBeforeServerStarts.js ${npm_config_src_path}/build/mainIndex.js"
14
- },
15
- "author": "",
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/plugin-proposal-object-rest-spread": "^7.20.7",
22
- "@babel/plugin-transform-react-jsx": "^7.22.15",
23
- "@babel/preset-env": "^7.23.2",
24
- "@babel/preset-react": "^7.22.15",
25
- "@babel/register": "^7.22.15",
26
- "@loadable/babel-plugin": "^5.16.1",
27
- "@loadable/component": "^5.15.3",
28
- "@loadable/server": "^5.16.1",
29
- "@loadable/webpack-plugin": "^5.15.2",
30
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
31
- "@svgr/webpack": "^8.1.0",
32
- "@tata1mg/router": "^0.0.1-alpha.13",
33
- "acorn-loose": "^8.4.0",
34
- "app-root-path": "^3.1.0",
35
- "aws-sdk": "^2.1490.0",
36
- "axios": "^0.19.2",
37
- "babel-loader": "^9.1.3",
38
- "babel-plugin-dynamic-import-node": "^2.3.3",
39
- "babel-plugin-syntax-dynamic-import": "^6.18.0",
40
- "babel-plugin-transform-class-properties": "^6.24.1",
41
- "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
42
- "babel-plugin-transform-export-extensions": "^6.22.0",
43
- "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
44
- "body-parser": "^1.20.2",
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
- "css-modules-require-hook": "^4.2.3",
50
- "dotenv-webpack": "^8.0.1",
51
- "esm-module-alias": "^2.0.3",
52
- "express": "^4.18.2",
53
- "express-static-gzip": "^2.1.7",
54
- "file-loader": "^6.2.0",
55
- "helmet": "^7.0.0",
56
- "html-loader": "^4.2.0",
57
- "img-loader": "^4.0.0",
58
- "isomorphic-dompurify": "^1.13.0",
59
- "lodash.template": "^4.5.0",
60
- "mini-css-extract-plugin": "^2.7.6",
61
- "module-alias": "^2.2.3",
62
- "node-dev": "^7.4.3",
63
- "picocolors": "^1.0.0",
64
- "postcss-loader": "^7.3.3",
65
- "react": "^18.2.0",
66
- "react-dom": "^18.2.0",
67
- "react-redux": "^8.1.3",
68
- "react-refresh": "^0.14.0",
69
- "react-router-dom": "^6.16.0",
70
- "redux": "^4.2.1",
71
- "redux-logger": "^3.0.6",
72
- "redux-thunk": "^2.4.2",
73
- "sass": "^1.69.5",
74
- "sass-loader": "^13.3.2",
75
- "sass-resources-loader": "^2.2.5",
76
- "ua-parser-js": "^1.0.37",
77
- "url-loader": "^4.1.1",
78
- "webpack": "^5.88.2",
79
- "webpack-bundle-analyzer": "^4.9.1",
80
- "webpack-cli": "^5.1.4",
81
- "webpack-dev-server": "^4.15.1",
82
- "webpack-merge": "^5.9.0",
83
- "webpack-node-externals": "^3.0.0",
84
- "winston": "^3.11.0",
85
- "winston-daily-rotate-file": "^5.0.0"
86
- }
2
+ "name": "catalyst-core",
3
+ "version": "0.0.1-beta.4",
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.1-beta.1",
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
+ }
87
89
  }
@@ -4,12 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _reactRouterDom = require("react-router-dom");
8
- var _index = require("@src/js/routes/index.js");
9
- // FRAMEWORK COMMENT THIS IS JUST FOR THE APP
10
-
7
+ var _router = require("@tata1mg/router");
8
+ var _utils = require("@routes/utils.js");
11
9
  /**
12
10
  * @returns returns browsers routers (client routes)
13
- */
14
- const clientRouter = () => (0, _reactRouterDom.createBrowserRouter)((0, _index.preparedRoutes)());
11
+ */
12
+ const clientRouter = ({
13
+ store,
14
+ routerInitialState
15
+ }) => (0, _router.createBrowserRouter)((0, _utils.preparedRoutes)({
16
+ store,
17
+ routerInitialState
18
+ }));
15
19
  var _default = exports.default = clientRouter;
@@ -5,22 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _router = require("@tata1mg/router");
8
- // FRAMEWORK COMMENT THIS IS JUST FOR THE APP
9
- const {
10
- preparedRoutes
11
- } = require(`${process.env.src_path}/src/js/routes/index.js`);
12
-
13
- /**
14
- * @description return
15
- * @param {object} reduxData - redux data
16
- * @returns returns server routes
17
- */
8
+ var _utils = require("@routes/utils.js");
18
9
  const ServerRouter = reduxData => {
19
10
  const {
20
11
  store,
21
12
  intialData
22
13
  } = reduxData;
23
- return (0, _router.useRoutes)(preparedRoutes({
14
+ return (0, _router.useRoutes)((0, _utils.preparedRoutes)({
24
15
  store,
25
16
  routerInitialState: intialData
26
17
  }));
package/scripts/build.js CHANGED
@@ -1,27 +1,42 @@
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
- spawnSync,
10
- execSync
4
+ spawnSync
11
5
  } = require("child_process");
12
6
  const path = require("path");
13
7
  const {
14
8
  name
15
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
+ }
21
+
22
+ /**
23
+ * @description - creates a production build of the application.
24
+ */
16
25
  function start() {
17
- console.log("Running start....");
26
+ const commandLineArguments = process.argv.slice(2);
27
+ const argumentsObject = arrayToObject(commandLineArguments);
18
28
  const dirname = path.resolve(__dirname, "../");
19
29
  spawnSync("npm", ["run", "build", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
20
30
  cwd: dirname,
21
31
  stdio: "inherit",
22
- env: _objectSpread(_objectSpread({}, process.env), {}, {
23
- src_path: process.env.PWD
24
- })
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
+ }
25
40
  });
26
41
  }
27
42
  start();
@@ -0,0 +1,5 @@
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
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ const {
4
+ spawnSync
5
+ } = require("child_process");
6
+ const path = require("path");
7
+ const {
8
+ name
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
+ }
21
+
22
+ /**
23
+ * @description - creates a production build of the application.
24
+ */
25
+ function start() {
26
+ const commandLineArguments = process.argv.slice(2);
27
+ const argumentsObject = arrayToObject(commandLineArguments);
28
+ const dirname = path.resolve(__dirname, "../");
29
+ spawnSync("npm", ["run", "build", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
30
+ cwd: dirname,
31
+ stdio: "inherit",
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: true,
38
+ ...argumentsObject
39
+ }
40
+ });
41
+ }
42
+ start();
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ const {
4
+ spawnSync
5
+ } = require("child_process");
6
+ const path = require("path");
7
+ const {
8
+ name
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
+ }
21
+
22
+ /**
23
+ * @description - Serves production build of the application.
24
+ */
25
+
26
+ function start() {
27
+ const commandLineArguments = process.argv.slice(2);
28
+ const argumentsObject = arrayToObject(commandLineArguments);
29
+ const dirname = path.resolve(__dirname, "../");
30
+ spawnSync("npm", ["run", "serve", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
31
+ cwd: dirname,
32
+ stdio: "inherit",
33
+ env: {
34
+ ...process.env,
35
+ src_path: process.env.PWD,
36
+ build_output_path: BUILD_OUTPUT_PATH,
37
+ NODE_ENV: "production",
38
+ IS_DEV_COMMAND: true,
39
+ ...argumentsObject
40
+ }
41
+ });
42
+ }
43
+ start();
@@ -4,34 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- 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; }
8
- 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; }
9
- 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; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
- 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); }
12
- const catalystConfig = require("../config/config.js");
7
+ const appConfig = require(`${process.env.src_path}/config/config.json`);
13
8
  const {
14
- validatePackageJson,
15
9
  validateConfigFile
16
- } = require("../scripts/validator");
17
- const envConfig = require(`${process.env.src_path}/config/config.json`);
18
- const packageJSON = require(`${process.env.src_path}/package.json`);
19
- const env = process.env.NODE_ENV || "developmemt";
20
- const config = _objectSpread(_objectSpread({}, catalystConfig), validateConfigFile(envConfig) ? envConfig : {});
10
+ } = require("./validator.js");
21
11
 
22
12
  /**
23
13
  * @description stores all config.json key value into process.env before server starts.
24
14
  */
25
15
  const loadEnvironmentVariables = () => {
26
- process.env.BUILD_NUMBER = validatePackageJson(packageJSON) ? packageJSON.assetVersion : "";
27
- for (let k in envConfig) {
28
- // below code provides support for object handling present in config. However, for usage on client the client logic in define plugin needs to be checked and updated
29
- process.env[k] = typeof envConfig[k] === "object" ? JSON.stringify(envConfig[k]) : envConfig[k];
30
- }
31
- process.env.CLIENT_ONLY_RENDER = false;
32
- process.env.SERVER_SIDE_RENDER = true;
33
- if (process.env.BUILD_ENV === "localBuild" && env === "production") {
34
- process.env.LOCAL_BUILD_PUBLIC_ASSET_PATH = config.SERVER_PATH + config.LOCAL_ASSET_PATH;
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
+ }
35
22
  }
36
23
  };
37
24
  var _default = exports.default = loadEnvironmentVariables;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _cssModulesRequireHook = _interopRequireDefault(require("css-modules-require-hook"));
3
+ var _cssModulesRequireHook = _interopRequireDefault(require("@dr.pogodin/css-modules-require-hook"));
4
4
  var _path = _interopRequireDefault(require("path"));
5
5
  var _moduleAlias = _interopRequireDefault(require("module-alias"));
6
6
  var _loadEnvironmentVariables = _interopRequireDefault(require("./loadEnvironmentVariables"));
7
- var _logger = require("../logger");
8
- var _validator = require("./validator");
7
+ var _logger = require("../logger.js");
8
+ var _validator = require("./validator.js");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  const {
11
11
  cssModulesIdentifierDev
@@ -13,41 +13,33 @@ const {
13
13
  const {
14
14
  _moduleAliases
15
15
  } = require(`${process.env.src_path}/package.json`);
16
- // Add module aliases, but for server aliases (prefix by the `$` symbol), change
17
- // the directory to match the current build directory (e.g. /dist)
18
- // This ensures that all alises are properly referencing the babel-built
19
- // server files
16
+ // stores your config keys in enviorments variables
20
17
  (0, _loadEnvironmentVariables.default)();
18
+
19
+ // creates logger instance with provided config and stores them at global level.
21
20
  (0, _logger.configureLogger)({
22
21
  enableDebugLogs: process.env.ENABLE_DEBUG_LOGS,
23
22
  enableFileLogging: process.env.ENABLE_FILE_LOGGING,
24
23
  enableConsoleLogging: process.env.ENABLE_CONSOLE_LOGGING
25
24
  });
26
- process.loadableConfig = {
27
- CLIENT_ONLY_RENDER: process.env["CLIENT_ONLY_RENDER"] === "true",
28
- SERVER_SIDE_RENDER: process.env["SERVER_SIDE_RENDER"] === "true"
29
- };
25
+
26
+ // resolves module alias imports
30
27
  if ((0, _validator.validateModuleAlias)(_moduleAliases)) {
31
28
  _moduleAlias.default.addAliases(Object.keys(_moduleAliases || []).reduce((resultMap, aliasName) => {
32
29
  const aliasPath = _moduleAliases[aliasName];
33
- const sym = aliasName[0];
34
- if (sym === "$") {
30
+ if (aliasPath.includes("server")) {
35
31
  if (process.env.NODE_ENV !== "production") {
36
32
  resultMap[aliasName] = _path.default.join(process.env.src_path, aliasPath);
37
33
  } else {
38
- resultMap[aliasName] = _path.default.join(process.env.src_path, process.env.OUTPUT_PATH);
34
+ resultMap[aliasName] = _path.default.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH);
39
35
  }
40
- } else if (aliasPath.includes("templates")) {
41
- resultMap[aliasName] = _path.default.join(process.env.src_path, aliasPath);
42
- } else {
43
- resultMap[aliasName] = _path.default.join(process.env.src_path, aliasPath);
44
- }
36
+ } else resultMap[aliasName] = _path.default.join(process.env.src_path, aliasPath);
45
37
  return resultMap;
46
38
  }, {}));
47
39
  }
48
- // import hook before routes
49
40
 
50
- (0, _cssModulesRequireHook.default)({
41
+ // compile css-variables in realtime in dev mode.
42
+ if (process.env.NODE_ENV === "development") (0, _cssModulesRequireHook.default)({
51
43
  extensions: [".scss", ".css"],
52
44
  generateScopedName: cssModulesIdentifierDev,
53
45
  devMode: true,
package/scripts/serve.js CHANGED
@@ -1,27 +1,43 @@
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
- spawnSync,
10
- execSync
4
+ spawnSync
11
5
  } = require("child_process");
12
6
  const path = require("path");
13
7
  const {
14
8
  name
15
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
+ }
21
+
22
+ /**
23
+ * @description - Serves production build of the application.
24
+ */
25
+
16
26
  function start() {
17
- console.log("Running start....");
27
+ const commandLineArguments = process.argv.slice(2);
28
+ const argumentsObject = arrayToObject(commandLineArguments);
18
29
  const dirname = path.resolve(__dirname, "../");
19
30
  spawnSync("npm", ["run", "serve", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
20
31
  cwd: dirname,
21
32
  stdio: "inherit",
22
- env: _objectSpread(_objectSpread({}, process.env), {}, {
23
- src_path: process.env.PWD
24
- })
33
+ env: {
34
+ ...process.env,
35
+ src_path: process.env.PWD,
36
+ build_output_path: BUILD_OUTPUT_PATH,
37
+ NODE_ENV: "production",
38
+ IS_DEV_COMMAND: false,
39
+ ...argumentsObject
40
+ }
25
41
  });
26
42
  }
27
43
  start();
package/scripts/start.js CHANGED
@@ -1,28 +1,35 @@
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
- spawnSync,
10
- execSync
4
+ spawnSync
11
5
  } = require("child_process");
12
6
  const path = require("path");
7
+ function arrayToObject(array) {
8
+ const obj = {};
9
+ array.forEach(item => {
10
+ const [key, value] = item.split("=");
11
+ if (value) obj[key] = value;
12
+ });
13
+ return obj;
14
+ }
13
15
 
14
16
  /**
15
- * @description - starts node and react server.
17
+ * @description - starts webpack dev server and node server.
16
18
  */
17
19
  function start() {
18
- console.log("Running start....");
20
+ const commandLineArguments = process.argv.slice(2);
21
+ const argumentsObject = arrayToObject(commandLineArguments);
19
22
  const dirname = path.resolve(__dirname, "../");
20
23
  spawnSync("npm", ["run", "start", `--src_path=${process.env.PWD}`], {
21
24
  cwd: dirname,
22
25
  stdio: "inherit",
23
- env: _objectSpread(_objectSpread({}, process.env), {}, {
24
- src_path: process.env.PWD
25
- })
26
+ env: {
27
+ ...process.env,
28
+ src_path: process.env.PWD,
29
+ NODE_ENV: "development",
30
+ IS_DEV_COMMAND: false,
31
+ ...argumentsObject
32
+ }
26
33
  });
27
34
  }
28
35
  start();