Skip to content

feat: make plugin create output package-manager-aware via detection (3/3) - #600

Open
atilafassina wants to merge 2 commits into
pnpm-template/2-npm-artifactsfrom
pnpm-template/3-plugin-create-detect
Open

atilafassina wants to merge 2 commits into
pnpm-template/2-npm-artifactsfrom
pnpm-template/3-plugin-create-detect

Conversation

@atilafassina

@atilafassina atilafassina commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

appkit plugin create now prints install/build/add commands and generates its README using the project's package manager. For example, launching through npx in a pnpm project still produces pnpm instructions and keeps registry dependency installation on pnpm.

  • Detection prefers package.json#packageManager, then lockfiles in the working directory, then npm_config_user_agent.
  • Recognizes pnpm, yarn, npm package-lock.json and npm-shrinkwrap.json, and both Bun bun.lock and bun.lockb formats.
  • Plugin scaffolding defaults to pnpm when no manager is detected; registry installation retains its npm fallback.
  • Shared command strings use explicit run forms, including pnpm run build.

Stacked on #598 (pnpm-template/2-npm-artifacts); this PR covers the plugin-create and shared-detection changes.

Validation passed locally:

  • 124 focused tests across detector, registry, create, and scaffold suites, including seven registry command cases with mocked dependency installation.
  • A built-CLI smoke check through real npx confirmed 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).
  • Commit hooks: lint-staged, knip, and commitlint.

`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>
@atilafassina
atilafassina added this pull request to stack #599 September 23, 2026 19:18
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size report

Compared against bundle-size-baseline.json (main).

@databricks/appkit

npm tarball (packed): 1.2 MB (+38 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

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

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AppKit PR bot

🔬 Run evals

Start an eval for this PR from the evals-monitor app: Go to Evals Monitor →

📦 Try this PR's app template

Scaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh auth login — and the Databricks 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 @databricks/appkit and @databricks/appkit-ui to tarballs built from this branch, so the scaffolded app runs against this PR's code.

Signed-off-by: Atila Fassina <atila@fassina.eu>
@atilafassina
atilafassina marked this pull request as ready for review September 25, 2026 10:35
@atilafassina
atilafassina requested a review from a team as a code owner September 25, 2026 10:35
@atilafassina
atilafassina requested review from pkosiec and a lite review from Copilot September 25, 2026 10:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
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.

2 participants