Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.

Commit 190becb

Browse files
committed
platform support
1 parent cca8a35 commit 190becb

File tree

6 files changed

+244
-130
lines changed

6 files changed

+244
-130
lines changed

RELEASE.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,25 @@ npm install
2323

2424
# ビルドスクリプトを実行
2525
npm run build # TypeScriptのビルド
26-
node scripts/sea.js # SEAバイナリの生成
26+
27+
# macOS向けビルド
28+
node scripts/sea-mac.js
29+
30+
# Windows向けビルド
31+
node scripts/sea-windows.js
2732
```
2833

29-
ビルドが成功すると、`dist`ディレクトリに以下のファイルが生成されます:
30-
- `backlog-sea` - 実行可能なSEAバイナリ
31-
- `backlog-sea.blob` - SEAブロブファイル
34+
ビルドが成功すると、以下のディレクトリとファイルが生成されます:
35+
36+
#### macOS向け(`dist/macos`ディレクトリ)
37+
- `advanced-backlog-mcp` - macOS用実行可能なSEAバイナリ
38+
- `advanced-backlog-mcp.blob` - SEAブロブファイル
39+
- `sea-bundle.js` - バンドルされたJavaScriptファイル
40+
- `sea-config.json` - SEA設定ファイル
41+
42+
#### Windows向け(`dist/windows`ディレクトリ)
43+
- `advanced-backlog-mcp.exe` - Windows用実行可能なSEAバイナリ
44+
- `advanced-backlog-mcp.blob` - SEAブロブファイル
3245
- `sea-bundle.js` - バンドルされたJavaScriptファイル
3346
- `sea-config.json` - SEA設定ファイル
3447

@@ -57,8 +70,9 @@ git push origin vX.Y.Z
5770
4. 作成したタグを選択(例:`vX.Y.Z`
5871
5. リリースタイトルを入力(例:「Backlog v1.0.0」)
5972
6. リリースノートを記入(変更点や新機能などを説明)
60-
7. `dist/backlog-sea`ファイルをドラッグ&ドロップしてアップロード
61-
- macOS用とWindows用に別々のバイナリを用意する場合は、ファイル名を変更(例:`backlog-sea-macos``backlog-sea-win.exe`
73+
7. ビルドされたバイナリをドラッグ&ドロップしてアップロード
74+
- macOS用: `dist/macos/advanced-backlog-mcp`
75+
- Windows用: `dist/windows/advanced-backlog-mcp.exe`
6276
8. 「Publish release」ボタンをクリック
6377

6478
## ユーザーのインストール方法
@@ -67,25 +81,11 @@ git push origin vX.Y.Z
6781

6882
### macOSユーザー向け
6983

70-
```bash
71-
# リリースページからダウンロードしたバイナリを実行可能にする
72-
chmod +x backlog-sea
73-
74-
# PATHの通ったディレクトリに移動(オプション)
75-
sudo mv backlog-sea /usr/local/bin/backlog
76-
77-
# 実行
78-
backlog
79-
```
84+
TBD
8085

8186
### Windowsユーザー向け
8287

83-
```
84-
1. リリースページからbacklog-sea-win.exeをダウンロード
85-
2. 任意のディレクトリに保存
86-
3. コマンドプロンプトまたはPowerShellから実行
87-
> path\to\backlog-sea-win.exe
88-
```
88+
TBD
8989

9090
## リリース自動化(オプション)
9191

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"scripts": {
1414
"build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
1515
"prepare": "npm run build",
16+
"build:sea:mac": "npm run build && node scripts/sea-mac.js",
17+
"build:sea:win": "npm run build && node scripts/sea-windows.js",
18+
"build:sea": "npm run build && node scripts/sea-mac.js && node scripts/sea-windows.js",
1619
"watch": "tsc --watch",
1720
"inspector": "npx @modelcontextprotocol/inspector build/index.js",
1821
"test": "vitest run",

scripts/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Single Executable Application (SEA) ビルド手順
2+
3+
このディレクトリには、Backlog MCPサーバーをNode.jsの[Single Executable Application (SEA)](https://nodejs.org/api/single-executable-applications.html)機能を使用して単一の実行可能ファイルにビルドするためのスクリプトが含まれています。
4+
5+
## 前提条件
6+
7+
- Node.js v21.0.0以上がインストールされていること
8+
- 必要な依存パッケージ:`esbuild``postject`(package.jsonのdevDependenciesに追加するか、直接インストール)
9+
- macOSユーザーは`codesign`ツールが使用可能であること(標準でインストール済み)
10+
- 標準ビルド(`npm run build`)が完了していること
11+
12+
## スクリプトの説明
13+
14+
このディレクトリには以下のスクリプトが含まれています:
15+
16+
- `sea-mac.js` - macOS環境でSEAをビルドするためのスクリプト
17+
- `sea-windows.js` - Windows環境でSEAをビルドするためのスクリプト
18+
19+
## 使用方法
20+
21+
### macOS環境での実行
22+
23+
```bash
24+
# まず標準ビルドを実行
25+
npm run build
26+
27+
# macOS用実行ファイルを生成
28+
node ./scripts/sea-mac.js
29+
```
30+
31+
### Windows環境での実行
32+
33+
```bash
34+
# まず標準ビルドを実行
35+
npm run build
36+
37+
# Windows用実行ファイルを生成
38+
node ./scripts/sea-windows.js
39+
```
40+
41+
## 生成されるファイル
42+
43+
ビルドプロセスが完了すると、以下のファイルが`dist`ディレクトリに生成されます:
44+
45+
- macOS: `backlog-sea` (実行ファイル)
46+
- Windows: `backlog-sea.exe` (実行ファイル)
47+
48+
## package.jsonへの追加例
49+
50+
以下のようにpackage.jsonのscriptsセクションに追加することで、npm経由で実行できるようになります:
51+
52+
```json
53+
"scripts": {
54+
"build:sea:mac": "node ./scripts/sea-mac.js",
55+
"build:sea:win": "node ./scripts/sea-windows.js"
56+
}
57+
```
58+
59+
## 参考
60+
61+
- [Node.js Single Executable Applications ドキュメント](https://nodejs.org/api/single-executable-applications.html)
62+
- [MCPサーバーをexeにする記事](https://qiita.com/moritalous/items/6e02bcbf976d2e0c43d6)

scripts/sea-mac.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// sea-mac.js - macOS用SEAビルドスクリプト
2+
import { execSync } from 'child_process';
3+
import fs from 'fs';
4+
import path from 'path';
5+
import esbuild from 'esbuild';
6+
7+
// SEA設定
8+
const SEA_CONFIG = {
9+
main: './dist/macos/sea-bundle.js',
10+
output: './dist/macos/advanced-backlog-mcp.blob',
11+
executableName: 'advanced-backlog-mcp',
12+
};
13+
14+
// ビルドステップ
15+
async function buildSEAMac() {
16+
console.log('🚀 macOS向けSEAビルドを開始します...');
17+
18+
// ディレクトリ作成
19+
if (!fs.existsSync('./dist')) {
20+
fs.mkdirSync('./dist', { recursive: true });
21+
}
22+
if (!fs.existsSync('./dist/macos')) {
23+
fs.mkdirSync('./dist/macos', { recursive: true });
24+
}
25+
26+
// 1. esbuildでアプリケーションをバンドル(CommonJS形式に変換)
27+
console.log('📦 アプリケーションをバンドルしています...');
28+
await esbuild.build({
29+
entryPoints: ['./build/index.js'],
30+
bundle: true,
31+
platform: 'node',
32+
target: 'node16',
33+
outfile: SEA_CONFIG.main,
34+
format: 'cjs',
35+
});
36+
37+
console.log('✅ バンドル完了');
38+
39+
// 2. SEA設定ファイル生成
40+
console.log('📝 SEA設定ファイルを生成しています...');
41+
const seaConfigJSON = {
42+
main: SEA_CONFIG.main,
43+
output: SEA_CONFIG.output,
44+
};
45+
fs.writeFileSync('./dist/macos/sea-config.json', JSON.stringify(seaConfigJSON, null, 2));
46+
console.log('✅ SEA設定ファイル生成完了');
47+
48+
// 3. SEAブロブ生成
49+
console.log('🔧 SEAブロブを生成しています...');
50+
execSync('node --experimental-sea-config ./dist/macos/sea-config.json', { stdio: 'inherit' });
51+
console.log('✅ SEAブロブ生成完了');
52+
53+
// 4. Node.jsバイナリをコピー
54+
console.log('📋 Node.jsバイナリをコピーしています...');
55+
const destPath = `./dist/macos/${SEA_CONFIG.executableName}`;
56+
execSync(`cp $(command -v node) ${destPath}`, { stdio: 'inherit' });
57+
console.log('✅ バイナリコピー完了');
58+
59+
// 5. 署名を削除
60+
console.log('🔑 バイナリの署名を削除しています...');
61+
execSync(`codesign --remove-signature ${destPath}`, { stdio: 'inherit' });
62+
console.log('✅ 署名削除完了');
63+
64+
// 6. ブロブを注入
65+
console.log('💉 SEAブロブを注入しています...');
66+
execSync(`npx postject ${destPath} NODE_SEA_BLOB ${SEA_CONFIG.output} --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 --macho-segment-name NODE_SEA`, { stdio: 'inherit' });
67+
console.log('✅ ブロブ注入完了');
68+
69+
// 7. 再署名
70+
console.log('🔑 バイナリに再署名しています...');
71+
execSync(`codesign --sign - ${destPath}`, { stdio: 'inherit' });
72+
console.log('✅ 再署名完了');
73+
74+
// 8. 実行権限を付与
75+
console.log('🔒 実行権限を付与しています...');
76+
execSync(`chmod +x ${destPath}`, { stdio: 'inherit' });
77+
console.log('✅ 権限設定完了');
78+
79+
console.log(`🎉 macOS向けSEAビルドが完了しました! 実行ファイル: ${destPath}`);
80+
}
81+
82+
buildSEAMac().catch(err => {
83+
console.error('❌ SEAビルドエラー:', err);
84+
process.exit(1);
85+
});

scripts/sea-windows.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// sea-windows.js - Windows用SEAビルドスクリプト
2+
import { execSync } from 'child_process';
3+
import fs from 'fs';
4+
import path from 'path';
5+
import esbuild from 'esbuild';
6+
7+
// SEA設定
8+
const SEA_CONFIG = {
9+
main: './dist/windows/sea-bundle.js',
10+
output: './dist/windows/advanced-backlog-mcp.blob',
11+
executableName: 'advanced-backlog-mcp.exe',
12+
};
13+
14+
// ビルドステップ
15+
async function buildSEAWindows() {
16+
console.log('🚀 Windows向けSEAビルドを開始します...');
17+
18+
// ディレクトリ作成
19+
if (!fs.existsSync('./dist')) {
20+
fs.mkdirSync('./dist', { recursive: true });
21+
}
22+
if (!fs.existsSync('./dist/windows')) {
23+
fs.mkdirSync('./dist/windows', { recursive: true });
24+
}
25+
26+
// 1. esbuildでアプリケーションをバンドル(CommonJS形式に変換)
27+
console.log('📦 アプリケーションをバンドルしています...');
28+
await esbuild.build({
29+
entryPoints: ['./build/index.js'],
30+
bundle: true,
31+
platform: 'node',
32+
target: 'node16',
33+
outfile: SEA_CONFIG.main,
34+
format: 'cjs',
35+
});
36+
console.log('✅ バンドル完了');
37+
38+
// 2. SEA設定ファイル生成
39+
console.log('📝 SEA設定ファイルを生成しています...');
40+
const seaConfigJSON = {
41+
main: SEA_CONFIG.main,
42+
output: SEA_CONFIG.output,
43+
};
44+
fs.writeFileSync('./dist/windows/sea-config.json', JSON.stringify(seaConfigJSON, null, 2));
45+
console.log('✅ SEA設定ファイル生成完了');
46+
47+
// 3. SEAブロブ生成
48+
console.log('🔧 SEAブロブを生成しています...');
49+
execSync('node --experimental-sea-config ./dist/windows/sea-config.json', { stdio: 'inherit' });
50+
console.log('✅ SEAブロブ生成完了');
51+
52+
// 4. Node.jsバイナリをコピー
53+
console.log('📋 Node.jsバイナリをコピーしています...');
54+
const destPath = `./dist/windows/${SEA_CONFIG.executableName}`;
55+
// バックスラッシュをエスケープして、Node.js内で正しく解釈されるようにする
56+
const normalizedPath = destPath.replace(/\\/g, '\\\\');
57+
execSync(`node -e "require('fs').copyFileSync(process.execPath, '${normalizedPath}')"`, { stdio: 'inherit' });
58+
console.log('✅ バイナリコピー完了');
59+
60+
// 5. ブロブを注入
61+
console.log('💉 SEAブロブを注入しています...');
62+
// パスを引用符で囲む(スペースがあっても正しく処理されるように)
63+
execSync(`npx postject "${destPath}" NODE_SEA_BLOB "${SEA_CONFIG.output}" --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2`, { stdio: 'inherit' });
64+
console.log('✅ ブロブ注入完了');
65+
66+
console.log(`🎉 Windows向けSEAビルドが完了しました! 実行ファイル: ${destPath}`);
67+
}
68+
69+
buildSEAWindows().catch(err => {
70+
console.error('❌ SEAビルドエラー:', err);
71+
process.exit(1);
72+
});

0 commit comments

Comments
 (0)