chore(cli): formatting + version consistency

This commit is contained in:
Cory Dransfeldt 2025-06-11 13:01:36 -07:00
parent fdd556df83
commit 970061ff9d
No known key found for this signature in database
15 changed files with 83 additions and 34 deletions

View file

@ -31,6 +31,7 @@ export const initConfig = async () => {
message: 'Where is your storage root directory?',
validate: fs.pathExists
}]);
config.storageDir = storageDir;
}
} else {
@ -39,6 +40,7 @@ export const initConfig = async () => {
message: 'Where is your storage root directory?',
validate: fs.pathExists
}]);
config.storageDir = storageDir;
}
@ -66,6 +68,7 @@ export const initConfig = async () => {
message: `Subpath for ${mediaType}/${assetType} (relative to storage root):`,
default: defaultPath
}]);
subpath = response.subpath;
}
@ -161,6 +164,7 @@ const fetchGlobals = async () => {
if (!POSTGREST_URL || !POSTGREST_API_KEY) {
console.warn('⚠️ Missing POSTGREST_URL or POSTGREST_API_KEY in env, skipping globals fetch.');
return {};
}
@ -176,9 +180,11 @@ const fetchGlobals = async () => {
if (!res.ok) throw new Error(await res.text());
const data = await res.json();
return data[0] || {};
} catch (err) {
console.error('❌ Error fetching globals:', err.message);
return {};
}
};

View file

@ -71,6 +71,7 @@ export const searchItems = async (collection, query = '', filters = {}) => {
return data?.data ?? [];
} catch (err) {
console.error(`❌ Failed to search ${collection}:`, err.message);
return [];
}
};

View file

@ -17,6 +17,7 @@ export const promptForMultipleRelations = async (collection, label = collection)
if (!results.length) {
console.warn(`⚠️ No ${collection} found for "${query}".`);
continue;
}

View file

@ -31,11 +31,13 @@ const overwriteImageDownloadPrompt = async (url, finalPath, fileName) => {
if (!overwrite) {
console.log(`⚠️ Skipped existing file: ${fileName}`);
return;
}
}
await downloadImage(url, finalPath);
console.log(`✅ Saved to: ${finalPath}`);
};
@ -53,7 +55,8 @@ export const downloadWatchingImages = async () => {
});
if (!tmdbId) {
console.warn('⚠️ TMDB ID is required.')
console.warn('⚠️ TMDB ID is required.');
return;
}
@ -62,6 +65,7 @@ export const downloadWatchingImages = async () => {
message: 'Enter the poster url:',
validate: (val) => {
if (!val) return true;
return isValidTMDBUrl(val);
}
},
@ -70,6 +74,7 @@ export const downloadWatchingImages = async () => {
message: 'Enter the backdrop url:',
validate: (val) => {
if (!val) return true;
return isValidTMDBUrl(val);
}
}]);
@ -84,6 +89,7 @@ export const downloadWatchingImages = async () => {
if (!targetSubPath) {
console.error(`❌ Missing path for ${mediaType}/${type}. Check your config.`);
continue;
}
@ -102,7 +108,8 @@ export const downloadArtistImage = async () => {
});
if (!artistName) {
console.warn('⚠️ Artist name is required.')
console.warn('⚠️ Artist name is required.');
return;
}
@ -112,6 +119,7 @@ export const downloadArtistImage = async () => {
validate: (val) => {
try {
new URL(val);
return true;
} catch {
return '❌ Must be a valid url.';
@ -138,6 +146,7 @@ export const downloadAlbumImage = async () => {
if (!artistName) {
console.warn('⚠️ Artist name is required.');
return;
}
@ -148,6 +157,7 @@ export const downloadAlbumImage = async () => {
if (!albumName) {
console.warn('⚠️ Album name is required.');
return;
}
@ -157,6 +167,7 @@ export const downloadAlbumImage = async () => {
validate: (val) => {
try {
new URL(val);
return true;
} catch {
return '❌ Must be a valid url.';
@ -188,6 +199,7 @@ export const downloadBookImage = async () => {
if (!bookTitle) {
console.warn('⚠️ Book title is required.');
return;
}
@ -197,6 +209,7 @@ export const downloadBookImage = async () => {
validate: (val) => {
try {
new URL(val);
return true;
} catch {
return 'Must be a valid URL';

View file

@ -135,6 +135,7 @@ const runCurl = async ({
if (!url) {
console.error(`❌ Missing URL for job. Check ${urlEnvVar} in your .env`);
return;
}
@ -150,6 +151,7 @@ const runCurl = async ({
if (!res.ok) {
const errText = await res.text();
throw new Error(errText);
}

View file

@ -8,7 +8,6 @@ export const addBlockedRobot = async () => {
initDirectusClient(config);
const robots = await searchItems('robots', '/');
let rootRobot = robots.find(r => r.path === '/');
if (!rootRobot) {

View file

@ -16,6 +16,7 @@ export const addEpisodeToShow = async () => {
if (!matches.length) {
console.warn('⚠️ No matching shows found.');
return;
}
@ -63,6 +64,7 @@ export const addEpisodeToShow = async () => {
if (update) {
await updateItem('episodes', match.id, { plays });
console.log(`✅ Updated episode: S${season_number}E${episode_number}`);
} else {
console.warn('⚠️ Skipped update.');

View file

@ -5,6 +5,7 @@ import { removeUrlProtocol } from '../sanitize.js';
export const addLinkToShare = async () => {
const config = await loadConfig();
initDirectusClient(config);
const { title, link, description, authorQuery } = await inquirer.prompt([
@ -30,7 +31,6 @@ export const addLinkToShare = async () => {
]);
const authorMatches = await searchItems('authors', authorQuery);
let author;
if (!authorMatches.length) {
@ -98,6 +98,7 @@ export const addLinkToShare = async () => {
if (!tags.length) {
console.warn(`⚠️ No tags found matching "${trimmedQuery}"`);
continue;
}

View file

@ -55,6 +55,7 @@ export const addPost = async () => {
if (!tags.length) {
console.warn(`⚠️ No tags found matching "${trimmedQuery}"`);
continue;
}
@ -104,6 +105,7 @@ export const addPost = async () => {
if (!results.length) {
console.warn(`⚠️ No items found in "${collection}" matching "${query}"`);
continue;
}
@ -151,6 +153,7 @@ export const addPost = async () => {
if (!matches.length) {
console.warn(`⚠️ No ${mediaType} found matching "${query.trim()}"`);
continue;
}

View file

@ -11,6 +11,7 @@ export const updateReadingProgress = async () => {
if (!readingBooks.length) {
console.log('📖 No books currently marked as "started".');
return;
}
@ -33,6 +34,7 @@ export const updateReadingProgress = async () => {
message: '📕 New progress percentage (0100):',
validate: input => {
const num = Number(input);
return !isNaN(num) && num >= 0 && num <= 100 || 'Enter a number from 0 to 100';
}
});