valaxy-addon-typedoc 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/node/loader.ts +25 -6
  2. package/package.json +3 -3
package/node/loader.ts CHANGED
@@ -3,12 +3,12 @@ import type { TypeDocAddonOptions } from './index'
3
3
  import { execFileSync, spawn } from 'node:child_process'
4
4
  import { createHash } from 'node:crypto'
5
5
  import { createRequire } from 'node:module'
6
- import { dirname, relative, resolve, sep } from 'node:path'
6
+ import { dirname, posix, relative, resolve, sep } from 'node:path'
7
7
  import process from 'node:process'
8
8
  import { fileURLToPath } from 'node:url'
9
- import fg from 'fast-glob'
10
9
  import fs from 'fs-extra'
11
10
  import { minimatch } from 'minimatch'
11
+ import { glob } from 'tinyglobby'
12
12
  import { resolveSymbolAnchors } from './links'
13
13
 
14
14
  interface NavigationItem {
@@ -46,12 +46,12 @@ export function createTypeDocLoader(settings: TypeDocAddonOptions, userRoot: str
46
46
  let runs = 0
47
47
 
48
48
  async function sourceFiles() {
49
- const sources = await fg(settings.watch, { cwd: userRoot, absolute: true, onlyFiles: true, ignore: ['**/.valaxy/**', '**/dist/**'] })
49
+ const sources = await glob(settings.watch, { cwd: userRoot, absolute: true, onlyFiles: true, ignore: ['**/.valaxy/**', '**/dist/**'] })
50
50
  return [...new Set([optionsFile, ...sources, ...dependencies])].sort()
51
51
  }
52
52
 
53
53
  async function fingerprint(files: string[]) {
54
- const hash = createHash('sha256').update(JSON.stringify({ schema: 8, settings }))
54
+ const hash = createHash('sha256').update(JSON.stringify({ schema: 9, settings }))
55
55
  for (const pkg of ['valaxy-addon-typedoc', 'typedoc', 'typedoc-plugin-markdown', 'typescript']) {
56
56
  let directory = dirname(require.resolve(pkg))
57
57
  while (directory !== dirname(directory)) {
@@ -66,7 +66,26 @@ export function createTypeDocLoader(settings: TypeDocAddonOptions, userRoot: str
66
66
  // Source links generated by TypeDoc point at this exact revision.
67
67
  try {
68
68
  source.revision = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: userRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()
69
- source.dirty = !!execFileSync('git', ['status', '--porcelain'], { cwd: userRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()
69
+ const prefix = execFileSync('git', ['rev-parse', '--show-prefix'], { cwd: userRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()
70
+ const roots = [resolve(userRoot), await fs.realpath(userRoot)]
71
+ const inputs = new Set((await Promise.all(files.map(async (file) => {
72
+ // Git and Node can spell a Windows temp path with long or 8.3 names.
73
+ // Resolve from the selected project instead of comparing Git root names.
74
+ const paths = [file, await fs.realpath(file).catch(() => file)]
75
+ return roots.flatMap(root => paths.map(path => posix.normalize(`${prefix}${relative(root, path).replaceAll('\\', '/')}`)))
76
+ }))).flat())
77
+ const changes = execFileSync('git', ['status', '--porcelain=v1', '-z', '--untracked-files=all'], { cwd: userRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).split('\0')
78
+ // Generated site metadata and unrelated edits do not change API sources.
79
+ // NUL-delimited paths preserve spaces and non-ASCII names, including renames.
80
+ source.dirty = false
81
+ for (let index = 0; index < changes.length; index++) {
82
+ const entry = changes[index]
83
+ source.dirty ||= inputs.has(entry.slice(3))
84
+ if (/[RC]/.test(entry.slice(0, 2))) {
85
+ const previousPath = changes[++index]
86
+ source.dirty ||= inputs.has(previousPath)
87
+ }
88
+ }
70
89
  hash.update(JSON.stringify({ revision: source.revision, dirty: source.dirty }))
71
90
  }
72
91
  catch { hash.update('unversioned') }
@@ -138,7 +157,7 @@ export function createTypeDocLoader(settings: TypeDocAddonOptions, userRoot: str
138
157
  const result = await fs.readJson(resultFile) as { files: string[], version?: string }
139
158
  dependencies = result.files
140
159
  source.version = result.version
141
- const paths = await fg('**/*.md', { cwd: output })
160
+ const paths = await glob('**/*.md', { cwd: output })
142
161
  if (!paths.length)
143
162
  throw new Error('[typedoc] Refusing to publish empty API documentation.')
144
163
  const sources = new Map(await Promise.all(paths.map(async page => [page, await fs.readFile(resolve(output, page), 'utf8')] as const)))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy-addon-typedoc",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "Cached TypeDoc reference pages for Valaxy documentation sites",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -27,15 +27,15 @@
27
27
  "valaxy": ">=1.0.0-rc.13 <2"
28
28
  },
29
29
  "dependencies": {
30
- "fast-glob": "^3.3.3",
31
30
  "fs-extra": "^11.4.0",
32
31
  "minimatch": "^10.2.4",
32
+ "tinyglobby": "^0.2.17",
33
33
  "typedoc": "^0.28.20",
34
34
  "typedoc-plugin-markdown": "^4.13.1",
35
35
  "typescript": "^5.9.3"
36
36
  },
37
37
  "devDependencies": {
38
- "valaxy": "1.0.0-rc.15"
38
+ "valaxy": "1.0.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"