@lexibase/rdx-next 1.0.0-beta.6 → 1.0.0-beta.7
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/README.md +7 -0
- package/bin/public-assets.mjs +58 -0
- package/bin/rdx.mjs +3 -0
- package/package.json +3 -3
- package/templates/runtime/tsconfig.json +1 -1
package/README.md
CHANGED
|
@@ -17,3 +17,10 @@ explicitly configured plugins enable the shared navbar dropdown.
|
|
|
17
17
|
|
|
18
18
|
`.rdx/` is generated. Configure the site or edit a project-owned `home.tsx`
|
|
19
19
|
instead of modifying files inside `.rdx/`.
|
|
20
|
+
|
|
21
|
+
Place images, favicon and downloads in the project-root `public/` directory.
|
|
22
|
+
The CLI links `.rdx/public` to it using a junction on Windows or a directory
|
|
23
|
+
symlink elsewhere. `/images/logo.svg` serves `public/images/logo.svg` in dev and
|
|
24
|
+
production. No asset copies are cached and original files are never removed.
|
|
25
|
+
Restart/redeploy production after adding/removing assets. Documentation versions
|
|
26
|
+
share this directory; snapshots do not copy its contents.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { lstat, mkdir, realpath, symlink, unlink } from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import process from 'node:process'
|
|
4
|
+
|
|
5
|
+
async function inspect(filePath) {
|
|
6
|
+
try {
|
|
7
|
+
return await lstat(filePath)
|
|
8
|
+
} catch (error) {
|
|
9
|
+
if (error.code === 'ENOENT') return null
|
|
10
|
+
throw error
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Link generated Next public/ to project-owned assets; never copy or delete them. */
|
|
15
|
+
export async function preparePublicAssets(projectRoot, runtimeDirectory) {
|
|
16
|
+
const runtime = await inspect(runtimeDirectory)
|
|
17
|
+
if (!runtime?.isDirectory() || runtime.isSymbolicLink())
|
|
18
|
+
throw new Error(
|
|
19
|
+
'.rdx/ must be a real directory, not a symbolic link or junction.'
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const publicDirectory = path.join(projectRoot, 'public')
|
|
23
|
+
const existing = await inspect(publicDirectory)
|
|
24
|
+
if (existing && (!existing.isDirectory() || existing.isSymbolicLink()))
|
|
25
|
+
throw new Error('public/ must be a real directory in the project root.')
|
|
26
|
+
await mkdir(publicDirectory, { recursive: true })
|
|
27
|
+
|
|
28
|
+
const destination = path.join(runtimeDirectory, 'public')
|
|
29
|
+
const link = await inspect(destination)
|
|
30
|
+
if (link) {
|
|
31
|
+
if (!link.isSymbolicLink())
|
|
32
|
+
throw new Error(
|
|
33
|
+
'Cannot prepare .rdx/public: a file or directory already exists there. Move any assets to the project public/ directory, then remove the conflicting .rdx/public entry and retry. RDX has not removed it.'
|
|
34
|
+
)
|
|
35
|
+
let target
|
|
36
|
+
try {
|
|
37
|
+
target = await realpath(destination)
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error.code !== 'ENOENT') throw error
|
|
40
|
+
}
|
|
41
|
+
if (target === (await realpath(publicDirectory))) return
|
|
42
|
+
// Only unlink the internal pointer, never its old target or the user's files.
|
|
43
|
+
await unlink(destination)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const target = process.platform === 'win32' ? publicDirectory : '../public'
|
|
47
|
+
try {
|
|
48
|
+
await symlink(
|
|
49
|
+
target,
|
|
50
|
+
destination,
|
|
51
|
+
process.platform === 'win32' ? 'junction' : 'dir'
|
|
52
|
+
)
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`Could not link .rdx/public to public/: ${error.message}. Use a filesystem that supports directory links (junctions on Windows); your public files have not been removed.`
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
}
|
package/bin/rdx.mjs
CHANGED
|
@@ -10,6 +10,8 @@ import process from 'node:process'
|
|
|
10
10
|
import { createRdxProject } from '@lexibase/rdx-core/config'
|
|
11
11
|
import { createJiti } from 'jiti'
|
|
12
12
|
|
|
13
|
+
import { preparePublicAssets } from './public-assets.mjs'
|
|
14
|
+
|
|
13
15
|
const supportedCommands = new Set(['dev', 'build', 'start'])
|
|
14
16
|
const command = process.argv[2]
|
|
15
17
|
const commandArgs = process.argv.slice(3)
|
|
@@ -23,6 +25,7 @@ const runtimeDirectory = path.join(projectRoot, '.rdx')
|
|
|
23
25
|
|
|
24
26
|
async function prepareRuntime() {
|
|
25
27
|
await mkdir(runtimeDirectory, { recursive: true })
|
|
28
|
+
await preparePublicAssets(projectRoot, runtimeDirectory)
|
|
26
29
|
await cp(runtimeTemplate, runtimeDirectory, { force: true, recursive: true })
|
|
27
30
|
}
|
|
28
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexibase/rdx-next",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.7",
|
|
4
4
|
"description": "The Next.js runtime for RDX documentation projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"react": "19.1.0",
|
|
61
61
|
"react-dom": "19.1.0",
|
|
62
62
|
"typescript": "5.9.2",
|
|
63
|
-
"@rdx/
|
|
64
|
-
"@rdx/
|
|
63
|
+
"@rdx/eslint-config": "1.0.0",
|
|
64
|
+
"@rdx/typescript-config": "1.0.0"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "tsup src/index.ts src/runtime/index.tsx --format esm --dts --clean --external @lexibase/rdx-core --external @lexibase/rdx-types --external next --external react --external react-dom --external next-mdx-remote",
|