@pronto-tools-and-more/pronto 4.2.0 → 4.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/pronto",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "type": "module",
@@ -13,13 +13,13 @@
13
13
  "author": "",
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@pronto-tools-and-more/file-watcher": "4.2.0",
17
- "@pronto-tools-and-more/files": "4.2.0",
18
- "@pronto-tools-and-more/network-process": "4.2.0",
19
- "@pronto-tools-and-more/sass-compiler": "4.2.0",
16
+ "@pronto-tools-and-more/file-watcher": "4.4.0",
17
+ "@pronto-tools-and-more/files": "4.4.0",
18
+ "@pronto-tools-and-more/network-process": "4.4.0",
19
+ "@pronto-tools-and-more/sass-compiler": "4.4.0",
20
20
  "@lvce-editor/assert": "^1.2.0",
21
- "@lvce-editor/ipc": "^9.3.0",
22
- "@lvce-editor/json-rpc": "^1.3.0",
21
+ "@lvce-editor/ipc": "^9.4.0",
22
+ "@lvce-editor/json-rpc": "^1.4.0",
23
23
  "@lvce-editor/verror": "^1.3.0",
24
24
  "execa": "^9.3.0",
25
25
  "express": "^4.19.2"
@@ -27,7 +27,7 @@
27
27
  "devDependencies": {
28
28
  "@types/express": "^4.17.21",
29
29
  "@types/node": "^20.14.10",
30
- "@types/ws": "^8.5.11",
30
+ "@types/ws": "^8.5.12",
31
31
  "jest": "^29.7.0"
32
32
  },
33
33
  "jest": {
@@ -90,6 +90,22 @@ export const create = ({
90
90
  ProxyPath.create({
91
91
  prefix: "/resources/web",
92
92
  to: Config.managerWebUrl,
93
+ customIf: [
94
+ {
95
+ match: "purpleshared/custom.css",
96
+ file: join(defaultPath, "readmode", "custom.css"),
97
+ postfix: "",
98
+ },
99
+ {
100
+ match: "purpleshared/custom.js",
101
+ file: join(defaultPath, "readmode", "custom.js"),
102
+ postfix: `
103
+ const script = document.createElement('script')
104
+ script.src='/assets/live-reload-readmode.js'
105
+ document.head.append(script)
106
+ `,
107
+ },
108
+ ],
93
109
  })
94
110
  );
95
111
  return app;
@@ -4,7 +4,7 @@ import * as Exec from "../Exec/Exec.js";
4
4
  export const getCommitMessage = async () => {
5
5
  try {
6
6
  if (process.env.CI_COMMIT_MESSAGE) {
7
- return process.env.CI_COMMIT_MESSAGE;
7
+ return process.env.CI_COMMIT_MESSAGE.trim();
8
8
  }
9
9
  const { stdout } = await Exec.exec("git", ["log", "-1", "--pretty=%B"]);
10
10
  return stdout.trim();
@@ -1,10 +1,25 @@
1
+ import { readFile } from "node:fs/promises";
1
2
  import { join } from "node:path";
2
3
  import * as SendFullUpdates from "../SendFullUpdates/SendFullUpdates.js";
3
4
  import * as SendSassUpdates from "../SendSassUpdates/SendSassUpdates.js";
5
+ import * as SendUpdates from "../SendUpdates/SendUpdates.js";
4
6
 
5
- export const handleFileChange = (clients, event, root, errorColor) => {
6
- if (event.filename.endsWith(".scss")) {
7
- const absolutePath = join(root, event.filename);
7
+ export const handleFileChange = async (clients, event, root, errorColor) => {
8
+ const absolutePath = join(root, event.filename);
9
+ if (event.filename === "default/readmode/custom.css") {
10
+ const css = await readFile(absolutePath, "utf8");
11
+ const changes = [
12
+ {
13
+ fileName: event.filename,
14
+ css,
15
+ },
16
+ ];
17
+ SendUpdates.sendUpdates(clients, {
18
+ jsonrpc: "2.0",
19
+ method: "updateCss",
20
+ params: [changes],
21
+ });
22
+ } else if (event.filename.endsWith(".scss")) {
8
23
  SendSassUpdates.sendSassUpdates(
9
24
  clients,
10
25
  absolutePath,
@@ -1,4 +1,5 @@
1
1
  import { VError } from "@lvce-editor/verror";
2
+ import { readFile } from "node:fs/promises";
2
3
  import { pipeline } from "node:stream/promises";
3
4
 
4
5
  const getProxyResponse = async (prefix, to, sourceUrl) => {
@@ -16,8 +17,17 @@ const getProxyResponse = async (prefix, to, sourceUrl) => {
16
17
  }
17
18
  };
18
19
 
19
- export const create = ({ prefix, to }) => {
20
+ export const create = ({ prefix, to, customIf }) => {
20
21
  const proxyFn = async (req, res) => {
22
+ for (const item of customIf) {
23
+ if (req.url.includes(item.match)) {
24
+ const absolutePath = item.file;
25
+ const content = await readFile(absolutePath, "utf8");
26
+ const fullContent = content + "\n" + item.postfix;
27
+ res.end(fullContent);
28
+ return;
29
+ }
30
+ }
21
31
  const proxyResponse = await getProxyResponse(prefix, to, req.url);
22
32
  await pipeline(proxyResponse, res);
23
33
  };
@@ -25,12 +25,11 @@ export const upgrade = async () => {
25
25
  pullWorkingCopyUrl,
26
26
  } = Config;
27
27
  const src = join(Cwd.cwd, "src");
28
- const sessionInfo = await GetSessionId.getSessionId({
28
+ const sessionId = await GetSessionId.getSessionId({
29
29
  loginUrl,
30
30
  userEmail,
31
31
  userPassword,
32
32
  });
33
- const sessionId = sessionInfo.sessionID;
34
33
  await PullWorkingCopy.pullWorkingCopy({
35
34
  appId,
36
35
  sessionId,