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 chalk from 'chalk';
import figlet from 'figlet'; import figlet from 'figlet';
import { loadConfig } from '../lib/config.js'; import { loadConfig } from '../lib/config.js';
import { runRootScript } from '../lib/runScript.js';
import { handleExitError } from '../lib/handlers.js'; import { handleExitError } from '../lib/handlers.js';
import { runRootScript } from '../lib/runScript.js';
import { runJobsMenu } from '../lib/jobs.js'; import { runJobsMenu } from '../lib/jobs.js';
import { runTasksMenu } from '../lib/tasks/index.js'; import { runTasksMenu } from '../lib/tasks/index.js';

View file

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

View file

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

10
cli/package-lock.json generated
View file

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

View file

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

18
package-lock.json generated
View file

@ -668,9 +668,9 @@
"license": "ISC" "license": "ISC"
}, },
"node_modules/brace-expansion": { "node_modules/brace-expansion": {
"version": "1.1.11", "version": "1.1.12",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@ -756,9 +756,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001721", "version": "1.0.30001722",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001721.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001722.tgz",
"integrity": "sha512-cOuvmUVtKrtEaoKiO0rSc29jcjwMwX5tOHDy4MgVFEWiUXj4uBMJkwI8MDySkgXidpMiHUcviogAvFi4pA2hDQ==", "integrity": "sha512-DCQHBBZtiK6JVkAGw7drvAMK0Q0POD/xZvEmDp6baiMMP6QXXk9HpD6mNYBZWhOPG6LvIDb82ITqtWjhDckHCA==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@ -1757,9 +1757,9 @@
} }
}, },
"node_modules/glob/node_modules/brace-expansion": { "node_modules/glob/node_modules/brace-expansion": {
"version": "2.0.1", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {