feat(cli): Initial auto-provision support for integration install#14734
feat(cli): Initial auto-provision support for integration install#14734
Conversation
🦋 Changeset detectedLatest commit: 3a47ee2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📦 CLI Tarball ReadyThe Vercel CLI tarball for this PR is now available! Quick TestYou can test this PR's CLI directly by running: npx https://vercel-f5mquewsj.vercel.sh/tarballs/vercel.tgz --helpUse in vercel.jsonTo use this CLI version in your project builds, add to your {
"build": {
"env": {
"VERCEL_CLI_VERSION": "vercel@https://vercel-f5mquewsj.vercel.sh/tarballs/vercel.tgz"
}
}
} |
🧪 Unit Test StrategyComparing: Strategy: Affected packages only ✅ Only testing packages that have been modified or depend on modified packages. Affected packages - 1 (2%)
Unaffected packages - 40 (98%)
Results
This comment is automatically generated based on the affected testing strategy |
3528eff to
8684894
Compare
8684894 to
cc45ae7
Compare
cc45ae7 to
a17ba60
Compare
a17ba60 to
fe9268d
Compare
fe9268d to
48a0e16
Compare
48a0e16 to
999becc
Compare
999becc to
91183e5
Compare
91183e5 to
08157ce
Compare
08157ce to
fd0d365
Compare
fd0d365 to
7f651fd
Compare
7f651fd to
99ce14c
Compare
99ce14c to
1925210
Compare
1925210 to
e4c80fe
Compare
e4c80fe to
e7ed9e4
Compare
e7ed9e4 to
5267ce8
Compare
tknickman
left a comment
There was a problem hiding this comment.
Good implementation overall. The feature flag provides safe isolation and the test coverage is solid. A few minor suggestions below.
Implements server-managed state flow for new installations via the auto-provision API endpoint. This allows provisioning resources without an existing installation when the feature flag is enabled. - Add new types for auto-provision API responses - Create autoProvisionResource() function to call the new endpoint - Add provisionResourceViaAutoProvision() flow in add.ts - Gate behind FF_AUTO_PROVISION_INSTALL=1 feature flag The existing provisionResourceViaCLI flow remains unchanged. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5267ce8 to
3a47ee2
Compare
all feedback are tracked in tickets. thanks!
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## vercel@50.9.0 ### Minor Changes - Add confirmation prompt for DELETE API operations and agent mode warning ([#14769](#14769)) - DELETE operations now require user confirmation before proceeding - When running under an AI agent with `--dangerously-skip-permissions`, a warning is displayed to stderr - In non-TTY mode, DELETE operations fail unless `--dangerously-skip-permissions` is used ### Patch Changes - Add auto-provision flow for integration resources (behind feature flag) ([#14734](#14734)) - Revert "[cli] Use promote flow when targeting production alias" ([#14771](#14771)) - Improved curl generation with auth header placeholder ([#14752](#14752)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…4734) ## Summary Server-managed auto-provision flow for Marketplace integrations. Gated behind `FF_AUTO_PROVISION_INSTALL=1`. - Flag ON: Branches at line 51 to new flow - no legacy code runs - Flag OFF: Zero changes to existing flow ### Files | File | Purpose | |------|---------| | `add-auto-provision.ts` | Standalone flow (fetch integration → select product → collect metadata → provision → connect) | | `auto-provision-resource.ts` | API helper for `/v1/integrations/.../auto-provision` endpoint | | `types.ts` | `AcceptedPolicies`, `AutoProvisionResult`, `AutoProvisionFallback` types | | `add-auto-provision.test.ts` | 14 unit tests | ### Flow 1. Fetch integration and product (prompt if multiple products) 2. Collect resource name and metadata (skips wizard if schema unsupported) 3. First provision attempt with empty policies 4. If policies required: prompt for privacy/EULA acceptance, retry 5. If `kind === 'provisioned'`: success, optionally connect to project 6. If `kind !== 'provisioned'`: fallback to browser with resourceName + projectId params ### Test coverage - Successful provisioning (with/without project linking) - Policy acceptance flow (accept both, decline privacy, decline EULA) - Browser fallback for metadata/unknown responses - Error handling (team not found, integration not found, no products, external integration) - Multiple products selection - Telemetry tracking ## Test plan ```bash # Unit tests pnpm --filter vercel vitest-run --run test/unit/commands/integration/add-auto-provision.test.ts # Manual test (from repo root, in a linked project directory) pnpm --filter vercel build FF_AUTO_PROVISION_INSTALL=1 node packages/cli/dist/index.js integration add prisma ``` 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## vercel@50.9.0 ### Minor Changes - Add confirmation prompt for DELETE API operations and agent mode warning ([#14769](#14769)) - DELETE operations now require user confirmation before proceeding - When running under an AI agent with `--dangerously-skip-permissions`, a warning is displayed to stderr - In non-TTY mode, DELETE operations fail unless `--dangerously-skip-permissions` is used ### Patch Changes - Add auto-provision flow for integration resources (behind feature flag) ([#14734](#14734)) - Revert "[cli] Use promote flow when targeting production alias" ([#14771](#14771)) - Improved curl generation with auth header placeholder ([#14752](#14752)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…add` path (#14868) ## Summary Updates the legacy `integration add` path (`add.ts`) to pass CLI context parameters to the web checkout flow: - Add `source=cli` to `provisionResourceViaWebUI` and `handleManualVerificationAction` URLs - Add `defaultResourceName` parameter to pre-fill resource name in checkout - Keep `projectId` (Front derives `projectSlug` from it) ## How the two code paths work ``` OLD PATH (this PR) - via /api/marketplace/cli route ─────────────────────────────────────────────────── CLI (add.ts) Front (/api/marketplace/cli) Front (checkout) ──────────── ──────────────────────────── ──────────────── teamId ─────────────────────→ (auth) integrationId ──────────────→ ────────────────────────────────→ (URL path) productId ──────────────────→ → derives productSlug ──────────→ productSlug projectId ──────────────────→ → fetches project ──────────────→ projectSlug (derived) source=cli ─────────────────→ → forwards ─────────────────────→ source=cli ✅ defaultResourceName ────────→ → forwards ─────────────────────→ defaultResourceName ✅ NEW PATH - via auto-provision API (already working) ─────────────────────────────────────────────────── CLI (add-auto-provision.ts) API (auto-provision) Front (checkout) ─────────────────────────── ──────────────────── ──────────────── POST with name, metadata Returns 422 fallback: url = checkout URL ───────────→ (base URL) CLI appends to returned URL: projectSlug ──────────────────────────────────────────────────→ projectSlug ✅ source=cli ───────────────────────────────────────────────────→ source=cli ✅ defaultResourceName ──────────────────────────────────────────→ defaultResourceName ✅ ``` **Key difference:** The NEW path bypasses `/api/marketplace/cli` and goes directly to checkout. The OLD path goes through the Front route which rebuilds the URL - so the Front route must explicitly forward params. ## Dependencies **This CLI PR requires [vercel/front#61528](vercel/front#61528 to forward `source` and `defaultResourceName` through the `/api/marketplace/cli` route. Without that Front PR, these params are stripped before reaching checkout. ## Linear - [MKT-2440](https://linear.app/vercel/issue/MKT-2440) - Track cli-sourced installs (`source=cli`) - [MKT-2467](https://linear.app/vercel/issue/MKT-2467) - Resource name not preserved from CLI -> web (`defaultResourceName`) - [MKT-2502](https://linear.app/vercel/issue/MKT-2502) - CLI web fallback should auto connect projects (`projectSlug` - handled by existing `projectId` flow) ## Related PRs **This PR:** - Depends on: [vercel/front#61528](vercel/front#61528) (forwards params through `/api/marketplace/cli`) **Previous work:** - #14734: feat(cli): Initial auto-provision support (NEW path) - #14713: Track CLI as source for marketplace installations - [vercel/front#60881](vercel/front#60881): Auto-connect resource to project (checkout page support) ## Test plan - [ ] Merge Front PR first - [ ] Run `vc integration add <slug>` with linked project - verify URL includes `source=cli`, `projectId` - [ ] Run `vc integration add <slug>` without linked project - verify URL includes `source=cli` only - [ ] Test non-subscription billing fallback - verify `defaultResourceName` is passed - [ ] Test manual verification flow - verify authorization URL includes `source=cli` Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

Summary
Server-managed auto-provision flow for Marketplace integrations. Gated behind
FF_AUTO_PROVISION_INSTALL=1.Files
add-auto-provision.tsauto-provision-resource.ts/v1/integrations/.../auto-provisionendpointtypes.tsAcceptedPolicies,AutoProvisionResult,AutoProvisionFallbacktypesadd-auto-provision.test.tsFlow
kind === 'provisioned': success, optionally connect to projectkind !== 'provisioned': fallback to browser with resourceName + projectId paramsTest coverage
Test plan
🤖 Generated with Claude Code