cmyr-template-cli 1.4.0 → 1.5.2
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/plopfile.js +259 -28
- package/package.json +8 -4
- package/templates/README.md +144 -0
package/dist/plopfile.js
CHANGED
|
@@ -7,23 +7,48 @@ var ora = require('ora');
|
|
|
7
7
|
var download = require('download-git-repo');
|
|
8
8
|
var axios = require('axios');
|
|
9
9
|
var child_process = require('child_process');
|
|
10
|
-
var
|
|
10
|
+
var colors = require('colors');
|
|
11
|
+
var ejs = require('ejs');
|
|
12
|
+
var lodash = require('lodash');
|
|
13
|
+
var core = require('@lint-md/core');
|
|
11
14
|
|
|
12
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
16
|
|
|
17
|
+
function _interopNamespace(e) {
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
n["default"] = e;
|
|
32
|
+
return Object.freeze(n);
|
|
33
|
+
}
|
|
34
|
+
|
|
14
35
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
15
36
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
16
37
|
var ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
|
|
17
38
|
var download__default = /*#__PURE__*/_interopDefaultLegacy(download);
|
|
18
39
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
19
|
-
var
|
|
40
|
+
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
41
|
+
var ejs__default = /*#__PURE__*/_interopDefaultLegacy(ejs);
|
|
20
42
|
|
|
21
43
|
process.env;
|
|
22
44
|
const PACKAGE_MANAGER = 'pnpm';
|
|
23
45
|
|
|
24
46
|
if (!Promise.any) {
|
|
25
|
-
Promise.any
|
|
47
|
+
Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('promise.any')); }).then((any) => {
|
|
48
|
+
Promise.any = any.default;
|
|
49
|
+
});
|
|
26
50
|
}
|
|
51
|
+
const GITHUB_API_URL = 'https://api.github.com';
|
|
27
52
|
const REMOTES = [
|
|
28
53
|
'https://github.com',
|
|
29
54
|
'https://hub.fastgit.org',
|
|
@@ -32,14 +57,15 @@ const REMOTES = [
|
|
|
32
57
|
];
|
|
33
58
|
async function downloadGitRepo(repository, destination, options = {}) {
|
|
34
59
|
const fastRepo = await getFastGitRepo(repository);
|
|
35
|
-
const loading = ora__default["default"](
|
|
60
|
+
const loading = ora__default["default"](`正在下载模板 - ${repository}`);
|
|
36
61
|
loading.start();
|
|
37
|
-
return new Promise((resolve
|
|
62
|
+
return new Promise((resolve) => {
|
|
38
63
|
download__default["default"](fastRepo, destination, options, (err) => {
|
|
39
|
-
loading.stop();
|
|
40
64
|
if (err) {
|
|
41
|
-
|
|
65
|
+
loading.fail('下载模板失败!');
|
|
66
|
+
process.exit(1);
|
|
42
67
|
}
|
|
68
|
+
loading.succeed(`成功下载模板 - ${repository}`);
|
|
43
69
|
resolve(true);
|
|
44
70
|
});
|
|
45
71
|
});
|
|
@@ -56,15 +82,14 @@ async function getFastGitRepo(repository) {
|
|
|
56
82
|
timeout: 15 * 1000,
|
|
57
83
|
});
|
|
58
84
|
}));
|
|
85
|
+
loading.succeed(`成功选择了镜像源 - ${fast.config.url}`);
|
|
59
86
|
return `direct:${fast.config.url}`;
|
|
60
87
|
}
|
|
61
88
|
catch (error) {
|
|
62
89
|
console.error(error);
|
|
90
|
+
loading.fail('选择镜像源失败!');
|
|
63
91
|
process.exit(1);
|
|
64
92
|
}
|
|
65
|
-
finally {
|
|
66
|
-
loading.stop();
|
|
67
|
-
}
|
|
68
93
|
}
|
|
69
94
|
async function asyncExec(cmd, options) {
|
|
70
95
|
return new Promise((resolve, reject) => {
|
|
@@ -80,8 +105,7 @@ async function asyncExec(cmd, options) {
|
|
|
80
105
|
});
|
|
81
106
|
}
|
|
82
107
|
async function init(projectPath, answers) {
|
|
83
|
-
const
|
|
84
|
-
const { name, author, isOpenSource, isRemoveDependabot } = answers;
|
|
108
|
+
const { isOpenSource, isRemoveDependabot, gitRemoteUrl } = answers;
|
|
85
109
|
try {
|
|
86
110
|
await asyncExec('git --version', {
|
|
87
111
|
cwd: projectPath,
|
|
@@ -92,6 +116,12 @@ async function init(projectPath, answers) {
|
|
|
92
116
|
await asyncExec('git init', {
|
|
93
117
|
cwd: projectPath,
|
|
94
118
|
});
|
|
119
|
+
if (gitRemoteUrl) {
|
|
120
|
+
await asyncExec(`git remote add origin ${gitRemoteUrl}`, {
|
|
121
|
+
cwd: projectPath,
|
|
122
|
+
});
|
|
123
|
+
console.info(colors__default["default"].green(`请在远程 Git 仓库初始化 ${gitRemoteUrl}`));
|
|
124
|
+
}
|
|
95
125
|
const dependabotPath = path__default["default"].join(projectPath, '.github/dependabot.yml');
|
|
96
126
|
const mergifyPath = path__default["default"].join(projectPath, '.github/mergify.yml');
|
|
97
127
|
if (!isOpenSource || isRemoveDependabot) {
|
|
@@ -102,25 +132,26 @@ async function init(projectPath, answers) {
|
|
|
102
132
|
await fs__default["default"].remove(mergifyPath);
|
|
103
133
|
}
|
|
104
134
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
author,
|
|
110
|
-
private: !isOpenSource,
|
|
111
|
-
};
|
|
112
|
-
const newPkg = Object.assign({}, pkg, pkgData);
|
|
113
|
-
await fs__default["default"].writeFile(pkgPath, JSON.stringify(newPkg, null, 2));
|
|
135
|
+
await initProjectJson(projectPath, answers);
|
|
136
|
+
if (isOpenSource) {
|
|
137
|
+
await initReadme(projectPath, answers);
|
|
138
|
+
}
|
|
114
139
|
await asyncExec('git add .', {
|
|
115
140
|
cwd: projectPath,
|
|
116
141
|
});
|
|
117
142
|
await asyncExec('git commit -m "chore: init"', {
|
|
118
143
|
cwd: projectPath,
|
|
119
144
|
});
|
|
120
|
-
loading.start();
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
145
|
+
const loading = ora__default["default"]('正在安装依赖……').start();
|
|
146
|
+
try {
|
|
147
|
+
await asyncExec(`${PACKAGE_MANAGER} i`, {
|
|
148
|
+
cwd: projectPath,
|
|
149
|
+
});
|
|
150
|
+
loading.succeed('依赖安装成功!');
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
loading.fail('依赖安装失败!');
|
|
154
|
+
}
|
|
124
155
|
await asyncExec('git add .', {
|
|
125
156
|
cwd: projectPath,
|
|
126
157
|
});
|
|
@@ -128,14 +159,164 @@ async function init(projectPath, answers) {
|
|
|
128
159
|
catch (error) {
|
|
129
160
|
console.error(error);
|
|
130
161
|
}
|
|
131
|
-
finally {
|
|
132
|
-
loading.stop();
|
|
133
|
-
}
|
|
134
162
|
}
|
|
135
163
|
async function getGitUserName() {
|
|
136
164
|
const username = (await asyncExec('git config user.name'));
|
|
137
165
|
return username.trim();
|
|
138
166
|
}
|
|
167
|
+
async function initProjectJson(projectPath, answers) {
|
|
168
|
+
const loading = ora__default["default"]('正在初始化 package.json ……').start();
|
|
169
|
+
try {
|
|
170
|
+
const { name, author, description, isOpenSource, isPublishToNpm = false } = answers;
|
|
171
|
+
const repositoryUrl = `https://github.com/${author}/${name}`;
|
|
172
|
+
const homepage = `${repositoryUrl}#readme`;
|
|
173
|
+
const issuesUrl = `${repositoryUrl}/issues`;
|
|
174
|
+
const gitUrl = `git+${repositoryUrl}.git`;
|
|
175
|
+
const pkgPath = path__default["default"].join(projectPath, 'package.json');
|
|
176
|
+
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
177
|
+
const pkgData = {
|
|
178
|
+
name,
|
|
179
|
+
author,
|
|
180
|
+
description,
|
|
181
|
+
private: !isPublishToNpm,
|
|
182
|
+
license: 'UNLICENSED',
|
|
183
|
+
engines: {
|
|
184
|
+
node: '>=12',
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
let extData = {};
|
|
188
|
+
if (isOpenSource) {
|
|
189
|
+
extData = {
|
|
190
|
+
license: 'MIT',
|
|
191
|
+
homepage,
|
|
192
|
+
repository: {
|
|
193
|
+
type: 'git',
|
|
194
|
+
url: gitUrl,
|
|
195
|
+
},
|
|
196
|
+
bugs: {
|
|
197
|
+
url: issuesUrl,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const newPkg = Object.assign({}, pkg, pkgData, extData);
|
|
202
|
+
await fs__default["default"].writeFile(pkgPath, JSON.stringify(newPkg, null, 2));
|
|
203
|
+
loading.succeed('package.json 初始化成功!');
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
console.error(error);
|
|
207
|
+
loading.fail('package.json 初始化失败!');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const cleanText = (text) => text.replace(/-/g, '--').replace(/_/g, '__');
|
|
211
|
+
async function initReadme(projectPath, answers) {
|
|
212
|
+
var _a, _b, _c, _d, _e;
|
|
213
|
+
const loading = ora__default["default"]('正在初始化 README.md ……').start();
|
|
214
|
+
try {
|
|
215
|
+
const { name, author, description, isOpenSource, isPublishToNpm } = answers;
|
|
216
|
+
const packageManager = 'npm';
|
|
217
|
+
const templatePath = path__default["default"].join(__dirname, '../templates/README.md');
|
|
218
|
+
const template = (await fs__default["default"].readFile(templatePath, 'utf8')).toString();
|
|
219
|
+
const newReadmePath = path__default["default"].join(projectPath, 'README.md');
|
|
220
|
+
const pkgPath = path__default["default"].join(projectPath, 'package.json');
|
|
221
|
+
const pkg = await fs__default["default"].readJSON(pkgPath);
|
|
222
|
+
const engines = (pkg === null || pkg === void 0 ? void 0 : pkg.engines) || {};
|
|
223
|
+
const license = pkg === null || pkg === void 0 ? void 0 : pkg.license;
|
|
224
|
+
const version = pkg === null || pkg === void 0 ? void 0 : pkg.version;
|
|
225
|
+
const installCommand = isPublishToNpm ? `${packageManager} install ${name}` : `${packageManager} install`;
|
|
226
|
+
const startCommand = ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.scripts) === null || _a === void 0 ? void 0 : _a.start) && `${packageManager} run start`;
|
|
227
|
+
const devCommand = ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.scripts) === null || _b === void 0 ? void 0 : _b.dev) && `${packageManager} run dev`;
|
|
228
|
+
const buildCommand = ((_c = pkg === null || pkg === void 0 ? void 0 : pkg.scripts) === null || _c === void 0 ? void 0 : _c.build) && `${packageManager} run build`;
|
|
229
|
+
const testCommand = ((_d = pkg === null || pkg === void 0 ? void 0 : pkg.scripts) === null || _d === void 0 ? void 0 : _d.test) && `${packageManager} run test`;
|
|
230
|
+
const lintCommand = ((_e = pkg === null || pkg === void 0 ? void 0 : pkg.scripts) === null || _e === void 0 ? void 0 : _e.lint) && `${packageManager} run lint`;
|
|
231
|
+
const repositoryUrl = `https://github.com/${author}/${name}`;
|
|
232
|
+
const issuesUrl = `${repositoryUrl}/issues`;
|
|
233
|
+
const contributingUrl = `${repositoryUrl}/blob/master/CONTRIBUTING.md`;
|
|
234
|
+
const documentationUrl = `${repositoryUrl}#readme`;
|
|
235
|
+
const demoUrl = `${repositoryUrl}#readme`;
|
|
236
|
+
const homepage = documentationUrl;
|
|
237
|
+
const githubUsername = author;
|
|
238
|
+
const authorWebsite = isOpenSource ? await getAuthorWebsiteFromGithubAPI(githubUsername) : '';
|
|
239
|
+
const licenseUrl = `${repositoryUrl}/blob/master/LICENSE`;
|
|
240
|
+
const projectInfos = {
|
|
241
|
+
filename: templatePath,
|
|
242
|
+
currentYear: new Date().getFullYear(),
|
|
243
|
+
name,
|
|
244
|
+
description,
|
|
245
|
+
version,
|
|
246
|
+
author,
|
|
247
|
+
authorWebsite,
|
|
248
|
+
homepage,
|
|
249
|
+
demoUrl,
|
|
250
|
+
repositoryUrl,
|
|
251
|
+
issuesUrl,
|
|
252
|
+
contributingUrl,
|
|
253
|
+
githubUsername,
|
|
254
|
+
authorName: author,
|
|
255
|
+
authorGithubUsername: githubUsername,
|
|
256
|
+
engines,
|
|
257
|
+
licenseName: cleanText(license),
|
|
258
|
+
licenseUrl,
|
|
259
|
+
documentationUrl,
|
|
260
|
+
isGithubRepos: true,
|
|
261
|
+
installCommand,
|
|
262
|
+
startCommand,
|
|
263
|
+
usage: startCommand,
|
|
264
|
+
devCommand,
|
|
265
|
+
buildCommand,
|
|
266
|
+
testCommand,
|
|
267
|
+
lintCommand,
|
|
268
|
+
isJSProject: true,
|
|
269
|
+
packageManager,
|
|
270
|
+
isProjectOnNpm: isPublishToNpm,
|
|
271
|
+
isOpenSource,
|
|
272
|
+
projectName: name,
|
|
273
|
+
projectVersion: version,
|
|
274
|
+
projectDocumentationUrl: documentationUrl,
|
|
275
|
+
projectDescription: description,
|
|
276
|
+
projectHomepage: homepage,
|
|
277
|
+
projectDemoUrl: demoUrl,
|
|
278
|
+
projectPrerequisites: Object.keys(engines).map((key) => ({
|
|
279
|
+
name: key,
|
|
280
|
+
value: engines[key],
|
|
281
|
+
})),
|
|
282
|
+
};
|
|
283
|
+
const readmeContent = await ejs__default["default"].render(template, projectInfos, {
|
|
284
|
+
debug: false,
|
|
285
|
+
async: true,
|
|
286
|
+
});
|
|
287
|
+
if (await fs__default["default"].pathExists(newReadmePath)) {
|
|
288
|
+
await fs__default["default"].remove(newReadmePath);
|
|
289
|
+
}
|
|
290
|
+
await fs__default["default"].writeFile(newReadmePath, lintMd(lodash.unescape(readmeContent)));
|
|
291
|
+
loading.succeed('README.md 初始化成功!');
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
loading.fail('README.md 初始化失败!');
|
|
295
|
+
console.error(error);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async function getAuthorWebsiteFromGithubAPI(githubUsername) {
|
|
299
|
+
try {
|
|
300
|
+
const userData = (await axios__default["default"].get(`${GITHUB_API_URL}/users/${githubUsername}`)).data;
|
|
301
|
+
const authorWebsite = userData === null || userData === void 0 ? void 0 : userData.blog;
|
|
302
|
+
return authorWebsite || '';
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
console.error(error);
|
|
306
|
+
return '';
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function lintMd(markdown) {
|
|
310
|
+
const rules = {
|
|
311
|
+
'no-empty-code': 0,
|
|
312
|
+
'no-trailing-punctuation': 0,
|
|
313
|
+
'no-long-code': 0,
|
|
314
|
+
'no-empty-code-lang': 0,
|
|
315
|
+
'no-empty-inlinecode': 0,
|
|
316
|
+
};
|
|
317
|
+
const fixed = core.fix(markdown, rules);
|
|
318
|
+
return fixed;
|
|
319
|
+
}
|
|
139
320
|
|
|
140
321
|
module.exports = function (plop) {
|
|
141
322
|
plop.setActionType('initProject', async (answers) => {
|
|
@@ -159,6 +340,13 @@ module.exports = function (plop) {
|
|
|
159
340
|
default: '',
|
|
160
341
|
filter: (e) => e.trim(),
|
|
161
342
|
},
|
|
343
|
+
{
|
|
344
|
+
type: 'input',
|
|
345
|
+
name: 'description',
|
|
346
|
+
message: '请输入项目简介',
|
|
347
|
+
default: '',
|
|
348
|
+
filter: (e) => e.trim(),
|
|
349
|
+
},
|
|
162
350
|
{
|
|
163
351
|
type: 'input',
|
|
164
352
|
name: 'author',
|
|
@@ -202,6 +390,49 @@ module.exports = function (plop) {
|
|
|
202
390
|
message: '是否开源?',
|
|
203
391
|
default: false,
|
|
204
392
|
},
|
|
393
|
+
{
|
|
394
|
+
type: 'confirm',
|
|
395
|
+
name: 'isInitRemoteRepo',
|
|
396
|
+
message: '是否初始化远程 Git 仓库?',
|
|
397
|
+
default: false,
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
type: 'input',
|
|
401
|
+
name: 'gitRemoteUrl',
|
|
402
|
+
message: '请输入远程 Git 仓库 Url',
|
|
403
|
+
validate(input) {
|
|
404
|
+
return input.trim().length !== 0;
|
|
405
|
+
},
|
|
406
|
+
default(answers) {
|
|
407
|
+
const { isOpenSource, name, author } = answers;
|
|
408
|
+
if (isOpenSource) {
|
|
409
|
+
return `git@github.com:${author}/${name}.git`;
|
|
410
|
+
}
|
|
411
|
+
return `git@gitee.com:caomeiyouren/${name}.git`;
|
|
412
|
+
},
|
|
413
|
+
filter: (e) => e.trim(),
|
|
414
|
+
when(answers) {
|
|
415
|
+
return answers.isInitRemoteRepo;
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
type: 'confirm',
|
|
420
|
+
name: 'isPublishToNpm',
|
|
421
|
+
message: '是否发布到 npm?',
|
|
422
|
+
default: false,
|
|
423
|
+
when(answers) {
|
|
424
|
+
return answers.isOpenSource;
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
type: 'confirm',
|
|
429
|
+
name: 'isInitReadme',
|
|
430
|
+
message: '是否初始化 README.md ?',
|
|
431
|
+
default: true,
|
|
432
|
+
when(answers) {
|
|
433
|
+
return answers.isOpenSource;
|
|
434
|
+
},
|
|
435
|
+
},
|
|
205
436
|
{
|
|
206
437
|
type: 'confirm',
|
|
207
438
|
name: 'isRemoveDependabot',
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmyr-template-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "草梅友仁自制的项目模板创建器",
|
|
5
5
|
"author": "CaoMeiYouRen",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"type": "commonjs",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"templates"
|
|
11
12
|
],
|
|
12
13
|
"engines": {
|
|
13
14
|
"node": ">=12"
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"@semantic-release/changelog": "^6.0.0",
|
|
40
41
|
"@semantic-release/git": "^10.0.0",
|
|
41
42
|
"@types/debug": "^4.1.5",
|
|
43
|
+
"@types/ejs": "^3.1.0",
|
|
42
44
|
"@types/fs-extra": "^9.0.4",
|
|
43
45
|
"@types/lodash": "^4.14.165",
|
|
44
46
|
"@types/node": "^16.9.6",
|
|
@@ -52,10 +54,9 @@
|
|
|
52
54
|
"cz-conventional-changelog": "^3.3.0",
|
|
53
55
|
"debug": "^4.3.1",
|
|
54
56
|
"eslint": "^7.14.0",
|
|
55
|
-
"eslint-config-cmyr": "^1.1.
|
|
57
|
+
"eslint-config-cmyr": "^1.1.14",
|
|
56
58
|
"husky": "^7.0.2",
|
|
57
59
|
"lint-staged": "^12.0.2",
|
|
58
|
-
"lodash": "^4.17.20",
|
|
59
60
|
"rimraf": "^3.0.2",
|
|
60
61
|
"rollup": "^2.33.3",
|
|
61
62
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -66,12 +67,15 @@
|
|
|
66
67
|
"validate-commit-msg": "^2.14.0"
|
|
67
68
|
},
|
|
68
69
|
"dependencies": {
|
|
70
|
+
"@lint-md/core": "^0.2.1",
|
|
69
71
|
"axios": "^0.24.0",
|
|
70
72
|
"colors": "^1.4.0",
|
|
71
73
|
"commander": "^8.2.0",
|
|
72
74
|
"dayjs": "^1.9.6",
|
|
73
75
|
"download-git-repo": "^3.0.2",
|
|
76
|
+
"ejs": "^3.1.6",
|
|
74
77
|
"fs-extra": "^10.0.0",
|
|
78
|
+
"lodash": "^4.17.20",
|
|
75
79
|
"minimist": "^1.2.5",
|
|
76
80
|
"ora": "^5.4.1",
|
|
77
81
|
"plop": "^2.7.6",
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<h1 align="center"><%= projectName %> </h1>
|
|
2
|
+
<p>
|
|
3
|
+
<% if (isProjectOnNpm) { -%>
|
|
4
|
+
<a href="https://www.npmjs.com/package/<%= projectName %>" target="_blank">
|
|
5
|
+
<img alt="Version" src="https://img.shields.io/npm/v/<%= projectName %>.svg">
|
|
6
|
+
</a>
|
|
7
|
+
<% } -%>
|
|
8
|
+
<% if (projectVersion && !isProjectOnNpm) { -%>
|
|
9
|
+
<img alt="Version" src="https://img.shields.io/badge/version-<%= projectVersion %>-blue.svg?cacheSeconds=2592000" />
|
|
10
|
+
<% } -%>
|
|
11
|
+
<% if (projectPrerequisites) { -%>
|
|
12
|
+
<% projectPrerequisites.map(({ name, value }) => { -%>
|
|
13
|
+
<img src="https://img.shields.io/badge/<%= name %>-<%= encodeURIComponent(value) %>-blue.svg" />
|
|
14
|
+
<% }) -%>
|
|
15
|
+
<% } -%>
|
|
16
|
+
<% if (projectDocumentationUrl) { -%>
|
|
17
|
+
<a href="<%= projectDocumentationUrl %>" target="_blank">
|
|
18
|
+
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
|
|
19
|
+
</a>
|
|
20
|
+
<% } -%>
|
|
21
|
+
<% if (isGithubRepos) { -%>
|
|
22
|
+
<a href="<%= repositoryUrl %>/graphs/commit-activity" target="_blank">
|
|
23
|
+
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
|
|
24
|
+
</a>
|
|
25
|
+
<% } -%>
|
|
26
|
+
<% if (licenseName) { -%>
|
|
27
|
+
<a href="<%= licenseUrl ? licenseUrl : '#' %>" target="_blank">
|
|
28
|
+
<img alt="License: <%= licenseName %>" src="https://img.shields.io/<%= `badge/License-${licenseName}-yellow.svg` %>" />
|
|
29
|
+
</a>
|
|
30
|
+
<% } -%>
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
<% if (projectDescription) { -%>
|
|
34
|
+
|
|
35
|
+
> <%= projectDescription %>
|
|
36
|
+
<% } -%>
|
|
37
|
+
<% if (projectHomepage) { -%>
|
|
38
|
+
|
|
39
|
+
### 🏠 [主页](<%= projectHomepage %>)
|
|
40
|
+
|
|
41
|
+
[<%= projectHomepage %>](<%= projectHomepage %>)
|
|
42
|
+
|
|
43
|
+
<% } -%>
|
|
44
|
+
<% if (projectDemoUrl) { -%>
|
|
45
|
+
|
|
46
|
+
### ✨ [Demo](<%= projectDemoUrl %>)
|
|
47
|
+
|
|
48
|
+
[<%= projectDemoUrl %>](<%= projectDemoUrl %>)
|
|
49
|
+
|
|
50
|
+
<% } -%>
|
|
51
|
+
<% if (projectPrerequisites && projectPrerequisites.length) { -%>
|
|
52
|
+
|
|
53
|
+
## 依赖要求
|
|
54
|
+
|
|
55
|
+
<% projectPrerequisites.map(({ name, value }) => { -%>
|
|
56
|
+
- <%= name %> <%= value %>
|
|
57
|
+
<% }) -%>
|
|
58
|
+
<% } -%>
|
|
59
|
+
<% if (installCommand) { -%>
|
|
60
|
+
|
|
61
|
+
## 安装
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
<%= installCommand %>
|
|
65
|
+
```
|
|
66
|
+
<% } -%>
|
|
67
|
+
<% if (usage) { -%>
|
|
68
|
+
|
|
69
|
+
## 使用
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
<%= usage %>
|
|
73
|
+
```
|
|
74
|
+
<% } -%>
|
|
75
|
+
<% if (devCommand) { -%>
|
|
76
|
+
|
|
77
|
+
## 开发
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
<%= devCommand %>
|
|
81
|
+
```
|
|
82
|
+
<% } -%>
|
|
83
|
+
<% if (buildCommand) { -%>
|
|
84
|
+
|
|
85
|
+
## 编译
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
<%= buildCommand %>
|
|
89
|
+
```
|
|
90
|
+
<% } -%>
|
|
91
|
+
<% if (testCommand) { -%>
|
|
92
|
+
|
|
93
|
+
## 测试
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
<%= testCommand %>
|
|
97
|
+
```
|
|
98
|
+
<% } -%>
|
|
99
|
+
<% if (lintCommand) { -%>
|
|
100
|
+
|
|
101
|
+
## Lint
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
<%= lintCommand %>
|
|
105
|
+
```
|
|
106
|
+
<% } -%>
|
|
107
|
+
|
|
108
|
+
<% if (authorName || authorGithubUsername) { -%>
|
|
109
|
+
|
|
110
|
+
## 作者
|
|
111
|
+
|
|
112
|
+
<% if (authorName) { %>
|
|
113
|
+
👤 **<%= authorName %>**
|
|
114
|
+
<% } %>
|
|
115
|
+
<% if (authorWebsite) { -%>
|
|
116
|
+
* Website: [<%= authorWebsite %>](<%= authorWebsite %>)
|
|
117
|
+
<% } -%>
|
|
118
|
+
<% if (authorGithubUsername) { -%>
|
|
119
|
+
* GitHub: [@<%= authorGithubUsername %>](https://github.com/<%= authorGithubUsername %>)
|
|
120
|
+
<% } -%>
|
|
121
|
+
<% } %>
|
|
122
|
+
<% if (issuesUrl) { -%>
|
|
123
|
+
|
|
124
|
+
## 🤝贡献
|
|
125
|
+
|
|
126
|
+
欢迎 Contributions, issues and feature!<br />如有问题请查看 [issues page](<%= issuesUrl %>). <%= contributingUrl ? `您还可以查看[contributing guide](${contributingUrl}).` : '' %>
|
|
127
|
+
<% } -%>
|
|
128
|
+
|
|
129
|
+
## 支持
|
|
130
|
+
|
|
131
|
+
如果觉得这个项目有用的话请给一颗⭐️,非常感谢
|
|
132
|
+
|
|
133
|
+
<% if (licenseName && licenseUrl) { -%>
|
|
134
|
+
|
|
135
|
+
## 📝 License
|
|
136
|
+
|
|
137
|
+
<% if (authorName && authorGithubUsername) { -%>
|
|
138
|
+
Copyright © <%= currentYear %> [<%= authorName %>](https://github.com/<%= authorGithubUsername %>).<br />
|
|
139
|
+
<% } -%>
|
|
140
|
+
This project is [<%= licenseName %>](<%= licenseUrl %>) licensed.
|
|
141
|
+
<% } -%>
|
|
142
|
+
|
|
143
|
+
***
|
|
144
|
+
_This README was generated with ❤️ by [cmyr-template-cli](https://github.com/CaoMeiYouRen/cmyr-template-cli)_
|