cmyr-template-cli 1.7.6 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,40 @@
1
- # cmyr-template-cli
1
+ <h1 align="center">cmyr-template-cli </h1>
2
+ <p>
3
+ <a href="https://www.npmjs.com/package/cmyr-template-cli" target="_blank">
4
+ <img alt="Version" src="https://img.shields.io/npm/v/cmyr-template-cli.svg">
5
+ </a>
6
+ <a href="https://github.com/CaoMeiYouRen/cmyr-template-cli/actions?query=workflow%3ARelease" target="_blank">
7
+ <img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/CaoMeiYouRen/cmyr-template-cli/Release">
8
+ </a>
9
+ <img src="https://img.shields.io/badge/node-%3E%3D12-blue.svg" />
10
+ <a href="https://github.com/CaoMeiYouRen/cmyr-template-cli#readme" target="_blank">
11
+ <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
12
+ </a>
13
+ <a href="https://github.com/CaoMeiYouRen/cmyr-template-cli/graphs/commit-activity" target="_blank">
14
+ <img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
15
+ </a>
16
+ <a href="https://github.com/CaoMeiYouRen/cmyr-template-cli/blob/master/LICENSE" target="_blank">
17
+ <img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
18
+ </a>
19
+ </p>
2
20
 
3
- 草梅友仁自制的项目模板创建器
21
+
22
+ > 草梅友仁自制的项目模板创建器
23
+
24
+ ### 🏠 [主页](https://github.com/CaoMeiYouRen/cmyr-template-cli#readme)
25
+
26
+ [https://github.com/CaoMeiYouRen/cmyr-template-cli#readme](https://github.com/CaoMeiYouRen/cmyr-template-cli#readme)
27
+
28
+
29
+ ### ✨ [Demo](https://github.com/CaoMeiYouRen/cmyr-template-cli#readme)
30
+
31
+ [https://github.com/CaoMeiYouRen/cmyr-template-cli#readme](https://github.com/CaoMeiYouRen/cmyr-template-cli#readme)
32
+
33
+
34
+ ## 依赖要求
35
+
36
+
37
+ - node >=12
4
38
 
5
39
  ## 安装
6
40
 
@@ -11,13 +45,60 @@ npm i -g cmyr-template-cli
11
45
  # 或者 pnpm i -g cmyr-template-cli
12
46
  ```
13
47
 
48
+ ## 使用
14
49
 
50
+ ```sh
51
+ ct
52
+ # 或
53
+ ct create
54
+ ```
15
55
 
56
+ ## 开发
16
57
 
17
- ## 使用
58
+ ```sh
59
+ npm run dev
60
+ ```
18
61
 
62
+ ## 编译
19
63
 
20
- ``` sh
21
- ct create
64
+ ```sh
65
+ npm run build
22
66
  ```
23
67
 
68
+ ## Lint
69
+
70
+ ```sh
71
+ npm run lint
72
+ ```
73
+
74
+ ## Commit
75
+
76
+ ```sh
77
+ npm run commit
78
+ ```
79
+
80
+
81
+ ## 作者
82
+
83
+
84
+ 👤 **CaoMeiYouRen**
85
+
86
+ * Website: [https://blog.cmyr.ltd/](https://blog.cmyr.ltd/)
87
+ * GitHub: [@CaoMeiYouRen](https://github.com/CaoMeiYouRen)
88
+
89
+
90
+ ## 🤝贡献
91
+
92
+ 欢迎 贡献、提问或提出新功能!<br />如有问题请查看 [issues page](https://github.com/CaoMeiYouRen/cmyr-template-cli/issues). <br/>贡献或提出新功能可以查看[contributing guide](https://github.com/CaoMeiYouRen/cmyr-template-cli/blob/master/CONTRIBUTING.md).
93
+
94
+ ## 💰支持
95
+
96
+ 如果觉得这个项目有用的话请给一颗⭐️,非常感谢
97
+
98
+ ## 📝 License
99
+
100
+ Copyright © 2021 [CaoMeiYouRen](https://github.com/CaoMeiYouRen).<br />
101
+ This project is [MIT](https://github.com/CaoMeiYouRen/cmyr-template-cli/blob/master/LICENSE) licensed.
102
+
103
+ ***
104
+ _This README was generated with ❤️ by [cmyr-template-cli](https://github.com/CaoMeiYouRen/cmyr-template-cli)_
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
13
13
 
14
14
  const program = new commander.Command('ct')
15
15
  .description('草梅项目创建器');
16
- program.version("1.7.5" , '-v, --version');
16
+ program.version("1.8.2" , '-v, --version');
17
17
  const args = process.argv.slice(2);
18
18
  if (args.length === 0) {
19
19
  args.push('create');
package/dist/plopfile.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ var lodash = require('lodash');
4
5
  var fs = require('fs-extra');
5
6
  var path = require('path');
6
7
  var ora = require('ora');
@@ -9,7 +10,6 @@ var axios = require('axios');
9
10
  var child_process = require('child_process');
10
11
  var colors = require('colors');
11
12
  var ejs = require('ejs');
12
- var lodash = require('lodash');
13
13
  var core = require('@lint-md/core');
14
14
 
15
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -115,7 +115,7 @@ async function initProject(answers) {
115
115
  }
116
116
  async function init(projectPath, answers) {
117
117
  var _a;
118
- const { isOpenSource, isRemoveDependabot, gitRemoteUrl, isInitReadme, isInitContributing, isInitHusky, isInitSemanticRelease } = answers;
118
+ const { isOpenSource, gitRemoteUrl, isInitReadme, isInitContributing, isInitHusky, isInitSemanticRelease } = answers;
119
119
  try {
120
120
  await asyncExec('git --version', {
121
121
  cwd: projectPath,
@@ -132,16 +132,8 @@ async function init(projectPath, answers) {
132
132
  });
133
133
  console.info(colors__default["default"].green(`请在远程 Git 仓库初始化 ${gitRemoteUrl}`));
134
134
  }
135
- const dependabotPath = path__default["default"].join(projectPath, '.github/dependabot.yml');
136
- const mergifyPath = path__default["default"].join(projectPath, '.github/mergify.yml');
137
- if (!isOpenSource || isRemoveDependabot) {
138
- if (await fs__default["default"].pathExists(dependabotPath)) {
139
- await fs__default["default"].remove(dependabotPath);
140
- }
141
- if (await fs__default["default"].pathExists(mergifyPath)) {
142
- await fs__default["default"].remove(mergifyPath);
143
- }
144
- }
135
+ await initDependabot(projectPath, answers);
136
+ await initYarn(projectPath, answers);
145
137
  const newPkg = await initProjectJson(projectPath, answers);
146
138
  if (isInitSemanticRelease) {
147
139
  await initSemanticRelease(projectPath);
@@ -158,9 +150,7 @@ async function init(projectPath, answers) {
158
150
  if (isInitContributing) {
159
151
  await initContributing(projectPath, info);
160
152
  }
161
- if (info.licenseName === 'MIT') {
162
- await initLicense(projectPath, info);
163
- }
153
+ await initLicense(projectPath, info);
164
154
  }
165
155
  await initGithubWorkflows(projectPath, answers);
166
156
  }
@@ -204,6 +194,38 @@ async function getGitUserName() {
204
194
  const username = (await asyncExec('git config user.name')) || '';
205
195
  return username.trim();
206
196
  }
197
+ async function initDependabot(projectPath, answers) {
198
+ try {
199
+ const { isOpenSource, isRemoveDependabot } = answers;
200
+ const dependabotPath = path__default["default"].join(projectPath, '.github/dependabot.yml');
201
+ const mergifyPath = path__default["default"].join(projectPath, '.github/mergify.yml');
202
+ if (!isOpenSource || isRemoveDependabot) {
203
+ if (await fs__default["default"].pathExists(dependabotPath)) {
204
+ await fs__default["default"].remove(dependabotPath);
205
+ }
206
+ if (await fs__default["default"].pathExists(mergifyPath)) {
207
+ await fs__default["default"].remove(mergifyPath);
208
+ }
209
+ }
210
+ }
211
+ catch (error) {
212
+ console.error(error);
213
+ }
214
+ }
215
+ async function initYarn(projectPath, answers) {
216
+ try {
217
+ const { isRemoveYarn } = answers;
218
+ const yarnPath = path__default["default"].join(projectPath, 'yarn.lock');
219
+ if (isRemoveYarn) {
220
+ if (await fs__default["default"].pathExists(yarnPath)) {
221
+ await fs__default["default"].remove(yarnPath);
222
+ }
223
+ }
224
+ }
225
+ catch (error) {
226
+ console.error(error);
227
+ }
228
+ }
207
229
  async function initProjectJson(projectPath, answers) {
208
230
  const loading = ora__default["default"]('正在初始化 package.json ……').start();
209
231
  try {
@@ -247,6 +269,11 @@ async function initProjectJson(projectPath, answers) {
247
269
  },
248
270
  };
249
271
  }
272
+ if (isPublishToNpm) {
273
+ extData.publishConfig = {
274
+ access: 'public',
275
+ };
276
+ }
250
277
  const newPkg = Object.assign({}, pkg, pkgData, extData);
251
278
  await saveProjectJson(projectPath, newPkg);
252
279
  loading.succeed('package.json 初始化成功!');
@@ -303,6 +330,7 @@ async function getProjectInfo(projectPath, answers) {
303
330
  authorName: author,
304
331
  authorGithubUsername: githubUsername,
305
332
  engines,
333
+ license,
306
334
  licenseName: cleanText(license),
307
335
  licenseUrl,
308
336
  documentationUrl,
@@ -386,7 +414,14 @@ async function initContributing(projectPath, projectInfos) {
386
414
  async function initLicense(projectPath, projectInfos) {
387
415
  const loading = ora__default["default"]('正在初始化 LICENSE ……').start();
388
416
  try {
389
- const templatePath = path__default["default"].join(__dirname, '../templates/LICENSE');
417
+ let templatePath = '';
418
+ if (projectInfos.licenseName === 'MIT') {
419
+ templatePath = path__default["default"].join(__dirname, '../templates/licenses/MIT');
420
+ }
421
+ if (!templatePath) {
422
+ loading.fail('无效的 LICENSE Name');
423
+ return;
424
+ }
390
425
  const template = (await fs__default["default"].readFile(templatePath, 'utf8')).toString();
391
426
  const newReadmePath = path__default["default"].join(projectPath, 'LICENSE');
392
427
  const readmeContent = await ejs__default["default"].render(template, projectInfos, {
@@ -669,7 +704,7 @@ module.exports = function (plop) {
669
704
  return input.trim().length !== 0;
670
705
  },
671
706
  default: '',
672
- filter: (e) => e.trim(),
707
+ filter: (e) => lodash.kebabCase(e.trim()),
673
708
  },
674
709
  {
675
710
  type: 'input',
@@ -809,6 +844,15 @@ module.exports = function (plop) {
809
844
  return answers.isOpenSource;
810
845
  },
811
846
  },
847
+ {
848
+ type: 'confirm',
849
+ name: 'isRemoveYarn',
850
+ message: '是否移除 yarn ?',
851
+ default: false,
852
+ when(answers) {
853
+ return answers.isOpenSource;
854
+ },
855
+ },
812
856
  {
813
857
  type: 'confirm',
814
858
  name: 'isEnableAfdian',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmyr-template-cli",
3
- "version": "1.7.6",
3
+ "version": "1.9.0",
4
4
  "description": "草梅友仁自制的项目模板创建器",
5
5
  "author": "CaoMeiYouRen",
6
6
  "license": "MIT",
@@ -49,7 +49,7 @@
49
49
  "@typescript-eslint/parser": "^4.9.0",
50
50
  "commitizen": "^4.2.2",
51
51
  "conventional-changelog-cli": "^2.1.1",
52
- "conventional-changelog-cmyr-config": "^1.2.3",
52
+ "conventional-changelog-cmyr-config": "^2.0.2",
53
53
  "cross-env": "^7.0.2",
54
54
  "cz-conventional-changelog": "^3.3.0",
55
55
  "cz-conventional-changelog-cmyr": "^1.0.0",
@@ -13,7 +13,7 @@ jobs:
13
13
  uses: actions/setup-node@v2
14
14
  with:
15
15
  node-version: "lts/*"
16
- cache: "yarn"
16
+ # cache: "yarn"
17
17
  - name: Cache multiple paths
18
18
  uses: actions/cache@v2
19
19
  with:
@@ -24,9 +24,9 @@ jobs:
24
24
  **/node_modules
25
25
  key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
26
26
  - run: yarn
27
- - run: npm run lint
28
- - run: npm run build
27
+ - run: yarn run lint
28
+ - run: yarn run build
29
29
  - env:
30
30
  GH_TOKEN: ${{ secrets.GH_TOKEN }}
31
31
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32
- run: npm run release
32
+ run: yarn run release
@@ -10,7 +10,7 @@ jobs:
10
10
  uses: actions/setup-node@v2
11
11
  with:
12
12
  node-version: "lts/*"
13
- cache: "yarn"
13
+ # cache: "yarn"
14
14
  - name: Cache multiple paths
15
15
  uses: actions/cache@v2
16
16
  with:
@@ -21,5 +21,5 @@ jobs:
21
21
  **/node_modules
22
22
  key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
23
23
  - run: yarn
24
- - run: npm run lint
25
- - run: npm run build
24
+ - run: yarn run lint
25
+ - run: yarn run build
@@ -2,6 +2,12 @@
2
2
 
3
3
  在为此存储库做出贡献时,请首先通过 issue、电子邮件或任何其他方法与此存储库的所有者讨论您希望进行的更改,然后再进行更改。
4
4
 
5
+ **注意**:
6
+
7
+ - 提问之前请三思,不要浪费我们的时间
8
+ - 不要问那些你自己就能搞清楚的问题
9
+ - 不要问在文档中提过的问题
10
+
5
11
  ## 开发环境设置
6
12
 
7
13
  要设置开发环境,请按照以下步骤操作:
@@ -29,7 +35,7 @@
29
35
 
30
36
  ## 问题和功能请求
31
37
 
32
- 你在源代码中发现了一个错误,文档中有一个错误,或者你想要一个新功能? 看看[GitHub 讨论](<%= discussionsUrl %>)看看它是否已经在讨论中。您可以通过[在 GitHub 上提交问题](<%= issuesUrl %>)来帮助我们。在创建问题之前,请确保搜索问题存档 - 您的问题可能已经得到解决!
38
+ 你在源代码中发现了一个错误,文档中有一个错误,或者你想要一个新功能? 看看[GitHub 讨论](<%= discussionsUrl %>)看看它是否已经在讨论中。您可以通过[在 GitHub 上提交问题](<%= issuesUrl %>)来帮助我们。在创建问题之前,请确保搜索[问题存档](<%= issuesUrl %>?q=is%3Aissue+is%3Aclosed) - 您的问题可能已经得到解决!
33
39
 
34
40
  请尝试创建以下错误报告:
35
41
 
@@ -68,6 +74,7 @@
68
74
 
69
75
  - 若为 BUG 修复,则选择 `fix`
70
76
  - 若为新增功能,则选择 `feat`
77
+ - 若为性能优化,则选择 `perf`
71
78
  - 若为移除某些功能,则选择 `BREAKING CHANGE`
72
79
  - `BREAKING CHANGE` 和其他破坏性更新,若不是为了修复 BUG,原则上将拒绝该 PR
73
80
 
@@ -75,3 +82,6 @@
75
82
  5. 推送到分支 ( `git push origin feat/your_feature`)
76
83
 
77
84
  6. [打开一个新的 Pull Request](<%= repositoryUrl %>/compare?expand=1)
85
+
86
+ ***
87
+ _This CONTRIBUTING was generated with ❤️ by [cmyr-template-cli](https://github.com/CaoMeiYouRen/cmyr-template-cli)_
File without changes