Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
99e6592a
Unverified
提交
99e6592a
authored
6月 11, 2025
作者:
Will Chen
提交者:
GitHub
6月 11, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit upgrade (#391)
上级
007e0b2f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
2 行删除
+31
-2
select_component.spec.ts
e2e-tests/select_component.spec.ts
+2
-0
app_upgrade_handlers.ts
src/ipc/handlers/app_upgrade_handlers.ts
+18
-1
git_utils.ts
src/ipc/utils/git_utils.ts
+11
-1
没有找到文件。
e2e-tests/select_component.spec.ts
浏览文件 @
99e6592a
...
@@ -61,6 +61,8 @@ testSkipIfWindows("upgrade app to select component", async ({ po }) => {
...
@@ -61,6 +61,8 @@ testSkipIfWindows("upgrade app to select component", async ({ po }) => {
await
po
.
expectNoAppUpgrades
();
await
po
.
expectNoAppUpgrades
();
await
po
.
snapshotAppFiles
();
await
po
.
snapshotAppFiles
();
await
po
.
clickOpenInChatButton
();
await
po
.
clickOpenInChatButton
();
// There should be another version from the upgrade being committed.
await
expect
(
po
.
page
.
getByText
(
"Version 2"
)).
toBeVisible
();
await
po
.
clickPreviewPickElement
();
await
po
.
clickPreviewPickElement
();
...
...
src/ipc/handlers/app_upgrade_handlers.ts
浏览文件 @
99e6592a
...
@@ -8,6 +8,7 @@ import { getDyadAppPath } from "../../paths/paths";
...
@@ -8,6 +8,7 @@ import { getDyadAppPath } from "../../paths/paths";
import
fs
from
"node:fs"
;
import
fs
from
"node:fs"
;
import
path
from
"node:path"
;
import
path
from
"node:path"
;
import
{
spawn
}
from
"node:child_process"
;
import
{
spawn
}
from
"node:child_process"
;
import
{
gitAddAll
,
gitCommit
}
from
"../utils/git_utils"
;
const
logger
=
log
.
scope
(
"app_upgrade_handlers"
);
const
logger
=
log
.
scope
(
"app_upgrade_handlers"
);
const
handle
=
createLoggedHandler
(
logger
);
const
handle
=
createLoggedHandler
(
logger
);
...
@@ -109,7 +110,7 @@ async function applyComponentTagger(appPath: string) {
...
@@ -109,7 +110,7 @@ async function applyComponentTagger(appPath: string) {
await
fs
.
promises
.
writeFile
(
viteConfigPath
,
content
);
await
fs
.
promises
.
writeFile
(
viteConfigPath
,
content
);
// Install the dependency
// Install the dependency
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
await
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
logger
.
info
(
"Installing component-tagger dependency"
);
logger
.
info
(
"Installing component-tagger dependency"
);
const
process
=
spawn
(
const
process
=
spawn
(
"pnpm add -D @dyad-sh/react-vite-component-tagger || npm install --save-dev --legacy-peer-deps @dyad-sh/react-vite-component-tagger"
,
"pnpm add -D @dyad-sh/react-vite-component-tagger || npm install --save-dev --legacy-peer-deps @dyad-sh/react-vite-component-tagger"
,
...
@@ -138,6 +139,22 @@ async function applyComponentTagger(appPath: string) {
...
@@ -138,6 +139,22 @@ async function applyComponentTagger(appPath: string) {
reject
(
err
);
reject
(
err
);
});
});
});
});
// Commit changes
try
{
logger
.
info
(
"Staging and committing changes"
);
await
gitAddAll
({
path
:
appPath
});
await
gitCommit
({
path
:
appPath
,
message
:
"[dyad] add Dyad component tagger"
,
});
logger
.
info
(
"Successfully committed changes"
);
}
catch
(
err
)
{
logger
.
warn
(
`Failed to commit changes. This may happen if the project is not in a git repository, or if there are no changes to commit.`
,
err
,
);
}
}
}
export
function
registerAppUpgradeHandlers
()
{
export
function
registerAppUpgradeHandlers
()
{
...
...
src/ipc/utils/git_utils.ts
浏览文件 @
99e6592a
...
@@ -74,7 +74,7 @@ export async function gitStageToRevert({
...
@@ -74,7 +74,7 @@ export async function gitStageToRevert({
return
;
return
;
}
}
// Safety: refuse to run if the work-tree isn
’
t clean.
// Safety: refuse to run if the work-tree isn
'
t clean.
const
{
stdout
:
wtStatus
}
=
await
execAsync
(
const
{
stdout
:
wtStatus
}
=
await
execAsync
(
`git -C "
${
path
}
" status --porcelain`
,
`git -C "
${
path
}
" status --porcelain`
,
);
);
...
@@ -138,3 +138,13 @@ export async function gitStageToRevert({
...
@@ -138,3 +138,13 @@ export async function gitStageToRevert({
});
});
}
}
}
}
export
async
function
gitAddAll
({
path
}:
{
path
:
string
}):
Promise
<
void
>
{
const
settings
=
readSettings
();
if
(
settings
.
enableNativeGit
)
{
await
execAsync
(
`git -C "
${
path
}
" add .`
);
return
;
}
else
{
return
git
.
add
({
fs
,
dir
:
path
,
filepath
:
"."
});
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论