-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
34 additions
and
287 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,25 +11,18 @@ jobs: | |
name: Build pages | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
deno-version: [1.32.3] | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v1 | ||
- name: Install tools | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install ffmpeg jq p7zip-full -y | ||
- name: Use Deno Version ${{ matrix.deno-version }} | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: ${{ matrix.deno-version }} | ||
- name: Install Dependencies | ||
run: PUPPETEER_PRODUCT=chrome deno run --unstable --allow-env --allow-net --allow-write --allow-read https://deno.land/x/[email protected]/install.ts | ||
- name: Run Application | ||
run: deno run --unstable --allow-env --allow-run --allow-net --allow-read --allow-write deno.ts web | ||
run: | | ||
bun install | ||
bun bun.ts web | ||
- name: Pack 7z Package for nightly | ||
run: | | ||
cd nitrofiles | ||
|
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,4 +1,3 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.unstable": true | ||
"deno.enable": false | ||
} |
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,27 +1,29 @@ | ||
import puppeteer from "https://deno.land/x/[email protected]/mod.ts"; | ||
import {getAnyEdgeLatest} from "./edgePath.ts" | ||
import exists from "./exists.ts" | ||
import { $, Subprocess } from "bun"; | ||
import { stat, exists, readdir, unlink } from "node:fs/promises"; | ||
|
||
import puppeteer, { Browser } from "puppeteer"; | ||
import {getAnyEdgeLatest} from "edge-paths" | ||
|
||
const dedent = (string:string) => string.split('\n').map(line => line.trim()).join('\n') | ||
const needsUpdate = async (fileName: string, path:string) => | ||
!(await exists(fileName)) || ((await Deno.stat(fileName)).mtime || 0) < ((await Deno.stat(path)).mtime || 0) | ||
!(await exists(fileName)) || ((await stat(fileName)).mtime || 0) < ((await stat(path)).mtime || 0) | ||
|
||
const web = Deno.args.includes("web"); | ||
let jekyll; | ||
const web = Bun.argv.includes("web"); | ||
let jekyll: Subprocess; | ||
let accessURL:string; | ||
if (web) { | ||
accessURL = "https://" + await Deno.readTextFile("./CNAME"); | ||
console.log("Generating images from https://manual.ds-homebrew.com..."); | ||
accessURL = "https://" + await Bun.file("./CNAME").text(); | ||
console.log(`Generating images from ${accessURL}...`); | ||
} else { | ||
console.log("Generating images from local files..."); | ||
jekyll = new Deno.Command('bundle', { args: ['exec', 'jekyll', 'serve']}).spawn(); | ||
jekyll = Bun.spawn({ cmd: ["jekyll", "serve"] }) | ||
|
||
// Wait 5s for jekyll to be ready | ||
await new Promise(resolve => setTimeout(resolve, 5000)); | ||
accessURL = "http://127.0.0.1:4000/"; | ||
} | ||
|
||
let browser; | ||
let browser: Browser; | ||
try { | ||
browser = await puppeteer.launch({ product: 'chrome' }); | ||
} catch (error) { | ||
|
@@ -39,18 +41,16 @@ const tempFileNames = { | |
palette: "palette.png" | ||
} | ||
|
||
for await (const folder of Deno.readDir("pages")) { | ||
if (!folder.isDirectory) | ||
for (const folder of await readdir("pages", { withFileTypes: true })) { | ||
if (!folder.isDirectory()) | ||
continue; | ||
|
||
const dir = folder.name; | ||
if (dir == "_ic") | ||
continue; | ||
|
||
await Deno.mkdir(`nitrofiles/pages/${dir.substring(1)}`, {recursive: true}); | ||
|
||
for await (const subPageFolder of Deno.readDir(`pages/${dir}`)) { | ||
if (subPageFolder.isDirectory) | ||
for (const subPageFolder of await readdir(`pages/${dir}`, { withFileTypes: true })) { | ||
if (subPageFolder.isDirectory()) | ||
continue; | ||
|
||
const page = subPageFolder.name; | ||
|
@@ -77,15 +77,8 @@ for await (const folder of Deno.readDir("pages")) { | |
if (await needsUpdate(imagePath, `pages/${dir}/${page}`)) { | ||
await tab.screenshot({ path: tempFileNames.screenshot, clip: { x: 0, y: 0, width: 256, height: pageEval.height } }); | ||
|
||
const paletteProcess = new Deno.Command('ffmpeg', { | ||
args: ["-i", tempFileNames.screenshot, "-vf", "palettegen=max_colors=246", tempFileNames.palette, "-y", "-loglevel", "error"] | ||
}); | ||
await paletteProcess.output(); | ||
|
||
const conversionProcess = new Deno.Command('ffmpeg', { | ||
args: ["-i", tempFileNames.screenshot, "-i", tempFileNames.palette, "-filter_complex", "paletteuse", imagePath, "-y", "-loglevel", "error"] | ||
}) | ||
await conversionProcess.output(); | ||
$`ffmpeg -i ${tempFileNames.screenshot} -vf palettegen=max_colors=246 ${tempFileNames.palette} -y -loglevel error`; | ||
$`ffmpeg -i ${tempFileNames.screenshot} -i ${tempFileNames.palette} -filter_complex paletteuse ${imagePath} -y -loglevel error`; | ||
} | ||
|
||
if (await needsUpdate(`nitrofiles/pages/${rootPath}.ini`, `pages/${dir}/${page}`)) { | ||
|
@@ -96,24 +89,25 @@ for await (const folder of Deno.readDir("pages")) { | |
BG_COLOR_2 = 0xA108 | ||
`) | ||
|
||
const iniLinks = []; | ||
const iniLinks: string[] = []; | ||
for (const index in pageEval.links) { | ||
iniLinks.push(`[LINK${index}]\n` + Object.entries(pageEval.links[index]) | ||
.map(([key, value]) => `${key} = ${value}`) | ||
.join('\n')) | ||
} | ||
|
||
iniContent += iniLinks.join('\n\n') | ||
await Deno.writeTextFile(`nitrofiles/pages/${rootPath}.ini`, iniContent.trim()); | ||
await Bun.write(`nitrofiles/pages/${rootPath}.ini`, iniContent.trim()); | ||
} | ||
} | ||
} | ||
|
||
await browser.close(); | ||
|
||
// @ts-ignore | ||
if (jekyll) | ||
jekyll.kill(); | ||
|
||
for (const tempFile of Object.values(tempFileNames)) | ||
if (await exists(tempFile)) | ||
await Deno.remove(tempFile) | ||
await unlink(tempFile) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.