Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/CLI/scripts/upload-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,9 @@ export async function runUpload(
try {
writeArtifactResult(artifactDir, {
success: false,
projectId: null,
channelId: null,
serverUrl: normalizeServerUrl(serverUrl),
status: 'failed',
error: uploadError,
platform,
Expand Down Expand Up @@ -609,6 +612,11 @@ export async function runUpload(
const hasSourceMap = Boolean(options.sourcemap && artifact.sourceMapPath &&
fs.existsSync(artifact.sourceMapPath));
const result: Record<string, unknown> = {
success: true,
projectId: responseData.projectId ?? null,
channelId: responseData.channelId ?? null,
// Keep the artifact bound to the endpoint actually used for this upload.
serverUrl: normalizeServerUrl(serverUrl),
platform,
appVersion: version,
channel,
Expand Down
11 changes: 11 additions & 0 deletions src/tests/CLI/scripts/upload-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ describe('CLI/scripts/upload-cli', () => {
platform: 'android',
appVersion: '1.2.3',
channel: 'General',
success: true,
projectId: null,
channelId: null,
serverUrl: 'https://api.example.com',
runtimeVersion: '2.0.0',
packageVersion: '0.4.1',
bundleId: 'bundle-1',
Expand Down Expand Up @@ -454,6 +458,7 @@ describe('CLI/scripts/upload-cli', () => {
fs.writeFileSync(path.join(distDir, 'main.jsbundle.map'), 'source-map', 'utf8');
const artifactDir = path.join(tempPackageRoot, 'ci-artifacts');
mockAxiosNodePost.mockResolvedValue({ data: {
success: true, projectId: 'project-123', channelId: 'channel-456', serverUrl: 'https://untrusted.example.test',
bundleId: 'bundle-123', bundleVersion: 12, bundleVersionLabel: 'v12',
hash: 'returned-hash', runtimeVersion: '2.0.0',
} });
Expand All @@ -468,6 +473,7 @@ describe('CLI/scripts/upload-cli', () => {

const result = JSON.parse(fs.readFileSync(path.join(artifactDir, 'bundle-drop-result.json'), 'utf8'));
expect(result).toEqual(expect.objectContaining({
success: true, projectId: 'project-123', channelId: 'channel-456', serverUrl: 'https://api.example.com',
orgSlug: 'alpha-org', projectSlug: 'demo-app', channel: 'develop', platform: 'android',
appVersion: '1.2.3', runtimeVersion: '2.0.0',
bundleVersion: 12, bundleVersionLabel: 'v12', hash: 'returned-hash',
Expand Down Expand Up @@ -503,6 +509,7 @@ describe('CLI/scripts/upload-cli', () => {

const result = JSON.parse(fs.readFileSync(path.join(distDir, 'bundle-drop-result.json'), 'utf8'));
expect(result.dashboardUrl).toBe(dashboardUrl);
expect(result.serverUrl).toBe('https://api-staging.bundledrop.app');
expect(consoleLogSpy.mock.calls.flat().join(' ')).toContain(result.dashboardUrl);
});

Expand All @@ -526,6 +533,7 @@ describe('CLI/scripts/upload-cli', () => {
expect(result.dashboardUrl).toBe(
'https://developer.bundledrop.app/organizations/alpha-org/projects/demo-app',
);
expect(result.serverUrl).toBe('https://api.bundledrop.app');
expect(consoleLogSpy.mock.calls.flat().join(' ')).toContain(result.dashboardUrl);
});

Expand Down Expand Up @@ -1596,6 +1604,9 @@ describe('CLI/scripts/upload-cli', () => {
success: false,
status: 'failed',
error: 'network down',
projectId: null,
channelId: null,
serverUrl: 'https://api.example.com',
orgSlug: 'alpha-org',
projectSlug: 'demo-app',
channel: 'General',
Expand Down
Loading