diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 040b72b..9863a25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,13 @@ jobs: unit-tests: strategy: matrix: - os: ['ubuntu-latest', 'windows-latest'] - node_version: [lts/*] + os: + - 'ubuntu-latest' + - 'windows-latest' + - 'macos-latest' + node_version: + - '>=18.0.0' + - 'lts/*' fail-fast: false runs-on: ${{ matrix.os }} steps: diff --git a/README.md b/README.md index e847c7a..27017ae 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ ovm (Obsidian Vaults Manager) is a CLI application designed to streamline the ma ## Features - **Manage Obsidian plugins**: Install/Uninstall/Prune plugins in multiple vaults at one go. +- **Perform actions on Obsidian or custom vaults**: By default, Obsidian vaults are supported and detected. The vaults related commands support `-p` flag to define a custom vault/s from a path or [`Glob`]() pattern. e.g. `~/Documents/obsidian/*`. - **Generate reports**: Generate stats of vaults and installed plugins with Table/JSON format. - **Interactive CLI**: User-friendly interface to select vaults and plugins for each command. - **Cross-platform**: Windows, macOS, and Linux. @@ -43,6 +44,14 @@ USAGE ... ``` +**Common flags** + +```bash + -c, --config= [default: ~/ovm.json] Path to the config file. + -d, --debug Enable debugging mode. + -t, --timestamp Enable timestamp in logs. +``` + ## Config file The config file is created in the user's home directory and is named `ovm.json` by [`ovm ci`](#ovm-config-init--ovm-ci). It contains an array of plugins that are to be installed across single/multiple vault. @@ -141,7 +150,7 @@ info: Pruned 1 plugins {"vault":{"name":"Test","path":"~/Documents/obsidian/Test ### `ovm plugins uninstall` / `ovm pu` -Uninstall plugins from specified vaults. +Uninstall plugin/s from vaults. - _Usage:_ `ovm help plugins uninstall` - _See code:_ [src/commands/plugins/uninstall.ts](src/commands/plugins/uninstall.ts) diff --git a/package.json b/package.json index 6dc95b2..7fec078 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ovm", "description": "Obsidian Vaults Manager", "type": "commonjs", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "author": "Masoud Ghorbani", "homepage": "https://github.com/msudgh/ovm", diff --git a/src/commands/plugins/install.ts b/src/commands/plugins/install.ts index 3542853..97c87d9 100644 --- a/src/commands/plugins/install.ts +++ b/src/commands/plugins/install.ts @@ -13,6 +13,7 @@ import { } from '../../providers/github' import { modifyCommunityPlugins } from '../../services/plugins' import { vaultsSelector } from '../../services/vaults' +import { VAULTS_PATH_FLAG_DESCRIPTION } from '../../utils/constants' import { PluginNotFoundInRegistryError } from '../../utils/errors' import { logger } from '../../utils/logger' @@ -45,8 +46,7 @@ export default class Install extends FactoryCommand { static override readonly flags = { path: Flags.string({ char: 'p', - description: - 'Path or Glob pattern of vaults to install plugins. (default: detects vaults from Obsidian configuration)', + description: VAULTS_PATH_FLAG_DESCRIPTION, default: '', }), enable: Flags.boolean({ diff --git a/src/commands/plugins/prune.ts b/src/commands/plugins/prune.ts index 7818c72..4587e92 100644 --- a/src/commands/plugins/prune.ts +++ b/src/commands/plugins/prune.ts @@ -6,6 +6,7 @@ import FactoryCommand, { FactoryFlags } from '../../providers/command' import { Config, safeLoadConfig } from '../../providers/config' import { listInstalledPlugins, removePluginDir } from '../../services/plugins' import { vaultsSelector } from '../../services/vaults' +import { VAULTS_PATH_FLAG_DESCRIPTION } from '../../utils/constants' import { logger } from '../../utils/logger' interface PruneFlags { @@ -31,8 +32,7 @@ export default class Prune extends FactoryCommand { static override readonly flags = { path: Flags.string({ char: 'p', - description: - 'Path or Glob pattern of vaults to prune plugins. Default: reads from Obsidian config per environment.', + description: VAULTS_PATH_FLAG_DESCRIPTION, default: '', }), ...this.commonFlags, diff --git a/src/commands/plugins/uninstall.ts b/src/commands/plugins/uninstall.ts index 68df286..0efe8c8 100644 --- a/src/commands/plugins/uninstall.ts +++ b/src/commands/plugins/uninstall.ts @@ -5,6 +5,7 @@ import FactoryCommand, { FactoryFlags } from '../../providers/command' import { Config, Plugin, safeLoadConfig } from '../../providers/config' import { pluginsSelector, removePluginDir } from '../../services/plugins' import { vaultsSelector } from '../../services/vaults' +import { VAULTS_PATH_FLAG_DESCRIPTION } from '../../utils/constants' import { logger } from '../../utils/logger' interface UninstallArgs { @@ -25,7 +26,7 @@ interface UninstallPluginVaultOpts { */ export default class Uninstall extends FactoryCommand { static readonly aliases = ['pu', 'plugins:uninstall'] - static override readonly description = `Uninstall plugin/s from specified vaults.` + static override readonly description = `Uninstall plugin/s from vaults.` static override readonly examples = [ '<%= config.bin %> <%= command.id %> --path=/path/to/vaults', '<%= config.bin %> <%= command.id %> --path=/path/to/vaults/*/.obsidian', @@ -35,8 +36,7 @@ export default class Uninstall extends FactoryCommand { static override readonly flags = { path: Flags.string({ char: 'p', - description: - 'Path or Glob pattern of vaults to uninstall plugins. Default: reads from Obsidian config per environment.', + description: VAULTS_PATH_FLAG_DESCRIPTION, default: '', }), ...this.commonFlags, diff --git a/src/commands/reports/stats.ts b/src/commands/reports/stats.ts index 73d10ca..da9ec28 100644 --- a/src/commands/reports/stats.ts +++ b/src/commands/reports/stats.ts @@ -16,6 +16,7 @@ import FactoryCommand, { FactoryFlags } from '../../providers/command' import { Config, safeLoadConfig } from '../../providers/config' import { InstalledPlugins } from '../../services/plugins' import { vaultsSelector } from '../../services/vaults' +import { VAULTS_PATH_FLAG_DESCRIPTION } from '../../utils/constants' import { logger } from '../../utils/logger' interface StatsFlags { path: string @@ -33,8 +34,7 @@ export default class Stats extends FactoryCommand { static override readonly flags = { path: Flags.string({ char: 'p', - description: - 'Path or Glob pattern of vaults to get stats from. Default: reads from Obsidian per vault config per environment.', + description: VAULTS_PATH_FLAG_DESCRIPTION, default: '', }), output: Flags.string({ diff --git a/src/index.ts b/src/index.ts index 1d09b9b..98ca260 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,6 @@ export { run } from '@oclif/core' +export * from './commands/config/init' export * from './commands/plugins/install' export * from './commands/plugins/prune' export * from './commands/plugins/uninstall' +export * from './commands/reports/stats' diff --git a/src/providers/command.ts b/src/providers/command.ts index 2b71de6..6edca61 100644 --- a/src/providers/command.ts +++ b/src/providers/command.ts @@ -1,11 +1,11 @@ import { ExitPromptError } from '@inquirer/core' import { Command, Flags, handle } from '@oclif/core' import { Vault } from 'obsidian-utils' -import { DEFAULT_CONFIG_PATH } from '../constants' import { findVaultsByPatternMatching, findVaultsFromConfig, } from '../services/vaults' +import { DEFAULT_CONFIG_PATH } from '../utils/constants' import { logger } from '../utils/logger' export type CommonFlags = { @@ -21,16 +21,16 @@ export default class FactoryCommand extends Command { debug: Flags.boolean({ char: 'd', default: false, - description: 'Enable debugging mode', + description: 'Enable debugging mode.', }), timestamp: Flags.boolean({ char: 't', default: false, - description: 'Enable timestamp in logs', + description: 'Enable timestamp in logs.', }), config: Flags.file({ char: 'c', - description: `Path to the configuration file. (default: ${DEFAULT_CONFIG_PATH})`, + description: `Path to the config file.`, default: DEFAULT_CONFIG_PATH, required: false, }), diff --git a/src/providers/config.test.ts b/src/providers/config.test.ts index 458249f..6bcbc38 100644 --- a/src/providers/config.test.ts +++ b/src/providers/config.test.ts @@ -2,7 +2,7 @@ import { ConfigSchema, safeLoadConfig } from './config' import { expect } from 'chai' import mock from 'mock-fs' -import { OVM_CONFIG_FILENAME } from '../constants' +import { OVM_CONFIG_FILENAME } from '../utils/constants' describe('Config', () => { it("should load config from user's home dir", async () => { diff --git a/src/constants.ts b/src/utils/constants.ts similarity index 56% rename from src/constants.ts rename to src/utils/constants.ts index e6ee9d1..10f07f8 100644 --- a/src/constants.ts +++ b/src/utils/constants.ts @@ -3,3 +3,5 @@ import path from 'path' export const OVM_CONFIG_FILENAME = 'ovm.json' export const DEFAULT_CONFIG_PATH = path.join(homedir(), OVM_CONFIG_FILENAME) +export const VAULTS_PATH_FLAG_DESCRIPTION = + '[default: detect from Obsidian config] Path or Glob pattern of vaults to install plugins.'