Skip to content

Commit

Permalink
feat: added install and prune commands
Browse files Browse the repository at this point in the history
  • Loading branch information
msudgh committed Jul 15, 2024
1 parent c47f49b commit cc0b9b9
Show file tree
Hide file tree
Showing 26 changed files with 9,176 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: test
on:
push:
branches-ignore: [main]
workflow_dispatch:

jobs:
unit-tests:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest']
node_version: [lts/-1, lts/*, latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.5.0
run_install: true
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- run: pnpm run build
- run: pnpm run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ package-lock.json
.vscode
coverage
tsconfig.tsbuildinfo
cache
11 changes: 11 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json.schemastore.org/mocharc.json",
"import": ["tsx"],
"reporter": "spec",
"timeout": 5000,
"forbidOnly": true,
"watch-files": ["src"],
"watch-extensions": ["ts"],
"ui": "bdd",
"spec": ["src/**/*.test.ts", "src/**/*.spec.ts"]
}
7 changes: 7 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"check-coverage": true,
"extensions": [".ts"],
"reporter": ["text", "html", "lcov"]
}
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@oclif/prettier-config"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Masoud Ghorbani

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
114 changes: 114 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# ovm - an Obsidian vaults manager

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/msudgh/ovm/test)

## Table of Contents

- [ovm - an Obsidian vaults manager](#ovm---an-obsidian-vaults-manager)
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Commands](#commands)
- [`ovm ip`](#ovm-ip)
- [`ovm pp`](#ovm-pp)
- [`ovm help [COMMAND]`](#ovm-help-command)
- [License](#license)

## Usage

```sh-session
$ npm install -g ovm
$ ovm version
ovm/0.1.0 darwin-x64 node-v20.11.0 # Output may vary
$ ovm COMMAND
running command...
$ ovm --help [COMMAND]
USAGE
$ ovm COMMAND
...
```

## Commands

### `ovm ip`

Install plugins for Obsidian vaults.

```
USAGE
$ ovm ip [-d] [-p <value>]
FLAGS
-d, --debug Enable debugging mode
-p, --path=<value> Path or Glob pattern of vaults to install plugins. Default: reads from Obsidian
config per environment.
DESCRIPTION
Install plugins for Obsidian vaults.
ALIASES
$ ovm ip
$ ovm install-plugins
EXAMPLES
$ ovm ip --path=/path/to/vaults
$ ovm ip --path=/path/to/vaults/*/.obsidian
$ ovm ip --path=/path/to/vaults/**/.obsidian
```

_See code: [src/commands/plugins/install.ts](src/commands/plugins/install.ts)_

### `ovm pp`

Prune plugins for Obsidian **vaults**.

```
USAGE
$ ovm pp [-d] [-p <value>]
FLAGS
-d, --debug Enable debugging mode
-p, --path=<value> Path or Glob pattern of vaults to prune plugins. Default: reads from Obsidian
config per environment.
DESCRIPTION
Prune plugins for Obsidian vaults.
ALIASES
$ ovm pp
$ ovm prune-plugins
EXAMPLES
$ ovm pp --path=/path/to/vaults
$ ovm pp --path=/path/to/vaults/*/.obsidian
$ ovm pp --path=/path/to/vaults/**/.obsidian
```

_See code: [src/commands/plugins/prune.ts](src/commands/plugins/prune.ts)_

### `ovm help [COMMAND]`

Display help for ovm commands.

```
USAGE
$ ovm help [COMMAND...] [-n]
ARGUMENTS
COMMAND... Command to show help for.
FLAGS
-n, --nested-commands Include all nested commands in the output.
DESCRIPTION
Display help for ovm.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.4/src/commands/help.ts)_

## License

This project is licensed under the [MIT License](LICENSE).
3 changes: 3 additions & 0 deletions bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\dev" %*
6 changes: 6 additions & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node_modules/.bin/ts-node
// eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await
;(async () => {
const oclif = await import('@oclif/core')
await oclif.execute({development: true, dir: __dirname})
})()
3 changes: 3 additions & 0 deletions bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
7 changes: 7 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node

// eslint-disable-next-line unicorn/prefer-top-level-await
(async () => {
const oclif = await import('@oclif/core')
await oclif.execute({dir: __dirname})
})()
34 changes: 34 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const pluginJs = require('@eslint/js')
const globals = require('globals')
const tsEslint = require('typescript-eslint')

const rulesConfig = [
{
rules: {
'no-unused-vars': 'warn',
'no-undef': 'warn',
'prefer-arrow-callback': ['error', {allowNamedFunctions: false}],
'func-style': ['error', 'expression', {allowArrowFunctions: true}],
},
},
]

const ignoresConfig = [{ignores: ['dist', 'bin']}]

module.exports = [
{files: ['**/*.{ts}', '**/*.test.ts', '**/*.spec.ts']},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.mocha,
},
},
},
pluginJs.configs.recommended,
...tsEslint.configs.recommended,
...rulesConfig,
...ignoresConfig,
]
104 changes: 104 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"name": "ovm",
"description": "An Obsidian vaults manager",
"version": "0.1.0",
"author": "Masoud Ghorbani",
"bin": {
"ovm": "./bin/run.js"
},
"bugs": "https://github.com/w/ovm/issues",
"dependencies": {
"@inquirer/core": "^9.0.2",
"@inquirer/prompts": "^5.1.2",
"@inquirer/type": "^1.4.0",
"@oclif/core": "^4.0.12",
"@oclif/plugin-help": "^6.2.6",
"@oclif/plugin-not-found": "^3.2.11",
"@oclif/plugin-plugins": "^5.3.7",
"ansi-escapes": "^7.0.0",
"async": "^3.2.5",
"glob": "^11.0.0",
"inquirer": "^10.0.1",
"node-fetch-cache": "^4.1.2",
"obsidian-utils": "^0.10.2",
"winston": "^3.13.1",
"yoctocolors-cjs": "^2.1.2",
"zod": "^3.23.8"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@oclif/prettier-config": "^0.2.1",
"@oclif/test": "^4.0.4",
"@total-typescript/ts-reset": "^0.5.1",
"@types/async": "^3.2.24",
"@types/chai": "^4.3.16",
"@types/inquirer": "^9.0.7",
"@types/mocha": "^10.0.7",
"@types/mock-fs": "^4.13.4",
"@types/node": "^20.14.10",
"@types/sinon": "^17.0.3",
"@types/validator": "^13.12.0",
"chai": "^5.1.1",
"eslint": "^9.7.0",
"eslint-config-oclif": "^5.2.0",
"eslint-config-oclif-typescript": "^3.1.8",
"eslint-config-prettier": "^9.1.0",
"globals": "^15.8.0",
"mocha": "^10.6.0",
"mock-fs": "^5.2.0",
"nyc": "^17.0.0",
"obsidian": "1.6.6",
"oclif": "^4.14.5",
"prettier": "^3.3.3",
"shx": "^0.3.4",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",
"tsx": "^4.16.2",
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.1"
},
"engines": {
"node": ">=18.0.0"
},
"files": [
"/bin",
"/dist",
"/oclif.manifest.json"
],
"homepage": "https://github.com/msudgh/ovm",
"keywords": [
"oclif"
],
"license": "MIT",
"main": "dist/index.js",
"oclif": {
"bin": "ovm",
"dirname": "ovm",
"commands": "./dist/commands",
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-plugins",
"@oclif/plugin-not-found"
],
"topicSeparator": " ",
"topics": {
"plugins": {
"description": "Manage plugins for Obsidian vaults"
}
}
},
"repository": "https://github.com/musdgh/ovm",
"scripts": {
"build": "shx rm -rf dist && tsc -b",
"build:watch": "shx rm -rf dist && tsc -b -w",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write \"**/*.{ts,json}\"",
"postpack": "shx rm -f oclif.manifest.json",
"posttest": "pnpm run lint",
"prepack": "oclif manifest && oclif readme",
"test": "mocha",
"coverage": "nyc --reporter=lcov npm run test"
},
"types": "dist/index.d.ts"
}
Loading

0 comments on commit cc0b9b9

Please sign in to comment.