@pronto-tools-and-more/pronto 12.42.0 → 12.44.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/pronto",
3
- "version": "12.42.0",
3
+ "version": "12.44.0",
4
4
  "description": "",
5
5
  "main": "src/main.js",
6
6
  "type": "module",
@@ -17,17 +17,17 @@
17
17
  "@lvce-editor/ipc": "^13.7.0",
18
18
  "@lvce-editor/json-rpc": "^5.4.0",
19
19
  "@lvce-editor/verror": "^1.6.0",
20
- "@pronto-tools-and-more/api": "12.42.0",
21
- "@pronto-tools-and-more/components-renderer": "12.42.0",
22
- "@pronto-tools-and-more/components": "12.42.0",
23
- "@pronto-tools-and-more/custom-js-functions": "12.42.0",
24
- "@pronto-tools-and-more/diff-process": "12.42.0",
25
- "@pronto-tools-and-more/file-watcher": "12.42.0",
26
- "@pronto-tools-and-more/files": "12.42.0",
27
- "@pronto-tools-and-more/network-process": "12.42.0",
28
- "@pronto-tools-and-more/sass-compiler": "12.42.0",
29
- "@pronto-tools-and-more/schema-process": "12.42.0",
30
- "@pronto-tools-and-more/type-checker": "12.42.0",
20
+ "@pronto-tools-and-more/api": "12.44.0",
21
+ "@pronto-tools-and-more/components-renderer": "12.44.0",
22
+ "@pronto-tools-and-more/components": "12.44.0",
23
+ "@pronto-tools-and-more/custom-js-functions": "12.44.0",
24
+ "@pronto-tools-and-more/diff-process": "12.44.0",
25
+ "@pronto-tools-and-more/file-watcher": "12.44.0",
26
+ "@pronto-tools-and-more/files": "12.44.0",
27
+ "@pronto-tools-and-more/network-process": "12.44.0",
28
+ "@pronto-tools-and-more/sass-compiler": "12.44.0",
29
+ "@pronto-tools-and-more/schema-process": "12.44.0",
30
+ "@pronto-tools-and-more/type-checker": "12.44.0",
31
31
  "execa": "^9.5.2",
32
32
  "express": "^4.21.2"
33
33
  },
@@ -33,6 +33,7 @@ export const create = ({
33
33
  shimConfigLoader,
34
34
  apiUrl,
35
35
  supportNormalHtmlElements,
36
+ useFrameWorkLatest,
36
37
  }) => {
37
38
  const app = express();
38
39
  const storeFrontPath = join(root, "src", "default", "storefront");
@@ -48,6 +49,7 @@ export const create = ({
48
49
  platform,
49
50
  mode,
50
51
  filesPath: FilesPath.filesPath,
52
+ useFrameWorkLatest,
51
53
  })
52
54
  );
53
55
 
@@ -68,6 +70,7 @@ export const create = ({
68
70
  companyUrl,
69
71
  filesPath: FilesPath.filesPath,
70
72
  mode,
73
+ useFrameWorkLatest,
71
74
  })
72
75
  );
73
76
  if (supportNormalHtmlElements) {
@@ -77,6 +80,7 @@ export const create = ({
77
80
  storeFrontPath,
78
81
  filesPath: FilesPath.filesPath,
79
82
  mode,
83
+ useFrameWorkLatest,
80
84
  })
81
85
  );
82
86
  }
