Skip to content

Commit 40189c7

Browse files
Initial Commit (#1)
Co-authored-by: Hiroshiba <[email protected]>
1 parent 2597a33 commit 40189c7

22 files changed

+5009
-0
lines changed

.env.example

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# GitHub AppsのID
2+
APP_ID=
3+
# GitHub AppsのクライアントID
4+
CLIENT_ID=
5+
# GitHub Appsのクライアントシークレット
6+
CLIENT_SECRET=

.eslintrc.cjs

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
const vueEslintParser = "vue-eslint-parser";
2+
const vueEslintParserOptions = {
3+
ecmaVersion: 2020,
4+
parser: "@typescript-eslint/parser",
5+
};
6+
const tsEslintOptions = {
7+
project: ["./tsconfig.app.json", "./tsconfig.node.json"],
8+
tsconfigRootDir: __dirname,
9+
};
10+
11+
const tsEslintRules = {
12+
// Storeでよくasyncなしの関数を定義するので無効化
13+
// TODO: いずれは有効化する
14+
"@typescript-eslint/require-await": "off",
15+
16+
"@typescript-eslint/no-misused-promises": [
17+
"error",
18+
{
19+
// (...) => voidに(...) => Promise<void>を渡すのは許可
20+
// ただし特に強い意志でこれを許可しているわけではないので、
21+
// もし問題が発生した場合は有効化する
22+
// ref: https://canary.discord.com/channels/879570910208733277/893889888208977960/1267467454876225536
23+
checksVoidReturn: false,
24+
},
25+
],
26+
};
27+
28+
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.ConfigType} */
29+
module.exports = {
30+
root: true,
31+
env: {
32+
node: true,
33+
},
34+
extends: [
35+
"plugin:vue/vue3-recommended",
36+
"eslint:recommended",
37+
"@vue/typescript/recommended",
38+
"@vue/prettier",
39+
"@vue/eslint-config-typescript/recommended",
40+
"@vue/eslint-config-prettier",
41+
],
42+
plugins: ["import"],
43+
parser: vueEslintParser,
44+
parserOptions: vueEslintParserOptions,
45+
ignorePatterns: ["dist/**/*", "node_modules/**/*"],
46+
rules: {
47+
"linebreak-style":
48+
process.env.NODE_ENV === "production" && process.platform !== "win32"
49+
? ["error", "unix"]
50+
: "off",
51+
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
52+
"no-constant-condition": ["error", { checkLoops: false }], // while(true) などを許可
53+
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
54+
"prettier/prettier": [
55+
"error",
56+
{
57+
endOfLine: "auto",
58+
},
59+
],
60+
"vue/no-restricted-syntax": [
61+
"error",
62+
{
63+
selector: "LogicalExpression[operator=??]",
64+
message: `template内で"??"を使うとgithubのsyntax highlightが崩れるので\n三項演算子等を使って書き換えてください`,
65+
},
66+
{
67+
selector: "MemberExpression[optional=true]",
68+
message: `template内で"?."を使うとgithubのsyntax highlightが崩れるので\n三項演算子等を使って書き換えてください`,
69+
},
70+
],
71+
"@typescript-eslint/no-unused-vars": [
72+
process.env.NODE_ENV === "development" ? "warn" : "error", // 開発時のみwarn
73+
{
74+
ignoreRestSiblings: true,
75+
},
76+
],
77+
"vue/attribute-hyphenation": ["error", "never"],
78+
"vue/v-on-event-hyphenation": ["error", "never", { autofix: true }],
79+
"vue/v-bind-style": ["error", "shorthand", { sameNameShorthand: "always" }],
80+
"vue/component-name-in-template-casing": [
81+
"error",
82+
"PascalCase",
83+
{
84+
registeredComponentsOnly: false,
85+
ignores: [],
86+
},
87+
],
88+
"vue/component-tags-order": [
89+
"error",
90+
{
91+
order: ["template", "script", "style"],
92+
},
93+
],
94+
"vue/multi-word-component-names": [
95+
"error",
96+
{
97+
ignores: ["Container", "Presentation"],
98+
},
99+
],
100+
"import/order": "error",
101+
},
102+
overrides: [
103+
{
104+
files: ["*.ts", "*.mts"],
105+
parser: "@typescript-eslint/parser",
106+
extends: ["plugin:@typescript-eslint/recommended-type-checked"],
107+
parserOptions: tsEslintOptions,
108+
rules: tsEslintRules,
109+
},
110+
{
111+
files: ["*.vue"],
112+
parser: vueEslintParser,
113+
parserOptions: { ...vueEslintParserOptions, ...tsEslintOptions },
114+
extends: ["plugin:@typescript-eslint/recommended-type-checked"],
115+
rules: {
116+
...tsEslintRules,
117+
118+
// typescript-eslintにVueの型がanyとして認識されるので無効化
119+
"@typescript-eslint/no-unsafe-member-access": "off",
120+
"@typescript-eslint/no-unsafe-call": "off",
121+
"@typescript-eslint/no-unsafe-assignment": "off",
122+
"@typescript-eslint/no-unsafe-argument": "off",
123+
"@typescript-eslint/no-unsafe-return": "off",
124+
"@typescript-eslint/no-redundant-type-constituents": "off",
125+
},
126+
},
127+
],
128+
};

