starlight-versions 0.5.1 → 0.5.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # starlight-versions
2
2
 
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#24](https://github.com/HiDeoo/starlight-versions/pull/24) [`113cb97`](https://github.com/HiDeoo/starlight-versions/commit/113cb975b6acc3dc3dc6d1c252048e62248dc9ed) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue with symlinked version directories.
8
+
3
9
  ## 0.5.1
4
10
 
5
11
  ### Patch Changes
package/libs/fs.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { PathLike } from 'node:fs'
1
+ import type { Dirent, PathLike } from 'node:fs'
2
2
  import fs from 'node:fs/promises'
3
+ import path from 'node:path'
3
4
 
4
5
  import { ensureTrailingSlash } from './path'
5
6
 
@@ -60,6 +61,17 @@ export function ensureDirectory(directory: PathLike) {
60
61
  return fs.mkdir(directory, { recursive: true })
61
62
  }
62
63
 
64
+ // Checks if the entry is a directory or a symbolic link to a directory.
65
+ export async function isDirectoryEntry(entry: Dirent) {
66
+ if (entry.isDirectory()) return true
67
+ if (!entry.isSymbolicLink()) return false
68
+
69
+ const entryPath = path.join(entry.parentPath, entry.name)
70
+ const stats = await fs.stat(entryPath)
71
+
72
+ return stats.isDirectory()
73
+ }
74
+
63
75
  export type CopyDirectoryCallback = (
64
76
  entry:
65
77
  | { type: 'file'; content: string; url: URL }
package/libs/versions.ts CHANGED
@@ -5,7 +5,15 @@ import { z } from 'astro/zod'
5
5
  import type { StarlightVersionsConfig } from '..'
6
6
  import type { DocsVersionsConfig } from '../schema'
7
7
 
8
- import { copyDirectory, copyFile, ensureDirectory, listDirectory, readJSONFile, writeJSONFile } from './fs'
8
+ import {
9
+ copyDirectory,
10
+ copyFile,
11
+ ensureDirectory,
12
+ isDirectoryEntry,
13
+ listDirectory,
14
+ readJSONFile,
15
+ writeJSONFile,
16
+ } from './fs'
9
17
  import { transformMarkdown } from './markdown'
10
18
  import { ensureTrailingSlash, getExtension, stripExtension, stripLeadingSlash, stripTrailingSlash } from './path'
11
19
  import { throwPluginError } from './plugin'
@@ -317,7 +325,13 @@ async function checkForNewVersion(config: StarlightVersionsConfig, docsDir: URL)
317
325
  let newVersion: Version | undefined
318
326
 
319
327
  const docsDirEntries = await listDirectory(docsDir)
320
- const docsDirDirectories = new Set(docsDirEntries.filter((entry) => entry.isDirectory()).map((dirent) => dirent.name))
328
+ const docsDirDirectories = new Set<string>()
329
+
330
+ for (const entry of docsDirEntries) {
331
+ if (await isDirectoryEntry(entry)) {
332
+ docsDirDirectories.add(entry.name)
333
+ }
334
+ }
321
335
 
322
336
  for (const version of config.versions) {
323
337
  if (!docsDirDirectories.has(version.slug)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-versions",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to version documentation pages.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",