Skip to content

feat: per-platform packageContents for multi-file sub-packages - #7

Merged
dsherret merged 1 commit into
mainfrom
multi-file-sub-package
May 23, 2026
Merged

dsherret merged 1 commit into
mainfrom
multi-file-sub-package

Conversation

@dsherret

Copy link
Copy Markdown
Member

Summary

Some process plugins ship more than a standalone binary — e.g. a self-contained .NET app where the executable references DLLs and a native runtime in the same directory (dprint-plugin-roslyn extracts to ~205 files). The new optional packageContents per-platform field lets the helper ship the whole directory instead of just one file.

```ts
platforms: [{
platform: "linux-x86_64",
binaryPath: "./out/linux-x64/dprint-plugin-roslyn",
packageContents: "./out/linux-x64",
}]
```

When set:

  • The entire directory is copied recursively into the sub-package, preserving nested layout.
  • `binaryPath` must be a file inside `packageContents` (validated). Its basename still names the executable in the npm reference URL, and it still gets `chmod 0o755` on Unix.
  • The per-platform checksum in `plugin.json` is the sha256 of the resulting tarball, so it covers every shipped file — not just the executable.

When `packageContents` is unset: behavior is unchanged (single-file copy).

Test plan

  • `deno test -P` — 9/9 pass, including:
    • new "packageContents ships the whole dir" test that asserts executable + multiple DLLs + a nested sub-directory file all land in the sub-package, and that plugin.json's checksum matches sha256 of the resulting tarball
    • new validation test that rejects a `binaryPath` outside the supplied `packageContents` directory
  • `deno check` / `dprint check` clean.
  • After release, will be used by `dprint-plugin-roslyn`'s upcoming `create_npm_packages.ts`.

Some process plugins ship more than a standalone binary — e.g. a
self-contained .NET app where the executable references DLLs and
runtime files in the same directory. The new `packageContents`
per-platform option points at a directory whose contents are copied
recursively into the sub-package, instead of just the single
`binaryPath` file.

- `binaryPath` must be a file inside `packageContents`. It still names
  the executable in the npm reference URL and gets chmod 0o755 on Unix.
- All other files in `packageContents` (including nested
  sub-directories like `runtimes/`) are copied verbatim and end up in
  the published tarball.
- The tarball's sha256 covers everything, so dprint's per-platform
  verification still protects the whole package.

Tests cover the multi-file copy (executable + DLLs + nested sub-dir
file) and reject a binaryPath that isn't inside packageContents.
@dsherret
dsherret merged commit c8a0c2d into main May 23, 2026
1 check passed
@dsherret
dsherret deleted the multi-file-sub-package branch May 23, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant