@coraltravelcenter/b2c-landing-builder 2.6.2 → 2.6.3
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/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coraltravelcenter/b2c-landing-builder",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@coraltravelcenter/b2c-landing-builder",
|
|
9
|
-
"version": "2.6.
|
|
9
|
+
"version": "2.6.3",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@clack/prompts": "1.7.0",
|
package/package.json
CHANGED
package/src/deploy/assets.mjs
CHANGED
|
@@ -9,19 +9,40 @@ export async function uploadChangedAssets({
|
|
|
9
9
|
state,
|
|
10
10
|
root = process.cwd(),
|
|
11
11
|
uploadFile,
|
|
12
|
+
listFiles,
|
|
12
13
|
remoteRoot = "/content",
|
|
13
14
|
concurrency = 5,
|
|
14
15
|
}) {
|
|
15
16
|
const pending = changedAssets(manifest, state);
|
|
16
17
|
const assets = {...state.assets};
|
|
17
18
|
const uploaded = [];
|
|
19
|
+
const skipped = [];
|
|
20
|
+
const remoteDirectories = new Map();
|
|
18
21
|
let cursor = 0;
|
|
19
22
|
|
|
23
|
+
const namesInRemoteDirectory = (remoteDirectory) => {
|
|
24
|
+
if (!remoteDirectories.has(remoteDirectory)) {
|
|
25
|
+
remoteDirectories.set(remoteDirectory, Promise.resolve(listFiles(remoteDirectory)).then((listing) => {
|
|
26
|
+
const files = Array.isArray(listing) ? listing : listing?.files || [];
|
|
27
|
+
return new Set(files.map((file) => typeof file === "string" ? path.posix.basename(file) : file.name));
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
return remoteDirectories.get(remoteDirectory);
|
|
31
|
+
};
|
|
32
|
+
|
|
20
33
|
async function worker() {
|
|
21
34
|
while (cursor < pending.length) {
|
|
22
35
|
const asset = pending[cursor++];
|
|
23
36
|
const localPath = path.join(root, ...(manifest.assetsDirectory || "public").split("/"), ...asset.path.split("/"));
|
|
24
37
|
const remotePath = path.posix.join("/", remoteRoot, manifest.assetsPrefix, asset.path);
|
|
38
|
+
if (listFiles) {
|
|
39
|
+
const names = await namesInRemoteDirectory(path.posix.dirname(remotePath));
|
|
40
|
+
if (names.has(path.posix.basename(remotePath))) {
|
|
41
|
+
assets[asset.path] = {...asset, immutable: true};
|
|
42
|
+
skipped.push(asset.path);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
25
46
|
const result = await uploadFile(remotePath, localPath);
|
|
26
47
|
assets[asset.path] = {...asset, url: result?.files?.[0]?.url};
|
|
27
48
|
uploaded.push(asset.path);
|
|
@@ -33,6 +54,7 @@ export async function uploadChangedAssets({
|
|
|
33
54
|
return {
|
|
34
55
|
state: {...state, assets},
|
|
35
56
|
uploaded: uploaded.sort(),
|
|
57
|
+
skipped: skipped.sort(),
|
|
36
58
|
unchanged: manifest.assets.length - pending.length,
|
|
37
59
|
};
|
|
38
60
|
}
|
|
@@ -100,10 +100,17 @@ export class BackofficeClient {
|
|
|
100
100
|
return this.request("PUT", "/Content/UpdateDocumentStatus", {body: {pageContentId, documentStatus}});
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
async listFiles(remoteDirectory) {
|
|
104
|
+
const result = await this.request("GET", "/FileManagement/ListFiles", {
|
|
105
|
+
query: {path: remoteDirectory.replace(/^\/+/, "")},
|
|
106
|
+
});
|
|
107
|
+
return result?.result || result;
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
async uploadFile(remotePath, localPath) {
|
|
104
111
|
const parsed = path.posix.parse(remotePath);
|
|
105
112
|
const form = new FormData();
|
|
106
|
-
form.append("Body.OverWrite", "
|
|
113
|
+
form.append("Body.OverWrite", "false");
|
|
107
114
|
form.append("Body.Path", parsed.dir.replace(/^\/+/, ""));
|
|
108
115
|
form.append("Body.Files", new Blob([fs.readFileSync(localPath)]), parsed.base);
|
|
109
116
|
const result = await this.request("POST", "/FileManagement/UploadFile", {form});
|
package/src/deploy/deploy.mjs
CHANGED
|
@@ -30,9 +30,13 @@ export async function deployAssetsOnly({
|
|
|
30
30
|
root,
|
|
31
31
|
remoteRoot: new URL(preset.assetsBase).pathname,
|
|
32
32
|
uploadFile: api.uploadFile.bind(api),
|
|
33
|
+
listFiles: api.listFiles?.bind(api),
|
|
33
34
|
});
|
|
34
35
|
writeDeploymentState(preset.id, manifest.folder, result.state, root);
|
|
35
|
-
log(`[deploy] assets: uploaded=${result.uploaded.length}, unchanged=${result.unchanged}`);
|
|
36
|
+
log(`[deploy] assets: uploaded=${result.uploaded.length}, skipped=${result.skipped.length}, unchanged=${result.unchanged}`);
|
|
37
|
+
if (result.skipped.length) {
|
|
38
|
+
log(`[deploy] existing assets were not overwritten: ${result.skipped.join(", ")}. Rename changed files to publish new URLs.`);
|
|
39
|
+
}
|
|
36
40
|
return {...result, target: String(cdnUrl)};
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -56,6 +60,7 @@ export async function deployProject({
|
|
|
56
60
|
root,
|
|
57
61
|
remoteRoot: new URL(preset.assetsBase).pathname,
|
|
58
62
|
uploadFile: api.uploadFile.bind(api),
|
|
63
|
+
listFiles: api.listFiles?.bind(api),
|
|
59
64
|
});
|
|
60
65
|
const page = previous.placement
|
|
61
66
|
? await prepareExistingPage({client: api, placement: previous.placement, update})
|
|
@@ -72,7 +77,10 @@ export async function deployProject({
|
|
|
72
77
|
const preview = page.pageContent.uniqueId
|
|
73
78
|
? `https://${preset.domain}/preview/${page.pageContent.uniqueId}/`
|
|
74
79
|
: null;
|
|
75
|
-
log(`[deploy] assets: uploaded=${assets.uploaded.length}, unchanged=${assets.unchanged}`);
|
|
80
|
+
log(`[deploy] assets: uploaded=${assets.uploaded.length}, skipped=${assets.skipped.length}, unchanged=${assets.unchanged}`);
|
|
81
|
+
if (assets.skipped.length) {
|
|
82
|
+
log(`[deploy] existing assets were not overwritten: ${assets.skipped.join(", ")}. Rename changed files to publish new URLs.`);
|
|
83
|
+
}
|
|
76
84
|
log(`[deploy] widgets: added=${widgets.added}, updated=${widgets.updated}, removed=${widgets.removed}`);
|
|
77
85
|
if (preview) log(`[deploy] preview: ${preview}`);
|
|
78
86
|
return {assets, widgets, placement: page.placement, preview};
|