starlight-versions 0.5.1 → 0.5.3
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 +12 -0
- package/libs/fs.ts +13 -1
- package/libs/starlight.ts +1 -0
- package/libs/versions.ts +16 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# starlight-versions
|
|
2
2
|
|
|
3
|
+
## 0.5.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#29](https://github.com/HiDeoo/starlight-versions/pull/29) [`3cc3e30`](https://github.com/HiDeoo/starlight-versions/commit/3cc3e30d6b778c7615cee9c2fcb01f6225b6cb84) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue with versioned sidebars including a link to the homepage.
|
|
8
|
+
|
|
9
|
+
## 0.5.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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.
|
|
14
|
+
|
|
3
15
|
## 0.5.1
|
|
4
16
|
|
|
5
17
|
### 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/starlight.ts
CHANGED
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 {
|
|
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(
|
|
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)) {
|