@pronto-tools-and-more/pronto 3.3.10 → 3.3.11
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 +5 -5
- package/src/parts/App/App.js +16 -7
- package/src/parts/CommandMap/CommandMap.js +2 -0
- package/src/parts/Config/Config.js +32 -12
- package/src/parts/Cwd/Cwd.js +1 -0
- package/src/parts/GetCommandFromCliArgs/GetCommandFromCliArgs.js +3 -0
- package/src/parts/Help/Help.js +3 -0
- package/src/parts/UpdateIndexHtml/UpdateIndexHtml.js +14 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pronto-tools-and-more/pronto",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pronto-tools-and-more/file-watcher": "3.3.
|
|
17
|
-
"@pronto-tools-and-more/files": "3.3.
|
|
18
|
-
"@pronto-tools-and-more/network-process": "3.3.
|
|
19
|
-
"@pronto-tools-and-more/sass-compiler": "3.3.
|
|
16
|
+
"@pronto-tools-and-more/file-watcher": "3.3.11",
|
|
17
|
+
"@pronto-tools-and-more/files": "3.3.11",
|
|
18
|
+
"@pronto-tools-and-more/network-process": "3.3.11",
|
|
19
|
+
"@pronto-tools-and-more/sass-compiler": "3.3.11",
|
|
20
20
|
"@lvce-editor/assert": "^1.2.0",
|
|
21
21
|
"@lvce-editor/ipc": "^9.1.0",
|
|
22
22
|
"@lvce-editor/json-rpc": "^1.3.0",
|
package/src/parts/App/App.js
CHANGED
|
@@ -8,12 +8,18 @@ import * as FilesPath from "../FilesPath/FilesPath.js";
|
|
|
8
8
|
import * as UpdateCss from "../UpdateCss/UpdateCss.js";
|
|
9
9
|
import * as UpdateIndexHtml from "../UpdateIndexHtml/UpdateIndexHtml.js";
|
|
10
10
|
|
|
11
|
-
const handleIndex =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const handleIndex =
|
|
12
|
+
(storeFrontPath, appId, baseUrl, contentUrl) => async (req, res) => {
|
|
13
|
+
const indexHtmlPath = join(storeFrontPath, "index.html");
|
|
14
|
+
const indexHtmlContent = await readFile(indexHtmlPath, "utf8");
|
|
15
|
+
const newIndexHtml = UpdateIndexHtml.updateIndexHtml(
|
|
16
|
+
indexHtmlContent,
|
|
17
|
+
appId,
|
|
18
|
+
baseUrl,
|
|
19
|
+
contentUrl
|
|
20
|
+
);
|
|
21
|
+
res.end(newIndexHtml);
|
|
22
|
+
};
|
|
17
23
|
|
|
18
24
|
const handleCss = (storeFrontPath) => async (req, res, next) => {
|
|
19
25
|
const pathName = req._parsedUrl.pathname;
|
|
@@ -44,7 +50,10 @@ export const create = (root) => {
|
|
|
44
50
|
const storeFrontPath = join(root, "src", "default", "storefront");
|
|
45
51
|
const defaultPath = join(root, "src", "default");
|
|
46
52
|
const contentPath = join(root, "src", "default", "content");
|
|
47
|
-
|
|
53
|
+
const appId = Config.appId;
|
|
54
|
+
const baseUrl = Config.baseUrl;
|
|
55
|
+
const contentUrl = Config.contentUrl;
|
|
56
|
+
app.get("/", handleIndex(storeFrontPath, appId, baseUrl, contentUrl));
|
|
48
57
|
app.use("*", handleCss(storeFrontPath));
|
|
49
58
|
app.use(express.static(FilesPath.filesPath));
|
|
50
59
|
app.use(express.static(storeFrontPath));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Build from "../Build/Build.js";
|
|
2
|
+
import * as Help from "../Help/Help.js";
|
|
2
3
|
import * as Login from "../Login/Login.js";
|
|
3
4
|
import * as PullCode from "../PullCode/PullCode.js";
|
|
4
5
|
import * as PushCode from "../PushCode/PushCode.js";
|
|
@@ -7,6 +8,7 @@ import * as UploadZip from "../UploadZip/UploadZip.js";
|
|
|
7
8
|
|
|
8
9
|
export const commandMap = {
|
|
9
10
|
"Build.build": Build.build,
|
|
11
|
+
"Help.help": Help.help,
|
|
10
12
|
"Login.login": Login.login,
|
|
11
13
|
"PullCode.pullCode": PullCode.pullCode,
|
|
12
14
|
"PushCode.pushCode": PushCode.pushCode,
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
import { join } from "path";
|
|
2
|
-
import * as
|
|
2
|
+
import * as Cwd from "../Cwd/Cwd.js";
|
|
3
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
4
|
|
|
4
5
|
export const userEmail = process.env.PRONTO_USER_EMAIL;
|
|
5
6
|
export const userPassword = process.env.PRONTO_USER_PASSWORD;
|
|
7
|
+
|
|
8
|
+
const configFileUrl = join(Cwd.cwd, "pronto.json");
|
|
9
|
+
|
|
10
|
+
const getConfig = () => {
|
|
11
|
+
if (existsSync(configFileUrl)) {
|
|
12
|
+
const content = readFileSync(configFileUrl, "utf8");
|
|
13
|
+
const parsed = JSON.parse(content);
|
|
14
|
+
return parsed;
|
|
15
|
+
}
|
|
16
|
+
return {};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const config = getConfig();
|
|
6
20
|
// TODO use direct backend url
|
|
7
|
-
export const loginUrl =
|
|
8
|
-
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
export const loginUrl =
|
|
22
|
+
config.loginUrl || `https://builder.purplemanager.com/api/user/login`;
|
|
23
|
+
export const listResourcesUrl =
|
|
24
|
+
config.listResourcesUrl ||
|
|
25
|
+
`https://purplemanager.com/purple-manager-backend/app/listresources`;
|
|
26
|
+
export const appId = config.appId || ``;
|
|
27
|
+
export const downloadBaseUrl =
|
|
28
|
+
config.downloadBaseUrl ||
|
|
29
|
+
`https://purplemanager.com/purple-manager-backend/app/downloadappresources`;
|
|
30
|
+
export const uploadBaseUrl =
|
|
31
|
+
config.uploadBaseUrl ||
|
|
32
|
+
`https://purplemanager.com/purple-manager-backend/app/uploadresources`;
|
|
12
33
|
export const preview = true;
|
|
13
34
|
export const uploadTimeout = 120000;
|
|
35
|
+
export const baseUrl = config.baseUrl || "https://purplemanager.com/delivery";
|
|
36
|
+
export const contentUrl =
|
|
37
|
+
config.contentUrl || "https://catalog.purplemanager.com";
|
|
14
38
|
|
|
15
39
|
export const rootSassFile = join(
|
|
16
|
-
|
|
17
|
-
"packages",
|
|
18
|
-
"daz",
|
|
40
|
+
Cwd.cwd,
|
|
19
41
|
"src",
|
|
20
42
|
"default",
|
|
21
43
|
"storefront",
|
|
@@ -25,9 +47,7 @@ export const rootSassFile = join(
|
|
|
25
47
|
);
|
|
26
48
|
|
|
27
49
|
export const rootCssFile = join(
|
|
28
|
-
|
|
29
|
-
"packages",
|
|
30
|
-
"daz",
|
|
50
|
+
Cwd.cwd,
|
|
31
51
|
"src",
|
|
32
52
|
"default",
|
|
33
53
|
"storefront",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const cwd = process.cwd();
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
const occurrenceSnippetBody = "</body>";
|
|
2
|
-
const replacementSnippetBody =
|
|
2
|
+
const replacementSnippetBody = (appId, baseUrl, contentUrl) =>
|
|
3
|
+
`
|
|
3
4
|
<script>
|
|
4
5
|
window._editorAppInfo = {
|
|
5
|
-
appId: "
|
|
6
|
-
baseUrl: "
|
|
7
|
-
contentUrl: "
|
|
6
|
+
appId: "APP_ID",
|
|
7
|
+
baseUrl: "BASE_URL",
|
|
8
|
+
contentUrl: "CONTENT_URL",
|
|
8
9
|
forcePurpleImplUsage: true
|
|
9
10
|
};
|
|
10
11
|
</script>
|
|
11
12
|
<script type="module" src="/assets/preview-inject-bundle.js"></script>
|
|
12
13
|
<script type="module" src="/assets/live-reload.js"></script>
|
|
13
|
-
</body
|
|
14
|
+
</body>`
|
|
15
|
+
.replace("APP_ID", appId)
|
|
16
|
+
.replace("BASE_URL", baseUrl)
|
|
17
|
+
.replace("CONTENT_URL", contentUrl);
|
|
14
18
|
|
|
15
19
|
const occurrenceSnippetHead = "</head>";
|
|
16
20
|
const replacementSnippetHead = `
|
|
17
21
|
<link rel="stylesheet" href="/theme.css" />
|
|
18
22
|
</head>`;
|
|
19
23
|
|
|
20
|
-
export const updateIndexHtml = (content) => {
|
|
24
|
+
export const updateIndexHtml = (content, appId, baseUrl, contentUrl) => {
|
|
21
25
|
return content
|
|
22
|
-
.replace(
|
|
26
|
+
.replace(
|
|
27
|
+
occurrenceSnippetBody,
|
|
28
|
+
replacementSnippetBody(appId, baseUrl, contentUrl)
|
|
29
|
+
)
|
|
23
30
|
.replace(occurrenceSnippetHead, replacementSnippetHead);
|
|
24
31
|
};
|