Skip to content

Commit

Permalink
chore: deploy vsx
Browse files Browse the repository at this point in the history
  • Loading branch information
aooiuu committed Jun 1, 2024
1 parent 5fc06d7 commit f8512ea
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 233 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/electron.yml

This file was deleted.

95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Release

on:
push:
tags:
- "*"

jobs:
release:
name: release
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [windows-latest]
# os: [windows-latest, macos-latest, ubuntu-latest]

steps:
- name: Check out git repository
uses: actions/checkout@v4.1.1

- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: pnpm install
run: pnpm install

- name: build core
run: pnpm run core:build

- name: build shared
run: pnpm run shared:build

- name: build vscode template
run: pnpm run vscode:build-tpl

- name: rename vscode vsx
# working-directory 用于指定在哪个目录下执行命令
working-directory: ./packages/vscode
run: pnpm run build:rename

# https://github.com/HaaLeo/publish-vscode-extension
- name: build vscode vsx
uses: HaaLeo/publish-vscode-extension@v1
id: publishVSX
with:
packagePath: ./packages/vscode
pat: ${{ secrets.VSCODE_TOKEN }}
# 不发布
dryRun: true
skipDuplicate: true
registryUrl: https://marketplace.visualstudio.com
yarn: false

- name: Build Electron App
run: pnpm electron:build
# env:
# GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}

- name: Cleanup Artifacts for Windows
if: matrix.os == 'windows-latest'
run: |
npx rimraf "packages/web/dist/electron/!(*.exe)"
# - name: Cleanup Artifacts for MacOS
# if: matrix.os == 'macos-latest'
# run: |
# npx rimraf "packages/web/dist/electron/!(*.dmg)"

# https://github.com/actions/upload-artifact
- name: upload artifacts
uses: actions/upload-artifact@v3.0.0
with:
name: ${{ matrix.os }}
path: |
${{ steps.publishVSX.outputs.vsixPath }}
packages/web/dist/electron
# https://github.com/softprops/action-gh-release
- name: release
uses: softprops/action-gh-release@v2.0.4
if: startsWith(github.ref, 'refs/tags/')
with:
# draft: true
files: |
packages/web/dist/electron/**
packages/vscode/*.vsix
# prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
48 changes: 48 additions & 0 deletions .github/workflows/vsx-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: VSX Release

on:
push:
branches:
- "vscode/**"

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Check out git repository
uses: actions/checkout@v4.1.1

- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: pnpm install
run: pnpm install

- name: build core
run: pnpm run core:build

- name: build shared
run: pnpm run shared:build

- name: build vscode template
run: pnpm run vscode:build-tpl

- name: rename vscode vsx
working-directory: ./packages/vscode
run: pnpm run build:rename

# https://github.com/HaaLeo/publish-vscode-extension
- name: build vscode vsx
uses: HaaLeo/publish-vscode-extension@v1
id: publishVSX
with:
packagePath: ./packages/vscode
pat: ${{ secrets.VSCODE_TOKEN }}
skipDuplicate: true
registryUrl: https://marketplace.visualstudio.com
yarn: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY --parents packages/*/package.json /app/
RUN pnpm install

COPY . /app
RUN pnpm build:core && pnpm build:shared
RUN pnpm core:build && pnpm shared:build

