Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
gnugrep
llvmPackages.bintools
bun
nodejs_22
python313
rustup
typescript
Expand Down
16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
"url": "https://github.com/jackyzha0/quartz.git"
},
"scripts": {
"quartz": "bun quartz/bootstrap-cli.mjs",
"quartz": "bun quartz/bootstrap-cli.mts",
"docs": "bun run quartz build --serve -d docs",
"check": "node node_modules/typescript/bin/tsc --noEmit && node node_modules/prettier/bin/prettier.cjs . --check",
"format": "node node_modules/prettier/bin/prettier.cjs . --write",
"test": "node --import tsx --test",
"profile": "0x -D prof ./quartz/bootstrap-cli.mjs build --concurrency=1",
"install-plugins": "node node_modules/tsx/dist/cli.mjs ./quartz/plugins/loader/install-plugins.ts",
"check": "bun run tsc --noEmit && bun run prettier . --check",
"format": "bun run prettier . --write",
"test": "bun test",
"profile": "bun --cpu-prof --cpu-prof-dir prof quartz/bootstrap-cli.mts build --concurrency=1",
"install-plugins": "bun quartz/plugins/loader/install-plugins.ts",
"prebuild": "bun run install-plugins"
},
"engines": {
"node": ">=22",
"bun": ">=1.3.13"
},
"keywords": [
Expand All @@ -34,7 +33,7 @@
"quartz"
],
"bin": {
"quartz": "./quartz/bootstrap-cli.mjs"
"quartz": "./quartz/bootstrap-cli.mts"
},
"dependencies": {
"@clack/prompts": "^1.3.0",
Expand Down Expand Up @@ -84,7 +83,6 @@
"@types/yargs": "^17.0.35",
"esbuild": "^0.28.0",
"prettier": "^3.8.3",
"tsx": "^4.21.0",
"typescript": "^6.0.3"
},
"packageManager": "bun@1.3.13"
Expand Down
8 changes: 4 additions & 4 deletions quartz/bootstrap-cli.mjs → quartz/bootstrap-cli.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
handleUpgrade,
handleRestore,
handleSync,
} from "./cli/handlers.js"
} from "./cli/handlers.ts"

import {
handlePluginInstallUnified,
Expand All @@ -19,9 +19,9 @@ import {
handlePluginDisable,
handlePluginConfig,
handlePluginPrune,
} from "./cli/plugin-git-handlers.js"
import { CommonArgv, BuildArgv, CreateArgv, SyncArgv } from "./cli/args.js"
import { version } from "./cli/constants.js"
} from "./cli/plugin-git-handlers.ts"
import { CommonArgv, BuildArgv, CreateArgv, SyncArgv } from "./cli/args.ts"
import { version } from "./cli/constants.ts"

async function launchTui() {
const { join } = await import("path")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env bun
import workerpool from "workerpool"
const cacheFile = "./.quartz-cache/transpiled-worker.mjs"
const { parseMarkdown, processHtml } = await import(cacheFile)
Expand Down
File renamed without changes.
File renamed without changes.
13 changes: 7 additions & 6 deletions quartz/cli/handlers.js → quartz/cli/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { promises } from "fs"
import path from "path"
import esbuild from "esbuild"
Expand All @@ -14,20 +15,20 @@ import serveHandler from "serve-handler"
import { WebSocketServer } from "ws"
import { randomUUID } from "crypto"
import { Mutex } from "async-mutex"
import { CreateArgv } from "./args.js"
import { CreateArgv } from "./args.ts"
import { globby } from "globby"
import {
exitIfCancel,
escapePath,
gitPull,
popContentFolder,
stashContentFolder,
} from "./helpers.js"
} from "./helpers.ts"
import {
handlePluginRestore,
handlePluginCheck,
handlePluginResolve,
} from "./plugin-git-handlers.js"
} from "./plugin-git-handlers.ts"
import {
configExists,
createConfigFromDefault,
Expand All @@ -37,7 +38,7 @@ import {
extractPluginName,
updateGlobalConfig,
LOCKFILE_PATH,
} from "./plugin-data.js"
} from "./plugin-data.ts"
import {
UPSTREAM_NAME,
QUARTZ_SOURCE_BRANCH,
Expand All @@ -47,7 +48,7 @@ import {
fp,
cacheFile,
cwd,
} from "./constants.js"
} from "./constants.ts"

