@artinstack/migrator 0.1.8 → 0.1.9
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/dist/{bundle-uAAHehbv.d.ts → bundle-B3XS20r_.d.ts} +1 -1
- package/dist/{chunk-KYNKJ4XV.js → chunk-BONZ3U3I.js} +2 -2
- package/dist/{chunk-CB5KRANW.js → chunk-FB3MMCHY.js} +86 -23
- package/dist/chunk-FB3MMCHY.js.map +1 -0
- package/dist/{chunk-HI7JHWZU.js → chunk-KTQGOM45.js} +1 -1
- package/dist/chunk-KTQGOM45.js.map +1 -0
- package/dist/{chunk-Z3L6N63Y.js → chunk-PPT5RIZ4.js} +47 -8
- package/dist/chunk-PPT5RIZ4.js.map +1 -0
- package/dist/{chunk-WHGUE5FC.js → chunk-S4GMDRGX.js} +39 -4
- package/dist/chunk-S4GMDRGX.js.map +1 -0
- package/dist/{chunk-ALLFBWBO.js → chunk-S4SUJT2D.js} +2 -2
- package/dist/cli/index.js +5 -5
- package/dist/index.d.ts +6 -6
- package/dist/index.js +10 -6
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +3 -1
- package/dist/{media-urls-w46-CWUp.d.ts → media-urls-u49RCyPn.d.ts} +15 -1
- package/dist/normalizer/index.d.ts +4 -4
- package/dist/normalizer/index.js +1 -1
- package/dist/{rewrite-inline-images-DyxKUNs3.d.ts → rewrite-inline-images-BsgSquzV.d.ts} +1 -1
- package/dist/sinks/index.d.ts +21 -6
- package/dist/sinks/index.js +6 -4
- package/dist/transformers/index.d.ts +3 -3
- package/dist/transformers/index.js +3 -3
- package/dist/{types-DWOP8Dcy.d.ts → types-Ce4r6zqt.d.ts} +4 -0
- package/package.json +1 -1
- package/dist/chunk-CB5KRANW.js.map +0 -1
- package/dist/chunk-HI7JHWZU.js.map +0 -1
- package/dist/chunk-WHGUE5FC.js.map +0 -1
- package/dist/chunk-Z3L6N63Y.js.map +0 -1
- /package/dist/{chunk-KYNKJ4XV.js.map → chunk-BONZ3U3I.js.map} +0 -0
- /package/dist/{chunk-ALLFBWBO.js.map → chunk-S4SUJT2D.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NormalizedPost, a as NormalizedPage, b as NormalizedAsset, c as NormalizedPortfolio, d as NormalizedCategory, e as NormalizedTag, f as NormalizedEntity } from './types-
|
|
1
|
+
import { N as NormalizedPost, a as NormalizedPage, b as NormalizedAsset, c as NormalizedPortfolio, d as NormalizedCategory, e as NormalizedTag, f as NormalizedEntity } from './types-Ce4r6zqt.js';
|
|
2
2
|
|
|
3
3
|
interface EntityBundle {
|
|
4
4
|
posts: NormalizedPost[];
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isMigrationMediaRef,
|
|
4
4
|
normalizeAssetUrl,
|
|
5
5
|
resolveMigrationMediaSourceId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S4GMDRGX.js";
|
|
7
7
|
|
|
8
8
|
// src/transformers/rewrite-inline-images.ts
|
|
9
9
|
import * as cheerio from "cheerio";
|
|
@@ -121,4 +121,4 @@ export {
|
|
|
121
121
|
rewriteInlineImages,
|
|
122
122
|
stampMigrationMediaRefs
|
|
123
123
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-BONZ3U3I.js.map
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
enumerateSquarespaceEntities,
|
|
7
7
|
summarizeSquarespaceExport,
|
|
8
8
|
validateSquarespaceExportFile
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-PPT5RIZ4.js";
|
|
10
10
|
import {
|
|
11
11
|
stampMigrationMediaRefs
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BONZ3U3I.js";
|
|
13
13
|
import {
|
|
14
14
|
linkToPath,
|
|
15
15
|
sanitizeSlug
|
|
@@ -18,11 +18,12 @@ import {
|
|
|
18
18
|
buildContentMediaUrlIndex,
|
|
19
19
|
canonicalizeInlineAssetUrl,
|
|
20
20
|
discoverContentAssetUrls,
|
|
21
|
+
discoverContentAssets,
|
|
21
22
|
normalizeAssetUrl,
|
|
22
23
|
parseMigrationMediaRef,
|
|
23
24
|
resolveFeaturedContentAssetUrl,
|
|
24
25
|
rewriteOriginUrlsInText
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-S4GMDRGX.js";
|
|
26
27
|
|
|
27
28
|
// src/parsers/wordpress/parse-wxr.ts
|
|
28
29
|
import { readFile } from "fs/promises";
|
|
@@ -420,15 +421,33 @@ function flattenContactFormShortcodes(content, widgetRegistry) {
|
|
|
420
421
|
}
|
|
421
422
|
return html;
|
|
422
423
|
}
|
|
424
|
+
function emitInlineGalleryFromIds(idList) {
|
|
425
|
+
const images = idList.map((id) => `<img data-wp-attachment-id="${escapeLayoutAttr(id)}" alt="" />`).join("");
|
|
426
|
+
return `<figure data-wp-inline-gallery>${images}</figure>`;
|
|
427
|
+
}
|
|
428
|
+
function parseGalleryAttachmentIds(params) {
|
|
429
|
+
const ids = extractBareOrQuotedParam(params, "ids");
|
|
430
|
+
const idList = ids?.split(",").map((part) => part.trim()).filter((part) => /^\d+$/.test(part));
|
|
431
|
+
return idList?.length ? idList : void 0;
|
|
432
|
+
}
|
|
433
|
+
function flattenIdGalleryShortcode(content, tag) {
|
|
434
|
+
const escaped = escapeRegExp(tag);
|
|
435
|
+
const pattern = new RegExp(`\\[${escaped}\\b([^\\]]*)\\](?:\\s*\\[\\/${escaped}\\])?`, "gi");
|
|
436
|
+
return content.replace(pattern, (fullMatch, params) => {
|
|
437
|
+
const idList = parseGalleryAttachmentIds(params);
|
|
438
|
+
if (idList?.length) {
|
|
439
|
+
return emitInlineGalleryFromIds(idList);
|
|
440
|
+
}
|
|
441
|
+
return fullMatch;
|
|
442
|
+
});
|
|
443
|
+
}
|
|
423
444
|
function flattenGalleryShortcodes(content, widgetRegistry) {
|
|
424
445
|
const tag = escapeRegExp(widgetRegistry.galleryShortcode);
|
|
425
446
|
const pattern = new RegExp(`\\[${tag}\\b([^\\]]*)\\](?:\\s*\\[\\/${tag}\\])?`, "gi");
|
|
426
447
|
return content.replace(pattern, (_, params) => {
|
|
427
|
-
const
|
|
428
|
-
const idList = ids?.split(",").map((part) => part.trim()).filter((part) => /^\d+$/.test(part));
|
|
448
|
+
const idList = parseGalleryAttachmentIds(params);
|
|
429
449
|
if (idList?.length) {
|
|
430
|
-
|
|
431
|
-
return `<figure data-wp-inline-gallery>${images}</figure>`;
|
|
450
|
+
return emitInlineGalleryFromIds(idList);
|
|
432
451
|
}
|
|
433
452
|
const category = extractBareOrQuotedParam(params, "category") ?? extractBareOrQuotedParam(params, "type");
|
|
434
453
|
return emitWidgetStub("portfolio", {
|
|
@@ -437,6 +456,13 @@ function flattenGalleryShortcodes(content, widgetRegistry) {
|
|
|
437
456
|
});
|
|
438
457
|
});
|
|
439
458
|
}
|
|
459
|
+
function flattenIdBasedGalleryShortcodes(content, widgetRegistry) {
|
|
460
|
+
let html = content;
|
|
461
|
+
for (const tag of widgetRegistry.idGalleryShortcodes) {
|
|
462
|
+
html = flattenIdGalleryShortcode(html, tag);
|
|
463
|
+
}
|
|
464
|
+
return html;
|
|
465
|
+
}
|
|
440
466
|
function flattenPortfolioShortcodes(content, widgetRegistry) {
|
|
441
467
|
const tag = escapeRegExp(widgetRegistry.portfolioShortcode);
|
|
442
468
|
const pattern = new RegExp(`\\[${tag}\\b([^\\]]*)\\](?:\\s*\\[\\/${tag}\\])?`, "gi");
|
|
@@ -471,6 +497,7 @@ function flattenVideoShortcodes(content, widgetRegistry) {
|
|
|
471
497
|
function flattenWordPressWidgets(content, widgetRegistry = WORDPRESS_WIDGET_REGISTRY) {
|
|
472
498
|
let html = content;
|
|
473
499
|
html = flattenGalleryShortcodes(html, widgetRegistry);
|
|
500
|
+
html = flattenIdBasedGalleryShortcodes(html, widgetRegistry);
|
|
474
501
|
html = flattenPortfolioShortcodes(html, widgetRegistry);
|
|
475
502
|
html = flattenMapShortcodes(html, widgetRegistry);
|
|
476
503
|
html = flattenContactFormShortcodes(html, widgetRegistry);
|
|
@@ -520,6 +547,7 @@ function flattenWordPressBuilders(content, options = {}) {
|
|
|
520
547
|
|
|
521
548
|
// src/parsers/wordpress/parse-wxr.ts
|
|
522
549
|
var PLATFORM = "wordpress";
|
|
550
|
+
var DEFAULT_WORDPRESS_PORTFOLIO_CPT_SLUGS = ["portfolio"];
|
|
523
551
|
var WOOCOMMERCE_STUB_PAGE_SLUGS = /* @__PURE__ */ new Set(["cart", "checkout", "my-account"]);
|
|
524
552
|
var WOOCOMMERCE_STUB_SHORTCODE = /^\[woocommerce_(?:cart|checkout|my_account)\]\s*$/i;
|
|
525
553
|
function isWooCommerceStubPage(slug, contentHtml) {
|
|
@@ -559,15 +587,29 @@ function getContentEncoded(item) {
|
|
|
559
587
|
}
|
|
560
588
|
return textValue(item.encoded);
|
|
561
589
|
}
|
|
562
|
-
function sourceMeta(id, link, exportedAt) {
|
|
590
|
+
function sourceMeta(id, link, exportedAt, postType) {
|
|
563
591
|
return {
|
|
564
592
|
platform: PLATFORM,
|
|
565
593
|
id,
|
|
566
594
|
url: link || void 0,
|
|
567
595
|
path: linkToPath(link),
|
|
568
|
-
exportedAt
|
|
596
|
+
exportedAt,
|
|
597
|
+
...postType ? { postType } : {}
|
|
569
598
|
};
|
|
570
599
|
}
|
|
600
|
+
function resolvePortfolioCptSlugs(options) {
|
|
601
|
+
const slugs = options.portfolioCptSlugs ?? DEFAULT_WORDPRESS_PORTFOLIO_CPT_SLUGS;
|
|
602
|
+
return new Set(slugs.map((slug) => slug.toLowerCase()));
|
|
603
|
+
}
|
|
604
|
+
function portfolioCptSourceId(postId) {
|
|
605
|
+
return `portfolio:${postId}`;
|
|
606
|
+
}
|
|
607
|
+
function isPortfolioCptPostType(postType, portfolioCptSlugs) {
|
|
608
|
+
return portfolioCptSlugs.has(postType.toLowerCase());
|
|
609
|
+
}
|
|
610
|
+
function countWxrPortfolioCptItems(items, portfolioCptSlugs = new Set(DEFAULT_WORDPRESS_PORTFOLIO_CPT_SLUGS)) {
|
|
611
|
+
return items.filter((item) => isPortfolioCptPostType(textValue(item.post_type), portfolioCptSlugs)).length;
|
|
612
|
+
}
|
|
571
613
|
function getExcerpt(item) {
|
|
572
614
|
const excerpt = item.excerpt;
|
|
573
615
|
if (!excerpt) return "";
|
|
@@ -661,9 +703,10 @@ function collectTaxonomies(items) {
|
|
|
661
703
|
}
|
|
662
704
|
return { categories, tags };
|
|
663
705
|
}
|
|
664
|
-
function collectInlineAssets(html, attachmentIndex, seenUrls, exportedAt, originUrlRewrite) {
|
|
706
|
+
function collectInlineAssets(html, attachmentIndex, seenUrls, seenAttachmentIds, exportedAt, originUrlRewrite) {
|
|
665
707
|
const assets = [];
|
|
666
|
-
|
|
708
|
+
const discovery = discoverContentAssets(html);
|
|
709
|
+
for (const discovered of discovery.urls) {
|
|
667
710
|
const canonical = canonicalizeInlineAssetUrl(discovered, originUrlRewrite);
|
|
668
711
|
if (!canonical) continue;
|
|
669
712
|
if (seenUrls.has(canonical.canonicalUrl)) continue;
|
|
@@ -683,9 +726,22 @@ function collectInlineAssets(html, attachmentIndex, seenUrls, exportedAt, origin
|
|
|
683
726
|
mimeType: guessMime(filename)
|
|
684
727
|
});
|
|
685
728
|
}
|
|
686
|
-
for (const
|
|
729
|
+
for (const attachmentId of discovery.unresolvedAttachmentIds) {
|
|
730
|
+
if (seenAttachmentIds.has(attachmentId)) continue;
|
|
731
|
+
seenAttachmentIds.add(attachmentId);
|
|
732
|
+
const entry = attachmentIndex.get(attachmentId);
|
|
733
|
+
if (!entry) continue;
|
|
687
734
|
if (seenUrls.has(entry.sourceUrl)) continue;
|
|
688
|
-
|
|
735
|
+
seenUrls.add(entry.sourceUrl);
|
|
736
|
+
assets.push({
|
|
737
|
+
type: "asset",
|
|
738
|
+
source: sourceMeta(attachmentId, entry.sourceUrl, exportedAt),
|
|
739
|
+
sourceId: attachmentId,
|
|
740
|
+
sourceUrl: entry.sourceUrl,
|
|
741
|
+
filename: entry.filename,
|
|
742
|
+
mimeType: entry.mimeType ?? guessMime(entry.filename),
|
|
743
|
+
caption: entry.title
|
|
744
|
+
});
|
|
689
745
|
}
|
|
690
746
|
return assets;
|
|
691
747
|
}
|
|
@@ -740,20 +796,25 @@ async function* enumerateWxrEntities(options) {
|
|
|
740
796
|
caption: entry.title
|
|
741
797
|
};
|
|
742
798
|
}
|
|
799
|
+
const portfolioCptSlugs = resolvePortfolioCptSlugs(options);
|
|
743
800
|
for (const item of items) {
|
|
744
801
|
const postType = textValue(item.post_type);
|
|
745
|
-
|
|
802
|
+
const isPost = postType === "post";
|
|
803
|
+
const isPage = postType === "page";
|
|
804
|
+
const isPortfolioCpt = isPortfolioCptPostType(postType, portfolioCptSlugs);
|
|
805
|
+
if (!isPost && !isPage && !isPortfolioCpt) continue;
|
|
746
806
|
const id = textValue(item.post_id);
|
|
747
807
|
const link = maybeRewriteUrl(textValue(item.link), options.originUrlRewrite);
|
|
748
808
|
const slug = sanitizeSlug(textValue(item.post_name) || textValue(item.title) || id);
|
|
749
809
|
let contentHtml = preprocessContent(getContentEncoded(item), options);
|
|
750
|
-
if (
|
|
810
|
+
if (isPage && options.skipWooCommerceStubPages !== false && isWooCommerceStubPage(slug, contentHtml)) {
|
|
751
811
|
continue;
|
|
752
812
|
}
|
|
753
813
|
const inlineAssets = collectInlineAssets(
|
|
754
814
|
contentHtml,
|
|
755
815
|
attachmentIndex,
|
|
756
816
|
seenAssetUrls,
|
|
817
|
+
emittedAttachmentIds,
|
|
757
818
|
options.exportedAt,
|
|
758
819
|
options.originUrlRewrite
|
|
759
820
|
);
|
|
@@ -788,7 +849,7 @@ async function* enumerateWxrEntities(options) {
|
|
|
788
849
|
if (domain === "category") categorySlugs.push(nicename);
|
|
789
850
|
if (domain === "post_tag") tagSlugs.push(nicename);
|
|
790
851
|
}
|
|
791
|
-
if (
|
|
852
|
+
if (isPost) {
|
|
792
853
|
const thumbnailId = getPostMeta(item, "_thumbnail_id");
|
|
793
854
|
const featuredAssetSourceId = resolveFeaturedAssetSourceId(
|
|
794
855
|
thumbnailId,
|
|
@@ -813,11 +874,12 @@ async function* enumerateWxrEntities(options) {
|
|
|
813
874
|
};
|
|
814
875
|
yield post;
|
|
815
876
|
} else {
|
|
816
|
-
const isHomePage = getPostMeta(item, "_wp_show_on_front") === "1" || getPostMeta(item, "page_on_front") === "1";
|
|
877
|
+
const isHomePage = !isPortfolioCpt && (getPostMeta(item, "_wp_show_on_front") === "1" || getPostMeta(item, "page_on_front") === "1");
|
|
878
|
+
const pageSourceId = isPortfolioCpt ? portfolioCptSourceId(id) : id;
|
|
817
879
|
const page = {
|
|
818
880
|
type: "page",
|
|
819
|
-
source: sourceMeta(
|
|
820
|
-
sourceId:
|
|
881
|
+
source: sourceMeta(pageSourceId, link, options.exportedAt, isPortfolioCpt ? postType : void 0),
|
|
882
|
+
sourceId: pageSourceId,
|
|
821
883
|
title: textValue(item.title) || slug,
|
|
822
884
|
slug,
|
|
823
885
|
contentHtml,
|
|
@@ -849,7 +911,7 @@ async function validateWxrFile(filePath) {
|
|
|
849
911
|
posts: items.filter((i) => textValue(i.post_type) === "post").length,
|
|
850
912
|
pages: items.filter((i) => textValue(i.post_type) === "page").length,
|
|
851
913
|
assets: items.filter((i) => textValue(i.post_type) === "attachment").length,
|
|
852
|
-
|
|
914
|
+
portfolioCpt: countWxrPortfolioCptItems(items),
|
|
853
915
|
categories: 0,
|
|
854
916
|
tags: 0
|
|
855
917
|
};
|
|
@@ -870,11 +932,12 @@ function resolveWxrOptions(input) {
|
|
|
870
932
|
filePath: String(obj.path),
|
|
871
933
|
originUrlRewrite: obj.originUrlRewrite,
|
|
872
934
|
flattenBuilders: obj.flattenBuilders,
|
|
873
|
-
skipWooCommerceStubPages: obj.skipWooCommerceStubPages
|
|
935
|
+
skipWooCommerceStubPages: obj.skipWooCommerceStubPages,
|
|
936
|
+
portfolioCptSlugs: obj.portfolioCptSlugs
|
|
874
937
|
};
|
|
875
938
|
}
|
|
876
939
|
throw new Error(
|
|
877
|
-
"WordPress adapter requires input path (string or { path, originUrlRewrite?, flattenBuilders?, skipWooCommerceStubPages? })"
|
|
940
|
+
"WordPress adapter requires input path (string or { path, originUrlRewrite?, flattenBuilders?, skipWooCommerceStubPages?, portfolioCptSlugs? })"
|
|
878
941
|
);
|
|
879
942
|
}
|
|
880
943
|
var wordpressAdapter = {
|
|
@@ -2865,4 +2928,4 @@ export {
|
|
|
2865
2928
|
wixAdapter,
|
|
2866
2929
|
getAdapter
|
|
2867
2930
|
};
|
|
2868
|
-
//# sourceMappingURL=chunk-
|
|
2931
|
+
//# sourceMappingURL=chunk-FB3MMCHY.js.map
|