@wix/cli 1.1.59 → 1.1.61
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/build/{DevCommand-PLIPWJKO.js → DevCommand-3CEY3HPC.js} +17 -16
- package/build/{DevCommand-PLIPWJKO.js.map → DevCommand-3CEY3HPC.js.map} +1 -1
- package/build/{DevCommand-D6QHU2YA.js → DevCommand-NPVKUDPR.js} +27 -876
- package/build/DevCommand-NPVKUDPR.js.map +1 -0
- package/build/{LoginCommand-NRZ4VWWM.js → LoginCommand-RTNDZF77.js} +12 -12
- package/build/{LogoutCommand-INOYIE67.js → LogoutCommand-CUOS2BUH.js} +8 -8
- package/build/PreviewCommand-5GAG7MBS.js +471 -0
- package/build/PreviewCommand-5GAG7MBS.js.map +1 -0
- package/build/{WhoamiCommand-4V4GTNFW.js → WhoamiCommand-VZ6KKOVQ.js} +5 -5
- package/build/{chunk-F3E4MMLD.js → chunk-2KK3GKES.js} +6 -6
- package/build/{chunk-6F2RSXHN.js → chunk-2NWGTFAC.js} +3 -3
- package/build/{chunk-6F2RSXHN.js.map → chunk-2NWGTFAC.js.map} +1 -1
- package/build/{chunk-Z7P6TDPB.js → chunk-2WA6TGDO.js} +6 -6
- package/build/{chunk-HYAIYTKF.js → chunk-332V5RP4.js} +59 -7
- package/build/{chunk-HYAIYTKF.js.map → chunk-332V5RP4.js.map} +1 -1
- package/build/{chunk-SELJR2HV.js → chunk-3NEXZN7N.js} +5 -66
- package/build/chunk-3NEXZN7N.js.map +1 -0
- package/build/{chunk-JG7FKL4X.js → chunk-3UE73ERL.js} +29 -9
- package/build/chunk-3UE73ERL.js.map +1 -0
- package/build/{chunk-OOGMXJJV.js → chunk-6K6VPM3T.js} +6 -6
- package/build/chunk-6LI4WGAW.js +43 -0
- package/build/chunk-6LI4WGAW.js.map +1 -0
- package/build/chunk-6XRFJZTQ.js +74 -0
- package/build/chunk-6XRFJZTQ.js.map +1 -0
- package/build/{chunk-5ZVEBKUO.js → chunk-6YVNZGPU.js} +597 -362
- package/build/chunk-6YVNZGPU.js.map +1 -0
- package/build/{chunk-U32RURCT.js → chunk-77YDQA7O.js} +6 -6
- package/build/chunk-B5A3CFP2.js +135 -0
- package/build/chunk-B5A3CFP2.js.map +1 -0
- package/build/{chunk-IFQQVSBK.js → chunk-BGKFJNUK.js} +2 -2
- package/build/{chunk-VEVISRHN.js → chunk-DEO7G3RD.js} +5 -5
- package/build/{chunk-CS26555F.js → chunk-DP2BL2V4.js} +7 -7
- package/build/{chunk-X7XOMWAQ.js → chunk-G4NFI3XC.js} +4 -4
- package/build/{chunk-T4OH34QF.js → chunk-H6BDO22X.js} +12 -4
- package/build/{chunk-T4OH34QF.js.map → chunk-H6BDO22X.js.map} +1 -1
- package/build/{chunk-QGSHUCNV.js → chunk-HMGX4HL2.js} +49 -18
- package/build/chunk-HMGX4HL2.js.map +1 -0
- package/build/{chunk-AXVTET6V.js → chunk-HV2IEAOB.js} +2 -2
- package/build/{chunk-V4DAKO7L.js → chunk-J573TQNU.js} +577 -574
- package/build/chunk-J573TQNU.js.map +1 -0
- package/build/{chunk-4HVBZRJL.js → chunk-KOGQSQ4I.js} +2 -2
- package/build/{chunk-4OBSJ6OG.js → chunk-L53ZVQB7.js} +139 -113
- package/build/{chunk-4OBSJ6OG.js.map → chunk-L53ZVQB7.js.map} +1 -1
- package/build/{chunk-N5IXBRXL.js → chunk-M34KVUTA.js} +2 -2
- package/build/{chunk-3RBFRZE2.js → chunk-N3OHN3MH.js} +5 -5
- package/build/{chunk-3RBFRZE2.js.map → chunk-N3OHN3MH.js.map} +1 -1
- package/build/{chunk-GLXEVSFE.js → chunk-P4UAXEEN.js} +14 -132
- package/build/chunk-P4UAXEEN.js.map +1 -0
- package/build/{chunk-BV3B44QL.js → chunk-PTIE2TCP.js} +3 -3
- package/build/{chunk-BNWDAMAL.js → chunk-PX2L3CCA.js} +2 -2
- package/build/chunk-PX2L3CCA.js.map +1 -0
- package/build/chunk-Q3GS63B5.js +901 -0
- package/build/chunk-Q3GS63B5.js.map +1 -0
- package/build/{chunk-5XUFGBCU.js → chunk-SEOIN2A6.js} +7 -3
- package/build/chunk-SEOIN2A6.js.map +1 -0
- package/build/{chunk-YUFAOC35.js → chunk-V7JWKPQI.js} +8 -8
- package/build/{chunk-VRDC2KLN.js → chunk-VXGNI7CP.js} +5 -2
- package/build/{chunk-VRDC2KLN.js.map → chunk-VXGNI7CP.js.map} +1 -1
- package/build/{chunk-CMXHWKEP.js → chunk-XFEYPXEY.js} +3 -3
- package/build/{chunk-G6TDIUNY.js → chunk-Y4ZVXLXY.js} +2 -2
- package/build/{chunk-PNUERA4W.js → chunk-ZVHSVTAJ.js} +5 -5
- package/build/{dev-TEWYYBKR.js → dev-FOGJASYZ.js} +31 -30
- package/build/{dev-TEWYYBKR.js.map → dev-FOGJASYZ.js.map} +1 -1
- package/build/index.js +29 -29
- package/build/{install-MTS6LPPU.js → install-NSVJU2EB.js} +22 -21
- package/build/{install-MTS6LPPU.js.map → install-NSVJU2EB.js.map} +1 -1
- package/build/{preview-TDMPHSVV.js → preview-RQ5CLHV5.js} +24 -22
- package/build/{preview-TDMPHSVV.js.map → preview-RQ5CLHV5.js.map} +1 -1
- package/build/{publish-5VLMBE6J.js → publish-YWESFDVY.js} +30 -27
- package/build/publish-YWESFDVY.js.map +1 -0
- package/build/{render-command-7OMEGPW4.js → render-command-4GOKWOT7.js} +11 -11
- package/build/{render-command-UQPFUBIL.js → render-command-E3JPPTZA.js} +12 -12
- package/build/{render-command-FELGYBEY.js → render-command-WMEIFR3G.js} +13 -13
- package/build/{run-command-3YTQS4ZX.js → run-command-D54S2NI5.js} +9 -9
- package/build/{src-Y334LPF5.js → src-4W7XB5DS.js} +21 -9
- package/build/src-4W7XB5DS.js.map +1 -0
- package/build/{src-4W2WPIAM.js → src-HA6XHM2E.js} +8 -8
- package/build/{src-7NEL65ZK.js → src-IIEVMGC3.js} +18 -18
- package/build/{src-UWOBS6D7.js → src-NGHHXRWJ.js} +2 -2
- package/build/{src-LA3GYOE6.js → src-NS46VL23.js} +7 -7
- package/build/{src-IBLQL7AB.js → src-OIVJ4AKD.js} +6 -6
- package/build/{src-BMV74WCO.js → src-XSN6C5L2.js} +3 -3
- package/build/sync-types-SQEHJPEG.js +31 -0
- package/build/{uninstall-M4DEVSQC.js → uninstall-ASZ55QZA.js} +20 -19
- package/build/{uninstall-M4DEVSQC.js.map → uninstall-ASZ55QZA.js.map} +1 -1
- package/package.json +3 -3
- package/build/DevCommand-D6QHU2YA.js.map +0 -1
- package/build/chunk-5XUFGBCU.js.map +0 -1
- package/build/chunk-5ZVEBKUO.js.map +0 -1
- package/build/chunk-BNWDAMAL.js.map +0 -1
- package/build/chunk-GLXEVSFE.js.map +0 -1
- package/build/chunk-JG7FKL4X.js.map +0 -1
- package/build/chunk-QGSHUCNV.js.map +0 -1
- package/build/chunk-SELJR2HV.js.map +0 -1
- package/build/chunk-V4DAKO7L.js.map +0 -1
- package/build/publish-5VLMBE6J.js.map +0 -1
- package/build/src-Y334LPF5.js.map +0 -1
- package/build/sync-types-W3PVOJTK.js +0 -30
- /package/build/{LoginCommand-NRZ4VWWM.js.map → LoginCommand-RTNDZF77.js.map} +0 -0
- /package/build/{LogoutCommand-INOYIE67.js.map → LogoutCommand-CUOS2BUH.js.map} +0 -0
- /package/build/{WhoamiCommand-4V4GTNFW.js.map → WhoamiCommand-VZ6KKOVQ.js.map} +0 -0
- /package/build/{chunk-F3E4MMLD.js.map → chunk-2KK3GKES.js.map} +0 -0
- /package/build/{chunk-Z7P6TDPB.js.map → chunk-2WA6TGDO.js.map} +0 -0
- /package/build/{chunk-OOGMXJJV.js.map → chunk-6K6VPM3T.js.map} +0 -0
- /package/build/{chunk-U32RURCT.js.map → chunk-77YDQA7O.js.map} +0 -0
- /package/build/{chunk-IFQQVSBK.js.map → chunk-BGKFJNUK.js.map} +0 -0
- /package/build/{chunk-VEVISRHN.js.map → chunk-DEO7G3RD.js.map} +0 -0
- /package/build/{chunk-CS26555F.js.map → chunk-DP2BL2V4.js.map} +0 -0
- /package/build/{chunk-X7XOMWAQ.js.map → chunk-G4NFI3XC.js.map} +0 -0
- /package/build/{chunk-AXVTET6V.js.map → chunk-HV2IEAOB.js.map} +0 -0
- /package/build/{chunk-4HVBZRJL.js.map → chunk-KOGQSQ4I.js.map} +0 -0
- /package/build/{chunk-N5IXBRXL.js.map → chunk-M34KVUTA.js.map} +0 -0
- /package/build/{chunk-BV3B44QL.js.map → chunk-PTIE2TCP.js.map} +0 -0
- /package/build/{chunk-YUFAOC35.js.map → chunk-V7JWKPQI.js.map} +0 -0
- /package/build/{chunk-CMXHWKEP.js.map → chunk-XFEYPXEY.js.map} +0 -0
- /package/build/{chunk-G6TDIUNY.js.map → chunk-Y4ZVXLXY.js.map} +0 -0
- /package/build/{chunk-PNUERA4W.js.map → chunk-ZVHSVTAJ.js.map} +0 -0
- /package/build/{render-command-7OMEGPW4.js.map → render-command-4GOKWOT7.js.map} +0 -0
- /package/build/{render-command-UQPFUBIL.js.map → render-command-E3JPPTZA.js.map} +0 -0
- /package/build/{render-command-FELGYBEY.js.map → render-command-WMEIFR3G.js.map} +0 -0
- /package/build/{run-command-3YTQS4ZX.js.map → run-command-D54S2NI5.js.map} +0 -0
- /package/build/{src-4W2WPIAM.js.map → src-HA6XHM2E.js.map} +0 -0
- /package/build/{src-7NEL65ZK.js.map → src-IIEVMGC3.js.map} +0 -0
- /package/build/{src-BMV74WCO.js.map → src-NGHHXRWJ.js.map} +0 -0
- /package/build/{src-LA3GYOE6.js.map → src-NS46VL23.js.map} +0 -0
- /package/build/{src-IBLQL7AB.js.map → src-OIVJ4AKD.js.map} +0 -0
- /package/build/{src-UWOBS6D7.js.map → src-XSN6C5L2.js.map} +0 -0
- /package/build/{sync-types-W3PVOJTK.js.map → sync-types-SQEHJPEG.js.map} +0 -0
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
import { createRequire as _createRequire } from 'node:module';
|
|
2
|
+
const require = _createRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
getSourceFolder
|
|
5
|
+
} from "./chunk-SEOIN2A6.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError,
|
|
8
|
+
CliErrorCode
|
|
9
|
+
} from "./chunk-H6BDO22X.js";
|
|
10
|
+
import {
|
|
11
|
+
init_esm_shims
|
|
12
|
+
} from "./chunk-PYIAC2GK.js";
|
|
13
|
+
|
|
14
|
+
// ../cli-site/src/site-fs-manager.ts
|
|
15
|
+
init_esm_shims();
|
|
16
|
+
import { relative } from "node:path";
|
|
17
|
+
|
|
18
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/index.js
|
|
19
|
+
init_esm_shims();
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/wixSiteFSManager.js
|
|
22
|
+
init_esm_shims();
|
|
23
|
+
|
|
24
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/code/index.js
|
|
25
|
+
init_esm_shims();
|
|
26
|
+
|
|
27
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/code/code.js
|
|
28
|
+
init_esm_shims();
|
|
29
|
+
import path from "path";
|
|
30
|
+
|
|
31
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/code/utils/veloUtils.js
|
|
32
|
+
init_esm_shims();
|
|
33
|
+
|
|
34
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/code/utils/constants.js
|
|
35
|
+
init_esm_shims();
|
|
36
|
+
var PAGE_CODE_TEMPLATE = `// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
|
|
37
|
+
// \u201CHello, World!\u201D Example: https://learn-code.wix.com/en/article/hello-world
|
|
38
|
+
|
|
39
|
+
$w.onReady(function () {
|
|
40
|
+
// Write your JavaScript here
|
|
41
|
+
|
|
42
|
+
// To select an element by ID use: $w('#elementID')
|
|
43
|
+
|
|
44
|
+
// Click 'Preview' to run your code
|
|
45
|
+
});
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/node_modules/@wix/velo-github-layout-definitions/build/index.js
|
|
49
|
+
init_esm_shims();
|
|
50
|
+
import { join } from "node:path";
|
|
51
|
+
function getSourceFolder2(projectFolder) {
|
|
52
|
+
return join(projectFolder, "src");
|
|
53
|
+
}
|
|
54
|
+
function getPagesFolder(projectFolder = "") {
|
|
55
|
+
return join(getSourceFolder2(projectFolder), "pages");
|
|
56
|
+
}
|
|
57
|
+
function getPublicFolder(projectFolder = "") {
|
|
58
|
+
return join(getSourceFolder2(projectFolder), "public");
|
|
59
|
+
}
|
|
60
|
+
function getBackendFolder(projectFolder = "") {
|
|
61
|
+
return join(getSourceFolder2(projectFolder), "backend");
|
|
62
|
+
}
|
|
63
|
+
function getStylesFolder(projectFolder = "") {
|
|
64
|
+
return join(getSourceFolder2(projectFolder), "styles");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/types.js
|
|
68
|
+
init_esm_shims();
|
|
69
|
+
var foldersType = {
|
|
70
|
+
backend: "backend",
|
|
71
|
+
public: "public",
|
|
72
|
+
styles: "styles"
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/code/utils/veloUtils.js
|
|
76
|
+
var createDefaultPageCodeFile = async (siteFileSystem, filePath) => siteFileSystem.writeFile(filePath, PAGE_CODE_TEMPLATE);
|
|
77
|
+
var getPageCodeFilePath = (pageId) => `${getPagesFolder()}/${pageId}.js`;
|
|
78
|
+
var convertToGithubLayout = (state, path6, folderType) => {
|
|
79
|
+
switch (folderType) {
|
|
80
|
+
case foldersType.backend:
|
|
81
|
+
return transformPath(path6, state.fileStructure.getBackendFolderPath(), getBackendFolder());
|
|
82
|
+
case foldersType.public:
|
|
83
|
+
return transformPath(path6, state.fileStructure.getPublicFolderPath(), getPublicFolder());
|
|
84
|
+
case foldersType.styles:
|
|
85
|
+
return transformPath(path6, state.fileStructure.getStylesFolderPath(), getStylesFolder());
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var transformPath = (path6, basePath, folderPrefix) => {
|
|
89
|
+
const relativePath = path6.replace(`${basePath}/`, "");
|
|
90
|
+
return `${folderPrefix}/${relativePath}`;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/code/code.js
|
|
94
|
+
var readAllFilesInDir = async (state, dir, folderType) => {
|
|
95
|
+
const entries = await state.fileSystem.readFolder(dir);
|
|
96
|
+
const filePromises = entries.map(async (entry) => {
|
|
97
|
+
const entryPath = path.join(dir, entry.name);
|
|
98
|
+
if (entry.isFile()) {
|
|
99
|
+
return {
|
|
100
|
+
path: convertToGithubLayout(state, entryPath, folderType),
|
|
101
|
+
content: await state.fileSystem.readFile(entryPath)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return readAllFilesInDir(state, entryPath, folderType);
|
|
105
|
+
});
|
|
106
|
+
return (await Promise.all(filePromises)).flat();
|
|
107
|
+
};
|
|
108
|
+
var readBackendFiles = async (state) => readAllFilesInDir(state, state.fileStructure.getBackendFolderPath(), foldersType.backend);
|
|
109
|
+
var readPublicFiles = async (state) => readAllFilesInDir(state, state.fileStructure.getPublicFolderPath(), foldersType.public);
|
|
110
|
+
var readStylesFiles = async (state) => readAllFilesInDir(state, state.fileStructure.getStylesFolderPath(), foldersType.styles);
|
|
111
|
+
var readPageCodeFiles = async (state) => {
|
|
112
|
+
const codeFiles = [];
|
|
113
|
+
const pages = state.pages.getAll();
|
|
114
|
+
for (const { pageId, pagePath } of pages) {
|
|
115
|
+
const page = state.fileStructure.getPageFilesPaths(pagePath);
|
|
116
|
+
const content = await state.fileSystem.readFile(page.code);
|
|
117
|
+
codeFiles.push({ path: getPageCodeFilePath(pageId), content });
|
|
118
|
+
}
|
|
119
|
+
return codeFiles;
|
|
120
|
+
};
|
|
121
|
+
var getSiteCode = async (state) => {
|
|
122
|
+
const allFiles = await Promise.all([
|
|
123
|
+
readBackendFiles(state),
|
|
124
|
+
readPublicFiles(state),
|
|
125
|
+
readStylesFiles(state),
|
|
126
|
+
readPageCodeFiles(state)
|
|
127
|
+
]);
|
|
128
|
+
return {
|
|
129
|
+
files: allFiles.flat(),
|
|
130
|
+
layout: "GITHUB",
|
|
131
|
+
ignoreForbiddenPaths: true
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
var onlinePathRegex = /^(public\/pages|public|backend|styles)\/?((.+)\.js|.*)$/;
|
|
135
|
+
var splitOnlinePath = (onlinePath) => {
|
|
136
|
+
const [, folderPath, relativeFilePath, pageId] = onlinePathRegex.exec(onlinePath) ?? [];
|
|
137
|
+
return {
|
|
138
|
+
folderPath,
|
|
139
|
+
relativeFilePath,
|
|
140
|
+
pageId
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
var buildCodeFilePath = (folderPath, relativeFilePath) => {
|
|
144
|
+
if (!relativeFilePath) {
|
|
145
|
+
return folderPath;
|
|
146
|
+
}
|
|
147
|
+
return path.join(folderPath, relativeFilePath);
|
|
148
|
+
};
|
|
149
|
+
var buildPageCodeFilePath = ({ pages, fileStructure }, pageId) => {
|
|
150
|
+
if (!pageId) {
|
|
151
|
+
throw new Error("Invalid page code file path");
|
|
152
|
+
}
|
|
153
|
+
const pageFolderPath = pages.getFolderPath(pageId);
|
|
154
|
+
if (!pageFolderPath) {
|
|
155
|
+
throw new Error("Page does not exist");
|
|
156
|
+
}
|
|
157
|
+
return fileStructure.getPageFilesPaths(pageFolderPath).code;
|
|
158
|
+
};
|
|
159
|
+
var convertOnlineLayoutToRelativePath = (state, onlinePath) => {
|
|
160
|
+
const { fileStructure } = state;
|
|
161
|
+
const { folderPath, relativeFilePath, pageId } = splitOnlinePath(onlinePath);
|
|
162
|
+
switch (folderPath) {
|
|
163
|
+
case "public":
|
|
164
|
+
return buildCodeFilePath(fileStructure.getPublicFolderPath(), relativeFilePath);
|
|
165
|
+
case "backend":
|
|
166
|
+
return buildCodeFilePath(fileStructure.getBackendFolderPath(), relativeFilePath);
|
|
167
|
+
case "styles":
|
|
168
|
+
return buildCodeFilePath(fileStructure.getStylesFolderPath(), relativeFilePath);
|
|
169
|
+
case "public/pages":
|
|
170
|
+
return buildPageCodeFilePath(state, pageId);
|
|
171
|
+
default:
|
|
172
|
+
throw new Error("Unknown online path");
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var convertOnlineLayout = (state, basePath, onlinePath) => path.join(basePath, convertOnlineLayoutToRelativePath(state, onlinePath));
|
|
176
|
+
|
|
177
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/document/index.js
|
|
178
|
+
init_esm_shims();
|
|
179
|
+
|
|
180
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/document/document.js
|
|
181
|
+
init_esm_shims();
|
|
182
|
+
|
|
183
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/document/utils/wmlUtils.js
|
|
184
|
+
init_esm_shims();
|
|
185
|
+
var pageIdRegex = /<(?:Master)?Page\s[^>]*?(?<=\s)id="(.+?)".*?>/;
|
|
186
|
+
var getPageId = async (siteFileSystem, { structure }) => {
|
|
187
|
+
const structureXmlContent = await siteFileSystem.readFile(structure);
|
|
188
|
+
const [match, pageId] = structureXmlContent.match(pageIdRegex) ?? [];
|
|
189
|
+
if (!match) {
|
|
190
|
+
throw new Error("pageId not found in wml");
|
|
191
|
+
}
|
|
192
|
+
return pageId;
|
|
193
|
+
};
|
|
194
|
+
var mapWmlFiles = async (documentStructure, callbackFn) => {
|
|
195
|
+
const [structure, data, style] = await Promise.all([
|
|
196
|
+
callbackFn(documentStructure.structure, "structure"),
|
|
197
|
+
callbackFn(documentStructure.data, "data"),
|
|
198
|
+
callbackFn(documentStructure.style, "style")
|
|
199
|
+
]);
|
|
200
|
+
return { structure, data, style };
|
|
201
|
+
};
|
|
202
|
+
var writeWmlFiles = async (siteFileSystem, documentStructure, wml) => {
|
|
203
|
+
const filesContent = convertWmlExportToFiles(wml);
|
|
204
|
+
await mapWmlFiles(documentStructure, (filePath, fileName) => siteFileSystem.writeFile(filePath, filesContent[fileName]));
|
|
205
|
+
};
|
|
206
|
+
var removeWmlFiles = async (siteFileSystem, documentStructure) => {
|
|
207
|
+
await mapWmlFiles(documentStructure, (filePath) => siteFileSystem.removeFile(filePath));
|
|
208
|
+
};
|
|
209
|
+
var writeWml = async (siteFileSystem, documentStructure, pageData) => {
|
|
210
|
+
if (pageData === null) {
|
|
211
|
+
return removeWmlFiles(siteFileSystem, documentStructure);
|
|
212
|
+
}
|
|
213
|
+
return writeWmlFiles(siteFileSystem, documentStructure, pageData.data);
|
|
214
|
+
};
|
|
215
|
+
var readWml = async (siteFileSystem, documentStructure) => {
|
|
216
|
+
const filesContent = await mapWmlFiles(documentStructure, async (filePath) => await siteFileSystem.readFile(filePath));
|
|
217
|
+
return convertFilesToWmlExport(filesContent);
|
|
218
|
+
};
|
|
219
|
+
var indentedStringify = (data) => JSON.stringify(data, void 0, 2);
|
|
220
|
+
var convertWmlExportToFiles = (wmlExport) => {
|
|
221
|
+
const dataWithoutVersion = JSON.parse(wmlExport.data.content);
|
|
222
|
+
const dataWithVersion = indentedStringify({ ...dataWithoutVersion, version: wmlExport.version });
|
|
223
|
+
return {
|
|
224
|
+
structure: wmlExport.structure.content,
|
|
225
|
+
style: wmlExport.style.content,
|
|
226
|
+
data: dataWithVersion
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
var convertFilesToWmlExport = (filesContent) => {
|
|
230
|
+
const { version, ...dataWithoutVersion } = JSON.parse(filesContent.data);
|
|
231
|
+
return {
|
|
232
|
+
structure: { type: "xml", content: filesContent.structure },
|
|
233
|
+
data: { type: "json", content: indentedStringify(dataWithoutVersion) },
|
|
234
|
+
style: { type: "css", content: filesContent.style },
|
|
235
|
+
version
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/document/document.js
|
|
240
|
+
var getDocumentPages = async (state) => {
|
|
241
|
+
const documentPages = {};
|
|
242
|
+
const pages = state.pages.getAll();
|
|
243
|
+
for (const { pageId, pagePath } of pages) {
|
|
244
|
+
const page = state.fileStructure.getPageFilesPaths(pagePath);
|
|
245
|
+
const data = await readWml(state.fileSystem, page.document);
|
|
246
|
+
documentPages[pageId] = { data };
|
|
247
|
+
}
|
|
248
|
+
return documentPages;
|
|
249
|
+
};
|
|
250
|
+
var getSiteDocument = async (state) => {
|
|
251
|
+
const documentPages = await getDocumentPages(state);
|
|
252
|
+
const { masterPage, ...otherPages } = documentPages;
|
|
253
|
+
if (!masterPage) {
|
|
254
|
+
throw new Error("Missing master page");
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
pages: {
|
|
258
|
+
masterPage,
|
|
259
|
+
...otherPages
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/document/externalUpdates.js
|
|
265
|
+
init_esm_shims();
|
|
266
|
+
|
|
267
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/page/utils.js
|
|
268
|
+
init_esm_shims();
|
|
269
|
+
import path2 from "path";
|
|
270
|
+
var generatePageFolderPathByInfo = (state, pageInfo) => {
|
|
271
|
+
const pagePath = state.fileStructure.getPagesPathsForType(pageInfo.type);
|
|
272
|
+
return path2.join(...pagePath.map((entry) => entry.type === "Folder" ? entry.name : pageInfo[entry.variableName]));
|
|
273
|
+
};
|
|
274
|
+
var escapeRegexSpecialChars = (str) => str.replace(/[.*+?^=!:${}()|[\]/\\]/g, "\\$&");
|
|
275
|
+
var isPathFormatMatching = (fullPath, basePath) => new RegExp(`^${escapeRegexSpecialChars(basePath)}(?: \\((\\d*)\\))?$`).test(fullPath);
|
|
276
|
+
var generateNewPagePath = (state, pageInfo, existingPageFolderPath) => {
|
|
277
|
+
let pageFolderPath = generatePageFolderPathByInfo(state, pageInfo);
|
|
278
|
+
if (existingPageFolderPath && isPathFormatMatching(existingPageFolderPath, pageFolderPath)) {
|
|
279
|
+
return existingPageFolderPath;
|
|
280
|
+
}
|
|
281
|
+
while (state.pages.getPageId(pageFolderPath)) {
|
|
282
|
+
pageFolderPath = incrementPathSuffix(pageFolderPath);
|
|
283
|
+
}
|
|
284
|
+
return pageFolderPath;
|
|
285
|
+
};
|
|
286
|
+
var createPageFiles = async (state, folderPath, pageData) => {
|
|
287
|
+
const pageStructure = state.fileStructure.getPageFilesPaths(folderPath);
|
|
288
|
+
await Promise.all([
|
|
289
|
+
writeWml(state.fileSystem, pageStructure.document, pageData),
|
|
290
|
+
createDefaultPageCodeFile(state.fileSystem, pageStructure.code)
|
|
291
|
+
]);
|
|
292
|
+
};
|
|
293
|
+
var createPage = async (state, pageId, pageData) => {
|
|
294
|
+
const newPageFolder = generateNewPagePath(state, pageData.info);
|
|
295
|
+
await state.fileSystem.createFolder(newPageFolder);
|
|
296
|
+
await createPageFiles(state, newPageFolder, pageData);
|
|
297
|
+
state.pages.addPage(pageId, newPageFolder);
|
|
298
|
+
};
|
|
299
|
+
var removePage = async (state, pageId) => {
|
|
300
|
+
const folderPath = state.pages.getFolderPath(pageId);
|
|
301
|
+
if (!folderPath)
|
|
302
|
+
return;
|
|
303
|
+
await state.fileSystem.removeFolder(folderPath);
|
|
304
|
+
state.pages.removePageById(pageId);
|
|
305
|
+
};
|
|
306
|
+
var updatePage = async (state, pageId, existingPageFolderPath, pageData) => {
|
|
307
|
+
const expectedFolderPath = generateNewPagePath(state, pageData.info, existingPageFolderPath);
|
|
308
|
+
if (existingPageFolderPath !== expectedFolderPath) {
|
|
309
|
+
await removePage(state, pageId);
|
|
310
|
+
await createPage(state, pageId, pageData);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const pageStructure = state.fileStructure.getPageFilesPaths(existingPageFolderPath);
|
|
314
|
+
await writeWml(state.fileSystem, pageStructure.document, pageData);
|
|
315
|
+
};
|
|
316
|
+
var incrementPathSuffix = (path6) => {
|
|
317
|
+
const [, origPath, suffix = 1] = path6.match(/^(.*?)(?: \((\d+)\))?$/) ?? [];
|
|
318
|
+
return `${origPath} (${Number(suffix) + 1})`;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/document/externalUpdates.js
|
|
322
|
+
var applyPageUpdate = async (state, pageId, pageData) => {
|
|
323
|
+
if (pageData === null) {
|
|
324
|
+
return removePage(state, pageId);
|
|
325
|
+
}
|
|
326
|
+
const existingPageFolder = state.pages.getFolderPath(pageId);
|
|
327
|
+
if (existingPageFolder) {
|
|
328
|
+
return updatePage(state, pageId, existingPageFolder, pageData);
|
|
329
|
+
}
|
|
330
|
+
return createPage(state, pageId, pageData);
|
|
331
|
+
};
|
|
332
|
+
var applyDocumentExternalUpdates = async (state, { pages }) => {
|
|
333
|
+
for (const [pageId, pageData] of Object.entries(pages)) {
|
|
334
|
+
await applyPageUpdate(state, pageId, pageData);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/state.js
|
|
339
|
+
init_esm_shims();
|
|
340
|
+
|
|
341
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/siteFileStructure.js
|
|
342
|
+
init_esm_shims();
|
|
343
|
+
|
|
344
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/index.js
|
|
345
|
+
init_esm_shims();
|
|
346
|
+
|
|
347
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/code.js
|
|
348
|
+
init_esm_shims();
|
|
349
|
+
|
|
350
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/configs/index.js
|
|
351
|
+
init_esm_shims();
|
|
352
|
+
|
|
353
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/configs/blocksConfig.js
|
|
354
|
+
init_esm_shims();
|
|
355
|
+
var blocksConfig = {
|
|
356
|
+
backend: "backend",
|
|
357
|
+
public: "public",
|
|
358
|
+
styles: "styles",
|
|
359
|
+
pages: {
|
|
360
|
+
structure: {
|
|
361
|
+
code: "index.js",
|
|
362
|
+
document: {
|
|
363
|
+
structure: "structure.xml",
|
|
364
|
+
data: "data.json",
|
|
365
|
+
style: "style.wcss"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
folders: {
|
|
369
|
+
Widget: [
|
|
370
|
+
{ name: "widgets", type: "Folder" },
|
|
371
|
+
{ variableName: "widgetName", type: "DynamicFolder" }
|
|
372
|
+
],
|
|
373
|
+
Panel: [
|
|
374
|
+
{ name: "widgets", type: "Folder" },
|
|
375
|
+
{ variableName: "widgetName", type: "DynamicFolder" },
|
|
376
|
+
{ name: "panels", type: "Folder" },
|
|
377
|
+
{ variableName: "panelName", type: "DynamicFolder" }
|
|
378
|
+
]
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/configs/editorConfig.js
|
|
384
|
+
init_esm_shims();
|
|
385
|
+
var editorConfig = {
|
|
386
|
+
backend: "backend",
|
|
387
|
+
public: "public",
|
|
388
|
+
styles: "styles",
|
|
389
|
+
pages: {
|
|
390
|
+
structure: {
|
|
391
|
+
code: "index.js",
|
|
392
|
+
document: {
|
|
393
|
+
structure: "structure.xml",
|
|
394
|
+
data: "data.json",
|
|
395
|
+
style: "style.wcss"
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
folders: {
|
|
399
|
+
Page: [
|
|
400
|
+
{ name: "pages", type: "Folder" },
|
|
401
|
+
{ variableName: "title", type: "DynamicFolder" }
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/configs/index.js
|
|
408
|
+
var configs = {
|
|
409
|
+
Editor: editorConfig,
|
|
410
|
+
Blocks: blocksConfig
|
|
411
|
+
};
|
|
412
|
+
var getConfig = (structureType) => {
|
|
413
|
+
const config = configs[structureType];
|
|
414
|
+
if (!config) {
|
|
415
|
+
throw new Error("Unknown file structure type: " + structureType);
|
|
416
|
+
}
|
|
417
|
+
return config;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/code.js
|
|
421
|
+
var getBackendPath = (structureType) => getConfig(structureType).backend;
|
|
422
|
+
var getPublicPath = (structureType) => getConfig(structureType).public;
|
|
423
|
+
var getStylesPath = (structureType) => getConfig(structureType).styles;
|
|
424
|
+
|
|
425
|
+
// ../../node_modules/@wix/anyide-template-layout/dist/page.js
|
|
426
|
+
init_esm_shims();
|
|
427
|
+
import path3 from "path";
|
|
428
|
+
var getPagesPaths = (structureType) => getConfig(structureType).pages.folders;
|
|
429
|
+
var getPageFilesPaths = (structureType, folderPath) => {
|
|
430
|
+
const { pages } = getConfig(structureType);
|
|
431
|
+
const { structure } = pages;
|
|
432
|
+
return {
|
|
433
|
+
code: path3.join(folderPath, structure.code),
|
|
434
|
+
document: {
|
|
435
|
+
structure: path3.join(folderPath, structure.document.structure),
|
|
436
|
+
style: path3.join(folderPath, structure.document.style),
|
|
437
|
+
data: path3.join(folderPath, structure.document.data)
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
var getPageFilesNames = (structureType, pageStructureType) => {
|
|
442
|
+
const { pages } = getConfig(structureType);
|
|
443
|
+
const { structure } = pages;
|
|
444
|
+
if (pageStructureType === "document") {
|
|
445
|
+
return /* @__PURE__ */ new Set([
|
|
446
|
+
structure[pageStructureType].structure,
|
|
447
|
+
structure[pageStructureType].data,
|
|
448
|
+
structure[pageStructureType].style
|
|
449
|
+
]);
|
|
450
|
+
}
|
|
451
|
+
return /* @__PURE__ */ new Set([structure[pageStructureType]]);
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/siteFileStructure.js
|
|
455
|
+
var SiteFileStructure = class {
|
|
456
|
+
fileStructureType;
|
|
457
|
+
folderStructure;
|
|
458
|
+
constructor(fileStructureType) {
|
|
459
|
+
this.fileStructureType = fileStructureType;
|
|
460
|
+
this.folderStructure = [
|
|
461
|
+
{ path: this.generateFolderPath(getBackendPath), type: foldersType.backend },
|
|
462
|
+
{ path: this.generateFolderPath(getPublicPath), type: foldersType.public },
|
|
463
|
+
{ path: this.generateFolderPath(getStylesPath), type: foldersType.styles }
|
|
464
|
+
];
|
|
465
|
+
}
|
|
466
|
+
generateFolderPath(getPathFunction) {
|
|
467
|
+
return `${getPathFunction(this.fileStructureType)}/`;
|
|
468
|
+
}
|
|
469
|
+
getBackendFolderPath() {
|
|
470
|
+
return getBackendPath(this.fileStructureType);
|
|
471
|
+
}
|
|
472
|
+
getPublicFolderPath() {
|
|
473
|
+
return getPublicPath(this.fileStructureType);
|
|
474
|
+
}
|
|
475
|
+
getStylesFolderPath() {
|
|
476
|
+
return getStylesPath(this.fileStructureType);
|
|
477
|
+
}
|
|
478
|
+
getPagesPaths() {
|
|
479
|
+
return getPagesPaths(this.fileStructureType);
|
|
480
|
+
}
|
|
481
|
+
getPagesPathsForType(type) {
|
|
482
|
+
const paths = this.getPagesPaths();
|
|
483
|
+
const pathForType = paths[type];
|
|
484
|
+
if (!pathForType) {
|
|
485
|
+
throw new Error(`page type "${type}" is invalid for structureType "${this.fileStructureType}"`);
|
|
486
|
+
}
|
|
487
|
+
return pathForType;
|
|
488
|
+
}
|
|
489
|
+
getPageFilesPaths(pageFolderPath) {
|
|
490
|
+
return getPageFilesPaths(this.fileStructureType, pageFolderPath);
|
|
491
|
+
}
|
|
492
|
+
matchPagePath(filePath) {
|
|
493
|
+
const pageFilesPath = this.getPagesPaths();
|
|
494
|
+
const sortedPageFilesPath = Object.entries(pageFilesPath).sort((a, b) => b[1].length - a[1].length);
|
|
495
|
+
for (const [type, pagePath] of sortedPageFilesPath) {
|
|
496
|
+
const typeRegex = new RegExp(`^(${pagePath.map((entry) => entry.type === "Folder" ? entry.name : ".+?").join("/")})/(.+)`);
|
|
497
|
+
const path6 = typeRegex.exec(filePath);
|
|
498
|
+
if (path6) {
|
|
499
|
+
return {
|
|
500
|
+
type,
|
|
501
|
+
pagePath: path6[1],
|
|
502
|
+
fileName: path6[2]
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
createCodeStructureInfo(folderType) {
|
|
509
|
+
return { type: "code", isPageFile: false, folderType };
|
|
510
|
+
}
|
|
511
|
+
getCodeStructureInfoByFolderPath(filePath) {
|
|
512
|
+
for (const folder of this.folderStructure) {
|
|
513
|
+
if (filePath.startsWith(folder.path)) {
|
|
514
|
+
return this.createCodeStructureInfo(folder.type);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
getStructureInfoByFilePath(filePath) {
|
|
519
|
+
const folderStructure = this.getCodeStructureInfoByFolderPath(filePath);
|
|
520
|
+
if (folderStructure) {
|
|
521
|
+
return folderStructure;
|
|
522
|
+
}
|
|
523
|
+
const pageMatch = this.matchPagePath(filePath);
|
|
524
|
+
if (pageMatch) {
|
|
525
|
+
const { pagePath, fileName } = pageMatch;
|
|
526
|
+
const codeFiles = getPageFilesNames(this.fileStructureType, "code");
|
|
527
|
+
if (codeFiles.has(fileName)) {
|
|
528
|
+
return { type: "code", isPageFile: true, pagePath };
|
|
529
|
+
}
|
|
530
|
+
const documentFiles = getPageFilesNames(this.fileStructureType, "document");
|
|
531
|
+
if (documentFiles.has(fileName)) {
|
|
532
|
+
return { type: "document", isPageFile: true, pagePath };
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/siteFileSystem.js
|
|
540
|
+
init_esm_shims();
|
|
541
|
+
import fs from "fs/promises";
|
|
542
|
+
import path4 from "path";
|
|
543
|
+
var SiteFileSystem = class {
|
|
544
|
+
rootFolderPath;
|
|
545
|
+
constructor(rootFolderPath) {
|
|
546
|
+
this.rootFolderPath = rootFolderPath;
|
|
547
|
+
}
|
|
548
|
+
getFullPath(relativePath) {
|
|
549
|
+
return path4.join(this.rootFolderPath, relativePath);
|
|
550
|
+
}
|
|
551
|
+
async readFile(filePath) {
|
|
552
|
+
return fs.readFile(this.getFullPath(filePath), "utf-8");
|
|
553
|
+
}
|
|
554
|
+
async writeFile(filePath, content) {
|
|
555
|
+
return fs.writeFile(this.getFullPath(filePath), content);
|
|
556
|
+
}
|
|
557
|
+
async removeFile(filePath) {
|
|
558
|
+
return fs.rm(this.getFullPath(filePath));
|
|
559
|
+
}
|
|
560
|
+
async readFolder(folderPath) {
|
|
561
|
+
return fs.readdir(this.getFullPath(folderPath), { withFileTypes: true });
|
|
562
|
+
}
|
|
563
|
+
async createFolder(folderPath) {
|
|
564
|
+
await fs.mkdir(this.getFullPath(folderPath), { recursive: true });
|
|
565
|
+
}
|
|
566
|
+
async removeFolder(folderPath) {
|
|
567
|
+
return fs.rm(this.getFullPath(folderPath), { recursive: true });
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/stateBuilder.js
|
|
572
|
+
init_esm_shims();
|
|
573
|
+
|
|
574
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/sitePagesState.js
|
|
575
|
+
init_esm_shims();
|
|
576
|
+
var CaseInsensitiveMap = class {
|
|
577
|
+
map = /* @__PURE__ */ new Map();
|
|
578
|
+
normalizeKey(key) {
|
|
579
|
+
return key.toLowerCase();
|
|
580
|
+
}
|
|
581
|
+
get(key) {
|
|
582
|
+
return this.map.get(this.normalizeKey(key));
|
|
583
|
+
}
|
|
584
|
+
set(key, value) {
|
|
585
|
+
this.map.set(this.normalizeKey(key), value);
|
|
586
|
+
}
|
|
587
|
+
delete(key) {
|
|
588
|
+
this.map.delete(this.normalizeKey(key));
|
|
589
|
+
}
|
|
590
|
+
entries() {
|
|
591
|
+
return this.map.entries();
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
var SitePagesState = class {
|
|
595
|
+
pageIdToFolderPath = /* @__PURE__ */ new Map();
|
|
596
|
+
folderPathToPageId = new CaseInsensitiveMap();
|
|
597
|
+
validatePageIdExists(pageId) {
|
|
598
|
+
if (this.pageIdToFolderPath.has(pageId)) {
|
|
599
|
+
throw new Error(`Duplicated pageId found in structure.xml files: ${pageId}`);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
getAll() {
|
|
603
|
+
const allPages = [];
|
|
604
|
+
for (const [pageId, pagePath] of this.pageIdToFolderPath.entries()) {
|
|
605
|
+
allPages.push({ pageId, pagePath });
|
|
606
|
+
}
|
|
607
|
+
return allPages;
|
|
608
|
+
}
|
|
609
|
+
addPage(pageId, folderPath) {
|
|
610
|
+
this.validatePageIdExists(pageId);
|
|
611
|
+
this.pageIdToFolderPath.set(pageId, folderPath);
|
|
612
|
+
this.folderPathToPageId.set(folderPath, pageId);
|
|
613
|
+
}
|
|
614
|
+
removePageById(pageId) {
|
|
615
|
+
const folderPath = this.pageIdToFolderPath.get(pageId);
|
|
616
|
+
if (folderPath === void 0) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
this.pageIdToFolderPath.delete(pageId);
|
|
620
|
+
this.folderPathToPageId.delete(folderPath);
|
|
621
|
+
}
|
|
622
|
+
removePageByPath(path6) {
|
|
623
|
+
const pageId = this.folderPathToPageId.get(path6);
|
|
624
|
+
if (pageId === void 0) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
this.pageIdToFolderPath.delete(pageId);
|
|
628
|
+
this.folderPathToPageId.delete(path6);
|
|
629
|
+
}
|
|
630
|
+
getFolderPath(pageId) {
|
|
631
|
+
return this.pageIdToFolderPath.get(pageId);
|
|
632
|
+
}
|
|
633
|
+
getPageId(folderPath) {
|
|
634
|
+
return this.folderPathToPageId.get(folderPath);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/stateBuilder.js
|
|
639
|
+
import path5 from "path";
|
|
640
|
+
var getFoldersInPath = async (siteFileSystem, dirPath) => {
|
|
641
|
+
const entries = await siteFileSystem.readFolder(dirPath);
|
|
642
|
+
return entries.filter((entry) => entry.isDirectory()).map(({ name }) => name);
|
|
643
|
+
};
|
|
644
|
+
var getMatchingPaths = (folderName, paths) => paths.filter(([first]) => first?.type === "DynamicFolder" || first.name === folderName);
|
|
645
|
+
var getPages = async (siteFileSystem, paths, rootPath = "") => {
|
|
646
|
+
if (paths.length === 0)
|
|
647
|
+
return [];
|
|
648
|
+
const result = [];
|
|
649
|
+
const rootFolders = await getFoldersInPath(siteFileSystem, rootPath);
|
|
650
|
+
for (const folderName of rootFolders) {
|
|
651
|
+
const matchingPaths = getMatchingPaths(folderName, paths);
|
|
652
|
+
if (matchingPaths.length > 0) {
|
|
653
|
+
const finalPaths = matchingPaths.filter((p) => p.length === 1).map(() => path5.join(rootPath, folderName));
|
|
654
|
+
const nonFinalPaths = matchingPaths.filter((p) => p.length > 1).map(([, ...rest]) => rest);
|
|
655
|
+
const nestedPages = await getPages(siteFileSystem, nonFinalPaths, path5.join(rootPath, folderName));
|
|
656
|
+
result.push(...finalPaths, ...nestedPages);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return result;
|
|
660
|
+
};
|
|
661
|
+
var getAllPageFolders = async (siteFileStructure, siteFileSystem) => {
|
|
662
|
+
const paths = siteFileStructure.getPagesPaths();
|
|
663
|
+
return await getPages(siteFileSystem, Object.values(paths));
|
|
664
|
+
};
|
|
665
|
+
var buildPagesState = async (siteFileStructure, siteFileSystem) => {
|
|
666
|
+
const state = new SitePagesState();
|
|
667
|
+
const pagesFolders = await getAllPageFolders(siteFileStructure, siteFileSystem);
|
|
668
|
+
await Promise.all(pagesFolders.map(async (folderPath) => {
|
|
669
|
+
const filePaths = siteFileStructure.getPageFilesPaths(folderPath);
|
|
670
|
+
const pageId = await getPageId(siteFileSystem, filePaths.document);
|
|
671
|
+
state.addPage(pageId, folderPath);
|
|
672
|
+
}));
|
|
673
|
+
return state;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/state/state.js
|
|
677
|
+
var buildState = async (rootFolderPath, fileStructureType) => {
|
|
678
|
+
const fileSystem = new SiteFileSystem(rootFolderPath);
|
|
679
|
+
const fileStructure = new SiteFileStructure(fileStructureType);
|
|
680
|
+
const pages = await buildPagesState(fileStructure, fileSystem);
|
|
681
|
+
return {
|
|
682
|
+
fileSystem,
|
|
683
|
+
fileStructure,
|
|
684
|
+
pages
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/applyFsUpdates.js
|
|
689
|
+
init_esm_shims();
|
|
690
|
+
|
|
691
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/code/fsUpdates.js
|
|
692
|
+
init_esm_shims();
|
|
693
|
+
var initVeloCodeUpdate = () => {
|
|
694
|
+
return {
|
|
695
|
+
layout: "GITHUB",
|
|
696
|
+
ignoreForbiddenPaths: true
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
var applyDeleteCode = (codeUpdate, path6) => {
|
|
700
|
+
if (!codeUpdate) {
|
|
701
|
+
codeUpdate = initVeloCodeUpdate();
|
|
702
|
+
}
|
|
703
|
+
codeUpdate.pathsToDelete ??= [];
|
|
704
|
+
codeUpdate.pathsToDelete.push(path6);
|
|
705
|
+
return codeUpdate;
|
|
706
|
+
};
|
|
707
|
+
var applyUpdateCode = (codeUpdate, veloFile) => {
|
|
708
|
+
if (!codeUpdate) {
|
|
709
|
+
codeUpdate = initVeloCodeUpdate();
|
|
710
|
+
}
|
|
711
|
+
codeUpdate.filesToUpdate ??= [];
|
|
712
|
+
codeUpdate.filesToUpdate.push(veloFile);
|
|
713
|
+
return codeUpdate;
|
|
714
|
+
};
|
|
715
|
+
var accumulateFsUpdateToVeloCodeUpdate = async (state, veloCodeUpdate, structureInfo, { path: path6, action }) => {
|
|
716
|
+
let result = veloCodeUpdate;
|
|
717
|
+
const pathInGithubLayout = convertToGithubLayout(state, path6, structureInfo.folderType);
|
|
718
|
+
if (action === "DELETE") {
|
|
719
|
+
result = applyDeleteCode(result, pathInGithubLayout);
|
|
720
|
+
} else if (action === "UPDATE") {
|
|
721
|
+
result = applyUpdateCode(result, {
|
|
722
|
+
path: pathInGithubLayout,
|
|
723
|
+
content: await state.fileSystem.readFile(path6)
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
return result;
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/page/fsUpdates.js
|
|
730
|
+
init_esm_shims();
|
|
731
|
+
|
|
732
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/document/fsUpdates.js
|
|
733
|
+
init_esm_shims();
|
|
734
|
+
var applyDocumentUpdate = (documentUpdate, pageId, value) => {
|
|
735
|
+
documentUpdate ??= { pages: {} };
|
|
736
|
+
documentUpdate.pages[pageId] = value;
|
|
737
|
+
return documentUpdate;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/page/fsUpdates.js
|
|
741
|
+
var applyDeletePage = (siteFsUpdate, pageId) => {
|
|
742
|
+
siteFsUpdate.document = applyDocumentUpdate(siteFsUpdate.document, pageId, null);
|
|
743
|
+
const veloPath = getPageCodeFilePath(pageId);
|
|
744
|
+
siteFsUpdate.code = applyDeleteCode(siteFsUpdate.code, veloPath);
|
|
745
|
+
return siteFsUpdate;
|
|
746
|
+
};
|
|
747
|
+
var applyCodeUpdateInPage = async (state, siteFsUpdate, pageId, path6) => {
|
|
748
|
+
siteFsUpdate.code = applyUpdateCode(siteFsUpdate.code, {
|
|
749
|
+
path: getPageCodeFilePath(pageId),
|
|
750
|
+
content: await state.fileSystem.readFile(path6)
|
|
751
|
+
});
|
|
752
|
+
return siteFsUpdate;
|
|
753
|
+
};
|
|
754
|
+
var accumulatePageFsUpdateToWixSiteFSUpdate = async (state, siteFsUpdate, structureInfo, { action, path: path6 }) => {
|
|
755
|
+
const result = siteFsUpdate;
|
|
756
|
+
const pageId = state.pages.getPageId(structureInfo.pagePath);
|
|
757
|
+
if (action === "DELETE") {
|
|
758
|
+
if (!pageId) {
|
|
759
|
+
return result;
|
|
760
|
+
}
|
|
761
|
+
const { document, code } = applyDeletePage(result, pageId);
|
|
762
|
+
result.document = document;
|
|
763
|
+
result.code = code;
|
|
764
|
+
state.pages.removePageById(pageId);
|
|
765
|
+
} else if (action === "UPDATE") {
|
|
766
|
+
const page = state.fileStructure.getPageFilesPaths(structureInfo.pagePath);
|
|
767
|
+
if (structureInfo.type === "document") {
|
|
768
|
+
const wml = await readWml(state.fileSystem, page.document);
|
|
769
|
+
const pageIdInDocument = await getPageId(state.fileSystem, page.document);
|
|
770
|
+
const folderPathForPageIdInDocument = state.pages.getFolderPath(pageIdInDocument);
|
|
771
|
+
if (folderPathForPageIdInDocument && folderPathForPageIdInDocument !== structureInfo.pagePath) {
|
|
772
|
+
throw new Error(`Duplicated pageId found in structure.xml files: ${pageIdInDocument}`);
|
|
773
|
+
}
|
|
774
|
+
if (pageId !== pageIdInDocument) {
|
|
775
|
+
if (pageId) {
|
|
776
|
+
const { document, code } = applyDeletePage(result, pageId);
|
|
777
|
+
result.document = document;
|
|
778
|
+
result.code = code;
|
|
779
|
+
await applyCodeUpdateInPage(state, result, pageIdInDocument, page.code);
|
|
780
|
+
state.pages.removePageById(pageId);
|
|
781
|
+
}
|
|
782
|
+
state.pages.addPage(pageIdInDocument, structureInfo.pagePath);
|
|
783
|
+
}
|
|
784
|
+
result.document = applyDocumentUpdate(result.document, pageIdInDocument, { data: wml });
|
|
785
|
+
} else if (structureInfo.type === "code") {
|
|
786
|
+
if (!pageId) {
|
|
787
|
+
return result;
|
|
788
|
+
}
|
|
789
|
+
await applyCodeUpdateInPage(state, result, pageId, path6);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return result;
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/applyFsUpdates.js
|
|
796
|
+
var applyFsUpdates = async (state, updates) => {
|
|
797
|
+
const result = {};
|
|
798
|
+
for (const { path: path6, action } of updates) {
|
|
799
|
+
const structureInfo = state.fileStructure.getStructureInfoByFilePath(path6);
|
|
800
|
+
if (structureInfo === null)
|
|
801
|
+
continue;
|
|
802
|
+
if (structureInfo.isPageFile) {
|
|
803
|
+
const { document, code } = await accumulatePageFsUpdateToWixSiteFSUpdate(state, result, structureInfo, {
|
|
804
|
+
path: path6,
|
|
805
|
+
action
|
|
806
|
+
});
|
|
807
|
+
result.code = code;
|
|
808
|
+
result.document = document;
|
|
809
|
+
} else if (structureInfo.type === "code") {
|
|
810
|
+
result.code = await accumulateFsUpdateToVeloCodeUpdate(state, result.code, structureInfo, { path: path6, action });
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
return result;
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
// ../../node_modules/@wix/anyide-cli-file-structure/dist/wixSiteFSManager.js
|
|
817
|
+
var WixSiteFSManager = class _WixSiteFSManager {
|
|
818
|
+
state;
|
|
819
|
+
constructor(state) {
|
|
820
|
+
this.state = state;
|
|
821
|
+
}
|
|
822
|
+
static async create(rootFolderPath, fileStructureType) {
|
|
823
|
+
const state = await buildState(rootFolderPath, fileStructureType);
|
|
824
|
+
return new _WixSiteFSManager(state);
|
|
825
|
+
}
|
|
826
|
+
getCode = async () => getSiteCode(this.state);
|
|
827
|
+
getDocument = async () => getSiteDocument(this.state);
|
|
828
|
+
applyFsUpdates = async (updates) => applyFsUpdates(this.state, updates);
|
|
829
|
+
applyExternalUpdates = async ({ code, document }) => {
|
|
830
|
+
if (code) {
|
|
831
|
+
throw new Error("external code updates are not supported");
|
|
832
|
+
}
|
|
833
|
+
if (document) {
|
|
834
|
+
await applyDocumentExternalUpdates(this.state, document);
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
createConvertOnlineLayoutApi = (basePath) => (onlinePath) => convertOnlineLayout(this.state, basePath, onlinePath);
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
// ../cli-site/src/site-fs-manager.ts
|
|
841
|
+
async function createSiteFsManager(projectFolder) {
|
|
842
|
+
const srcFolder = getSourceFolder(projectFolder);
|
|
843
|
+
const fsManager = await WixSiteFSManager.create(srcFolder, "Editor").catch(
|
|
844
|
+
(error) => {
|
|
845
|
+
throw new CliError({
|
|
846
|
+
code: CliErrorCode.FailedToInitializeSiteFsManager(),
|
|
847
|
+
cause: error
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
);
|
|
851
|
+
return {
|
|
852
|
+
convertToOnlineLayout: fsManager.createConvertOnlineLayoutApi(
|
|
853
|
+
relative(projectFolder, srcFolder)
|
|
854
|
+
),
|
|
855
|
+
async getCode() {
|
|
856
|
+
try {
|
|
857
|
+
return await fsManager.getCode();
|
|
858
|
+
} catch (error) {
|
|
859
|
+
throw new CliError({
|
|
860
|
+
code: CliErrorCode.FailedToGetSiteFsManagerCode(),
|
|
861
|
+
cause: error
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
async getDocument() {
|
|
866
|
+
try {
|
|
867
|
+
return await fsManager.getDocument();
|
|
868
|
+
} catch (error) {
|
|
869
|
+
throw new CliError({
|
|
870
|
+
code: CliErrorCode.FailedToGetSiteFsManagerDocument(),
|
|
871
|
+
cause: error
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
async applyFsUpdates(updates) {
|
|
876
|
+
try {
|
|
877
|
+
return await fsManager.applyFsUpdates(updates);
|
|
878
|
+
} catch (error) {
|
|
879
|
+
throw new CliError({
|
|
880
|
+
code: CliErrorCode.FailedToApplySiteFsManagerFsUpdates(),
|
|
881
|
+
cause: error
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
async applyExternalUpdates(update) {
|
|
886
|
+
try {
|
|
887
|
+
await fsManager.applyExternalUpdates(update);
|
|
888
|
+
} catch (error) {
|
|
889
|
+
throw new CliError({
|
|
890
|
+
code: CliErrorCode.FailedToApplySiteFsManagerExternalUpdates(),
|
|
891
|
+
cause: error
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
export {
|
|
899
|
+
createSiteFsManager
|
|
900
|
+
};
|
|
901
|
+
//# sourceMappingURL=chunk-Q3GS63B5.js.map
|