Skip to content

Commit b7ffb84

Browse files
authored
Merge pull request #1 from strohganoff/feature/debug-mode
Feature/debug mode
2 parents 5537c25 + fea0319 commit b7ffb84

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ If a release was already saved to directory '0.0.1-1', then a new release direct
5151
#### Next Step
5252
Simply double-click the .streamDeckPlugin file, which will load up the plugin in the Stream Deck application.
5353

54+
#### Pack for debug mode
55+
To pack the plugin in debug mode, which enables remote debugging capabilities, use the `--debug` flag:
56+
57+
```bash
58+
streamdeck-cli pack /path/to/plugin --debug --debug-port 5679
59+
```
60+
61+
This will create a flag file named `.debug` in the packed plugin containing the specified port.
62+
63+
When this file is included, the plugin will wait for a debugger to attach at that port before starting. You can use tools like VS Code's Python debugger or PyCharm's remote debugger to connect to it.
5464

5565
## Contributing
5666
Contributions are welcome! Please open an issue or submit a pull request on GitHub.

streamdeck_cli/commands/pack/__init__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
"""Pack/build a Stream Deck plugin into a .streamDeckPlugin file."""
2-
from __future__ import annotations
3-
42
import logging
53
from pathlib import Path
64
from typing import Optional
@@ -35,6 +33,12 @@ def pack(
3533
help="Output directory",
3634
),
3735
version: Optional[str] = None, # noqa: UP007
36+
debug_port: Optional[int] = typer.Option(
37+
None,
38+
"--debug",
39+
"-d",
40+
help="Enable debug mode in the packed plugin to listen for debug messages on the specified port",
41+
),
3842
) -> None:
3943
"""Pack/build a Stream Deck plugin into a .streamDeckPlugin file."""
4044
# Validate the manifest by initiating its model.
@@ -49,7 +53,7 @@ def pack(
4953
# Define the full output file path for the plugin.
5054
# The output file at this path will be a .streamDeckPlugin file, which will open the plugin in the Stream Deck app.
5155
# The output file at this path is a zip file containing the files of the plugin, which the Stream Deck software unzips to a specific app directory.
52-
output_filepath = output_dirpath / f"{manifest.uuid}.streamDeckPlugin"
56+
output_filepath = versioned_output_dirpath / f"{manifest.uuid}.streamDeckPlugin"
5357
logger.info("Output plugin file will be created at: %s", output_filepath)
5458

5559
# Create the package directory
@@ -59,7 +63,13 @@ def pack(
5963
pathignore_spec: pathspec.PathSpec = get_packignore_specification(plugin_dirpath)
6064

6165
# Create the zip file and add the plugin files
62-
archive_plugin_files(plugin_dirpath, output_filepath, plugin_uuid=manifest.uuid, packignore_spec=pathignore_spec)
66+
archive_plugin_files(
67+
plugin_dirpath,
68+
output_filepath,
69+
plugin_uuid=manifest.uuid,
70+
packignore_spec=pathignore_spec,
71+
debug_port=debug_port,
72+
)
6373

6474

6575
if __name__ == "__main__":

streamdeck_cli/commands/pack/zip.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919
logger = logging.getLogger("streamdeck-cli")
2020

2121

22-
def archive_plugin_files(plugin_dirpath: Path, output_filepath: Path, plugin_uuid: str, packignore_spec: pathspec.PathSpec) -> None:
22+
def archive_plugin_files(
23+
plugin_dirpath: Path,
24+
output_filepath: Path,
25+
plugin_uuid: str,
26+
packignore_spec: pathspec.PathSpec,
27+
debug_port: int | None = None,
28+
) -> None:
2329
"""Archive the plugin files into a a new zip file."""
2430
with zipfile.ZipFile(output_filepath, "w", zipfile.ZIP_DEFLATED) as zip_file:
2531
# Files should be stuffed in the zip file under a base directory with the name of the plugin UUID found in the manifest.
@@ -37,6 +43,12 @@ def archive_plugin_files(plugin_dirpath: Path, output_filepath: Path, plugin_uui
3743
zip_file.write(full_filepath, arcname=arcname)
3844

3945

46+
# Add a file `.debug` containing the debug port number if debug mode is enabled to the zip file
47+
if debug_port:
48+
print("YOOO")
49+
zip_file.writestr(f"{entry_prefix}/.debug", str(debug_port))
50+
51+
4052
def walk_filtered_plugin_files(source_dirpath: Path, packignore_spec: pathspec.PathSpec) -> Generator[Path, None, None]:
4153
"""Walk through the plugin directory and yield files that are not ignored."""
4254
# Walk through the directory and yield files that are not ignored

0 commit comments

Comments
 (0)