Skip to content

feat: config.js をビルドから除外する#5005

Open
uni-kakurenbo wants to merge 3 commits intomasterfrom
feat/remove-config-js
Open

feat: config.js をビルドから除外する#5005
uni-kakurenbo wants to merge 3 commits intomasterfrom
feat/remove-config-js

Conversation

@uni-kakurenbo
Copy link
Contributor

@uni-kakurenbo uni-kakurenbo commented Dec 31, 2025

概要

なぜこの PR を入れたいのか

closes: #4796

@github-actions
Copy link

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.98%. Comparing base (a5feecc) to head (c5a9e4c).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5005      +/-   ##
==========================================
+ Coverage   60.81%   60.98%   +0.16%     
==========================================
  Files         101      101              
  Lines        2973     2973              
  Branches      616      616              
==========================================
+ Hits         1808     1813       +5     
+ Misses       1071     1063       -8     
- Partials       94       97       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes config.js from the build process, requiring it to be mounted externally when deploying with Docker. The change introduces TypeScript type definitions and JSON schema for configuration validation, and adds automated schema generation via GitHub Actions.

  • Removed public/config.js from the repository and excluded it from build artifacts via a custom Vite plugin
  • Added config.d.ts TypeScript definitions and config.schema.json for configuration validation
  • Updated Docker deployment to require external mounting of config.js with validation in the startup script

Reviewed changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vite.config.ts Added Rollup plugin to exclude config.js from build output
tsconfig.json Included config.d.ts in TypeScript compilation
tests/unit/tsconfig.json Included config.d.ts for unit tests
public/config.js Removed configuration file from repository (143 lines deleted)
package.json Added ts-json-schema-generator dependency for schema generation
package-lock.json Updated lock file with new dependency and transitive dependencies
config.schema.json Added JSON schema for configuration validation (134 lines)
config.d.ts Added TypeScript type definitions for Config interface (118 lines)
build/docker/startup.sh Added validation check to ensure config.js is mounted at startup
Dockerfile Removed config.js from default files as it's now externally injected
README.md Added Docker deployment documentation requiring config.js mounting
.github/workflows/generate-schema.yml Added automated workflow to regenerate schema from TypeScript definitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@uni-kakurenbo uni-kakurenbo force-pushed the feat/remove-config-js branch 2 times, most recently from ecf7ce5 to 768d51d Compare January 1, 2026 06:10
@uni-kakurenbo uni-kakurenbo force-pushed the feat/remove-config-js branch from 768d51d to c5a9e4c Compare January 1, 2026 06:13
@uni-kakurenbo uni-kakurenbo self-assigned this Jan 1, 2026
ENV THEME_COLOR=#0D67EA

# 設定上書き処理用に、.brを消して、元の設定を別のディレクトリに保存しておく
# config.js は外部から注入されるため除外
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] これって breaking change はあります?(このままアップデートかけても壊れない?)

というか config.js は消すと fork 先がまずかったりする?もしかして(ちゃんと想像がついてないけど) 特に ex とかで困る可能性があるから、どういう対応が必要になるかが分かるような資料は必要になるかも (理想はそのままアップデートかけてもなにも問題がない状態)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manifest 側の対応が済んでいれば壊れることはないはずですが、fork は何もしないと確実に動かなくなると思います。
ちょっと考えてみます


if [ ! -f /app/override/config.js ]; then
echo "ERROR: config.js is not mounted at /app/override/config.js"
echo "Please mount config.js when starting the container:"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imo] README.md に誘導する文言入れてあげてほしいかも

CACHE_KEY=$(md5sum /usr/share/caddy/new-relic.js | cut -d ' ' -f 1)
mv /usr/share/caddy/new-relic.js /usr/share/caddy/new-relic-$CACHE_KEY.js
sed -i -e "s/<!-- <script src=\"\/new-relic-{hash}.js\"><\/script> -->/<script src=\"\/new-relic-$CACHE_KEY.js\"><\/script>/" /usr/share/caddy/index.html
echo "Startup: set up New Relic"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なんか format がかかっちゃってる?理由がなければ戻してほしいかも

on:
push:
branches:
- master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[imo] できれば master で push する前に PR のタイミングで生成してもらう(自動テストで diff ないかチェックしてあったら落とす) の方が、 master で変なデータが挟まる可能性がなくて良い気がする

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

たしかにです
そうします


cp "${CONFIG_SOURCE_PATH}" "${CONFIG_DIST_PATH}"
else
echo "config.js not found, downloading from manifest repository..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] これ echo で出力する理由ってある? なんか 気持ち的には debug レベルの出力( = 普通はなくていい)な気がしちゃう

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

手癖で書いてしまいました
私もいらないと思います

@@ -0,0 +1,13 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback よりなんか default config として使えるといいかも

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

たしかにです
薄いほうがいいとは思うのですが、どうしましょう……?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

今の内容で default config を作ってしまえば良いと思います!元々のゴールは conflict 防止なので、別に最悪そこまで薄くなくても良い

Copy link
Member

@ras0q ras0q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue立てて全然動向を終えてなくてすみません。
問題が複雑になっていそうな気がします。
現状の public/config.js ($schema付きJSONでいいのは間違いないが時すでに遅し) をどこでも動くようにfallbackのものにして、各環境でDockerでマウント or フォークで直接書き換えだけだと足りないですかね?

@uni-kakurenbo
Copy link
Contributor Author

issue立てて全然動向を終えてなくてすみません。 問題が複雑になっていそうな気がします。 現状の public/config.js ($schema付きJSONでいいのは間違いないが時すでに遅し) をどこでも動くようにfallbackのものにして、各環境でDockerでマウント or フォークで直接書き換えだけだと足りないですかね?

改めて考えるとたしかにそうですね、なんか勘違いしていた気がします
override する機能は既にあるので文字通り薄くすればいいだけでした

@ras0q
Copy link
Member

ras0q commented Jan 9, 2026

今更知ったんですが既に/app/overrideにvolumeするだけで上書きできるようになってたんですね #2145
OSSとしてのtraPtitech/traQにq.trap.jp用の設定が書いてあるのは好ましくないですが、#4796 で書いたmergeするたびにconflictは既に避けられるようになっていたのか、、、

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

デフォルトのconfig.jsを薄くする

4 participants