tsbuild 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tsbuild-1.0.0/.github/workflows/publish.yml +29 -0
- tsbuild-1.0.0/.gitignore +5 -0
- tsbuild-1.0.0/PKG-INFO +143 -0
- tsbuild-1.0.0/README.md +125 -0
- tsbuild-1.0.0/install.ps1 +205 -0
- tsbuild-1.0.0/pyproject.toml +28 -0
- tsbuild-1.0.0/tsbuild/__init__.py +1 -0
- tsbuild-1.0.0/tsbuild/__main__.py +171 -0
- tsbuild-1.0.0/version.txt +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build-and-publish:
|
|
9
|
+
name: Build and publish to PyPI
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.x"
|
|
21
|
+
|
|
22
|
+
- name: Install hatch
|
|
23
|
+
run: pip install hatch
|
|
24
|
+
|
|
25
|
+
- name: Build package
|
|
26
|
+
run: hatch build
|
|
27
|
+
|
|
28
|
+
- name: Publish to PyPI
|
|
29
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
tsbuild-1.0.0/.gitignore
ADDED
tsbuild-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tsbuild
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Bun + TypeScript 開発サーバーをホットリロード付きで1コマンド起動するツール
|
|
5
|
+
Project-URL: Homepage, https://github.com/Lapius7/tsbuild
|
|
6
|
+
Project-URL: Issues, https://github.com/Lapius7/tsbuild/issues
|
|
7
|
+
Author-email: Lapius7 <me@lapius7.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: bun,cli,dev-server,hot-reload,typescript
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# tsbuild
|
|
20
|
+
|
|
21
|
+
`tssetup` で構築した Bun + TypeScript プロジェクトにおいて、開発サーバーの起動・TypeScript の自動ビルド・ブラウザのホットリロードを1コマンドで一元管理する開発支援ツールです。
|
|
22
|
+
|
|
23
|
+
## 🚀 特徴
|
|
24
|
+
|
|
25
|
+
- **1コマンド起動:** ローカルWebサーバー起動・ブラウザ自動起動・TS監視ビルドをすべて開始します。
|
|
26
|
+
- **ポート衝突の自動回避:** デフォルトの 53000 番ポートが使用中の場合、空いているポートを自動で探します。
|
|
27
|
+
- **404エラー防止:** 起動と同時に初回コンパイルを実行し、ブラウザ起動直後の404エラーを防ぎます。
|
|
28
|
+
- **ホットリロード:** `src/` 内のコード変更や `index.html` の編集を検知し、ブラウザを自動でリロードします。
|
|
29
|
+
- **ゾンビプロセス防止:** `Ctrl + C` で終了した際に、バックグラウンドの Bun サーバーを自動停止・クリーンアップします。
|
|
30
|
+
- **自動バージョン確認:** 実行時に最新バージョンを確認し、更新がある場合は通知します。
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 🛠️ インストール方法
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install tsbuild
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> [!NOTE]
|
|
41
|
+
>
|
|
42
|
+
> - PowerShell・CMD・Windows Terminal どれからでも使えます。
|
|
43
|
+
> - 動作には **Python 3.9+** と **Bun** が必要です。
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ⚙️ 動作に必要な環境(依存関係)
|
|
48
|
+
|
|
49
|
+
| ツール | 用途 | インストール |
|
|
50
|
+
| :--- | :--- | :--- |
|
|
51
|
+
| **Python 3.9+** | tsbuild 本体の実行 | [python.org](https://www.python.org/) |
|
|
52
|
+
| **Bun** | 開発サーバー起動・TSコンパイル | `powershell -c "irm bun.sh/install.ps1 \| iex"` |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## ⚡ 使い方
|
|
57
|
+
|
|
58
|
+
`tssetup` で構築したプロジェクトのルートディレクトリ(`package.json` と `server.ts` があるフォルダ)で実行します。
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
tsbuild
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
プロジェクト外(`package.json` / `server.ts` がないディレクトリ)で実行するとバージョン情報・インフォ画面が表示されます。
|
|
65
|
+
|
|
66
|
+
### パラメータ
|
|
67
|
+
|
|
68
|
+
| パラメータ | 短縮形 | 説明 |
|
|
69
|
+
| :--- | :--- | :--- |
|
|
70
|
+
| `--version` | `-v` | バージョンを表示 |
|
|
71
|
+
| `--help` | `-h` | ヘルプを表示 |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 📁 対象プロジェクトの構成
|
|
76
|
+
|
|
77
|
+
`tsbuild` は `tssetup` で作成した以下の構成を前提としています。
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
my-app/
|
|
81
|
+
├── src/
|
|
82
|
+
│ └── index.ts ← 編集対象の TypeScript ファイル
|
|
83
|
+
├── dist/ ← tsc が自動生成する JS 出力先
|
|
84
|
+
├── index.html ← フロントエンドの HTML
|
|
85
|
+
├── server.ts ← tsbuild が起動する Bun サーバー
|
|
86
|
+
├── tsconfig.json ← TypeScript コンパイラ設定
|
|
87
|
+
└── package.json ← Bun プロジェクト設定
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 🚀 プロジェクトの始め方
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# 1. プロジェクトを作成(カレントディレクトリが自動で移動)
|
|
96
|
+
tssetup my-app
|
|
97
|
+
|
|
98
|
+
# 2. 開発サーバーを起動
|
|
99
|
+
tsbuild
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## コマンド実行時の挙動
|
|
105
|
+
|
|
106
|
+
1. **ポート自動探索** — `53000` 番から順に空きポートを検索してサーバーを起動
|
|
107
|
+
2. **初回ビルド** — `bun x tsc` で初回コンパイルを実行(ブラウザ起動前に JS を生成)
|
|
108
|
+
3. **ブラウザ自動起動** — `http://localhost:53000`(または自動検出したポート)を開く
|
|
109
|
+
4. **リアルタイム監視** — `bun x tsc --watch` でファイル変更を検知して自動コンパイル
|
|
110
|
+
5. **ホットリロード** — ビルド完了後、WebSocket 経由でブラウザに通知してリロード
|
|
111
|
+
|
|
112
|
+
### 終了方法
|
|
113
|
+
|
|
114
|
+
**`Ctrl + C`** を押すと、バックグラウンドの Bun サーバーを自動停止してクリーンアップします。
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🔄 アップデート
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install --upgrade tsbuild
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## ✉️ 問い合わせ先
|
|
127
|
+
|
|
128
|
+
- **X (旧Twitter):** [@Lapius7](https://x.com/Lapius7)
|
|
129
|
+
- **GitHub Issues:** [Lapius7/tsbuild/issues](https://github.com/Lapius7/tsbuild/issues)
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## ⚠️ 免責事項
|
|
134
|
+
|
|
135
|
+
本ソフトウェアの使用によって生じた直接的・間接的な損害について、作者は一切の責任を負いません。自己責任のもとでご使用ください。
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 📄 ライセンス & コピーライト
|
|
140
|
+
|
|
141
|
+
本プロジェクトは [MIT License](https://opensource.org/licenses/MIT) のもとで公開されています。
|
|
142
|
+
|
|
143
|
+
Copyright (c) 2026 Lapius7
|
tsbuild-1.0.0/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# tsbuild
|
|
2
|
+
|
|
3
|
+
`tssetup` で構築した Bun + TypeScript プロジェクトにおいて、開発サーバーの起動・TypeScript の自動ビルド・ブラウザのホットリロードを1コマンドで一元管理する開発支援ツールです。
|
|
4
|
+
|
|
5
|
+
## 🚀 特徴
|
|
6
|
+
|
|
7
|
+
- **1コマンド起動:** ローカルWebサーバー起動・ブラウザ自動起動・TS監視ビルドをすべて開始します。
|
|
8
|
+
- **ポート衝突の自動回避:** デフォルトの 53000 番ポートが使用中の場合、空いているポートを自動で探します。
|
|
9
|
+
- **404エラー防止:** 起動と同時に初回コンパイルを実行し、ブラウザ起動直後の404エラーを防ぎます。
|
|
10
|
+
- **ホットリロード:** `src/` 内のコード変更や `index.html` の編集を検知し、ブラウザを自動でリロードします。
|
|
11
|
+
- **ゾンビプロセス防止:** `Ctrl + C` で終了した際に、バックグラウンドの Bun サーバーを自動停止・クリーンアップします。
|
|
12
|
+
- **自動バージョン確認:** 実行時に最新バージョンを確認し、更新がある場合は通知します。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🛠️ インストール方法
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install tsbuild
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
> [!NOTE]
|
|
23
|
+
>
|
|
24
|
+
> - PowerShell・CMD・Windows Terminal どれからでも使えます。
|
|
25
|
+
> - 動作には **Python 3.9+** と **Bun** が必要です。
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ⚙️ 動作に必要な環境(依存関係)
|
|
30
|
+
|
|
31
|
+
| ツール | 用途 | インストール |
|
|
32
|
+
| :--- | :--- | :--- |
|
|
33
|
+
| **Python 3.9+** | tsbuild 本体の実行 | [python.org](https://www.python.org/) |
|
|
34
|
+
| **Bun** | 開発サーバー起動・TSコンパイル | `powershell -c "irm bun.sh/install.ps1 \| iex"` |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## ⚡ 使い方
|
|
39
|
+
|
|
40
|
+
`tssetup` で構築したプロジェクトのルートディレクトリ(`package.json` と `server.ts` があるフォルダ)で実行します。
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
tsbuild
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
プロジェクト外(`package.json` / `server.ts` がないディレクトリ)で実行するとバージョン情報・インフォ画面が表示されます。
|
|
47
|
+
|
|
48
|
+
### パラメータ
|
|
49
|
+
|
|
50
|
+
| パラメータ | 短縮形 | 説明 |
|
|
51
|
+
| :--- | :--- | :--- |
|
|
52
|
+
| `--version` | `-v` | バージョンを表示 |
|
|
53
|
+
| `--help` | `-h` | ヘルプを表示 |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 📁 対象プロジェクトの構成
|
|
58
|
+
|
|
59
|
+
`tsbuild` は `tssetup` で作成した以下の構成を前提としています。
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
my-app/
|
|
63
|
+
├── src/
|
|
64
|
+
│ └── index.ts ← 編集対象の TypeScript ファイル
|
|
65
|
+
├── dist/ ← tsc が自動生成する JS 出力先
|
|
66
|
+
├── index.html ← フロントエンドの HTML
|
|
67
|
+
├── server.ts ← tsbuild が起動する Bun サーバー
|
|
68
|
+
├── tsconfig.json ← TypeScript コンパイラ設定
|
|
69
|
+
└── package.json ← Bun プロジェクト設定
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 🚀 プロジェクトの始め方
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# 1. プロジェクトを作成(カレントディレクトリが自動で移動)
|
|
78
|
+
tssetup my-app
|
|
79
|
+
|
|
80
|
+
# 2. 開発サーバーを起動
|
|
81
|
+
tsbuild
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## コマンド実行時の挙動
|
|
87
|
+
|
|
88
|
+
1. **ポート自動探索** — `53000` 番から順に空きポートを検索してサーバーを起動
|
|
89
|
+
2. **初回ビルド** — `bun x tsc` で初回コンパイルを実行(ブラウザ起動前に JS を生成)
|
|
90
|
+
3. **ブラウザ自動起動** — `http://localhost:53000`(または自動検出したポート)を開く
|
|
91
|
+
4. **リアルタイム監視** — `bun x tsc --watch` でファイル変更を検知して自動コンパイル
|
|
92
|
+
5. **ホットリロード** — ビルド完了後、WebSocket 経由でブラウザに通知してリロード
|
|
93
|
+
|
|
94
|
+
### 終了方法
|
|
95
|
+
|
|
96
|
+
**`Ctrl + C`** を押すと、バックグラウンドの Bun サーバーを自動停止してクリーンアップします。
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🔄 アップデート
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pip install --upgrade tsbuild
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## ✉️ 問い合わせ先
|
|
109
|
+
|
|
110
|
+
- **X (旧Twitter):** [@Lapius7](https://x.com/Lapius7)
|
|
111
|
+
- **GitHub Issues:** [Lapius7/tsbuild/issues](https://github.com/Lapius7/tsbuild/issues)
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## ⚠️ 免責事項
|
|
116
|
+
|
|
117
|
+
本ソフトウェアの使用によって生じた直接的・間接的な損害について、作者は一切の責任を負いません。自己責任のもとでご使用ください。
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 📄 ライセンス & コピーライト
|
|
122
|
+
|
|
123
|
+
本プロジェクトは [MIT License](https://opensource.org/licenses/MIT) のもとで公開されています。
|
|
124
|
+
|
|
125
|
+
Copyright (c) 2026 Lapius7
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# 💡 インストールを実行するPowerShellスクリプト
|
|
2
|
+
$functionName = "tsbuild"
|
|
3
|
+
$functionCode = @'
|
|
4
|
+
function tsbuild {
|
|
5
|
+
[CmdletBinding()]
|
|
6
|
+
param (
|
|
7
|
+
[Parameter(Mandatory = $false)][switch]$Help,
|
|
8
|
+
[Parameter(Mandatory = $false)][switch]$Uninstall
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
if ($Uninstall) {
|
|
12
|
+
Write-Host ""
|
|
13
|
+
Write-Host "⚠ tsbuild をアンインストールします。本当によろしいですか? (y/N): " -NoNewline -ForegroundColor Yellow
|
|
14
|
+
$confirm = Read-Host
|
|
15
|
+
if ($confirm -ne "y" -and $confirm -ne "Y") {
|
|
16
|
+
Write-Host "キャンセルしました。" -ForegroundColor DarkGray
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
$profileContent = Get-Content $PROFILE -Raw -ErrorAction SilentlyContinue
|
|
20
|
+
$n = "tsbuild"
|
|
21
|
+
if ($profileContent -match "# <<BEGIN:${n}>>") {
|
|
22
|
+
$profileContent = $profileContent -replace "(?s)`n?# <<BEGIN:${n}>>.*?# <<END:${n}>>", ""
|
|
23
|
+
[System.IO.File]::WriteAllText($PROFILE, $profileContent.Trim(), [System.Text.UTF8Encoding]::new($true))
|
|
24
|
+
Remove-Item Function:tsbuild -ErrorAction SilentlyContinue
|
|
25
|
+
Write-Host "✅ tsbuild をアンインストールしました。" -ForegroundColor Green
|
|
26
|
+
} else {
|
|
27
|
+
Write-Host "⚠ tsbuild はインストールされていません。" -ForegroundColor Yellow
|
|
28
|
+
}
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
$localVersion = "1.0.1"
|
|
33
|
+
$remoteVersion = $null
|
|
34
|
+
try {
|
|
35
|
+
$remoteVersion = (irm https://raw.githubusercontent.com/Lapius7/tsbuild/main/version.txt -TimeoutSec 3 -ErrorAction Stop).Trim()
|
|
36
|
+
if ($remoteVersion -ne $localVersion) {
|
|
37
|
+
Write-Host "🔄 新しいバージョン ($remoteVersion) があります。自動更新しています..." -ForegroundColor Yellow
|
|
38
|
+
irm https://raw.githubusercontent.com/Lapius7/tsbuild/main/install.ps1 | iex
|
|
39
|
+
Write-Host "✅ 更新完了!もう一度コマンドを実行してください。" -ForegroundColor Green
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
} catch {}
|
|
43
|
+
|
|
44
|
+
if (!(Test-Path "package.json") -or !(Test-Path "server.ts")) {
|
|
45
|
+
Write-Host ""
|
|
46
|
+
Write-Host "⚡ tsbuild" -ForegroundColor Cyan -NoNewline; Write-Host " v$localVersion" -ForegroundColor DarkGray
|
|
47
|
+
Write-Host "Bun + TypeScript 開発サーバーをホットリロード付きで1コマンド起動するツール"
|
|
48
|
+
Write-Host ""
|
|
49
|
+
Write-Host "開発者 : " -NoNewline -ForegroundColor Yellow; Write-Host "Lapius7"
|
|
50
|
+
Write-Host "X : " -NoNewline -ForegroundColor Yellow; Write-Host "https://x.com/Lapius7"
|
|
51
|
+
Write-Host "GitHub : " -NoNewline -ForegroundColor Yellow; Write-Host "https://github.com/Lapius7/tsbuild"
|
|
52
|
+
Write-Host ""
|
|
53
|
+
if ($null -ne $remoteVersion) {
|
|
54
|
+
if ($remoteVersion -eq $localVersion) {
|
|
55
|
+
Write-Host "バージョン : $localVersion " -NoNewline; Write-Host "✅ 最新です" -ForegroundColor Green
|
|
56
|
+
} else {
|
|
57
|
+
Write-Host "バージョン : $localVersion " -NoNewline; Write-Host "⬆ 最新: $remoteVersion" -ForegroundColor Yellow
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
Write-Host "バージョン : $localVersion " -NoNewline; Write-Host "(バージョン確認失敗)" -ForegroundColor DarkGray
|
|
61
|
+
}
|
|
62
|
+
Write-Host ""
|
|
63
|
+
Write-Host "使い方 : tssetup でプロジェクトを作成してから、そのフォルダ内で tsbuild を実行してください" -ForegroundColor DarkGray
|
|
64
|
+
Write-Host "ヘルプ : tsbuild -Help" -ForegroundColor DarkGray
|
|
65
|
+
Write-Host ""
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if ($Help) {
|
|
70
|
+
Write-Host "`n⚡ [tsbuild] コマンドヘルプ" -ForegroundColor Cyan
|
|
71
|
+
Write-Host "==================================================" -ForegroundColor DarkGray
|
|
72
|
+
Write-Host "開発用サーバーの起動、および変更の自動ビルド(Watch)を一括実行します。"
|
|
73
|
+
Write-Host "`n使い方:" -ForegroundColor Yellow
|
|
74
|
+
Write-Host " tsbuild"
|
|
75
|
+
Write-Host "`n機能:" -ForegroundColor Yellow
|
|
76
|
+
Write-Host " 1. バックグラウンドでBunによる高速Webサーバー起動(ポート自動競合回避)"
|
|
77
|
+
Write-Host " 2. 初回コンパイル実行によるブラウザ読み込みエラー(404)の完全防止"
|
|
78
|
+
Write-Host " 3. ブラウザの自動起動"
|
|
79
|
+
Write-Host " 4. tsc --watch によるリアルタイム自動コンパイル"
|
|
80
|
+
Write-Host " 5. ファイル変更時のブラウザ自動更新(ホットリロード)"
|
|
81
|
+
Write-Host " 6. [Ctrl + C] 終了時のゾンビプロセス自動クリーンアップ"
|
|
82
|
+
Write-Host "`n📁 対象プロジェクトの構成:" -ForegroundColor Yellow
|
|
83
|
+
Write-Host " myapp/"
|
|
84
|
+
Write-Host " ├── src/"
|
|
85
|
+
Write-Host " │ └── index.ts"
|
|
86
|
+
Write-Host " ├── dist/ " -NoNewline; Write-Host "← tsc が自動生成" -ForegroundColor DarkGray
|
|
87
|
+
Write-Host " ├── index.html"
|
|
88
|
+
Write-Host " ├── server.ts " -NoNewline; Write-Host "← tsbuild が起動するサーバー" -ForegroundColor DarkGray
|
|
89
|
+
Write-Host " ├── tsconfig.json"
|
|
90
|
+
Write-Host " └── package.json"
|
|
91
|
+
Write-Host "==================================================`n" -ForegroundColor DarkGray
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!(Test-Path "package.json") -or !(Test-Path "server.ts")) {
|
|
96
|
+
Write-Error "エラー: package.json または server.ts がありません。プロジェクトのルートで実行してください。"
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Write-Host "🚀 開発環境を起動中(ホットリロード有効)..." -ForegroundColor Cyan
|
|
101
|
+
|
|
102
|
+
$currentDir = (Get-Location).Path
|
|
103
|
+
$serverJob = Start-Job -ScriptBlock {
|
|
104
|
+
param($dir)
|
|
105
|
+
Set-Location $dir
|
|
106
|
+
bun server.ts
|
|
107
|
+
} -ArgumentList $currentDir
|
|
108
|
+
|
|
109
|
+
$tscOutput = bun x tsc 2>&1
|
|
110
|
+
if ($LASTEXITCODE -ne 0) {
|
|
111
|
+
Write-Host "⚠ TypeScript コンパイルエラー:" -ForegroundColor Yellow
|
|
112
|
+
$tscOutput | ForEach-Object { Write-Host " $_" -ForegroundColor Yellow }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
$targetUrl = "http://localhost:53000"
|
|
116
|
+
$maxWait = 5000
|
|
117
|
+
$waited = 0
|
|
118
|
+
while ($waited -lt $maxWait) {
|
|
119
|
+
Start-Sleep -Milliseconds 200
|
|
120
|
+
$waited += 200
|
|
121
|
+
$combined = Receive-Job -Job $serverJob -Keep | Out-String
|
|
122
|
+
if ($combined -match "http://localhost:\d+") {
|
|
123
|
+
$targetUrl = $matches[0]
|
|
124
|
+
break
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
Start-Process $targetUrl
|
|
128
|
+
|
|
129
|
+
Write-Host "==================================================" -ForegroundColor Yellow
|
|
130
|
+
Write-Host " 🔥 ホットリロード稼働中!コードを変更するとブラウザが自動更新されます。" -ForegroundColor Green
|
|
131
|
+
Write-Host " [Ctrl + C] を押すと、すべてのプロセスを終了します。" -ForegroundColor Yellow
|
|
132
|
+
Write-Host "==================================================" -ForegroundColor Yellow
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
bun x tsc --watch
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
Write-Host "`n🛑 開発環境を停止しています..." -ForegroundColor Red
|
|
139
|
+
Get-Job | Where-Object { $_.State -eq "Running" } | Stop-Job
|
|
140
|
+
Get-Job | Remove-Job
|
|
141
|
+
Write-Host "✨ すべてのプロセスが正常に終了しました。" -ForegroundColor Green
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
'@
|
|
145
|
+
|
|
146
|
+
if (!(Test-Path $PROFILE)) {
|
|
147
|
+
New-Item -Type File -Path $PROFILE -Force > $null
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
$profileContent = Get-Content $PROFILE -Raw -ErrorAction SilentlyContinue
|
|
151
|
+
if ([string]::IsNullOrEmpty($profileContent)) { $profileContent = "" }
|
|
152
|
+
|
|
153
|
+
$beginMarker = "# <<BEGIN:$functionName>>"
|
|
154
|
+
$endMarker = "# <<END:$functionName>>"
|
|
155
|
+
$markerPattern = "(?s)# <<BEGIN:$functionName>>.*# <<END:$functionName>>"
|
|
156
|
+
|
|
157
|
+
if ($profileContent -match $markerPattern) {
|
|
158
|
+
$profileContent = $profileContent -replace $markerPattern, ""
|
|
159
|
+
}
|
|
160
|
+
$profileContent = $profileContent.Replace("# <<END:$functionName>>", "").Trim()
|
|
161
|
+
|
|
162
|
+
if (-not ($profileContent -match "# <<BEGIN:$functionName>>") -and $profileContent -match "function\s+$functionName\b") {
|
|
163
|
+
Write-Host ""
|
|
164
|
+
Write-Host "⚠ 警告: マーカーのない旧バージョンの $functionName がプロファイルに存在します。" -ForegroundColor Yellow
|
|
165
|
+
Write-Host " 自動削除は行いません。以下を手動で実行してください:" -ForegroundColor Yellow
|
|
166
|
+
Write-Host ""
|
|
167
|
+
Write-Host " 1. メモ帳でプロファイルを開く:" -ForegroundColor Cyan
|
|
168
|
+
Write-Host " notepad `$PROFILE" -ForegroundColor White
|
|
169
|
+
Write-Host " 2. 'function $functionName' から始まるブロックを手動で削除する" -ForegroundColor Cyan
|
|
170
|
+
Write-Host " 3. 保存後にこのインストールコマンドを再実行する" -ForegroundColor Cyan
|
|
171
|
+
Write-Host ""
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
$block = "$beginMarker`n$functionCode`n$endMarker"
|
|
176
|
+
$newProfileContent = $profileContent.Trim() + "`n`n" + $block
|
|
177
|
+
[System.IO.File]::WriteAllText($PROFILE, $newProfileContent.Trim(), [System.Text.UTF8Encoding]::new($true))
|
|
178
|
+
|
|
179
|
+
Invoke-Expression $functionCode
|
|
180
|
+
|
|
181
|
+
Write-Host "✨ tsbuild コマンドのインストール/更新が完了しました!" -ForegroundColor Green
|
|
182
|
+
Write-Host ""
|
|
183
|
+
Write-Host "📦 インストールコマンド(再インストール・更新時):" -ForegroundColor Cyan
|
|
184
|
+
Write-Host " irm https://raw.githubusercontent.com/Lapius7/tsbuild/main/install.ps1 | iex"
|
|
185
|
+
Write-Host ""
|
|
186
|
+
Write-Host "📋 使い方:" -ForegroundColor Cyan
|
|
187
|
+
Write-Host " tsbuild " -NoNewline; Write-Host "# 開発サーバー起動・ホットリロード開始" -ForegroundColor DarkGray
|
|
188
|
+
Write-Host " tsbuild -Help " -NoNewline; Write-Host "# 詳細ヘルプを表示" -ForegroundColor DarkGray
|
|
189
|
+
Write-Host ""
|
|
190
|
+
Write-Host "📁 対象プロジェクトの構成(tssetup で作成した場合):" -ForegroundColor Cyan
|
|
191
|
+
Write-Host " myapp/"
|
|
192
|
+
Write-Host " ├── src/"
|
|
193
|
+
Write-Host " │ └── index.ts"
|
|
194
|
+
Write-Host " ├── dist/ " -NoNewline; Write-Host "← tsc が自動生成" -ForegroundColor DarkGray
|
|
195
|
+
Write-Host " ├── index.html"
|
|
196
|
+
Write-Host " ├── server.ts " -NoNewline; Write-Host "← tsbuild が起動するサーバー" -ForegroundColor DarkGray
|
|
197
|
+
Write-Host " ├── tsconfig.json"
|
|
198
|
+
Write-Host " └── package.json"
|
|
199
|
+
Write-Host ""
|
|
200
|
+
Write-Host "🚀 プロジェクトの始め方:" -ForegroundColor Cyan
|
|
201
|
+
Write-Host " tssetup myapp " -NoNewline; Write-Host "# プロジェクト作成" -ForegroundColor DarkGray
|
|
202
|
+
Write-Host " cd myapp " -NoNewline; Write-Host "# ディレクトリ移動" -ForegroundColor DarkGray
|
|
203
|
+
Write-Host " tsbuild " -NoNewline; Write-Host "# 開発サーバー起動" -ForegroundColor DarkGray
|
|
204
|
+
Write-Host ""
|
|
205
|
+
Write-Host "新しいPowerShellウィンドウを開くか、 '. `$PROFILE' を実行して即時反映させてください。" -ForegroundColor Yellow
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tsbuild"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Bun + TypeScript 開発サーバーをホットリロード付きで1コマンド起動するツール"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Lapius7", email = "me@lapius7.com" }]
|
|
13
|
+
keywords = ["bun", "typescript", "hot-reload", "dev-server", "cli"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: Microsoft :: Windows",
|
|
20
|
+
"Topic :: Software Development",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
tsbuild = "tsbuild.__main__:main"
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/Lapius7/tsbuild"
|
|
28
|
+
Issues = "https://github.com/Lapius7/tsbuild/issues"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import subprocess
|
|
3
|
+
import urllib.request
|
|
4
|
+
import webbrowser
|
|
5
|
+
import re
|
|
6
|
+
import time
|
|
7
|
+
import signal
|
|
8
|
+
import threading
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from . import __version__
|
|
12
|
+
|
|
13
|
+
# --- Console setup (Windows: enable ANSI + force UTF-8) ---
|
|
14
|
+
|
|
15
|
+
def _setup_console():
|
|
16
|
+
if sys.platform == "win32":
|
|
17
|
+
try:
|
|
18
|
+
import ctypes
|
|
19
|
+
ctypes.windll.kernel32.SetConsoleMode(
|
|
20
|
+
ctypes.windll.kernel32.GetStdHandle(-11), 7)
|
|
21
|
+
except Exception:
|
|
22
|
+
pass
|
|
23
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
24
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
25
|
+
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
|
26
|
+
|
|
27
|
+
_setup_console()
|
|
28
|
+
|
|
29
|
+
R = "\033[0m"
|
|
30
|
+
CYAN = "\033[36m"
|
|
31
|
+
GREEN = "\033[32m"
|
|
32
|
+
YELLOW = "\033[33m"
|
|
33
|
+
WHITE = "\033[97m"
|
|
34
|
+
GRAY = "\033[90m"
|
|
35
|
+
RED = "\033[31m"
|
|
36
|
+
|
|
37
|
+
def c(text, color): return f"{color}{text}{R}"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# --- Version check ---
|
|
41
|
+
|
|
42
|
+
def fetch_remote_version() -> str | None:
|
|
43
|
+
try:
|
|
44
|
+
url = "https://raw.githubusercontent.com/Lapius7/tsbuild/main/version.txt"
|
|
45
|
+
with urllib.request.urlopen(url, timeout=3) as r:
|
|
46
|
+
return r.read().decode().strip()
|
|
47
|
+
except Exception:
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# --- Info screen ---
|
|
52
|
+
|
|
53
|
+
def show_info(remote: str | None):
|
|
54
|
+
print()
|
|
55
|
+
print(c("⚡ tsbuild", CYAN) + c(f" v{__version__}", GRAY))
|
|
56
|
+
print("Bun + TypeScript 開発サーバーをホットリロード付きで1コマンド起動するツール")
|
|
57
|
+
print()
|
|
58
|
+
print(c("開発者 : ", YELLOW) + "Lapius7")
|
|
59
|
+
print(c("X : ", YELLOW) + "https://x.com/Lapius7")
|
|
60
|
+
print(c("GitHub : ", YELLOW) + "https://github.com/Lapius7/tsbuild")
|
|
61
|
+
print()
|
|
62
|
+
if remote is None:
|
|
63
|
+
print(f"バージョン : {__version__} " + c("(バージョン確認失敗)", GRAY))
|
|
64
|
+
elif remote == __version__:
|
|
65
|
+
print(f"バージョン : {__version__} " + c("✅ 最新です", GREEN))
|
|
66
|
+
else:
|
|
67
|
+
print(f"バージョン : {__version__} " + c(f"⬆ 最新: {remote}", YELLOW))
|
|
68
|
+
print()
|
|
69
|
+
print(c("使い方 : tssetup でプロジェクトを作成してから、そのフォルダ内で tsbuild を実行してください", GRAY))
|
|
70
|
+
print(c("ヘルプ : tsbuild --help", GRAY))
|
|
71
|
+
print()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# --- Dev server ---
|
|
75
|
+
|
|
76
|
+
def run_server():
|
|
77
|
+
if not Path("package.json").exists() or not Path("server.ts").exists():
|
|
78
|
+
remote = fetch_remote_version()
|
|
79
|
+
show_info(remote)
|
|
80
|
+
return
|
|
81
|
+
|
|
82
|
+
print(c("🚀 開発環境を起動中(ホットリロード有効)...", CYAN))
|
|
83
|
+
|
|
84
|
+
server_proc = subprocess.Popen(
|
|
85
|
+
["bun", "server.ts"],
|
|
86
|
+
stdout=subprocess.PIPE,
|
|
87
|
+
stderr=subprocess.STDOUT,
|
|
88
|
+
text=True,
|
|
89
|
+
encoding="utf-8",
|
|
90
|
+
errors="replace",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Initial compile
|
|
94
|
+
tsc_result = subprocess.run(
|
|
95
|
+
["bun", "x", "tsc"],
|
|
96
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace"
|
|
97
|
+
)
|
|
98
|
+
if tsc_result.returncode != 0:
|
|
99
|
+
print(c("⚠ TypeScript コンパイルエラー:", YELLOW))
|
|
100
|
+
for line in (tsc_result.stdout + tsc_result.stderr).splitlines():
|
|
101
|
+
print(c(f" {line}", YELLOW))
|
|
102
|
+
|
|
103
|
+
# Wait for server URL
|
|
104
|
+
target_url = "http://localhost:53000"
|
|
105
|
+
deadline = time.time() + 5
|
|
106
|
+
|
|
107
|
+
def _read_url():
|
|
108
|
+
nonlocal target_url
|
|
109
|
+
while time.time() < deadline:
|
|
110
|
+
line = server_proc.stdout.readline()
|
|
111
|
+
if not line:
|
|
112
|
+
break
|
|
113
|
+
m = re.search(r"http://localhost:\d+", line)
|
|
114
|
+
if m:
|
|
115
|
+
target_url = m.group()
|
|
116
|
+
break
|
|
117
|
+
|
|
118
|
+
t = threading.Thread(target=_read_url, daemon=True)
|
|
119
|
+
t.start()
|
|
120
|
+
t.join(timeout=5)
|
|
121
|
+
|
|
122
|
+
webbrowser.open(target_url)
|
|
123
|
+
|
|
124
|
+
print(c("=" * 50, YELLOW))
|
|
125
|
+
print(c(" 🔥 ホットリロード稼働中!コードを変更するとブラウザが自動更新されます。", GREEN))
|
|
126
|
+
print(c(" [Ctrl + C] を押すと、すべてのプロセスを終了します。", YELLOW))
|
|
127
|
+
print(c("=" * 50, YELLOW))
|
|
128
|
+
|
|
129
|
+
def cleanup(signum=None, frame=None):
|
|
130
|
+
print(c("\n🛑 開発環境を停止しています...", RED))
|
|
131
|
+
server_proc.terminate()
|
|
132
|
+
try:
|
|
133
|
+
server_proc.wait(timeout=3)
|
|
134
|
+
except subprocess.TimeoutExpired:
|
|
135
|
+
server_proc.kill()
|
|
136
|
+
print(c("✨ すべてのプロセスが正常に終了しました。", GREEN))
|
|
137
|
+
sys.exit(0)
|
|
138
|
+
|
|
139
|
+
signal.signal(signal.SIGINT, cleanup)
|
|
140
|
+
|
|
141
|
+
try:
|
|
142
|
+
subprocess.run(["bun", "x", "tsc", "--watch"])
|
|
143
|
+
finally:
|
|
144
|
+
cleanup()
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
# --- Entry point ---
|
|
148
|
+
|
|
149
|
+
def main():
|
|
150
|
+
import argparse
|
|
151
|
+
parser = argparse.ArgumentParser(
|
|
152
|
+
prog="tsbuild",
|
|
153
|
+
description="Bun + TypeScript 開発サーバーをホットリロード付きで起動するツール",
|
|
154
|
+
)
|
|
155
|
+
parser.add_argument("--version", "-v", action="store_true", help="バージョンを表示")
|
|
156
|
+
args = parser.parse_args()
|
|
157
|
+
|
|
158
|
+
if args.version:
|
|
159
|
+
print(f"tsbuild v{__version__}")
|
|
160
|
+
return
|
|
161
|
+
|
|
162
|
+
remote = fetch_remote_version()
|
|
163
|
+
if remote and remote != __version__:
|
|
164
|
+
print()
|
|
165
|
+
print(c(f"🔄 新しいバージョン ({remote}) があります。pip install --upgrade tsbuild で更新できます。", YELLOW))
|
|
166
|
+
|
|
167
|
+
run_server()
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.0
|