Skip to content

Commit

Permalink
chore: update modules (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
giladgd authored Oct 31, 2024
1 parent ea12dc5 commit ff02ebd
Show file tree
Hide file tree
Showing 83 changed files with 1,970 additions and 1,724 deletions.
166 changes: 0 additions & 166 deletions .eslintrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ jobs:
export DOCS_PACKAGE_VERSION="$(cat ./docsVersion.txt)"
echo "Package version: $DOCS_PACKAGE_VERSION"
git apply --ignore-whitespace ./scripts/patches/vitepress+1.3.4.patch
npm run docs:build
- name: Upload docs to GitHub Pages
uses: actions/upload-pages-artifact@v3
Expand Down Expand Up @@ -792,7 +791,6 @@ jobs:
export DOCS_PACKAGE_VERSION="$(cat ./docsVersion.txt)"
echo "Package version: $DOCS_PACKAGE_VERSION"
git apply --ignore-whitespace ./scripts/patches/vitepress+1.3.4.patch
npm run docs:build
- name: Upload docs to GitHub Pages
uses: actions/upload-pages-artifact@v3
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install modules
run: npm ci
- name: ESLint
run: npx eslint --ext .js --ext .ts .
run: npx eslint
- name: TypeScript validity
run: npm run test:typescript

Expand All @@ -44,6 +44,4 @@ jobs:
CI: true
run: node ./dist/cli/cli.js source download --release latest --skipBuild --noBundle --noUsageExample --updateBinariesReleaseMetadataAndSaveGitBundle
- name: Compile docs
run: |
git apply --ignore-whitespace ./scripts/patches/vitepress+1.3.4.patch
npm run docs:build
run: npm run docs:build
2 changes: 2 additions & 0 deletions .releaserc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ const homepageUrlWithoutTrailingSlash = homepageUrl.endsWith("/")
? homepageUrl.slice(0, -1)
: homepageUrl;

/* eslint-disable @stylistic/max-len */
const newFooterTemplate = defaultFooterTemplate + "\n---\n\n" +
`Shipped with \`llama.cpp\` release [\`${binariesSourceRelease.split("`").join("")}\`](https://github.com/${defaultLlamaCppGitHubRepo}/releases/tag/${encodeURIComponent(binariesSourceRelease)})\n\n` +
`> To use the latest \`llama.cpp\` release available, run \`npx -n ${cliBinName} source download --release latest\`. ([learn more](${homepageUrlWithoutTrailingSlash}/guide/building-from-source#download-new-release))\n`;
/* eslint-enable @stylistic/max-len */

const githubPluginConfig = {
discussionCategoryName: "Releases" as string | boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function getElectronExampleAppDownloadLink() {

const isMacOs = platformInfo?.platform != null
? platformInfo.platform === "macOS"
: (navigator.userAgent.includes("Mac OS X") || navigator.userAgent.includes("Macintosh"))
: (navigator.userAgent.includes("Mac OS X") || navigator.userAgent.includes("Macintosh"));
const isWindows = platformInfo?.platform != null
? platformInfo.platform === "Windows"
: navigator.userAgent.includes("Windows");
Expand Down Expand Up @@ -73,17 +73,17 @@ export async function getElectronExampleAppDownloadLink() {
relevantAssets = assets
.filter((asset) => asset.name.includes(".macOS."))
.filter(filterByArchitecture)
.filter((asset) => asset.name.endsWith(".dmg"))
.filter((asset) => asset.name.endsWith(".dmg"));
} else if (isWindows) {
relevantAssets = assets
.filter((asset) => asset.name.includes(".Windows."))
.filter(filterByArchitecture)
.filter((asset) => asset.name.endsWith(".exe"))
.filter((asset) => asset.name.endsWith(".exe"));
} else if (isLinux) {
relevantAssets = assets
.filter((asset) => asset.name.includes(".Linux."))
.filter(filterByArchitecture)
.filter((asset) => asset.name.endsWith(".AppImage"))
.filter((asset) => asset.name.endsWith(".AppImage"));
}

if (relevantAssets.length > 0 && relevantAssets[0]!.browser_download_url != null)
Expand Down
20 changes: 10 additions & 10 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {createContentLoader, defineConfig, HeadConfig} from "vitepress";
import path from "path";
import {createRequire} from "node:module";
import process from "process";
import fs from "fs-extra";
import {fileURLToPath} from "url";
import fs from "fs-extra";
import {createContentLoader, defineConfig, HeadConfig} from "vitepress";
import {transformerTwoslash} from "@shikijs/vitepress-twoslash";
import ts from "typescript";
import envVar from "env-var";
import {Feed} from "feed";
import {rehype} from "rehype";
import {Element as HastElement, Parent} from "hast";
import sharp from "sharp";
import {GitChangelog, GitChangelogMarkdownSection} from "@nolebase/vitepress-plugin-git-changelog/vite";
import {buildEndGenerateOpenGraphImages} from "@nolebase/vitepress-plugin-og-image/vitepress";
import {Resvg, initWasm as initResvgWasm, ResvgRenderOptions} from "@resvg/resvg-wasm";
import {Resvg, initWasm as initResvgWasm, type ResvgRenderOptions} from "@resvg/resvg-wasm";
import {BlogPageInfoPlugin} from "./config/BlogPageInfoPlugin.js";
import {getApiReferenceSidebar} from "./config/apiReferenceSidebar.js";
import {ensureLocalImage} from "./utils/ensureLocalImage.js";
import type {Element as HastElement, Parent} from "hast";

import type {Node as UnistNode} from "unist";
import type {ShikiTransformer} from "shiki";
Expand All @@ -34,7 +34,7 @@ const packageVersion = env.get("DOCS_PACKAGE_VERSION")
.default(packageJson.version)
.asString();

const hostname = "https://node-llama-cpp.withcat.ai/"
const hostname = "https://node-llama-cpp.withcat.ai/";
const buildDate = new Date();

const socialPosterLink = hostname + "social.poster.jpg";
Expand Down Expand Up @@ -178,7 +178,7 @@ export default defineConfig({
"window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js',new Date());" +
"gtag('config','G-Q2SWE5Z1ST');"
],
["style", {}],
["style", {}]
],
async transformHead({pageData, head}) {
if (pageData.filePath === "index.md") {
Expand Down Expand Up @@ -263,7 +263,7 @@ export default defineConfig({
pageData.frontmatter.editLink = false;
pageData.frontmatter.lastUpdated = false;
pageData.frontmatter.aside = false;
pageData.frontmatter.outline = false
pageData.frontmatter.outline = false;
pageData.frontmatter.nolebase = {
gitChangelog: false
};
Expand Down Expand Up @@ -507,7 +507,7 @@ export default defineConfig({
"inter-latin-ext-400-normal.woff2",
"inter-latin-ext-500-normal.woff2",
"inter-latin-ext-600-normal.woff2",
"inter-latin-ext-700-normal.woff2",
"inter-latin-ext-700-normal.woff2"
];

return await Promise.all(
Expand All @@ -532,7 +532,7 @@ export default defineConfig({
const innerSvgImages = loadInnerSvgImages();

async function renderSvg(svgPath: string, destPngPath: string, options: ResvgRenderOptions) {
console.info(`Rendering "${svgPath}" to "${destPngPath}"`)
console.info(`Rendering "${svgPath}" to "${destPngPath}"`);

const svgContent = await fs.readFile(svgPath, "utf8");
const svgImages = await innerSvgImages;
Expand Down Expand Up @@ -665,7 +665,7 @@ export default defineConfig({
author: {
name: typeof packageJson.author === "string"
? packageJson.author
: (packageJson.author as undefined | { name?: string })?.name
: (packageJson.author as undefined | {name?: string})?.name
},
hub: "https://pubsubhubbub.appspot.com/"
});
Expand Down
17 changes: 8 additions & 9 deletions .vitepress/config/BlogPageInfoPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {MarkdownEnv, Plugin} from "vitepress";
import path from "path";
import {htmlEscape} from "../utils/htmlEscape.js";
import {MarkdownEnv, Plugin} from "vitepress";
import {getMarkdownRenderer} from "../utils/getMarkdownRenderer.js";
import {renderHtmlTag} from "../utils/renderHtmlTag.js";
import {ensureLocalImage, resolveImageBuffers, relativeToAbsoluteImageUrls} from "../utils/ensureLocalImage.js";

export function BlogPageInfoPlugin({
include
}: {
include(id: string): boolean,
include(id: string): boolean
}): Plugin {
const refIdToUrlPath = new Map<string, string>();
let root = "";
Expand Down Expand Up @@ -84,12 +83,13 @@ export function BlogPageInfoPlugin({
const frontmatterCode = code.slice(0, frontmatterEndIndex);
const markdownCode = code.slice(frontmatterEndIndex);

const frontmatterDate = new Date(frontmatter.date);
let newCode = frontmatterCode + (
"# " + frontmatter.title + "\n\n" +
[
"",
'<script setup lang="ts">',
`const articleDate = new Date(${JSON.stringify(new Date(frontmatter.date).toISOString())}).toLocaleDateString("en-US", {`,
`const articleDate = new Date(${JSON.stringify(frontmatterDate.toISOString())}).toLocaleDateString("en-US", {`,
' year: "numeric",',
' month: "long",',
' day: "numeric"',
Expand Down Expand Up @@ -118,10 +118,9 @@ export function BlogPageInfoPlugin({
alt: frontmatter.title,
width: width,
height: height,
style: 'background-image: url(' + JSON.stringify(previewUrlPath.absolute) + ');'
style: "background-image: url(" + JSON.stringify(previewUrlPath.absolute) + ");"
});
}
else if (typeof (frontmatter.image as any).url === "string") {
} else if (typeof (frontmatter.image as any).url === "string") {
const {
urlPath, previewUrlPath, width, height
} = await ensureLocalImage((frontmatter.image as any).url, "cover", {
Expand All @@ -133,7 +132,7 @@ export function BlogPageInfoPlugin({
alt: (frontmatter.image as any).alt ?? frontmatter.title,
width: width ?? (frontmatter.image as any).width,
height: height ?? (frontmatter.image as any).height,
style: 'background-image: url(' + JSON.stringify(previewUrlPath.absolute) + ');'
style: "background-image: url(" + JSON.stringify(previewUrlPath.absolute) + ");"
});
}
}
Expand All @@ -143,7 +142,7 @@ export function BlogPageInfoPlugin({

return newCode;
}
}
};
}

function findFrontmatterEndIndex(mdCode: string): number {
Expand Down
Loading

0 comments on commit ff02ebd

Please sign in to comment.