diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3babb08..a1993b7 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,35 +1,4 @@ module.exports = { - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:vue/vue3-recommended", - "turbo", - "prettier", - ], - - // https://eslint.vuejs.org/user-guide/#how-to-use-a-custom-parser - parser: "vue-eslint-parser", - parserOptions: { - parser: "@typescript-eslint/parser", - }, - - plugins: ["@typescript-eslint", "vue", "prettier"], - - rules: { - // Note: you must disable the base rule as it can report incorrect errors - semi: "off", - quotes: "off", - "no-undef": "off", - "vue/require-default-prop": "off", - "vue/no-deprecated-slot-attribute": "off", - "vue/component-definition-name-casing": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/no-this-alias": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unused-vars": "off", - "@typescript-eslint/no-explicit-any": "off", - "turbo/no-undeclared-env-vars": "off", - "prettier/prettier": "error", - }, + root: true, + extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"], } diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 96b767d..5f9e945 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -19,6 +19,82 @@ updates: - "npm dependencies" - "npm" + - package-ecosystem: npm + directory: "/libs/zhi-picgo-core" + schedule: + interval: daily + time: "00:00" + open-pull-requests-limit: 10 + reviewers: + - terwer + assignees: + - terwer + commit-message: + prefix: fix + prefix-development: chore + include: scope + labels: + - "npm dependencies" + - "npm" + - "picgo-core" + + - package-ecosystem: npm + directory: "/libs/zhi-picgo-siyuan" + schedule: + interval: daily + time: "00:00" + open-pull-requests-limit: 10 + reviewers: + - terwer + assignees: + - terwer + commit-message: + prefix: fix + prefix-development: chore + include: scope + labels: + - "npm dependencies" + - "npm" + - "picgo-siyuan" + + - package-ecosystem: npm + directory: "/packages/picgo-plugin-bootstrap" + schedule: + interval: daily + time: "00:00" + open-pull-requests-limit: 10 + reviewers: + - terwer + assignees: + - terwer + commit-message: + prefix: fix + prefix-development: chore + include: scope + labels: + - "npm dependencies" + - "npm" + - "bootstrap" + + - package-ecosystem: npm + directory: "/packages/picgo-plugin-app" + schedule: + interval: daily + time: "00:00" + open-pull-requests-limit: 10 + reviewers: + - terwer + assignees: + - terwer + commit-message: + prefix: fix + prefix-development: chore + include: scope + labels: + - "npm dependencies" + - "npm" + - "app" + # Fetch and update latest `github-actions` pkgs - package-ecosystem: github-actions directory: "/" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72712f1..78dc439 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: fetch-depth: 2 @@ -30,8 +30,8 @@ jobs: - name: Install dependencies run: pnpm install - - name: Build - run: pnpm build + - name: Prepare release + run: pnpm prepareRelease - name: Package run: pnpm package diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 2c5a166..b7661ac 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -10,94 +10,82 @@ jobs: steps: # Create release - name: Create release - uses: google-github-actions/release-please-action@v3 + uses: google-github-actions/release-please-action@v4 id: release with: - release-type: node - package-name: release-please-action - ## branch to open pull release PR against (detected by default) - default-branch: main - ## Should breaking changes before 1.0.0 produce minor bumps? Default false - bump-minor-pre-major: false - ## Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? Default false - bump-patch-for-minor-pre-major: false - ## If set, create releases that are pre-major or pre-release version marked as pre-release on GitHub. Defaults false - prerelease: false - ## header used within the release PR body, defaults to using :robot: I have created a release *beep* *boop* - pull-request-header: ':robot: A new release will be created' - ## A JSON formatted String containing to override the outputted changelog sections - changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Code Refactoring","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"perf","section":"Performance Improvements","hidden":false}]' + # this assumes that you have created a personal access token + # (PAT) and configured it as a GitHub action secret named + # `GH_TOKEN` (this secret name is not important). + token: ${{ secrets.GH_TOKEN }} + # optional. customize path to release-please-config.json + config-file: release-please-config.json + # optional. customize path to .release-please-manifest.json + manifest-file: .release-please-manifest.json # Checkout - name: Checkout + uses: actions/checkout@v3 if: ${{ steps.release.outputs.release_created }} - uses: actions/checkout@v4 # Install Node.js - name: Install Node.js - if: ${{ steps.release.outputs.release_created }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 registry-url: 'https://registry.npmjs.org' + if: ${{ steps.release.outputs.release_created }} # Install pnpm - name: Install pnpm - if: ${{ steps.release.outputs.release_created }} - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v3 id: pnpm-install with: version: 8 run_install: false + if: ${{ steps.release.outputs.release_created }} # Get pnpm store directory - name: Get pnpm store directory - if: ${{ steps.release.outputs.release_created }} id: pnpm-cache shell: bash run: | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + if: ${{ steps.release.outputs.release_created }} # Setup pnpm cache - name: Setup pnpm cache - if: ${{ steps.release.outputs.release_created }} - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- + if: ${{ steps.release.outputs.release_created }} # Install dependencies - name: Install dependencies - if: ${{ steps.release.outputs.release_created }} run: pnpm install + if: ${{ steps.release.outputs.release_created }} # Prepare new version # https://github.com/google-github-actions/release-please-action#outputs - name: Prepare new version - if: ${{ steps.release.outputs.release_created }} run: | pnpm prepareRelease - - # Build for production - - name: Build for production if: ${{ steps.release.outputs.release_created }} - run: pnpm build - # Archive package - - name: Archive package - if: ${{ steps.release.outputs.release_created }} + # Build for production and Archive package + - name: Build for production run: pnpm package + if: ${{ steps.release.outputs.release_created }} # Upload package to release # https://github.com/philips-labs/terraform-aws-github-runner/blob/main/.github/workflows/release.yml#L46 - name: Upload package.zip to the release - if: ${{ steps.release.outputs.releases_created }} env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} run: | - ls -l ./build for f in $(find ./build -name '*.zip'); do gh release upload ${{ steps.release.outputs.tag_name }} $f - done \ No newline at end of file + done + if: ${{ steps.release.outputs.releases_created }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0f73cc1..bda17ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,28 +1,42 @@ -# Logs -logs -*.log +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +node_modules +.pnp +.pnp.js + +# testing +coverage + +# next.js +.next/ +out/ +build + +# misc +.DS_Store +*.pem + +# debug npm-debug.log* yarn-debug.log* yarn-error.log* -pnpm-debug.log* -lerna-debug.log* -node_modules -dist -dist-ssr -*.local -build -lib -__pycache__ +# local env files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# turbo +.turbo -# Editor directories and files -.vscode/* -!.vscode/extensions.json +# vercel +.vercel + +# IDE .idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? -coverage +artifacts +cookie.txt +token.txt \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..0e74e44 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +auto-install-peers=true +shamefully-hoist=true \ No newline at end of file diff --git a/.prettierrc.cjs b/.prettierrc.cjs index c5f0468..eec8622 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -24,7 +24,7 @@ */ module.exports = { - semi: false, - singleQuote: false, - printWidth: 120, + semi: false, + singleQuote: false, + printWidth: 120 } diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..4a2f7e6 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.5.1" +} \ No newline at end of file diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..83fd353 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,35 @@ +# Development + +## Prerequisites + +```bash +pnpm install +``` + +## Development + +serve + +```bash +pnpm serve -F picgo-plugin-app +``` + +dev + +```bash +pnpm dev -F picgo-plugin-app +pnpm dev -F picgo-plugin-bootstrap +``` + +## Build + +```bash +pnpm package +``` + +artifacts structure + +``` +├── build + ├── package.zip +``` \ No newline at end of file diff --git a/README.md b/README.md index c469a68..d0576aa 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ Your favorite PicGo image bed and PicGo plugins are still available in siyuan-notes, wuhu~ -> Important Note: -> -> Please refrain from updating this plugin for versions of siyuan-note prior to `2.10.8`. The maximum compatible version is `1.4.5`. +> Important Note: > -> For versions `2.10.8` and later, you can upgrade to the latest PicGO plugin. +> Please refrain from updating this plugin for versions of siyuan-note prior to `3.0.3`; the highest permissible version remains `1.5.1`. For siyuan-note versions `3.0.3` and beyond, the PicGO plugin may be upgraded to `1.6.0+`. +> +> For versions of siyuan-note before `2.10.8`, it is advised not to upgrade this plugin beyond version `1.4.5`. Subsequent to siyuan-note `2.10.8`, the PicGO plugin can be updated to `1.5.0+`. ## Changelog @@ -42,4 +42,5 @@ If you approve of this project, invite me to have a cup of coffee, which will en Thanks to the solutions provided by the open source community, which simplifies a lot of work for this project! -- [PicGo-Core](https://github.com/PicGo/PicGo-Core) \ No newline at end of file +- [PicGo-Core](https://github.com/PicGo/PicGo-Core) +- [PicList](https://github.com/Kuingsmile/PicList) \ No newline at end of file diff --git a/README_zh_CN.md b/README_zh_CN.md index f448fbd..0116739 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -8,9 +8,9 @@ > 重要提示: > -> 思源笔记 `2.10.8` 之前的版本请不要升级本插件,最高只能使用使用 `1.4.5` 版本。 +> 思源笔记 `3.0.3` 之前的版本请不要升级本插件,最高只能使用使用 `1.5.1` 版本。 思源笔记 `3.0.3` 之后的版本可升级 PicGO 插件到 `1.6.0+` 。 > -> 思源笔记 `2.10.8` 之后的版本可升级 PicGO 插件到 `1.5.0+` 。 +> 思源笔记 `2.10.8` 之前的版本请不要升级本插件,最高只能使用使用 `1.4.5` 版本。 思源笔记 `2.10.8` 之后的版本可升级 PicGO 插件到 `1.5.0+` 。 ## 更新历史 @@ -42,4 +42,5 @@ 感谢来自开源社区提供的解决方案,简化了本项目的不少工作! -- [PicGo-Core](https://github.com/PicGo/PicGo-Core) \ No newline at end of file +- [PicGo-Core](https://github.com/PicGo/PicGo-Core) +- [PicList](https://github.com/Kuingsmile/PicList) \ No newline at end of file diff --git a/auto-imports.d.ts b/auto-imports.d.ts deleted file mode 100644 index 78813d8..0000000 --- a/auto-imports.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* eslint-disable */ -/* prettier-ignore */ -// @ts-nocheck -// noinspection JSUnusedGlobalSymbols -// Generated by unplugin-auto-import -export {} -declare global { - const ElMessage: typeof import('element-plus/es')['ElMessage'] -} diff --git a/commitlint.config.cjs b/commitlint.config.cjs new file mode 100644 index 0000000..8f9e2c8 --- /dev/null +++ b/commitlint.config.cjs @@ -0,0 +1,110 @@ +module.exports = { + extends: ["@commitlint/config-angular"], + rules: { + "type-enum": [2, "always", ["feat", "fix", "refactor", "perf", "revert", "chore", "docs"]], + }, + prompt: { + settings: {}, + messages: { + skip: ":skip", + max: "upper %d chars", + min: "%d chars at least", + emptyWarning: "can not be empty", + upperLimitWarning: "over limit", + lowerLimitWarning: "below limit", + }, + questions: { + type: { + description: "Select the type of change that you're committing:", + enum: { + feat: { + description: "A new feature", + title: "Features", + emoji: "✨", + }, + fix: { + description: "A bug fix", + title: "Bug Fixes", + emoji: "🐛", + }, + refactor: { + description: "A code change that neither fixes a bug nor adds a feature", + title: "Code Refactoring", + emoji: "📦", + }, + perf: { + description: "A code change that improves performance", + title: "Performance Improvements", + emoji: "🚀", + }, + revert: { + description: "Reverts a previous commit", + title: "Reverts", + emoji: "🗑", + }, + chore: { + description: "Other changes that don't modify src or test files", + title: "Chores", + emoji: "♻️", + }, + docs: { + description: "Documentation only changes", + title: "Documentation", + emoji: "📚", + }, + style: { + description: + "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)", + title: "Styles", + emoji: "💎", + }, + test: { + description: "Adding missing tests or correcting existing tests", + title: "Tests", + emoji: "🚨", + }, + build: { + description: + "Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)", + title: "Builds", + emoji: "🛠", + }, + ci: { + description: + "Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)", + title: "Continuous Integrations", + emoji: "⚙️", + }, + }, + }, + scope: { + description: "What is the scope of this change (e.g. component or file name)", + }, + subject: { + description: "Write a short, imperative tense description of the change", + }, + body: { + description: "Provide a longer description of the change", + }, + isBreaking: { + description: "Are there any breaking changes?", + }, + breakingBody: { + description: "A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself", + }, + breaking: { + description: "Describe the breaking changes", + }, + isIssueAffected: { + description: "Does this change affect any open issues?", + }, + issuesBody: { + description: + "If issues are closed, the commit requires a body. Please enter a longer description of the commit itself", + }, + issues: { + description: 'Add issue references (e.g. "fix #123", "re #123".)', + }, + }, + }, +} diff --git a/common/appLogger.ts b/common/appLogger.ts deleted file mode 100644 index d439f65..0000000 --- a/common/appLogger.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2023, Terwer . All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Terwer designates this - * particular file as subject to the "Classpath" exception as provided - * by Terwer in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com - * or visit www.terwer.space if you need additional information or have any - * questions. - */ - -import { isDev } from "~/common/Constants.ts" -import { simpleLogger } from "zhi-lib-base" - -/** - * 使用 eruda 更好的控制日志 - */ -if (typeof window === "undefined") { - global.console = console -} else { - window.console = isDev ? (window as any).eruda.get("console") : window.console -} - -/** - * 简单的日志接口 - */ -interface ILogger { - debug: (msg: string, obj?: any) => void - info: (msg: string, obj?: any) => void - warn: (msg: string, obj?: any) => void - error: (msg: string | Error, obj?: any) => void -} - -/** - * 一个简单轻量级的日志记录器 - * - * @author terwer - * @version 1.0.0 - * @since 1.0.0 - */ -export const createAppLogger = (name: string): ILogger => { - return simpleLogger(name, "picgo-plugin-app", isDev) -} - -/** - * 销毁日志 - */ -export const destroyLogger = (): void => { - ;(window as any).eruda.destroy() -} diff --git a/components.d.ts b/components.d.ts deleted file mode 100644 index bec7d3e..0000000 --- a/components.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* eslint-disable */ -/* prettier-ignore */ -// @ts-nocheck -// Generated by unplugin-vue-components -// Read more: https://github.com/vuejs/core/pull/3399 -export {} - -declare module 'vue' { - export interface GlobalComponents { - BackPage: typeof import('./src/components/common/BackPage.vue')['default'] - ClearData: typeof import('./src/components/transport/ClearData.vue')['default'] - ConfigForm: typeof import('./src/components/common/ConfigForm.vue')['default'] - ElAlert: typeof import('element-plus/es')['ElAlert'] - ElButton: typeof import('element-plus/es')['ElButton'] - ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup'] - ElCard: typeof import('element-plus/es')['ElCard'] - ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] - ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] - ElCol: typeof import('element-plus/es')['ElCol'] - ElDialog: typeof import('element-plus/es')['ElDialog'] - ElForm: typeof import('element-plus/es')['ElForm'] - ElFormItem: typeof import('element-plus/es')['ElFormItem'] - ElIcon: typeof import('element-plus/es')['ElIcon'] - ElInput: typeof import('element-plus/es')['ElInput'] - ElOption: typeof import('element-plus/es')['ElOption'] - ElPageHeader: typeof import('element-plus/es')['ElPageHeader'] - ElPopover: typeof import('element-plus/es')['ElPopover'] - ElRow: typeof import('element-plus/es')['ElRow'] - ElSelect: typeof import('element-plus/es')['ElSelect'] - ElSwitch: typeof import('element-plus/es')['ElSwitch'] - ElTabPane: typeof import('element-plus/es')['ElTabPane'] - ElTabs: typeof import('element-plus/es')['ElTabs'] - ElTooltip: typeof import('element-plus/es')['ElTooltip'] - ExportData: typeof import('./src/components/transport/ExportData.vue')['default'] - ExternalPicgoSetting: typeof import('./src/components/setting/ExternalPicgoSetting.vue')['default'] - ImportData: typeof import('./src/components/transport/ImportData.vue')['default'] - PicbedSetting: typeof import('./src/components/setting/PicbedSetting.vue')['default'] - PicgoConfigSetting: typeof import('./src/components/setting/PicgoConfigSetting.vue')['default'] - PicGoIndex: typeof import('./src/components/PicGoIndex.vue')['default'] - PicgoPluginSetting: typeof import('./src/components/setting/PicgoPluginSetting.vue')['default'] - PicgoSetting: typeof import('./src/components/PicgoSetting.vue')['default'] - RouterLink: typeof import('vue-router')['RouterLink'] - RouterView: typeof import('vue-router')['RouterView'] - SiyuanSetting: typeof import('./src/components/setting/SiyuanSetting.vue')['default'] - TransportSelect: typeof import('./src/components/transport/TransportSelect.vue')['default'] - } - export interface ComponentCustomProperties { - vLoading: typeof import('element-plus/es')['ElLoadingDirective'] - } -} diff --git a/esbuild.config.cjs b/esbuild.config.cjs deleted file mode 100644 index 617e611..0000000 --- a/esbuild.config.cjs +++ /dev/null @@ -1,86 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2023. Terwer - * - * 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. - */ - -const path = require("path") -const minimist = require("minimist") -const stylePlugin = require("esbuild-style-plugin") -const { copy } = require("esbuild-plugin-copy") - -const args = minimist(process.argv.slice(2)) -const isWatch = args.watch || args.w || false - -const baseDir = isWatch - ? "/Users/terwer/Documents/mydocs/SiYuanWorkspace/test/data/plugins/siyuan-plugin-picgo" - // ? "/Users/terwer/Documents/mydocs/SiYuanWorkspace/public/data/plugins/siyuan-plugin-picgo" - : "./" -const distDir = isWatch ? baseDir : path.join(baseDir, "dist") - -module.exports = { - esbuildConfig: { - entryPoints: ["siyuan/index.ts"], - outfile: path.join(distDir, "index.js"), - bundle: true, - format: "cjs", - external: ["siyuan"], - define: { "process.env.DEV_MODE": `"${isWatch}"` }, - plugins: [ - stylePlugin(), - - copy({ - // this is equal to process.cwd(), which means we use cwd path as base path to resolve `to` path - // if not specified, this plugin uses ESBuild.build outdir/outfile options as base path. - resolveFrom: "cwd", - assets: [ - // copy folder - { - from: "./siyuan/i18n/*", - to: [path.join(distDir, "i18n")], - }, - // copy one file - { - from: ["./README.md"], - to: [path.join(distDir, "/README.md")], - }, - { - from: ["./README_zh_CN.md"], - to: [path.join(distDir, "/README_zh_CN.md")], - }, - { - from: ["./preview.png"], - to: [path.join(distDir, "/preview.png")], - }, - { - from: ["./icon.png"], - to: [path.join(distDir, "/icon.png")], - }, - { - from: ["./plugin.json"], - to: [path.join(distDir, "/plugin.json")], - }, - ], - watch: true, - }), - ], - }, -} diff --git a/external-picgo.config.ts b/external-picgo.config.ts deleted file mode 100644 index ea26c08..0000000 --- a/external-picgo.config.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2023, Terwer . All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Terwer designates this - * particular file as subject to the "Classpath" exception as provided - * by Terwer in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com - * or visit www.terwer.space if you need additional information or have any - * questions. - */ - -/** - * 外部 Picgo 配置接口 - */ -interface IExternalPicgoConfig { - useBundledPicgo?: boolean - - /** - * extPicgoApiUrl 是一个字符串,表示外部 Picgo API 的 URL - */ - extPicgoApiUrl?: string - - /** - * 其他配置项,可以是任意类型 - */ - [key: string]: any -} - -/** - * 外部 Picgo 配置实例 - */ -export const ExternalPicgoConfig: IExternalPicgoConfig = { - useBundledPicgo: true, - extPicgoApiUrl: "http://127.0.0.1:36677", -} diff --git a/libs/zhi-picgo-core/.eslintignore b/libs/zhi-picgo-core/.eslintignore new file mode 100644 index 0000000..f06235c --- /dev/null +++ b/libs/zhi-picgo-core/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist diff --git a/libs/zhi-picgo-core/.eslintrc.cjs b/libs/zhi-picgo-core/.eslintrc.cjs new file mode 100644 index 0000000..a1993b7 --- /dev/null +++ b/libs/zhi-picgo-core/.eslintrc.cjs @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"], +} diff --git a/libs/zhi-picgo-core/CHANGELOG.md b/libs/zhi-picgo-core/CHANGELOG.md new file mode 100644 index 0000000..33e2220 --- /dev/null +++ b/libs/zhi-picgo-core/CHANGELOG.md @@ -0,0 +1,401 @@ +# zhi-picgo-core + +## 1.7.0 + +### Minor Changes + +- feat: fit latest siyuan note + +## 1.6.1 + +### Patch Changes + +- chore: format code + +# :tada: 1.5.0 (2022-11-13) + +# :tada: 1.5.0-alpha.17 (2022-11-13) + +### :sparkles: Features + +- update picgo.use ([e19bb6e](https://github.com/PicGo/PicGo-Core/commit/e19bb6e)) + +### :bug: Bug Fixes + +- some case will cause proxy not work ([6272303](https://github.com/PicGo/PicGo-Core/commit/6272303)) + +# :tada: 1.5.0-alpha.16 (2022-11-09) + +### :bug: Bug Fixes + +- upyun url-options is not required ([9736a11](https://github.com/PicGo/PicGo-Core/commit/9736a11)) + +# :tada: 1.5.0-alpha.15 (2022-10-24) + +### :bug: Bug Fixes + +- tencent cos url encode bug ([eafb70f](https://github.com/PicGo/PicGo-Core/commit/eafb70f)) + +# :tada: 1.5.0-alpha.14 (2022-10-24) + +### :bug: Bug Fixes + +- url encode bug ([4c70e9b](https://github.com/PicGo/PicGo-Core/commit/4c70e9b)) + +# :tada: 1.5.0-alpha.13 (2022-10-19) + +### :bug: Bug Fixes + +- type error ([b934e8a](https://github.com/PicGo/PicGo-Core/commit/b934e8a)) + +### :package: Chore + +- create oldRequest types ([749359a](https://github.com/PicGo/PicGo-Core/commit/749359a)) + +# :tada: 1.5.0-alpha.12 (2022-10-14) + +### :bug: Bug Fixes + +- types bug ([d77e6f3](https://github.com/PicGo/PicGo-Core/commit/d77e6f3)) + +# :tada: 1.5.0-alpha.11 (2022-10-13) + +# :tada: 1.5.0-alpha.10 (2022-09-25) + +### :sparkles: Features + +- add zh-TW ([#135](https://github.com/PicGo/PicGo-Core/issues/135)) ([d111d6a](https://github.com/PicGo/PicGo-Core/commit/d111d6a)) +- update linux.sh ([#134](https://github.com/PicGo/PicGo-Core/issues/134)) ([2910c20](https://github.com/PicGo/PicGo-Core/commit/2910c20)) + +### :bug: Bug Fixes + +- some texts in zh-TW ([#136](https://github.com/PicGo/PicGo-Core/issues/136)) ([907e6c9](https://github.com/PicGo/PicGo-Core/commit/907e6c9)) +- url image download bug & tencent cos url encode bug ([53d54f8](https://github.com/PicGo/PicGo-Core/commit/53d54f8)) + +# :tada: 1.5.0-alpha.9 (2022-09-03) + +### :sparkles: Features + +- finish request -> axios ([b89cf1e](https://github.com/PicGo/PicGo-Core/commit/b89cf1e)) + +### :bug: Bug Fixes + +- qiniu error msg can't show ([0e4661b](https://github.com/PicGo/PicGo-Core/commit/0e4661b)) +- sm.ms backupDomain message text ([45424d1](https://github.com/PicGo/PicGo-Core/commit/45424d1)) +- when request-options resolveWithFullResponse is false bug ([eb8217a](https://github.com/PicGo/PicGo-Core/commit/eb8217a)) + +# :tada: 1.5.0-alpha.8 (2022-08-27) + +### :sparkles: Features + +- add backupDomain for sm.ms ([c6d54f1](https://github.com/PicGo/PicGo-Core/commit/c6d54f1)) +- add debug logger type ([4342268](https://github.com/PicGo/PicGo-Core/commit/4342268)) +- add picgo.use for easily using plugin ([c0107f1](https://github.com/PicGo/PicGo-Core/commit/c0107f1)) + +### :bug: Bug Fixes + +- sometime tencent-cloud error message is empty ([6355e1b](https://github.com/PicGo/PicGo-Core/commit/6355e1b)) + +# :tada: 1.5.0-alpha.7 (2022-08-20) + +### :sparkles: Features + +- finish i18n text ([11b3197](https://github.com/PicGo/PicGo-Core/commit/11b3197)) + +### :bug: Bug Fixes + +- aliyun content-type -> Content-Type ([a649fcc](https://github.com/PicGo/PicGo-Core/commit/a649fcc)) + +# :tada: 1.5.0-alpha.6 (2022-08-17) + +### :bug: Bug Fixes + +- tencent cos upload error ([61df53a](https://github.com/PicGo/PicGo-Core/commit/61df53a)) + +# :tada: 1.5.0-alpha.5 (2022-07-31) + +### :sparkles: Features + +- add log file size limit ([158be01](https://github.com/PicGo/PicGo-Core/commit/158be01)) +- change inner db to @picgo/store ([0e90af3](https://github.com/PicGo/PicGo-Core/commit/0e90af3)) + +### :bug: Bug Fixes + +- build error ([674a6b5](https://github.com/PicGo/PicGo-Core/commit/674a6b5)) + +# :tada: 1.5.0-alpha.4 (2022-05-26) + +### :sparkles: Features + +- add userAgent for tencent cloud COS ([acac59a](https://github.com/PicGo/PicGo-Core/commit/acac59a)) + +# :tada: 1.5.0-alpha.3 (2022-04-04) + +### :bug: Bug Fixes + +- picgo-gui clipboard image uploading error ([1302f76](https://github.com/PicGo/PicGo-Core/commit/1302f76)) + +# :tada: 1.5.0-alpha.2 (2022-04-03) + +### :sparkles: Features + +- add wayland support for linux ([#119](https://github.com/PicGo/PicGo-Core/issues/119)) ([28905f2](https://github.com/PicGo/PicGo-Core/commit/28905f2)) + +### :bug: Bug Fixes + +- qiniu && upyun errors ([587dd3f](https://github.com/PicGo/PicGo-Core/commit/587dd3f)) + +# :tada: 1.5.0-alpha.1 (2022-03-08) + +### :sparkles: Features + +- add options for tencent cos ([1fccdcc](https://github.com/PicGo/PicGo-Core/commit/1fccdcc)), closes [#117](https://github.com/PicGo/PicGo-Core/issues/117) +- **i18n:** add i18n for picgo ([4b93a76](https://github.com/PicGo/PicGo-Core/commit/4b93a76)) + +### :bug: Bug Fixes + +- build error in windows ([5616fb9](https://github.com/PicGo/PicGo-Core/commit/5616fb9)) + +### :package: Chore + +- add alpha branch for alpha version ([6882022](https://github.com/PicGo/PicGo-Core/commit/6882022)), closes [#106](https://github.com/PicGo/PicGo-Core/issues/106) + +# :tada: 1.5.0-alpha.0 (2021-10-26) + +### :package: Chore + +- **build:** migrate to esbuild and change export assignment to esm export ([#102](https://github.com/PicGo/PicGo-Core/issues/102)) ([2a6cd18](https://github.com/PicGo/PicGo-Core/commit/2a6cd18)) + +## :tada: 1.4.26 (2021-08-23) + +### :bug: Bug Fixes + +- engine bug in package.json ([1c65144](https://github.com/PicGo/PicGo-Core/commit/1c65144)) + +## :tada: 1.4.25 (2021-08-21) + +### :bug: Bug Fixes + +- handle clipboard file path error ([ff4ec86](https://github.com/PicGo/PicGo-Core/commit/ff4ec86)), closes [#97](https://github.com/PicGo/PicGo-Core/issues/97) +- **error:** throw error when transform failed ([#96](https://github.com/PicGo/PicGo-Core/issues/96)) ([57fce75](https://github.com/PicGo/PicGo-Core/commit/57fce75)) +- clipboard path contains space ([#95](https://github.com/PicGo/PicGo-Core/issues/95)) ([d2b73c1](https://github.com/PicGo/PicGo-Core/commit/d2b73c1)) + +## :tada: 1.4.24 (2021-08-01) + +### :sparkles: Features + +- uploaded now can be modified since picgo will not use this value ([b6a8b58](https://github.com/PicGo/PicGo-Core/commit/b6a8b58)) + +## :tada: 1.4.23 (2021-07-27) + +### :bug: Bug Fixes + +- cases when clipboard of wsl contain image file ([#91](https://github.com/PicGo/PicGo-Core/issues/91)) ([adfc55e](https://github.com/PicGo/PicGo-Core/commit/adfc55e)) + +### :package: Chore + +- add github actions for publishing ([caae80e](https://github.com/PicGo/PicGo-Core/commit/caae80e)) + +## :tada: 1.4.22 (2021-07-27) + +### :sparkles: Features + +- **smms:** smms now supports image without token ([#89](https://github.com/PicGo/PicGo-Core/issues/89)) ([456b81c](https://github.com/PicGo/PicGo-Core/commit/456b81c)) +- add support for clipboard in wsl ([#87](https://github.com/PicGo/PicGo-Core/issues/87)) ([3e230de](https://github.com/PicGo/PicGo-Core/commit/3e230de)) + +## :tada: 1.4.21 (2021-05-09) + +### :bug: Bug Fixes + +- output empty after uploading when using isolate context ([79c228b](https://github.com/PicGo/PicGo-Core/commit/79c228b)) + +## :tada: 1.4.20 (2021-05-09) + +### :sparkles: Features + +- add createContext for each upload process ([ecde023](https://github.com/PicGo/PicGo-Core/commit/ecde023)) + +### :package: Chore + +- add debug launch.json ([9950259](https://github.com/PicGo/PicGo-Core/commit/9950259)) + +## :tada: 1.4.19 (2021-04-04) + +### :sparkles: Features + +- add current uploader && transformer log ([67b2bb1](https://github.com/PicGo/PicGo-Core/commit/67b2bb1)) +- limit some of config's capabilities ([f901505](https://github.com/PicGo/PicGo-Core/commit/f901505)) + +## :tada: 1.4.18 (2021-03-06) + +### :bug: Bug Fixes + +- unregister plugin delete pluginMap ([85228d8](https://github.com/PicGo/PicGo-Core/commit/85228d8)) + +## :tada: 1.4.17 (2021-02-09) + +### :bug: Bug Fixes + +- **type:** type error in index.d.ts ([f617658](https://github.com/PicGo/PicGo-Core/commit/f617658)), closes [#69](https://github.com/PicGo/PicGo-Core/issues/69) + +## :tada: 1.4.16 (2021-02-08) + +### :sparkles: Features + +- add proxy & registry options for pluginHandler ([b10b963](https://github.com/PicGo/PicGo-Core/commit/b10b963)) +- dynamic proxy getter with ctx.Request.request ([687805f](https://github.com/PicGo/PicGo-Core/commit/687805f)), closes [#64](https://github.com/PicGo/PicGo-Core/issues/64) +- supporting install specific version of plugin ([35e15b0](https://github.com/PicGo/PicGo-Core/commit/35e15b0)) + +## :tada: 1.4.15 (2021-01-24) + +### :sparkles: Features + +- add local plugin install/uninstall/update support & imporve plugin name handler ([f8ec464](https://github.com/PicGo/PicGo-Core/commit/f8ec464)) + +## :tada: 1.4.14 (2020-12-19) + +### :bug: Bug Fixes + +- types error ([303a4ec](https://github.com/PicGo/PicGo-Core/commit/303a4ec)) + +## :tada: 1.4.13 (2020-12-19) + +### :sparkles: Features + +- new addPlugin api for node projects ([5a18432](https://github.com/PicGo/PicGo-Core/commit/5a18432)) + +### :bug: Bug Fixes + +- **type:** some type error ([233a6ca](https://github.com/PicGo/PicGo-Core/commit/233a6ca)) +- pluginLoader can't get the full plugin list ([83535b9](https://github.com/PicGo/PicGo-Core/commit/83535b9)), closes [#60](https://github.com/PicGo/PicGo-Core/issues/60) + +## :tada: 1.4.12 (2020-11-04) + +### :bug: Bug Fixes + +- let tcyun error info more detail ([ddf645f](https://github.com/PicGo/PicGo-Core/commit/ddf645f)) +- not encode before uploading an image with url ([c0aee32](https://github.com/PicGo/PicGo-Core/commit/c0aee32)) +- qiniu error handler ([de94212](https://github.com/PicGo/PicGo-Core/commit/de94212)) + +## :tada: 1.4.11 (2020-07-12) + +### :bug: Bug Fixes + +- initailize db function error ([df7d526](https://github.com/PicGo/PicGo-Core/commit/df7d526)) + +## :tada: 1.4.10 (2020-06-28) + +### :bug: Bug Fixes + +- url image hash bug ([e405221](https://github.com/PicGo/PicGo-Core/commit/e405221)) + +## :tada: 1.4.9 (2020-06-27) + +### :sparkles: Features + +- add plugin running && error logs ([6adc070](https://github.com/PicGo/PicGo-Core/commit/6adc070)) +- **transformer:** add fallback to support more image formats such as HEIC ([0f5d2a9](https://github.com/PicGo/PicGo-Core/commit/0f5d2a9)), closes [#13](https://github.com/PicGo/PicGo-Core/issues/13) + +### :bug: Bug Fixes + +- multiline logs format ([444a42f](https://github.com/PicGo/PicGo-Core/commit/444a42f)) +- the issue of lost logs ([daa7508](https://github.com/PicGo/PicGo-Core/commit/daa7508)) +- the order of the uploaded list may not be the same as the order entered ([2bf1ed9](https://github.com/PicGo/PicGo-Core/commit/2bf1ed9)), closes [#40](https://github.com/PicGo/PicGo-Core/issues/40) +- unregisterPlugin's bug ([966bfd8](https://github.com/PicGo/PicGo-Core/commit/966bfd8)) + +### :package: Chore + +- add vscode workspace settings & migrate tslint to eslint ([50a4842](https://github.com/PicGo/PicGo-Core/commit/50a4842)) + +## :tada: 1.4.8 (2020-04-04) + +### :bug: Bug Fixes + +- encode url before finishing ([7a6b39c](https://github.com/PicGo/PicGo-Core/commit/7a6b39c)) +- return true if decodeURI throw error to avoid crash ([d09d77a](https://github.com/PicGo/PicGo-Core/commit/d09d77a)) +- win10 cmd crash bug when "picgo upload" ([#35](https://github.com/PicGo/PicGo-Core/issues/35)) ([deec252](https://github.com/PicGo/PicGo-Core/commit/deec252)) + +## :tada: 1.4.7 (2020-03-07) + +### :sparkles: Features + +- add smms-v2 support ([7e10655](https://github.com/PicGo/PicGo-Core/commit/7e10655)) +- remove weibo support ([96b2b3a](https://github.com/PicGo/PicGo-Core/commit/96b2b3a)) + +### :pencil: Documentation + +- update README ([aff6326](https://github.com/PicGo/PicGo-Core/commit/aff6326)) + +## :tada: 1.4.6 (2020-02-23) + +### :bug: Bug Fixes + +- auto generate a local png bug ([c54ac67](https://github.com/PicGo/PicGo-Core/commit/c54ac67)) + +## :tada: 1.4.5 (2020-02-23) + +### :sparkles: Features + +- add upload image from URL support ([0d87342](https://github.com/PicGo/PicGo-Core/commit/0d87342)) + +### :package: Chore + +- travis-ci deploy option ([a2a89cd](https://github.com/PicGo/PicGo-Core/commit/a2a89cd)) + +## :tada: 1.4.4 (2019-12-30) + +### :bug: Bug Fixes + +- image_repeated error from smms ([#28](https://github.com/PicGo/PicGo-Core/issues/28)) ([f246b8d](https://github.com/PicGo/PicGo-Core/commit/f246b8d)) + +## :tada: 1.4.3 (2019-12-27) + +### :sparkles: Features + +- add aliyun optionUrl option ([0a3bdea](https://github.com/PicGo/PicGo-Core/commit/0a3bdea)) + +## :tada: 1.4.2 (2019-12-26) + +### :bug: Bug Fixes + +- cli source ([be6cdcc](https://github.com/PicGo/PicGo-Core/commit/be6cdcc)) + +## :tada: 1.4.1 (2019-12-26) + +# :tada: 1.4.0 (2019-12-26) + +### :sparkles: Features + +- add config methods && pluginHandler to ctx ([f9bb9fb](https://github.com/PicGo/PicGo-Core/commit/f9bb9fb)) +- **plugin:** passing environment variables ([50467c7](https://github.com/PicGo/PicGo-Core/commit/50467c7)) + +### :bug: Bug Fixes + +- correct sm.ms err msg ([#18](https://github.com/PicGo/PicGo-Core/issues/18)) ([f0a4e8a](https://github.com/PicGo/PicGo-Core/commit/f0a4e8a)) +- pluginHandler args length error ([e15eac2](https://github.com/PicGo/PicGo-Core/commit/e15eac2)) + +### :package: Chore + +- **types:** added typings field to export type inform… ([#23](https://github.com/PicGo/PicGo-Core/issues/23)) ([8bb16e7](https://github.com/PicGo/PicGo-Core/commit/8bb16e7)) + +## :tada: 1.3.7 (2019-05-12) + +### :bug: Bug Fixes + +- **clipboard:** clipboard image getter error in macOS ([8314604](https://github.com/PicGo/PicGo-Core/commit/8314604)) + +## :tada: 1.3.6 (2019-04-20) + +### :bug: Bug Fixes + +- clipboard image upload under win10 ([48b72ed](https://github.com/PicGo/PicGo-Core/commit/48b72ed)) + +## :tada: 1.3.5 (2019-04-15) + +### :bug: Bug Fixes + +- writing log sometimes disappeared ([d36c0ae](https://github.com/PicGo/PicGo-Core/commit/d36c0ae)) + +### :package: Chore + +- add picgo bump version ([c312302](https://github.com/PicGo/PicGo-Core/commit/c312302)) diff --git a/libs/zhi-picgo-core/README.md b/libs/zhi-picgo-core/README.md new file mode 100644 index 0000000..4edf102 --- /dev/null +++ b/libs/zhi-picgo-core/README.md @@ -0,0 +1,45 @@ +# zhi-picgo-core + +A tool for picture uploading forked from [PicGO-Core](https://github.com/PicGo/PicGo-Core), for electron usage. + +![picgo-core](https://cdn.jsdelivr.net/gh/Molunerfinn/test/picgo/picgo-core-fix.jpg) + +## Usage + +### Use in node project + +#### Common JS + +```js +const { PicGo } = require("picgo") +``` + +#### ES Module + +```js +import { PicGo } from "picgo" +``` + +#### API usage example + +```js +const picgo = new PicGo() + +// upload a picture from path +picgo.upload(["/xxx/xxx.jpg"]) + +// upload a picture from clipboard +picgo.upload() +``` + +### Use in electron + +```js +const { PicGo } = require("/Users/terwer/Documents/mydocs/zhi-framework/zhi/libs/zhi-picgo-core/dist/index.cjs.js") +const picgo = new PicGo() +console.log(picgo) +``` + +## Documentation + +For more details, you can checkout [documentation](https://picgo.github.io/PicGo-Core-Doc/). diff --git a/libs/zhi-picgo-core/dist/core/Lifecycle.d.ts b/libs/zhi-picgo-core/dist/core/Lifecycle.d.ts new file mode 100644 index 0000000..d05bbbe --- /dev/null +++ b/libs/zhi-picgo-core/dist/core/Lifecycle.d.ts @@ -0,0 +1,15 @@ +/// +import { EventEmitter } from "events"; +import { IPicGo } from "../types"; +export declare class Lifecycle extends EventEmitter { + private readonly ctx; + constructor(ctx: IPicGo); + start(input: any[]): Promise; + private beforeTransform; + private doTransform; + private beforeUpload; + private doUpload; + private afterUpload; + private handlePlugins; +} +export default Lifecycle; diff --git a/libs/zhi-picgo-core/dist/core/PicGo.d.ts b/libs/zhi-picgo-core/dist/core/PicGo.d.ts new file mode 100644 index 0000000..a0f9692 --- /dev/null +++ b/libs/zhi-picgo-core/dist/core/PicGo.d.ts @@ -0,0 +1,49 @@ +/// +import { EventEmitter } from "events"; +import Commander from "../lib/Commander"; +import { Logger } from "../lib/Logger"; +import { IHelper, IImgInfo, IPicGo, IStringKeyMap, IPluginLoader, II18nManager, IPicGoPlugin, IPicGoPluginInterface, IRequest } from "../types"; +import Request from "../lib/Request"; +import PluginHandler from "../lib/PluginHandler"; +export declare class PicGo extends EventEmitter implements IPicGo { + private _config; + private lifecycle; + private db; + private _pluginLoader; + configPath: string; + baseDir: string; + helper: IHelper; + log: Logger; + cmd: Commander; + output: IImgInfo[]; + input: any[]; + pluginHandler: PluginHandler; + /** + * @deprecated will be removed in v1.5.0+ + * + * use request instead + */ + Request: Request; + i18n: II18nManager; + VERSION: string; + GUI_VERSION?: string; + get pluginLoader(): IPluginLoader; + constructor(configPath?: string); + private initConfigPath; + private initConfig; + private init; + /** + * easily mannually load a plugin + * if provide plugin name, will register plugin by name + * or just instantiate a plugin + */ + use(plugin: IPicGoPlugin, name?: string): IPicGoPluginInterface; + registerCommands(): void; + getConfig(name?: string): T; + saveConfig(config: IStringKeyMap): void; + removeConfig(key: string, propName: string): void; + setConfig(config: IStringKeyMap): void; + unsetConfig(key: string, propName: string): void; + get request(): IRequest["request"]; + upload(input?: any[]): Promise; +} diff --git a/libs/zhi-picgo-core/dist/i18n/en.d.ts b/libs/zhi-picgo-core/dist/i18n/en.d.ts new file mode 100644 index 0000000..8150461 --- /dev/null +++ b/libs/zhi-picgo-core/dist/i18n/en.d.ts @@ -0,0 +1,2 @@ +import { ILocales } from "./zh-CN"; +export declare const EN: ILocales; diff --git a/libs/zhi-picgo-core/dist/i18n/index.d.ts b/libs/zhi-picgo-core/dist/i18n/index.d.ts new file mode 100644 index 0000000..d7c103d --- /dev/null +++ b/libs/zhi-picgo-core/dist/i18n/index.d.ts @@ -0,0 +1,18 @@ +import { ILocalesKey } from "./zh-CN"; +import { IPicGo } from "../types"; +import { IStringKeyMap, II18nManager } from "../types/index"; +import { ILocale } from "@picgo/i18n/dist/types"; +declare class I18nManager implements II18nManager { + private readonly i18n; + private readonly objectAdapter; + private readonly ctx; + constructor(ctx: IPicGo); + private loadOutterI18n; + private getOutterI18nFolder; + translate(key: ILocalesKey | T, args?: IStringKeyMap): string; + setLanguage(language: string): void; + addLocale(language: string, locales: ILocale): boolean; + addLanguage(language: string, locales: ILocale): boolean; + getLanguageList(): string[]; +} +export { I18nManager }; diff --git a/libs/zhi-picgo-core/dist/i18n/zh-CN.d.ts b/libs/zhi-picgo-core/dist/i18n/zh-CN.d.ts new file mode 100644 index 0000000..4d9e3ed --- /dev/null +++ b/libs/zhi-picgo-core/dist/i18n/zh-CN.d.ts @@ -0,0 +1,91 @@ +export declare const ZH_CN: { + UPLOAD_FAILED: string; + CHECK_SETTINGS: string; + CHECK_SETTINGS_AND_NETWORK: string; + UPLOAD_FAILED_REASON: string; + SERVER_ERROR: string; + AUTH_FAILED: string; + PICBED_SMMS: string; + PICBED_SMMS_TOKEN: string; + PICBED_SMMS_BACKUP_DOMAIN: string; + PICBED_SMMS_MESSAGE_BACKUP_DOMAIN: string; + PICBED_ALICLOUD: string; + PICBED_ALICLOUD_ACCESSKEYID: string; + PICBED_ALICLOUD_ACCESSKEYSECRET: string; + PICBED_ALICLOUD_BUCKET: string; + PICBED_ALICLOUD_AREA: string; + PICBED_ALICLOUD_PATH: string; + PICBED_ALICLOUD_CUSTOMURL: string; + PICBED_ALICLOUD_OPTIONS: string; + PICBED_ALICLOUD_MESSAGE_AREA: string; + PICBED_ALICLOUD_MESSAGE_PATH: string; + PICBED_ALICLOUD_MESSAGE_OPTIONS: string; + PICBED_ALICLOUD_MESSAGE_CUSTOMURL: string; + PICBED_TENCENTCLOUD: string; + PICBED_TENCENTCLOUD_VERSION: string; + PICBED_TENCENTCLOUD_SECRETID: string; + PICBED_TENCENTCLOUD_SECRETKEY: string; + PICBED_TENCENTCLOUD_APPID: string; + PICBED_TENCENTCLOUD_BUCKET: string; + PICBED_TENCENTCLOUD_AREA: string; + PICBED_TENCENTCLOUD_PATH: string; + PICBED_TENCENTCLOUD_OPTIONS: string; + PICBED_TENCENTCLOUD_CUSTOMURL: string; + PICBED_TENCENTCLOUD_MESSAGE_APPID: string; + PICBED_TENCENTCLOUD_MESSAGE_AREA: string; + PICBED_TENCENTCLOUD_MESSAGE_PATH: string; + PICBED_TENCENTCLOUD_MESSAGE_CUSTOMURL: string; + PICBED_TENCENTCLOUD_MESSAGE_OPTIONS: string; + PICBED_GITHUB: string; + PICBED_GITHUB_TOKEN: string; + PICBED_GITHUB_REPO: string; + PICBED_GITHUB_PATH: string; + PICBED_GITHUB_BRANCH: string; + PICBED_GITHUB_CUSTOMURL: string; + PICBED_GITHUB_MESSAGE_REPO: string; + PICBED_GITHUB_MESSAGE_BRANCH: string; + PICBED_GITHUB_MESSAGE_PATH: string; + PICBED_GITHUB_MESSAGE_CUSTOMURL: string; + PICBED_QINIU: string; + PICBED_QINIU_ACCESSKEY: string; + PICBED_QINIU_SECRETKEY: string; + PICBED_QINIU_BUCKET: string; + PICBED_QINIU_PATH: string; + PICBED_QINIU_URL: string; + PICBED_QINIU_OPTIONS: string; + PICBED_QINIU_AREA: string; + PICBED_QINIU_MESSAGE_PATH: string; + PICBED_QINIU_MESSAGE_AREA: string; + PICBED_QINIU_MESSAGE_OPTIONS: string; + PICBED_QINIU_MESSAGE_URL: string; + PICBED_IMGUR: string; + PICBED_IMGUR_CLIENTID: string; + PICBED_IMGUR_PROXY: string; + PICBED_IMGUR_MESSAGE_PROXY: string; + PICBED_UPYUN: string; + PICBED_UPYUN_BUCKET: string; + PICBED_UPYUN_OPERATOR: string; + PICBED_UPYUN_PASSWORD: string; + PICBED_UPYUN_PATH: string; + PICBED_UPYUN_URL: string; + PICBED_UPYUN_OPTIONS: string; + PICBED_UPYUN_MESSAGE_OPERATOR: string; + PICBED_UPYUN_MESSAGE_PASSWORD: string; + PICBED_UPYUN_MESSAGE_URL: string; + PICBED_UPYUN_MESSAGE_OPTIONS: string; + PICBED_UPYUN_MESSAGE_PATH: string; + PLUGIN_HANDLER_PLUGIN_INSTALL_SUCCESS: string; + PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED: string; + PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED_REASON: string; + PLUGIN_HANDLER_PLUGIN_INSTALL_FAILED_PATH: string; + PLUGIN_HANDLER_PLUGIN_UNINSTALL_SUCCESS: string; + PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED: string; + PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED_REASON: string; + PLUGIN_HANDLER_PLUGIN_UNINSTALL_FAILED_VALID: string; + PLUGIN_HANDLER_PLUGIN_UPDATE_SUCCESS: string; + PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED: string; + PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_REASON: string; + PLUGIN_HANDLER_PLUGIN_UPDATE_FAILED_VALID: string; +}; +export type ILocalesKey = keyof typeof ZH_CN; +export type ILocales = typeof ZH_CN; diff --git a/libs/zhi-picgo-core/dist/i18n/zh-TW.d.ts b/libs/zhi-picgo-core/dist/i18n/zh-TW.d.ts new file mode 100644 index 0000000..45f1c0e --- /dev/null +++ b/libs/zhi-picgo-core/dist/i18n/zh-TW.d.ts @@ -0,0 +1,2 @@ +import { ILocales } from "./zh-CN"; +export declare const ZH_TW: ILocales; diff --git a/libs/zhi-picgo-core/dist/index.cjs.js b/libs/zhi-picgo-core/dist/index.cjs.js new file mode 100644 index 0000000..7c7cfc9 --- /dev/null +++ b/libs/zhi-picgo-core/dist/index.cjs.js @@ -0,0 +1,2 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs-extra"),t=require("path"),n=require("events"),r=require("os"),i=require("commander"),s=require("inquirer"),a=require("image-size"),o=require("url"),l=require("chalk"),u=require("minimatch"),c=require("globby"),d=require("ejs"),p=require("download-git-repo"),g=require("rimraf"),E=require("dayjs"),_=require("util"),I=require("crypto"),f=require("mime-types"),h=require("qiniu"),P=require("ali-oss"),C=require("stream"),m=require("arraybuffer-to-buffer"),U=require("md5"),N=require("upyun"),L=require("resolve"),S=require("lodash"),D=require("child_process"),A=require("is-wsl"),T=require("axios"),y=require("form-data"),O=require("https"),B=require("tunnel"),b=require("@picgo/store"),x=require("cross-spawn"),w=require("js-yaml"),R=require("@picgo/i18n");function G(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var $=G(e),v=G(t),M=G(r),H=G(s),F=G(l),q=G(u),k=G(c),K=G(d),Y=G(p),j=G(g),Q=G(E),W=G(_),z=G(I),V=G(f),J=G(h),X=G(P),Z=G(m),ee=G(U),te=G(N),ne=G(L),re=G(A),ie=G(T),se=G(y),ae=G(O),oe=G(B),le=G(x),ue=G(w);const ce={handle:e=>{const t=e.cmd;t.program.command("install ").description("install picgo plugin").alias("add").option("-p, --proxy ","Add proxy for installing").option("-r, --registry ","Choose a registry for installing").action(((t,n)=>{const{proxy:r,registry:i}=n,s={proxy:r,registry:i};e.pluginHandler.install(t,s).catch((t=>{e.log.error(t)}))})),t.program.command("uninstall ").alias("rm").description("uninstall picgo plugin").action((t=>{e.pluginHandler.uninstall(t).catch((t=>{e.log.error(t)}))})),t.program.command("update ").description("update picgo plugin").option("-p, --proxy ","Add proxy for installing").option("-r, --registry ","Choose a registry for installing").action(((t,n)=>{const{proxy:r,registry:i}=n,s={proxy:r,registry:i};e.pluginHandler.update(t,s).catch((t=>{e.log.error(t)}))}))}},de={handle:e=>{e.cmd.program.option("-c, --config ","set config path")}},pe=e=>e.startsWith("http://")||e.startsWith("https://"),ge=e=>((e=>{e=e||"";try{return e!==decodeURI(e)}catch(e){return!0}})(e)||(e=encodeURI(e)),e),Ee=e=>{try{const{width:t=0,height:n=0}=a.imageSize(e);return{real:!0,width:t,height:n}}catch(e){return{real:!1,width:200,height:200}}},_e=e=>/^@[^/]+\/picgo-plugin-/.test(e)?"scope":e.startsWith("picgo-plugin-")?"normal":Ie(e)?"simple":"unknown",Ie=e=>{if(v.default.isAbsolute(e))return!1;const t=v.default.join(process.cwd(),e);return!$.default.existsSync(t)&&(!e.includes("/")&&!e.includes("\\"))},fe=(e,t="")=>t?`@${t}/picgo-plugin-${e}`:`picgo-plugin-${e}`,he=e=>e.split(v.default.sep).join("/"),Pe=(e,t=!1)=>{if(e.includes("@")){let n=/(.+\/)?(picgo-plugin-\w+)(@.+)*/;t&&(n=/(.+\/)?(^@[^/]+\/picgo-plugin-\w+)(@.+)*/);const r=e.match(n);return r?r[2]:(console.warn("can not remove plugin version"),e)}return e},Ce=[],me=e=>Ce.some((t=>e.startsWith(t))),Ue=e=>"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0;function Ne(e){try{return JSON.parse(e)}catch(t){return e}}const Le={handle:e=>{e.cmd.program.command("upload").description("upload, go go go").arguments("[input...]").alias("u").action((t=>{(async()=>{const n=t.map((e=>pe(e)?e:v.default.resolve(e))).filter((t=>{const n=$.default.existsSync(t)||pe(t);return n||e.log.warn(`${t} does not exist.`),n}));await e.upload(n)})().catch((t=>{e.log.error(t)}))}))}},Se=async(e,t,n,r)=>{const i=await e.cmd.inquirer.prompt(t),s="uploader"===n?`picBed.${r}`:"transformer"===n?`transformer.${r}`:r;e.saveConfig({[s]:i})},De={handle:e=>{e.cmd.program.command("set").alias("config").arguments(" [name]").description("configure config of picgo modules").action(((t,n)=>{(async()=>{var r,i;try{switch(t){case"uploader":case"transformer":if(n){const r=e.helper[t].get(n);if(!r)return e.log.error(`No ${t} named ${n}`);r.config&&await Se(e,r.config(e),t,n)}else{const n=[{type:"list",name:`${t}`,choices:e.helper[t].getIdList(),message:`Choose a(n) ${t}`}],r=await e.cmd.inquirer.prompt(n),i=e.helper[t].get(r[t]);(null==i?void 0:i.config)&&await Se(e,i.config(e),t,r[t])}break;case"plugin":if(n){if(n.includes("picgo-plugin-")||(n=`picgo-plugin-${n}`),!Object.keys(e.getConfig("picgoPlugins")).includes(n))return e.log.error(`No plugin named ${n}`);(null===(r=e.pluginLoader.getPlugin(n))||void 0===r?void 0:r.config)&&await Se(e,e.pluginLoader.getPlugin(n).config(e),"plugin",n)}else{const t=[{type:"list",name:"plugin",choices:e.pluginLoader.getFullList(),message:"Choose a plugin"}],n=await e.cmd.inquirer.prompt(t);(null===(i=e.pluginLoader.getPlugin(n.plugin))||void 0===i?void 0:i.config)&&await Se(e,e.pluginLoader.getPlugin(n.plugin).config(e),"plugin",n.plugin)}break;default:return e.log.warn(`No module named ${t}`),e.log.warn("Available modules are uploader|transformer|plugin")}const s="plugin"===t?"plugins":t;e.log.success("Configure config successfully!"),e.log.info(`If you want to use this config, please run 'picgo use ${s}'`)}catch(t){if(e.log.error(t),process.argv.includes("--debug"))throw t}})().catch((t=>{e.log.error(t)}))}))}},Ae={handle:async e=>{const t=e.cmd;t.program.command("use").arguments("[module]").description("use modules of picgo").action((n=>{(async()=>{try{let r=[];const i={uploader:{type:"list",name:"uploader",message:"Use an uploader",choices:e.helper.uploader.getIdList(),default:e.getConfig("picBed.uploader")||e.getConfig("picBed.current")||"github"},transformer:{type:"list",name:"transformer",message:"Use a transformer",choices:e.helper.transformer.getIdList(),default:e.getConfig("picBed.transformer")||"path"},plugins:{type:"checkbox",name:"plugins",message:"Use plugins",choices:e.pluginLoader.getFullList(),default:Object.keys(e.getConfig("picgoPlugins")).filter((t=>e.getConfig(`picgoPlugins.${t}`)))}};if(n){if(!i[n])return e.log.warn(`No module named ${n}`),e.log.warn("Available modules are uploader|transformer|plugins");r.push(i[n])}else r=Object.keys(i).map((e=>i[e]));const s=await t.inquirer.prompt(r);if(s.plugins){const t=e.getConfig("picgoPlugins");Object.keys(t).map((e=>{s.plugins.includes(e)?t[e]=!0:t[e]=!1})),e.saveConfig({picgoPlugins:t})}e.saveConfig({"picBed.current":s.uploader||e.getConfig("picBed.current"),"picBed.uploader":s.uploader||e.getConfig("picBed.current"),"picBed.transformer":s.transformer||"path"}),e.log.success("Configure config successfully!")}catch(t){if(e.log.error(t),process.argv.includes("--debug"))throw t}})().catch((t=>{e.log.error(t)}))}))}},Te={handle:e=>{e.cmd.program.option("-p, --proxy ","set proxy for uploading",(t=>{e.setConfig({"picBed.proxy":t})}))}},ye=async(e,t)=>{try{const n=Be(t.tmp),r=v.default.join(t.tmp,"template");let i={};n.prompts&&n.prompts.length>0&&(i=await e.cmd.inquirer.prompt(n.prompts));let s=await k.default(["**/*"],{cwd:r,dot:!0});if(s=s.filter((t=>{let r="";return Object.keys(n.filters).forEach((e=>{q.default(t,e,{dot:!0})&&(r=t)})),!r||Oe(e,n.filters[r],i)})),0===s.length)return e.log.warn("Template files not found!");const a=be(s,r,i);xe(t.dest,a),"function"==typeof n.complete&&n.complete({answers:i,options:t,files:s,ctx:e}),n.completeMessage&&e.log.success(n.completeMessage),e.log.success("Done!")}catch(t){return e.log.error(t)}},Oe=(e,t,n)=>{const r=new Function("data","with (data) { return "+t+"}");try{return r(n)}catch(n){return e.log.error(`Error when evaluating filter condition: ${JSON.stringify(t)}`),!1}},Be=e=>{const t=v.default.join(e,"index.js");if($.default.existsSync(t)){return require(t)}return{}},be=(e,t,n)=>{const r={};return e.forEach((e=>{const i=$.default.readFileSync(v.default.join(t,e),"utf8"),s=K.default.render(i,n);(Buffer.isBuffer(s)||/[^\s]/.test(s))&&(r[e]=s)})),r},xe=(e,t)=>{Object.keys(t).forEach((n=>{const r=v.default.join(e,n);$.default.ensureDirSync(v.default.dirname(r)),$.default.writeFileSync(r,t[n])}))},we=(e,t)=>{t.offline?$.default.existsSync(t.template)?ye(e,t).catch((t=>{e.log.error(t)})):e.log.error(`Local template ${t.template} not found`):(t.template=t.hasSlash?t.template:"PicGo/picgo-template-"+t.template,Re(e,t))},Re=(e,t)=>{$.default.existsSync(t.tmp)&&j.default.sync(t.tmp),e.log.info("Template files are downloading..."),Y.default(t.template,t.tmp,{clone:t.clone},(n=>{if(n)return e.log.error(n);e.log.success("Template files are downloaded!"),ye(e,t).catch((t=>{e.log.error(t)}))}))},Ge={handle:async e=>{e.cmd.program.command("init").arguments("