Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ If a release was already saved to directory '0.0.1-1', then a new release direct
#### Next Step
Simply double-click the .streamDeckPlugin file, which will load up the plugin in the Stream Deck application.

#### Pack for debug mode
To pack the plugin in debug mode, which enables remote debugging capabilities, use the `--debug` flag:

```bash
streamdeck-cli pack /path/to/plugin --debug --debug-port 5679
```

This will create a flag file named `.debug` in the packed plugin containing the specified port.

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.

## Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Expand Down
18 changes: 14 additions & 4 deletions streamdeck_cli/commands/pack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Pack/build a Stream Deck plugin into a .streamDeckPlugin file."""
from __future__ import annotations

import logging
from pathlib import Path
from typing import Optional
Expand Down Expand Up @@ -35,6 +33,12 @@ def pack(
help="Output directory",
),
version: Optional[str] = None, # noqa: UP007
debug_port: Optional[int] = typer.Option(
None,
"--debug",
"-d",
help="Enable debug mode in the packed plugin to listen for debug messages on the specified port",
),
) -> None:
"""Pack/build a Stream Deck plugin into a .streamDeckPlugin file."""
# Validate the manifest by initiating its model.
Expand All @@ -49,7 +53,7 @@ def pack(
# Define the full output file path for the plugin.
# The output file at this path will be a .streamDeckPlugin file, which will open the plugin in the Stream Deck app.
# 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.
output_filepath = output_dirpath / f"{manifest.uuid}.streamDeckPlugin"
output_filepath = versioned_output_dirpath / f"{manifest.uuid}.streamDeckPlugin"
logger.info("Output plugin file will be created at: %s", output_filepath)

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

# Create the zip file and add the plugin files
archive_plugin_files(plugin_dirpath, output_filepath, plugin_uuid=manifest.uuid, packignore_spec=pathignore_spec)
archive_plugin_files(
plugin_dirpath,
output_filepath,
plugin_uuid=manifest.uuid,
packignore_spec=pathignore_spec,
debug_port=debug_port,
)


if __name__ == "__main__":
Expand Down
14 changes: 13 additions & 1 deletion streamdeck_cli/commands/pack/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
logger = logging.getLogger("streamdeck-cli")


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


# Add a file `.debug` containing the debug port number if debug mode is enabled to the zip file
if debug_port:
print("YOOO")
zip_file.writestr(f"{entry_prefix}/.debug", str(debug_port))


def walk_filtered_plugin_files(source_dirpath: Path, packignore_spec: pathspec.PathSpec) -> Generator[Path, None, None]:
"""Walk through the plugin directory and yield files that are not ignored."""
# Walk through the directory and yield files that are not ignored
Expand Down