Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
65b3d9cb
Unverified
提交
65b3d9cb
authored
7月 10, 2025
作者:
Will Chen
提交者:
GitHub
7月 10, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix git migration edge case (#612)
Fixes #608
上级
94281146
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
15 行增加
和
7 行删除
+15
-7
supabase_migrations.spec.ts
e2e-tests/supabase_migrations.spec.ts
+10
-1
response_processor.ts
src/ipc/processors/response_processor.ts
+3
-5
file_utils.ts
src/ipc/utils/file_utils.ts
+2
-1
没有找到文件。
e2e-tests/supabase_migrations.spec.ts
浏览文件 @
65b3d9cb
...
@@ -2,9 +2,12 @@ import { expect } from "@playwright/test";
...
@@ -2,9 +2,12 @@ import { expect } from "@playwright/test";
import
{
test
}
from
"./helpers/test_helper"
;
import
{
test
}
from
"./helpers/test_helper"
;
import
fs
from
"fs-extra"
;
import
fs
from
"fs-extra"
;
import
path
from
"path"
;
import
path
from
"path"
;
import
{
execSync
}
from
"child_process"
;
test
(
"supabase migrations"
,
async
({
po
})
=>
{
test
(
"supabase migrations"
,
async
({
po
})
=>
{
await
po
.
setUp
({
autoApprove
:
true
});
// Turning on native Git to catch this edge case:
// https://github.com/dyad-sh/dyad/issues/608
await
po
.
setUp
({
autoApprove
:
true
,
nativeGit
:
true
});
await
po
.
sendPrompt
(
"tc=add-supabase"
);
await
po
.
sendPrompt
(
"tc=add-supabase"
);
// Connect to Supabase
// Connect to Supabase
...
@@ -43,6 +46,12 @@ test("supabase migrations", async ({ po }) => {
...
@@ -43,6 +46,12 @@ test("supabase migrations", async ({ po }) => {
expect
(
await
fs
.
readFile
(
path
.
join
(
migrationsDir
,
files
[
0
]),
"utf8"
)).
toEqual
(
expect
(
await
fs
.
readFile
(
path
.
join
(
migrationsDir
,
files
[
0
]),
"utf8"
)).
toEqual
(
"CREATE TABLE users (id serial primary key);"
,
"CREATE TABLE users (id serial primary key);"
,
);
);
// Make sure git is clean.
const
gitStatus
=
execSync
(
"git status --porcelain"
,
{
cwd
:
appPath
,
encoding
:
"utf8"
,
}).
trim
();
expect
(
gitStatus
).
toBe
(
""
);
// Send a prompt that triggers a migration
// Send a prompt that triggers a migration
await
po
.
sendPrompt
(
"tc=execute-sql-no-description"
);
await
po
.
sendPrompt
(
"tc=execute-sql-no-description"
);
...
...
src/ipc/processors/response_processor.ts
浏览文件 @
65b3d9cb
...
@@ -92,7 +92,6 @@ export async function processFullResponseActions(
...
@@ -92,7 +92,6 @@ export async function processFullResponseActions(
const
dyadExecuteSqlQueries
=
chatWithApp
.
app
.
supabaseProjectId
const
dyadExecuteSqlQueries
=
chatWithApp
.
app
.
supabaseProjectId
?
getDyadExecuteSqlTags
(
fullResponse
)
?
getDyadExecuteSqlTags
(
fullResponse
)
:
[];
:
[];
let
writtenSqlMigrationFiles
=
0
;
const
message
=
await
db
.
query
.
messages
.
findFirst
({
const
message
=
await
db
.
query
.
messages
.
findFirst
({
where
:
and
(
where
:
and
(
...
@@ -119,12 +118,12 @@ export async function processFullResponseActions(
...
@@ -119,12 +118,12 @@ export async function processFullResponseActions(
// Only write migration file if SQL execution succeeded
// Only write migration file if SQL execution succeeded
if
(
settings
.
enableSupabaseWriteSqlMigration
)
{
if
(
settings
.
enableSupabaseWriteSqlMigration
)
{
try
{
try
{
await
writeMigrationFile
(
const
migrationFilePath
=
await
writeMigrationFile
(
appPath
,
appPath
,
query
.
content
,
query
.
content
,
query
.
description
,
query
.
description
,
);
);
written
SqlMigrationFiles
++
;
written
Files
.
push
(
migrationFilePath
)
;
}
catch
(
error
)
{
}
catch
(
error
)
{
errors
.
push
({
errors
.
push
({
message
:
`Failed to write SQL migration file for:
${
query
.
description
}
`
,
message
:
`Failed to write SQL migration file for:
${
query
.
description
}
`
,
...
@@ -322,8 +321,7 @@ export async function processFullResponseActions(
...
@@ -322,8 +321,7 @@ export async function processFullResponseActions(
writtenFiles
.
length
>
0
||
writtenFiles
.
length
>
0
||
renamedFiles
.
length
>
0
||
renamedFiles
.
length
>
0
||
deletedFiles
.
length
>
0
||
deletedFiles
.
length
>
0
||
dyadAddDependencyPackages
.
length
>
0
||
dyadAddDependencyPackages
.
length
>
0
;
writtenSqlMigrationFiles
>
0
;
let
uncommittedFiles
:
string
[]
=
[];
let
uncommittedFiles
:
string
[]
=
[];
let
extraFilesError
:
string
|
undefined
;
let
extraFilesError
:
string
|
undefined
;
...
...
src/ipc/utils/file_utils.ts
浏览文件 @
65b3d9cb
...
@@ -67,7 +67,7 @@ export async function writeMigrationFile(
...
@@ -67,7 +67,7 @@ export async function writeMigrationFile(
appPath
:
string
,
appPath
:
string
,
queryContent
:
string
,
queryContent
:
string
,
queryDescription
?:
string
,
queryDescription
?:
string
,
)
{
)
:
Promise
<
string
>
{
const
migrationsDir
=
path
.
join
(
appPath
,
"supabase"
,
"migrations"
);
const
migrationsDir
=
path
.
join
(
appPath
,
"supabase"
,
"migrations"
);
await
fsExtra
.
ensureDir
(
migrationsDir
);
await
fsExtra
.
ensureDir
(
migrationsDir
);
...
@@ -94,6 +94,7 @@ export async function writeMigrationFile(
...
@@ -94,6 +94,7 @@ export async function writeMigrationFile(
const
migrationFilePath
=
path
.
join
(
migrationsDir
,
migrationFileName
);
const
migrationFilePath
=
path
.
join
(
migrationsDir
,
migrationFileName
);
await
fsExtra
.
writeFile
(
migrationFilePath
,
queryContent
);
await
fsExtra
.
writeFile
(
migrationFilePath
,
queryContent
);
return
path
.
relative
(
appPath
,
migrationFilePath
);
}
}
export
async
function
fileExists
(
filePath
:
string
)
{
export
async
function
fileExists
(
filePath
:
string
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论