From 0060a6475b7e29c853b6a69fd74729838665ff3b Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Tue, 2 Dec 2025 14:08:43 +0100 Subject: [PATCH] feat: Support missing calls with multi-project the options --- CHANGELOG.md | 6 +++++ lib/releases/__tests__/index.test.js | 40 ++++++++++++++++++++++++++++ lib/releases/index.ts | 5 +++- lib/types.ts | 4 +++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6da70b512..77dbf0b46a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Improvements + +- In the JavaScript API, added multi-project support to `releases.newDeploy()` method. This method now accept a `projects` option (array of project slugs), aligning them with the Rust CLI's multi-project capabilities and matching the existing behavior of `releases.new()` and `releases.uploadSourceMaps()` ([#3001](https://github.com/getsentry/sentry-cli/pull/3001)). + ## 3.0.1 ### Performance Improvements diff --git a/lib/releases/__tests__/index.test.js b/lib/releases/__tests__/index.test.js index 491a509c9e..bffba31ab6 100644 --- a/lib/releases/__tests__/index.test.js +++ b/lib/releases/__tests__/index.test.js @@ -144,5 +144,45 @@ describe('SentryCli releases', () => { ); }); }); + + describe('newDeploy', () => { + test('without projects', async () => { + await cli.releases.newDeploy('my-version', { env: 'production' }); + + expect(mockExecute).toHaveBeenCalledWith( + ['releases', 'deploys', 'my-version', 'new', '--env', 'production'], + null, + false, + undefined, + { silent: false } + ); + }); + + test('with projects', async () => { + await cli.releases.newDeploy('my-version', { + env: 'production', + projects: ['proj-a', 'proj-b'], + }); + + expect(mockExecute).toHaveBeenCalledWith( + [ + 'releases', + 'deploys', + '-p', + 'proj-a', + '-p', + 'proj-b', + 'my-version', + 'new', + '--env', + 'production', + ], + null, + false, + undefined, + { silent: false } + ); + }); + }); }); }); diff --git a/lib/releases/index.ts b/lib/releases/index.ts index c8f57adf60..120a0fe0d7 100644 --- a/lib/releases/index.ts +++ b/lib/releases/index.ts @@ -203,6 +203,7 @@ export class Releases { * time: 1295, // deployment duration in seconds. This can be specified alternatively to `started` and `finished` * name: 'PickleRick', // human readable name for this deployment * url: 'https://example.com', // URL that points to the deployment + * projects: ['project1', 'project2'], // list of projects to deploy to * }); * * @param release Unique name of the release. @@ -213,7 +214,9 @@ export class Releases { if (!options || !options.env) { throw new Error('options.env must be a valid name'); } - const args = ['releases', 'deploys', release, 'new']; + const args = ['releases', 'deploys'] + .concat(helper.getProjectFlagsFromOptions(options)) + .concat([release, 'new']); return this.execute(helper.prepareCommand(args, DEPLOYS_OPTIONS, options), null); } diff --git a/lib/types.ts b/lib/types.ts index 9f0a3efa0e..f3d995e1a5 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -167,6 +167,10 @@ export type SentryCliNewDeployOptions = { * URL that points to the deployment. */ url?: string; + /** + * The projects to deploy the release to. If not provided, the deployment will be created for the default project. + */ + projects?: string[]; } /**