chore(*): use prettier for formatting

This commit is contained in:
Cory Dransfeldt 2025-06-14 16:43:12 -07:00
parent 6c659fe1d0
commit 029caaaa9e
No known key found for this signature in database
73 changed files with 1390 additions and 794 deletions

View file

@ -14,42 +14,50 @@ const ASSET_TYPES = ['poster', 'backdrop'];
dotenv.config({ path: path.resolve(__dirname, '..', '..', '.env') });
export const initConfig = async () => {
const existingConfig = await fs.pathExists(CONFIG_PATH) ? await fs.readJson(CONFIG_PATH) : {};
const existingConfig = (await fs.pathExists(CONFIG_PATH)) ? await fs.readJson(CONFIG_PATH) : {};
const config = { ...existingConfig };
if (config.storageDir) {
const { updateStorage } = await inquirer.prompt([{
type: 'confirm',
name: 'updateStorage',
message: `Storage directory is already set to "${config.storageDir}". Do you want to update it?`,
default: false
}]);
const { updateStorage } = await inquirer.prompt([
{
type: 'confirm',
name: 'updateStorage',
message: `Storage directory is already set to "${config.storageDir}". Do you want to update it?`,
default: false
}
]);
if (updateStorage) {
const { storageDir } = await inquirer.prompt([{
name: 'storageDir',
message: 'Where is your storage root directory?',
validate: fs.pathExists
}]);
const { storageDir } = await inquirer.prompt([
{
name: 'storageDir',
message: 'Where is your storage root directory?',
validate: fs.pathExists
}
]);
config.storageDir = storageDir;
}
} else {
const { storageDir } = await inquirer.prompt([{
name: 'storageDir',
message: 'Where is your storage root directory?',
validate: fs.pathExists
}]);
const { storageDir } = await inquirer.prompt([
{
name: 'storageDir',
message: 'Where is your storage root directory?',
validate: fs.pathExists
}
]);
config.storageDir = storageDir;
}
const { customize } = await inquirer.prompt([{
type: 'confirm',
name: 'customize',
message: 'Do you want to customize default media paths?',
default: false
}]);
const { customize } = await inquirer.prompt([
{
type: 'confirm',
name: 'customize',
message: 'Do you want to customize default media paths?',
default: false
}
]);
config.mediaPaths = {};
@ -63,11 +71,13 @@ export const initConfig = async () => {
let subpath = defaultPath;
if (customize) {
const response = await inquirer.prompt([{
name: 'subpath',
message: `Subpath for ${mediaType}/${assetType} (relative to storage root):`,
default: defaultPath
}]);
const response = await inquirer.prompt([
{
name: 'subpath',
message: `Subpath for ${mediaType}/${assetType} (relative to storage root):`,
default: defaultPath
}
]);
subpath = response.subpath;
}
@ -113,28 +123,34 @@ export const initConfig = async () => {
: 'Media assets/books';
if (config.directus?.apiUrl) {
const { updateApiUrl } = await inquirer.prompt([{
type: 'confirm',
name: 'updateApiUrl',
message: `Directus API URL is already set to "${config.directus.apiUrl}". Do you want to update it?`,
default: false
}]);
const { updateApiUrl } = await inquirer.prompt([
{
type: 'confirm',
name: 'updateApiUrl',
message: `Directus API URL is already set to "${config.directus.apiUrl}". Do you want to update it?`,
default: false
}
]);
if (updateApiUrl) {
const { apiUrl } = await inquirer.prompt([{
name: 'apiUrl',
message: 'Enter your Directus instance URL:',
validate: input => input.startsWith('http') || 'Must be a valid URL'
}]);
const { apiUrl } = await inquirer.prompt([
{
name: 'apiUrl',
message: 'Enter your Directus instance URL:',
validate: (input) => input.startsWith('http') || 'Must be a valid URL'
}
]);
config.directus.apiUrl = apiUrl;
}
} else {
const { apiUrl } = await inquirer.prompt([{
name: 'apiUrl',
message: 'Enter your Directus URL:',
validate: input => input.startsWith('http') || 'Must be a valid URL'
}]);
const { apiUrl } = await inquirer.prompt([
{
name: 'apiUrl',
message: 'Enter your Directus URL:',
validate: (input) => input.startsWith('http') || 'Must be a valid URL'
}
]);
config.directus = { ...(config.directus || {}), apiUrl };
}
@ -150,7 +166,7 @@ export const initConfig = async () => {
};
export const loadConfig = async () => {
if (!await fs.pathExists(CONFIG_PATH)) {
if (!(await fs.pathExists(CONFIG_PATH))) {
console.error('❌ Config not found. Run `coryd init` first.');
process.exit(1);
}