fix(scripts): replace async fs glob with globSync (failed on Node 22.18)
This commit is contained in:
@@ -25,9 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { execFileSync } from 'node:child_process'
|
import { execFileSync } from 'node:child_process'
|
||||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
import { globSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
||||||
import { join, relative, resolve } from 'node:path'
|
import { join, relative, resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
import ts from 'typescript'
|
import ts from 'typescript'
|
||||||
|
|
||||||
const root = resolve(import.meta.dirname, '..')
|
const root = resolve(import.meta.dirname, '..')
|
||||||
@@ -139,7 +138,7 @@ const markdownGlobs = ['README.md', 'docs/**/*.md', 'packages/*/*.md', 'packages
|
|||||||
|
|
||||||
const files: string[] = []
|
const files: string[] = []
|
||||||
for (const pattern of markdownGlobs) {
|
for (const pattern of markdownGlobs) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) files.push(resolve(root, match))
|
for (const match of globSync(pattern, { cwd: root })) files.push(resolve(root, match))
|
||||||
}
|
}
|
||||||
files.sort()
|
files.sort()
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,8 @@
|
|||||||
* Run: `tsx scripts/verify-doc-refs.ts`.
|
* Run: `tsx scripts/verify-doc-refs.ts`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { existsSync, readFileSync } from 'node:fs'
|
import { existsSync, globSync, readFileSync } from 'node:fs'
|
||||||
import { relative, resolve } from 'node:path'
|
import { relative, resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
|
|
||||||
const root = resolve(import.meta.dirname, '..')
|
const root = resolve(import.meta.dirname, '..')
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ function findViolations(absPath: string): Violation[] {
|
|||||||
const all: Violation[] = []
|
const all: Violation[] = []
|
||||||
let checked = 0
|
let checked = 0
|
||||||
for (const pattern of PATTERNS) {
|
for (const pattern of PATTERNS) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) {
|
for (const match of globSync(pattern, { cwd: root })) {
|
||||||
if (isExcluded(match)) continue
|
if (isExcluded(match)) continue
|
||||||
checked++
|
checked++
|
||||||
all.push(...findViolations(resolve(root, match)))
|
all.push(...findViolations(resolve(root, match)))
|
||||||
|
|||||||
@@ -32,9 +32,8 @@
|
|||||||
* Run: `tsx scripts/verify-md-links.ts`.
|
* Run: `tsx scripts/verify-md-links.ts`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
import { existsSync, globSync, readFileSync, realpathSync } from 'node:fs'
|
||||||
import { dirname, relative, resolve } from 'node:path'
|
import { dirname, relative, resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
import { fromMarkdown } from 'mdast-util-from-markdown'
|
import { fromMarkdown } from 'mdast-util-from-markdown'
|
||||||
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
||||||
import { gfm } from 'micromark-extension-gfm'
|
import { gfm } from 'micromark-extension-gfm'
|
||||||
@@ -134,7 +133,7 @@ const seen = new Set<string>()
|
|||||||
const all: Violation[] = []
|
const all: Violation[] = []
|
||||||
let checked = 0
|
let checked = 0
|
||||||
for (const pattern of PATTERNS) {
|
for (const pattern of PATTERNS) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) {
|
for (const match of globSync(pattern, { cwd: root })) {
|
||||||
const abs = resolve(root, match)
|
const abs = resolve(root, match)
|
||||||
// CLAUDE.md symlinks resolve onto AGENTS.md; dedupe by real path so a file
|
// CLAUDE.md symlinks resolve onto AGENTS.md; dedupe by real path so a file
|
||||||
// matched twice (or via symlink) is checked once.
|
// matched twice (or via symlink) is checked once.
|
||||||
|
|||||||
@@ -25,9 +25,8 @@
|
|||||||
* Run: `tsx scripts/verify-md-wrap.ts`.
|
* Run: `tsx scripts/verify-md-wrap.ts`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readFileSync, realpathSync } from 'node:fs'
|
import { globSync, readFileSync, realpathSync } from 'node:fs'
|
||||||
import { relative, resolve } from 'node:path'
|
import { relative, resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
import { fromMarkdown } from 'mdast-util-from-markdown'
|
import { fromMarkdown } from 'mdast-util-from-markdown'
|
||||||
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
||||||
import { gfm } from 'micromark-extension-gfm'
|
import { gfm } from 'micromark-extension-gfm'
|
||||||
@@ -76,7 +75,7 @@ const seen = new Set<string>()
|
|||||||
const all: Violation[] = []
|
const all: Violation[] = []
|
||||||
let checked = 0
|
let checked = 0
|
||||||
for (const pattern of PATTERNS) {
|
for (const pattern of PATTERNS) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) {
|
for (const match of globSync(pattern, { cwd: root })) {
|
||||||
const abs = resolve(root, match)
|
const abs = resolve(root, match)
|
||||||
// CLAUDE.md symlinks resolve onto AGENTS.md; dedupe by real path so a file
|
// CLAUDE.md symlinks resolve onto AGENTS.md; dedupe by real path so a file
|
||||||
// matched twice (or via symlink) is checked once.
|
// matched twice (or via symlink) is checked once.
|
||||||
|
|||||||
@@ -12,9 +12,8 @@
|
|||||||
* Run: `tsx scripts/verify-mermaid.ts`.
|
* Run: `tsx scripts/verify-mermaid.ts`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readFileSync, realpathSync } from 'node:fs'
|
import { globSync, readFileSync, realpathSync } from 'node:fs'
|
||||||
import { resolve } from 'node:path'
|
import { resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
import { fromMarkdown } from 'mdast-util-from-markdown'
|
import { fromMarkdown } from 'mdast-util-from-markdown'
|
||||||
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
||||||
import { gfm } from 'micromark-extension-gfm'
|
import { gfm } from 'micromark-extension-gfm'
|
||||||
@@ -72,7 +71,7 @@ const blocks: Block[] = []
|
|||||||
const seen = new Set<string>()
|
const seen = new Set<string>()
|
||||||
let checkedFiles = 0
|
let checkedFiles = 0
|
||||||
for (const pattern of PATTERNS) {
|
for (const pattern of PATTERNS) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) {
|
for (const match of globSync(pattern, { cwd: root })) {
|
||||||
const real = realpathSync(resolve(root, match))
|
const real = realpathSync(resolve(root, match))
|
||||||
if (seen.has(real)) continue
|
if (seen.has(real)) continue
|
||||||
seen.add(real)
|
seen.add(real)
|
||||||
|
|||||||
@@ -39,9 +39,8 @@
|
|||||||
* Run: `tsx scripts/verify-package-paths.ts`.
|
* Run: `tsx scripts/verify-package-paths.ts`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs'
|
import { existsSync, globSync, readdirSync, readFileSync, realpathSync } from 'node:fs'
|
||||||
import { relative, resolve } from 'node:path'
|
import { relative, resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
|
|
||||||
const root = resolve(import.meta.dirname, '..')
|
const root = resolve(import.meta.dirname, '..')
|
||||||
|
|
||||||
@@ -144,7 +143,7 @@ const all: Violation[] = []
|
|||||||
let checked = 0
|
let checked = 0
|
||||||
const seen = new Set<string>()
|
const seen = new Set<string>()
|
||||||
for (const pattern of PATTERNS) {
|
for (const pattern of PATTERNS) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) {
|
for (const match of globSync(pattern, { cwd: root })) {
|
||||||
if (isExcluded(match)) continue
|
if (isExcluded(match)) continue
|
||||||
// Dedup by real path: the root/packages CLAUDE.md are symlinks to AGENTS.md.
|
// Dedup by real path: the root/packages CLAUDE.md are symlinks to AGENTS.md.
|
||||||
const real = realpathSync(resolve(root, match))
|
const real = realpathSync(resolve(root, match))
|
||||||
|
|||||||
@@ -44,9 +44,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { createHash } from 'node:crypto'
|
import { createHash } from 'node:crypto'
|
||||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
import { existsSync, globSync, readFileSync, writeFileSync } from 'node:fs'
|
||||||
import { basename, join, resolve } from 'node:path'
|
import { basename, join, resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
import { fromMarkdown } from 'mdast-util-from-markdown'
|
import { fromMarkdown } from 'mdast-util-from-markdown'
|
||||||
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
||||||
import { gfm } from 'micromark-extension-gfm'
|
import { gfm } from 'micromark-extension-gfm'
|
||||||
@@ -211,7 +210,7 @@ function parse(content: string): Nodes {
|
|||||||
// Enumerate the scope once.
|
// Enumerate the scope once.
|
||||||
const files = new Set<string>()
|
const files = new Set<string>()
|
||||||
for (const pattern of SCOPE_PATTERNS) {
|
for (const pattern of SCOPE_PATTERNS) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) files.add(match)
|
for (const match of globSync(pattern, { cwd: root })) files.add(match)
|
||||||
}
|
}
|
||||||
const translations = [...files].filter(f => f.endsWith('.zh.md')).sort()
|
const translations = [...files].filter(f => f.endsWith('.zh.md')).sort()
|
||||||
const metas = [...files].filter(f => f.endsWith('.i18n.yaml')).sort()
|
const metas = [...files].filter(f => f.endsWith('.i18n.yaml')).sort()
|
||||||
|
|||||||
@@ -22,9 +22,8 @@
|
|||||||
* Run: `tsx scripts/verify-type-equiv.ts`.
|
* Run: `tsx scripts/verify-type-equiv.ts`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { readFileSync, existsSync } from 'node:fs'
|
import { globSync, readFileSync, existsSync } from 'node:fs'
|
||||||
import { resolve } from 'node:path'
|
import { resolve } from 'node:path'
|
||||||
import { glob } from 'node:fs/promises'
|
|
||||||
import ts from 'typescript'
|
import ts from 'typescript'
|
||||||
|
|
||||||
const root = resolve(import.meta.dirname, '..')
|
const root = resolve(import.meta.dirname, '..')
|
||||||
@@ -148,7 +147,7 @@ const keyOf = (x: { doc: string; symbol: string }): string => `${x.doc}::${x.sym
|
|||||||
// as an orphan rather than silently skipped.
|
// as an orphan rather than silently skipped.
|
||||||
const docSet = new Set<string>()
|
const docSet = new Set<string>()
|
||||||
for (const pattern of MARKDOWN_GLOBS) {
|
for (const pattern of MARKDOWN_GLOBS) {
|
||||||
for await (const match of glob(pattern, { cwd: root })) docSet.add(match)
|
for (const match of globSync(pattern, { cwd: root })) docSet.add(match)
|
||||||
}
|
}
|
||||||
const blocks: EquivBlock[] = [...docSet].sort().flatMap(extractEquivBlocks)
|
const blocks: EquivBlock[] = [...docSet].sort().flatMap(extractEquivBlocks)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user