EXPOSE 8899
CMD ["pnpm", "web:dev"]
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
],
"scripts": {
"run:core": "npm -C packages/core run start",
"build:core": "npm -C packages/core run build",
"build:shared": "npm -C packages/shared run build",
"core:build": "npm -C packages/core run build",
"shared:build": "npm -C packages/shared run build",
"build": "npm-run-all core:build shared:build build:web",
"build:web": "npm -C packages/web run build",
"build:web-w": "npm -C packages/web run build:w",
"run:vsc": "npm-run-all build:core build:web-w",
"run:vsc": "npm-run-all core:build build:web-w",
"docs": "npm -C docs run docs:dev",
"build:docs": "npm -C docs run docs:build",
"server": "npm -C packages/server run dev",
"build": "npm-run-all build:core build:shared build:web",
"run:server": "run-p server run:web",
"test": "jest",
"coveralls": "jest --coverage",
Expand All @@ -44,7 +44,8 @@
"electron:server": "npm -C packages/web run electron:dev",
"electron:build": "npm -C packages/web run electron:build",
"vscode:server": "npm -C packages/web run vscode:dev",
"vscode:dev": "npm-run-all build:core build:shared --parallel vscode:server server",
"vscode:dev": "npm-run-all core:build shared:build --parallel vscode:server server",
"vscode:build-tpl": "npm -C packages/web run vscode:build",
"vscode:build": "npm -C packages/vscode run build",
"server:build": "npm -C packages/server run build",
"cli:build-tpl": "npm -C packages/web run cli:build",
Expand Down
18 changes: 14 additions & 4 deletions packages/shared/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,13 @@ export function useApi(register: any, { CONFIG_PATH, bookDir }: any) {

// 记录接口调用情况
if (typeof log === 'object' && log.ruleId && log.check) {
const isOk = log.check(result)
ruleExtraManager.updateApiStatus(log.ruleId(...arg), isOk ? `${apiPath}.ok` : `${apiPath}.fail`)
const ruleId = log.ruleId(...arg)

// 不记录没有规则ID的接口
if (ruleId) {
const isOk = log.check(result)
ruleExtraManager.updateApiStatus(ruleId, isOk ? `${apiPath}.ok` : `${apiPath}.fail`)
}
}

// 返回数据
Expand All @@ -255,6 +260,11 @@ export function useApi(register: any, { CONFIG_PATH, bookDir }: any) {
check: (v: any[]) => Array.isArray(v) && v.length > 0,
}

const contentLog = {
ruleId: (data: any) => data.ruleId,
check: (v: any) => v?.content?.length > 0,
}

// 注册接口
registerApi('get@discoverMap', async ({ ruleId = '' } = {}) => await discoverMap(ruleId), discoverLog)
registerApi('post@discover', async (data: any) => await discover(data), discoverLog)
Expand All @@ -268,8 +278,8 @@ export function useApi(register: any, { CONFIG_PATH, bookDir }: any) {
registerApi('post@createRule', async (data: any) => await createRule(data))
registerApi('post@updateRule', async (data: any) => await updateRule(data))
registerApi('post@searchByRuleId', async (data: any) => await searchByRuleId(data), discoverLog)
registerApi('post@content', async (data: any) => await content(data))
registerApi('post@getChapter', async (data: any) => await getChapter(data))
registerApi('post@content', async (data: any) => await content(data), contentLog)
registerApi('post@getChapter', async (data: any) => await getChapter(data), discoverLog)
registerApi('get@readConfig', async () => await readConfig(CONFIG_PATH))
registerApi('post@updateConfig', async (data: any) => await updateConfig(CONFIG_PATH, data))
registerApi('get@getRuleExtras', async () => await getRuleExtras())
Expand Down
1 change: 0 additions & 1 deletion packages/vscode/.yarnrc

This file was deleted.

31 changes: 17 additions & 14 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "any-reader",
"name": "@any-reader/vscode",
"displayName": "any-reader",
"description": "摸鱼,自定义规则多站点聚合搜索阅读小说、漫画。包含JS规则解析库和VSCode插件。支持本地小说 TXT、EPUB",
"icon": "resources/icon.png",
"version": "1.3.3",
"version": "1.3.5",
"publisher": "aooiu",
"qna": "https://github.com/aooiuu/any-reader/issues",
"bugs": {
Expand Down Expand Up @@ -43,14 +43,16 @@
],
"main": "./dist/extension.js",
"scripts": {
"build": "vsce package --no-dependencies",
"vscode:prepublish": "yarn run package",
"build:rename": "esno ./scripts/publish.cjs",
"build:vsce": "vsce package --no-dependencies",
"build": "npm-run-all build:rename build:vsce",
"vscode:prepublish": "pnpm run package",
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "yarn run compile-tests && yarn run compile && yarn run lint",
"pretest": "pnpm run compile-tests && pnpm run compile && pnpm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
Expand Down Expand Up @@ -208,6 +210,8 @@
}
},
"devDependencies": {
"@any-reader/core": "workspace:*",
"@any-reader/shared": "workspace:*",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^7.2.0",
"@types/mocha": "^9.1.1",
Expand All @@ -216,24 +220,23 @@
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"@vscode/test-electron": "^2.1.5",
"bufferutil": "^4.0.8",
"easy-post-message": "^0.1.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"execa": "^8.0.1",
"explorer-opener": "^1.0.1",
"fs-extra": "^11.1.1",
"glob": "^8.0.3",
"mocha": "^10.0.0",
"prettier": "^2.7.1",
"qs": "^6.12.1",
"ts-loader": "^9.3.1",
"typescript": "^4.7.4",
"utf-8-validate": "^6.0.4",
"uuid": "^9.0.1",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@any-reader/core": "workspace:*",
"@any-reader/shared": "workspace:*",
"easy-post-message": "^0.1.0",
"explorer-opener": "^1.0.1",
"fs-extra": "^11.1.1",
"qs": "^6.12.1",
"uuid": "^9.0.1"
}
}
14 changes: 14 additions & 0 deletions packages/vscode/scripts/publish.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { dirname, join } = require('path');
const fs = require('fs-extra');

const root = dirname(__dirname);

async function publish() {
const pkgPath = join(root, 'package.json');
const rawJSON = await fs.readFile(pkgPath, 'utf-8');
const pkg = JSON.parse(rawJSON);
pkg.name = 'any-reader';
await fs.writeJSON(pkgPath, pkg, { spaces: 2 });
}

publish();
Loading

0 comments on commit f8512ea

Please sign in to comment.