cmyr-template-cli 1.7.4 → 1.8.1

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/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.3" , '-v, --version');
16
+ program.version("1.8.0" , '-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
@@ -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);
@@ -165,6 +157,7 @@ async function init(projectPath, answers) {
165
157
  await initGithubWorkflows(projectPath, answers);
166
158
  }
167
159
  await initConfig(projectPath);
160
+ await initCommitizen(projectPath);
168
161
  await sortProjectJson(projectPath);
169
162
  await asyncExec('git add .', {
170
163
  cwd: projectPath,
@@ -203,6 +196,38 @@ async function getGitUserName() {
203
196
  const username = (await asyncExec('git config user.name')) || '';
204
197
  return username.trim();
205
198
  }
199
+ async function initDependabot(projectPath, answers) {
200
+ try {
201
+ const { isOpenSource, isRemoveDependabot } = answers;
202
+ const dependabotPath = path__default["default"].join(projectPath, '.github/dependabot.yml');
203
+ const mergifyPath = path__default["default"].join(projectPath, '.github/mergify.yml');
204
+ if (!isOpenSource || isRemoveDependabot) {
205
+ if (await fs__default["default"].pathExists(dependabotPath)) {
206
+ await fs__default["default"].remove(dependabotPath);
207
+ }
208
+ if (await fs__default["default"].pathExists(mergifyPath)) {
209
+ await fs__default["default"].remove(mergifyPath);
210
+ }
211
+ }
212
+ }
213
+ catch (error) {
214
+ console.error(error);
215
+ }
216
+ }
217
+ async function initYarn(projectPath, answers) {
218
+ try {
219
+ const { isRemoveYarn } = answers;
220
+ const yarnPath = path__default["default"].join(projectPath, 'yarn.lock');
221
+ if (isRemoveYarn) {
222
+ if (await fs__default["default"].pathExists(yarnPath)) {
223
+ await fs__default["default"].remove(yarnPath);
224
+ }
225
+ }
226
+ }
227
+ catch (error) {
228
+ console.error(error);
229
+ }
230
+ }
206
231
  async function initProjectJson(projectPath, answers) {
207
232
  const loading = ora__default["default"]('正在初始化 package.json ……').start();
208
233
  try {
@@ -523,14 +548,11 @@ async function initHusky(projectPath) {
523
548
  const devDependencies = {
524
549
  '@commitlint/cli': '^15.0.0',
525
550
  '@commitlint/config-conventional': '^15.0.0',
526
- commitizen: '^4.2.3',
527
- 'cz-conventional-changelog': '^3.3.0',
528
551
  husky: '^7.0.4',
529
552
  'lint-staged': '^12.1.2',
530
553
  };
531
554
  const pkgData = {
532
555
  scripts: {
533
- commit: 'cz',
534
556
  ...pkg === null || pkg === void 0 ? void 0 : pkg.scripts,
535
557
  prepare: 'husky install',
536
558
  },
@@ -539,11 +561,6 @@ async function initHusky(projectPath) {
539
561
  ...pkg === null || pkg === void 0 ? void 0 : pkg.devDependencies,
540
562
  },
541
563
  husky: undefined,
542
- config: {
543
- commitizen: {
544
- path: 'cz-conventional-changelog',
545
- },
546
- },
547
564
  'lint-staged': {
548
565
  [keyname]: [
549
566
  'npm run lint',
@@ -559,6 +576,38 @@ async function initHusky(projectPath) {
559
576
  console.error(error);
560
577
  }
561
578
  }
579
+ async function initCommitizen(projectPath) {
580
+ const loading = ora__default["default"]('正在初始化 commitizen ……').start();
581
+ try {
582
+ const pkg = await getProjectJson(projectPath);
583
+ const devDependencies = {
584
+ commitizen: '^4.2.3',
585
+ 'cz-conventional-changelog-cmyr': `^${await getNpmPackageVersion('cz-conventional-changelog-cmyr')}`,
586
+ };
587
+ const pkgData = {
588
+ scripts: {
589
+ ...pkg === null || pkg === void 0 ? void 0 : pkg.scripts,
590
+ commit: 'cz',
591
+ },
592
+ devDependencies: {
593
+ ...devDependencies,
594
+ ...pkg === null || pkg === void 0 ? void 0 : pkg.devDependencies,
595
+ },
596
+ config: {
597
+ ...pkg === null || pkg === void 0 ? void 0 : pkg.config,
598
+ commitizen: {
599
+ path: './node_modules/cz-conventional-changelog-cmyr',
600
+ },
601
+ },
602
+ };
603
+ await saveProjectJson(projectPath, pkgData);
604
+ loading.succeed('commitizen 初始化成功!');
605
+ }
606
+ catch (error) {
607
+ console.error(error);
608
+ loading.fail('commitizen 初始化失败!');
609
+ }
610
+ }
562
611
  async function sortProjectJson(projectPath) {
563
612
  try {
564
613
  const pkg = await getProjectJson(projectPath);
@@ -784,6 +833,15 @@ module.exports = function (plop) {
784
833
  return answers.isOpenSource;
785
834
  },
786
835
  },
836
+ {
837
+ type: 'confirm',
838
+ name: 'isRemoveYarn',
839
+ message: '是否移除 yarn ?',
840
+ default: false,
841
+ when(answers) {
842
+ return answers.isOpenSource;
843
+ },
844
+ },
787
845
  {
788
846
  type: 'confirm',
789
847
  name: 'isEnableAfdian',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmyr-template-cli",
3
- "version": "1.7.4",
3
+ "version": "1.8.1",
4
4
  "description": "草梅友仁自制的项目模板创建器",
5
5
  "author": "CaoMeiYouRen",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "rm": "rimraf node_modules",
27
27
  "start": "node ./dist/index",
28
28
  "release": "semantic-release",
29
- "commit": "git add . && git cz",
29
+ "commit": "cz",
30
30
  "create": "ct create",
31
31
  "build:dev": "rimraf dist && cross-env NODE_ENV=development rollup -c && rimraf temp && cross-env NODE_ENV=development ct create",
32
32
  "build:prod": "npm run build && rimraf temp && cross-env NODE_ENV=production ct create"
@@ -49,9 +49,10 @@
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
+ "cz-conventional-changelog-cmyr": "^1.0.0",
55
56
  "debug": "^4.3.1",
56
57
  "eslint": "^7.14.0",
57
58
  "eslint-config-cmyr": "^1.1.14",
@@ -83,7 +84,7 @@
83
84
  },
84
85
  "config": {
85
86
  "commitizen": {
86
- "path": "cz-conventional-changelog"
87
+ "path": "./node_modules/cz-conventional-changelog-cmyr"
87
88
  }
88
89
  },
89
90
  "changelog": {
@@ -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
@@ -68,6 +68,7 @@
68
68
 
69
69
  - 若为 BUG 修复,则选择 `fix`
70
70
  - 若为新增功能,则选择 `feat`
71
+ - 若为性能优化,则选择 `perf`
71
72
  - 若为移除某些功能,则选择 `BREAKING CHANGE`
72
73
  - `BREAKING CHANGE` 和其他破坏性更新,若不是为了修复 BUG,原则上将拒绝该 PR
73
74
 
@@ -75,3 +76,6 @@
75
76
  5. 推送到分支 ( `git push origin feat/your_feature`)
76
77
 
77
78
  6. [打开一个新的 Pull Request](<%= repositoryUrl %>/compare?expand=1)
79
+
80
+ ***
81
+ _This CONTRIBUTING was generated with ❤️ by [cmyr-template-cli](https://github.com/CaoMeiYouRen/cmyr-template-cli)_