cmyr-template-cli 1.32.3 → 1.33.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/dist/plopfile.js +49 -3
- package/package.json +1 -1
package/dist/plopfile.js
CHANGED
|
@@ -349,6 +349,28 @@ async function createGithubRepo(authToken, data) {
|
|
|
349
349
|
return null;
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
+
async function replaceGithubRepositoryTopics(authToken, data) {
|
|
353
|
+
try {
|
|
354
|
+
const { owner, repo, topics } = data;
|
|
355
|
+
const resp = await axios__default["default"]({
|
|
356
|
+
url: `/repos/${owner}/${repo}/topics`,
|
|
357
|
+
baseURL: GITHUB_API_URL,
|
|
358
|
+
method: 'PUT',
|
|
359
|
+
headers: {
|
|
360
|
+
Authorization: `Bearer ${authToken}`,
|
|
361
|
+
Accept: 'application/vnd.github+json',
|
|
362
|
+
},
|
|
363
|
+
data: {
|
|
364
|
+
names: topics,
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
return resp.data;
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
console.error(error);
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
352
374
|
async function loadTemplateCliConfig() {
|
|
353
375
|
const paths = [process.cwd(), os__default["default"].homedir()].map((e) => path__default["default"].join(e, '.ctrc'));
|
|
354
376
|
const [local, home] = (await Promise.all(paths.map(async (p) => {
|
|
@@ -574,10 +596,11 @@ async function getGitUserName() {
|
|
|
574
596
|
return username === null || username === void 0 ? void 0 : username.trim();
|
|
575
597
|
}
|
|
576
598
|
async function initRemoteGitRepo(projectPath, answers) {
|
|
577
|
-
var _a, _b;
|
|
599
|
+
var _a, _b, _c, _d, _e;
|
|
578
600
|
const loading = ora__default["default"]('正在初始化远程 Git 仓库……').start();
|
|
579
601
|
try {
|
|
580
|
-
const { name, description, gitRemoteUrl, isOpenSource, isInitRemoteRepo } = answers;
|
|
602
|
+
const { name, description, gitRemoteUrl, isOpenSource, isInitRemoteRepo, keywords, template } = answers;
|
|
603
|
+
const templateMeta = getTemplateMeta(template);
|
|
581
604
|
if (!gitRemoteUrl) {
|
|
582
605
|
loading.fail('未找到远程 Git 仓库地址,请自行初始化!');
|
|
583
606
|
return;
|
|
@@ -613,6 +636,29 @@ async function initRemoteGitRepo(projectPath, answers) {
|
|
|
613
636
|
if ((resp === null || resp === void 0 ? void 0 : resp.status) >= 200) {
|
|
614
637
|
loading.succeed('远程 Git 仓库初始化成功!');
|
|
615
638
|
console.info(colors__default["default"].green(`远程 Git 仓库地址 ${(_a = resp.data) === null || _a === void 0 ? void 0 : _a.html_url}`));
|
|
639
|
+
const owner = (_c = (_b = resp.data) === null || _b === void 0 ? void 0 : _b.owner) === null || _c === void 0 ? void 0 : _c.login;
|
|
640
|
+
const repo = (_d = resp.data) === null || _d === void 0 ? void 0 : _d.name;
|
|
641
|
+
if (owner && repo) {
|
|
642
|
+
console.info(colors__default["default"].green('正在初始化仓库 topics !'));
|
|
643
|
+
if (templateMeta.docker) {
|
|
644
|
+
keywords.push('docker');
|
|
645
|
+
}
|
|
646
|
+
if (templateMeta === null || templateMeta === void 0 ? void 0 : templateMeta.language) {
|
|
647
|
+
keywords.push(templateMeta === null || templateMeta === void 0 ? void 0 : templateMeta.language);
|
|
648
|
+
}
|
|
649
|
+
if (templateMeta === null || templateMeta === void 0 ? void 0 : templateMeta.runtime) {
|
|
650
|
+
keywords.push(templateMeta === null || templateMeta === void 0 ? void 0 : templateMeta.runtime);
|
|
651
|
+
}
|
|
652
|
+
if ((templateMeta === null || templateMeta === void 0 ? void 0 : templateMeta.vueVersion) === 3) {
|
|
653
|
+
keywords.push('vue3');
|
|
654
|
+
}
|
|
655
|
+
await replaceGithubRepositoryTopics(authToken, {
|
|
656
|
+
owner,
|
|
657
|
+
repo,
|
|
658
|
+
topics: lodash.uniq(keywords).map((e) => kebabCase(e)),
|
|
659
|
+
});
|
|
660
|
+
console.info(colors__default["default"].green('仓库 topics 初始化成功!'));
|
|
661
|
+
}
|
|
616
662
|
}
|
|
617
663
|
else {
|
|
618
664
|
loading.fail('远程 Git 仓库初始化失败!');
|
|
@@ -633,7 +679,7 @@ async function initRemoteGitRepo(projectPath, answers) {
|
|
|
633
679
|
});
|
|
634
680
|
if ((resp === null || resp === void 0 ? void 0 : resp.status) >= 200) {
|
|
635
681
|
loading.succeed('远程 Git 仓库初始化成功!');
|
|
636
|
-
console.info(colors__default["default"].green(`远程 Git 仓库地址 ${(
|
|
682
|
+
console.info(colors__default["default"].green(`远程 Git 仓库地址 ${(_e = resp.data) === null || _e === void 0 ? void 0 : _e.html_url}`));
|
|
637
683
|
}
|
|
638
684
|
else {
|
|
639
685
|
loading.fail('远程 Git 仓库初始化失败!');
|