Make the apps plugin build-only: move upload, publish, and OAuth to apps-cli - #494
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🔗 Commit SHA: a8a18a9 | Docs | View more details | Give us feedback! |
5e76625 to
b09d7f1
Compare
b09d7f1 to
b8a6a16
Compare
b8a6a16 to
620d3f9
Compare
620d3f9 to
46462ed
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46462ed6e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await buildAppPackage({ | ||
| backendOutputs, | ||
| backendFunctions, | ||
| context, | ||
| doAuthenticatedRequest, | ||
| options, | ||
| }); |
There was a problem hiding this comment.
Restrict package generation to production builds
Vite 6 also invokes closeBundle when a development server's plugin container closes, so stopping vite dev executes this call. If dist contains an existing production package, buildAppPackage deletes and replaces it using stale frontend output and only the backend functions discovered during that dev session, potentially leaving an incomplete archive for a subsequent datadog-apps upload. Gate this hook on Vite's build command, or split the production and development hooks into separately applied plugins.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Verified and fixed in a8a18a9.
The behavior is real: confirmed in the Vite 6.3.5 source that dev server shutdown → pluginContainer.close() → closeBundle fires unconditionally, so a vite dev exit was re-running the backend build and re-packaging (and deleting the existing dist zip first).
The P1 impact isn't reachable, though: datadog-apps upload/deploy always trigger their own fresh vite build as a child process with DATADOG_APPS_PACKAGE_DIR pointed at a controlled directory, so the zip in the project's dist is never the upload source. The dev-session-derived archive couldn't have been consumed.
Still worth guarding for the residual issues: wasted nested build + packaging on every dev exit, deletion of any manual vite build output in dist, and a possible noisy rejection at shutdown if the dev session surfaced an invalid backend file.
The guard: configureServer (dev-only hook) marks the session; closeBundle skips packaging when that flag is set. Covered by a test that starts a dev session then asserts closeBundle neither builds backend functions nor packages.
46462ed to
a8a18a9
Compare

Summary
The apps plugin is now build-only.
@datadog/apps-cliowns everything that touches Datadog APIs: OAuth, app identity, deploy settings, uploading, and publishing.A production
vite buildwrites a singledatadog-app-assets.zip(frontend + backend +manifest.json) next to the Vite output. Packaging makes no API requests.For the dev server, authentication is resolved from the environment:
DD_API_KEY+DD_APP_KEYfirst, thenDD_OAUTH_ACCESS_TOKEN(passed bydatadog-apps dev, per the RFC on OAuth multi-org credential management in the apps CLI).Details
Removed
upload.ts,vite/handle-upload.ts, and their tests.core/helpers/oauth-request.ts(browser auth, keychain storage, token refresh) and its test. OAuth now lives entirely in apps-cli, which passes a resolved access token viaDD_OAUTH_ACCESS_TOKEN.identifier.ts(identifier/name computed from git remote / package.json). apps-cli resolves the app's identity at deploy time.apps.dryRun,apps.identifier,apps.name,apps.description,apps.selfService,apps.permissions(and theAuthMethod/AppsProtectionLeveltypes),apps.authOverrides.DD_APPS_INTAKE_URL,DD_APPS_PUBLISH,DD_APPS_UPLOAD_ASSETS,DD_APPS_VERSION_NAME,DD_APPS_AUTH_METHOD(andDATADOG_aliases).@napi-rs/keyringandoauth4webapifrom core and all five published packages (both were OAuth-only), plus thechalkdep in the apps plugin.siteSubdomainonAuthOptionsWithDefaults(written, never read),getHighestPackageJsonDir(test-only),APPS_API_PATH,hasActionCatalogImports, unused post-message transport types.Notes for reviewers
{ backend: { functions } }— the deploy-time settings (description, permissions, self-service) are apps-cli's concern.apps.longPollingand the local-execution (?dd-local-exec) work recently merged to master are preserved; the long-poll option threads through the same validate/types surface this PR rewrites./__dd/executeActionrequests return 400 with guidance.packages/published/vite-plugin/package.jsonis reindented (2-space) but semantically unchanged except the two removed dependencies; workspaceexports["."]still points at source,publishConfig.exportsatdist.LICENSES-3rdparty.csv,yarn.lock,.yarn/cache, CODEOWNERS, and theoss/apply.tslicense overrides are regenerated/purged accordingly.Verification
yarn cli integrity(link checks) pass.