Skip to content

Commit a1d383e

Browse files
author
kaiyu.kong
committed
init
0 parents  commit a1d383e

File tree

135 files changed

+21264
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+21264
-0
lines changed

.dumirc.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { defineConfig } from 'dumi';
2+
3+
const logo =
4+
'https://imagev2.xmcdn.com/storages/f8d2-audiofreehighqps/81/43/GMCoOSYIO18uAAAvaAIdYbXD.png';
5+
6+
const publicPath =
7+
process.env.NODE_ENV === 'production' ? `/cli/create-project/` : '/';
8+
9+
export default defineConfig({
10+
themeConfig: {
11+
name: 'create-project',
12+
logo,
13+
},
14+
history: {
15+
type: 'hash',
16+
},
17+
hash: true,
18+
favicons: [logo],
19+
publicPath,
20+
alias: {
21+
images: '/docs/images',
22+
},
23+
resolve: {
24+
docDirs: ['docs'],
25+
},
26+
});

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
.dumi/tmp
14+
.dumi/tmp-production
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

.gitlab-ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pages:
2+
stage: deploy
3+
script:
4+
- pwd
5+
- ls
6+
# 因为,服务器端的 nodejs 版本较低 & fsevents 不兼容 linux(仅仅是 macos 需要而已)
7+
# ☞ 设置略过环境检查,保证 gitlab ci 顺利执行
8+
- yarn config set ignore-engines true
9+
- yarn
10+
- yarn build
11+
- rm -rf public/*
12+
- mkdir .public
13+
- cp -r dist/* .public
14+
- mv .public public
15+
artifacts:
16+
paths:
17+
- public
18+
only:
19+
- master

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/*.svg
2+
**/*.ejs
3+
**/*.html
4+
package.json
5+
docs
6+
.dumi/tmp
7+
.dumi/tmp-production
8+
*.yaml

.prettierrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 80,
5+
"overrides": [
6+
{
7+
"files": ".prettierrc",
8+
"options": { "parser": "json" }
9+
},
10+
{
11+
"files": "*.md",
12+
"options": {
13+
"proseWrap": "preserve"
14+
}
15+
}
16+
]
17+
}

.yarnrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"@xmly:registry" "http://xnpm.ximalaya.com/"
2+
"@xmc:registry" "http://xnpm.ximalaya.com/"

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Getting Started
2+
3+
```bash
4+
npx -p @xmly/create-project create-project
5+
```
6+
7+
## 下载自定义模版
8+
9+
```bash
10+
npx -p @xmly/create-project create-project download [模板名称]
11+
```
12+
13+
## 将项目转换为模版
14+
15+
先进入项目目录,再执行以下命令:
16+
17+
```bash
18+
npx -p @xmly/create-project create-project transform [模板名]
19+
20+
```
21+
22+
模版存放目录(可选):
23+
24+
```bash
25+
npx -p @xmly/create-project create-project transform [模板名] <模版存放目录>
26+
```
27+
28+
[文档](http://react-library.pages.xmly.work/cli/create-project)

docs/download.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: 下载模版
3+
order: 1
4+
toc: content
5+
nav:
6+
title: 下载模版
7+
order: 2
8+
---
9+
10+
# 下载模版
11+
12+
百分百还原 template 内容,0 改写,极大的降低了心智负担,规避了 create-react-app 下载模版的痛点
13+
14+
下载模版:
15+
16+
```bash
17+
npx -p @xmly/create-project create-project download [模板名称]
18+
```
19+
20+
`or`
21+
22+
支持输入项目名称:
23+
24+
```bash
25+
npx -p @xmly/create-project create-project download [模板名称] [项目名称]
26+
```
27+
28+
支持下载模版后替换内容:
29+
30+
```bash
31+
npx -p @xmly/create-project create-project download [模板名称] -r [旧内容] [新内容]
32+
```
33+
34+
## 要求的模版目录文件
35+
36+
下载的 template 模版内容必须存在以下目录和文件
37+
38+
<Tree>
39+
<ul>
40+
<li>
41+
template
42+
<small>模板的文件目录</small>
43+
<ul>
44+
<li>gitignore <small>注意:gitignore文件没有句号</small></li>
45+
<li> ... <small>其他文件</small></li>
46+
</ul>
47+
</li>
48+
<li>package.json</li>
49+
<li>README.md <small>可选</small></li>
50+
<li>template.json</li>
51+
</ul>
52+
</Tree>
53+
54+
## 使用 create-react-app (CRA)下载 cra-template 模板
55+
56+
```bash
57+
yarn create react-app [项目名称] --template [模版名称]
58+
```
59+
60+
:::warning{title=问题}
61+
使用 create-react-app (CRA)下载 cra-template 模板时,会改写 `tsconfig.json` 中的配置,导致不符合预期,例如:
62+
63+
会删除 `tsconfig.json` 中的路径别名配置
64+
:::
65+
66+
:::warning{title=下载缓慢}
67+
下载模版时,同时会安装模版中的所有依赖,导致等待时间较长。安装完成后,才能看到项目的完整目录
68+
:::

docs/guide/apm.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: 配置云效参数
3+
order: 7
4+
toc: content
5+
group:
6+
title: 基础
7+
order: 3
8+
nav:
9+
title: 指南
10+
order: 1
11+
---
12+
13+
# 配置云效参数
14+
15+
云效发布时,需要配置 `Sentry``apm`
16+
17+
## 配置 Sentry
18+
19+
```ts | pure
20+
import * as Sentry from '@sentry/react';
21+
import { name as projectName, version } from '../package.json';
22+
const { MODE } = import.meta.env;
23+
24+
// Sentry Project ☞ Client Keys DSN
25+
// https://websentry.ximalaya.com/settings/xmly/projects/
26+
// 一般在创建云效应用时,会看到自动创建 Sentry Project,可以看到 Client Keys DSN(否则,从上方链接去查找,若未创建可手动创建)
27+
const CLIENT_KEY = '';
28+
29+
/**
30+
* Sentry
31+
* - test/production 均上报,方便提早发现问题。
32+
* - Sentry React: https://docs.sentry.io/platforms/javascript/guides/react/
33+
*/
34+
Sentry.init({
35+
dsn: CLIENT_KEY, // Client Keys DSN
36+
environment: MODE, // 区分上报环境
37+
sampleRate: 0.1,
38+
release: `${projectName}@${version}`,
39+
});
40+
```
41+
42+
## 配置 apm
43+
44+
```ts | pure
45+
import { apm } from '@xmly/xmrep';
46+
import { name as projectName } from '../package.json';
47+
48+
// Sentry Project ☞ Client Keys DSN
49+
// https://websentry.ximalaya.com/settings/xmly/projects/
50+
// 一般在创建云效应用时,会看到自动创建 Sentry Project,可以看到 Client Keys DSN(否则,从上方链接去查找,若未创建可手动创建)
51+
const CLIENT_KEY = '';
52+
53+
/**
54+
* APM 性能监控
55+
* - https://thoughts.ximalaya.com/workspaces/5d679697f30f8700018aa32f/docs/5eddded3f4c0000001da3558
56+
*/
57+
apm.init({
58+
name: projectName, // 云效项目名(通常应当与项目名称相同,如不一致,需修改)
59+
});
60+
```

0 commit comments

Comments
 (0)