/**
* Resolve content directory path
Expand Down Expand Up @@ -583,7 +584,7 @@ export async function handleBuild(argv) {
if (argv.watch) {
const paths = await globby([
"**/*.ts",
"quartz/cli/*.js",
"quartz/cli/*.ts",
"quartz/static/**/*",
"**/*.tsx",
"**/*.scss",
Expand Down
3 changes: 2 additions & 1 deletion quartz/cli/helpers.js → quartz/cli/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-nocheck
import { isCancel, outro } from "@clack/prompts"
import { styleText } from "util"
import { contentCacheFolder } from "./constants.js"
import { contentCacheFolder } from "./constants.ts"
import { spawnSync } from "child_process"
import fs from "fs"

Expand Down
1 change: 1 addition & 0 deletions quartz/cli/plugin-data.js → quartz/cli/plugin-data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import fs from "fs"
import path from "path"
import { execSync } from "child_process"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import fs from "fs"
import path from "path"
import os from "os"
Expand All @@ -19,7 +20,7 @@ import {
formatSource,
resolveLockfileName,
getNameOverrides,
} from "./plugin-data.js"
} from "./plugin-data.ts"

const INTERNAL_EXPORTS = new Set(["manifest", "default"])

Expand Down
69 changes: 57 additions & 12 deletions quartz/plugins/loader/install-plugins.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,70 @@
#!/usr/bin/env node
#!/usr/bin/env bun

import fs from "node:fs"
import path from "node:path"
import YAML from "yaml"
import { installPlugins, parsePluginSource } from "./gitLoader.js"
import config from "../../../quartz.js"
import type { GitPluginSpec } from "./gitLoader.js"
import type { PluginSource, QuartzPluginsJson } from "./types"

const configCandidates = [
"quartz.config.yaml",
"quartz.plugins.json",
"quartz.config.default.yaml",
"quartz.plugins.default.json",
]

function resolveConfigPath(): string | undefined {
return configCandidates
.map((candidate) => path.resolve(process.cwd(), candidate))
.find((candidate) => fs.existsSync(candidate))
}

function readPluginsConfig(): QuartzPluginsJson | undefined {
const configPath = resolveConfigPath()
if (!configPath) {
return undefined
}

const raw = fs.readFileSync(configPath, "utf-8")
if (configPath.endsWith(".yaml") || configPath.endsWith(".yml")) {
return YAML.parse(raw) as QuartzPluginsJson
}

return JSON.parse(raw) as QuartzPluginsJson
}

function enabledPluginSources(config: QuartzPluginsJson | undefined): PluginSource[] {
return (config?.plugins ?? []).filter((entry) => entry.enabled).map((entry) => entry.source)
}

function uniqueSpecs(sources: PluginSource[]): GitPluginSpec[] {
const specs = new Map<string, GitPluginSpec>()
for (const source of sources) {
const spec = parsePluginSource(source)
if (!specs.has(spec.name)) {
specs.set(spec.name, spec)
}
}

return [...specs.values()]
}

async function main() {
const quartzConfig: any = config
const externalPlugins = quartzConfig.externalPlugins || []
const specs = uniqueSpecs(enabledPluginSources(readPluginsConfig()))

if (externalPlugins.length === 0) {
console.log("No external plugins to install.")
if (specs.length === 0) {
console.log("No enabled plugins to install.")
return
}

console.log(`Installing ${externalPlugins.length} plugin(s) from Git...`)

const specs = externalPlugins.map((source: string) => parsePluginSource(source))
console.log(`Installing ${specs.length} enabled plugin(s)...`)
const installed = await installPlugins(specs, { verbose: true })

if (installed.size === externalPlugins.length) {
console.log("✓ All plugins installed successfully")
if (installed.size === specs.length) {
console.log("All plugins installed successfully")
} else {
console.error(`✗ Only ${installed.size}/${externalPlugins.length} plugins installed`)
console.error(`Only ${installed.size}/${specs.length} plugins installed`)
process.exit(1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion quartz/processors/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export async function parseMarkdown(ctx: BuildCtx, fps: FilePath[]): Promise<Pro
}
} else {
await transpileWorkerScript()
const pool = workerpool.pool("./quartz/bootstrap-worker.mjs", {
const pool = workerpool.pool("./quartz/bootstrap-worker.mts", {
minWorkers: "max",
maxWorkers: concurrency,
workerType: "thread",
Expand Down
Loading
Loading