@artinstack/migrator 0.1.3 → 0.1.5

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/cli/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ createWpContentGatewayRewrite,
3
4
  getAdapter
4
- } from "../chunk-QEXTXHFG.js";
5
+ } from "../chunk-XUBCG3IA.js";
5
6
  import {
6
7
  analyzeConflicts,
7
8
  buildMigrationReport,
@@ -16,10 +17,11 @@ import {
16
17
  runMigration,
17
18
  staleUrlsFromEstimate,
18
19
  writeFilesystemExport
19
- } from "../chunk-HH7666MQ.js";
20
+ } from "../chunk-YLFVYPB3.js";
20
21
  import {
21
22
  collectEntities
22
23
  } from "../chunk-HI7JHWZU.js";
24
+ import "../chunk-S7TRWILI.js";
23
25
  import "../chunk-2PNSVE5Y.js";
24
26
 
25
27
  // src/cli/index.ts
@@ -45,9 +47,12 @@ Options:
45
47
  --report <dir> With --dry-run, write conflicts.json + migration-report.json
46
48
  --offline Skip network HEAD requests (4 MB fallback per asset)
47
49
  --urls <file> Wix W2: newline URL list or sitemap.xml for static page snapshots
50
+ --rewrite-gateway <url> WordPress: API gateway base (requires --rewrite-public)
51
+ --rewrite-public <url> WordPress: public origin for /wp-content/ asset paths
48
52
 
49
53
  Examples:
50
54
  artinstack-migrate wordpress export.xml --dry-run --report ./preview/
55
+ artinstack-migrate wordpress export.xml --rewrite-gateway https://gateway.example/prod --rewrite-public https://www.example.com --dry-run --report ./preview/
51
56
  artinstack-migrate wix feed.xml --urls ./sitemap-urls.txt --dry-run
52
57
  artinstack-migrate wordpress export.xml --out ./output
53
58
  artinstack-migrate wordpress export.xml --sink filesystem --out ./output
@@ -76,6 +81,8 @@ function parseArgs(argv) {
76
81
  let dryRun = false;
77
82
  let formatJson = false;
78
83
  let offline = false;
84
+ let rewriteGateway;
85
+ let rewritePublic;
79
86
  const first = args[0];
80
87
  if (first === "validate") {
81
88
  command = "validate";
@@ -101,12 +108,36 @@ function parseArgs(argv) {
101
108
  sinkName = args[++i];
102
109
  } else if (flag === "--urls" && args[i + 1]) {
103
110
  urlsPath = args[++i];
111
+ } else if (flag === "--rewrite-gateway" && args[i + 1]) {
112
+ rewriteGateway = args[++i];
113
+ } else if (flag === "--rewrite-public" && args[i + 1]) {
114
+ rewritePublic = args[++i];
104
115
  }
105
116
  }
106
117
  } else {
107
118
  command = first;
108
119
  }
109
- return { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline };
120
+ return { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic };
121
+ }
122
+ function buildAdapterInput(platform, inputPath, urlsPath, rewriteGateway, rewritePublic) {
123
+ if (rewriteGateway || rewritePublic) {
124
+ if (platform !== "wordpress") {
125
+ throw new Error("--rewrite-gateway and --rewrite-public are WordPress-only options");
126
+ }
127
+ if (!rewriteGateway || !rewritePublic) {
128
+ throw new Error("Both --rewrite-gateway and --rewrite-public are required together");
129
+ }
130
+ }
131
+ if (platform === "wordpress") {
132
+ return {
133
+ path: inputPath,
134
+ ...rewriteGateway && rewritePublic ? { originUrlRewrite: createWpContentGatewayRewrite(rewriteGateway, rewritePublic) } : {}
135
+ };
136
+ }
137
+ return {
138
+ path: inputPath,
139
+ ...urlsPath ? { urlsFile: urlsPath } : {}
140
+ };
110
141
  }