@@ -95,6 +99,7 @@ export const create = ({
95
99
  HandleFeaturesJson.handleFeaturesJson({
96
100
  storeFrontPath,
97
101
  filesPath: FilesPath.filesPath,
102
+ useFrameWorkLatest,
98
103
  })
99
104
  );
100
105
  app.get(
@@ -113,9 +118,10 @@ export const create = ({
113
118
  app.use(express.static(defaultPath));
114
119
  app.use(express.static(contentPath));
115
120
  if (mode === "slim") {
121
+ const frameWorkName = useFrameWorkLatest ? "framework-latest" : "framework";
116
122
  app.use(
117
123
  express.static(
118
- join(FilesPath.filesPath, "framework", "src", "default", "storefront")
124
+ join(FilesPath.filesPath, frameWorkName, "src", "default", "storefront")
119
125
  )
120
126
  );
121
127
  }
@@ -28,8 +28,12 @@ export const build = async () => {
28
28
  await writeFile(rootCssMapFile, JSON.stringify(result.sourceMap) + "\n");
29
29
  if (Config.mode === "slim") {
30
30
  await mkdir(join(dist, "src"), { recursive: true });
31
+ const frameWorkName = Config.useFrameWorkLatest
32
+ ? "framework-latest"
33
+ : "framework";
34
+
31
35
  await cp(
32
- join(FilesPath.filesPath, "framework", "src"),
36
+ join(FilesPath.filesPath, frameWorkName, "src"),
33
37
  join(dist, "src"),
34
38
  {
35
39
  recursive: true,
@@ -12,6 +12,7 @@ import * as Split from "../Split/Split.js";
12
12
  import * as TypeCheck from "../TypeCheck/TypeCheck.js";
13
13
  import * as Upgrade from "../Upgrade/Upgrade.js";
14
14
  import * as UploadZip from "../UploadZip/UploadZip.js";
15
+ import * as UpgradeLatest from "../UpgradeLatest/UpgradeLatest.js";
15
16
  import * as ValidateAllSchemas from "../ValidateAllSchemas/ValidateAllSchemas.js";
16
17
 
17
18
  export const commandMap = {
@@ -28,6 +29,7 @@ export const commandMap = {
28
29
  "ListExperienceVersionsAndPrint.listExperienceVersionsAndPrint":
29
30
  ListExperienceVersionsAndPrint.listExperienceVersionsAndPrint,
30
31
  "UploadZip.uploadZip": UploadZip.uploadZip,
32
+ "UpgradeLatest.upgradeLatest": UpgradeLatest.upgradeLatest,
31
33
  "ValidateAllSchema.validateAllSchemas": ValidateAllSchemas.validateAllSchemas,
32
34
  "PrintVersion.printVersion": PrintVersion.printVersion,
33
35
  "TypeCheck.typeCheck": TypeCheck.typeCheck,
@@ -123,3 +123,5 @@ export const supportNormalHtmlElements =
123
123
 
124
124
  export const apiUrl =
125
125
  process.env.API_URL || "https://catalog.purplemanager.com/graphql";
126
+
127
+ export const useFrameWorkLatest = config.useFrameWorkLatest || false;
@@ -31,6 +31,7 @@ export const createServer = async (root, errorColor) => {
31
31
  releaseAppId: Config.releaseAppId,
32
32
  apiUrl: Config.apiUrl,
33
33
  supportNormalHtmlElements: Config.supportNormalHtmlElements,
34
+ useFrameWorkLatest: Config.useFrameWorkLatest,
34
35
  });
35
36
  const server = http.createServer(app);
36
37
  const webSocketServer = new ws.WebSocketServer({
@@ -1,8 +1,14 @@
1
1
  import { join } from "node:path";
2
2
 
3
- export const getBasePath = (mode, storeFrontPath, filesPath) => {
3
+ export const getBasePath = ({
4
+ mode,
5
+ storeFrontPath,
6
+ filesPath,
7
+ useFrameWorkLatest,
8
+ }) => {
4
9
  if (mode === "slim") {
5
- return join(filesPath, "framework", "src", "default", "storefront");
10
+ const frameWorkName = useFrameWorkLatest ? "framework-latest" : "framework";
11
+ return join(filesPath, frameWorkName, "src", "default", "storefront");
6
12
  }
7
13
  return storeFrontPath;
8
14
  };
@@ -14,6 +14,9 @@ export const getCommandFromCliArgs = (argv) => {
14
14
  if (argv.includes("upgrade")) {
15
15
  return "Upgrade.upgrade";
16
16
  }
17
+ if (argv.includes("upgrade-latest")) {
18
+ return "UpgradeLatest.upgradeLatest";
19
+ }
17
20
  if (argv.includes("list-experience-versions")) {
18
21
  return "ListExperienceVersionsAndPrint.listExperienceVersionsAndPrint";
19
22
  }
@@ -0,0 +1,11 @@
1
+ import * as Assert from "../Assert/Assert.js";
2
+
3
+ export const getLatestUnstableVersion = (versions) => {
4
+ Assert.array(versions);
5
+ for (const version of versions) {
6
+ if (version.endsWith("-SNAPSHOT")) {
7
+ return version;
8
+ }
9
+ }
10
+ throw new Error(`latest stable version not found`);
11
+ };
@@ -5,9 +5,14 @@ import * as GetCommonJsSnippet from "../GetCommonJsSnippet/GetCommonJsSnippet.js
5
5
  import * as GetNewCommonJsContent from "../GetNewCommonJsContent/GetNewCommonJsContent.js";
6
6
 
7
7
  export const handleCommonJs =
8
- ({ storeFrontPath, filesPath, mode }) =>
8
+ ({ storeFrontPath, filesPath, mode, useFrameWorkLatest }) =>
9
9
  async (req, res) => {
10
- const basePath = GetBasePath.getBasePath(mode, storeFrontPath, filesPath);
10
+ const basePath = GetBasePath.getBasePath({
11
+ mode,
12
+ storeFrontPath,
13
+ filesPath,
14
+ useFrameWorkLatest,
15
+ });
11
16
  // TODO use etag
12
17
  const commonPath = join(basePath, "modules", "common.js");
13
18
  const content = await readFile(commonPath, "utf8");
@@ -3,14 +3,15 @@ import { readFile } from "fs/promises";
3
3
  import { join } from "path";
4
4
 
5
5
  export const handleFeaturesJson =
6
- ({ storeFrontPath, filesPath }) =>
6
+ ({ storeFrontPath, filesPath, useFrameWorkLatest }) =>
7
7
  async (req, res) => {
8
8
  res.setHeader("Content-Type", "application/json");
9
+ const frameWorkName = useFrameWorkLatest ? "framework-latest" : "framework";
9
10
  const pathsToTry = [
10
11
  join(storeFrontPath, "assets", "features.json"),
11
12
  join(
12
13
  filesPath,
13
- "framework",
14
+ frameWorkName,
14
15
  "src",
15
16
  "default",
16
17
  "storefront",
@@ -2,8 +2,14 @@ import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import * as UpdateIndexHtml from "../UpdateIndexHtml/UpdateIndexHtml.js";
4
4
 
5
- const getIndexHtmlPath = (mode, filesPath, storeFrontPath) => {
5
+ const getIndexHtmlPath = ({
6
+ mode,
7
+ filesPath,
8
+ storeFrontPath,
9
+ useFrameWorkLatest,
10
+ }) => {
6
11
  if (mode === "slim") {
12
+ const frameWorkName = useFrameWorkLatest ? "framework-latest" : "framework";
7
13
  return join(
8
14
  filesPath,
9
15
  "framework",
@@ -17,9 +23,23 @@ const getIndexHtmlPath = (mode, filesPath, storeFrontPath) => {
17
23
  };
18
24
 
19
25
  export const handleIndex =
20
- ({ storeFrontPath, appId, baseUrl, contentUrl, platform, mode, filesPath }) =>
26
+ ({
27
+ storeFrontPath,
28
+ appId,
29
+ baseUrl,
30
+ contentUrl,
31
+ platform,
32
+ mode,
33
+ filesPath,
34
+ useFrameWorkLatest,
35
+ }) =>
21
36
  async (req, res) => {
22
- const indexHtmlPath = getIndexHtmlPath(mode, filesPath, storeFrontPath);
37
+ const indexHtmlPath = getIndexHtmlPath({
38
+ mode,
39
+ filesPath,
40
+ storeFrontPath,
41
+ useFrameWorkLatest,
42
+ });
23
43
  const indexHtmlContent = await readFile(indexHtmlPath, "utf8");
24
44
  const newIndexHtml = UpdateIndexHtml.updateIndexHtml(
25
45
  indexHtmlContent,
@@ -14,9 +14,15 @@ export const handleMainJs =
14
14
  companyUrl,
15
15
  filesPath,
16
16
  mode,
17
+ useFrameWorkLatest,
17
18
  }) =>
18
19
  async (req, res) => {
19
- const basePath = GetBasePath.getBasePath(mode, storeFrontPath, filesPath);
20
+ const basePath = GetBasePath.getBasePath({
21
+ mode,
22
+ storeFrontPath,
23
+ filesPath,
24
+ useFrameWorkLatest,
25
+ });
20
26
  // TODO use etag
21
27
  const mainPath = join(basePath, "modules", "main.js");
22
28
  const content = await readFile(mainPath, "utf8");
@@ -0,0 +1,69 @@
1
+ import { VError } from "@lvce-editor/verror";
2
+ import { join } from "node:path";
3
+ import * as Config from "../Config/Config.js";
4
+ import * as Cwd from "../Cwd/Cwd.js";
5
+ import * as DiffSimple from "../DiffSimple/DiffSimple.js";
6
+ import * as DownloadDiffFiles from "../DownloadDiffFiles/DownloadDiffFiles.js";
7
+ import * as GetLatestUnstableVersion from "../GetLatestUnstableVersion/GetLatestUnstableVersion.js";
8
+ import * as GetSessionId from "../GetSessionId/GetSessionId.js";
9
+ import * as ListExperienceVersions from "../ListExperienceVersions/ListExperienceVersions.js";
10
+ import * as MakeUpgradeRequest from "../MakeUpgradeRequest/MakeUpgradeRequest.js";
11
+ import * as NetworkProcess from "../NetworkProcess/NetworkProcess.js";
12
+ import * as PullWorkingCopy from "../PullWorkingCopy/PullWorkingCopy.js";
13
+
14
+ export const upgradeLatest = async () => {
15
+ try {
16
+ const {
17
+ userEmail,
18
+ userPassword,
19
+ loginUrl,
20
+ appId,
21
+ listVersionsUrl,
22
+ appsUrl,
23
+ diffSimpleUrl,
24
+ downloadFileBaseUrl,
25
+ pullWorkingCopyUrl,
26
+ } = Config;
27
+ const src = join(Cwd.cwd, "src");
28
+ const sessionId = await GetSessionId.getSessionId({
29
+ loginUrl,
30
+ userEmail,
31
+ userPassword,
32
+ });
33
+ await PullWorkingCopy.pullWorkingCopy({
34
+ appId,
35
+ sessionId,
36
+ pullWorkingCopyUrl,
37
+ });
38
+ const versions = await ListExperienceVersions.listExperienceVersions({
39
+ listVersionsUrl,
40
+ sessionId,
41
+ appId,
42
+ });
43
+ const latestStableVersion =
44
+ GetLatestUnstableVersion.getLatestUnstableVersion(versions);
45
+ console.info(`[pronto] Found latest version ${latestStableVersion}`);
46
+ await MakeUpgradeRequest.makeUpgradeRequest({
47
+ appsUrl,
48
+ appId,
49
+ sessionId,
50
+ targetVersion: latestStableVersion,
51
+ });
52
+ const diffFiles = await DiffSimple.diffSimple({
53
+ diffSimpleUrl,
54
+ sessionId,
55
+ appId,
56
+ });
57
+ await DownloadDiffFiles.downloadDiffFiles({
58
+ diffFiles,
59
+ src,
60
+ downloadFileBaseUrl,
61
+ appId,
62
+ sessionId,
63
+ });
64
+ } catch (error) {
65
+ throw new VError(error, `Failed to upgrade`);
66
+ } finally {
67
+ NetworkProcess.dispose();
68
+ }
69
+ };
@@ -1 +1 @@
1
- export const version = '12.42.0'
1
+ export const version = '12.44.0'