From b90fa8ae33c092341b3a68be0610f0ae08f70606 Mon Sep 17 00:00:00 2001
From: CaoMeiYouRen <996881204@qq.com>
Date: Tue, 16 Jul 2024 23:56:51 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=20docker=20hub=20?=
=?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E5=92=8C=E5=BE=BD=E7=AB=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 5 ++++-
src/utils.ts | 5 ++++-
templates/README.md | 8 ++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index e531c36..99b1808 100644
--- a/README.md
+++ b/README.md
@@ -68,7 +68,8 @@ ct create
"PATREON_USERNAME": "",
"WEIBO_USERNAME": "",
"TWITTER_USERNAME": "",
- "NPM_USERNAME": ""
+ "NPM_USERNAME": "",
+ "DOCKER_USERNAME": ""
}
```
@@ -90,6 +91,8 @@ TWITTER_USERNAME:Twitter 用户名,可空,默认值为空
NPM_USERNAME:Npm 用户名,可空,默认会使用 `GITHUB_USERNAME` 的用户名
+DOCKER_USERNAME:Docker Hub 用户名,可空,默认会使用**小写的** `GITHUB_USERNAME` 的用户名
+
**如果不使用自动初始化远程仓库功能,可以跳过该配置**
## 开发
diff --git a/src/utils.ts b/src/utils.ts
index 0b9979d..521f701 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -129,6 +129,7 @@ type TemplateCliConfig = {
WEIBO_USERNAME: string
TWITTER_USERNAME: string
NPM_USERNAME: string
+ DOCKER_USERNAME: string
}
type GiteeRepo = {
@@ -840,7 +841,8 @@ async function getProjectInfo(projectPath: string, answers: InitAnswers) {
const twitterUsername = config?.TWITTER_USERNAME
const afdianUsername = config?.AFDIAN_USERNAME
const patreonUsername = config?.PATREON_USERNAME
- const npmUsername = config?.NPM_USERNAME || author
+ const npmUsername = config?.NPM_USERNAME || githubUsername
+ const dockerUsername = config?.DOCKER_USERNAME || githubUsername?.toLowerCase()
const repositoryUrl = `https://github.com/${githubUsername}/${projectName}`
const gitUrl = `git+${repositoryUrl}.git`
@@ -908,6 +910,7 @@ async function getProjectInfo(projectPath: string, answers: InitAnswers) {
weiboUsername,
twitterUsername,
npmUsername,
+ dockerUsername,
templateMeta,
mainFile,
}
diff --git a/templates/README.md b/templates/README.md
index 3538d4a..eb2dfe9 100644
--- a/templates/README.md
+++ b/templates/README.md
@@ -4,10 +4,18 @@
+
+
+
<% } -%>
<% if (projectVersion && isJSProject) { -%>
<% } -%>
+<% if (isOpenSource && isInitDocker) { -%>
+
+
+
+<% } -%>
<% if (isGithubRepos && isInitSemanticRelease) { -%>