Skip to content

Commit

Permalink
feat(swc): Add some data (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Aug 26, 2024
1 parent 75465cb commit e34cc7b
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 2 deletions.
13 changes: 13 additions & 0 deletions swc-plugins/app/import/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fs from "node:fs/promises";

export default async function Page() {
if (process.env.NODE_ENV === "production") {
return <div>Not allowed</div>;
}

const plugins = JSON.parse(
await fs.readFile("./data/.cache/plugins.json", "utf8")
);
}

export const dynamic = "force-dynamic";
46 changes: 46 additions & 0 deletions swc-plugins/app/import/ranges/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { db } from "@/lib/prisma";
import fs from "node:fs/promises";

export default async function Page() {
if (process.env.NODE_ENV === "production") {
return <div>Not allowed</div>;
}

const ranges: { min: string; max: string }[] = JSON.parse(
await fs.readFile("./data/ranges.json", "utf8")
);

for (const { min, max } of ranges) {
await db.compatRange.upsert({
where: {
from_to: {
from: min,
to: max,
},
},
update: {},
create: {
from: min,
to: max,
},
});
}

const runtimes = ["@swc/core", "next", "rspack"];

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

return <div>Done</div>;
}

export const dynamic = "force-dynamic";
66 changes: 66 additions & 0 deletions swc-plugins/data/ranges.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"min": "0.54.0",
"max": "0.59.40"
},
{
"min": "v0.61.0",
"max": "0.64.10"
},
{
"min": "0.66.0",
"max": "0.68.0"
},
{
"min": "0.69.0",
"max": "0.72.3"
},
{
"min": "0.72.4",
"max": "0.74.6"
},
{
"min": "0.75.0",
"max": "0.75.48"
},
{
"min": "0.76.0",
"max": "0.77.0"
},
{
"min": "0.78.0",
"max": "0.78.28"
},
{
"min": "0.79.0",
"max": "0.81.8"
},
{
"min": "0.82.0",
"max": "0.87.28"
},
{
"min": "0.88.0",
"max": "0.89.8"
},
{
"min": "0.90.0",
"max": "0.90.37"
},
{
"min": "0.91.0",
"max": "0.93.4"
},
{
"min": "0.94.0",
"max": "0.94.0"
},
{
"min": "0.95.0",
"max": "0.96.9"
},
{
"min": "0.98.0",
"max": "*"
}
]
10 changes: 8 additions & 2 deletions swc-plugins/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ model CompatRange {
updatedAt DateTime @updatedAt
runtimes SwcRuntimeVersion[]
plugins SwcPluginVersion[]
@@unique([from, to])
}

/// Plugin runner
model SwcRuntime {
id BigInt @id @default(autoincrement())
name String
name String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
versions SwcRuntimeVersion[]
Expand All @@ -161,11 +163,13 @@ model SwcRuntimeVersion {
compatRangeId BigInt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([runtimeId, version])
}

model SwcPlugin {
id BigInt @id @default(autoincrement())
name String
name String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
versions SwcPluginVersion[]
Expand All @@ -180,4 +184,6 @@ model SwcPluginVersion {
compatRangeId BigInt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([pluginId, version])
}

0 comments on commit e34cc7b

Please sign in to comment.