Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
f2b157b8
提交
f2b157b8
authored
4月 18, 2025
作者:
Will Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplified setup flow: user installs node.js; pnpm is configured
上级
ffdf3e1c
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
43 行增加
和
135 行删除
+43
-135
SetupBanner.tsx
src/components/SetupBanner.tsx
+0
-0
node_handlers.ts
src/ipc/handlers/node_handlers.ts
+31
-106
ipc_client.ts
src/ipc/ipc_client.ts
+6
-15
ipc_types.ts
src/ipc/ipc_types.ts
+5
-10
home.tsx
src/pages/home.tsx
+0
-4
preload.ts
src/preload.ts
+1
-0
没有找到文件。
src/components/SetupBanner.tsx
浏览文件 @
f2b157b8
差异被折叠。
点击展开。
src/ipc/handlers/node_handlers.ts
浏览文件 @
f2b157b8
import
{
ipcMain
}
from
"electron"
;
import
{
ipcMain
,
app
}
from
"electron"
;
import
{
spawn
}
from
"child_process"
;
import
{
platform
}
from
"os"
;
import
{
InstallNodeResult
}
from
"../ipc_types"
;
type
ShellResult
=
|
{
success
:
true
;
output
:
string
;
}
|
{
success
:
false
;
errorMessage
:
string
;
};
function
runShell
(
command
:
string
):
Promise
<
ShellResult
>
{
return
new
Promise
((
resolve
)
=>
{
let
stdout
=
""
;
let
stderr
=
""
;
const
process
=
spawn
(
command
,
{
shell
:
true
,
stdio
:
[
"ignore"
,
"pipe"
,
"pipe"
],
// ignore stdin, pipe stdout/stderr
});
process
.
stdout
?.
on
(
"data"
,
(
data
)
=>
{
stdout
+=
data
.
toString
();
});
process
.
stderr
?.
on
(
"data"
,
(
data
)
=>
{
stderr
+=
data
.
toString
();
});
process
.
on
(
"error"
,
(
error
)
=>
{
console
.
error
(
`Error executing command "
${
command
}
":`
,
error
.
message
);
resolve
({
success
:
false
,
errorMessage
:
error
.
message
});
});
process
.
on
(
"close"
,
(
code
)
=>
{
if
(
code
===
0
)
{
resolve
({
success
:
true
,
output
:
stdout
.
trim
()
});
}
else
{
const
errorMessage
=
stderr
.
trim
()
||
`Command failed with code
${
code
}
`
;
console
.
error
(
`Command "
${
command
}
" failed with code
${
code
}
:
${
stderr
.
trim
()}
`
);
resolve
({
success
:
false
,
errorMessage
});
}
});
});
}
import
{
platform
,
arch
}
from
"os"
;
import
{
NodeSystemInfo
}
from
"../ipc_types"
;
function
checkCommandExists
(
command
:
string
):
Promise
<
string
|
null
>
{
return
new
Promise
((
resolve
)
=>
{
let
output
=
""
;
const
process
=
spawn
(
command
,
[
"--version"
],
{
const
process
=
spawn
(
command
,
{
shell
:
true
,
stdio
:
[
"ignore"
,
"pipe"
,
"pipe"
],
// ignore stdin, pipe stdout/stderr
});
...
...
@@ -87,64 +41,35 @@ function checkCommandExists(command: string): Promise<string | null> {
}
export
function
registerNodeHandlers
()
{
ipcMain
.
handle
(
"nodejs-status"
,
async
():
Promise
<
{
nodeVersion
:
string
|
null
;
pnpmVersion
:
string
|
null
;
}
>
=>
{
// Run checks in parallel
const
[
nodeVersion
,
pnpmVersion
]
=
await
Promise
.
all
([
checkCommandExists
(
"node"
),
checkCommandExists
(
"pnpm"
),
]);
return
{
nodeVersion
,
pnpmVersion
};
}
);
ipcMain
.
handle
(
"install-node"
,
async
():
Promise
<
InstallNodeResult
>
=>
{
console
.
log
(
"Installing Node.js..."
);
if
(
platform
()
===
"win32"
)
{
let
result
=
await
runShell
(
"winget install Volta.Volta"
);
if
(
!
result
.
success
)
{
return
{
success
:
false
,
errorMessage
:
result
.
errorMessage
};
}
}
else
{
let
result
=
await
runShell
(
"curl https://get.volta.sh | bash"
);
if
(
!
result
.
success
)
{
return
{
success
:
false
,
errorMessage
:
result
.
errorMessage
};
ipcMain
.
handle
(
"nodejs-status"
,
async
():
Promise
<
NodeSystemInfo
>
=>
{
// Run checks in parallel
const
[
nodeVersion
,
pnpmVersion
]
=
await
Promise
.
all
([
checkCommandExists
(
"node --version"
),
// First, check if pnpm is installed.
// If not, try to install it using corepack.
// If both fail, then pnpm is not available.
checkCommandExists
(
"pnpm --version || corepack enable pnpm && pnpm --version"
),
]);
// Default to mac download url.
let
nodeDownloadUrl
=
"https://nodejs.org/dist/v22.14.0/node-v22.14.0.pkg"
;
if
(
platform
()
==
"win32"
)
{
if
(
arch
()
===
"arm64"
||
arch
()
===
"arm"
)
{
nodeDownloadUrl
=
"https://nodejs.org/dist/v22.14.0/node-v22.14.0-arm64.msi"
;
}
else
{
// x64 is the most common architecture for Windows so it's the
// default download url.
nodeDownloadUrl
=
"https://nodejs.org/dist/v22.14.0/node-v22.14.0-x64.msi"
;
}
}
console
.
log
(
"Installed Volta"
);
process
.
env
.
PATH
=
[
"~/.volta/bin"
,
process
.
env
.
PATH
].
join
(
":"
);
console
.
log
(
"Updated PATH"
);
let
result
=
await
runShell
(
"volta install node"
);
if
(
!
result
.
success
)
{
return
{
success
:
false
,
errorMessage
:
result
.
errorMessage
};
}
console
.
log
(
"Installed Node.js (via Volta)"
);
result
=
await
runShell
(
"node --version"
);
if
(
!
result
.
success
)
{
return
{
success
:
false
,
errorMessage
:
result
.
errorMessage
};
}
const
nodeVersion
=
result
.
output
.
trim
();
console
.
log
(
"Node.js is setup with version"
,
nodeVersion
);
result
=
await
runShell
(
"corepack enable pnpm"
);
if
(
!
result
.
success
)
{
return
{
success
:
false
,
errorMessage
:
result
.
errorMessage
};
}
console
.
log
(
"Enabled pnpm"
);
result
=
await
runShell
(
"pnpm --version"
);
if
(
!
result
.
success
)
{
return
{
success
:
false
,
errorMessage
:
result
.
errorMessage
};
}
const
pnpmVersion
=
result
.
output
.
trim
();
console
.
log
(
"pnpm is setup with version"
,
pnpmVersion
);
return
{
nodeVersion
,
pnpmVersion
,
nodeDownloadUrl
};
});
return
{
success
:
true
,
nodeVersion
,
pnpmVersion
};
ipcMain
.
handle
(
"reload-dyad"
,
async
():
Promise
<
void
>
=>
{
app
.
relaunch
();
app
.
exit
(
0
);
});
}
src/ipc/ipc_client.ts
浏览文件 @
f2b157b8
...
...
@@ -15,6 +15,7 @@ import type {
CreateAppResult
,
InstallNodeResult
,
ListAppsResponse
,
NodeSystemInfo
,
SandboxConfig
,
Version
,
}
from
"./ipc_types"
;
...
...
@@ -132,6 +133,10 @@ export class IpcClient {
return
IpcClient
.
instance
;
}
public
async
reloadDyad
():
Promise
<
void
>
{
await
this
.
ipcRenderer
.
invoke
(
"reload-dyad"
);
}
// Create a new app with an initial chat
public
async
createApp
(
params
:
CreateAppParams
):
Promise
<
CreateAppResult
>
{
try
{
...
...
@@ -493,10 +498,7 @@ export class IpcClient {
}
// Check Node.js and npm status
public
async
getNodejsStatus
():
Promise
<
{
nodeVersion
:
string
|
null
;
pnpmVersion
:
string
|
null
;
}
>
{
public
async
getNodejsStatus
():
Promise
<
NodeSystemInfo
>
{
try
{
const
result
=
await
this
.
ipcRenderer
.
invoke
(
"nodejs-status"
);
return
result
;
...
...
@@ -506,17 +508,6 @@ export class IpcClient {
}
}
// Install Node.js and npm
public
async
installNode
():
Promise
<
InstallNodeResult
>
{
try
{
const
result
=
await
this
.
ipcRenderer
.
invoke
(
"install-node"
);
return
result
;
}
catch
(
error
)
{
showError
(
error
);
throw
error
;
}
}
// --- GitHub Device Flow ---
public
startGithubDeviceFlow
(
appId
:
number
|
null
):
void
{
this
.
ipcRenderer
.
invoke
(
"github:start-flow"
,
{
appId
});
...
...
src/ipc/ipc_types.ts
浏览文件 @
f2b157b8
...
...
@@ -66,13 +66,8 @@ export interface SandboxConfig {
entry
:
string
;
}
export
type
InstallNodeResult
=
|
{
success
:
true
;
nodeVersion
:
string
;
pnpmVersion
:
string
;
}
|
{
success
:
false
;
errorMessage
:
string
;
};
export
interface
NodeSystemInfo
{
nodeVersion
:
string
|
null
;
pnpmVersion
:
string
|
null
;
nodeDownloadUrl
:
string
;
}
src/pages/home.tsx
浏览文件 @
f2b157b8
...
...
@@ -84,10 +84,6 @@ export default function HomePage() {
// Main Home Page Content
return
(
<
div
className=
"flex flex-col items-center justify-center max-w-3xl m-auto p-8"
>
<
h1
className=
"text-6xl font-bold mb-12 bg-clip-text text-transparent bg-gradient-to-r from-gray-900 to-gray-600 dark:from-gray-100 dark:to-gray-400 tracking-tight"
>
Build your dream app
</
h1
>
<
SetupBanner
/>
<
div
className=
"w-full"
>
...
...
src/preload.ts
浏览文件 @
f2b157b8
...
...
@@ -37,6 +37,7 @@ const validInvokeChannels = [
"github:create-repo"
,
"github:push"
,
"get-app-version"
,
"reload-dyad"
,
]
as
const
;
// Add valid receive channels
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论