@lexibase/create-rdx 0.0.0-stage → 1.0.0-beta.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.
- package/LICENSE +8 -0
- package/bin/index.js +128 -0
- package/package.json +31 -3
- package/templates/default/README.md +12 -0
- package/templates/default/docs/examples/_category.json +4 -0
- package/templates/default/docs/examples/colors.mdx +7 -0
- package/templates/default/docs/examples/markdown.mdx +15 -0
- package/templates/default/docs/init/_category.json +4 -0
- package/templates/default/docs/init/getting-started.mdx +17 -0
- package/templates/default/docs/init/intro.mdx +10 -0
- package/templates/default/gitignore.template +4 -0
- package/templates/default/package.json +25 -0
- package/templates/default/rdx.config.ts +11 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright © 2025 Lexibase
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'node:child_process'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
|
|
7
|
+
import fs from 'fs-extra'
|
|
8
|
+
import prompts from 'prompts'
|
|
9
|
+
|
|
10
|
+
const projectNamePattern = /^[a-z0-9][a-z0-9._-]*$/i
|
|
11
|
+
const argumentsFromCli = process.argv.slice(2)
|
|
12
|
+
const skipInstall = argumentsFromCli.includes('--skip-install')
|
|
13
|
+
const nameFromCli = argumentsFromCli.find(
|
|
14
|
+
(argument) => !argument.startsWith('-')
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
function getPackageManager() {
|
|
18
|
+
const userAgent = process.env.npm_config_user_agent || ''
|
|
19
|
+
|
|
20
|
+
if (userAgent.startsWith('pnpm')) return 'pnpm'
|
|
21
|
+
if (userAgent.startsWith('yarn')) return 'yarn'
|
|
22
|
+
|
|
23
|
+
return 'npm'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function validateProjectName(projectName) {
|
|
27
|
+
if (!projectName) return 'Please enter a project name.'
|
|
28
|
+
if (!projectNamePattern.test(projectName)) {
|
|
29
|
+
return 'Use letters, numbers, dots, dashes, or underscores only.'
|
|
30
|
+
}
|
|
31
|
+
if (projectName === '.' || projectName === '..') {
|
|
32
|
+
return 'Choose a name other than . or ...'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function run(command, args, cwd) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
// Reuse the package manager's Node entry point, including on Windows,
|
|
41
|
+
// where a .cmd shim cannot be launched directly with spawn().
|
|
42
|
+
const packageManagerEntry = process.env.npm_execpath
|
|
43
|
+
const useNodeEntry =
|
|
44
|
+
command === getPackageManager() &&
|
|
45
|
+
packageManagerEntry &&
|
|
46
|
+
/\.[cm]?js$/i.test(packageManagerEntry)
|
|
47
|
+
const executable = useNodeEntry ? process.execPath : command
|
|
48
|
+
const commandArgs = useNodeEntry ? [packageManagerEntry, ...args] : args
|
|
49
|
+
const child = spawn(executable, commandArgs, {
|
|
50
|
+
cwd,
|
|
51
|
+
stdio: 'inherit',
|
|
52
|
+
shell: !useNodeEntry && process.platform === 'win32',
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
child.on('error', reject)
|
|
56
|
+
child.on('exit', (code) => {
|
|
57
|
+
if (code === 0) resolve()
|
|
58
|
+
else reject(new Error(`${command} ${args.join(' ')} exited with ${code}`))
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const response = nameFromCli
|
|
64
|
+
? { projectName: nameFromCli }
|
|
65
|
+
: await prompts({
|
|
66
|
+
type: 'text',
|
|
67
|
+
name: 'projectName',
|
|
68
|
+
message: 'What is your project named?',
|
|
69
|
+
validate: validateProjectName,
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const { projectName } = response
|
|
73
|
+
if (!projectName) {
|
|
74
|
+
console.log('Project creation cancelled.')
|
|
75
|
+
process.exit(0)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const targetDir = path.resolve(process.cwd(), projectName)
|
|
79
|
+
const relativeTarget = path.relative(process.cwd(), targetDir)
|
|
80
|
+
|
|
81
|
+
if (relativeTarget.startsWith('..') || path.isAbsolute(relativeTarget)) {
|
|
82
|
+
throw new Error('Project must be created inside the current directory.')
|
|
83
|
+
}
|
|
84
|
+
if (await fs.pathExists(targetDir)) {
|
|
85
|
+
throw new Error(`The directory "${projectName}" already exists.`)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const currentFile = fileURLToPath(import.meta.url)
|
|
89
|
+
const templateDir = path.resolve(
|
|
90
|
+
path.dirname(currentFile),
|
|
91
|
+
'../templates/default'
|
|
92
|
+
)
|
|
93
|
+
await fs.copy(templateDir, targetDir, { errorOnExist: true })
|
|
94
|
+
|
|
95
|
+
const gitignoreTemplatePath = path.join(targetDir, 'gitignore.template')
|
|
96
|
+
await fs.move(gitignoreTemplatePath, path.join(targetDir, '.gitignore'), {
|
|
97
|
+
overwrite: true,
|
|
98
|
+
})
|
|
99
|
+
await fs.remove(path.join(targetDir, 'gitignore'))
|
|
100
|
+
await fs.remove(path.join(targetDir, '.npmignore'))
|
|
101
|
+
|
|
102
|
+
const pkgPath = path.join(targetDir, 'package.json')
|
|
103
|
+
const pkg = await fs.readJson(pkgPath)
|
|
104
|
+
pkg.name = projectName
|
|
105
|
+
await fs.writeJson(pkgPath, pkg, { spaces: 2 })
|
|
106
|
+
|
|
107
|
+
const readmePath = path.join(targetDir, 'README.md')
|
|
108
|
+
const readme = await fs.readFile(readmePath, 'utf8')
|
|
109
|
+
await fs.writeFile(
|
|
110
|
+
readmePath,
|
|
111
|
+
readme.replaceAll('__RDX_PROJECT_NAME__', projectName)
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
const packageManager = getPackageManager()
|
|
115
|
+
|
|
116
|
+
if (!skipInstall) {
|
|
117
|
+
console.log(`\nInstalling dependencies with ${packageManager}...\n`)
|
|
118
|
+
await run(packageManager, ['install'], targetDir)
|
|
119
|
+
const prepareArgs =
|
|
120
|
+
packageManager === 'npm'
|
|
121
|
+
? ['exec', '--', 'rdx', 'prepare']
|
|
122
|
+
: ['exec', 'rdx', 'prepare']
|
|
123
|
+
await run(packageManager, prepareArgs, targetDir)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
console.log(`\nRDX project "${projectName}" created successfully.\n`)
|
|
127
|
+
console.log(` cd ${projectName}`)
|
|
128
|
+
console.log(` ${packageManager} dev\n`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexibase/create-rdx",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "Create a new RDX documentation project.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-rdx": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"templates",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18.18"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/lexibase/rdx.git",
|
|
24
|
+
"directory": "packages/create-rdx"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/lexibase/rdx/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/lexibase/rdx#readme",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"fs-extra": "^11.1.1",
|
|
32
|
+
"prompts": "^2.4.2"
|
|
33
|
+
}
|
|
6
34
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown
|
|
3
|
+
description: A small Markdown and MDX example.
|
|
4
|
+
link_position: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Markdown works
|
|
8
|
+
|
|
9
|
+
- Organize content with lists
|
|
10
|
+
- Add [links](https://mdxjs.com/)
|
|
11
|
+
- Use **strong text** and `inline code`
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
const framework = 'RDX'
|
|
15
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Getting started
|
|
3
|
+
description: Learn how to add pages and categories to your site.
|
|
4
|
+
link_position: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Create a page
|
|
8
|
+
|
|
9
|
+
Add an `.mdx` file inside a folder in `docs/`. Its path becomes the page URL.
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
docs/
|
|
13
|
+
└── guides/
|
|
14
|
+
└── deployment.mdx
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This file is available at `/docs/guides/deployment`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: Start building your documentation with RDX.
|
|
4
|
+
link_position: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Welcome to your documentation
|
|
8
|
+
|
|
9
|
+
RDX turns folders and `.mdx` files into a documentation site. Start by editing
|
|
10
|
+
this page or adding new pages inside `docs/`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__RDX_PROJECT_NAME__",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "rdx dev",
|
|
8
|
+
"build": "rdx build",
|
|
9
|
+
"start": "rdx start"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@lexibase/rdx-next": "^1.0.0-beta.0",
|
|
13
|
+
"next": "^15.5.0",
|
|
14
|
+
"react": "19.1.0",
|
|
15
|
+
"react-dom": "19.1.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.15.3",
|
|
19
|
+
"@types/react": "19.1.0",
|
|
20
|
+
"typescript": "5.9.2"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.18"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/README.md
DELETED