-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vscode): Angular JSON tree provider
- Loading branch information
Showing
15 changed files
with
443 additions
and
84 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
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,67 @@ | ||
import { | ||
commands, | ||
ExtensionContext, | ||
Task, | ||
tasks, | ||
window, | ||
TaskScope | ||
} from 'vscode'; | ||
|
||
import { NgTaskProvider } from './ng-task-provider/ng-task-provider'; | ||
import { NgTaskDefinition } from './ng-task-provider/ng-task-definition'; | ||
|
||
let ngTaskProvider: NgTaskProvider; | ||
export function registerNgCliCommands( | ||
context: ExtensionContext, | ||
n: NgTaskProvider | ||
) { | ||
ngTaskProvider = n; | ||
|
||
['build', 'lint', 'deploy', 'e2e', 'serve', 'test', 'xi18n'].forEach( | ||
command => { | ||
context.subscriptions.push( | ||
commands.registerCommand( | ||
`ng-console.${command}`, | ||
runNgCliCommand(command) | ||
) | ||
); | ||
} | ||
); | ||
} | ||
|
||
function runNgCliCommand(command: string) { | ||
return () => { | ||
const items = ngTaskProvider | ||
.getProjectEntries() | ||
.map(([projectName, { architect }]) => ({ | ||
projectName, | ||
architectDef: architect && architect[command] | ||
})) | ||
.filter(({ architectDef }) => Boolean(architectDef)) | ||
.flatMap(({ architectDef, projectName }) => | ||
[undefined, ...Object.keys(architectDef!.configurations || {})].map(c => | ||
c ? `${projectName} --configuration=${c}` : projectName | ||
) | ||
); | ||
|
||
window.showQuickPick(items).then(selection => { | ||
if (!selection) { | ||
return; | ||
} | ||
|
||
const [projectName, configuration] = selection.split(' --configuration='); | ||
const taskDef: NgTaskDefinition = { | ||
type: 'ng', | ||
projectName, | ||
configuration, | ||
architectName: command | ||
}; | ||
const task = ngTaskProvider.resolveTask( | ||
new Task(taskDef, TaskScope.Workspace, 'n/a', 'n/a') | ||
); | ||
if (task) { | ||
tasks.executeTask(task); | ||
} | ||
}); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
apps/vscode/src/app/ng-task-provider/ng-task-definition.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,42 @@ | ||
export interface NgTaskDefinition { | ||
type: string; | ||
projectName: string; | ||
architectName: string; | ||
configuration?: string; | ||
} | ||
|
||
export interface ArchitectDef { | ||
configurations?: { | ||
[configuration: string]: {}; | ||
}; | ||
} | ||
|
||
export interface ProjectDef { | ||
root: string; | ||
architect?: { | ||
[architectName: string]: ArchitectDef; | ||
}; | ||
} | ||
|
||
export interface Projects { | ||
[projectName: string]: ProjectDef; | ||
} | ||
|
||
export interface AngularJson { | ||
projects: Projects; | ||
} | ||
|
||
export function getArchitectTaskDefintions( | ||
defaultTaskDefinition: NgTaskDefinition, | ||
architectDef: ArchitectDef | ||
) { | ||
return [ | ||
defaultTaskDefinition, | ||
...Object.keys(architectDef.configurations || {}).map( | ||
(configuration): NgTaskDefinition => ({ | ||
...defaultTaskDefinition, | ||
configuration | ||
}) | ||
) | ||
]; | ||
} |
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
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
Oops, something went wrong.