-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: dependency check before starting a task #2421
feat: dependency check before starting a task #2421
Conversation
chenbin92
commented
Jul 11, 2019
•
edited
Loading
edited
- 执行任务前检查依赖是否安装,如果未安装则给出对应的提示
- 日志流写入到 Global
- 日志流写入到当前 Xterm 中
@@ -68,11 +68,17 @@ function useDependency(diableUseSocket) { | |||
await dependenciesStore.reset(); | |||
|
|||
setResetModal(false); | |||
globalTerminalStore.show(); | |||
|
|||
if (showGlobalTerminal) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果要封装 showGlobalTerminal 这个参数的话,建议是把 globalTerminalStore.show();
封装一下,这样控制掉所有的这个场景,不仅仅是 reset 这个场景。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
怎么封装,没理解
} | ||
|
||
if (!diableUseSocket) { | ||
useSocket('adapter.dependency.reset.data', writeGlobalLog); | ||
if (writeChunk) { | ||
useSocket('adapter.dependency.reset.data', data => writeChunk(data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议在外部处理这个逻辑,不封装到 useDependency 内。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 外部处理是指在哪里处理?
- 不封装到 useDependency 的理由?
封装到 useDependency 的理由:封装 useDependency 本来是为了共用的,与写入到 Global 保持一致都在 useDependency 处理。反而写入到 Global 可以写在 useDependency 而 WriteChunk 不可以写的考虑是怎样的呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是这个考虑的话,
那是不是所有有 writeGlobalLog 的地方都同时 writeChunk ?
function writeLog(data) {
writeGlobalLog(data);
writeChunk(data);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 场景:在这里安装依赖的前提是启动调试服务,日志流都在工程面板输出合理
- 那是不是所有有 writeGlobalLog 的地方都同时 writeChunk ?
肯定不是,log 是人为输出的可读的操作日志,chunk 是类似 npm install 和 npm run start 的流数据
|
||
async function onStart() { | ||
try { | ||
writeLog(type); | ||
await taskStore.start(type); | ||
if (!taskStore.dataSource.installed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议是将这个状态放入 dependenciesStore。
这里应该是:
if (!dependenciesStore.dataSource.installed) {
setInstallDependencyVisible(true);
return;
}
installDependencyVisible, | ||
onInstallDependencyCancel, | ||
onInstallDependencyOk, | ||
} = useTask({ type, writeLog, writeChunk }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果将 installed 状态放入 dependenciesStore ,则 useTask 内部不需要包含 useDependency 逻辑?
可以直接使用 useDependency 内的状态:
- installDependencyVisible => onResetModal
- onInstallDependencyCancel => onResetModalCancel
- onInstallDependencyOk => onResetModalOk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是封装到 dependency/index.ts 中更合适呢
同下面一个问题:#2421 (diff)
- 放在 useDependency 的检查时机是什么呢,每次都去请求一遍?如果是这样的话我觉得放在 task 更合理,触发时机就是
start
,build
,lint
等时机,这个字段也是工程需要的,dependency 并太在意是否安装过
- onResetModal 这个语义太难理解了
请同时处理 QuickDevPanel |
@@ -20,6 +20,8 @@ export default class Task implements ITaskModule { | |||
|
|||
private status: object = {}; | |||
|
|||
private installed: boolean = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是封装到 dependency/index.ts 中更合适呢
QuickDevPanel 和 quickBuildPanel 已加 |
installed 在 taskStore 感觉真心不合适呀。 |
不只是初始化,还需要考虑用户在直接在目录里面删除,然后每次获取的时候在去执行一遍? |
refresh 是每次都会做的呀。 |
从另外一个角度考虑:启动工程对应的是 package.json 中的 scripts 脚本,假设我们在命令行中执行
这里想表达的是这里是存在对应关系的,可以放在一起处理,至于是否更合理,我觉得需要整体看下 |