Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/improve-whitelist-ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@tktco/create-devenv": patch
---

ホワイトリスト追加フローを改善

- ファイル選択UIを罫線付きツリー形式に変更し、ディレクトリ構造を視覚化
- ホワイトリスト追加後にmoduleListを再パースし、新規ファイルが即座にPUSH対象に含まれるように修正
8 changes: 8 additions & 0 deletions packages/create-devenv/src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { readFile, rm } from "node:fs/promises";
import { defineCommand } from "citty";
import consola from "consola";
import { downloadTemplate } from "giget";
import { parse } from "jsonc-parser";
import { join, resolve } from "pathe";
import {
addPatternToModulesFile,
Expand Down Expand Up @@ -144,6 +145,13 @@ export const pushCommand = defineCommand({
}
updatedModulesContent = currentContent;

// 更新されたモジュールリストを再パースして反映
// これにより、新しく追加したパターンが差分検出で使用される
const parsedUpdated = parse(updatedModulesContent) as {
modules: TemplateModule[];
};
moduleList = parsedUpdated.modules;

const totalAdded = selectedFiles.reduce(
(sum, s) => sum + s.files.length,
0,
Expand Down
35 changes: 29 additions & 6 deletions packages/create-devenv/src/prompts/push.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { checkbox, confirm, input, password } from "@inquirer/prompts";
import {
checkbox,
confirm,
input,
password,
Separator,
} from "@inquirer/prompts";
import type { DiffResult, FileDiff } from "../modules/schemas";
import {
colorizeUnifiedDiff,
Expand Down Expand Up @@ -162,13 +168,30 @@ export async function promptAddUntrackedFiles(
selectedFolders.includes(f.folder),
);

// Step 2: ファイルを選択(フォルダごとにグループ化して一括表示)
const allFileChoices: { name: string; value: UntrackedFile }[] = [];
// Step 2: ファイルを選択(罫線付きツリー形式で表示)
const allFileChoices: ({ name: string; value: UntrackedFile } | Separator)[] =
[];

for (const { folder, files } of selectedFolderData) {
// フォルダヘッダーを追加
allFileChoices.push(new Separator(`\n ── ${folder} ──`));

// フォルダ内のファイルをソート
const sortedFiles = [...files].sort((a, b) => a.path.localeCompare(b.path));

// ツリー形式で表示
for (let i = 0; i < sortedFiles.length; i++) {
const file = sortedFiles[i];
const isLast = i === sortedFiles.length - 1;
const prefix = isLast ? "└─" : "├─";

// フォルダ部分を除いたファイル名を取得
const relativePath = file.path.startsWith(`${folder}/`)
? file.path.slice(folder.length + 1)
: file.path;

for (const { files } of selectedFolderData) {
for (const file of files) {
allFileChoices.push({
name: file.path,
name: `${prefix} ${relativePath}`,
value: file,
});
}
Expand Down