chore: restructure repository into packages/ folder (#3197)

We're having a growing number of packages in this repository. This PR
moves them into a `packages/` directory like it's commonly done in other
projects.
This commit is contained in:
Marvin Hagemeister
2025-08-06 15:52:45 +02:00
committed by GitHub
parent 27e407a1e3
commit 815b1940e3
184 changed files with 94 additions and 82 deletions
@@ -0,0 +1,53 @@
import type { Plugin } from "vite";
export function buildIdPlugin(): Plugin {
let buildId = "";
const regex = /^(jsr:)?@fresh\/build-id(@.*)?$/;
return {
name: "fresh:build-id",
async config(_, env) {
const isDev = env.command === "serve";
buildId = await getBuildId(isDev);
return {
define: {
BUILD_ID: JSON.stringify(buildId),
},
};
},
applyToEnvironment() {
return true;
},
resolveId(id) {
if (regex.test(id)) {
return `\0fresh/build-id`;
}
},
load(id) {
if (id !== `\0fresh/build-id`) return;
return `export let BUILD_ID = ${JSON.stringify(buildId)};
export const DENO_DEPLOYMENT_ID = undefined;
export function setBuildId(id) {
BUILD_ID = id;
}`;
},
};
}
export async function getBuildId(dev: boolean): Promise<string> {
if (!dev) {
const bin = Deno.build.os === "windows" ? "git.exe" : "git";
const res = await new Deno.Command(bin, { args: ["rev-parse", "HEAD"] })
.output();
return new TextDecoder().decode(res.stdout);
}
const arr = new Uint32Array(1);
crypto.getRandomValues(arr);
return String(arr[0]);
}