-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: iceworks project viewer style(#177)
* feat: add stop command * feat: add stop command * feat: auto install deps * feat: refresh when file changed * fix: fix terminal dispose * fix: treeItem class name * fix: comment * feat: add inputboxs * chore: inputBox text
- Loading branch information
Showing
20 changed files
with
271 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as vscode from 'vscode'; | ||
import { Terminal, TerminalOptions } from 'vscode'; | ||
import { ITerminalMap } from '../types'; | ||
|
||
export default function executeCommand(terminalMapping: ITerminalMap, script: vscode.Command, id?: string) { | ||
if (!script.arguments) { | ||
return; | ||
} | ||
const args = script.arguments; | ||
const [cwd, command] = args; | ||
if (!command) { | ||
return; | ||
} | ||
|
||
const terminalId = id || command; | ||
let terminal: Terminal; | ||
|
||
if (terminalMapping.has(terminalId)) { | ||
terminal = terminalMapping.get(terminalId)!; | ||
} else { | ||
const terminalOptions: TerminalOptions = { cwd, name: command }; | ||
terminal = vscode.window.createTerminal(terminalOptions); | ||
terminalMapping.set(terminalId, terminal); | ||
} | ||
|
||
terminal.show(); | ||
terminal.sendText(command); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ITerminalMap } from '../types'; | ||
|
||
export default function stopCommand(terminalMapping: ITerminalMap, scriptId: string) { | ||
const currentTerminal = terminalMapping.get(scriptId); | ||
if (currentTerminal) { | ||
currentTerminal.dispose(); | ||
terminalMapping.delete(scriptId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as vscode from 'vscode'; | ||
import { NodeDepTypes, ITerminalMap } from '../types'; | ||
import executeCommand from '../commands/executeCommand'; | ||
|
||
export default async function showDepsInputBox(terminals: ITerminalMap, nodeDependenciesInstance: any, depType: NodeDepTypes) { | ||
const result = await vscode.window.showInputBox({ | ||
placeHolder: '例如: lodash react@latest', | ||
prompt: `请输入需要添加到 ${depType} 的依赖名称, 支持通过空格添加多个依赖` | ||
}); | ||
if (!result) { | ||
return; | ||
} | ||
executeCommand(terminals, nodeDependenciesInstance.getAddDependencyScript(depType, result)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as path from 'path'; | ||
import * as vscode from 'vscode'; | ||
import * as fsExtra from 'fs-extra'; | ||
import { entryFileSuffix } from './constants'; | ||
|
||
export default function openEntryFile(p: string) { | ||
const currentSuffix = entryFileSuffix.find((suffix) => fsExtra.pathExistsSync(path.join(p, `index${suffix}`))); | ||
if (currentSuffix) { | ||
const resource = vscode.Uri.file(path.join(p, `index${currentSuffix}`)); | ||
vscode.window.showTextDocument(resource); | ||
} else { | ||
vscode.window.showErrorMessage('Entry file not found.'); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
extensions/iceworks-app/src/quickPicks/showDepsQuickPick.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as vscode from 'vscode'; | ||
import { nodeDepTypes } from '../constants'; | ||
import { NodeDepTypes, ITerminalMap } from '../types'; | ||
import showDepsInputBox from '../inputBoxs/showDepsInputBox'; | ||
|
||
export default function showDepsQuickPick(terminals: ITerminalMap, nodeDependenciesInstance: any) { | ||
const quickPick = vscode.window.createQuickPick(); | ||
quickPick.items = nodeDepTypes.map(label => ({ label, detail: `Install ${label}` })); | ||
quickPick.onDidChangeSelection(selection => { | ||
if (selection[0]) { | ||
showDepsInputBox(terminals, nodeDependenciesInstance, selection[0].label as NodeDepTypes) | ||
.catch(console.error); | ||
} | ||
}); | ||
quickPick.onDidHide(() => quickPick.dispose()); | ||
quickPick.show(); | ||
}; |
15 changes: 3 additions & 12 deletions
15
...s/iceworks-app/src/createStatusBarItem.ts → ...src/quickPicks/showExtensionsQuickPick.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
extensions/iceworks-app/src/statusBar/createExtensionsStatusBar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as vscode from 'vscode'; | ||
import { showExtensionsQuickPickCommandId } from '../constants'; | ||
|
||
export default function createExtensionsStatusBar() { | ||
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100); | ||
statusBarItem.text = 'Iceworks'; | ||
statusBarItem.command = showExtensionsQuickPickCommandId; | ||
statusBarItem.show(); | ||
return statusBarItem; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.