Skip to content

Commit

Permalink
Move to native glob
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 3, 2024
1 parent cddfb7e commit 8bb1a4c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 60 deletions.
15 changes: 14 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import loguxConfig from '@logux/eslint-config'

/** @type {import('eslint').Linter.Config[]} */
export default [{ ignores: ['dist/', 'design/'] }, ...loguxConfig]
export default [
{ ignores: ['dist/', 'design/'] },
...loguxConfig,
{
rules: {
'n/no-unsupported-features/node-builtins': [
'error',
{
ignores: ['fs.globSync']
}
]
}
}
]
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"dependencies": {
"@types/node": "^22.7.4",
"autoprefixer": "^10.4.20",
"globby": "^14.0.2",
"jstransformer-lowlight": "^0.1.0",
"postcss": "^8.4.47",
"postcss-hexrgba": "^2.1.0",
Expand Down
40 changes: 0 additions & 40 deletions pnpm-lock.yaml

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

29 changes: 16 additions & 13 deletions scripts/build-api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { globby } from 'globby'
import childProcess from 'node:child_process'
import { existsSync } from 'node:fs'
import { existsSync, globSync } from 'node:fs'
import { mkdir, rm, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import { promisify } from 'node:util'
Expand Down Expand Up @@ -67,17 +66,14 @@ async function downloadProject(name) {
}

async function readTypedoc() {
let files = await globby('lib/*.d.ts', {
absolute: true,
cwd: join(PROJECTS, 'postcss')
})
let files = globSync(join(PROJECTS, 'postcss/lib/*.d.ts'))

let app = new TypeDoc.Application()
app.bootstrap({
entryPoints: files.flat(),
entryPoints: files,
tsconfig: join(PROJECTS, 'postcss', 'tsconfig.json')
})
app.options.setCompilerOptions(files.flat(), {
app.options.setCompilerOptions(files, {
esModuleInterop: true
})

Expand Down Expand Up @@ -281,7 +277,10 @@ function typeString(type) {
'{ ' +
decl.children
.map(i => {
if (i.kind === ReflectionKind.Function || i.kind === ReflectionKind.Method) {
if (
i.kind === ReflectionKind.Function ||
i.kind === ReflectionKind.Method
) {
return i.name + ': ' + functionString(i)
} else {
return i.name + ': ' + typeString(i.type)
Expand All @@ -303,7 +302,7 @@ function typeHtml(nodes, type) {
.replace(/<>/g, '')
.replace(
'DeclarationProps | Declaration | AtRule | Rule | Comment | AtRuleProps' +
' | RuleProps | CommentProps',
' | RuleProps | CommentProps',
'ChildProps | ChildNode'
)
.replace(
Expand Down Expand Up @@ -458,9 +457,13 @@ function generateBody(nodes) {
let children = type.children || []
if (name === 'postcss' && node.kind === ReflectionKind.Namespace) {
children = node.children
} else if (!node.signatures?.length && !node.comment && !node.children?.length) {
type = node.tryGetTargetReflection();
children = type.children || [];
} else if (
!node.signatures?.length &&
!node.comment &&
!node.children?.length
) {
type = node.tryGetTargetReflection()
children = type.children || []
if (!children.length) return ''
} else if (name !== 'postcss' && node.kind === ReflectionKind.Namespace) {
return ''
Expand Down
9 changes: 4 additions & 5 deletions scripts/build-docs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import { globby } from 'globby'
import childProcess from 'node:child_process'
import { existsSync } from 'node:fs'
import { existsSync, globSync } from 'node:fs'
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import { promisify } from 'node:util'
Expand All @@ -13,7 +12,7 @@ import remarkRehype from 'remark-rehype'
import { unified } from 'unified'
import { build } from 'vite'

import { DIST, PROJECTS, ROOT, SRC } from './lib/dir.js'
import { DIST, PROJECTS, SRC } from './lib/dir.js'

let exec = promisify(childProcess.exec)

Expand Down Expand Up @@ -94,12 +93,12 @@ const IGNORE_FILES = [
]

async function readDocs() {
let files = await globby(join(PROJECTS, 'postcss/docs/**/*.md'))
let files = globSync(join(PROJECTS, 'postcss/docs/**/*.md'))
let docs = await Promise.all(
files
.filter(file => !IGNORE_FILES.includes(file))
.map(async file => {
let md = await readFile(join(ROOT, file))
let md = await readFile(file)
let tree = await unified()().use(remarkParse).parse(md)
tree = await unified()
.use(remarkRehype, { allowDangerousHtml: true })
Expand Down

0 comments on commit 8bb1a4c

Please sign in to comment.