chore(cli): only load url from globals data

This commit is contained in:
Cory Dransfeldt 2025-06-11 09:52:32 -07:00
parent 3d20361355
commit fdd556df83
No known key found for this signature in database
6 changed files with 25 additions and 23 deletions

View file

@ -4,8 +4,8 @@ import { program } from 'commander';
import chalk from 'chalk';
import figlet from 'figlet';
import { loadConfig } from '../lib/config.js';
import { runRootScript } from '../lib/runScript.js';
import { handleExitError } from '../lib/handlers.js';
import { runRootScript } from '../lib/runScript.js';
import { runJobsMenu } from '../lib/jobs.js';
import { runTasksMenu } from '../lib/tasks/index.js';

View file

@ -136,7 +136,9 @@ export const initConfig = async () => {
config.directus = { ...(config.directus || {}), apiUrl };
}
config.globals = await fetchGlobals();
const globals = await fetchGlobals();
config.url = globals.url;
await fs.ensureDir(CACHE_DIR);
await fs.writeJson(CONFIG_PATH, config, { spaces: 2 });

View file

@ -21,7 +21,7 @@ export const runJobsMenu = async () => {
{
name: '💿 Scrobble listens from Navidrome',
type: 'curl',
apiUrl: `${config.globals.url}/api/scrobble.php`,
apiUrl: `${config.url}/api/scrobble.php`,
tokenEnvVar: 'NAVIDROME_SCROBBLE_TOKEN',
method: 'POST'
},
@ -35,14 +35,14 @@ export const runJobsMenu = async () => {
{
name: '🐘 Send posts to Mastodon',
type: 'curl',
apiUrl: `${config.globals.url}/api/mastodon.php`,
apiUrl: `${config.url}/api/mastodon.php`,
tokenEnvVar: 'MASTODON_SYNDICATION_TOKEN',
method: 'POST'
},
{
name: '🎤 Import artist from Navidrome',
type: 'curl',
apiUrl: `${config.globals.url}/api/artist-import.php`,
apiUrl: `${config.url}/api/artist-import.php`,
tokenEnvVar: 'ARTIST_IMPORT_TOKEN',
method: 'POST',
paramsPrompt: [{
@ -55,7 +55,7 @@ export const runJobsMenu = async () => {
{
name: '📖 Import book',
type: 'curl',
apiUrl: `${config.globals.url}/api/book-import.php`,
apiUrl: `${config.url}/api/book-import.php`,
tokenEnvVar: 'BOOK_IMPORT_TOKEN',
method: 'POST',
paramsPrompt: [{
@ -68,7 +68,7 @@ export const runJobsMenu = async () => {
{
name: '📽 Import movie or show',
type: 'curl',
apiUrl: `${config.globals.url}/api/watching-import.php`,
apiUrl: `${config.url}/api/watching-import.php`,
tokenEnvVar: 'WATCHING_IMPORT_TOKEN',
method: 'POST',
tokenIncludeInParams: true,
@ -89,7 +89,7 @@ export const runJobsMenu = async () => {
{
name: '📺 Import upcoming TV seasons',
type: 'curl',
apiUrl: `${config.globals.url}/api/seasons-import.php`,
apiUrl: `${config.url}/api/seasons-import.php`,
tokenEnvVar: 'SEASONS_IMPORT_TOKEN',
method: 'POST'
}];

10
cli/package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "coryd",
"version": "3.2.3",
"version": "3.2.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd",
"version": "3.2.3",
"version": "3.2.4",
"dependencies": {
"@directus/sdk": "^19.1.0",
"chalk": "^5.4.1",
@ -432,9 +432,9 @@
"license": "MIT"
},
"node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"

View file

@ -1,6 +1,6 @@
{
"name": "coryd",
"version": "3.2.3",
"version": "3.2.4",
"description": "The CLI for my site to run scripts, manage and download assets.",
"type": "module",
"bin": {