Skip to content

Commit

Permalink
fix: #157
Browse files Browse the repository at this point in the history
  • Loading branch information
MuYunyun committed Jun 27, 2021
1 parent f817c4e commit ea7c6c4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
8 changes: 8 additions & 0 deletions docs/更新日志.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

`create-react-doc` 严格遵循 [Semantic Versioning 2.0.0](http://semver.org/lang/zh-CN/) 语义化版本规范。

### 1.3.4

`2021-06-27`

- **Fix**

- 🐞 修复 npx create-react-doc doc 初始化生成文档项目报错的问题。[issue](https://github.com/MuYunyun/create-react-doc/issues/157)

### 1.3.3

`2021-06-24`
Expand Down
5 changes: 2 additions & 3 deletions packages/crd-generator-sitemap/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ const { getDocsConfig } = require('crd-utils')

const docsConfig = getDocsConfig()

const domain = docsConfig.domain
const repo = docsConfig.repo

const template = content =>
`<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
Expand All @@ -24,6 +21,8 @@ const template = content =>
* generate sitemap for google.
*/
const generateSiteMap = (routes) => {
const domain = docsConfig && docsConfig.domain
const repo = docsConfig && docsConfig.repo
let content = ''
for (let i = 0; i < routes.length; i++) {
if (i === routes.length - 1) {
Expand Down
6 changes: 5 additions & 1 deletion packages/create-react-doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ $ react-doc doc // 在当前文件夹下创建名为 doc 的文档站点
$ react-doc start // 启动项目
$ react-doc build // 项目打包
$ react-doc deploy // 手动发布项目
```
```

# 调试

进入该目录, 执行 yarn link, 即可在全局使用 react-doc xxx 命令。
35 changes: 20 additions & 15 deletions packages/scripts/src/commands/initProject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')
const { execSync } = require('child_process')
const fs = require('fs-extra')
const { templatePath } = require('crd-utils')
const { templatePath, resolveApp } = require('crd-utils')
const copyTemplate = require('copy-template-dir')
const paths = require('../conf/path')

Expand All @@ -28,19 +28,24 @@ module.exports = function (params) {
if (!fs.pathExistsSync(defaultTemplatePath)) {
execSync('mkdir temp && cd temp && yarn add crd-templates -D')
}
copyTemplate(defaultTemplatePath, outDir, {
name: projectName,
crdVersion: CRD_VERSION,
}, (err, createdFiles) => {
if (err) return log(`Copy Tamplate Error: ${err} !!!`.red)
createdFiles.sort().forEach((createdFile) => {
log(` ${'create'.green} ${createdFile.replace(paths.projectPath, '')}`)
const templatePathInTemp = resolveApp('temp/node_modules/crd-templates/default')
if (fs.pathExistsSync(templatePathInTemp)) {
copyTemplate(templatePathInTemp, outDir, {
name: projectName,
crdVersion: CRD_VERSION,
}, (err, createdFiles) => {
if (err) return log(`Copy Tamplate Error: ${err} !!!`.red)
createdFiles.sort().forEach((createdFile) => {
log(` ${'create'.green} ${createdFile.replace(paths.projectPath, '')}`)
})
// to hack https://github.com/yoshuawuyts/copy-template-dir/issues/16
execSync(`cp -r ${templatePathInTemp}/.github ${outDir}`)
execSync('rm -rf temp')
log('\n initialization finished!\n'.green)
const cmdstr = `cd ${projectName} && yarn && yarn start`.cyan
log(` Run the ${cmdstr} to start the website.\n\n`)
})
// this is to hack https://github.com/yoshuawuyts/copy-template-dir/issues/16
execSync(`cp -r ${defaultTemplatePath}/.github ${outDir}`)
execSync('rm -rf temp')
log('\n initialization finished!\n'.green)
const cmdstr = `cd ${projectName} && yarn && yarn start`.cyan
log(` Run the ${cmdstr} to start the website.\n\n`)
})
} else {
log(` ❎ crd-templates install fail.\n\n`)
}
}

0 comments on commit ea7c6c4

Please sign in to comment.