-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6183314
Showing
25 changed files
with
30,485 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# vscode | ||
.vscode | ||
|
||
# Intellij | ||
*.iml | ||
.idea | ||
|
||
# npm | ||
node_modules | ||
|
||
# Don't include the compiled main.js file in the repo. | ||
# They should be uploaded to GitHub releases instead. | ||
main.js | ||
|
||
# Exclude sourcemaps | ||
*.map | ||
|
||
# obsidian | ||
data.json | ||
|
||
# Exclude macOS Finder (System Explorer) View States | ||
.DS_Store | ||
|
||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 ibelyalov | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Belyalov Commander | ||
|
||
This is a plugin for [Obsidian](https://obsidian.md/) that note preview and management. | ||
|
||
## Installation | ||
|
||
- `Belyalov Commander` is not available on [the official Community Plugins repository](https://obsidian.md/plugins) yet. | ||
- Beta releases can be installed through [BRAT](https://github.com/TfTHacker/obsidian42-brat) | ||
|
||
## License | ||
|
||
© [ibelyalov](https://github.com/theotheo/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import esbuild from "esbuild"; | ||
import process from "process"; | ||
import builtins from "builtin-modules"; | ||
import { existsSync, renameSync } from "fs"; | ||
import { | ||
cp, | ||
mkdir, | ||
readFile, | ||
rm | ||
} from "fs/promises"; | ||
|
||
interface NpmPackage { | ||
name: string; | ||
} | ||
|
||
|
||
|
||
const banner = | ||
`/* | ||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD | ||
if you want to view the source, please visit the github repository of this plugin | ||
*/ | ||
`; | ||
|
||
const isProductionBuild = (process.argv[2] === "production"); | ||
|
||
const distDir = isProductionBuild ? "dist/build" : "dist/dev"; | ||
if (existsSync(distDir)) { | ||
await rm(distDir, { recursive: true }); | ||
} | ||
await mkdir(distDir, { recursive: true }); | ||
|
||
const distFileNames = ["manifest.json", "styles.css"]; | ||
if (!isProductionBuild) { | ||
distFileNames.push(".hotreload"); | ||
} | ||
|
||
const renamePlugin = () => ({ | ||
name: 'rename-plugin', | ||
setup(build: any) { | ||
build.onEnd(async () => { | ||
try { | ||
renameSync(`${distDir}/main.css`, `${distDir}/styles.css`); | ||
} catch (e) { | ||
console.error('Failed to rename file:', e); | ||
} | ||
}); | ||
}, | ||
}); | ||
|
||
for (const fileName of distFileNames) { | ||
const localFile = `./${fileName}`; | ||
const distFile = `${distDir}/${fileName}`; | ||
|
||
if (existsSync(localFile)) { | ||
await cp(localFile, distFile); | ||
} | ||
} | ||
|
||
const context = await esbuild.context({ | ||
banner: { | ||
js: banner, | ||
}, | ||
entryPoints: ["src/BelyalovCommanderPlugin.ts"], | ||
bundle: true, | ||
external: [ | ||
"obsidian", | ||
"electron", | ||
"@codemirror/autocomplete", | ||
"@codemirror/collab", | ||
"@codemirror/commands", | ||
"@codemirror/language", | ||
"@codemirror/lint", | ||
"@codemirror/search", | ||
"@codemirror/state", | ||
"@codemirror/view", | ||
"@lezer/common", | ||
"@lezer/highlight", | ||
"@lezer/lr", | ||
...builtins], | ||
format: "cjs", | ||
target: "es2018", | ||
logLevel: "info", | ||
sourcemap: isProductionBuild ? false : "inline", | ||
treeShaking: true, | ||
outfile: `${distDir}/main.js`, | ||
plugins: [ | ||
renamePlugin(), | ||
{ | ||
name: "copy-to-obsidian-plugins-folder", | ||
setup: (build): void => { | ||
build.onEnd(async () => { | ||
if (isProductionBuild || !process.env["OBSIDIAN_CONFIG_DIR"]) { | ||
return; | ||
} | ||
|
||
const npmPackage = JSON.parse(await readFile("./package.json", "utf8")) as NpmPackage; | ||
const pluginName = npmPackage.name; | ||
const pluginDir = `${process.env["OBSIDIAN_CONFIG_DIR"]}/plugins/${pluginName}`; | ||
if (!existsSync(pluginDir)) { | ||
await mkdir(pluginDir); | ||
} | ||
|
||
await cp(distDir, pluginDir, { recursive: true }); | ||
}); | ||
} | ||
} | ||
] | ||
}); | ||
|
||
if (isProductionBuild) { | ||
await context.rebuild(); | ||
process.exit(0); | ||
} else { | ||
await context.watch(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
declare module "@typescript-eslint/eslint-plugin" { | ||
import type { | ||
ESLint, | ||
Linter | ||
} from "eslint"; | ||
|
||
type Config = { | ||
overrides: Config[]; | ||
rules: Linter.RulesRecord; | ||
} | ||
|
||
const plugin: ESLint.Plugin & { | ||
configs: Record<string, Config> | ||
}; | ||
export default plugin; | ||
} | ||
|
||
declare module "eslint-plugin-import" { | ||
} | ||
|
||
declare module "eslint-plugin-modules-newlines" { | ||
} | ||
|
||
declare module "globals" { | ||
const globals: { | ||
browser: object; | ||
node: object; | ||
}; | ||
export default globals; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// eslint-disable-next-line import/no-namespace | ||
import * as typescriptEslintParser from "@typescript-eslint/parser"; | ||
// eslint-disable-next-line import/no-namespace | ||
import * as eslintPluginImport from "eslint-plugin-import"; | ||
|
||
import typescriptEslintPlugin from "@typescript-eslint/eslint-plugin"; | ||
import stylisticEslintPlugin from "@stylistic/eslint-plugin"; | ||
import eslintPluginModulesNewlines from "eslint-plugin-modules-newlines"; | ||
import globals from "globals"; | ||
import "eslint-import-resolver-typescript"; | ||
import type { | ||
ESLint, | ||
Linter | ||
} from "eslint"; | ||
|
||
const configs: Linter.FlatConfig[] = [ | ||
{ | ||
files: ["**/*.ts"], | ||
ignores: ["dist/**"], | ||
languageOptions: { | ||
parser: typescriptEslintParser as Linter.ParserModule, | ||
sourceType: "module", | ||
globals: { | ||
...globals.browser, | ||
...globals.node | ||
}, | ||
parserOptions: { | ||
project: "./tsconfig.json" | ||
} | ||
}, | ||
plugins: { | ||
"@typescript-eslint": typescriptEslintPlugin, | ||
"import": eslintPluginImport, | ||
"modules-newlines": eslintPluginModulesNewlines, | ||
"@stylistic": stylisticEslintPlugin as ESLint.Plugin | ||
}, | ||
rules: { | ||
...typescriptEslintPlugin.configs["eslint-recommended"]!.overrides[0]!.rules, | ||
...typescriptEslintPlugin.configs["recommended"]!.rules, | ||
...typescriptEslintPlugin.configs["recommended-type-checked"]!.rules, | ||
"import/no-unresolved": "error", | ||
"import/no-namespace": "error", | ||
"modules-newlines/import-declaration-newline": "error", | ||
"modules-newlines/export-declaration-newline": "error", | ||
"@typescript-eslint/explicit-function-return-type": "error", | ||
"@stylistic/indent": ["error", 2], | ||
"@stylistic/quotes": ["error", "double"], | ||
semi: "error", | ||
"no-extra-semi": "error", | ||
"@typescript-eslint/explicit-member-accessibility": "error" | ||
}, | ||
settings: { | ||
"import/resolver": { | ||
typescript: { | ||
alwaysTryTypes: true | ||
} | ||
} | ||
} | ||
} | ||
]; | ||
|
||
export default configs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id": "belyalov-commander", | ||
"name": "Belyalov Commander", | ||
"version": "0.1.0", | ||
"minAppVersion": "0.15.0", | ||
"description": "Note preview and management", | ||
"author": "theotheo", | ||
"authorUrl": "https://github.com/theotheo/", | ||
"isDesktopOnly": false | ||
} |
Oops, something went wrong.