111
142
  function migrationExitCode(hasBlockers, hasWarn) {
112
143
  if (hasBlockers) return 1;
@@ -114,7 +145,7 @@ function migrationExitCode(hasBlockers, hasWarn) {
114
145
  return 0;
115
146
  }
116
147
  async function main() {
117
- const { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline } = parseArgs(process.argv.slice(2));
148
+ const { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic } = parseArgs(process.argv.slice(2));
118
149
  if (!command || command === "--help" || command === "-h") {
119
150
  printUsage();
120
151
  process.exit(0);
@@ -142,10 +173,13 @@ async function main() {
142
173
  process.exit(1);
143
174
  }
144
175
  const adapter = getAdapter(platform);
145
- const input = {
146
- path: inputPath,
147
- ...urlsPath ? { urlsFile: urlsPath } : {}
148
- };
176
+ let input;
177
+ try {
178
+ input = buildAdapterInput(platform, inputPath, urlsPath, rewriteGateway, rewritePublic);
179
+ } catch (error) {
180
+ console.error(error instanceof Error ? error.message : error);
181
+ process.exit(1);
182
+ }
149
183
  if (dryRun) {
150
184
  const result = await runDryRun({
151
185
  adapter,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { writeFile } from \"node:fs/promises\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { getAdapter } from \"../parsers/index.js\";\nimport type { MigrationPlatform } from \"../normalizer/types.js\";\nimport {\n analyzeConflicts,\n buildMigrationReport,\n buildRedirectMap,\n bundleToCombinedJson,\n createFilesystemMigrationSink,\n detectRedirectLoops,\n hasBlockingConflicts,\n hasWarnings,\n runDryRun,\n runMigration,\n writeFilesystemExport,\n} from \"../sinks/index.js\";\nimport { collectEntities } from \"../normalizer/bundle.js\";\nimport { estimateStorage, staleUrlsFromEstimate } from \"../sinks/storage-estimate.js\";\n\nconst PLATFORMS: MigrationPlatform[] = [\"wordpress\", \"smugmug\", \"squarespace\", \"wix\"];\nconst SINKS = [\"filesystem\"] as const;\n\nfunction printUsage(): void {\n console.log(`artinstack-migrate — platform content migration CLI\n\nUsage:\n artinstack-migrate <platform> <export-file> [options]\n artinstack-migrate validate <platform> <export-file>\n\nPlatforms: ${PLATFORMS.join(\", \")}\n\nOptions:\n --out <dir> Write grouped JSON files to directory\n --sink <name> Run through MigrationSink (supported: ${SINKS.join(\", \")})\n --format json Write combined JSON to stdout\n --dry-run Parse and analyze without writing content files\n --report <dir> With --dry-run, write conflicts.json + migration-report.json\n --offline Skip network HEAD requests (4 MB fallback per asset)\n --urls <file> Wix W2: newline URL list or sitemap.xml for static page snapshots\n\nExamples:\n artinstack-migrate wordpress export.xml --dry-run --report ./preview/\n artinstack-migrate wix feed.xml --urls ./sitemap-urls.txt --dry-run\n artinstack-migrate wordpress export.xml --out ./output\n artinstack-migrate wordpress export.xml --sink filesystem --out ./output\n pnpm cli wordpress fixtures/wordpress/long-form-journal.xml --dry-run\n`);\n}\n\nfunction printDryRunStatus(exitCode: 0 | 1 | 2, reportDir?: string): void {\n const dest = reportDir ? ` Reports written to ${reportDir}.` : \"\";\n if (exitCode === 0) {\n console.error(`Dry run complete.${dest}`);\n } else if (exitCode === 2) {\n console.error(`Dry run complete with warnings (exit 2).${dest}`);\n } else {\n console.error(`Dry run found blocking conflicts (exit 1).${dest}`);\n }\n}\n\nfunction parseArgs(argv: string[]): {\n command: string | undefined;\n platform: MigrationPlatform | undefined;\n inputPath: string | undefined;\n urlsPath: string | undefined;\n outDir: string | undefined;\n reportDir: string | undefined;\n sinkName: string | undefined;\n dryRun: boolean;\n formatJson: boolean;\n offline: boolean;\n} {\n const args = [...argv];\n let command: string | undefined;\n let platform: MigrationPlatform | undefined;\n let inputPath: string | undefined;\n let urlsPath: string | undefined;\n let outDir: string | undefined;\n let reportDir: string | undefined;\n let sinkName: string | undefined;\n let dryRun = false;\n let formatJson = false;\n let offline = false;\n\n const first = args[0];\n if (first === \"validate\") {\n command = \"validate\";\n platform = args[1] as MigrationPlatform;\n inputPath = args[2];\n for (let i = 3; i < args.length; i++) {\n if (args[i] === \"--urls\" && args[i + 1]) urlsPath = args[++i];\n }\n } else if (first && PLATFORMS.includes(first as MigrationPlatform)) {\n command = \"migrate\";\n platform = first as MigrationPlatform;\n inputPath = args[1];\n for (let i = 2; i < args.length; i++) {\n const flag = args[i];\n if (flag === \"--dry-run\") dryRun = true;\n else if (flag === \"--format\" && args[i + 1] === \"json\") formatJson = true;\n else if (flag === \"--offline\") offline = true;\n else if (flag === \"--out\" && args[i + 1]) {\n outDir = args[++i];\n } else if (flag === \"--report\" && args[i + 1]) {\n reportDir = args[++i];\n } else if (flag === \"--sink\" && args[i + 1]) {\n sinkName = args[++i];\n } else if (flag === \"--urls\" && args[i + 1]) {\n urlsPath = args[++i];\n }\n }\n } else {\n command = first;\n }\n\n return { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline };\n}\n\nfunction migrationExitCode(hasBlockers: boolean, hasWarn: boolean): 0 | 1 | 2 {\n if (hasBlockers) return 1;\n if (hasWarn) return 2;\n return 0;\n}\n\nasync function main(): Promise<void> {\n const { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline } =\n parseArgs(process.argv.slice(2));\n\n if (!command || command === \"--help\" || command === \"-h\") {\n printUsage();\n process.exit(0);\n }\n\n if (command === \"validate\") {\n if (!platform || !PLATFORMS.includes(platform) || !inputPath) {\n console.error(\"Usage: artinstack-migrate validate <platform> <export-file>\");\n process.exit(1);\n }\n const adapter = getAdapter(platform);\n const result = await adapter.validateInput({\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n });\n console.log(JSON.stringify(result, null, 2));\n process.exit(result.ok ? 0 : 1);\n }\n\n if (command === \"migrate\") {\n if (!platform || !inputPath) {\n printUsage();\n process.exit(1);\n }\n\n if (sinkName && !SINKS.includes(sinkName as (typeof SINKS)[number])) {\n console.error(`Unknown sink: ${sinkName}. Supported: ${SINKS.join(\", \")}`);\n process.exit(1);\n }\n\n const adapter = getAdapter(platform);\n const input = {\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n };\n\n if (dryRun) {\n const result = await runDryRun({\n adapter,\n input,\n platform,\n offlineStorageEstimate: offline,\n });\n\n if (reportDir) {\n await mkdir(reportDir, { recursive: true });\n await writeFile(\n join(reportDir, \"conflicts.json\"),\n `${JSON.stringify(result.conflicts, null, 2)}\\n`,\n );\n await writeFile(\n join(reportDir, \"migration-report.json\"),\n `${JSON.stringify(result.report, null, 2)}\\n`,\n );\n } else {\n console.log(JSON.stringify(result.report, null, 2));\n }\n\n printDryRunStatus(result.exitCode, reportDir);\n process.exit(result.exitCode);\n }\n\n const startedAt = new Date();\n\n if (sinkName === \"filesystem\") {\n if (!outDir) {\n console.error(\"Filesystem sink requires --out <dir>\");\n process.exit(1);\n }\n\n const sink = createFilesystemMigrationSink();\n const runResult = await runMigration({\n sink,\n platform,\n entities: adapter.enumerateEntities({ input }),\n });\n\n const bundle = sink.bundle;\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n redirectLoops: detectRedirectLoops(redirectMap),\n });\n const report = buildMigrationReport({\n platform,\n mode: \"sink\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n warnings:\n runResult.failed > 0\n ? [`${runResult.failed} entity write(s) failed during sink migration`]\n : [],\n });\n\n await sink.flush({ outDir, bundle, conflicts, report });\n console.error(`Wrote sink export to ${outDir}`);\n\n const exitCode = migrationExitCode(\n hasBlockingConflicts(conflicts) || runResult.failed > 0,\n hasWarnings(conflicts),\n );\n process.exit(exitCode);\n }\n\n const bundle = await collectEntities(adapter.enumerateEntities({ input }));\n\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n });\n\n const report = buildMigrationReport({\n platform,\n mode: \"export\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n });\n\n if (formatJson) {\n console.log(JSON.stringify({ ...bundleToCombinedJson(bundle), conflicts, report }, null, 2));\n process.exit(0);\n }\n\n if (!outDir) {\n console.error(\"Specify --out <dir>, --format json, --dry-run, or --sink filesystem --out <dir>\");\n process.exit(1);\n }\n\n await writeFilesystemExport({\n outDir,\n bundle,\n conflicts,\n report,\n });\n\n console.error(`Wrote export to ${outDir}`);\n process.exit(0);\n }\n\n console.error(`Unknown command: ${command}`);\n printUsage();\n process.exit(1);\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,YAAY;AAoBrB,IAAM,YAAiC,CAAC,aAAa,WAAW,eAAe,KAAK;AACpF,IAAM,QAAQ,CAAC,YAAY;AAE3B,SAAS,aAAmB;AAC1B,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMD,UAAU,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA,4DAI2B,MAAM,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAa3E;AACD;AAEA,SAAS,kBAAkB,UAAqB,WAA0B;AACxE,QAAM,OAAO,YAAY,uBAAuB,SAAS,MAAM;AAC/D,MAAI,aAAa,GAAG;AAClB,YAAQ,MAAM,oBAAoB,IAAI,EAAE;AAAA,EAC1C,WAAW,aAAa,GAAG;AACzB,YAAQ,MAAM,2CAA2C,IAAI,EAAE;AAAA,EACjE,OAAO;AACL,YAAQ,MAAM,6CAA6C,IAAI,EAAE;AAAA,EACnE;AACF;AAEA,SAAS,UAAU,MAWjB;AACA,QAAM,OAAO,CAAC,GAAG,IAAI;AACrB,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,SAAS;AACb,MAAI,aAAa;AACjB,MAAI,UAAU;AAEd,QAAM,QAAQ,KAAK,CAAC;AACpB,MAAI,UAAU,YAAY;AACxB,cAAU;AACV,eAAW,KAAK,CAAC;AACjB,gBAAY,KAAK,CAAC;AAClB,aAAS,IA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,SAAS;AAAA,QACtD,YAAYA,UAAS;AAAA,MACvB;AACA,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAEA,UAAM,SAAS,MAAM,gBAAgB,QAAQ,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAEzE,UAAM,WAAW,MAAM,gBAAgB;AAAA,MACrC,QAAQ,OAAO;AAAA,MACf;AAAA,IACF,CAAC;AACD,UAAM,cAAc,iBAAiB,MAAM;AAC3C,UAAM,YAAY,iBAAiB,QAAQ;AAAA,MACzC,gBAAgB,sBAAsB,QAAQ;AAAA,IAChD,CAAC;AAED,UAAM,SAAS,qBAAqB;AAAA,MAClC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,SAAS;AAAA,IAClC,CAAC;AAED,QAAI,YAAY;AACd,cAAQ,IAAI,KAAK,UAAU,EAAE,GAAG,qBAAqB,MAAM,GAAG,WAAW,OAAO,GAAG,MAAM,CAAC,CAAC;AAC3F,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI,CAAC,QAAQ;AACX,cAAQ,MAAM,iFAAiF;AAC/F,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,sBAAsB;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,mBAAmB,MAAM,EAAE;AACzC,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,UAAQ,MAAM,oBAAoB,OAAO,EAAE;AAC3C,aAAW;AACX,UAAQ,KAAK,CAAC;AAChB;AAEA,KAAK,EAAE,MAAM,CAAC,UAAmB;AAC/B,UAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,KAAK;AAC5D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["bundle","estimate","redirectMap","conflicts","report"]}
1
+ {"version":3,"sources":["../../src/cli/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { writeFile } from \"node:fs/promises\";\nimport { mkdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { getAdapter } from \"../parsers/index.js\";\nimport type { MigrationPlatform } from \"../normalizer/types.js\";\nimport {\n analyzeConflicts,\n buildMigrationReport,\n buildRedirectMap,\n bundleToCombinedJson,\n createFilesystemMigrationSink,\n detectRedirectLoops,\n hasBlockingConflicts,\n hasWarnings,\n runDryRun,\n runMigration,\n writeFilesystemExport,\n} from \"../sinks/index.js\";\nimport { collectEntities } from \"../normalizer/bundle.js\";\nimport { createWpContentGatewayRewrite } from \"../lib/origin-url-rewrite.js\";\nimport { estimateStorage, staleUrlsFromEstimate } from \"../sinks/storage-estimate.js\";\n\nconst PLATFORMS: MigrationPlatform[] = [\"wordpress\", \"smugmug\", \"squarespace\", \"wix\"];\nconst SINKS = [\"filesystem\"] as const;\n\nfunction printUsage(): void {\n console.log(`artinstack-migrate — platform content migration CLI\n\nUsage:\n artinstack-migrate <platform> <export-file> [options]\n artinstack-migrate validate <platform> <export-file>\n\nPlatforms: ${PLATFORMS.join(\", \")}\n\nOptions:\n --out <dir> Write grouped JSON files to directory\n --sink <name> Run through MigrationSink (supported: ${SINKS.join(\", \")})\n --format json Write combined JSON to stdout\n --dry-run Parse and analyze without writing content files\n --report <dir> With --dry-run, write conflicts.json + migration-report.json\n --offline Skip network HEAD requests (4 MB fallback per asset)\n --urls <file> Wix W2: newline URL list or sitemap.xml for static page snapshots\n --rewrite-gateway <url> WordPress: API gateway base (requires --rewrite-public)\n --rewrite-public <url> WordPress: public origin for /wp-content/ asset paths\n\nExamples:\n artinstack-migrate wordpress export.xml --dry-run --report ./preview/\n artinstack-migrate wordpress export.xml --rewrite-gateway https://gateway.example/prod --rewrite-public https://www.example.com --dry-run --report ./preview/\n artinstack-migrate wix feed.xml --urls ./sitemap-urls.txt --dry-run\n artinstack-migrate wordpress export.xml --out ./output\n artinstack-migrate wordpress export.xml --sink filesystem --out ./output\n pnpm cli wordpress fixtures/wordpress/long-form-journal.xml --dry-run\n`);\n}\n\nfunction printDryRunStatus(exitCode: 0 | 1 | 2, reportDir?: string): void {\n const dest = reportDir ? ` Reports written to ${reportDir}.` : \"\";\n if (exitCode === 0) {\n console.error(`Dry run complete.${dest}`);\n } else if (exitCode === 2) {\n console.error(`Dry run complete with warnings (exit 2).${dest}`);\n } else {\n console.error(`Dry run found blocking conflicts (exit 1).${dest}`);\n }\n}\n\nfunction parseArgs(argv: string[]): {\n command: string | undefined;\n platform: MigrationPlatform | undefined;\n inputPath: string | undefined;\n urlsPath: string | undefined;\n outDir: string | undefined;\n reportDir: string | undefined;\n sinkName: string | undefined;\n dryRun: boolean;\n formatJson: boolean;\n offline: boolean;\n rewriteGateway: string | undefined;\n rewritePublic: string | undefined;\n} {\n const args = [...argv];\n let command: string | undefined;\n let platform: MigrationPlatform | undefined;\n let inputPath: string | undefined;\n let urlsPath: string | undefined;\n let outDir: string | undefined;\n let reportDir: string | undefined;\n let sinkName: string | undefined;\n let dryRun = false;\n let formatJson = false;\n let offline = false;\n let rewriteGateway: string | undefined;\n let rewritePublic: string | undefined;\n\n const first = args[0];\n if (first === \"validate\") {\n command = \"validate\";\n platform = args[1] as MigrationPlatform;\n inputPath = args[2];\n for (let i = 3; i < args.length; i++) {\n if (args[i] === \"--urls\" && args[i + 1]) urlsPath = args[++i];\n }\n } else if (first && PLATFORMS.includes(first as MigrationPlatform)) {\n command = \"migrate\";\n platform = first as MigrationPlatform;\n inputPath = args[1];\n for (let i = 2; i < args.length; i++) {\n const flag = args[i];\n if (flag === \"--dry-run\") dryRun = true;\n else if (flag === \"--format\" && args[i + 1] === \"json\") formatJson = true;\n else if (flag === \"--offline\") offline = true;\n else if (flag === \"--out\" && args[i + 1]) {\n outDir = args[++i];\n } else if (flag === \"--report\" && args[i + 1]) {\n reportDir = args[++i];\n } else if (flag === \"--sink\" && args[i + 1]) {\n sinkName = args[++i];\n } else if (flag === \"--urls\" && args[i + 1]) {\n urlsPath = args[++i];\n } else if (flag === \"--rewrite-gateway\" && args[i + 1]) {\n rewriteGateway = args[++i];\n } else if (flag === \"--rewrite-public\" && args[i + 1]) {\n rewritePublic = args[++i];\n }\n }\n } else {\n command = first;\n }\n\n return { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic };\n}\n\nfunction buildAdapterInput(\n platform: MigrationPlatform,\n inputPath: string,\n urlsPath: string | undefined,\n rewriteGateway: string | undefined,\n rewritePublic: string | undefined,\n): unknown {\n if (rewriteGateway || rewritePublic) {\n if (platform !== \"wordpress\") {\n throw new Error(\"--rewrite-gateway and --rewrite-public are WordPress-only options\");\n }\n if (!rewriteGateway || !rewritePublic) {\n throw new Error(\"Both --rewrite-gateway and --rewrite-public are required together\");\n }\n }\n\n if (platform === \"wordpress\") {\n return {\n path: inputPath,\n ...(rewriteGateway && rewritePublic\n ? { originUrlRewrite: createWpContentGatewayRewrite(rewriteGateway, rewritePublic) }\n : {}),\n };\n }\n\n return {\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n };\n}\n\nfunction migrationExitCode(hasBlockers: boolean, hasWarn: boolean): 0 | 1 | 2 {\n if (hasBlockers) return 1;\n if (hasWarn) return 2;\n return 0;\n}\n\nasync function main(): Promise<void> {\n const { command, platform, inputPath, urlsPath, outDir, reportDir, sinkName, dryRun, formatJson, offline, rewriteGateway, rewritePublic } =\n parseArgs(process.argv.slice(2));\n\n if (!command || command === \"--help\" || command === \"-h\") {\n printUsage();\n process.exit(0);\n }\n\n if (command === \"validate\") {\n if (!platform || !PLATFORMS.includes(platform) || !inputPath) {\n console.error(\"Usage: artinstack-migrate validate <platform> <export-file>\");\n process.exit(1);\n }\n const adapter = getAdapter(platform);\n const result = await adapter.validateInput({\n path: inputPath,\n ...(urlsPath ? { urlsFile: urlsPath } : {}),\n });\n console.log(JSON.stringify(result, null, 2));\n process.exit(result.ok ? 0 : 1);\n }\n\n if (command === \"migrate\") {\n if (!platform || !inputPath) {\n printUsage();\n process.exit(1);\n }\n\n if (sinkName && !SINKS.includes(sinkName as (typeof SINKS)[number])) {\n console.error(`Unknown sink: ${sinkName}. Supported: ${SINKS.join(\", \")}`);\n process.exit(1);\n }\n\n const adapter = getAdapter(platform);\n let input: unknown;\n try {\n input = buildAdapterInput(platform, inputPath, urlsPath, rewriteGateway, rewritePublic);\n } catch (error) {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n }\n\n if (dryRun) {\n const result = await runDryRun({\n adapter,\n input,\n platform,\n offlineStorageEstimate: offline,\n });\n\n if (reportDir) {\n await mkdir(reportDir, { recursive: true });\n await writeFile(\n join(reportDir, \"conflicts.json\"),\n `${JSON.stringify(result.conflicts, null, 2)}\\n`,\n );\n await writeFile(\n join(reportDir, \"migration-report.json\"),\n `${JSON.stringify(result.report, null, 2)}\\n`,\n );\n } else {\n console.log(JSON.stringify(result.report, null, 2));\n }\n\n printDryRunStatus(result.exitCode, reportDir);\n process.exit(result.exitCode);\n }\n\n const startedAt = new Date();\n\n if (sinkName === \"filesystem\") {\n if (!outDir) {\n console.error(\"Filesystem sink requires --out <dir>\");\n process.exit(1);\n }\n\n const sink = createFilesystemMigrationSink();\n const runResult = await runMigration({\n sink,\n platform,\n entities: adapter.enumerateEntities({ input }),\n });\n\n const bundle = sink.bundle;\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n redirectLoops: detectRedirectLoops(redirectMap),\n });\n const report = buildMigrationReport({\n platform,\n mode: \"sink\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n warnings:\n runResult.failed > 0\n ? [`${runResult.failed} entity write(s) failed during sink migration`]\n : [],\n });\n\n await sink.flush({ outDir, bundle, conflicts, report });\n console.error(`Wrote sink export to ${outDir}`);\n\n const exitCode = migrationExitCode(\n hasBlockingConflicts(conflicts) || runResult.failed > 0,\n hasWarnings(conflicts),\n );\n process.exit(exitCode);\n }\n\n const bundle = await collectEntities(adapter.enumerateEntities({ input }));\n\n const estimate = await estimateStorage({\n assets: bundle.media,\n offline,\n });\n const redirectMap = buildRedirectMap(bundle);\n const conflicts = analyzeConflicts(bundle, {\n staleAssetUrls: staleUrlsFromEstimate(estimate),\n });\n\n const report = buildMigrationReport({\n platform,\n mode: \"export\",\n bundle,\n conflicts,\n redirectMap,\n startedAt,\n storageBytesEstimated: estimate.totalBytes,\n });\n\n if (formatJson) {\n console.log(JSON.stringify({ ...bundleToCombinedJson(bundle), conflicts, report }, null, 2));\n process.exit(0);\n }\n\n if (!outDir) {\n console.error(\"Specify --out <dir>, --format json, --dry-run, or --sink filesystem --out <dir>\");\n process.exit(1);\n }\n\n await writeFilesystemExport({\n outDir,\n bundle,\n conflicts,\n report,\n });\n\n console.error(`Wrote export to ${outDir}`);\n process.exit(0);\n }\n\n console.error(`Unknown command: ${command}`);\n printUsage();\n process.exit(1);\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,YAAY;AAqBrB,IAAM,YAAiC,CAAC,aAAa,WAAW,eAAe,KAAK;AACpF,IAAM,QAAQ,CAAC,YAAY;AAE3B,SAAS,aAAmB;AAC1B,UAAQ,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAMD,UAAU,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA,4DAI2B,MAAM,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAgB3E;AACD;AAEA,SAAS,kBAAkB,UAAqB,WAA0B;AACxE,QAAM,OAAO,YAAY,uBAAuB,SAAS,MAAM;AAC/D,MAAI,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imate","redirectMap","conflicts","report"]}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- import { M as MigrationAdapter, a as MigrationPlatform, V as ValidationResult } from './bundle-DfM_jKbq.js';
2
- export { A as AdapterContext, B as BundleCounts, E as EntityBundle, b as EntityKey, c as EntityType, d as MigrationCursor, N as NormalizedAsset, e as NormalizedAssetExif, f as NormalizedCategory, g as NormalizedEntity, h as NormalizedPage, i as NormalizedPortfolio, j as NormalizedPost, k as NormalizedTag, P as PortfolioMediaLink, l as PublishStatus, S as SourceMetadata, m as ValidationIssue, n as bundleCounts, o as collectEntities, p as emptyBundle, q as entityKey } from './bundle-DfM_jKbq.js';
1
+ import { M as MigrationAdapter, g as MigrationPlatform } from './types-DWOP8Dcy.js';
2
+ export { A as AdapterContext, E as EntityKey, h as EntityType, i as MigrationCursor, b as NormalizedAsset, j as NormalizedAssetExif, d as NormalizedCategory, f as NormalizedEntity, a as NormalizedPage, c as NormalizedPortfolio, N as NormalizedPost, e as NormalizedTag, P as PortfolioMediaLink, k as PublishStatus, S as SourceMetadata, V as ValidationIssue, l as ValidationResult, m as entityKey } from './types-DWOP8Dcy.js';
3
3
  export { EntityState, MigrationCheckpoint, TrackedEntity, buildPortfolioMediaLinks, isTerminalState, normalizedAssetExifSchema, normalizedAssetSchema, normalizedCategorySchema, normalizedEntitySchema, normalizedPageSchema, normalizedPortfolioSchema, normalizedPostSchema, normalizedTagSchema, shouldProcessEntity, sourceMetadataSchema, validateNormalizedAsset, validateNormalizedCategory, validateNormalizedEntity, validateNormalizedPage, validateNormalizedPortfolio, validateNormalizedPost, validateNormalizedTag } from './normalizer/index.js';
4
- export { C as ConflictReport, D as DryRunOptions, a as DryRunResult, F as FALLBACK_ASSET_BYTES, b as FilesystemMigrationSink, M as MIGRATION_WRITE_STAGES, c as MigrationRedirect, d as MigrationReport, e as MigrationRunMode, f as MigrationRunOptions, g as MigrationRunResult, h as MigrationSink, i as MigrationWriteStage, R as RewriteInlineImageRef, j as RewriteInlineImagesOptions, k as RewriteInlineImagesResult, S as StorageEstimate, U as UploadAssetInput, l as UploadAssetResult, m as UploadedAssetRef, W as WriteFilesystemOptions, n as analyzeConflicts, o as buildMigrationReport, p as buildRedirectMap, q as bundleToCombinedJson, r as createFilesystemMigrationSink, s as detectRedirectLoops, t as emptyConflictReport, u as estimateStorage, v as hasBlockingConflicts, w as hasWarnings, x as portfolioMediaMatchesBundle, y as rewriteInlineImages, z as runDryRun, A as runMigration, B as runMigrationFromBundle, E as staleUrlsFromEstimate, G as writeFilesystemExport } from './index-D88mjcF5.js';
5
- import { z } from 'zod';
4
+ export { B as BundleCounts, E as EntityBundle, b as bundleCounts, c as collectEntities, e as emptyBundle } from './bundle-uAAHehbv.js';
5
+ export { ConflictReport, DryRunOptions, DryRunResult, FALLBACK_ASSET_BYTES, FilesystemMigrationSink, MIGRATION_WRITE_STAGES, MigrationRedirect, MigrationReport, MigrationRunMode, MigrationRunOptions, MigrationRunResult, MigrationSink, MigrationWriteStage, StorageEstimate, UploadAssetInput, UploadAssetResult, WriteFilesystemOptions, analyzeConflicts, buildMigrationReport, buildRedirectMap, bundleToCombinedJson, createFilesystemMigrationSink, detectRedirectLoops, emptyConflictReport, estimateStorage, hasBlockingConflicts, hasWarnings, portfolioMediaMatchesBundle, runDryRun, runMigration, runMigrationFromBundle, staleUrlsFromEstimate, writeFilesystemExport } from './sinks/index.js';
6
+ export { R as RewriteInlineImageRef, a as RewriteInlineImagesOptions, b as RewriteInlineImagesResult, U as UploadedAssetRef, r as rewriteInlineImages } from './rewrite-inline-images-BckVKPbh.js';
7
+ export { GrapesComponent, GrapesProjectSnapshot, GrapesStyleRule, HtmlToGrapesOptions, HtmlToTiptapOptions, LayoutKind, LayoutTypeMap, TiptapDoc, TiptapMark, TiptapNode, ValidateGrapesProjectSnapshotOptions, ValidateTiptapDocOptions, cssToStyles, grapesComponentSchema, grapesProjectSnapshotSchema, grapesStyleRuleSchema, htmlToGrapes, htmlToTiptap, tiptapDocSchema, tiptapMarkSchema, tiptapNodeSchema, validateGrapesProjectSnapshot, validateTiptapDoc } from './transformers/index.js';
6
8
  export { discoverContentAssetUrls, discoverRawImgSrcs, extractInlineImageSrcs, isLikelyImageUrl, normalizeAssetUrl } from './lib/index.js';
9
+ import { z } from 'zod';
7
10
  import 'node:stream';
8
11
 
9
12
  interface OriginUrlRewriteRule {
@@ -518,86 +521,4 @@ declare const wixAdapter: MigrationAdapter;
518
521
 
519
522
  declare function getAdapter(platform: MigrationPlatform): MigrationAdapter;
520
523
 
521
- interface HtmlToGrapesOptions {
522
- /** Map source class names to Grapes component types. */
523
- componentMap?: Record<string, string>;
524
- }
525
- interface GrapesStyleRule {
526
- selectors: string[];
527
- style: Record<string, string>;
528
- }
529
- interface GrapesComponent {
530
- type: string;
531
- tagName?: string;
532
- attributes?: Record<string, string>;
533
- classes?: string[];
534
- components?: GrapesComponent[];
535
- content?: string;
536
- void?: boolean;
537
- }
538
- interface GrapesProjectSnapshot {
539
- content: GrapesComponent[];
540
- styles: GrapesStyleRule[];
541
- contentHtml?: string;
542
- contentCss?: string;
543
- }
544
-
545
- /** Cheerio HTML walk → Grapes `content` + root `styles`. */
546
- declare function htmlToGrapes(html: string, options?: HtmlToGrapesOptions): GrapesProjectSnapshot;
547
-
548
- /** Parse `<style>` blocks and class rules into Grapes root `styles[]`. */
549
- declare function cssToStyles(css: string): GrapesStyleRule[];
550
-
551
- declare const grapesStyleRuleSchema: z.ZodObject<{
552
- selectors: z.ZodArray<z.ZodString, "many">;
553
- style: z.ZodRecord<z.ZodString, z.ZodString>;
554
- }, "strip", z.ZodTypeAny, {
555
- style: Record<string, string>;
556
- selectors: string[];
557
- }, {
558
- style: Record<string, string>;
559
- selectors: string[];
560
- }>;
561
- declare const grapesComponentSchema: z.ZodType<GrapesComponent>;
562
- declare const grapesProjectSnapshotSchema: z.ZodObject<{
563
- content: z.ZodArray<z.ZodType<GrapesComponent, z.ZodTypeDef, GrapesComponent>, "many">;
564
- styles: z.ZodArray<z.ZodObject<{
565
- selectors: z.ZodArray<z.ZodString, "many">;
566
- style: z.ZodRecord<z.ZodString, z.ZodString>;
567
- }, "strip", z.ZodTypeAny, {
568
- style: Record<string, string>;
569
- selectors: string[];
570
- }, {
571
- style: Record<string, string>;
572
- selectors: string[];
573
- }>, "many">;
574
- contentHtml: z.ZodOptional<z.ZodString>;
575
- contentCss: z.ZodOptional<z.ZodString>;
576
- }, "strip", z.ZodTypeAny, {
577
- content: GrapesComponent[];
578
- styles: {
579
- style: Record<string, string>;
580
- selectors: string[];
581
- }[];
582
- contentHtml?: string | undefined;
583
- contentCss?: string | undefined;
584
- }, {
585
- content: GrapesComponent[];
586
- styles: {
587
- style: Record<string, string>;
588
- selectors: string[];
589
- }[];
590
- contentHtml?: string | undefined;
591
- contentCss?: string | undefined;
592
- }>;
593
- interface ValidateGrapesProjectSnapshotOptions {
594
- /** When set, every component `type` in the tree must be in this allowlist. */
595
- allowedComponentTypes?: string[];
596
- }
597
- /**
598
- * Opt-in structural check for a Grapes project snapshot (not a full Grapes editor project file).
599
- * Does not validate host-specific component registries unless `allowedComponentTypes` is passed.
600
- */
601
- declare function validateGrapesProjectSnapshot(snapshot: unknown, options?: ValidateGrapesProjectSnapshotOptions): ValidationResult;
602
-
603
- export { type GrapesComponent, type GrapesProjectSnapshot, type GrapesStyleRule, type HtmlToGrapesOptions, MigrationAdapter, MigrationPlatform, type OriginUrlRewriteConfig, type OriginUrlRewriteRule, SMUGMUG_API_BASE, SMUGMUG_OAUTH_ENDPOINTS, SQUARESPACE_JSON_FORMAT, SmugMugApiClient, type SmugMugClientOptions, type SmugMugCredentials, type SquarespaceClientOptions, type SquarespaceCollectTarget, SquarespaceCollectionClient, type ValidateGrapesProjectSnapshotOptions, ValidationResult, WixCollectionClient, WixPageSnapshotCollector, buildJsonPrettyUrl, buildSmugMugAuthorizationHeader, createWpContentGatewayRewrite, cssToStyles, getAdapter, grapesComponentSchema, grapesProjectSnapshotSchema, grapesStyleRuleSchema, htmlToGrapes, mapJsonPrettyWire, readSmugMugCredentialsFromEnv, rewriteOriginUrlsInText, signSmugMugOAuthRequest, smugMugCredentialsSchema, smugmugAdapter, squarespaceAdapter, validateGrapesProjectSnapshot, wixAdapter, wordpressAdapter };
524
+ export { MigrationAdapter, MigrationPlatform, type OriginUrlRewriteConfig, type OriginUrlRewriteRule, SMUGMUG_API_BASE, SMUGMUG_OAUTH_ENDPOINTS, SQUARESPACE_JSON_FORMAT, SmugMugApiClient, type SmugMugClientOptions, type SmugMugCredentials, type SquarespaceClientOptions, type SquarespaceCollectTarget, SquarespaceCollectionClient, WixCollectionClient, WixPageSnapshotCollector, buildJsonPrettyUrl, buildSmugMugAuthorizationHeader, createWpContentGatewayRewrite, getAdapter, mapJsonPrettyWire, readSmugMugCredentialsFromEnv, rewriteOriginUrlsInText, signSmugMugOAuthRequest, smugMugCredentialsSchema, smugmugAdapter, squarespaceAdapter, wixAdapter, wordpressAdapter };