.github/workflows/update_pages.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "Update Pages"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: "pages"
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
jobs:
18+
update_pages:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Install pnpm
25+
run: corepack enable
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: "20"
31+
cache: "pnpm"
32+
33+
- name: Install Dependencies
34+
run: |
35+
pnpm install
36+
37+
- name: Build Pages
38+
run: |
39+
pnpm run collect
40+
41+
pnpm run build --base /preview-pages
42+
env:
43+
APP_ID: ${{ secrets.APP_ID }}
44+
CLIENT_ID: ${{ secrets.CLIENT_ID }}
45+
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
46+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
47+
48+
- name: Setup Pages
49+
uses: actions/configure-pages@v4
50+
51+
- name: Upload artifact
52+
uses: actions/upload-pages-artifact@v3
53+
with:
54+
path: "./dist"
55+
56+
- name: Deploy to GitHub Pages
57+
id: deployment
58+
uses: actions/deploy-pages@v4

.gitignore

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
private-key.pem
27+
public/preview/*
28+
!public/preview/.gitkeep

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@jsr:registry=https://npm.jsr.io

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 VOICEVOX
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# VOICEVOX Preview Pages
2+
3+
[voicevox/voicevox](https://github.com/voicevox/voicevox) のプレビューページを提供するためのリポジトリです。
4+
対象ブランチ:
5+
6+
- `main`
7+
- `project-*`
8+
- プルリクエスト
9+
10+
## 動かす
11+
12+
1. GitHub Appsを作成します。
13+
14+
権限は以下の通りです:
15+
16+
- Pull requests:Read & write
17+
18+
### Actionsで動かす
19+
20+
2. 作成したGitHub Appsの`Private key`を取得し、リポジトリの`Settings` > `Secrets``PRIVATE_KEY`として保存します。
21+
3. `.env.example` の内容をリポジトリの`Settings` > `Secrets` にキーごとに保存します。
22+
23+
### ローカルで動かす
24+
25+
2. 作成したGitHub Appsの`Private key`を取得し、`private-key.pem`として保存します。
26+
3. `.env.example` をコピーして `.env` を作成します。内容はコメントを参照してください。
27+
28+
## 仕組み
29+
30+
```mermaid
31+
sequenceDiagram
32+
actor user as ユーザー
33+
participant editor_fork as ユーザー/voicevox(フォーク)
34+
participant editor_main as voicevox/voicevox(main)
35+
participant preview_pages as voicevox/preview_pages
36+
37+
user->>editor_fork: PRを出す
38+
39+
note over editor_fork: ビルドを開始する
40+
activate editor_fork
41+
42+
user-->>editor_main: pull_request_targetが発火する
43+
editor_main->>+preview_pages: update_pages.ymlを発火させる
44+
45+
loop
46+
preview_pages->>editor_fork: Jobの終了を問い合わせる
47+
editor_fork->>preview_pages:
48+
end
49+
50+
note over editor_fork: ビルドが完了する
51+
deactivate editor_fork
52+
preview_pages->>editor_fork: Artifactをダウンロードする
53+
editor_fork->>preview_pages:
54+
55+
note over preview_pages: Pagesにデプロイする
56+
deactivate preview_pages
57+
```
58+
59+
## ライセンス
60+
61+
[LICENSE](LICENSE) を参照してください。

index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="ja">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Voicevox Preview</title>
7+
</head>
8+
<body>
9+
<div id="app"></div>
10+
<script type="module" src="/src/main.ts"></script>
11+
</body>
12+
</html>

package.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "editor-preview",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"packageManager": "[email protected]",
7+
"scripts": {
8+
"lint": "eslint --ext .js,.vue,.ts,.mts *.config.* src scripts",
9+
"fmt": "eslint --ext .js,.vue,.ts,.mts *.config.* src scripts --fix",
10+
"collect": "tsx scripts/collect.ts",
11+
"dev": "vite",
12+
"build": "vue-tsc -b && vite build",
13+
"preview": "vite preview"
14+
},
15+
"dependencies": {
16+
"@core/asyncutil": "npm:@jsr/[email protected]",
17+
"@logtape/logtape": "0.7.1",
18+
"element-plus": "2.8.7",
19+
"vue": "3.5.12"
20+
},
21+
"devDependencies": {
22+
"@octokit/plugin-paginate-rest": "11.3.5",
23+
"@octokit/types": "13.6.1",
24+
"@types/node": "22.9.0",
25+
"@types/unzip-stream": "0.3.4",
26+
"@typescript-eslint/eslint-plugin": "7.15.0",
27+
"@typescript-eslint/parser": "7.15.0",
28+
"@typescript-eslint/types": "7.15.0",
29+
"@typescript-eslint/utils": "7.15.0",
30+
"@vitejs/plugin-vue": "5.1.4",
31+
"@vue/eslint-config-prettier": "9.0.0",
32+
"@vue/eslint-config-typescript": "13.0.0",
33+
"dotenv": "16.4.5",
34+
"eslint": "8.57.1",
35+
"eslint-config-prettier": "9.1.0",
36+
"eslint-plugin-import": "2.29.1",
37+
"eslint-plugin-prettier": "5.1.3",
38+
"eslint-plugin-vue": "9.26.0",
39+
"octokit": "4.0.2",
40+
"prettier": "3.2.5",
41+
"sass-embedded": "1.80.6",
42+
"tsx": "4.19.2",
43+
"typescript": "5.6.2",
44+
"unzip-stream": "0.3.4",
45+
"vite": "5.4.10",
46+
"vue-tsc": "2.1.8"
47+
}
48+
}

0 commit comments

Comments
 (0)