Skip to content

Commit a9b2019

Browse files
authored
feat: Support missing calls with multi-project options (#3001)
This adds more support for having multiple projects where the Rust API had already support. This only affects `.newDeploy()` Closes #2902 Closes [CLI-212](https://linear.app/getsentry/issue/CLI-212/align-js-api-between-commands-that-accept-multiple-projects)
1 parent c9e87cf commit a9b2019

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
### New Features
6+
7+
- 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)).
8+
9+
### Fixes
10+
511
- Fixed a bug that prevented project IDs from being used with the `sentry-cli releases new` command for users with self-hosted Sentry instances on versions older than 25.12.1 ([#3068](https://github.com/getsentry/sentry-cli/issues/3068)).
612

713
## 3.0.3

lib/releases/__tests__/index.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,45 @@ describe('SentryCli releases', () => {
144144
);
145145
});
146146
});
147+
148+
describe('newDeploy', () => {
149+
test('without projects', async () => {
150+
await cli.releases.newDeploy('my-version', { env: 'production' });
151+
152+
expect(mockExecute).toHaveBeenCalledWith(
153+
['deploys', 'new', '--release', 'my-version', '--env', 'production'],
154+
null,
155+
false,
156+
undefined,
157+
{ silent: false }
158+
);
159+
});
160+
161+
test('with projects', async () => {
162+
await cli.releases.newDeploy('my-version', {
163+
env: 'production',
164+
projects: ['proj-a', 'proj-b'],
165+
});
166+
167+
expect(mockExecute).toHaveBeenCalledWith(
168+
[
169+
'deploys',
170+
'new',
171+
'-p',
172+
'proj-a',
173+
'-p',
174+
'proj-b',
175+
'--release',
176+
'my-version',
177+
'--env',
178+
'production',
179+
],
180+
null,
181+
false,
182+
undefined,
183+
{ silent: false }
184+
);
185+
});
186+
});
147187
});
148188
});

lib/releases/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export class Releases {
203203
* time: 1295, // deployment duration in seconds. This can be specified alternatively to `started` and `finished`
204204
* name: 'PickleRick', // human readable name for this deployment
205205
* url: 'https://example.com', // URL that points to the deployment
206+
* projects: ['project1', 'project2'], // list of projects to deploy to
206207
* });
207208
*
208209
* @param release Unique name of the release.
@@ -213,7 +214,9 @@ export class Releases {
213214
if (!options || !options.env) {
214215
throw new Error('options.env must be a valid name');
215216
}
216-
const args = ['releases', 'deploys', release, 'new'];
217+
const args = ['deploys', 'new']
218+
.concat(helper.getProjectFlagsFromOptions(options))
219+
.concat(['--release', release]);
217220
return this.execute(helper.prepareCommand(args, DEPLOYS_OPTIONS, options), null);
218221
}
219222

lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ export type SentryCliNewDeployOptions = {
167167
* URL that points to the deployment.
168168
*/
169169
url?: string;
170+
/**
171+
* The projects to deploy the release to. If not provided, the deployment will be created for all projects associated with the release.
172+
*/
173+
projects?: string[];
170174
}
171175

172176
/**

0 commit comments

Comments
 (0)