feat: make plugin create output package-manager-aware via detection (3/3) - #600
atilafassina wants to merge 2 commits into
Conversation
`appkit plugin create` previously hardcoded pnpm in its guidance. Detect the developer's package manager and render the right commands instead — with no CLI flag, since the command runs inside a project whose manager is already decided. - New shared module `cli/package-manager.ts`: `detectPackageManager` (order: `npm_config_user_agent` -> lockfile in cwd, including `package-lock.json` -> npm -> pnpm fallback) and a `PM_COMMANDS` capability map (install/build/add/exec) that always uses an explicit `run` form, e.g. `pnpm run build` (pnpm 11 shadows bare script names). - `printNextSteps` (isolated-placement branch) and the generated plugin README now render install/build/add for the detected manager. - `registry add` consolidated onto the shared detector (its local lockfile-only copy removed) for a single source of truth. Covers pnpm, npm, yarn, and bun. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Atila Fassina <atila@fassina.eu>
📦 Bundle size reportCompared against
|
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 1.2 MB (+86 B) | 425 KB (+7 B) |
| Type declarations | 443 KB | 161 KB |
| Source maps | 2.3 MB (+20 B) | 797 KB (+14 B) |
| Other | 11 KB | 3.7 KB |
| Total | 4.0 MB (+106 B) | 1.4 MB (+21 B) |
Per-entry composition (own code — deps external (as shipped))
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
. |
96 KB | 2.5 KB | 98 KB | external | 314 KB |
./beta |
93 KB | 456 B | 93 KB | external | 280 KB |
./testing |
38 KB | 30 KB (-2 B) | 69 KB (-2 B) | external | 200 KB |
./tsdown |
520 B | 0 B | 520 B | external | 813 B |
./type-generator |
23 KB | 0 B | 23 KB | external | 65 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
. |
index.js |
initial | 92 KB |
. |
utils.js |
initial | 4.0 KB |
. |
remote-tunnel-manager.js |
lazy | 2.5 KB |
./beta |
beta.js |
initial | 77 KB |
./beta |
stream-manager.js |
initial | 5.8 KB |
./beta |
wide-event-emitter.js |
initial | 3.2 KB |
./beta |
databricks.js |
initial | 3.2 KB |
./beta |
configuration.js |
initial | 2.3 KB |
./beta |
service-context.js |
initial | 1.3 KB |
./beta |
client.js |
initial | 434 B |
./beta |
client-options.js |
initial | 220 B |
./beta |
supervisor-api.js |
lazy | 192 B |
./beta |
databricks.js |
lazy | 142 B |
./beta |
index.js |
lazy | 122 B |
./testing |
manifest.js |
initial | 26 KB |
./testing |
index.js |
initial | 9.9 KB |
./testing |
wide-event-emitter.js |
initial | 2.9 KB |
./testing |
index.js |
lazy | 26 KB |
./testing |
remote-tunnel-manager.js |
lazy | 2.5 KB |
./testing |
utils.js |
lazy | 1.2 KB |
./tsdown |
index.js |
initial | 520 B |
./type-generator |
index.js |
initial | 23 KB |
@databricks/appkit-ui
npm tarball (packed): 350 KB (-50 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 395 KB | 132 KB |
| Type declarations | 229 KB (-148 B) | 84 KB (-32 B) |
| Source maps | 766 KB (-82 B) | 253 KB (-10 B) |
| CSS | 16 KB | 3.2 KB |
| Total | 1.4 MB (-230 B) | 472 KB (-42 B) |
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
./js |
5.3 KB | 49 KB | 55 KB | 208 KB | 14 KB |
./js/beta |
20 B | 0 B | 20 B | 0 B | 0 B |
./react |
432 KB | 49 KB | 481 KB | 1.3 MB | 177 KB |
./react/beta |
1.0 KB | 0 B | 1.0 KB | 0 B | 1.9 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
./js |
index.js |
initial | 5.2 KB |
./js |
chunk |
initial | 120 B |
./js |
apache-arrow |
lazy | 49 KB |
./js/beta |
beta.js |
initial | 20 B |
./react |
index.js |
initial | 430 KB |
./react |
tslib |
initial | 2.1 KB |
./react |
apache-arrow |
lazy | 49 KB |
./react/beta |
beta.js |
initial | 1.0 KB |
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh run download 35984342601 -R databricks/appkit -n appkit-template-0.76.1-pr.467340c-pnpm-template-3-plugin-create-detect-600 -D appkit-pr-600 \
&& unzip -o "appkit-pr-600/appkit-template-0.76.1-pr.467340c-pnpm-template-3-plugin-create-detect-600.zip" -d "appkit-pr-600" \
&& databricks apps init --template "appkit-pr-600"The template pins |
Signed-off-by: Atila Fassina <atila@fassina.eu>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The reviewed changes are covered by focused tests and have no unresolved blocking issues.
Review effort: Lite
Findings: None
What changed in this PR
Adds package-manager detection for plugin creation, scaffolding, README commands, and registry dependency installation.
Changes:
- Detects pnpm, npm, Yarn, and Bun from project metadata, lockfiles, or launcher context.
- Generates package-manager-specific commands and README instructions.
- Preserves npm fallback behavior for registry installs.
- Adds focused detection and integration tests.
| File | Description |
|---|---|
packages/shared/src/cli/package-manager.ts |
Shared detection and command mappings |
packages/shared/src/cli/package-manager.test.ts |
Detection and command tests |
packages/shared/src/cli/commands/registry/add.ts |
Package-manager-aware dependency installation |
packages/shared/src/cli/commands/registry/add-package-manager.test.ts |
Registry installation tests |
packages/shared/src/cli/commands/plugin/create/scaffold.ts |
Manager-specific README generation |
packages/shared/src/cli/commands/plugin/create/scaffold.test.ts |
README command tests |
packages/shared/src/cli/commands/plugin/create/create.ts |
Manager-aware next-step output |
packages/shared/src/cli/commands/plugin/create/create.test.ts |
Next-step output tests |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
appkit plugin createnow prints install/build/add commands and generates its README using the project's package manager. For example, launching throughnpxin a pnpm project still produces pnpm instructions and keeps registry dependency installation on pnpm.package.json#packageManager, then lockfiles in the working directory, thennpm_config_user_agent.package-lock.jsonandnpm-shrinkwrap.json, and both Bunbun.lockandbun.lockbformats.runforms, includingpnpm run build.Stacked on #598 (
pnpm-template/2-npm-artifacts); this PR covers the plugin-create and shared-detection changes.Validation passed locally:
npxconfirmed pnpm detection, next-step commands, and README output.pnpm build && pnpm docs:build.pnpm check:fix && pnpm -r typecheck(existing unrelated unused-variable warnings remain).