@pronto-tools-and-more/pronto 10.12.0 → 10.14.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +11 -10
- package/src/parts/App/App.js +10 -0
- package/src/parts/Build/Build.js +25 -0
- package/src/parts/Config/Config.js +2 -0
- package/src/parts/CreateServer/CreateServer.js +1 -0
- package/src/parts/CustomJsFunctionsPath/CustomJsFunctionsPath.js +13 -0
- package/src/parts/GetCustomServerJsContent/GetCustomServerJsContent.js +13 -0
- package/src/parts/HandleCustomServer/HandleCustomServer.js +28 -0
- package/src/parts/Version/Version.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pronto-tools-and-more/pronto",
|
3
|
-
"version": "10.
|
3
|
+
"version": "10.14.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "src/main.js",
|
6
6
|
"type": "module",
|
@@ -17,15 +17,16 @@
|
|
17
17
|
"@lvce-editor/ipc": "^11.3.0",
|
18
18
|
"@lvce-editor/json-rpc": "^5.2.0",
|
19
19
|
"@lvce-editor/verror": "^1.6.0",
|
20
|
-
"@pronto-tools-and-more/file-watcher": "10.
|
21
|
-
"@pronto-tools-and-more/files": "10.
|
22
|
-
"@pronto-tools-and-more/network-process": "10.
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "10.
|
24
|
-
"@pronto-tools-and-more/components-renderer": "10.
|
25
|
-
"@pronto-tools-and-more/components": "10.
|
26
|
-
"@pronto-tools-and-more/schema-process": "10.
|
27
|
-
"@pronto-tools-and-more/diff-process": "10.
|
28
|
-
"@pronto-tools-and-more/type-checker": "10.
|
20
|
+
"@pronto-tools-and-more/file-watcher": "10.14.0",
|
21
|
+
"@pronto-tools-and-more/files": "10.14.0",
|
22
|
+
"@pronto-tools-and-more/network-process": "10.14.0",
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "10.14.0",
|
24
|
+
"@pronto-tools-and-more/components-renderer": "10.14.0",
|
25
|
+
"@pronto-tools-and-more/components": "10.14.0",
|
26
|
+
"@pronto-tools-and-more/schema-process": "10.14.0",
|
27
|
+
"@pronto-tools-and-more/diff-process": "10.14.0",
|
28
|
+
"@pronto-tools-and-more/type-checker": "10.14.0",
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "10.14.0",
|
29
30
|
"execa": "^9.5.1",
|
30
31
|
"express": "^4.21.1"
|
31
32
|
},
|
package/src/parts/App/App.js
CHANGED
@@ -6,6 +6,7 @@ import * as HandleFeaturesJson from "../HandleFeaturesJson/HandleFeaturesJson.js
|
|
6
6
|
import * as HandleIndex from "../HandleIndex/HandleIndex.js";
|
7
7
|
import * as HandleMainJs from "../HandleMainJs/HandleMainJs.js";
|
8
8
|
import * as HandleViews from "../HandleViews/HandleViews.js";
|
9
|
+
import * as HandleCustomServer from "../HandleCustomServer/HandleCustomServer.js";
|
9
10
|
import * as ProxyPath from "../ProxyPath/ProxyPath.js";
|
10
11
|
|
11
12
|
export const create = ({
|
@@ -23,6 +24,7 @@ export const create = ({
|
|
23
24
|
reactComponents,
|
24
25
|
managerWebUrl,
|
25
26
|
resourceDynamicUrlsInViewsJson,
|
27
|
+
injectCustomJs,
|
26
28
|
}) => {
|
27
29
|
const app = express();
|
28
30
|
const storeFrontPath = join(root, "src", "default", "storefront");
|
@@ -69,6 +71,14 @@ export const create = ({
|
|
69
71
|
filesPath: FilesPath.filesPath,
|
70
72
|
})
|
71
73
|
);
|
74
|
+
app.get(
|
75
|
+
"/assets/scripts/custom.server.js",
|
76
|
+
HandleCustomServer.handleCustomServerJs({
|
77
|
+
storeFrontPath,
|
78
|
+
filesPath: FilesPath.filesPath,
|
79
|
+
injectCustomJs,
|
80
|
+
})
|
81
|
+
);
|
72
82
|
app.use("*", HandleCss.handleCss(storeFrontPath));
|
73
83
|
app.use(express.static(FilesPath.filesPath));
|
74
84
|
if (mode === "slim") {
|
package/src/parts/Build/Build.js
CHANGED
@@ -9,6 +9,7 @@ import * as FilesPath from "../FilesPath/FilesPath.js";
|
|
9
9
|
import * as GetViewsResponse from "../GetViewsResponse/GetViewsResponse.js";
|
10
10
|
import * as SassProcess from "../SassProcess/SassProcess.js";
|
11
11
|
import * as ValidateAllSchemas from "../ValidateAllSchemas/ValidateAllSchemas.js";
|
12
|
+
import * as GetCustomServerJsContent from "../GetCustomServerJsContent/GetCustomServerJsContent.js";
|
12
13
|
|
13
14
|
const sourceMap = false;
|
14
15
|
|
@@ -64,6 +65,30 @@ export const build = async () => {
|
|
64
65
|
await mkdir(dirname(viewsPath), { recursive: true });
|
65
66
|
await writeFile(viewsPath, viewsResponse);
|
66
67
|
}
|
68
|
+
if (Config.injectCustomJs) {
|
69
|
+
const newContent =
|
70
|
+
await GetCustomServerJsContent.getCustomServerJsContent({
|
71
|
+
customServerJsPath: join(
|
72
|
+
Cwd.cwd,
|
73
|
+
"src",
|
74
|
+
"default",
|
75
|
+
"storefront",
|
76
|
+
"assets",
|
77
|
+
"scripts",
|
78
|
+
"custom.server.js"
|
79
|
+
),
|
80
|
+
});
|
81
|
+
const customServrJsPathDist = join(
|
82
|
+
dist,
|
83
|
+
"src",
|
84
|
+
"default",
|
85
|
+
"storefront",
|
86
|
+
"assets",
|
87
|
+
"scripts",
|
88
|
+
"custom.server.js"
|
89
|
+
);
|
90
|
+
await writeFile(customServrJsPathDist, newContent);
|
91
|
+
}
|
67
92
|
if (Config.validateSchema) {
|
68
93
|
await ValidateAllSchemas.validateAllSchemas();
|
69
94
|
}
|
@@ -25,6 +25,7 @@ export const createServer = async (root, errorColor) => {
|
|
25
25
|
reactComponents: Config.reactComponents,
|
26
26
|
splitViews: Config.splitViews,
|
27
27
|
resourceDynamicUrlsInViewsJson: Config.resourceDynamicUrlsInViewsJson,
|
28
|
+
injectCustomJs: Config.injectCustomJs,
|
28
29
|
});
|
29
30
|
const server = http.createServer(app);
|
30
31
|
const webSocketServer = new ws.WebSocketServer({
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import * as Path from "node:path";
|
2
|
+
import * as ResolveBin from "../ResolveBin/ResolveBin.js";
|
3
|
+
import * as Root from "../Root/Root.js";
|
4
|
+
|
5
|
+
export const customJsFunctionsPath =
|
6
|
+
ResolveBin.resolveBin("@pronto-tools-and-more/custom-js-functions") ||
|
7
|
+
Path.join(
|
8
|
+
Root.root,
|
9
|
+
"packages",
|
10
|
+
"pronto-custom-js-functions",
|
11
|
+
"dist",
|
12
|
+
"main.js"
|
13
|
+
);
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { readFile } from "fs/promises";
|
2
|
+
import * as CustomJsFunctionsPath from "../CustomJsFunctionsPath/CustomJsFunctionsPath.js";
|
3
|
+
|
4
|
+
export const getCustomServerJsContent = async ({ customServerJsPath }) => {
|
5
|
+
const baseContent = await readFile(customServerJsPath, "utf8");
|
6
|
+
const injectedContent = await readFile(
|
7
|
+
CustomJsFunctionsPath.customJsFunctionsPath,
|
8
|
+
"utf8"
|
9
|
+
);
|
10
|
+
const merged =
|
11
|
+
baseContent + `\n\n\n// pronto injected code\n\n\n` + injectedContent;
|
12
|
+
return merged;
|
13
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { createReadStream } from "fs";
|
2
|
+
import { join } from "path";
|
3
|
+
import { pipeline } from "stream/promises";
|
4
|
+
import * as GetCustomServerJsContent from "../GetCustomServerJsContent/GetCustomServerJsContent.js";
|
5
|
+
|
6
|
+
export const handleCustomServerJs =
|
7
|
+
({ storeFrontPath, filesPath, injectCustomJs }) =>
|
8
|
+
async (req, res) => {
|
9
|
+
try {
|
10
|
+
const customServerJsPath = join(
|
11
|
+
storeFrontPath,
|
12
|
+
"assets",
|
13
|
+
"scripts",
|
14
|
+
"custom.server.js"
|
15
|
+
);
|
16
|
+
if (injectCustomJs) {
|
17
|
+
const content = await GetCustomServerJsContent.getCustomServerJsContent(
|
18
|
+
{ customServerJsPath }
|
19
|
+
);
|
20
|
+
res.end(content);
|
21
|
+
} else {
|
22
|
+
await pipeline(createReadStream(customServerJsPath), res);
|
23
|
+
}
|
24
|
+
} catch (error) {
|
25
|
+
console.error(`[server] ${error}`);
|
26
|
+
res.status(500).end("internal server error when generating server js");
|
27
|
+
}
|
28
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
export const version = '10.
|
1
|
+
export const version = '10.14.0'
|