Skip to content

Commit

Permalink
allow error
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Aug 27, 2024
1 parent e186325 commit f3ddeb9
Showing 1 changed file with 76 additions and 68 deletions.
144 changes: 76 additions & 68 deletions apps/swc-plugins/lib/api/updater/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,47 +45,51 @@ export const updaterRouter = router({
const api = await (await import("@/lib/api/server")).createCaller(ctx);

for (const pkg of input.pkgs) {
const plugin = await db.swcPlugin.upsert({
where: {
name: pkg.name,
},
create: {
name: pkg.name,
},
update: {},
});

for (const version of pkg.versions) {
const swcCoreVersion = version.swcCoreVersion;
const compatRange = await api.compatRange.byCoreVersion({
version: swcCoreVersion,
try {
const plugin = await db.swcPlugin.upsert({
where: {
name: pkg.name,
},
create: {
name: pkg.name,
},
update: {},
});

if (!compatRange) {
throw new TRPCError({
code: "NOT_FOUND",
message: `Compat range not found for SWC core version ${swcCoreVersion}`,
for (const version of pkg.versions) {
const swcCoreVersion = version.swcCoreVersion;
const compatRange = await api.compatRange.byCoreVersion({
version: swcCoreVersion,
});
}

await db.swcPluginVersion.upsert({
where: {
pluginId_version: {
if (!compatRange) {
throw new TRPCError({
code: "NOT_FOUND",
message: `Compat range not found for SWC core version ${swcCoreVersion}`,
});
}

await db.swcPluginVersion.upsert({
where: {
pluginId_version: {
pluginId: plugin.id,
version: version.version,
},
},
create: {
pluginId: plugin.id,
version: version.version,
compatRangeId: compatRange.id,
swcCoreVersion,
},
},
create: {
pluginId: plugin.id,
version: version.version,
compatRangeId: compatRange.id,
swcCoreVersion,
},
update: {
compatRangeId: compatRange.id,
swcCoreVersion,
},
});
update: {
compatRangeId: compatRange.id,
swcCoreVersion,
},
});
}
} catch (e) {
console.error(`Error updating wasm plugins for ${pkg.name}`, e);
}
}
}),
Expand Down Expand Up @@ -117,45 +121,49 @@ export const updaterRouter = router({
}

for (const pkg of input.pkgs) {
const runtime = await db.swcRuntime.upsert({
where: {
name: pkg.name,
},
create: {
name: pkg.name,
},
update: {},
});

for (const version of pkg.versions) {
const swcCoreVersion = version.swcCoreVersion;
const compatRange = byVersion(swcCoreVersion);

if (!compatRange) {
throw new TRPCError({
code: "NOT_FOUND",
message: `Compat range not found for SWC core version ${swcCoreVersion}`,
});
}

await db.swcRuntimeVersion.upsert({
try {
const runtime = await db.swcRuntime.upsert({
where: {
runtimeId_version: {
runtimeId: runtime.id,
version: version.version,
},
name: pkg.name,
},
create: {
runtimeId: runtime.id,
version: version.version,
compatRangeId: compatRange.id,
swcCoreVersion,
},
update: {
compatRangeId: compatRange.id,
swcCoreVersion,
name: pkg.name,
},
update: {},
});

for (const version of pkg.versions) {
const swcCoreVersion = version.swcCoreVersion;
const compatRange = byVersion(swcCoreVersion);

if (!compatRange) {
throw new TRPCError({
code: "NOT_FOUND",
message: `Compat range not found for SWC core version ${swcCoreVersion}`,
});
}

await db.swcRuntimeVersion.upsert({
where: {
runtimeId_version: {
runtimeId: runtime.id,
version: version.version,
},
},
create: {
runtimeId: runtime.id,
version: version.version,
compatRangeId: compatRange.id,
swcCoreVersion,
},
update: {
compatRangeId: compatRange.id,
swcCoreVersion,
},
});
}
} catch (e) {
console.error(`Error updating runtimes for ${pkg.name}`, e);
}
}
}),
Expand Down

0 comments on commit f3ddeb9

Please sign in to comment.