Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b284750
feat: check if a command is registered.
theschitz Feb 20, 2022
60fcbd5
style: the code needs to breathe
theschitz Feb 20, 2022
db33048
feat: add postConversionTasks and item.
theschitz Feb 20, 2022
6b19257
Merge branch 'master' into 302-post-template-conversion-tasks
theschitz Feb 20, 2022
8bd4aec
cast as Error
theschitz Feb 20, 2022
574e1bd
add postConversionTasks
theschitz Feb 20, 2022
2fd9c02
feat: TaskRunner
theschitz Feb 20, 2022
982cd39
add postConversionTasks to template
theschitz Feb 21, 2022
c661095
Merge branch 'master' into 302-post-template-conversion-tasks
theschitz Feb 21, 2022
b407b88
export/import tasks
theschitz Mar 3, 2022
55c3c3c
style: import statement spring cleaning
theschitz Mar 4, 2022
d5c1747
style: the code needs to breath
theschitz Mar 4, 2022
17e80e1
feat(VSCodeFunctions): showConfirmDialog
theschitz Mar 4, 2022
643d9a4
refactor: it's a showMessage handler!
theschitz Mar 4, 2022
ab922a2
run remaining tasks on activation
theschitz Mar 4, 2022
1588ec0
rename functions
theschitz Mar 4, 2022
8bb3197
use thenable hehe
theschitz Mar 4, 2022
ee908cd
delete task files
theschitz Mar 4, 2022
093df4d
add openFile
theschitz Mar 4, 2022
919b009
test
theschitz Mar 4, 2022
35fed47
Merge branch 'master' into 302-post-template-conversion-tasks
theschitz Mar 4, 2022
5285cd9
chore: add template-app to workspace
theschitz Mar 5, 2022
085bc73
transfer postConversionTasks on construct
theschitz Mar 5, 2022
a60e52d
check length
theschitz Mar 5, 2022
1b92b93
test deserialization of postConversionTasks
theschitz Mar 5, 2022
0445622
add logging and telemetry
theschitz Mar 5, 2022
8b68e0c
fix: casing in template-app workspace
theschitz Mar 5, 2022
18c76f5
get root dir
theschitz Mar 5, 2022
b11fdce
try catch and do nothing
theschitz Mar 6, 2022
43a077e
Test import
theschitz Mar 6, 2022
2d77fba
Merge branch 'master' into 302-post-template-conversion-tasks
theschitz Apr 4, 2022
3538484
remove property required
theschitz Apr 4, 2022
d1672ef
use SettingsLoader to get workspace folder path
theschitz Apr 4, 2022
6d049d2
only log if there's tasks to run
theschitz Apr 4, 2022
6c655f5
remove property required.
theschitz Apr 4, 2022
d1fa4c3
delete file on successful execution
theschitz Apr 4, 2022
e749add
Merge branch 'master' into 302-post-template-conversion-tasks
theschitz Apr 15, 2022
40245c8
extract to function
theschitz Apr 15, 2022
56ee124
showTextDocument
theschitz Apr 15, 2022
ddb4c1f
test: required removed test error in commandsExists instead
theschitz Apr 15, 2022
7a4ad41
test: TaskRunner.openFile
theschitz Apr 15, 2022
3a28a5f
remove commented code
theschitz Apr 15, 2022
b08cb9a
test: deleteTaskFile
theschitz Apr 15, 2022
7c5ad05
move test
theschitz Apr 15, 2022
4a5b146
test: remove unnecessary assertions
theschitz Apr 15, 2022
3953f2d
test: disable naughty test
theschitz Apr 16, 2022
c1d06ae
test: deleteTaskFile but with a better command
theschitz Apr 16, 2022
8d2c777
delete task file before executing command. We have nog guarantees tha…
theschitz Apr 16, 2022
eb34487
forEach is the devil!
theschitz Apr 16, 2022
9e8ff42
refactor: replace forEach with for
theschitz Apr 16, 2022
3157dd1
constructor parameter optional
theschitz Apr 16, 2022
e5188c3
remove required property from required properties ;)
theschitz Apr 16, 2022
b442de5
add reloadWindow property
theschitz Apr 16, 2022
7c9d0df
deleteTaskFile: clear taskpath
theschitz Apr 16, 2022
3276736
handle reload and task file deletion
theschitz Apr 16, 2022
5200a32
if no workspace file is found execute all
theschitz Apr 16, 2022
415340b
remove word required from string
theschitz Apr 16, 2022
8971cdb
improved error message
theschitz Apr 16, 2022
2844adc
remove unnecessary assignments
theschitz Apr 16, 2022
10c63ff
remove comment, move function
theschitz Apr 16, 2022
cfa3ffb
add item to iteration test
theschitz Apr 16, 2022
3676d20
fix expected error message
theschitz Apr 17, 2022
14c2f35
remove uniqueItems constraint
theschitz Apr 17, 2022
7cabb9d
feat(template/TaskRunner): support command arguments
theschitz Apr 17, 2022
acf2230
docs: update changelog and readme
theschitz Apr 17, 2022
76815ce
test: open file error
theschitz Apr 17, 2022
66fee31
normalize path
theschitz Apr 17, 2022
22a9325
Merge branch '302-post-template-conversion-tasks' into dev/post-templ…
theschitz Apr 17, 2022
ac11cb8
test: task with arguments
theschitz Apr 17, 2022
20ebd01
Merge branch 'master' into dev/post-template-task-v2
theschitz Apr 17, 2022
a04be73
test: use existing extension for test
theschitz Apr 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions extension/src/Template/TaskRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ export class TaskRunner {
if (this.isReloadingCommand(task.command)) {
this.deleteTaskFile(task);
}
await vscode.commands.executeCommand(task.command).then(
() => {
/**
* NOTE: We have no guarantee that this will trigger when running arbitrary commands.
*
* Commands triggering reload should be added to TaskRunner.reloadingCommands.
*/
this.deleteTaskFile(task);
},
(reason) => {
throw new Error(reason);
}
);

await vscode.commands
.executeCommand(task.command, task.arguments ?? [])
.then(
() => {
/**
* NOTE: We have no guarantee that this will trigger when running arbitrary commands.
*
* Commands triggering reload should be added to TaskRunner.reloadingCommands.
*/
this.deleteTaskFile(task);
},
(reason) => {
throw new Error(reason);
}
);
if (task.reloadWindow) {
await vscode.commands.executeCommand(this.reloadingCommands.reloadWindow);
}
Expand Down
15 changes: 15 additions & 0 deletions extension/src/Template/TaskRunnerItem.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { Position, Uri } from "vscode";

export interface TaskRunnerItem {
description: string;
command: string;
arguments?: CommandParameter[];
openFile?: string;
taskPath?: string;
reloadWindow?: boolean;
}

// Allowed arguments types for vscode.commands.executeCommand
type CommandParameter =
| string
| boolean
| number
| undefined
| null
| Position
| Range
| Uri
| Location;
13 changes: 13 additions & 0 deletions extension/src/test/TaskRunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,17 @@ suite("Task Runner Tests", function () {
await taskRunner.executeAll();
}, "Unexpected rejection of promise.");
});

test("Task with parameters", async function () {
const task: TaskRunnerItem = {
description: "Diff files.",
command: "vscode.openIssueReporter",
arguments: ["nabsolutions.nab-al-tools"],
};
const taskRunner = new TaskRunner([]);

await assert.doesNotReject(async () => {
await taskRunner.execute(task);
}, "Unexpected rejection of promise.");
});
});
4 changes: 4 additions & 0 deletions extension/syntaxes/templateSettingsSyntax.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@
"type": "string",
"minLength": 1
},
"arguments": {
"description": "Specifies arguments passed with the command to vscode.commands.executeCommand. Note that not all commands support arguments.",
"type": "array"
},
"openFile": {
"description": "Specifies a file path to be opened before running the task. The path should be relative to the workspace root.",
"type": "string"
Expand Down