feat(*.liquid): apply prettier to liquid templates
- offer to create tag when none is found while adding a link from cli - fix tag display in search
This commit is contained in:
parent
49e21d574e
commit
efe701f939
112 changed files with 1319 additions and 1134 deletions
|
@ -1,12 +1,12 @@
|
|||
import inquirer from 'inquirer';
|
||||
import { loadConfig } from '../config.js';
|
||||
import inquirer from "inquirer";
|
||||
import { loadConfig } from "../config.js";
|
||||
import {
|
||||
initDirectusClient,
|
||||
getDirectusClient,
|
||||
searchItems,
|
||||
createItem,
|
||||
updateItem
|
||||
} from '../directus/client.js';
|
||||
} from "../directus/client.js";
|
||||
|
||||
export const addEpisodeToShow = async () => {
|
||||
const config = await loadConfig();
|
||||
|
@ -15,21 +15,21 @@ export const addEpisodeToShow = async () => {
|
|||
|
||||
const directus = getDirectusClient();
|
||||
const showResults = await inquirer.prompt({
|
||||
name: 'query',
|
||||
message: 'Search for a show:'
|
||||
name: "query",
|
||||
message: "Search for a show:"
|
||||
});
|
||||
const matches = await searchItems('shows', showResults.query);
|
||||
const matches = await searchItems("shows", showResults.query);
|
||||
|
||||
if (!matches.length) {
|
||||
console.warn('⚠️ No matching shows found.');
|
||||
console.warn("⚠️ No matching shows found.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const { showId } = await inquirer.prompt({
|
||||
type: 'list',
|
||||
name: 'showId',
|
||||
message: 'Select a show:',
|
||||
type: "list",
|
||||
name: "showId",
|
||||
message: "Select a show:",
|
||||
choices: matches.map((s) => ({
|
||||
name: s.title || s.name || s.id,
|
||||
value: s.id
|
||||
|
@ -37,23 +37,23 @@ export const addEpisodeToShow = async () => {
|
|||
});
|
||||
const { season_number, episode_number, plays } = await inquirer.prompt([
|
||||
{
|
||||
name: 'season_number',
|
||||
message: 'Season number:',
|
||||
name: "season_number",
|
||||
message: "Season number:",
|
||||
validate: (val) => !isNaN(val)
|
||||
},
|
||||
{
|
||||
name: 'episode_number',
|
||||
message: 'Episode number:',
|
||||
name: "episode_number",
|
||||
message: "Episode number:",
|
||||
validate: (val) => !isNaN(val)
|
||||
},
|
||||
{
|
||||
name: 'plays',
|
||||
message: 'Play count:',
|
||||
name: "plays",
|
||||
message: "Play count:",
|
||||
default: 0,
|
||||
validate: (val) => !isNaN(val)
|
||||
}
|
||||
]);
|
||||
const existing = await searchItems('episodes', `${season_number} ${episode_number}`);
|
||||
const existing = await searchItems("episodes", `${season_number} ${episode_number}`);
|
||||
const match = existing.find(
|
||||
(e) =>
|
||||
Number(e.season_number) === Number(season_number) &&
|
||||
|
@ -63,21 +63,21 @@ export const addEpisodeToShow = async () => {
|
|||
|
||||
if (match) {
|
||||
const { update } = await inquirer.prompt({
|
||||
type: 'confirm',
|
||||
name: 'update',
|
||||
type: "confirm",
|
||||
name: "update",
|
||||
message: `Episode exists. Update play count from ${match.plays ?? 0} to ${plays}?`,
|
||||
default: true
|
||||
});
|
||||
|
||||
if (update) {
|
||||
await updateItem('episodes', match.id, { plays });
|
||||
await updateItem("episodes", match.id, { plays });
|
||||
|
||||
console.log(`✅ Updated episode: S${season_number}E${episode_number}`);
|
||||
} else {
|
||||
console.warn('⚠️ Skipped update.');
|
||||
console.warn("⚠️ Skipped update.");
|
||||
}
|
||||
} else {
|
||||
await createItem('episodes', {
|
||||
await createItem("episodes", {
|
||||
season_number: Number(season_number),
|
||||
episode_number: Number(episode_number),
|
||||
plays: Number(plays),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue