Skip to content

Commit

Permalink
sisoe24/0.16.0 (#23)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sisoe24 authored Oct 10, 2024
1 parent a048544 commit 3a1864d
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 114 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## [0.16.0] - 07/07/2024

### Changed

- Changed the `nuketools.environmentVariables` keys to use an array of strings rather than a single string (`{"VAR_NAME": ["value1", "value2", ...]}`)
- Added new placeholders for the `nuketools.environmentVariables` setting: `${workspaceFolderBasename}` and `${userHome}`.
- Added the ability to use any system environment variable in the `nuketools.environmentVariables` setting.

### Fixed

- Fixed light theme icon
- Extensions commands for extra and packages now properly show a label rather than a variable name.

## [0.15.1] - 07/07/2024

### Fixed
Expand Down
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Seamlessly integrate Nuke into your Visual Studio Code workflow, enabling you to
- [1.7. BlinkScript](#17-blinkscript)
- [1.8. Available Commands](#18-available-commands)
- [1.9. Environment Variables](#19-environment-variables)
- [Placeholders and Variables](#placeholders-and-variables)
- [1.9.1. Additional Settings](#191-additional-settings)
- [1.9.2. Network Settings](#192-network-settings)
- [1.10. Windows Users](#110-windows-users)
Expand Down Expand Up @@ -163,19 +164,43 @@ NOTES:

## 1.9. Environment Variables

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

```json
{
"nukeTools.environmentVariables": {
"NUKE_PATH": "${workspaceFolder}/gizmo:$NUKE_PATH",
"PYTHONPATH": "$PYTHONPATH:/path/to/python/lib",
"API_KEY": "0a9f0381-aebb-4e40-a77a-2c381b08e0ea"
}
"nukeTools.environmentVariables": {
"VAR_NAME": ["value1", "value2", ...]
}
}
```

### Placeholders and Variables

- `${workspaceFolder}`: Current workspace folder
- `${workspaceFolderBasename}`: Name of the workspace folder
- `${userHome}`: User's home directory
- `$VAR_NAME`: System environment variables

Example

```json
{
"nukeTools.environmentVariables": {
"NUKE_PATH": [
"${workspaceFolder}/gizmo",
"$NUKE_PATH"
],
"PYTHONPATH": [
"$MYLIB/path/to/python/lib"
],
"API_KEY": [
"0a9f0381-aebb-4e40-a77a-2c381b08e0ea"
]
}
}
```

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

## 1.9.1. Additional Settings

Expand Down
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,21 @@
"type": "boolean"
},
"nukeTools.environmentVariables": {
"description": "Environment variables that will be added when running an executable.",
"description": "An object with environment variables that will be added when running an executable.",
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
},
"examples": [
{
"NUKE_PATH": "${workspaceFolder}/gizmos:$NUKE_PATH"
"NUKE_PATH": [
"${workspaceFolder}/${workspaceFolderBasename}/bin",
"${userHome}/.nuke",
"$NUKE_PATH"
]
}
]
},
Expand Down
7 changes: 3 additions & 4 deletions resources/icons/light/run_code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type ExecutableMap = {
[key: string]: ExecutableConfig;
};

export type EnvVars = { [key: string]: string };
export type EnvVars = { [key: string]: Array<string> };

type CommandMappings = "executablesMap";

Expand Down
119 changes: 68 additions & 51 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { Version } from "./version";
import * as executables from "./launch_executable";
import * as nukeTemplate from "./create_project";

import { Version } from "./version";

import { BlinkSnippets } from "./blinkscript/blink_snippet";
import { BlinkScriptFormat } from "./blinkscript/blink_format";
import { BlinkScriptCompletionProvider } from "./blinkscript/blink_completion";
Expand All @@ -20,7 +18,7 @@ import { NukeCompletionProvider } from "./nuke/completitions";
import { NukeNodesInspectorProvider } from "./nuke/nodes_tree";

import { showNotification } from "./notification";
import { fetchPackagesLatestVersion } from "./fetch_packages";
import { fetchPackagesLatestVersion } from "./packages_fetch";
import { initializePackageLog } from "./packages";
import { getConfig } from "./config";

Expand Down Expand Up @@ -74,69 +72,88 @@ function registerBlinkScriptCommands(context: vscode.ExtensionContext): void {
);
}

type Action = {
label: string;
execute: () => void;
};

interface ActionItem extends vscode.QuickPickItem {
execute: () => void;
}

function showActionPicker(items: Array<Action>) {
const picker = vscode.window.createQuickPick();
picker.items = items.map((item) => {
return {
label: item.label,
execute: item.execute,
};
});

picker.onDidChangeSelection((selection) => {
const selected = selection[0] as ActionItem;
if (selected) {
selected.execute();
picker.hide();
}
});

picker.onDidHide(() => picker.dispose());
picker.show();
}

function registerPackagesCommands(context: vscode.ExtensionContext): void {
const addExtras: Record<string, () => void> = {
pysideTemplate: nukeTemplate.createTemplate,
pythonStubs: stubs.addStubs,
nukeServerSocket: nuke.addNukeServerSocket,
vimDcc: nuke.addVimDcc,
};
const actions: Array<Action> = [
{
label: "Pyside Template",
execute: nukeTemplate.createTemplate,
},
{
label: "Python Stubs",
execute: stubs.addStubs,
},
{
label: "Nuke Server Socket",
execute: nuke.addNukeServerSocket,
},
{
label: "Vim DCC",
execute: nuke.addVimDcc,
},
];

context.subscriptions.push(
vscode.commands.registerCommand("nuke-tools.addPackages", () => {
const picker = vscode.window.createQuickPick();
picker.items = Object.keys(addExtras).map((key) => {
return {
label: key,
};
});

picker.onDidChangeSelection((selection) => {
if (selection[0]) {
addExtras[selection[0].label]();
picker.hide();
}
});

picker.onDidHide(() => picker.dispose());
picker.show();
showActionPicker(actions);
})
);
}

function registerExtraCommands(context: vscode.ExtensionContext): void {
const extras: Record<string, () => void> = {
clearPackagesCache: () => {
initializePackageLog();
fetchPackagesLatestVersion();
vscode.window.showInformationMessage("Packages cached cleared.");
const actions: Array<Action> = [
{
label: "Clear Package Cache",
execute: () => {
initializePackageLog();
fetchPackagesLatestVersion();
vscode.window.showInformationMessage("Packages cached cleared.");
},
},
testRunInsideNuke: () => {
void socket.sendDebugMessage();
{
label: "Send Debug Message",
execute: socket.sendDebugMessage,
},
showNetworkAddresses: () => {
vscode.window.showInformationMessage(socket.getAddresses());
{
label: "Show Network Addresses",
execute: () => {
vscode.window.showInformationMessage(socket.getAddresses());
},
},
};
];

context.subscriptions.push(
vscode.commands.registerCommand("nuke-tools.extras", () => {
const picker = vscode.window.createQuickPick();
picker.items = Object.keys(extras).map((key) => {
return {
label: key,
};
});

picker.onDidChangeSelection((selection) => {
if (selection[0]) {
extras[selection[0].label]();
picker.hide();
}
});

picker.onDidHide(() => picker.dispose());
picker.show();
showActionPicker(actions);
})
);
}
Expand Down
Loading

0 comments on commit 3a1864d

Please sign in to comment.