-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: m4rc3l05 <15786310+M4RC3L05@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
95 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
.bin/* | ||
!.bin/git-hooks | ||
!.bin/.gitkeep | ||
!.bin/public-to-json.ts | ||
share | ||
lib | ||
include | ||
data | ||
src/public.json | ||
*.dll | ||
.cache | ||
.env | ||
embed.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env -S deno run -A --no-lock | ||
|
||
import $ from "jsr:@david/dax@0.42.0"; | ||
import { basename, resolve } from "@std/path"; | ||
|
||
const rootDir = resolve(import.meta.dirname!, "../"); | ||
const binDir = resolve(rootDir, ".bin"); | ||
const binName = "denotag" as const; | ||
|
||
const targets = [ | ||
"x86_64-pc-windows-msvc", | ||
"x86_64-apple-darwin", | ||
"aarch64-apple-darwin", | ||
"x86_64-unknown-linux-gnu", | ||
"aarch64-unknown-linux-gnu", | ||
] as const; | ||
|
||
for (const file of Deno.readDirSync("./.bin")) { | ||
if ( | ||
file.name.match(/.*\.(zip|tar\.gz)(\.sha256)?$/) || | ||
targets.some((target) => file.name.includes(target)) | ||
) { | ||
Deno.removeSync(resolve(binDir, file.name), { recursive: true }); | ||
} | ||
} | ||
|
||
const buildFor = async (target: typeof targets[number]) => { | ||
const finalBinDir = resolve(binDir, `${binName}-${target}`); | ||
const finalBinName = target.includes("windows") ? `${binName}.exe` : binName; | ||
const finalCompressName = target.includes("windows") | ||
? `${basename(finalBinDir)}.zip` | ||
: `${basename(finalBinDir)}.tar.gz`; | ||
const finalCompressPath = resolve(binDir, finalCompressName); | ||
const checksumName = `${finalCompressName}.sha256`; | ||
const checksumPath = resolve(binDir, checksumName); | ||
const finalBinPath = resolve(finalBinDir, finalBinName); | ||
const compressCmd = target.includes("windows") | ||
? `zip -j ${finalCompressPath} ${finalBinPath}` | ||
: `tar -czvf ${finalCompressPath} -C ${finalBinDir} ${finalBinName}`; | ||
const scriptPath = resolve(rootDir, "src", "main.ts"); | ||
|
||
await $`deno compile --allow-env=ENV --allow-net=127.0.0.1 --cached-only --env=${ | ||
$.path(resolve(rootDir, ".env")) | ||
} --target=${target} --output ${$.path(finalBinPath)} ${$.path(scriptPath)}`; | ||
await $.raw`${compressCmd}`; | ||
await $`cd ${$.path(binDir)} && sha256sum ${finalCompressName} > ${ | ||
$.path(checksumPath) | ||
}`; | ||
await Deno.remove(finalBinDir, { recursive: true }); | ||
}; | ||
|
||
await $`echo "ENV=production" > ${$.path(resolve(rootDir, ".env"))}`; | ||
|
||
await Promise.all(targets.map(buildFor)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env -S deno run -A --no-lock | ||
|
||
import { resolve } from "jsr:@std/path@1.0.6"; | ||
|
||
const rootDir = resolve(import.meta.dirname!, "../"); | ||
const dataDir = resolve(rootDir, "data"); | ||
const embedFilePath = resolve(rootDir, "embed.json"); | ||
|
||
const embed: Record<string, unknown> = {}; | ||
|
||
for (const file of Deno.readDirSync(dataDir)) { | ||
if (file.name !== "index.html") continue; | ||
|
||
embed[file.name] = Array.from(Deno.readFileSync(resolve(dataDir, file.name))); | ||
} | ||
|
||
Deno.writeTextFileSync(embedFilePath, JSON.stringify(embed)); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters