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

@ -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();

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';
}
});

34
cli/package-lock.json generated
View file

@ -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"

View file

@ -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"

37
package-lock.json generated
View file

@ -27,7 +27,7 @@
"markdown-it-footnote": "^4.0.0",
"markdown-it-link-attributes": "4.0.1",
"markdown-it-prism": "^3.0.0",
"postcss": "^8.5.4",
"postcss": "^8.5.5",
"postcss-import": "^16.1.0",
"postcss-import-ext-glob": "^2.1.1",
"rimraf": "^6.0.1",
@ -1756,24 +1756,37 @@
"node": ">= 6"
}
},
"node_modules/glob/node_modules/balanced-match": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-3.0.1.tgz",
"integrity": "sha512-vjtV3hiLqYDNRoiAv0zC4QaGAMPomEoq83PRmYIofPswwZurCeWR5LByXm7SyoL0Zh5+2z0+HC7jG8gSZJUh0w==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 16"
}
},
"node_modules/glob/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==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
"balanced-match": "^3.0.0"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/glob/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==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^2.0.1"
"brace-expansion": "^4.0.1"
},
"engines": {
"node": "20 || >=22"
@ -2817,9 +2830,9 @@
}
},
"node_modules/postcss": {
"version": "8.5.4",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.4.tgz",
"integrity": "sha512-QSa9EBe+uwlGTFmHsPKokv3B/oEMQZxfqW0QqNCyhpa6mB1afzulwn8hihglqAb2pOw+BJgNlmXQ8la2VeHB7w==",
"version": "8.5.5",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.5.tgz",
"integrity": "sha512-d/jtm+rdNT8tpXuHY5MMtcbJFBkhXE6593XVR9UoGCH8jSFGci7jGvMGH5RYd5PBJW+00NZQt6gf7CbagJCrhg==",
"dev": true,
"funding": [
{

View file

@ -47,7 +47,7 @@
"markdown-it-footnote": "^4.0.0",
"markdown-it-link-attributes": "4.0.1",
"markdown-it-prism": "^3.0.0",
"postcss": "^8.5.4",
"postcss": "^8.5.5",
"postcss-import": "^16.1.0",
"postcss-import-ext-glob": "^2.1.1",
"rimraf": "^6.0.1",