gz-cli-front 0.0.0-stage → 1.0.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/README.md CHANGED
@@ -1,3 +1,173 @@
1
- # Temporary Holding Version
1
+ # gz-cli-front
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 一个轻量级的现代前端脚手架工具,通过远程模板创建项目。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g gz-cli-front
9
+ ```
10
+
11
+ ## 使用
12
+
13
+ ```bash
14
+ gz-cli-front init [project-name]
15
+ ```
16
+
17
+ 也可以不全局安装,直接运行:
18
+
19
+ ```bash
20
+ npx gz-cli-front init demo-app
21
+ ```
22
+
23
+ `create` 命令仍可使用,例如 `gz-cli-front create demo-app`。
24
+ 新包只注册 `gz-cli-front` 命令,不注册旧的 `gg-cli` 命令。
25
+
26
+ 可通过 `--pm` 指定本次初始化使用的包管理器:
27
+
28
+ ```bash
29
+ gz-cli-front init demo-app --pm npm
30
+ gz-cli-front init demo-app --pm pnpm
31
+ gz-cli-front init demo-app --pm yarn
32
+ ```
33
+
34
+ 未指定时,CLI 会按 `pnpm`、`yarn`、`npm` 的顺序检测当前环境;都未检测到时默认使用 `npm`。模板注册表不包含包管理器配置。
35
+
36
+ ### 网络代理
37
+
38
+ CLI 会自动读取当前系统代理,不绑定具体代理工具、地址或端口。代理优先级如下:
39
+
40
+ ```text
41
+ --no-proxy 强制直连
42
+ --proxy 参数
43
+ HTTP_PROXY / HTTPS_PROXY / NO_PROXY
44
+ 操作系统代理
45
+ 无代理直连
46
+ ```
47
+
48
+ 临时指定代理或强制直连:
49
+
50
+ ```bash
51
+ gz-cli-front init demo-app --proxy http://proxy-host:port
52
+ gz-cli-front init demo-app --no-proxy
53
+ ```
54
+
55
+ 系统代理检测支持 Windows、macOS 和 Linux。代理相关日志只显示网络路径,不输出代理地址、账号或密码。
56
+
57
+ ### 模板缓存
58
+
59
+ 模板注册仓库和模板仓库会浅克隆并缓存到 `~/.gz-cli-front/cache`,减少重复创建项目时的网络等待。需要忽略缓存并获取最新内容时执行:
60
+
61
+ ```bash
62
+ gz-cli-front init demo-app --refresh
63
+ ```
64
+
65
+ 注册表缓存有效期为 5 分钟,`latest` 模板缓存有效期为 10 分钟;指定版本的模板缓存可以长期复用。远程暂时不可用时,未指定 `--refresh` 会回退到已有缓存。
66
+
67
+ 模板注册仓库和模板仓库均为公共仓库,默认通过配置中的 HTTPS 地址直接下载,无需配置 GitHub Token 或 SSH Key。Git 操作设有超时并支持网络代理;如显式配置 SSH clone URL,仍会使用本机 SSH Agent。
68
+
69
+ 可通过 `GZ_CLI_FRONT_CACHE_DIR` 指定缓存目录,通过 `GZ_CLI_FRONT_DEBUG=1` 开启网络和模板调试日志。新包不读取旧的 `GG_CLI_*` 环境变量,也不复用旧包的默认缓存目录。
70
+
71
+ 模板注册仓库由 `config/gz-cli-front.config.json` 管理,现有远程仓库地址保持不变:
72
+
73
+ ```json
74
+ {
75
+ "templateRegistry": {
76
+ "source": "git",
77
+ "url": "https://github.com/gz-fronted/gg-cli-template-register.git",
78
+ "file": "templates.json"
79
+ }
80
+ }
81
+ ```
82
+
83
+ 注册表中的每个模板使用独立仓库,例如:
84
+
85
+ ```json
86
+ [
87
+ {
88
+ "name": "main-app",
89
+ "label": "主应用模板",
90
+ "description": "Garfish 主应用模板",
91
+ "type": "main",
92
+ "source": "git",
93
+ "url": "https://github.com/your-org/gg-cli-template-main-app.git",
94
+ "version": "latest"
95
+ },
96
+ {
97
+ "name": "micro-app",
98
+ "label": "微应用模板",
99
+ "description": "Garfish 微应用模板",
100
+ "type": "micro",
101
+ "source": "git",
102
+ "url": "https://github.com/your-org/gg-cli-template-micro-app.git",
103
+ "version": "latest"
104
+ }
105
+ ]
106
+ ```
107
+
108
+ 公共仓库建议使用 `source: "git"` 和 HTTPS clone URL,避免要求使用者配置 SSH Key。CLI 会按配置的协议执行浅克隆;`source` 仍兼容 `github`、`gitlab` 和 `git`,旧的 GitHub `repo` 配置也可继续使用。
109
+
110
+ ### Git 仓库访问测试
111
+
112
+ 发版前可以在本机验证 Git 仓库访问失败时的错误提示,不会修改全局 Git 配置:
113
+
114
+ ```bash
115
+ npm run test:auth-error
116
+ ```
117
+
118
+ 该脚本使用独立缓存和模拟失败的 Git 命令运行构建后的 CLI,要求在超时前返回明确错误。正常访问链路仍使用以下命令验证:
119
+
120
+ ```bash
121
+ npm run build
122
+ node dist/index.js init --refresh
123
+ ```
124
+
125
+ 发版前统一执行:
126
+
127
+ ```bash
128
+ npm run test:release
129
+ ```
130
+
131
+ 该命令会依次验证构建、HTTPS Git 兼容性、公共注册仓库访问、失败错误提示和 npm 发布包内容。
132
+
133
+ 如果已经手动执行过 `npm run build`,可以只验证构建产物和 Git 场景:
134
+
135
+ ```bash
136
+ npm run test:smoke
137
+ ```
138
+
139
+ ## 发布到 npm
140
+
141
+ 本包以 `gz-cli-front` 为独立包名,初始版本为 `1.0.0`,不会覆盖或更新旧的 `@chenhui996/gg-cli` 包。
142
+
143
+ 首次发布前,确认包名尚未被占用,并登录有发布权限的 npm 账号:
144
+
145
+ ```bash
146
+ npm view gz-cli-front --registry=https://registry.npmjs.org/
147
+ npm login --registry=https://registry.npmjs.org/
148
+ npm whoami --registry=https://registry.npmjs.org/
149
+ ```
150
+
151
+ 查询返回 E404 表示未找到该包;网络或认证错误不能作为包名可用的判断依据。最终能否发布以 npm 的校验结果为准。
152
+
153
+ 安装依赖并验证:
154
+
155
+ ```bash
156
+ npm ci
157
+ npm run test:release
158
+ ```
159
+
160
+ 确认通过后发布:
161
+
162
+ ```bash
163
+ npm publish --registry=https://registry.npmjs.org/
164
+ ```
165
+
166
+ 发布时会自动通过 `prepublishOnly` 再运行一次发布验证。发布内容包括 `bin`、构建后的 `dist`、包信息和 README,不包含 `src/template` 中的本地模板。
167
+
168
+ 发布后可验证:
169
+
170
+ ```bash
171
+ npm view gz-cli-front version --registry=https://registry.npmjs.org/
172
+ npx --registry=https://registry.npmjs.org/ gz-cli-front@1.0.0 --version
173
+ ```
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/index.js';
@@ -0,0 +1,7 @@
1
+ {
2
+ "templateRegistry": {
3
+ "source": "git",
4
+ "url": "https://github.com/gz-fronted/gg-cli-template-register.git",
5
+ "file": "templates.json"
6
+ }
7
+ }
@@ -0,0 +1,2 @@
1
+
2
+ export { }