create-mg-app v0.2.8
create-mg-app
使用模板搭建项目
参考 @vite/create-app 和 vue-cli@2.9.6
需要 Node.js 版本 >=12.0.0.
# 使用 yarn
yarn create mg-app
# 使用 npm
npm init mg-app然后跟随提示操作!
也可以直接指定项目名称和要使用的模板,详细用法如下:
yarn create mg-app [project_name] \
[-t/--template <template_name>] \
[--repo [github|gitlab:][hostname:]repo_owner/repo_name[#branch]] \
[--auth "<username>: <password>"] \
[--token: <private_token>] \
[--header "Private-Token: <private_token>"] \
[--offline] \
[-h/--help]用法示例:
创建项目,且命名为
my-projectyarn create mg-app my-project创建项目,使用 离线模板(模板已经缓存在本地)
yarn create mg-app --offline创建项目,指定使用
vue3模板yarn create mg-app -t vue3创建名称为
my-project的项目,使用 离线模式,并指定模板为vue3yarn create mg-app my-project --offline -t vue3创建项目,使用
github公有仓库(将设仓库所有者为owner,仓库名为my-public,分支为dev)yarn create mg-app --repo owner/my-public#dev创建项目,使用
gitlab公有仓库(仓库类型为gitlab,将设主机名为hostname,仓库所有者为owner,仓库名my-public)yarn create mg-app --repo gitlab:hostname:owner/my-public创建项目,使用
gitlab私有仓库(使用 个人访问令牌 验证身份)yarn create mg-app --repo gitlab:hostname:owner/my-private --token 9koXpg98eAheJpvBs5tK创建项目,使用
gitlab私有仓库(使用 用户名和密码 验证身份,该验证方式只支持了gitlab,优先使用 个人访问令牌)yarn create mg-app --repo gitlab:hostname:owner/my-private --auth "hdcljt: 1qaz@WSX"
另外:
默认仓库配置为
hdcljt/create-app#old,但是主要用途是下载维护在 gitlab 上私有的模板仓库(即用法示例 7)
仓库下载后,模板缓存在~/.mg-templates/templates/目录。--offline离线模式也是读取的此目录--token和--auth的参数配置会缓存在本地的~/.mg-templates/config.json文件中,即在没有输入的情况下会优先读取缓存中的token(其次auth)
创建个人访问令牌
Gitlab
您可以在 GitLab 个人资料中创建任意数量的个人访问令牌。
- 登录到您的
GitLab帐户 - 转到您的
User Settings > Access Tokens - 选择令牌的 名称, 有效期 和所需的 范围,创建令牌
- 将个人访问令牌保存在安全的地方。离开或刷新页面后,将无法再次访问它
Github
GitHub 会自动删除一年内未使用过的个人访问令牌
- 登录到您的
GitHub帐户 - 转到您的
Settings > Developer settings > Personal access tokens - 选择令牌的 名称 和所需的 范围,创建令牌
- 将个人访问令牌保存在安全的地方。离开或刷新页面后,将无法再次访问它
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago