@paroicms/converter 0.1.0 → 0.2.1
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/converter.js +13 -5
- package/dist/index.js +42 -42
- package/package.json +9 -6
package/dist/converter.js
CHANGED
|
@@ -19,11 +19,13 @@ function convertRow(row) {
|
|
|
19
19
|
inlineFormats: {
|
|
20
20
|
size: (value) => ({ type: "textSize", attrs: { value } }),
|
|
21
21
|
obfuscate: (value) => ({ type: "obfuscate", attrs: { asALink: value } }),
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
underline: (value) => (value ? { type: "italic" } : undefined),
|
|
23
|
+
},
|
|
24
|
+
inlineNodes: {
|
|
25
|
+
"internal-link": (value) => ({
|
|
26
|
+
type: "internalLink",
|
|
24
27
|
attrs: { documentId: value },
|
|
25
28
|
}),
|
|
26
|
-
underline: (value) => (value ? { type: "italic" } : undefined),
|
|
27
29
|
},
|
|
28
30
|
embeds: {
|
|
29
31
|
media: (value) => {
|
|
@@ -36,8 +38,14 @@ function convertRow(row) {
|
|
|
36
38
|
}
|
|
37
39
|
return { type: "media", attrs };
|
|
38
40
|
},
|
|
39
|
-
"html-snippet": (value) => ({ type: "htmlSnippet", attrs:
|
|
40
|
-
"video
|
|
41
|
+
"html-snippet": (value) => ({ type: "htmlSnippet", attrs: value }),
|
|
42
|
+
"platform-video": (value) => ({
|
|
43
|
+
type: "platformVideo",
|
|
44
|
+
attrs: {
|
|
45
|
+
videoId: value.videoId,
|
|
46
|
+
platform: value.platform,
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
41
49
|
},
|
|
42
50
|
},
|
|
43
51
|
};
|
package/dist/index.js
CHANGED
|
@@ -4,33 +4,24 @@ import { access } from "node:fs/promises";
|
|
|
4
4
|
import { parseCliArguments } from "./cli.js";
|
|
5
5
|
import { createBackup, getFieldRows, processRows } from "./converter.js";
|
|
6
6
|
import { createMultisiteResult, discoverDatabases } from "./multisite.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
client: "sqlite3",
|
|
13
|
-
connection: {
|
|
14
|
-
filename: dbPath,
|
|
15
|
-
},
|
|
16
|
-
useNullAsDefault: true,
|
|
17
|
-
});
|
|
7
|
+
main().catch((error) => {
|
|
8
|
+
console.error("Unhandled error:", error);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
});
|
|
11
|
+
async function main() {
|
|
18
12
|
try {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
errors: 0,
|
|
26
|
-
errorDetails: [],
|
|
27
|
-
};
|
|
13
|
+
const options = parseCliArguments(process.argv.slice(2));
|
|
14
|
+
if (options.kind === "singleDatabase") {
|
|
15
|
+
await runSingleDatabaseMode();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
await runMultisiteMode();
|
|
28
19
|
}
|
|
29
|
-
console.log(`Processing ${rows.length} rows...`);
|
|
30
|
-
return await processRows(cn, rows, isDryRun);
|
|
31
20
|
}
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
catch (error) {
|
|
22
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
23
|
+
console.error(`Error: ${errorMessage}`);
|
|
24
|
+
process.exit(1);
|
|
34
25
|
}
|
|
35
26
|
}
|
|
36
27
|
async function runSingleDatabaseMode() {
|
|
@@ -110,7 +101,7 @@ async function runMultisiteMode() {
|
|
|
110
101
|
if (!options.force) {
|
|
111
102
|
console.log("=".repeat(80));
|
|
112
103
|
console.log("DRY-RUN PASS - Checking all databases");
|
|
113
|
-
console.log("=".repeat(80)
|
|
104
|
+
console.log(`${"=".repeat(80)}\n`);
|
|
114
105
|
for (const db of existingDatabases) {
|
|
115
106
|
console.log(`\n--- ${db.siteName} ---`);
|
|
116
107
|
console.log(`Database: ${db.dbPath}`);
|
|
@@ -147,7 +138,7 @@ async function runMultisiteMode() {
|
|
|
147
138
|
// Second pass: actual conversion on all databases
|
|
148
139
|
console.log("=".repeat(80));
|
|
149
140
|
console.log("CONVERSION PASS - Converting all databases");
|
|
150
|
-
console.log("=".repeat(80)
|
|
141
|
+
console.log(`${"=".repeat(80)}\n`);
|
|
151
142
|
for (const db of existingDatabases) {
|
|
152
143
|
console.log(`\n--- ${db.siteName} ---`);
|
|
153
144
|
console.log(`Database: ${db.dbPath}`);
|
|
@@ -162,7 +153,7 @@ async function runMultisiteMode() {
|
|
|
162
153
|
}
|
|
163
154
|
const multisiteResult = createMultisiteResult(existingDatabases);
|
|
164
155
|
const totalTimeInSeconds = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
165
|
-
console.log(
|
|
156
|
+
console.log(`\n${"=".repeat(80)}`);
|
|
166
157
|
console.log("FINAL SUMMARY");
|
|
167
158
|
console.log("=".repeat(80));
|
|
168
159
|
console.log(`Total databases: ${multisiteResult.totalDatabases}`);
|
|
@@ -176,23 +167,32 @@ async function runMultisiteMode() {
|
|
|
176
167
|
console.log("Exit code: 0");
|
|
177
168
|
process.exit(0);
|
|
178
169
|
}
|
|
179
|
-
async function
|
|
170
|
+
async function processSingleDatabase(dbPath, isDryRun, doBackup) {
|
|
171
|
+
if (doBackup && !isDryRun) {
|
|
172
|
+
await createBackup(dbPath);
|
|
173
|
+
}
|
|
174
|
+
const cn = knex({
|
|
175
|
+
client: "sqlite3",
|
|
176
|
+
connection: {
|
|
177
|
+
filename: dbPath,
|
|
178
|
+
},
|
|
179
|
+
useNullAsDefault: true,
|
|
180
|
+
});
|
|
180
181
|
try {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
const rows = await getFieldRows(cn);
|
|
183
|
+
console.log(`Found ${rows.length} rows to process\n`);
|
|
184
|
+
if (rows.length === 0) {
|
|
185
|
+
return {
|
|
186
|
+
totalRows: 0,
|
|
187
|
+
converted: 0,
|
|
188
|
+
errors: 0,
|
|
189
|
+
errorDetails: [],
|
|
190
|
+
};
|
|
187
191
|
}
|
|
192
|
+
console.log(`Processing ${rows.length} rows...`);
|
|
193
|
+
return await processRows(cn, rows, isDryRun);
|
|
188
194
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
console.error(`Error: ${errorMessage}`);
|
|
192
|
-
process.exit(1);
|
|
195
|
+
finally {
|
|
196
|
+
await cn.destroy();
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
|
-
main().catch((error) => {
|
|
196
|
-
console.error("Unhandled error:", error);
|
|
197
|
-
process.exit(1);
|
|
198
|
-
});
|
package/package.json
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/converter",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "CLI tool to migrate field data from Quill to Tiptap format",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "CLI tool to migrate field data from Quill to Tiptap format in ParoiCMS databases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"paroicms-converter": "
|
|
7
|
+
"paroicms-converter": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"clear": "rimraf dist/*",
|
|
12
12
|
"dev": "tsc --watch --preserveWatchOutput",
|
|
13
|
-
"postbuild": "chmod +x dist/index.js"
|
|
13
|
+
"postbuild": "chmod +x dist/index.js",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest"
|
|
14
16
|
},
|
|
15
17
|
"dependencies": {
|
|
16
18
|
"knex": "~3.1.0",
|
|
17
19
|
"sqlite3": "~5.1.7",
|
|
18
|
-
"@paroicms/quill-delta-to-tiptap-json": "0.
|
|
20
|
+
"@paroicms/quill-delta-to-tiptap-json": "0.2.0"
|
|
19
21
|
},
|
|
20
22
|
"devDependencies": {
|
|
21
23
|
"@types/node": "~24.8.1",
|
|
22
24
|
"rimraf": "~6.0.1",
|
|
23
|
-
"typescript": "~5.9.3"
|
|
25
|
+
"typescript": "~5.9.3",
|
|
26
|
+
"vitest": "~3.2.4"
|
|
24
27
|
},
|
|
25
28
|
"files": [
|
|
26
29
|
"dist"
|