Skip to content

Commit 61a936b

Browse files
committed
feat: plop new code and docs template
1 parent 7e6184d commit 61a936b

File tree

15 files changed

+150
-29
lines changed

15 files changed

+150
-29
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1.0.0 (2020-02-29)
1+
# 1.0.0 (2020-03-02)
22

33

44
### Bug Fixes
@@ -42,6 +42,7 @@
4242
* math -> binary ([7158a67](https://github.com/Rain120/awesome-javascript-code-implementation/commit/7158a672269f54928a8ee549a279790adaf650cc))
4343
* math gcm; update vuepress doc ([066bf3c](https://github.com/Rain120/awesome-javascript-code-implementation/commit/066bf3cafa0766879354ebefa0005d1c629eaa5f))
4444
* math pow; fix: ci.yml ([89be97b](https://github.com/Rain120/awesome-javascript-code-implementation/commit/89be97bdd3d4be266212d72dca45732e70e7a41a))
45+
* navbar add hot repo; auto deploy to gitpages and netlify; update write docs ([7e6184d](https://github.com/Rain120/awesome-javascript-code-implementation/commit/7e6184d892c3070c6dd5d63c39ac048bdb7658ec))
4546
* new ([e1b1495](https://github.com/Rain120/awesome-javascript-code-implementation/commit/e1b1495c204bb8936a45356eaa8b7266020ba055))
4647
* object.is ([437d64a](https://github.com/Rain120/awesome-javascript-code-implementation/commit/437d64a8f5fb0ad357cadc41b11d68286aa81b3e))
4748
* observer pattern ([77c78f7](https://github.com/Rain120/awesome-javascript-code-implementation/commit/77c78f7359161c0e64b3143e3a66fea3f5d4eb46))
@@ -53,10 +54,10 @@
5354
* update netlify status ([013b5ca](https://github.com/Rain120/awesome-javascript-code-implementation/commit/013b5ca5847873adabbff93a89daa41500ccf153))
5455
* update readme for plans ([b427b96](https://github.com/Rain120/awesome-javascript-code-implementation/commit/b427b9667cc97c77df75ef0af56eb84b6b4c3ba6))
5556
* update test.yml -> ci.yml and set command ([43b96b6](https://github.com/Rain120/awesome-javascript-code-implementation/commit/43b96b63fc2788a5ea37fa7567c6a6dced4b875f))
56-
* update xmind ([71317c6](https://github.com/Rain120/awesome-javascript-code-implementation/commit/71317c67376bc8196f80e25391adfdc9b2496380))
5757
* update xmind ([4256758](https://github.com/Rain120/awesome-javascript-code-implementation/commit/4256758c5fe0a036ce3ececc43f848e48964d7a0))
58-
* update xmind ([cb23933](https://github.com/Rain120/awesome-javascript-code-implementation/commit/cb23933f46152c59a7b08f84d7355b35bba25002))
5958
* update xmind ([408ca68](https://github.com/Rain120/awesome-javascript-code-implementation/commit/408ca685142dc425e90be64a284016d57d580893))
59+
* update xmind ([71317c6](https://github.com/Rain120/awesome-javascript-code-implementation/commit/71317c67376bc8196f80e25391adfdc9b2496380))
60+
* update xmind ([cb23933](https://github.com/Rain120/awesome-javascript-code-implementation/commit/cb23933f46152c59a7b08f84d7355b35bba25002))
6061
* update: plans; fix: readme bug ([d44e559](https://github.com/Rain120/awesome-javascript-code-implementation/commit/d44e559def7834fcccbb19797a1d29bf5cc4e5b7))
6162
* vuepress docs v1.0.0 ([785caeb](https://github.com/Rain120/awesome-javascript-code-implementation/commit/785caeb41beeff7a0f53646fc952d1c89ebb61d5))
6263
* zh-cn and plans ([62b460f](https://github.com/Rain120/awesome-javascript-code-implementation/commit/62b460f200a2f76ee36cd3cae94d1660ed4ff3c2))

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ Document Link:
4848

4949
⌨️
5050

51+
生成 `code` 模板
52+
```sh
53+
npm run template
54+
```
55+
56+
生成 `docs` 模板
57+
58+
```sh
59+
npm run docs
60+
```
61+
5162
[how-to-write-docs](docs/zh/how-to-write-docs/README.md)
5263

5364
#### 🤝 Contributing

docs/.vuepress/config.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,14 @@ module.exports = {
5050
// chainWebpack:(config,isServer) =>{
5151
// config.resolve.alias.set('@images',path.resolve(__dirname, '../../'))
5252
// },
53-
locales: {
54-
'/': {
55-
lang: 'zh-CN',
56-
}
57-
},
53+
// locales: {
54+
// '/zh': {
55+
// lang: 'zh-CN',
56+
// },
57+
// '/en': {
58+
// lang: 'en-US',
59+
// }
60+
// },
5861
// markdown
5962
markdown: {
6063
lineNumbers: true,

docs/zh/guide/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ Document Link:
4848

4949
⌨️
5050

51+
生成 `code` 模板
52+
```sh
53+
npm run template
54+
```
55+
56+
生成 `docs` 模板
57+
58+
```sh
59+
npm run docs
60+
```
61+
5162
[how-to-write-docs](docs/zh/how-to-write-docs/README.md)
5263

5364
## 🤝 Contributing

docs/zh/how-to-write-docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
:::
1414

1515
```sh
16+
npm run docs
17+
18+
# or
19+
1620
touch docs/zh/test/README.md
1721
```
1822

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = {
3030
coveragePathIgnorePatterns: [
3131
"<rootDir>/node_modules/",
3232
"<rootDir>/docs/",
33+
"<rootDir>/plop-templates/",
3334
],
3435

3536
// A list of reporter names that Jest uses when writing coverage reports

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"lint-staged": "lint-staged",
1818
"lint-staged:ts": "tslint -c ./tslint.json src/**/**.ts",
1919
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
20+
"plop": "./node_modules/.bin/plop",
21+
"template": "npm run plop template",
22+
"docs": "npm run plop docs",
2023
"docs:dev": "vuepress dev docs",
2124
"docs:build": "vuepress build docs",
2225
"deploy": "bash deploy.sh"
@@ -63,6 +66,7 @@
6366
"markdown-it-katex": "^2.0.3",
6467
"markdown-it-task-lists": "^2.1.1",
6568
"moment": "^2.24.0",
69+
"plop": "^2.5.4",
6670
"ts-jest": "^24.1.0",
6771
"ts-node": "^8.5.0",
6872
"tslint": "^5.20.1",

plop-templates/code/README.md.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### 原理
2+
3+
### 参考

plop-templates/code/__tests__.ts.hbs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* @Author: Rainy
3+
* @Date: 2020-02-06 19:05:18
4+
* @LastEditors: Rainy
5+
* @LastEditTime: 2020-03-01 21:08:17
6+
*/
7+
8+
import { {{name}} } from '.';
9+
10+
test('{{name}} instanceof {{name}} should false', () => {
11+
expect({{name}}()).toBe(undefined);
12+
});

plop-templates/code/index.ts.hbs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* @Author: Rainy
3+
* @Date: 2019-11-14 19:25:01
4+
* @LastEditors: Rainy
5+
* @LastEditTime: 2020-03-01 21:08:22
6+
*/
7+
8+
export function {{name}}(params?: any): any {}

plop-templates/docs/zh/README.md.hbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## 原理
2+
3+
## 实现代码
4+
5+
## 参考
6+

plopfile.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* @Author: Rainy
3+
* @Date: 2020-03-01 19:29:27
4+
* @LastEditors: Rainy
5+
* @LastEditTime: 2020-03-01 21:01:15
6+
*/
7+
8+
module.exports = plop => {
9+
plop.setGenerator('template', {
10+
description: 'Create root template',
11+
prompts: [
12+
{
13+
type: 'input',
14+
name: 'name',
15+
message: 'please input the template name: ',
16+
default: 'template'
17+
},
18+
{
19+
type: 'confirm',
20+
name: 'needTest',
21+
message: 'Do you want test file ? '
22+
},
23+
{
24+
type: 'input',
25+
name: 'path',
26+
message: 'generator path (etc: src/template) ?',
27+
default: 'src'
28+
}
29+
],
30+
actions: answer => {
31+
let actions = [
32+
{
33+
type: 'add',
34+
path: '{{path}}/{{name}}/index.ts',
35+
templateFile: 'plop-templates/code/index.ts.hbs'
36+
},
37+
{
38+
type: 'add',
39+
path: '{{path}}/{{name}}/README.md',
40+
templateFile: 'plop-templates/code/README.md.hbs'
41+
}
42+
];
43+
if (answer.needTest) {
44+
actions.push({
45+
type: 'add',
46+
path: '{{path}}/{{name}}/__tests__.ts',
47+
templateFile: 'plop-templates/code/__tests__.ts.hbs'
48+
});
49+
}
50+
return actions;
51+
}
52+
});
53+
plop.setGenerator('docs', {
54+
description: 'Create root zh docs',
55+
prompts: [
56+
{
57+
type: 'input',
58+
name: 'name',
59+
message: 'please input the docs model name: ',
60+
default: 'model'
61+
},
62+
{
63+
type: 'input',
64+
name: 'path',
65+
message: 'generator model path (etc: docs/zh/model) ?',
66+
default: 'docs/zh'
67+
}
68+
],
69+
actions: answer => {
70+
return [
71+
{
72+
type: 'add',
73+
path: '{{path}}/{{name}}/README.md',
74+
templateFile: 'plop-templates/docs/zh/README.md.hbs'
75+
}];
76+
}
77+
});
78+
};

src/model/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/model/__test__.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/model/index.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)