sentry-cli icon indicating copy to clipboard operation
sentry-cli copied to clipboard

Align JS API between commands that accept multiple projects

Open andreiborza opened this issue 2 months ago • 7 comments

Problem Statement

Today, only releases.new and releases.uploadSourcemaps support supplying multiple projects via the getProjectFlagsFromOptions helper:

https://github.com/getsentry/sentry-cli/blob/8c6e63e6da73194fae6d2257daf643b3200389b5/js/releases/index.js#L53-L56

https://github.com/getsentry/sentry-cli/blob/8c6e63e6da73194fae6d2257daf643b3200389b5/js/releases/index.js#L197-L199

Briefly looking over the rust code-base, it seems that more commands support passing multiple projects.

Solution Brainstorm

Align the JS API with the Rust API to allow passing multiple projects to all commands that have a JS counterpart and support passing multiple projects.

We should be able to use the same helper and approach as in the above mentioned apis.

andreiborza avatar Oct 31 '25 14:10 andreiborza

CLI-212

linear[bot] avatar Oct 31 '25 14:10 linear[bot]

@andreiborza @JPeer264 One very important item to note here: Although I believe many Sentry CLI commands accept multiple project arguments, many (possibly most) of the commands ignore all but the first supplied project. This behavior is not very well documented — probably something we should improve independently of this task — but in any case, we need to be careful with aligning the JS API

szokeasaurusrex avatar Nov 03 '25 10:11 szokeasaurusrex

@szokeasaurusrex could you give us a list of which commands (relevant to JS, i.e. releases, set commits, finalize, upload sourcemaps etc) take multiple project AND use it?

I created this task because we recently updated the bundler plugins to be able to supply multiple projects for sourcemaps upload but it's not super clear how to set up the sentry cli instance in that case and what effect it has on other commands.

andreiborza avatar Nov 03 '25 10:11 andreiborza

Yeah, I can prepare that for you, although I think you might also have luck with asking Cursor. How soon would you need this?

szokeasaurusrex avatar Nov 03 '25 11:11 szokeasaurusrex

According to claude:

⏺ Commands that support multiple -p/--project flags and actually use all of them:

  Releases

  1. releases new (src/commands/releases/new.rs:40)
    - Passes projects: Vec<String> to API
    - Creates release for all specified projects
  2. releases finalize (src/commands/releases/finalize.rs:54)
    - Passes projects: Option<Vec<String>> to API
    - Finalizes release for all specified projects
  3. releases set-commits (src/commands/releases/set_commits.rs:149-158)
    - Passes projects: Vec<String> to API when projects provided
    - Associates commits for all specified projects

  Source Maps

  4. sourcemaps upload (src/commands/sourcemaps/upload.rs:425,454)
    - Passes projects: Some(&[String]) to UploadContext
    - Uploads sourcemaps to all specified projects
   
  React Native

  5. react-native gradle (src/commands/react_native/gradle.rs:76,126)
    - Passes projects: Some(&[String]) to UploadContext
    - Uploads React Native bundles to all specified projects
  6. react-native appcenter (src/commands/react_native/appcenter.rs:121,199)
    - Passes projects: Some(&[String]) to UploadContext
    - Uploads AppCenter artifacts to all specified projects

  All these commands accept: sentry-cli <command> -p proj1 -p proj2 -p proj3

Does that seem accurate @szokeasaurusrex?

andreiborza avatar Nov 03 '25 12:11 andreiborza

All of those commands use multiple projects. I haven't checked that the list is complete, but it seems like it probably is (at least, for the JS API relevant portions).

react-native appcenter is, however, deprecated, so you should not adjust its JS API.

szokeasaurusrex avatar Nov 03 '25 15:11 szokeasaurusrex

Great points made there. Thx for the research :) I'll tackle this right after #2910 has been merged. This would simplify a lot IMO-

JPeer264 avatar Nov 04 '25 14:11 JPeer264