chore(cli): dry up link + post tag prompt

This commit is contained in:
Cory Dransfeldt 2025-06-16 14:56:55 -07:00
parent efe701f939
commit 555ba74bf6
No known key found for this signature in database
8 changed files with 75 additions and 104 deletions

View file

@ -2,6 +2,7 @@ import inquirer from "inquirer";
import { loadConfig } from "../config.js";
import { initDirectusClient, createItem, searchItems } from "../directus/client.js";
import { promptForMultipleRelations } from "../directus/relationHelpers.js";
import { promptForTags } from "../directus/tagHelpers.js";
const ASSOCIATED_MEDIA_TYPES = ["artists", "books", "movies", "shows", "genres"];
const BLOCK_COLLECTIONS = [
@ -42,44 +43,7 @@ export const addPost = async () => {
}
]);
let tagIds = [];
while (true) {
const { query } = await inquirer.prompt({
name: "query",
message: "🏷 Search for tags (or leave blank to finish):"
});
const trimmedQuery = query.trim();
if (!trimmedQuery) break;
const tags = await searchItems("tags", trimmedQuery);
if (!tags.length) {
console.warn(`⚠️ No tags found matching "${trimmedQuery}"`);
continue;
}
const { selected } = await inquirer.prompt({
type: "checkbox",
name: "selected",
message: "✔ Select tags to add:",
choices: tags.map((tag) => ({ name: tag.name, value: tag.id }))
});
tagIds.push(...selected);
const { again } = await inquirer.prompt({
type: "confirm",
name: "again",
message: "Search and select more tags?",
default: false
});
if (!again) break;
}
const tagIds = await promptForTags();
const selectedBlocks = [];
const { includeBlocks } = await inquirer.prompt({
type: "confirm",