@magicpages/ghost-typesense-cli 1.7.0 → 1.8.0
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/index.js +29 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var { version } = JSON.parse(
|
|
|
18
18
|
program.name("ghost-typesense").description("CLI tool for managing Ghost content in Typesense").version(version, "-V, --version", "Output the version number").option("-v", "Output the version number", () => {
|
|
19
19
|
console.log(version);
|
|
20
20
|
process.exit(0);
|
|
21
|
-
});
|
|
21
|
+
}).option("-d, --debug", "Enable debug mode");
|
|
22
22
|
program.command("init").description("Initialize Typesense collection with schema from config").requiredOption("-c, --config <path>", "Path to config file").action(async (options) => {
|
|
23
23
|
try {
|
|
24
24
|
const spinner = ora("Reading configuration...").start();
|
|
@@ -35,16 +35,41 @@ program.command("init").description("Initialize Typesense collection with schema
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
program.command("sync").description("Sync all Ghost posts to Typesense").requiredOption("-c, --config <path>", "Path to config file").action(async (options) => {
|
|
38
|
+
const debug = program.opts().debug;
|
|
38
39
|
try {
|
|
39
|
-
const spinner = ora("Reading configuration...").start();
|
|
40
|
+
const spinner = debug ? null : ora("Reading configuration...").start();
|
|
40
41
|
const configPath = resolve(process.cwd(), options.config);
|
|
41
42
|
const configContent = readFileSync(configPath, "utf-8");
|
|
43
|
+
if (debug) {
|
|
44
|
+
console.log(chalk.blue("\u{1F4C4} Config path:"), configPath);
|
|
45
|
+
console.log(chalk.blue("\u{1F4CB} Config content:"), configContent);
|
|
46
|
+
}
|
|
42
47
|
const config = validateConfig(JSON.parse(configContent));
|
|
43
|
-
|
|
48
|
+
if (debug) {
|
|
49
|
+
console.log(chalk.green("\u2705 Config validated successfully"));
|
|
50
|
+
console.log(chalk.blue("\u{1F527} Ghost URL:"), config.ghost.url);
|
|
51
|
+
console.log(chalk.blue("\u{1F511} Ghost API Key:"), config.ghost.key.substring(0, 10) + "...");
|
|
52
|
+
console.log(chalk.blue("\u{1F50D} Typesense nodes:"), JSON.stringify(config.typesense.nodes, null, 2));
|
|
53
|
+
}
|
|
54
|
+
if (spinner) spinner.text = "Syncing posts to Typesense...";
|
|
44
55
|
const manager = new GhostTypesenseManager(config);
|
|
56
|
+
if (debug) {
|
|
57
|
+
console.log(chalk.yellow("\u{1F4E1} Fetching posts from Ghost..."));
|
|
58
|
+
}
|
|
45
59
|
await manager.indexAllPosts();
|
|
46
|
-
spinner
|
|
60
|
+
if (spinner) {
|
|
61
|
+
spinner.succeed("Posts synced successfully");
|
|
62
|
+
} else {
|
|
63
|
+
console.log(chalk.green("\u2705 Posts synced successfully"));
|
|
64
|
+
}
|
|
47
65
|
} catch (error) {
|
|
66
|
+
if (debug) {
|
|
67
|
+
console.error(chalk.red("\u274C Error details:"));
|
|
68
|
+
console.error(error);
|
|
69
|
+
if (error instanceof Error && error.stack) {
|
|
70
|
+
console.error(chalk.red("Stack trace:"), error.stack);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
48
73
|
ora().fail(chalk.red(`Failed to sync posts: ${error.message}`));
|
|
49
74
|
process.exit(1);
|
|
50
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicpages/ghost-typesense-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "CLI tool for managing Ghost content in Typesense",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"typecheck": "tsc --noEmit"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@magicpages/ghost-typesense-config": "^1.
|
|
23
|
-
"@magicpages/ghost-typesense-core": "^1.
|
|
22
|
+
"@magicpages/ghost-typesense-config": "^1.8.0",
|
|
23
|
+
"@magicpages/ghost-typesense-core": "^1.8.0",
|
|
24
24
|
"chalk": "^5.3.0",
|
|
25
25
|
"commander": "^12.0.0",
|
|
26
26
|
"ora": "^8.0.1"
|