forked from web-infra-dev/rspress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a019959
commit a3e7d09
Showing
24 changed files
with
414 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// eslint-disable-next-line import/no-commonjs | ||
module.exports = { | ||
root: true, | ||
extends: ['@modern-js-app'], | ||
ignorePatterns: ['**/template/**'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.json'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.DS_Store | ||
|
||
.pnp | ||
.pnp.js | ||
.env.local | ||
.env.*.local | ||
.history | ||
.rts* | ||
*.log* | ||
*.pid | ||
*.pid.* | ||
*.report | ||
*.lcov | ||
lib-cov | ||
|
||
node_modules/ | ||
.npm | ||
.lock-wscript | ||
.yarn-integrity | ||
.node_repl_history | ||
.nyc_output | ||
*.tsbuildinfo | ||
.eslintcache | ||
.sonarlint | ||
|
||
dist/ | ||
coverage/ | ||
release/ | ||
output/ | ||
output_resource/ | ||
log/ | ||
|
||
.vscode/**/* | ||
!.vscode/settings.json | ||
!.vscode/extensions.json | ||
.idea/ | ||
|
||
**/*/typings/auto-generated | ||
|
||
.changeset/pre.json | ||
|
||
.pnpm-store/ | ||
|
||
modern.config.local.ts | ||
modern.config.local.js | ||
modern.config.local.mjs | ||
|
||
doc_build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.DS_Store | ||
|
||
.pnp | ||
.pnp.js | ||
.env.local | ||
.env.*.local | ||
.history | ||
.rts* | ||
*.log* | ||
*.pid | ||
*.pid.* | ||
*.report | ||
*.lcov | ||
lib-cov | ||
|
||
node_modules/ | ||
.npm | ||
.lock-wscript | ||
.yarn-integrity | ||
.node_repl_history | ||
.nyc_output | ||
*.tsbuildinfo | ||
.eslintcache | ||
.sonarlint | ||
|
||
coverage/ | ||
release/ | ||
output/ | ||
output_resource/ | ||
tests/ | ||
|
||
.vscode/**/* | ||
!.vscode/settings.json | ||
!.vscode/extensions.json | ||
.idea/ | ||
|
||
**/*/api/typings/auto-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
strict-peer-dependencies=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/gallium |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023-present Bytedance, Inc. and its affiliates. | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# create-rspress | ||
|
||
The scaffolding tool to create a new rspress project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { moduleTools, defineConfig } from '@modern-js/module-tools'; | ||
|
||
export default defineConfig({ | ||
plugins: [moduleTools()], | ||
buildConfig: { | ||
target: 'esnext', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "create-rspress", | ||
"version": "0.1.0", | ||
"types": "./dist/index.d.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.js", | ||
"bin": { | ||
"create-rspress": "./dist/index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/web-infra-dev/rspress", | ||
"directory": "packages/create-rspress" | ||
}, | ||
"scripts": { | ||
"dev": "modern build -w", | ||
"build": "modern build", | ||
"build:watch": "modern build -w", | ||
"test": "vitest run", | ||
"reset": "rimraf ./**/node_modules", | ||
"new": "modern new", | ||
"upgrade": "modern upgrade" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "~29.2.4", | ||
"@types/node": "~16.11.7", | ||
"@types/prompts": "^2.4.4", | ||
"@types/react": "~18.0.26", | ||
"@types/fs-extra": "11.0.1", | ||
"rimraf": "~3.0.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "~5.0.4", | ||
"cac": "6.7.14", | ||
"chalk": "5.3.0", | ||
"fs-extra": "11.1.1", | ||
"prompts": "2.4.1" | ||
}, | ||
"sideEffects": [], | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true, | ||
"registry": "https://registry.npmjs.org/" | ||
}, | ||
"files": [ | ||
"dist", | ||
"template" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// eslint-disable-next-line import/no-commonjs | ||
module.exports = { | ||
root: true, | ||
extends: ['@modern-js-app'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['../tsconfig.json'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env node | ||
import path from 'path'; | ||
import { cac } from 'cac'; | ||
import prompts from 'prompts'; | ||
import fs from 'fs-extra'; | ||
import { copyFolder, formatTargetDir, getPkgManager } from './utils'; | ||
|
||
const cli = cac('create-rspress').help(); | ||
|
||
cli.command('', 'Create a new rspress site').action(async () => { | ||
const defaultProjectName = 'rspress-site'; | ||
let targetDir = defaultProjectName; | ||
const promptProjectDir = async () => | ||
await prompts([ | ||
{ | ||
type: 'text', | ||
name: 'projectDir', | ||
initial: defaultProjectName, | ||
message: 'Project folder', | ||
onState: state => { | ||
targetDir = formatTargetDir(state.value) || defaultProjectName; | ||
}, | ||
}, | ||
]); | ||
|
||
await promptProjectDir(); | ||
let root = path.resolve(process.cwd(), targetDir); | ||
while (fs.existsSync(root)) { | ||
console.log( | ||
`${targetDir} is not empty, please choose another project name`, | ||
); | ||
await promptProjectDir(); | ||
root = path.resolve(process.cwd(), targetDir); | ||
} | ||
|
||
await fs.mkdir(root, { recursive: true }); | ||
const srcFolder = path.resolve(__dirname, '../template'); | ||
await copyFolder(srcFolder, targetDir); | ||
const pkgManager = getPkgManager(); | ||
console.log('\nDone. Now run:\n'); | ||
console.log(`cd ${targetDir}\n`); | ||
console.log(`${pkgManager} install\n`); | ||
console.log(`${pkgManager} run dev\n`); | ||
}); | ||
|
||
cli.parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types='@modern-js/module-tools/types' /> | ||
/// <reference types='@modern-js/plugin-testing/types' /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
|
||
export async function copyFolder(src: string, dest: string) { | ||
const renameFiles: Record<string, string> = { | ||
_gitignore: '.gitignore', | ||
}; | ||
|
||
await fs.mkdir(dest, { recursive: true }); | ||
for (const file of await fs.readdir(src)) { | ||
const srcFile = path.resolve(src, file); | ||
const dstFile = renameFiles[file] | ||
? path.resolve(dest, renameFiles[file]) | ||
: path.resolve(dest, file); | ||
const stat = await fs.stat(srcFile); | ||
if (stat.isDirectory()) { | ||
await copyFolder(srcFile, dstFile); | ||
} else { | ||
await fs.copyFile(srcFile, dstFile); | ||
} | ||
} | ||
} | ||
|
||
export function getPkgManager() { | ||
const ua = process.env.npm_config_user_agent; | ||
if (!ua) { | ||
return 'npm'; | ||
} | ||
const [pkgInfo] = ua.split(' '); | ||
const [name] = pkgInfo.split('/'); | ||
return name || 'npm'; | ||
} | ||
|
||
/** | ||
* format the targetDir | ||
*/ | ||
export function formatTargetDir(targetDir: string) { | ||
return targetDir.trim().replace(/\/+$/g, ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
doc_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Guide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "rspress-doc-template", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "rspress dev", | ||
"build": "rspress build", | ||
"preview": "rspress preview" | ||
}, | ||
"dependencies": { | ||
"rspress": "latest" | ||
}, | ||
"devDependencies": { | ||
"@modern-js/tsconfig": "2.30.0", | ||
"@types/jest": "^29", | ||
"@types/node": "^14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as path from 'path'; | ||
import { defineConfig } from 'rspress/config'; | ||
|
||
export default defineConfig({ | ||
root: path.join(__dirname, 'doc'), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"esModuleInterop": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "@modern-js/tsconfig/base", | ||
"declaration": true, | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"target": "ESNext", | ||
"baseUrl": "./", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
}, | ||
"isolatedModules": true | ||
}, | ||
"include": ["src", "./modern.config.ts"], | ||
"exclude": ["**/node_modules", "**/template/**"] | ||
} |
Oops, something went wrong.