mirror of
https://github.com/hanzoai/quickjs-emscripten.git
synced 2026-10-30 19:37:29 +00:00
* Migrate from Yarn to pnpm - Replace Yarn 4.0.2 with pnpm 10.29.3 as the package manager - Add pnpm-workspace.yaml and .npmrc configuration - Update all scripts to use pnpm commands - Rename getYarnWorkspaces() to getWorkspaces() in scripts/helpers.ts - Update CI workflow to use pnpm/action-setup@v4 with Node 22 - Add @jitl/tsconfig as root devDependency for proper resolution - Add variant packages as devDependencies for test resolution - Fix TypeScript 5.9 compatibility in memory.ts (Int32Array<ArrayBuffer>) - Upgrade typedoc to 0.28.17 for TypeScript 5.9 support - Upgrade typedoc-plugin-markdown to 4.10.0 - Regenerate documentation with new typedoc version * Clarify git commit --amend rule in CLAUDE.md * CI: Add --ignore-scripts to pnpm install Equivalent to yarn's YARN_ENABLE_SCRIPTS=0 - prevents prepare scripts from running during install, which would fail on a fresh checkout. * Fix pnpm tarball naming in smoketest scripts pnpm pack generates tarball names like jitl-quickjs-ffi-types-0.32.0.tgz (without @ prefix, with version) instead of @jitl-quickjs-ffi-types.tgz * Update examples to TypeScript 5.9 for compatibility The library now requires TypeScript 5.9+ due to stricter typed array generics (Int32Array<ArrayBuffer>). Update all TypeScript-using examples. * Use --legacy-peer-deps for create-react-app smoketest react-scripts@5 only supports TypeScript 3.x/4.x, but our library now requires TypeScript 5.9+ for typed array generics. Use --legacy-peer-deps to work around the peer dependency conflict. * Fix formatting issues * Fix remaining formatting issues * Add reminder to run prettier and lint before pushing * Document CI workflow in CLAUDE.md * Add typedoc.json and remark plugins for in-page table of contents - Add typedoc-plugin-remark, remark-toc, and remark-insert-headings - Configure remark plugins to generate "Contents" section for Class, Interface, Enum, TypeAlias, and Function pages - This restores the in-page TOC that lists methods/properties that was removed in typedoc-plugin-markdown 4.3.0 * Use custom remark plugin for headless TOC in docs Replace remark-insert-headings + remark-toc with a custom plugin that inserts the table of contents directly after the class description, without a separate "Contents" heading. * Revert to standard remark plugins for TOC with Contents heading Use remark-insert-headings + remark-toc instead of custom plugin. Remove mdast-util-toc dependency and custom remark-toc-headless.mjs. * Fix lockfile - remove mdast-util-toc * Ignore pnpm-lock.yaml in prettier, update .yarn to .pnpm --------- Co-authored-by: Hanzo Dev <[email protected]>
102 lines
3.1 KiB
TypeScript
Executable File
102 lines
3.1 KiB
TypeScript
Executable File
#!/usr/bin/env -S npx tsx
|
|
import fs from "node:fs"
|
|
import * as glob from "glob"
|
|
import * as sh from "./helpers"
|
|
|
|
function hasMagic(str: string) {
|
|
return glob.hasMagic(str) || str.includes("!")
|
|
}
|
|
|
|
function checkFiles(pkg: sh.WorkspaceJson, packageJson: sh.PackageJson) {
|
|
const mustExist = (fileName: string, msg: string) => {
|
|
const abs = fileName.startsWith(pkg.location) ? fileName : sh.resolve(pkg.location, fileName)
|
|
if (!fs.existsSync(abs)) {
|
|
throw new Error(`${msg}: ${abs}`)
|
|
}
|
|
}
|
|
|
|
const globs = packageJson.files?.map((file) => sh.resolve(pkg.location, file))
|
|
if (!globs) return
|
|
|
|
const noMagic = globs.filter((str) => !hasMagic(str))
|
|
for (const mustExist of noMagic) {
|
|
if (!fs.existsSync(mustExist)) {
|
|
throw new Error(`package.json files entry ${mustExist} does not exist`)
|
|
}
|
|
}
|
|
|
|
const magic = globs.filter(hasMagic)
|
|
if (magic.length) {
|
|
const files = glob.sync(magic, { nodir: true })
|
|
if (!files.length) {
|
|
throw new Error(`package.json globs ${JSON.stringify(magic)} did not match any files`)
|
|
}
|
|
}
|
|
|
|
for (const [exportName, exportConditions] of Object.entries(packageJson.exports ?? {})) {
|
|
if (typeof exportConditions === "string") {
|
|
mustExist(exportConditions, `export ${exportName} file does not exist`)
|
|
} else if (!exportConditions) {
|
|
throw new Error(`export ${exportName} has no conditions`)
|
|
} else {
|
|
for (const [condition, exportFile] of Object.entries(exportConditions)) {
|
|
if (!exportFile) {
|
|
throw new Error(`export ${exportName} condition ${condition} has no file`)
|
|
}
|
|
mustExist(exportFile, `export ${exportName} condition ${condition} file does not exist`)
|
|
}
|
|
}
|
|
}
|
|
|
|
packageJson.main && mustExist(packageJson.main, `package.json main file does not exist`)
|
|
packageJson.module && mustExist(packageJson.module, `package.json module file does not exist`)
|
|
packageJson.types && mustExist(packageJson.types, `package.json types file does not exist`)
|
|
}
|
|
|
|
function checkReadme(
|
|
pkg: sh.WorkspaceJson,
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
_packageJson: sh.PackageJson,
|
|
) {
|
|
if (!fs.existsSync(sh.resolve(pkg.location, "README.md"))) {
|
|
throw new Error(`package.json files entry must include README.md`)
|
|
}
|
|
}
|
|
|
|
function checkProperties(pkg: sh.WorkspaceJson, packageJson: sh.PackageJson) {
|
|
if (!packageJson.name) {
|
|
throw new Error(`package.json must include name`)
|
|
}
|
|
if (!packageJson.version) {
|
|
throw new Error(`package.json must include name`)
|
|
}
|
|
|
|
if (packageJson.files || packageJson.exports) {
|
|
if (!packageJson.main) {
|
|
throw new Error(`package.json must include main`)
|
|
}
|
|
|
|
if (packageJson.main) {
|
|
if (!packageJson.types) {
|
|
throw new Error(`package.json must include types`)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (const pkg of sh.getWorkspaces()) {
|
|
const packageJson: sh.PackageJson = sh.readJson(sh.resolve(pkg.location, "package.json"))
|
|
if (packageJson.private) {
|
|
continue
|
|
}
|
|
|
|
try {
|
|
checkFiles(pkg, packageJson)
|
|
checkReadme(pkg, packageJson)
|
|
checkProperties(pkg, packageJson)
|
|
} catch (error: any) {
|
|
error.message = `${pkg.location}: ${error.message}`
|
|
throw error
|
|
}
|
|
}
|