forked from ourongxing/ohmymn
-
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
Showing
215 changed files
with
13,904 additions
and
6,626 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,4 @@ | ||
node_modules | ||
dist | ||
pnpm-lock.yaml | ||
test |
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,34 @@ | ||
module.exports = { | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
ignorePatterns: "*.d.ts", | ||
extends: [ | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
rules: { | ||
"prettier/prettier": "off", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/naming-convention": [ | ||
"warn", | ||
{ | ||
selector: "variable", | ||
format: ["camelCase", "UPPER_CASE", "PascalCase"], | ||
leadingUnderscore: "allow", | ||
trailingUnderscore: "allow" | ||
}, | ||
{ | ||
selector: "typeLike", | ||
format: ["PascalCase"] | ||
} | ||
], | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-unused-vars": "off" | ||
}, | ||
env: { | ||
browser: true, | ||
node: true | ||
} | ||
} |
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
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
pnpm commitlint --edit "$1" |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
pnpm lint-staged --allow-empty "$1" |
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Diff not rendered.
Diff not rendered.
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,91 @@ | ||
import { build } from "@ourongxing/estrella" | ||
import { Plugin } from "esbuild" | ||
import mnaddon from "./mnaddon.json" | ||
import copy from "esbuild-plugin-mxn-copy" | ||
import autoImport from "unplugin-auto-import/esbuild" | ||
import { homedir } from "os" | ||
import fs from "fs" | ||
import { exec } from "child_process" | ||
|
||
const isProd = process.env.NODE_ENV === "production" | ||
|
||
const bannerText = `/* | ||
THIS IS A GENERATED/BUNDLED FILE BY ESBuild | ||
if you want to view the source code, please visit the github repository | ||
https://github.com/marginnoteapp/ohmymn | ||
version: ${mnaddon.version} by ${mnaddon.author} | ||
welcome to contribute to this project! | ||
*/ | ||
` | ||
|
||
const outDir = isProd | ||
? "./dist/" | ||
: homedir() + | ||
`/Library/Containers/QReader.MarginStudyMac/Data/Library/MarginNote Extensions/${mnaddon.addonid}/` | ||
|
||
function clear(): Plugin { | ||
return { | ||
name: "Clear", | ||
setup(build) { | ||
build.onStart(() => { | ||
if (fs.existsSync(outDir)) { | ||
fs.rmSync(outDir, { recursive: true }) | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
|
||
function zip(): Plugin { | ||
return { | ||
name: "Zip", | ||
setup(build) { | ||
build.onEnd(() => { | ||
const fileName = `${mnaddon.addonid.split(".")[2]} v${ | ||
mnaddon.version | ||
}`.replace(/[ .]/g, "_") | ||
exec(`cd ${outDir} && zip -qr ${fileName}.mnaddon *`) | ||
}) | ||
} | ||
} | ||
} | ||
|
||
build({ | ||
entry: "src/main.ts", | ||
tslint: !isProd, | ||
outfile: outDir + "main.js", | ||
splitting: false, | ||
sourcemap: false, | ||
clear: true, | ||
watch: !isProd, | ||
minify: isProd, | ||
banner: { | ||
js: bannerText | ||
}, | ||
pure: ["console.log", "console.error", "console.assert", "console.warn"], | ||
bundle: true, | ||
plugins: [ | ||
clear(), | ||
autoImport({ | ||
imports: [ | ||
{ | ||
"~/utils/common": [isProd ? "" : "console"] | ||
} | ||
], | ||
dts: false | ||
}), | ||
copy({ | ||
copy: [ | ||
"assets/logo.png", | ||
"mnaddon.json", | ||
"assets/icon" | ||
// "assets/dict.db", | ||
// "assets/dict.zip" | ||
].map(k => ({ | ||
from: k, | ||
to: outDir | ||
})) | ||
}), | ||
zip() | ||
] | ||
}) |
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,23 @@ | ||
module.exports = { | ||
extends: ["@commitlint/config-conventional"], | ||
rules: { | ||
"type-enum": [ | ||
2, | ||
"always", | ||
[ | ||
"feat", // 新功能 | ||
"improve", // 改进 | ||
"style", // 格式(不影响代码运行的变动) | ||
"refactor", // 重构(即不是新增功能,也不是修改 bug 的代码变动) | ||
"perf", // 提高性能 | ||
"fix", // 修补 bug | ||
"docs", // 文档 | ||
"note", // 注释或其他文字 | ||
"test", // 增加测试 | ||
"chore", // 构建过程或辅助工具的变动 | ||
"release", // 发布新版本 | ||
"preview" // 预览版本,测试版本 | ||
] | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"addonid": "marginnote.extension.ohmymn", | ||
"author": "ourongxing", | ||
"author": "ourongxing|MN", | ||
"title": "OhMyMN", | ||
"version": "3.2.1", | ||
"marginnote_version_min": "3.7.10", | ||
"version": "4.0.0", | ||
"marginnote_version_min": "3.7.18", | ||
"cert_key": "" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,39 +1,47 @@ | ||
{ | ||
"name": "ohmymn", | ||
"author": "ourongxing", | ||
"version": "3.2.1", | ||
"author": "MarginNote<https://github.com/marginnoteapp>", | ||
"version": "4.0.0", | ||
"license": "MIT", | ||
"description": "Maybe the most powerful addon of Marginnote3", | ||
"main": "", | ||
"description": "MarginNote Addon Control Panel and Development Framework", | ||
"scripts": { | ||
"build": "rm -rf ./dist && NODE_ENV=production rollup --config rollup.config.ts && cd ./dist && zip -qrm \"${npm_package_name}_v$npm_package_version.mnaddon\" *", | ||
"dev": "NODE_ENV=development rollup -w --config rollup.config.ts", | ||
"prettify": "prettier --write \"./**/*.{ts, json}\"" | ||
"dev": "tsx ./build.ts", | ||
"build": "NODE_ENV=production pnpm dev", | ||
"build:iPad": "pnpm build && airdrop ./dist/*.mnaddon", | ||
"lint:fix": "eslint . --fix --ext .ts", | ||
"lint": "eslint . --ext .ts", | ||
"prettier": "prettier --write .", | ||
"prepare": "husky install" | ||
}, | ||
"lint-staged": { | ||
"src/**/*.{js,jsx,ts,tsx,json}": [ | ||
"prettier --write", | ||
"eslint --cache --fix", | ||
"git add" | ||
] | ||
}, | ||
"keywords": [ | ||
"marginote", | ||
"addon", | ||
"typescript" | ||
], | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^21.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.0.5", | ||
"@rollup/plugin-strip": "^2.1.0", | ||
"@rollup/plugin-typescript": "^8.2.0", | ||
"@types/bluebird": "^3.5.36", | ||
"@types/node": "^17.0.8", | ||
"esbuild": "^0.14.8", | ||
"prettier": "^2.4.1", | ||
"rollup": "^2.42.4", | ||
"rollup-plugin-banner": "^0.2.1", | ||
"rollup-plugin-copy": "^3.4.0", | ||
"rollup-plugin-esbuild": "^4.8.1", | ||
"rollup-plugin-ts-paths": "^1.0.5", | ||
"rollup-plugin-typescript2": "^0.31.1", | ||
"ts-toolbelt": "^9.6.0", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.5.4", | ||
"unplugin-auto-import": "^0.5.5" | ||
"@commitlint/cli": "^17.0.3", | ||
"@commitlint/config-conventional": "^17.0.3", | ||
"@ourongxing/estrella": "^1.4.1", | ||
"@types/node": "^18.6.1", | ||
"@typescript-eslint/eslint-plugin": "^5.31.0", | ||
"@typescript-eslint/parser": "^5.31.0", | ||
"esbuild": "^0.14.50", | ||
"esbuild-plugin-mxn-copy": "^1.0.1", | ||
"eslint": "^8.20.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"husky": "^8.0.1", | ||
"lint-staged": "^13.0.3", | ||
"prettier": "^2.7.1", | ||
"tsx": "^3.8.0", | ||
"typescript": "^4.7.4", | ||
"unplugin-auto-import": "^0.10.1" | ||
} | ||
} | ||
} |
Oops, something went wrong.