Skip to content

Commit

Permalink
Fix upload aab file not working
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Dec 2, 2024
1 parent 53de9d8 commit 728bd63
Show file tree
Hide file tree
Showing 12 changed files with 967 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cli/cli.mjs
Git LFS file not shown
2 changes: 1 addition & 1 deletion cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function start() {
console.log("Distributing", {
filePath,
})
await uploadArtifact(file, orgName, appName, values.releaseNotes ? values.releaseNotes : null)
await uploadArtifact(file, orgName, appName, values.releaseNotes ? values.releaseNotes : null, undefined)
console.log('Finished Distributing', {
filePath,
})
Expand Down
10 changes: 4 additions & 6 deletions components/AppFileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ watchEffect(() => {
const { mutateAsync, isPending } = useMutation({
mutationFn: async (file: File) => {
const { artifactId } = await onUpload(file)
const { artifactId } = await onUpload(file, undefined)
const groupIds = selectedGroup.value?.map(e => e.id) ?? []
if (artifactId && groupIds && groupIds.length) {
await $fetch('/api/update-artifact-groups', {
Expand Down Expand Up @@ -84,12 +84,10 @@ const submit = async () => {
mutateAsync(realFile)
}
const onUpload = async (file: File) => {
const data = await uploadArtifact(file, orgName.value, appName.value, releaseNotes.value)
const onUpload = async (file: File, apkFile: File | undefined) => {
const data = await uploadArtifact(file, orgName.value, appName.value, releaseNotes.value, apkFile)
return {
artifactId: data!.artifactId,
}
};
}
</script>
2 changes: 1 addition & 1 deletion server/api/artifacts/upload-artifact-url.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineEventHandler(async (event) => {
}

const packageData = packageMetadata as {
versionCode: number,
versionCode: string,
versionName: string,
packageName: string,
extension: string,
Expand Down
12 changes: 9 additions & 3 deletions server/api/artifacts/upload-artifact.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export async function findApiKey(

export default defineEventHandler(async (event) => {
const db = event.context.drizzle
const { orgName, appName } = await readValidatedBody(event, z.object({
const { orgName, appName, hasFileApk } = await readValidatedBody(event, z.object({
appName: z.string().trim().min(1).max(128),
orgName: z.string().trim().min(1).max(128),
hasFileApk: z.boolean().default(false),
}).parse)

var orgId: string
Expand Down Expand Up @@ -100,9 +101,14 @@ export default defineEventHandler(async (event) => {
})
}

const { fileKey, signedUrl } = await generateSignedUrlUpload(event, orgId, appId)
const { fileKey, signedUrl } = await generateSignedUrlUpload(orgId, appId)
const apkUrl = hasFileApk ? await generateSignedUrlUpload(orgId, appId) : undefined
return {
fileKey,
url: signedUrl,
}
apkUrl: apkUrl ? {
apkSignedUrl: apkUrl.signedUrl,
apkFileKey: apkUrl.fileKey,
} : undefined,
} satisfies UploadArtifactResponse
})
20 changes: 20 additions & 0 deletions server/db/drizzle/0045_nostalgic_rafael_vega.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_grouptester` (
`id` text PRIMARY KEY NOT NULL,
`testerId` text NOT NULL,
`organizationId` text NOT NULL,
`appsId` text NOT NULL,
`artifactGroupId` text NOT NULL,
FOREIGN KEY (`testerId`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`organizationId`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`appsId`) REFERENCES `apps`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`artifactGroupId`) REFERENCES `artifactsGroups`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
INSERT INTO `__new_grouptester`("id", "testerId", "organizationId", "appsId", "artifactGroupId") SELECT "id", "testerId", "organizationId", "appsId", "artifactGroupId" FROM `grouptester`;--> statement-breakpoint
DROP TABLE `grouptester`;--> statement-breakpoint
ALTER TABLE `__new_grouptester` RENAME TO `grouptester`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> statement-breakpoint
CREATE UNIQUE INDEX `grouptester_id_unique` ON `grouptester` (`id`);--> statement-breakpoint
CREATE UNIQUE INDEX `testerId_orgId_appId_groupId` ON `grouptester` (`testerId`,`organizationId`,`appsId`,`artifactGroupId`);--> statement-breakpoint
ALTER TABLE `artifacts` ADD `file_object_apk_key` text;
Loading

0 comments on commit 728bd63

Please sign in to comment.