@aku11i/phantom 0.5.0 → 0.7.0
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.
- package/README.ja.md +91 -2
- package/README.md +94 -2
- package/dist/phantom.js +846 -90
- package/dist/phantom.js.map +4 -4
- package/package.json +4 -2
package/README.ja.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@aku11i/phantom)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://nodejs.org)
|
|
10
|
+
[](https://deepwiki.com/aku11i/phantom)
|
|
10
11
|
|
|
11
12
|
[インストール](#-インストール) • [基本的な使い方](#-基本的な使い方) • [なぜPhantom?](#-なぜphantom) • [ドキュメント](#-ドキュメント)
|
|
12
13
|
|
|
@@ -108,9 +109,21 @@ npm link
|
|
|
108
109
|
```bash
|
|
109
110
|
# 対応するブランチを持つ新しいworktreeを作成
|
|
110
111
|
phantom create <name>
|
|
112
|
+
phantom create <name> --shell # 作成してインタラクティブシェルに入る
|
|
113
|
+
phantom create <name> --exec <command> # 作成してコマンドを実行
|
|
114
|
+
phantom create <name> --tmux # 作成して新しいtmuxウィンドウで開く
|
|
115
|
+
phantom create <name> --tmux-vertical # 作成してtmuxペインを縦に分割
|
|
116
|
+
phantom create <name> --tmux-v # --tmux-verticalの短縮形
|
|
117
|
+
phantom create <name> --tmux-horizontal # 作成してtmuxペインを横に分割
|
|
118
|
+
phantom create <name> --tmux-h # --tmux-horizontalの短縮形
|
|
119
|
+
|
|
120
|
+
# worktreeを作成し、特定のファイルをコピー
|
|
121
|
+
phantom create <name> --copy-file ".env" --copy-file ".env.local"
|
|
111
122
|
|
|
112
123
|
# 既存のブランチにworktreeとしてアタッチ
|
|
113
124
|
phantom attach <branch-name>
|
|
125
|
+
phantom attach <branch-name> --shell # アタッチしてインタラクティブシェルに入る
|
|
126
|
+
phantom attach <branch-name> --exec <command> # アタッチしてコマンドを実行
|
|
114
127
|
|
|
115
128
|
# すべてのworktreeとその現在のステータスをリスト表示
|
|
116
129
|
phantom list
|
|
@@ -200,6 +213,79 @@ phantom shell feature-awesome # 機能開発を続行
|
|
|
200
213
|
| worktreeでコマンド実行 | `cd ../project-feature && npm test` | `phantom exec feature npm test` |
|
|
201
214
|
| worktreeの削除 | `git worktree remove ../project-feature` | `phantom delete feature` |
|
|
202
215
|
|
|
216
|
+
## ⚙️ 設定
|
|
217
|
+
|
|
218
|
+
Phantomはリポジトリルートの`phantom.config.json`ファイルによる設定をサポートします。これにより、新しいworktreeを作成する際に自動的にコピーされるファイルの定義や、実行されるコマンドを設定できます。
|
|
219
|
+
|
|
220
|
+
### 設定ファイル
|
|
221
|
+
|
|
222
|
+
リポジトリルートに`phantom.config.json`ファイルを作成します:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"postCreate": {
|
|
227
|
+
"copyFiles": [
|
|
228
|
+
".env",
|
|
229
|
+
".env.local",
|
|
230
|
+
"config/local.json"
|
|
231
|
+
],
|
|
232
|
+
"commands": [
|
|
233
|
+
"pnpm install",
|
|
234
|
+
"pnpm build"
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### ファイルコピー機能
|
|
241
|
+
|
|
242
|
+
新しいworktreeを作成する際、Phantomは現在のworktreeから新しいworktreeへ指定されたファイルを自動的にコピーできます。これは以下のような場合に特に便利です:
|
|
243
|
+
|
|
244
|
+
- 環境設定ファイル(`.env`、`.env.local`)
|
|
245
|
+
- ローカル開発設定
|
|
246
|
+
- gitignoreされているシークレットファイル
|
|
247
|
+
|
|
248
|
+
ファイルのコピーは2つの方法で指定できます:
|
|
249
|
+
|
|
250
|
+
1. **コマンドラインオプションを使用:**
|
|
251
|
+
```bash
|
|
252
|
+
phantom create feature --copy-file ".env" --copy-file ".env.local" --copy-file "config/local.json"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
2. **設定ファイルを使用:**
|
|
256
|
+
`phantom.config.json`で一度設定すれば、すべての新しいworktreeに適用されます。
|
|
257
|
+
|
|
258
|
+
3. **両方を使用:**
|
|
259
|
+
設定ファイルとコマンドラインオプションの両方で指定されたファイルはマージされます(重複は削除されます)。
|
|
260
|
+
|
|
261
|
+
> **注意:** 現在、globパターンはサポートされていません。ファイルはリポジトリルートからの相対パスで正確に指定する必要があります。
|
|
262
|
+
|
|
263
|
+
### 作成後コマンド
|
|
264
|
+
|
|
265
|
+
Phantomは新しいworktreeを作成した後に自動的にコマンドを実行できます。これは以下のような場合に便利です:
|
|
266
|
+
|
|
267
|
+
- 依存関係のインストール(`pnpm install`、`npm install`、`yarn install`)
|
|
268
|
+
- プロジェクトのビルド
|
|
269
|
+
- 開発環境のセットアップ
|
|
270
|
+
- データベースマイグレーションの実行
|
|
271
|
+
- プロジェクト固有のその他のセットアップタスク
|
|
272
|
+
|
|
273
|
+
コマンドは設定ファイルで指定された順序で実行されます。コマンドが失敗した場合、作成プロセスは停止し、エラーが報告されます。
|
|
274
|
+
|
|
275
|
+
使用例:
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"postCreate": {
|
|
279
|
+
"commands": [
|
|
280
|
+
"pnpm install", // 依存関係をインストール
|
|
281
|
+
"pnpm db:migrate", // データベースマイグレーションを実行
|
|
282
|
+
"cp .env.example .env", // テンプレートから環境ファイルを作成
|
|
283
|
+
"pnpm build" // プロジェクトをビルド
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
203
289
|
## 🛠️ 開発
|
|
204
290
|
|
|
205
291
|
```bash
|
|
@@ -211,6 +297,9 @@ pnpm install
|
|
|
211
297
|
# テストの実行
|
|
212
298
|
pnpm test
|
|
213
299
|
|
|
300
|
+
# 特定のテストファイルを実行
|
|
301
|
+
pnpm test:file src/core/worktree/create.test.js
|
|
302
|
+
|
|
214
303
|
# 型チェック
|
|
215
304
|
pnpm typecheck
|
|
216
305
|
|
|
@@ -274,8 +363,8 @@ Phantomの新しいバージョンをリリースするには:
|
|
|
274
363
|
```
|
|
275
364
|
|
|
276
365
|
7. **リリースノートを分かりやすく更新**
|
|
277
|
-
-
|
|
278
|
-
- 重要な詳細についてはPR
|
|
366
|
+
- 自動生成されたリリースノートを`gh release view v<version>`でレビュー
|
|
367
|
+
- 重要な詳細についてはPRの説明を`gh pr view <number>`で確認
|
|
279
368
|
- リリースノートをよりユーザーフレンドリーに更新:
|
|
280
369
|
- 変更をカテゴリー別にグループ化(機能、バグ修正、改善)
|
|
281
370
|
- 新機能には使用例を追加
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@aku11i/phantom)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://nodejs.org)
|
|
10
|
+
[](https://deepwiki.com/aku11i/phantom)
|
|
10
11
|
|
|
11
12
|
[Installation](#-installation) • [Basic Usage](#-basic-usage) • [Why Phantom?](#-why-phantom) • [Documentation](#-documentation) • [日本語](./README.ja.md)
|
|
12
13
|
|
|
@@ -108,9 +109,21 @@ npm link
|
|
|
108
109
|
```bash
|
|
109
110
|
# Create a new worktree with a matching branch
|
|
110
111
|
phantom create <name>
|
|
112
|
+
phantom create <name> --shell # Create and enter interactive shell
|
|
113
|
+
phantom create <name> --exec <command> # Create and execute command
|
|
114
|
+
phantom create <name> --tmux # Create and open in new tmux window
|
|
115
|
+
phantom create <name> --tmux-vertical # Create and split tmux pane vertically
|
|
116
|
+
phantom create <name> --tmux-v # Shorthand for --tmux-vertical
|
|
117
|
+
phantom create <name> --tmux-horizontal # Create and split tmux pane horizontally
|
|
118
|
+
phantom create <name> --tmux-h # Shorthand for --tmux-horizontal
|
|
119
|
+
|
|
120
|
+
# Create a worktree and copy specific files
|
|
121
|
+
phantom create <name> --copy-file ".env" --copy-file ".env.local"
|
|
111
122
|
|
|
112
123
|
# Attach to an existing branch as a worktree
|
|
113
124
|
phantom attach <branch-name>
|
|
125
|
+
phantom attach <branch-name> --shell # Attach and enter interactive shell
|
|
126
|
+
phantom attach <branch-name> --exec <command> # Attach and execute command
|
|
114
127
|
|
|
115
128
|
# List all worktrees with their current status
|
|
116
129
|
phantom list
|
|
@@ -121,6 +134,8 @@ phantom where <name>
|
|
|
121
134
|
# Delete a worktree and its branch
|
|
122
135
|
phantom delete <name>
|
|
123
136
|
phantom delete <name> --force # Force delete with uncommitted changes
|
|
137
|
+
phantom delete --current # Delete the current worktree (when inside one)
|
|
138
|
+
phantom delete --current --force # Force delete current worktree
|
|
124
139
|
```
|
|
125
140
|
|
|
126
141
|
#### Working with Worktrees
|
|
@@ -199,6 +214,80 @@ phantom shell feature-awesome # Continue feature development
|
|
|
199
214
|
| Navigate to worktree | `cd ../project-feature` | `phantom shell feature` |
|
|
200
215
|
| Run command in worktree | `cd ../project-feature && npm test` | `phantom exec feature npm test` |
|
|
201
216
|
| Remove worktree | `git worktree remove ../project-feature` | `phantom delete feature` |
|
|
217
|
+
| Remove current worktree | `cd .. && git worktree remove project-feature` | `phantom delete --current` |
|
|
218
|
+
|
|
219
|
+
## ⚙️ Configuration
|
|
220
|
+
|
|
221
|
+
Phantom supports configuration through a `phantom.config.json` file in your repository root. This allows you to define files to be automatically copied and commands to be executed when creating new worktrees.
|
|
222
|
+
|
|
223
|
+
### Configuration File
|
|
224
|
+
|
|
225
|
+
Create a `phantom.config.json` file in your repository root:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"postCreate": {
|
|
230
|
+
"copyFiles": [
|
|
231
|
+
".env",
|
|
232
|
+
".env.local",
|
|
233
|
+
"config/local.json"
|
|
234
|
+
],
|
|
235
|
+
"commands": [
|
|
236
|
+
"pnpm install",
|
|
237
|
+
"pnpm build"
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Copy Files Feature
|
|
244
|
+
|
|
245
|
+
When creating a new worktree, Phantom can automatically copy specified files from your current worktree to the new one. This is particularly useful for:
|
|
246
|
+
|
|
247
|
+
- Environment configuration files (`.env`, `.env.local`)
|
|
248
|
+
- Local development settings
|
|
249
|
+
- Secret files that are gitignored
|
|
250
|
+
|
|
251
|
+
You can specify files to copy in two ways:
|
|
252
|
+
|
|
253
|
+
1. **Using the command line option:**
|
|
254
|
+
```bash
|
|
255
|
+
phantom create feature --copy-file ".env" --copy-file ".env.local" --copy-file "config/local.json"
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
2. **Using the configuration file:**
|
|
259
|
+
Configure once in `phantom.config.json` and it will apply to all new worktrees.
|
|
260
|
+
|
|
261
|
+
3. **Using both:**
|
|
262
|
+
Files specified in both the configuration file and command line options are merged together (duplicates are removed).
|
|
263
|
+
|
|
264
|
+
> **Note:** Currently, glob patterns are not supported. Files must be specified with their exact paths relative to the repository root.
|
|
265
|
+
|
|
266
|
+
### Post-Create Commands
|
|
267
|
+
|
|
268
|
+
Phantom can automatically execute commands after creating a new worktree. This is useful for:
|
|
269
|
+
|
|
270
|
+
- Installing dependencies (`pnpm install`, `npm install`, `yarn install`)
|
|
271
|
+
- Building the project
|
|
272
|
+
- Setting up the development environment
|
|
273
|
+
- Running database migrations
|
|
274
|
+
- Any other setup tasks specific to your project
|
|
275
|
+
|
|
276
|
+
Commands are executed in the order they are specified in the configuration file. If a command fails, the creation process will stop and report the error.
|
|
277
|
+
|
|
278
|
+
Example use cases:
|
|
279
|
+
```json
|
|
280
|
+
{
|
|
281
|
+
"postCreate": {
|
|
282
|
+
"commands": [
|
|
283
|
+
"pnpm install", // Install dependencies
|
|
284
|
+
"pnpm db:migrate", // Run database migrations
|
|
285
|
+
"cp .env.example .env", // Create environment file from template
|
|
286
|
+
"pnpm build" // Build the project
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
```
|
|
202
291
|
|
|
203
292
|
## 🛠️ Development
|
|
204
293
|
|
|
@@ -211,6 +300,9 @@ pnpm install
|
|
|
211
300
|
# Run tests
|
|
212
301
|
pnpm test
|
|
213
302
|
|
|
303
|
+
# Run a specific test file
|
|
304
|
+
pnpm test:file src/core/worktree/create.test.js
|
|
305
|
+
|
|
214
306
|
# Type checking
|
|
215
307
|
pnpm typecheck
|
|
216
308
|
|
|
@@ -274,8 +366,8 @@ To release a new version of Phantom:
|
|
|
274
366
|
```
|
|
275
367
|
|
|
276
368
|
7. **Update release notes for clarity**
|
|
277
|
-
- Review the auto-generated release notes
|
|
278
|
-
- Check PR descriptions for important details
|
|
369
|
+
- Review the auto-generated release notes using `gh release view v<version>`
|
|
370
|
+
- Check PR descriptions for important details using `gh pr view <number>`
|
|
279
371
|
- Update the release notes to be more user-friendly:
|
|
280
372
|
- Group changes by category (Features, Bug Fixes, Improvements)
|
|
281
373
|
- Add usage examples for new features
|