From f1b9ce5a85eeb96ad014b2d4a357e5614a75fa17 Mon Sep 17 00:00:00 2001 From: aster <137767097+aster-void@users.noreply.github.com> Date: Wed, 2 Apr 2025 00:00:01 +0900 Subject: [PATCH 1/9] update scraper --- .cspell.json | 3 ++- .gitignore | 3 +++ flake.lock | 18 +++++++++--------- flake.nix | 5 ++--- scraper/src/io.rs | 14 ++++++++++---- scraper/src/main.rs | 7 +++++-- server/prisma/schema.prisma | 4 ++-- 7 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.cspell.json b/.cspell.json index 57ebb38e..3b24a862 100644 --- a/.cspell.json +++ b/.cspell.json @@ -25,7 +25,8 @@ "rustc", "pkgs", "nixpkgs", - "libquery" + "libquery", + "replacen" ], "dictionaries": [ "softwareTerms", diff --git a/.gitignore b/.gitignore index 0535f467..1a29dfcb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ /.direnv /.husky +.cache +data.json + # Logs logs *.log diff --git a/flake.lock b/flake.lock index 8b9b19c0..4b3fd8ff 100644 --- a/flake.lock +++ b/flake.lock @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1739262174, - "narHash": "sha256-W0436s/nXInSuxfiXKtT2n1nUkNw8Ibddz7w4GAweJ4=", + "lastModified": 1743501102, + "narHash": "sha256-7PCBQ4aGVF8OrzMkzqtYSKyoQuU2jtpPi4lmABpe5X4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2a39e74c3ea50a164168215a47b86f72180db76c", + "rev": "02f2af8c8a8c3b2c05028936a1e84daefa1171d4", "type": "github" }, "original": { @@ -54,11 +54,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1739019272, - "narHash": "sha256-7Fu7oazPoYCbDzb9k8D/DdbKrC3aU1zlnc39Y8jy/s8=", + "lastModified": 1743472173, + "narHash": "sha256-xwNv3FYTC5pl4QVZ79gUxqCEvqKzcKdXycpH5UbYscw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fa35a3c8e17a3de613240fea68f876e5b4896aec", + "rev": "88e992074d86ad50249de12b7fb8dbaadf8dc0c5", "type": "github" }, "original": { @@ -106,11 +106,11 @@ ] }, "locked": { - "lastModified": 1739240901, - "narHash": "sha256-YDtl/9w71m5WcZvbEroYoWrjECDhzJZLZ8E68S3BYok=", + "lastModified": 1743475035, + "narHash": "sha256-uLjVsb4Rxnp1zmFdPCDmdODd4RY6ETOeRj0IkC0ij/4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "03473e2af8a4b490f4d2cdb2e4d3b75f82c8197c", + "rev": "bee11c51c2cda3ac57c9e0149d94b86cc1b00d13", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 79e4ae47..836c2d26 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ }; unstable = nixpkgs-unstable.legacyPackages.${system}; - rust-bin = pkgs.rust-bin.fromRustupToolchainFile ./scraper/rust-toolchain.toml; + rust-bin = pkgs.rust-bin.beta.latest.default; # pkgs.rust-bin.fromRustupToolchainFile ./scraper/rust-toolchain.toml; prisma = pkgs.callPackage ./server/prisma.nix {inherit prisma-utils;}; common = { @@ -62,8 +62,7 @@ }; in { packages.scraper = pkgs.callPackage ./scraper {toolchain = rust-bin;}; - devShells.default = pkgs.mkShell common; - devShells.scraper = pkgs.mkShell { + devShells.default = pkgs.mkShell { inherit (common) env; packages = common.packages diff --git a/scraper/src/io.rs b/scraper/src/io.rs index b6b3cba2..14fb798e 100644 --- a/scraper/src/io.rs +++ b/scraper/src/io.rs @@ -1,6 +1,5 @@ use crate::types::*; use anyhow::ensure; -use sha2::{Digest, Sha256}; use tokio::fs; use tokio::io::AsyncWriteExt; @@ -10,13 +9,20 @@ pub async fn write_to(file: &mut fs::File, content: Entry) -> anyhow::Result<()> Ok(()) } -use crate::CACHE_DIR; +use crate::cache_dir; pub async fn request(url: &str) -> anyhow::Result { println!("[request] sending request to {}", url); - let hash = Sha256::digest(url.as_bytes()); - let path = format!("{CACHE_DIR}/{:x}", hash); + let cache_key = url + .to_string() + .replacen("/", "_", 1000) + .replacen(":", "_", 1000) + .replacen("?", "_", 1000) + .replacen("&", "_", 1000) + .replacen("=", "_", 1000) + .to_string(); + let path = format!("{}/{cache_key}", cache_dir()); if let Ok(bytes) = fs::read(&path).await { if let Ok(text) = String::from_utf8(bytes) { return Ok(text); diff --git a/scraper/src/main.rs b/scraper/src/main.rs index d3fd67b6..5bd1a520 100644 --- a/scraper/src/main.rs +++ b/scraper/src/main.rs @@ -16,13 +16,16 @@ use scraper::{Html, Selector}; use urls::URLS; const RESULT_FILE: &str = "./data.json"; -const CACHE_DIR: &str = "./.cache"; + +fn cache_dir() -> String { + "./.cache".to_string() +} #[tokio::main(flavor = "multi_thread")] async fn main() { println!("[log] starting..."); - let _ = fs::DirBuilder::new().create(CACHE_DIR).await; + let _ = fs::DirBuilder::new().create(cache_dir()).await; let mut file = fs::File::create(RESULT_FILE) .await diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma index 8f6bb750..4ebc225a 100644 --- a/server/prisma/schema.prisma +++ b/server/prisma/schema.prisma @@ -92,7 +92,7 @@ model Course { // コマ。1つの講義に対して複数存在しうる。 model Slot { id Int @id @default(autoincrement()) - course Course @relation(fields: [courseId], references: [id]) + course Course @relation(fields: [courseId], references: [id], onDelete: Cascade) courseId String period Int // 1-6. 0 の場合はなし (集中など) day Day // 曜日。other の場合は集中など @@ -104,7 +104,7 @@ model Enrollment { id Int @id @default(autoincrement()) user User @relation(fields: [userId], references: [id], onDelete: Cascade) userId Int - course Course @relation(fields: [courseId], references: [id]) + course Course @relation(fields: [courseId], references: [id], onDelete: Cascade) courseId String @@unique([userId, courseId]) From 15e020aa010232a44b7e9918cd292f463233a444 Mon Sep 17 00:00:00 2001 From: aster <137767097+aster-void@users.noreply.github.com> Date: Wed, 2 Apr 2025 01:01:36 +0900 Subject: [PATCH 2/9] add support for zenki --- .cspell.json | 3 ++- scraper/src/main.rs | 3 ++- scraper/src/parser.rs | 35 ++++++++++++++++++++--------------- scraper/src/urls.rs | 6 +++++- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.cspell.json b/.cspell.json index 3b24a862..1e3afebf 100644 --- a/.cspell.json +++ b/.cspell.json @@ -26,7 +26,8 @@ "pkgs", "nixpkgs", "libquery", - "replacen" + "replacen", + "zenki" ], "dictionaries": [ "softwareTerms", diff --git a/scraper/src/main.rs b/scraper/src/main.rs index 5bd1a520..e7a5a76b 100644 --- a/scraper/src/main.rs +++ b/scraper/src/main.rs @@ -62,7 +62,8 @@ async fn get_courses_of(base_url: &str) -> Vec { futures::future::join_all(courses) .await .into_iter() - .collect::>() + .flatten() + .collect() } lazy_static! { diff --git a/scraper/src/parser.rs b/scraper/src/parser.rs index f3214ed2..fef9ef0c 100644 --- a/scraper/src/parser.rs +++ b/scraper/src/parser.rs @@ -1,6 +1,6 @@ use anyhow::anyhow; use lazy_static::lazy_static; -use scraper::{Html, Selector}; +use scraper::{ElementRef, Html, Selector}; use crate::types::*; @@ -17,19 +17,24 @@ lazy_static! { Selector::parse(".catalog-page-detail-table-cell.code-cell").unwrap(); } -pub fn parse_course_info(html: Html) -> anyhow::Result { - Ok(Course { - name: select(&html, &NAME_SELECTOR, 1)?, - teacher: select(&html, &TEACHER_SELECTOR, 1)?, - semester: select_all(&html, &SEMESTER_SELECTOR, 1)?.join(","), - period: select(&html, &PERIOD_SELECTOR, 1)?, - code: select_all(&html, &CODE_SELECTOR, 1)?.join(" "), - }) +pub fn parse_course_info(html: Html) -> anyhow::Result> { + html.select(&Selector::parse(".catalog-page-detail-table-row").unwrap()) + .skip(1) + .map(|el| { + Ok(Course { + name: select(&el, &NAME_SELECTOR)?, + teacher: select(&el, &TEACHER_SELECTOR)?, + semester: select_all(&el, &SEMESTER_SELECTOR)?.join(","), + period: select(&el, &PERIOD_SELECTOR)?, + code: select_all(&el, &CODE_SELECTOR)?.join(" "), + }) + }) + .collect() } -fn select(html: &Html, selector: &Selector, nth: usize) -> anyhow::Result { - html.select(selector) - .nth(nth) +fn select(el: &ElementRef, selector: &Selector) -> anyhow::Result { + el.select(selector) + .next() .ok_or(anyhow!( "Couldn't find matching element for selector {:?}", selector, @@ -38,12 +43,12 @@ fn select(html: &Html, selector: &Selector, nth: usize) -> anyhow::Result( - html: &'a Html, + html: &'a ElementRef, selector: &'static Selector, - nth: usize, + // nth: usize, ) -> anyhow::Result> { html.select(selector) - .nth(nth) + .next() .ok_or(anyhow!( "Couldn't find matching element for selector {:?}", selector, diff --git a/scraper/src/urls.rs b/scraper/src/urls.rs index aaa7f78c..565cbd50 100644 --- a/scraper/src/urls.rs +++ b/scraper/src/urls.rs @@ -1,4 +1,8 @@ -pub static URLS: [(&str, &str); 10] = [ +pub static URLS: [(&str, &str); 11] = [ + ( + "zenki", + "https://catalog.he.u-tokyo.ac.jp/result?q=&type=all&faculty_id=&facet=%7B%22faculty_type%22%3A%5B%22jd%22%5D%7D&page=", + ), ( "law", "https://catalog.he.u-tokyo.ac.jp/result?type=ug&faculty_id=1&page=", From 95b45e204b885de8efce5a6eb560df4a5474436d Mon Sep 17 00:00:00 2001 From: aster <137767097+aster-void@users.noreply.github.com> Date: Wed, 2 Apr 2025 01:08:08 +0900 Subject: [PATCH 3/9] add sample.ts --- scraper/sample.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 scraper/sample.ts diff --git a/scraper/sample.ts b/scraper/sample.ts new file mode 100644 index 00000000..ea8b12ba --- /dev/null +++ b/scraper/sample.ts @@ -0,0 +1,14 @@ +[ + { + name: "zenki", + courses: [ + { + name: "数理科学基礎", + teacher: "(人名)", + semester: "S1", + period: "月曜2限、水曜1限", + code: "30003 CAS-FC1871L1", + }, + ], + }, +]; From 06df165adb0a5c5e7dfe0142cee937d0b4fb4f11 Mon Sep 17 00:00:00 2001 From: aster <137767097+aster-void@users.noreply.github.com> Date: Wed, 2 Apr 2025 01:09:38 +0900 Subject: [PATCH 4/9] update bun.lock --- bun.lock | 6 +++--- common/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bun.lock b/bun.lock index 1cc4a83f..855b0776 100644 --- a/bun.lock +++ b/bun.lock @@ -13,7 +13,7 @@ "name": "common", "version": "1.0.0", "devDependencies": { - "@types/bun": "latest", + "@types/bun": "^1.2.8", }, "peerDependencies": { "typescript": "^5.0.0", @@ -430,7 +430,7 @@ "@types/body-parser": ["@types/body-parser@1.19.5", "", { "dependencies": { "@types/connect": "*", "@types/node": "*" } }, "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg=="], - "@types/bun": ["@types/bun@1.2.4", "", { "dependencies": { "bun-types": "1.2.4" } }, "sha512-QtuV5OMR8/rdKJs213iwXDpfVvnskPXY/S0ZiFbsTjQZycuqPbMW8Gf/XhLfwE5njW8sxI2WjISURXPlHypMFA=="], + "@types/bun": ["@types/bun@1.2.8", "", { "dependencies": { "bun-types": "1.2.7" } }, "sha512-t8L1RvJVUghW5V+M/fL3Thbxcs0HwNsXsnTEBEfEVqGteiJToOlZ/fyOEaR1kZsNqnu+3XA4RI/qmnX4w6+S+w=="], "@types/caseless": ["@types/caseless@0.12.5", "", {}, "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg=="], @@ -536,7 +536,7 @@ "buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="], - "bun-types": ["bun-types@1.2.4", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-nDPymR207ZZEoWD4AavvEaa/KZe/qlrbMSchqpQwovPZCKc7pwMoENjEtHgMKaAjJhy+x6vfqSBA1QU3bJgs0Q=="], + "bun-types": ["bun-types@1.2.7", "", { "dependencies": { "@types/node": "*", "@types/ws": "*" } }, "sha512-P4hHhk7kjF99acXqKvltyuMQ2kf/rzIw3ylEDpCxDS9Xa0X0Yp/gJu/vDCucmWpiur5qJ0lwB2bWzOXa2GlHqA=="], "busboy": ["busboy@1.6.0", "", { "dependencies": { "streamsearch": "^1.1.0" } }, "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA=="], diff --git a/common/package.json b/common/package.json index 46c6de25..52044406 100644 --- a/common/package.json +++ b/common/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "type": "module", "devDependencies": { - "@types/bun": "latest" + "@types/bun": "^1.2.8" }, "peerDependencies": { "typescript": "^5.0.0", From a661c0ceeaf3e9d1bf00b315b975fd67a95a6bac Mon Sep 17 00:00:00 2001 From: aster <137767097+aster-void@users.noreply.github.com> Date: Wed, 2 Apr 2025 15:03:18 +0900 Subject: [PATCH 5/9] fix ci --- .github/workflows/ci.yml | 12 ++++++------ Dockerfile | 2 +- package.json | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0eaf48df..438c0706 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - uses: oven-sh/setup-bun@v2 with: bun-version: latest - - run: bun i --frozen-lockfile + - run: bun install:production - run: bunx prisma db push working-directory: server @@ -38,7 +38,7 @@ jobs: - uses: oven-sh/setup-bun@v2 with: bun-version: latest - - run: bun install --frozen-lockfile + - run: bun install:production - run: bun run build biome: @@ -53,7 +53,7 @@ jobs: with: version: latest - - run: bun install --frozen-lockfile + - run: bun install:production - run: bun style:check type-check: @@ -64,7 +64,7 @@ jobs: - uses: oven-sh/setup-bun@v2 with: bun-version: latest - - run: bun install --frozen-lockfile + - run: bun install:production - run: bun type spell-check: @@ -76,7 +76,7 @@ jobs: with: bun-version: latest - - run: bun install --frozen-lockfile + - run: bun install:production - run: bun spell . test: @@ -86,7 +86,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v2 - - run: bun install --frozen-lockfile + - run: bun install:production - run: bun run test deploy-test-web: diff --git a/Dockerfile b/Dockerfile index 80b12fec..5e7f2f57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN test -n "${SQL_GENERATE_URL}" ENV DATABASE_URL=$SQL_GENERATE_URL ENV DIRECT_URL=$SQL_GENERATE_URL COPY . . -RUN --mount=type=cache,target=~/.bun/install bun install --frozen-lockfile --ignore-scripts +RUN --mount=type=cache,target=~/.bun/install bun install:production RUN cd server; bun prisma generate --sql RUN cd server; bun run :build diff --git a/package.json b/package.json index 04956ad3..bb814d19 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "keywords": [], "license": "ISC", "scripts": { + "install:production": "bun install --frozen-lockfile --ignore-scripts", "prepare": "lefthook install && (cd server; bun run prepare)", "check": "bun type && bun style:check", "style": "biome check . --fix", From 9cfdf50884a92ddbfc3d009474ac992754a57803 Mon Sep 17 00:00:00 2001 From: naka-12 <104970808+naka-12@users.noreply.github.com> Date: Mon, 14 Apr 2025 06:55:08 +0900 Subject: [PATCH 6/9] feat: json transformer --- .cspell.json | 1 + biome.json | 1 + server/src/.gitignore | 2 +- server/src/seeds/insertKoukiCourses.ts | 106 +++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 server/src/seeds/insertKoukiCourses.ts diff --git a/.cspell.json b/.cspell.json index 0c54450e..234c79c0 100644 --- a/.cspell.json +++ b/.cspell.json @@ -54,6 +54,7 @@ "**/*.svg", "**/migration.sql", "**/data.json", + "**/server/src/seeds/json/**", "**/Cargo.*", "scraper/target", "**/rust-toolchain.toml", diff --git a/biome.json b/biome.json index 3ff85b17..52e82609 100644 --- a/biome.json +++ b/biome.json @@ -22,6 +22,7 @@ "bun.lockb", "server/target", "data.json", + "server/src/seeds/json", "scraper/target", ".next", "next-env.d.ts", diff --git a/server/src/.gitignore b/server/src/.gitignore index 3bfac405..a63bb097 100644 --- a/server/src/.gitignore +++ b/server/src/.gitignore @@ -1,2 +1,2 @@ /common -/seeds/data.json +/seeds/json/* diff --git a/server/src/seeds/insertKoukiCourses.ts b/server/src/seeds/insertKoukiCourses.ts new file mode 100644 index 00000000..75e01937 --- /dev/null +++ b/server/src/seeds/insertKoukiCourses.ts @@ -0,0 +1,106 @@ +import * as fs from "node:fs"; +import * as path from "node:path"; + +import { prisma } from "../database/client"; + +// 後期 (scraper) 形式のデータを読み込む。 +const FILE_PATH = path.join(__dirname, "data.json"); + +// sample +// [ +// { +// name: "zenki", +// courses: [ +// { +// name: "数理科学基礎", +// teacher: "(人名)", +// semester: "S1,S2", +// period: "月曜2限、水曜1限", +// code: "30003 CAS-FC1871L1", +// }, +// ], +// }, +// ]; + +async function main() { + const jsonData: { + courses: { + name: string; + teacher: string; + semester: string; + period: string; + code: string; + }[]; + }[] = JSON.parse(fs.readFileSync(FILE_PATH, "utf-8")); + console.log(jsonData); + + const coursesData = jsonData[0].courses + .filter((course) => course.semester.split("")[0] === "S") + .map((course) => { + const { code, name, teacher } = course; + return { + id: code.split(" ")[0], + name: name, + teacher: teacher, + }; + }); + + await prisma.course.createMany({ + data: coursesData, + }); + + const slotsData: { + day: "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun" | "other"; + period: number; + courseId: string; + }[] = []; + + for (const courseData of jsonData[0].courses) { + const { code, period } = courseData; + + if (courseData.semester.split("")[0] !== "S") continue; + + for (const p of period.split("、")) { + const [dayJp, periodStr] = p.split("曜"); + const day = + dayJp === "月" + ? "mon" + : dayJp === "火" + ? "tue" + : dayJp === "水" + ? "wed" + : dayJp === "木" + ? "thu" + : dayJp === "金" + ? "fri" + : dayJp === "土" + ? "sat" + : dayJp === "日" + ? "sun" + : "other"; + + slotsData.push({ + day, + period: Number.parseInt(periodStr?.split("")[0]) || 0, + courseId: code.split(" ")[0], + }); + } + } + + await prisma.slot.createMany({ + data: slotsData, + skipDuplicates: true, + }); + + console.log("Data inserted successfully!"); +} + +main() + .then(async () => { + await prisma.$disconnect(); + }) + .catch(async (e) => { + console.error(e); + await prisma.$disconnect(); + process.exit(1); + }); From ec8a6651480ef604539ad25ebaf2de849a6fe43a Mon Sep 17 00:00:00 2001 From: naka-12 <104970808+naka-12@users.noreply.github.com> Date: Wed, 16 Apr 2025 00:23:31 +0900 Subject: [PATCH 7/9] Revert "fix ci" This reverts commit a661c0ceeaf3e9d1bf00b315b975fd67a95a6bac. --- .github/workflows/ci.yml | 12 ++++++------ Dockerfile | 2 +- package.json | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 438c0706..0eaf48df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: - uses: oven-sh/setup-bun@v2 with: bun-version: latest - - run: bun install:production + - run: bun i --frozen-lockfile - run: bunx prisma db push working-directory: server @@ -38,7 +38,7 @@ jobs: - uses: oven-sh/setup-bun@v2 with: bun-version: latest - - run: bun install:production + - run: bun install --frozen-lockfile - run: bun run build biome: @@ -53,7 +53,7 @@ jobs: with: version: latest - - run: bun install:production + - run: bun install --frozen-lockfile - run: bun style:check type-check: @@ -64,7 +64,7 @@ jobs: - uses: oven-sh/setup-bun@v2 with: bun-version: latest - - run: bun install:production + - run: bun install --frozen-lockfile - run: bun type spell-check: @@ -76,7 +76,7 @@ jobs: with: bun-version: latest - - run: bun install:production + - run: bun install --frozen-lockfile - run: bun spell . test: @@ -86,7 +86,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v2 - - run: bun install:production + - run: bun install --frozen-lockfile - run: bun run test deploy-test-web: diff --git a/Dockerfile b/Dockerfile index 5e7f2f57..80b12fec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN test -n "${SQL_GENERATE_URL}" ENV DATABASE_URL=$SQL_GENERATE_URL ENV DIRECT_URL=$SQL_GENERATE_URL COPY . . -RUN --mount=type=cache,target=~/.bun/install bun install:production +RUN --mount=type=cache,target=~/.bun/install bun install --frozen-lockfile --ignore-scripts RUN cd server; bun prisma generate --sql RUN cd server; bun run :build diff --git a/package.json b/package.json index bb814d19..04956ad3 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "keywords": [], "license": "ISC", "scripts": { - "install:production": "bun install --frozen-lockfile --ignore-scripts", "prepare": "lefthook install && (cd server; bun run prepare)", "check": "bun type && bun style:check", "style": "biome check . --fix", From cc05c8fa8785f37e4e39fd268fa1846046466d2a Mon Sep 17 00:00:00 2001 From: naka-12 <104970808+naka-12@users.noreply.github.com> Date: Wed, 16 Apr 2025 00:23:48 +0900 Subject: [PATCH 8/9] Revert "update bun.lock" This reverts commit 06df165adb0a5c5e7dfe0142cee937d0b4fb4f11. --- bun.lock | 6 +++--- common/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bun.lock b/bun.lock index 855b0776..1cc4a83f 100644 --- a/bun.lock +++ b/bun.lock @@ -13,7 +13,7 @@ "name": "common", "version": "1.0.0", "devDependencies": { - "@types/bun": "^1.2.8", + "@types/bun": "latest", }, "peerDependencies": { "typescript": "^5.0.0", @@ -430,7 +430,7 @@ "@types/body-parser": ["@types/body-parser@1.19.5", "", { "dependencies": { "@types/connect": "*", "@types/node": "*" } }, "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg=="], - "@types/bun": ["@types/bun@1.2.8", "", { "dependencies": { "bun-types": "1.2.7" } }, "sha512-t8L1RvJVUghW5V+M/fL3Thbxcs0HwNsXsnTEBEfEVqGteiJToOlZ/fyOEaR1kZsNqnu+3XA4RI/qmnX4w6+S+w=="], + "@types/bun": ["@types/bun@1.2.4", "", { "dependencies": { "bun-types": "1.2.4" } }, "sha512-QtuV5OMR8/rdKJs213iwXDpfVvnskPXY/S0ZiFbsTjQZycuqPbMW8Gf/XhLfwE5njW8sxI2WjISURXPlHypMFA=="], "@types/caseless": ["@types/caseless@0.12.5", "", {}, "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg=="], @@ -536,7 +536,7 @@ "buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="], - "bun-types": ["bun-types@1.2.7", "", { "dependencies": { "@types/node": "*", "@types/ws": "*" } }, "sha512-P4hHhk7kjF99acXqKvltyuMQ2kf/rzIw3ylEDpCxDS9Xa0X0Yp/gJu/vDCucmWpiur5qJ0lwB2bWzOXa2GlHqA=="], + "bun-types": ["bun-types@1.2.4", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-nDPymR207ZZEoWD4AavvEaa/KZe/qlrbMSchqpQwovPZCKc7pwMoENjEtHgMKaAjJhy+x6vfqSBA1QU3bJgs0Q=="], "busboy": ["busboy@1.6.0", "", { "dependencies": { "streamsearch": "^1.1.0" } }, "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA=="], diff --git a/common/package.json b/common/package.json index 52044406..46c6de25 100644 --- a/common/package.json +++ b/common/package.json @@ -4,7 +4,7 @@ "version": "1.0.0", "type": "module", "devDependencies": { - "@types/bun": "^1.2.8" + "@types/bun": "latest" }, "peerDependencies": { "typescript": "^5.0.0", From 990f00f1b66e255d1ef3bb36d92cc80bd8ca8ed9 Mon Sep 17 00:00:00 2001 From: naka-12 <104970808+naka-12@users.noreply.github.com> Date: Wed, 16 Apr 2025 00:24:16 +0900 Subject: [PATCH 9/9] renew bun.lock --- bun.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bun.lock b/bun.lock index 1cc4a83f..1998c206 100644 --- a/bun.lock +++ b/bun.lock @@ -430,7 +430,7 @@ "@types/body-parser": ["@types/body-parser@1.19.5", "", { "dependencies": { "@types/connect": "*", "@types/node": "*" } }, "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg=="], - "@types/bun": ["@types/bun@1.2.4", "", { "dependencies": { "bun-types": "1.2.4" } }, "sha512-QtuV5OMR8/rdKJs213iwXDpfVvnskPXY/S0ZiFbsTjQZycuqPbMW8Gf/XhLfwE5njW8sxI2WjISURXPlHypMFA=="], + "@types/bun": ["@types/bun@1.2.9", "", { "dependencies": { "bun-types": "1.2.9" } }, "sha512-epShhLGQYc4Bv/aceHbmBhOz1XgUnuTZgcxjxk+WXwNyDXavv5QHD1QEFV0FwbTSQtNq6g4ZcV6y0vZakTjswg=="], "@types/caseless": ["@types/caseless@0.12.5", "", {}, "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg=="], @@ -536,7 +536,7 @@ "buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="], - "bun-types": ["bun-types@1.2.4", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-nDPymR207ZZEoWD4AavvEaa/KZe/qlrbMSchqpQwovPZCKc7pwMoENjEtHgMKaAjJhy+x6vfqSBA1QU3bJgs0Q=="], + "bun-types": ["bun-types@1.2.9", "", { "dependencies": { "@types/node": "*", "@types/ws": "*" } }, "sha512-dk/kOEfQbajENN/D6FyiSgOKEuUi9PWfqKQJEgwKrCMWbjS/S6tEXp178mWvWAcUSYm9ArDlWHZKO3T/4cLXiw=="], "busboy": ["busboy@1.6.0", "", { "dependencies": { "streamsearch": "^1.1.0" } }, "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA=="],