Skip to content

Commit 7fc320b

Browse files
committed
fix: #157
1 parent f817c4e commit 7fc320b

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

docs/更新日志.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

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

5+
### 1.3.4
6+
7+
`2021-06-27`
8+
9+
- **Fix**
10+
11+
- 🐞 修复 npx create-react-doc doc 初始化生成文档项目报错的问题。[issue](https://github.com/MuYunyun/create-react-doc/issues/157)
12+
513
### 1.3.3
614

715
`2021-06-24`

packages/crd-generator-sitemap/generate.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ const { getDocsConfig } = require('crd-utils')
1010

1111
const docsConfig = getDocsConfig()
1212

13-
const domain = docsConfig.domain
14-
const repo = docsConfig.repo
15-
1613
const template = content =>
1714
`<?xml version="1.0" encoding="UTF-8"?>
1815
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
@@ -24,6 +21,8 @@ const template = content =>
2421
* generate sitemap for google.
2522
*/
2623
const generateSiteMap = (routes) => {
24+
const domain = docsConfig && docsConfig.domain
25+
const repo = docsConfig && docsConfig.repo
2726
let content = ''
2827
for (let i = 0; i < routes.length; i++) {
2928
if (i === routes.length - 1) {

packages/create-react-doc/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ $ react-doc doc // 在当前文件夹下创建名为 doc 的文档站点
1919
$ react-doc start // 启动项目
2020
$ react-doc build // 项目打包
2121
$ react-doc deploy // 手动发布项目
22-
```
22+
```
23+
24+
# 调试
25+
26+
进入该目录, 执行 yarn link, 即可在全局使用 react-doc xxx 命令。

packages/scripts/src/commands/initProject.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path')
22
const { execSync } = require('child_process')
33
const fs = require('fs-extra')
4-
const { templatePath } = require('crd-utils')
4+
const { templatePath, resolveApp } = require('crd-utils')
55
const copyTemplate = require('copy-template-dir')
66
const paths = require('../conf/path')
77

@@ -28,19 +28,24 @@ module.exports = function (params) {
2828
if (!fs.pathExistsSync(defaultTemplatePath)) {
2929
execSync('mkdir temp && cd temp && yarn add crd-templates -D')
3030
}
31-
copyTemplate(defaultTemplatePath, outDir, {
32-
name: projectName,
33-
crdVersion: CRD_VERSION,
34-
}, (err, createdFiles) => {
35-
if (err) return log(`Copy Tamplate Error: ${err} !!!`.red)
36-
createdFiles.sort().forEach((createdFile) => {
37-
log(` ${'create'.green} ${createdFile.replace(paths.projectPath, '')}`)
31+
const templatePathInTemp = resolveApp('temp/node_modules/crd-templates/default')
32+
if (fs.pathExistsSync(templatePathInTemp)) {
33+
copyTemplate(templatePathInTemp, outDir, {
34+
name: projectName,
35+
crdVersion: CRD_VERSION,
36+
}, (err, createdFiles) => {
37+
if (err) return log(`Copy Tamplate Error: ${err} !!!`.red)
38+
createdFiles.sort().forEach((createdFile) => {
39+
log(` ${'create'.green} ${createdFile.replace(paths.projectPath, '')}`)
40+
})
41+
// to hack https://github.com/yoshuawuyts/copy-template-dir/issues/16
42+
execSync(`cp -r ${templatePathInTemp}/.github ${outDir}`)
43+
execSync('rm -rf temp')
44+
log('\n initialization finished!\n'.green)
45+
const cmdstr = `cd ${projectName} && yarn && yarn start`.cyan
46+
log(` Run the ${cmdstr} to start the website.\n\n`)
3847
})
39-
// this is to hack https://github.com/yoshuawuyts/copy-template-dir/issues/16
40-
execSync(`cp -r ${defaultTemplatePath}/.github ${outDir}`)
41-
execSync('rm -rf temp')
42-
log('\n initialization finished!\n'.green)
43-
const cmdstr = `cd ${projectName} && yarn && yarn start`.cyan
44-
log(` Run the ${cmdstr} to start the website.\n\n`)
45-
})
48+
} else {
49+
log(` ❎ crd-templates install fail.\n\n`)
50+
}
4651
}

0 commit comments

Comments
 (0)