Skip to content

Commit 3a1864d

Browse files
authored
sisoe24/0.16.0 (#23)
* Refactor placeholder replacements in launch_executable.ts * Remove duplicate import * Improve environment variables options #22 * Refactor resolveEnvVariables function and optimize environment variable replacement * Remove commented lines * Update readme * Update changelog * Rename file * Update readme * Update notification message for breaking changes in settings * Use property shorthand * Fix commands camelCaseName #21 * Update run_code.svg icon * Update changelog
1 parent a048544 commit 3a1864d

9 files changed

Lines changed: 167 additions & 114 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Change Log
22

3+
## [0.16.0] - 07/07/2024
4+
5+
### Changed
6+
7+
- Changed the `nuketools.environmentVariables` keys to use an array of strings rather than a single string (`{"VAR_NAME": ["value1", "value2", ...]}`)
8+
- Added new placeholders for the `nuketools.environmentVariables` setting: `${workspaceFolderBasename}` and `${userHome}`.
9+
- Added the ability to use any system environment variable in the `nuketools.environmentVariables` setting.
10+
11+
### Fixed
12+
13+
- Fixed light theme icon
14+
- Extensions commands for extra and packages now properly show a label rather than a variable name.
15+
316
## [0.15.1] - 07/07/2024
417

518
### Fixed

README.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Seamlessly integrate Nuke into your Visual Studio Code workflow, enabling you to
3939
- [1.7. BlinkScript](#17-blinkscript)
4040
- [1.8. Available Commands](#18-available-commands)
4141
- [1.9. Environment Variables](#19-environment-variables)
42+
- [Placeholders and Variables](#placeholders-and-variables)
4243
- [1.9.1. Additional Settings](#191-additional-settings)
4344
- [1.9.2. Network Settings](#192-network-settings)
4445
- [1.10. Windows Users](#110-windows-users)
@@ -163,19 +164,43 @@ NOTES:
163164

164165
## 1.9. Environment Variables
165166

166-
Add environment variables to the terminal instance with `$VAR_NAME` for system variables or `${workspaceFolder}` for the workspace folder.
167+
Add environment variables to the terminal instance using the `nukeTools.environmentVariables` setting.
167168

168169
```json
169170
{
170-
"nukeTools.environmentVariables": {
171-
"NUKE_PATH": "${workspaceFolder}/gizmo:$NUKE_PATH",
172-
"PYTHONPATH": "$PYTHONPATH:/path/to/python/lib",
173-
"API_KEY": "0a9f0381-aebb-4e40-a77a-2c381b08e0ea"
174-
}
171+
"nukeTools.environmentVariables": {
172+
"VAR_NAME": ["value1", "value2", ...]
173+
}
174+
}
175+
```
176+
177+
### Placeholders and Variables
178+
179+
- `${workspaceFolder}`: Current workspace folder
180+
- `${workspaceFolderBasename}`: Name of the workspace folder
181+
- `${userHome}`: User's home directory
182+
- `$VAR_NAME`: System environment variables
183+
184+
Example
185+
186+
```json
187+
{
188+
"nukeTools.environmentVariables": {
189+
"NUKE_PATH": [
190+
"${workspaceFolder}/gizmo",
191+
"$NUKE_PATH"
192+
],
193+
"PYTHONPATH": [
194+
"$MYLIB/path/to/python/lib"
195+
],
196+
"API_KEY": [
197+
"0a9f0381-aebb-4e40-a77a-2c381b08e0ea"
198+
]
199+
}
175200
}
176201
```
177202

178-
> Note: From my testing it seems that you can use the ':' separator for multiple paths even on Windows.
203+
The extension combines arrays of strings using the appropriate separator for the detected shell and operating system.
179204

180205
## 1.9.1. Additional Settings
181206

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,21 @@
143143
"type": "boolean"
144144
},
145145
"nukeTools.environmentVariables": {
146-
"description": "Environment variables that will be added when running an executable.",
146+
"description": "An object with environment variables that will be added when running an executable.",
147147
"type": "object",
148+
"additionalProperties": {
149+
"type": "array",
150+
"items": {
151+
"type": "string"
152+
}
153+
},
148154
"examples": [
149155
{
150-
"NUKE_PATH": "${workspaceFolder}/gizmos:$NUKE_PATH"
156+
"NUKE_PATH": [
157+
"${workspaceFolder}/${workspaceFolderBasename}/bin",
158+
"${userHome}/.nuke",
159+
"$NUKE_PATH"
160+
]
151161
}
152162
]
153163
},

resources/icons/light/run_code.svg

Lines changed: 3 additions & 4 deletions
Loading

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type ExecutableMap = {
99
[key: string]: ExecutableConfig;
1010
};
1111

12-
export type EnvVars = { [key: string]: string };
12+
export type EnvVars = { [key: string]: Array<string> };
1313

1414
type CommandMappings = "executablesMap";
1515

src/extension.ts

Lines changed: 68 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import { Version } from "./version";
1010
import * as executables from "./launch_executable";
1111
import * as nukeTemplate from "./create_project";
1212

13-
import { Version } from "./version";
14-
1513
import { BlinkSnippets } from "./blinkscript/blink_snippet";
1614
import { BlinkScriptFormat } from "./blinkscript/blink_format";
1715
import { BlinkScriptCompletionProvider } from "./blinkscript/blink_completion";
@@ -20,7 +18,7 @@ import { NukeCompletionProvider } from "./nuke/completitions";
2018
import { NukeNodesInspectorProvider } from "./nuke/nodes_tree";
2119

2220
import { showNotification } from "./notification";
23-
import { fetchPackagesLatestVersion } from "./fetch_packages";
21+
import { fetchPackagesLatestVersion } from "./packages_fetch";
2422
import { initializePackageLog } from "./packages";
2523
import { getConfig } from "./config";
2624

@@ -74,69 +72,88 @@ function registerBlinkScriptCommands(context: vscode.ExtensionContext): void {
7472
);
7573
}
7674

75+
type Action = {
76+
label: string;
77+
execute: () => void;
78+
};
79+
80+
interface ActionItem extends vscode.QuickPickItem {
81+
execute: () => void;
82+
}
83+
84+
function showActionPicker(items: Array<Action>) {
85+
const picker = vscode.window.createQuickPick();
86+
picker.items = items.map((item) => {
87+
return {
88+
label: item.label,
89+
execute: item.execute,
90+
};
91+
});
92+
93+
picker.onDidChangeSelection((selection) => {
94+
const selected = selection[0] as ActionItem;
95+
if (selected) {
96+
selected.execute();
97+
picker.hide();
98+
}
99+
});
100+
101+
picker.onDidHide(() => picker.dispose());
102+
picker.show();
103+
}
104+
77105
function registerPackagesCommands(context: vscode.ExtensionContext): void {
78-
const addExtras: Record<string, () => void> = {
79-
pysideTemplate: nukeTemplate.createTemplate,
80-
pythonStubs: stubs.addStubs,
81-
nukeServerSocket: nuke.addNukeServerSocket,
82-
vimDcc: nuke.addVimDcc,
83-
};
106+
const actions: Array<Action> = [
107+
{
108+
label: "Pyside Template",
109+
execute: nukeTemplate.createTemplate,
110+
},
111+
{
112+
label: "Python Stubs",
113+
execute: stubs.addStubs,
114+
},
115+
{
116+
label: "Nuke Server Socket",
117+
execute: nuke.addNukeServerSocket,
118+
},
119+
{
120+
label: "Vim DCC",
121+
execute: nuke.addVimDcc,
122+
},
123+
];
84124

85125
context.subscriptions.push(
86126
vscode.commands.registerCommand("nuke-tools.addPackages", () => {
87-
const picker = vscode.window.createQuickPick();
88-
picker.items = Object.keys(addExtras).map((key) => {
89-
return {
90-
label: key,
91-
};
92-
});
93-
94-
picker.onDidChangeSelection((selection) => {
95-
if (selection[0]) {
96-
addExtras[selection[0].label]();
97-
picker.hide();
98-
}
99-
});
100-
101-
picker.onDidHide(() => picker.dispose());
102-
picker.show();
127+
showActionPicker(actions);
103128
})
104129
);
105130
}
106131

107132
function registerExtraCommands(context: vscode.ExtensionContext): void {
108-
const extras: Record<string, () => void> = {
109-
clearPackagesCache: () => {
110-
initializePackageLog();
111-
fetchPackagesLatestVersion();
112-
vscode.window.showInformationMessage("Packages cached cleared.");
133+
const actions: Array<Action> = [
134+
{
135+
label: "Clear Package Cache",
136+
execute: () => {
137+
initializePackageLog();
138+
fetchPackagesLatestVersion();
139+
vscode.window.showInformationMessage("Packages cached cleared.");
140+
},
113141
},
114-
testRunInsideNuke: () => {
115-
void socket.sendDebugMessage();
142+
{
143+
label: "Send Debug Message",
144+
execute: socket.sendDebugMessage,
116145
},
117-
showNetworkAddresses: () => {
118-
vscode.window.showInformationMessage(socket.getAddresses());
146+
{
147+
label: "Show Network Addresses",
148+
execute: () => {
149+
vscode.window.showInformationMessage(socket.getAddresses());
150+
},
119151
},
120-
};
152+
];
121153

122154
context.subscriptions.push(
123155
vscode.commands.registerCommand("nuke-tools.extras", () => {
124-
const picker = vscode.window.createQuickPick();
125-
picker.items = Object.keys(extras).map((key) => {
126-
return {
127-
label: key,
128-
};
129-
});
130-
131-
picker.onDidChangeSelection((selection) => {
132-
if (selection[0]) {
133-
extras[selection[0].label]();
134-
picker.hide();
135-
}
136-
});
137-
138-
picker.onDidHide(() => picker.dispose());
139-
picker.show();
156+
showActionPicker(actions);
140157
})
141158
);
142159
}

0 commit comments

Comments
 (0)