chore(cli): formatting + version consistency
This commit is contained in:
parent
fdd556df83
commit
970061ff9d
15 changed files with 83 additions and 34 deletions
|
@ -12,7 +12,7 @@ import { runTasksMenu } from '../lib/tasks/index.js';
|
|||
process.on('unhandledRejection', (err) => handleExitError(err, 'Unhandled rejection'));
|
||||
process.on('uncaughtException', (err) => handleExitError(err, 'Uncaught exception'));
|
||||
|
||||
program.name('coryd').description('🪄 Handle tasks, run commands or jobs, download things and have fun.').version('3.2.0');
|
||||
program.name('coryd').description('🪄 Handle tasks, run commands or jobs, download things and have fun.').version('3.2.5');
|
||||
program.command('init').description('Initialize CLI and populate required config.').action(async () => {
|
||||
const { initConfig } = await import('../lib/config.js');
|
||||
await initConfig();
|
||||
|
|
|
@ -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 {};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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 [];
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,6 +17,7 @@ export const promptForMultipleRelations = async (collection, label = collection)
|
|||
|
||||
if (!results.length) {
|
||||
console.warn(`⚠️ No ${collection} found for "${query}".`);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ export const addBlockedRobot = async () => {
|
|||
initDirectusClient(config);
|
||||
|
||||
const robots = await searchItems('robots', '/');
|
||||
|
||||
let rootRobot = robots.find(r => r.path === '/');
|
||||
|
||||
if (!rootRobot) {
|
||||
|
|
|
@ -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.');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 (0–100):',
|
||||
validate: input => {
|
||||
const num = Number(input);
|
||||
|
||||
return !isNaN(num) && num >= 0 && num <= 100 || 'Enter a number from 0 to 100';
|
||||
}
|
||||
});
|
||||
|
|
34
cli/package-lock.json
generated
34
cli/package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "coryd",
|
||||
"version": "3.2.4",
|
||||
"version": "3.2.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "coryd",
|
||||
"version": "3.2.4",
|
||||
"version": "3.2.5",
|
||||
"dependencies": {
|
||||
"@directus/sdk": "^19.1.0",
|
||||
"chalk": "^5.4.1",
|
||||
|
@ -426,18 +426,24 @@
|
|||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||
"license": "MIT"
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-3.0.1.tgz",
|
||||
"integrity": "sha512-vjtV3hiLqYDNRoiAv0zC4QaGAMPomEoq83PRmYIofPswwZurCeWR5LByXm7SyoL0Zh5+2z0+HC7jG8gSZJUh0w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 16"
|
||||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
|
||||
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-4.0.1.tgz",
|
||||
"integrity": "sha512-YClrbvTCXGe70pU2JiEiPLYXO9gQkyxYeKpJIQHVS/gOs6EWMQP2RYBwjFLNT322Ji8TOC3IMPfsYCedNpzKfA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
"balanced-match": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
|
@ -785,12 +791,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "10.0.1",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz",
|
||||
"integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==",
|
||||
"version": "10.0.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.2.tgz",
|
||||
"integrity": "sha512-+9TJCIYXgZ2Dm5LxVCFsa8jOm+evMwXHFI0JM1XROmkfkpz8/iLLDh+TwSmyIBrs6C6Xu9294/fq8cBA+P6AqA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^2.0.1"
|
||||
"brace-expansion": "^4.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "20 || >=22"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "coryd",
|
||||
"version": "3.2.4",
|
||||
"description": "The CLI for my site to run scripts, manage and download assets.",
|
||||
"version": "3.2.5",
|
||||
"description": "The CLI for my site to handle tasks, run commands or jobs and download things.",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"coryd": "./bin/index.js"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue