cmyr-template-cli 1.7.3 → 1.7.4
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 +1 -1
- package/dist/plopfile.js +20 -18
- package/package.json +1 -1
- package/templates/.releaserc.js +5 -3
- package/templates/CONTRIBUTING.md +2 -2
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.
|
|
16
|
+
program.version("1.7.3" , '-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
|
@@ -213,8 +213,7 @@ async function initProjectJson(projectPath, answers) {
|
|
|
213
213
|
const gitUrl = `git+${repositoryUrl}.git`;
|
|
214
214
|
const nodeVersion = await getLtsNodeVersion() || '16';
|
|
215
215
|
const node = Number(nodeVersion) - 4;
|
|
216
|
-
const
|
|
217
|
-
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
216
|
+
const pkg = await getProjectJson(projectPath);
|
|
218
217
|
const pkgData = {
|
|
219
218
|
name,
|
|
220
219
|
author,
|
|
@@ -248,7 +247,7 @@ async function initProjectJson(projectPath, answers) {
|
|
|
248
247
|
};
|
|
249
248
|
}
|
|
250
249
|
const newPkg = Object.assign({}, pkg, pkgData, extData);
|
|
251
|
-
await
|
|
250
|
+
await saveProjectJson(projectPath, newPkg);
|
|
252
251
|
loading.succeed('package.json 初始化成功!');
|
|
253
252
|
return newPkg;
|
|
254
253
|
}
|
|
@@ -264,8 +263,7 @@ async function getProjectInfo(projectPath, answers) {
|
|
|
264
263
|
try {
|
|
265
264
|
const { name, author, description, isOpenSource, isPublishToNpm } = answers;
|
|
266
265
|
const packageManager = 'npm';
|
|
267
|
-
const
|
|
268
|
-
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
266
|
+
const pkg = await getProjectJson(projectPath);
|
|
269
267
|
const engines = (pkg === null || pkg === void 0 ? void 0 : pkg.engines) || {};
|
|
270
268
|
const license = pkg === null || pkg === void 0 ? void 0 : pkg.license;
|
|
271
269
|
const version = pkg === null || pkg === void 0 ? void 0 : pkg.version;
|
|
@@ -471,12 +469,10 @@ async function initSemanticRelease(projectPath) {
|
|
|
471
469
|
}
|
|
472
470
|
await fs__default["default"].copyFile(templatePath, newPath);
|
|
473
471
|
});
|
|
474
|
-
const
|
|
475
|
-
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
472
|
+
const pkg = await getProjectJson(projectPath);
|
|
476
473
|
const devDependencies = {
|
|
477
474
|
'@semantic-release/changelog': '^6.0.1',
|
|
478
475
|
'@semantic-release/git': '^10.0.1',
|
|
479
|
-
'conventional-changelog-cli': '^2.1.1',
|
|
480
476
|
'semantic-release': '^18.0.1',
|
|
481
477
|
};
|
|
482
478
|
const pkgData = {
|
|
@@ -490,8 +486,7 @@ async function initSemanticRelease(projectPath) {
|
|
|
490
486
|
'conventional-changelog-cmyr-config': `^${await getNpmPackageVersion('conventional-changelog-cmyr-config')}`,
|
|
491
487
|
},
|
|
492
488
|
};
|
|
493
|
-
|
|
494
|
-
await fs__default["default"].writeFile(pkgPath, JSON.stringify(newPkg, null, 2));
|
|
489
|
+
await saveProjectJson(projectPath, pkgData);
|
|
495
490
|
loading.succeed('semantic-release 初始化成功!');
|
|
496
491
|
}
|
|
497
492
|
catch (error) {
|
|
@@ -517,8 +512,7 @@ async function initHusky(projectPath) {
|
|
|
517
512
|
await fs__default["default"].copyFile(templatePath, newPath);
|
|
518
513
|
});
|
|
519
514
|
const extnames = ['js', 'ts'];
|
|
520
|
-
const
|
|
521
|
-
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
515
|
+
const pkg = await getProjectJson(projectPath);
|
|
522
516
|
if ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.dependencies) === null || _a === void 0 ? void 0 : _a.vue) {
|
|
523
517
|
extnames.push('vue');
|
|
524
518
|
}
|
|
@@ -557,8 +551,7 @@ async function initHusky(projectPath) {
|
|
|
557
551
|
],
|
|
558
552
|
},
|
|
559
553
|
};
|
|
560
|
-
|
|
561
|
-
await fs__default["default"].writeFile(pkgPath, JSON.stringify(newPkg, null, 2));
|
|
554
|
+
await saveProjectJson(projectPath, pkgData);
|
|
562
555
|
loading.succeed('husky 初始化成功!');
|
|
563
556
|
}
|
|
564
557
|
catch (error) {
|
|
@@ -568,14 +561,12 @@ async function initHusky(projectPath) {
|
|
|
568
561
|
}
|
|
569
562
|
async function sortProjectJson(projectPath) {
|
|
570
563
|
try {
|
|
571
|
-
const
|
|
572
|
-
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
564
|
+
const pkg = await getProjectJson(projectPath);
|
|
573
565
|
const pkgData = {
|
|
574
566
|
dependencies: sortKey((pkg === null || pkg === void 0 ? void 0 : pkg.dependencies) || {}),
|
|
575
567
|
devDependencies: sortKey((pkg === null || pkg === void 0 ? void 0 : pkg.devDependencies) || {}),
|
|
576
568
|
};
|
|
577
|
-
|
|
578
|
-
await fs__default["default"].writeFile(pkgPath, JSON.stringify(newPkg, null, 2));
|
|
569
|
+
await saveProjectJson(projectPath, pkgData);
|
|
579
570
|
}
|
|
580
571
|
catch (error) {
|
|
581
572
|
console.error(error);
|
|
@@ -627,6 +618,17 @@ function sortKey(obj) {
|
|
|
627
618
|
});
|
|
628
619
|
return obj2;
|
|
629
620
|
}
|
|
621
|
+
async function getProjectJson(projectPath) {
|
|
622
|
+
const pkgPath = path__default["default"].join(projectPath, 'package.json');
|
|
623
|
+
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
624
|
+
return pkg;
|
|
625
|
+
}
|
|
626
|
+
async function saveProjectJson(projectPath, pkgData) {
|
|
627
|
+
const pkgPath = path__default["default"].join(projectPath, 'package.json');
|
|
628
|
+
const pkg = await getProjectJson(projectPath);
|
|
629
|
+
const newPkg = Object.assign({}, pkg, pkgData);
|
|
630
|
+
await fs__default["default"].writeFile(pkgPath, JSON.stringify(newPkg, null, 2));
|
|
631
|
+
}
|
|
630
632
|
|
|
631
633
|
module.exports = function (plop) {
|
|
632
634
|
plop.setActionType('initProject', initProject);
|
package/package.json
CHANGED
package/templates/.releaserc.js
CHANGED
|
@@ -7,10 +7,12 @@ module.exports = {
|
|
|
7
7
|
"config": "conventional-changelog-cmyr-config"
|
|
8
8
|
}
|
|
9
9
|
],
|
|
10
|
-
[
|
|
10
|
+
[
|
|
11
|
+
"@semantic-release/release-notes-generator",
|
|
11
12
|
{
|
|
12
13
|
"config": "conventional-changelog-cmyr-config"
|
|
13
|
-
}
|
|
14
|
+
}
|
|
15
|
+
],
|
|
14
16
|
[
|
|
15
17
|
"@semantic-release/changelog",
|
|
16
18
|
{
|
|
@@ -31,4 +33,4 @@ module.exports = {
|
|
|
31
33
|
}
|
|
32
34
|
]
|
|
33
35
|
]
|
|
34
|
-
}
|
|
36
|
+
}
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
|
|
69
69
|
- 若为 BUG 修复,则选择 `fix`
|
|
70
70
|
- 若为新增功能,则选择 `feat`
|
|
71
|
-
- 若为移除某些功能,则选择 `
|
|
72
|
-
- `
|
|
71
|
+
- 若为移除某些功能,则选择 `BREAKING CHANGE`
|
|
72
|
+
- `BREAKING CHANGE` 和其他破坏性更新,若不是为了修复 BUG,原则上将拒绝该 PR
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
5. 推送到分支 ( `git push origin feat/your_feature`)
|