catalyst-core 0.0.1-beta.4 → 0.0.1-beta.5
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 +5 -5
- package/.eslintrc +0 -1
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/babel.config.json +1 -0
- package/bin/catalyst.js +1 -4
- package/caching.js +1 -16
- package/changelog.md +5 -19
- package/commitlint.config.js +11 -0
- package/index.js +1 -16
- package/logger.js +3 -92
- package/package.json +89 -87
- package/router/ClientRouter.js +2 -18
- package/router/ServerRouter.js +1 -19
- package/router.js +1 -16
- package/scripts/build.js +9 -41
- package/scripts/checkVersion.js +1 -5
- package/scripts/devBuild.js +9 -41
- package/scripts/devServe.js +4 -42
- 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 -42
- package/scripts/start.js +5 -34
- package/scripts/validator.js +1 -127
- 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 -237
- package/server/renderer/index.js +1 -12
- package/server/renderer/render.js +8 -71
- package/server/startServer.js +6 -66
- package/server/utils/userAgentUtil.js +3 -45
- package/server/utils/validator.js +1 -127
- 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 -175
- package/webpack/development.client.babel.js +4 -85
- package/webpack/production.client.babel.js +4 -78
- package/webpack/production.ssr.babel.js +4 -61
- package/webpack/scssParams.js +5 -47
- 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/server/utils/metaTags.js +0 -13
- 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/.eslintignore
CHANGED
package/.eslintrc
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no -- commitlint --edit $1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run lint-staged
|
package/babel.config.json
CHANGED
package/bin/catalyst.js
CHANGED
|
@@ -18,14 +18,12 @@ if (["build", "start", "serve", "devBuild", "devServe"].includes(script)) {
|
|
|
18
18
|
)
|
|
19
19
|
if (result.signal) {
|
|
20
20
|
if (result.signal === "SIGKILL") {
|
|
21
|
-
/* eslint-disable no-console */
|
|
22
21
|
console.log(
|
|
23
22
|
"The build failed because the process exited too early. " +
|
|
24
23
|
"This probably means the system ran out of memory or someone called " +
|
|
25
24
|
"`kill -9` on the process."
|
|
26
25
|
)
|
|
27
26
|
} else if (result.signal === "SIGTERM") {
|
|
28
|
-
/* eslint-disable no-console */
|
|
29
27
|
console.log(
|
|
30
28
|
"The build failed because the process exited too early. " +
|
|
31
29
|
"Someone might have called `kill` or `killall`, or the system could " +
|
|
@@ -36,6 +34,5 @@ if (["build", "start", "serve", "devBuild", "devServe"].includes(script)) {
|
|
|
36
34
|
}
|
|
37
35
|
process.exit(result.status)
|
|
38
36
|
} else {
|
|
39
|
-
|
|
40
|
-
console.log('Unknown script "' + script + '".');
|
|
37
|
+
console.log('Unknown script "' + script + '".')
|
|
41
38
|
}
|
package/caching.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _apiCaching = require("@tata1mg/api-caching");
|
|
7
|
-
Object.keys(_apiCaching).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _apiCaching[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _apiCaching[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _apiCaching=require("@tata1mg/api-caching");Object.keys(_apiCaching).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_apiCaching[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _apiCaching[key];}});});
|
package/changelog.md
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.0.1-beta.
|
|
4
|
-
### Added
|
|
5
|
-
- Implemented dynamic metadata for nested routing.
|
|
6
|
-
- Dev build and dev serve configurations for a smoother development experience.([Refer documenatation](https://catalyst.1mg.com/public_docs/content/deployment))
|
|
7
|
-
- ESLint security rules for improved code security.
|
|
8
|
-
|
|
9
|
-
### Changed
|
|
10
|
-
- Security audit conducted on all packages.
|
|
11
|
-
- Removed Babel packages already included in the Babel preset.
|
|
12
|
-
- Updated router version to support nested routing. (0.0.1-beta.0 to 0.0.1-beta.1)
|
|
3
|
+
## [0.0.1-beta.5] - 21-05-2024
|
|
13
4
|
|
|
14
|
-
###
|
|
15
|
-
- `metadataFunction` is deprecated and has been renamed to `setMetaData`.
|
|
5
|
+
### Added
|
|
16
6
|
|
|
17
|
-
|
|
18
|
-
-
|
|
7
|
+
- Enhanced CLI for the commands: start, build, devBuild, devServe, and serve.
|
|
8
|
+
- Integration of Husky with lint-staged, using conventional commits.
|
|
19
9
|
|
|
20
10
|
### Fixed
|
|
21
|
-
- Updated documentation to reflect the latest changes.
|
|
22
11
|
|
|
23
|
-
|
|
24
|
-
- The `metadataFunction` has been renamed to `setMetaData`. Update your code accordingly.
|
|
25
|
-
- The `preparedRoutes` function now supports nested routing. Modify your routing setup to use this new functionality.
|
|
26
|
-
- For more information on handling these changes, please refer to the [migration guide](https://catalyst.1mg.com/content/migration_guide/0.0.1-beta.4) in the documentation.
|
|
12
|
+
- Fixed logs folder creation in project directory.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/*
|
|
3
|
+
* Resolve and load @commitlint/config-conventional from node_modules.
|
|
4
|
+
* Referenced packages must be installed
|
|
5
|
+
*/
|
|
6
|
+
extends: ["@commitlint/config-conventional"],
|
|
7
|
+
/*
|
|
8
|
+
* Any rules defined here will override rules from @commitlint/config-conventional
|
|
9
|
+
*/
|
|
10
|
+
rules: {},
|
|
11
|
+
}
|
package/index.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _index = require("./server/renderer/document/index");
|
|
7
|
-
Object.keys(_index).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _index[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _index[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _index=require("./server/renderer/document/index");Object.keys(_index).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_index[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _index[key];}});});
|
package/logger.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const winston = require("winston");
|
|
4
|
-
const DailyRotateFile = require("winston-daily-rotate-file");
|
|
5
|
-
const pc = require("picocolors");
|
|
6
|
-
const {
|
|
7
|
-
createLogger,
|
|
8
|
-
format,
|
|
9
|
-
transports
|
|
10
|
-
} = winston;
|
|
11
|
-
|
|
12
|
-
/**
|
|
1
|
+
"use strict";const winston=require("winston");const DailyRotateFile=require("winston-daily-rotate-file");const pc=require("picocolors");const{createLogger,format,transports}=winston;/**
|
|
13
2
|
* @description Logger library with rotational strategy. Creates a logs folder in root.
|
|
14
3
|
* With debug, error and info log directories with their respective log files.
|
|
15
4
|
*
|
|
@@ -17,83 +6,5 @@ const {
|
|
|
17
6
|
* @param config { @enableDebugLogs: Bool // default: true }
|
|
18
7
|
* @returns loggerInstance
|
|
19
8
|
*
|
|
20
|
-
*/
|
|
21
|
-
const
|
|
22
|
-
const {
|
|
23
|
-
enableDebugLogs = true,
|
|
24
|
-
enableFileLogging = true,
|
|
25
|
-
enableConsoleLogging = true
|
|
26
|
-
} = config;
|
|
27
|
-
const consoleTransport = new transports.Console({
|
|
28
|
-
level: "debug"
|
|
29
|
-
});
|
|
30
|
-
const fileTransport = (type = "info") => {
|
|
31
|
-
return new DailyRotateFile({
|
|
32
|
-
filename: `./logs/${type}/%DATE%.${type}.log`,
|
|
33
|
-
datePattern: "YYYY-MM-DD",
|
|
34
|
-
maxFiles: "3d",
|
|
35
|
-
// Logs will be removed after 2days,
|
|
36
|
-
loglevel: type,
|
|
37
|
-
level: type
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
const infoLogger = createLogger({
|
|
41
|
-
format: format.combine(format.timestamp({
|
|
42
|
-
format: "YYYY-MM-DD HH:mm:ss"
|
|
43
|
-
}), format.json()),
|
|
44
|
-
defaultMeta: {
|
|
45
|
-
loglevel: "info"
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const debugLogger = createLogger({
|
|
49
|
-
format: format.combine(format.timestamp({
|
|
50
|
-
format: "YYYY-MM-DD HH:mm:ss"
|
|
51
|
-
}), format.json()),
|
|
52
|
-
defaultMeta: {
|
|
53
|
-
loglevel: "debug"
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
const errorLogger = createLogger({
|
|
57
|
-
format: format.combine(format.timestamp({
|
|
58
|
-
format: "YYYY-MM-DD HH:mm:ss"
|
|
59
|
-
}), format.json()),
|
|
60
|
-
defaultMeta: {
|
|
61
|
-
loglevel: "error"
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
if (enableConsoleLogging && JSON.parse(enableConsoleLogging)) {
|
|
65
|
-
infoLogger.add(consoleTransport);
|
|
66
|
-
debugLogger.add(consoleTransport);
|
|
67
|
-
errorLogger.add(consoleTransport);
|
|
68
|
-
}
|
|
69
|
-
if (enableFileLogging && JSON.parse(enableFileLogging)) {
|
|
70
|
-
infoLogger.add(fileTransport("info"));
|
|
71
|
-
debugLogger.add(fileTransport("debug"));
|
|
72
|
-
errorLogger.add(fileTransport("error"));
|
|
73
|
-
}
|
|
74
|
-
const Logger = {
|
|
75
|
-
debug: () => {},
|
|
76
|
-
error: msg => {
|
|
77
|
-
/* eslint-disable no-console */
|
|
78
|
-
console.log(pc.red(pc.bold("ERROR: " + JSON.stringify(msg))));
|
|
79
|
-
errorLogger.error(msg);
|
|
80
|
-
},
|
|
81
|
-
info: msg => {
|
|
82
|
-
/* eslint-disable no-console */
|
|
83
|
-
console.log(pc.green(pc.bold("INFO: " + JSON.stringify(msg))));
|
|
84
|
-
infoLogger.info(msg);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
if (enableDebugLogs && JSON.parse(enableDebugLogs)) {
|
|
88
|
-
Logger.debug = msg => {
|
|
89
|
-
/* eslint-disable no-console */
|
|
90
|
-
console.log(pc.yellow(pc.bold("DEBUG: " + JSON.stringify(msg))));
|
|
91
|
-
debugLogger.debug(msg);
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
if (global) global.logger = Logger;
|
|
95
|
-
return Logger;
|
|
96
|
-
};
|
|
97
|
-
module.exports = {
|
|
98
|
-
configureLogger
|
|
99
|
-
};
|
|
9
|
+
*/const configureLogger=(config={})=>{const{enableDebugLogs=true,enableFileLogging=true,enableConsoleLogging=true}=config;const consoleTransport=new transports.Console({level:"debug"});const fileTransport=(type="info")=>{return new DailyRotateFile({filename:`${process.env.src_path}/logs/${type}/%DATE%.${type}.log`,datePattern:"YYYY-MM-DD",maxFiles:"3d",// Logs will be removed after 2days,
|
|
10
|
+
loglevel:type,level:type});};const infoLogger=createLogger({format:format.combine(format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),format.json()),defaultMeta:{loglevel:"info"}});const debugLogger=createLogger({format:format.combine(format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),format.json()),defaultMeta:{loglevel:"debug"}});const errorLogger=createLogger({format:format.combine(format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),format.json()),defaultMeta:{loglevel:"error"}});if(enableConsoleLogging&&JSON.parse(enableConsoleLogging)){infoLogger.add(consoleTransport);debugLogger.add(consoleTransport);errorLogger.add(consoleTransport);}if(enableFileLogging&&JSON.parse(enableFileLogging)){infoLogger.add(fileTransport("info"));debugLogger.add(fileTransport("debug"));errorLogger.add(fileTransport("error"));}const Logger={debug:()=>{},error:msg=>{console.log(pc.red(pc.bold("ERROR: "+JSON.stringify(msg))));errorLogger.error(msg);},info:msg=>{console.log(pc.green(pc.bold("INFO: "+JSON.stringify(msg))));infoLogger.info(msg);}};if(enableDebugLogs&&JSON.parse(enableDebugLogs)){Logger.debug=msg=>{console.log(pc.yellow(pc.bold("DEBUG: "+JSON.stringify(msg))));debugLogger.debug(msg);};}if(global)global.logger=Logger;return Logger;};module.exports={configureLogger};
|
package/package.json
CHANGED
|
@@ -1,89 +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
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
2
|
+
"name": "catalyst-core",
|
|
3
|
+
"version": "0.0.1-beta.5",
|
|
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
|
+
}
|
|
89
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,42 +1,10 @@
|
|
|
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
|
-
/**
|
|
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");/**
|
|
23
2
|
* @description - creates a production build of the application.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
stdio:
|
|
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
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
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
package/scripts/devBuild.js
CHANGED
|
@@ -1,42 +1,10 @@
|
|
|
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
|
-
/**
|
|
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");/**
|
|
23
2
|
* @description - creates a production build of the application.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
stdio:
|
|
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();
|
|
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();
|