Skip to content

Commit 5fb45fb

Browse files
committed
feat: Support missing calls with multi-project the options
1 parent 0c9cd59 commit 5fb45fb

File tree

4 files changed

+133
-4
lines changed

4 files changed

+133
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ The following changes only apply when using `sentry-cli` via the npm package [`@
5353
### Improvements
5454

5555
- The `sentry-cli upload-proguard` command now uses chunked uploading by default ([#2918](https://github.com/getsentry/sentry-cli/pull/2918)). Users who previously set the `SENTRY_EXPERIMENTAL_PROGUARD_CHUNK_UPLOAD` environment variable to opt into this behavior no longer need to set the variable.
56+
- In the JavaScript API, added multi-project support to `releases.finalize()`, `releases.setCommits()`, and `releases.newDeploy()` methods. These methods 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()`.
57+
5658

5759
### Fixes
5860

lib/releases/__tests__/index.test.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,100 @@ describe('SentryCli releases', () => {
144144
);
145145
});
146146
});
147+
148+
describe('finalize', () => {
149+
test('without projects', async () => {
150+
await cli.releases.finalize('my-version');
151+
152+
expect(mockExecute).toHaveBeenCalledWith(
153+
['releases', 'finalize', 'my-version'],
154+
null,
155+
false,
156+
undefined,
157+
{ silent: false }
158+
);
159+
});
160+
161+
test('with projects', async () => {
162+
await cli.releases.finalize('my-version', { projects: ['proj-a', 'proj-b'] });
163+
164+
expect(mockExecute).toHaveBeenCalledWith(
165+
['releases', 'finalize', '-p', 'proj-a', '-p', 'proj-b', 'my-version'],
166+
null,
167+
false,
168+
undefined,
169+
{ silent: false }
170+
);
171+
});
172+
});
173+
174+
describe('setCommits', () => {
175+
test('without projects', async () => {
176+
await cli.releases.setCommits('my-version', { auto: true });
177+
178+
expect(mockExecute).toHaveBeenCalledWith(
179+
['releases', 'set-commits', 'my-version', '--auto'],
180+
false,
181+
false,
182+
undefined,
183+
{ silent: false }
184+
);
185+
});
186+
187+
test('with projects', async () => {
188+
await cli.releases.setCommits('my-version', {
189+
auto: true,
190+
projects: ['proj-a', 'proj-b'],
191+
});
192+
193+
expect(mockExecute).toHaveBeenCalledWith(
194+
['releases', 'set-commits', '-p', 'proj-a', '-p', 'proj-b', 'my-version', '--auto'],
195+
false,
196+
false,
197+
undefined,
198+
{ silent: false }
199+
);
200+
});
201+
});
202+
203+
describe('newDeploy', () => {
204+
test('without projects', async () => {
205+
await cli.releases.newDeploy('my-version', { env: 'production' });
206+
207+
expect(mockExecute).toHaveBeenCalledWith(
208+
['releases', 'deploys', 'my-version', 'new', '--env', 'production'],
209+
null,
210+
false,
211+
undefined,
212+
{ silent: false }
213+
);
214+
});
215+
216+
test('with projects', async () => {
217+
await cli.releases.newDeploy('my-version', {
218+
env: 'production',
219+
projects: ['proj-a', 'proj-b'],
220+
});
221+
222+
expect(mockExecute).toHaveBeenCalledWith(
223+
[
224+
'releases',
225+
'deploys',
226+
'-p',
227+
'proj-a',
228+
'-p',
229+
'proj-b',
230+
'my-version',
231+
'new',
232+
'--env',
233+
'production',
234+
],
235+
null,
236+
false,
237+
undefined,
238+
{ silent: false }
239+
);
240+
});
241+
});
147242
});
148243
});

lib/releases/index.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import {
44
SentryCliCommitsOptions,
5+
SentryCliFinalizeReleaseOptions,
56
SentryCliNewDeployOptions,
67
SentryCliOptions,
78
SentryCliUploadSourceMapsOptions,
@@ -62,18 +63,28 @@ export class Releases {
6263
commitFlags.push('--ignore-missing');
6364
}
6465

65-
return this.execute(['releases', 'set-commits', release].concat(commitFlags), false);
66+
return this.execute(
67+
['releases', 'set-commits']
68+
.concat(helper.getProjectFlagsFromOptions(options))
69+
.concat([release])
70+
.concat(commitFlags),
71+
false
72+
);
6673
}
6774

6875
/**
6976
* Marks this release as complete. This should be called once all artifacts has been
7077
* uploaded.
7178
*
7279
* @param release Unique name of the release.
80+
* @param options Options to configure which projects to finalize the release for.
7381
* @returns A promise that resolves when the release has been finalized.
7482
*/
75-
async finalize(release: string): Promise<string> {
76-
return this.execute(['releases', 'finalize', release], null);
83+
async finalize(release: string, options?: SentryCliFinalizeReleaseOptions): Promise<string> {
84+
const args = ['releases', 'finalize']
85+
.concat(helper.getProjectFlagsFromOptions(options))
86+
.concat([release]);
87+
return this.execute(args, null);
7788
}
7889

7990
/**
@@ -203,6 +214,7 @@ export class Releases {
203214
* time: 1295, // deployment duration in seconds. This can be specified alternatively to `started` and `finished`
204215
* name: 'PickleRick', // human readable name for this deployment
205216
* url: 'https://example.com', // URL that points to the deployment
217+
* projects: ['project1', 'project2'], // list of projects to deploy to
206218
* });
207219
*
208220
* @param release Unique name of the release.
@@ -213,7 +225,9 @@ export class Releases {
213225
if (!options || !options.env) {
214226
throw new Error('options.env must be a valid name');
215227
}
216-
const args = ['releases', 'deploys', release, 'new'];
228+
const args = ['releases', 'deploys']
229+
.concat(helper.getProjectFlagsFromOptions(options))
230+
.concat([release, 'new']);
217231
return this.execute(helper.prepareCommand(args, DEPLOYS_OPTIONS, options), null);
218232
}
219233

lib/types.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ export type SentryCliUploadSourceMapsOptions = {
147147
useArtifactBundle?: boolean;
148148
}
149149

150+
/**
151+
* Options for finalizing a release
152+
*/
153+
export interface SentryCliFinalizeReleaseOptions {
154+
/**
155+
* The projects to finalize the release for. If not provided, the release will be finalized for the default project.
156+
*/
157+
projects?: string[];
158+
}
159+
150160
/**
151161
* Options for creating a new deployment
152162
*/
@@ -175,6 +185,10 @@ export type SentryCliNewDeployOptions = {
175185
* URL that points to the deployment.
176186
*/
177187
url?: string;
188+
/**
189+
* The projects to deploy the release to. If not provided, the deployment will be created for the default project.
190+
*/
191+
projects?: string[];
178192
}
179193

180194
/**
@@ -208,4 +222,8 @@ export type SentryCliCommitsOptions = {
208222
* When the flag is set, command will not fail and just exit silently if no new commits for a given release have been found.
209223
*/
210224
ignoreEmpty?: boolean;
225+
/**
226+
* The projects to set commits for. If not provided, commits will be set for the default project.
227+
*/
228+
projects?: string[];
211229
}

0 commit comments

Comments
 (0)