create-component-template-cli 1.0.1 → 1.0.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/AGENTS.md +1 -1
- package/CHANGELOG.md +7 -1
- package/CLAUDE.md +1 -1
- package/README.md +12 -4
- package/bin/cli.mjs +1 -1
- package/docs/2026-05-11T12-35-00-npx/346/211/247/350/241/214/345/205/245/345/217/243/344/277/256/345/244/215/2026-05-11T12-35-00-npx/346/211/247/350/241/214/345/205/245/345/217/243/344/277/256/345/244/215-/345/256/236/346/226/275/346/226/271/346/241/210.md +66 -0
- package/docs/2026-05-11T12-35-00-npx/346/211/247/350/241/214/345/205/245/345/217/243/344/277/256/345/244/215/2026-05-11T12-35-00-npx/346/211/247/350/241/214/345/205/245/345/217/243/344/277/256/345/244/215-/346/200/235/350/267/257/346/226/207/346/241/243.md +69 -0
- package/docs/2026-05-11T12-35-00-npx/346/211/247/350/241/214/345/205/245/345/217/243/344/277/256/345/244/215/2026-05-11T12-35-00-npx/346/211/247/350/241/214/345/205/245/345/217/243/344/277/256/345/244/215-/346/200/273/347/273/223/346/226/207/346/241/243.md +27 -0
- package/package.json +4 -3
package/AGENTS.md
CHANGED
|
@@ -4,7 +4,7 @@ This file provides guidance to Codex (Codex.ai/code) when working with code in t
|
|
|
4
4
|
|
|
5
5
|
## Project Overview
|
|
6
6
|
|
|
7
|
-
**create-vue-component-template** (CLI command: `cvct`) — a CLI scaffolding tool that generates Vue component directory structures with predefined templates. Published to npm as a global CLI utility.
|
|
7
|
+
**create-vue-component-template-cli** (CLI command: `cvct`) — a CLI scaffolding tool that generates Vue component directory structures with predefined templates. Published to npm as a global CLI utility.
|
|
8
8
|
|
|
9
9
|
## Commands
|
|
10
10
|
|
package/CHANGELOG.md
CHANGED
package/CLAUDE.md
CHANGED
|
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
4
4
|
|
|
5
5
|
## Project Overview
|
|
6
6
|
|
|
7
|
-
**create-vue-component-template** (CLI command: `cvct`) — a CLI scaffolding tool that generates Vue component directory structures with predefined templates. Published to npm as a global CLI utility.
|
|
7
|
+
**create-vue-component-template-cli** (CLI command: `cvct`) — a CLI scaffolding tool that generates Vue component directory structures with predefined templates. Published to npm as a global CLI utility.
|
|
8
8
|
|
|
9
9
|
## Commands
|
|
10
10
|
|
package/README.md
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
# create-
|
|
1
|
+
# create-component-template-cli
|
|
2
2
|
|
|
3
3
|
一个用于快速创建 Vue 3 + TypeScript + Sass 组件骨架的 CLI 工具。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 使用方式
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
#
|
|
8
|
+
# 通过包名直接执行(适合 npm / npx 用户)
|
|
9
|
+
npx create-component-template-cli --version
|
|
10
|
+
npx create-component-template-cli
|
|
11
|
+
|
|
12
|
+
# 通过短命令执行
|
|
13
|
+
npx cvct --version
|
|
14
|
+
npx cvct
|
|
15
|
+
|
|
16
|
+
# 本地开发调试
|
|
9
17
|
node bin/cli.mjs
|
|
10
18
|
|
|
11
19
|
# 非交互模式
|
|
@@ -14,7 +22,7 @@ node bin/cli.mjs --name=MyComponent --rootPath=src/components/platform
|
|
|
14
22
|
# 指定业务模板类型
|
|
15
23
|
node bin/cli.mjs --name=MyComponent --rootPath=src/components/platform --templateType=single-pick
|
|
16
24
|
|
|
17
|
-
# 指定 index.vue 的 Vue
|
|
25
|
+
# 指定 index.vue 的 Vue 写法
|
|
18
26
|
node bin/cli.mjs --name=MyComponent --rootPath=src/components/platform --templateType=multiple-pick --vueTemplateType=normal
|
|
19
27
|
```
|
|
20
28
|
|
package/bin/cli.mjs
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# npx 执行入口修复-实施方案
|
|
2
|
+
|
|
3
|
+
## 1. 问题描述
|
|
4
|
+
|
|
5
|
+
用户在发包成功后执行 `npx create-component-template-cli`,终端报错:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
'cvct' 不是内部或外部命令,也不是可运行的程序或批处理文件。
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
但执行 `npx cvct` 可以正常输出版本号。
|
|
12
|
+
|
|
13
|
+
## 2. 原因分析
|
|
14
|
+
|
|
15
|
+
当前包的 `package.json` 只声明了一个可执行入口:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
bin:
|
|
19
|
+
cvct -> bin/cli.mjs
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
这会导致:
|
|
23
|
+
|
|
24
|
+
1. 用户如果明确执行 `npx cvct`,npm 能找到对应的可执行文件。
|
|
25
|
+
2. 用户如果执行 `npx create-component-template-cli`,npm 在 Windows 环境下不会自动把包名映射成 `cvct`,从而出现命令不存在。
|
|
26
|
+
|
|
27
|
+
## 3. 实施方案
|
|
28
|
+
|
|
29
|
+
### 3.1 修复入口映射
|
|
30
|
+
|
|
31
|
+
在 `package.json` 中同时声明两个可执行名称,并都指向同一个入口文件:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
bin:
|
|
35
|
+
cvct -> bin/cli.mjs
|
|
36
|
+
create-component-template-cli -> bin/cli.mjs
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 3.2 更新使用文档
|
|
40
|
+
|
|
41
|
+
在 README 中明确说明两种推荐调用方式:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
npx create-component-template-cli
|
|
45
|
+
npx cvct
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
这样做的原因是:
|
|
49
|
+
|
|
50
|
+
1. 包名调用方式更符合用户直觉。
|
|
51
|
+
2. 短命令调用方式更适合高频使用。
|
|
52
|
+
|
|
53
|
+
## 4. 验证方案
|
|
54
|
+
|
|
55
|
+
使用以下命令做闭环验证:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
步骤 1:验证本地入口文件仍可正常输出版本
|
|
59
|
+
步骤 2:验证 npx cvct --version 可以执行
|
|
60
|
+
步骤 3:验证 npx create-component-template-cli --version 可以执行
|
|
61
|
+
步骤 4:验证 npm pack 后产物包含 bin/cli.mjs 与双 bin 映射
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 5. 风险说明
|
|
65
|
+
|
|
66
|
+
本次修改只涉及包元数据与说明文档,不改变模板生成逻辑,业务风险较低。
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# npx 执行入口修复-思路文档
|
|
2
|
+
|
|
3
|
+
## 1. 排查思路
|
|
4
|
+
|
|
5
|
+
这次问题表面上看是“命令找不到”,但需要先区分是以下哪一层出了问题:
|
|
6
|
+
|
|
7
|
+
1. 包没有成功发布。
|
|
8
|
+
2. 发布包里缺少 `bin/cli.mjs`。
|
|
9
|
+
3. `package.json` 的 `bin` 字段配置错误。
|
|
10
|
+
4. `npx` 调用的命令名和实际暴露的 bin 名不一致。
|
|
11
|
+
|
|
12
|
+
## 2. 实际排查过程
|
|
13
|
+
|
|
14
|
+
### 2.1 先看本地源码
|
|
15
|
+
|
|
16
|
+
确认 `package.json` 中存在:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
name = create-component-template-cli
|
|
20
|
+
bin.cvct = bin/cli.mjs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
说明源码只暴露了 `cvct` 这个命令。
|
|
24
|
+
|
|
25
|
+
### 2.2 再看打包产物
|
|
26
|
+
|
|
27
|
+
通过 `npm pack` 检查 tarball 内容,确认 `bin/cli.mjs` 已被打进包里。
|
|
28
|
+
|
|
29
|
+
这一步的意义是:
|
|
30
|
+
|
|
31
|
+
1. 排除“发包漏文件”。
|
|
32
|
+
2. 证明运行时报错不是因为入口脚本缺失。
|
|
33
|
+
|
|
34
|
+
### 2.3 再看线上元数据
|
|
35
|
+
|
|
36
|
+
通过 `npm view create-component-template-cli ...` 查看线上元数据,确认线上 `bin` 仍然只有 `cvct`。
|
|
37
|
+
|
|
38
|
+
### 2.4 最后做最小复现
|
|
39
|
+
|
|
40
|
+
复现结果:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
npx cvct --version -> 成功
|
|
44
|
+
npx create-component-template-cli --version -> 失败
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
这说明真正的问题不是 CLI 代码本身,而是可执行命令别名不完整。
|
|
48
|
+
|
|
49
|
+
## 3. 为什么这样修
|
|
50
|
+
|
|
51
|
+
最小改动方案是直接补一个与包名同名的 bin 映射,而不是改动 `bin/cli.mjs` 的执行逻辑。
|
|
52
|
+
|
|
53
|
+
原因:
|
|
54
|
+
|
|
55
|
+
1. 问题发生在 npm 命令解析阶段,不在业务代码阶段。
|
|
56
|
+
2. 增加包名别名不会影响已有用户继续使用 `cvct`。
|
|
57
|
+
3. 兼容“记包名”和“记短命令”两类用户习惯。
|
|
58
|
+
|
|
59
|
+
## 4. 伪代码示意
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
if user_run_by_package_name:
|
|
63
|
+
resolve bin["create-component-template-cli"]
|
|
64
|
+
|
|
65
|
+
if user_run_by_short_name:
|
|
66
|
+
resolve bin["cvct"]
|
|
67
|
+
|
|
68
|
+
both -> execute "bin/cli.mjs"
|
|
69
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# npx 执行入口修复-总结文档
|
|
2
|
+
|
|
3
|
+
## 本次完成内容
|
|
4
|
+
|
|
5
|
+
1. 定位了 `npx create-component-template-cli` 报错的根因。
|
|
6
|
+
2. 在 `package.json` 中新增了 `create-component-template-cli -> bin/cli.mjs` 的 bin 映射。
|
|
7
|
+
3. 保留了原有 `cvct -> bin/cli.mjs` 的短命令入口,避免兼容性回退。
|
|
8
|
+
4. 重写 README 的使用说明,补充了包名调用方式与短命令调用方式。
|
|
9
|
+
5. 完成了本地命令验证与打包产物验证。
|
|
10
|
+
|
|
11
|
+
## 当前版本收益
|
|
12
|
+
|
|
13
|
+
1. 用户可以直接执行 `npx create-component-template-cli`,调用方式和包名保持一致。
|
|
14
|
+
2. 老用户仍可继续执行 `npx cvct`,不会受到影响。
|
|
15
|
+
3. 文档说明更完整,后续排障成本更低。
|
|
16
|
+
|
|
17
|
+
## 目前不足
|
|
18
|
+
|
|
19
|
+
1. README 之外的其他文档(如 AGENTS/CLAUDE 中的示例)仍以本地 `node bin/cli.mjs` 为主,没有单独强调包名执行方式。
|
|
20
|
+
2. 仓库当前没有自动化测试覆盖“npx/发布后入口解析”这个场景,未来仍可能出现回归。
|
|
21
|
+
3. 打包产物目前包含较多与发布无关的文件,后续可以考虑通过 `files` 字段进一步收敛 npm 包体积。
|
|
22
|
+
|
|
23
|
+
## 后续建议
|
|
24
|
+
|
|
25
|
+
1. 发一个补丁版本,把新的 bin 映射发布到 npm。
|
|
26
|
+
2. 增加一个发布前校验脚本,自动验证 tarball 中的 `bin` 配置和入口文件是否完整。
|
|
27
|
+
3. 视情况补充 `files` 字段,减少无关文件进入 npm 包。
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-component-template-cli",
|
|
3
|
-
"description": "create-vue-component-template,A CLI tool for creating standardized Vue 3 + TypeScript + Sass public component templates.",
|
|
4
|
-
"version": "1.0.
|
|
3
|
+
"description": "create-vue-component-template-cli,A CLI tool for creating standardized Vue 3 + TypeScript + Sass public component templates.",
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
|
-
"
|
|
10
|
+
"cctc": "bin/cli.mjs",
|
|
11
|
+
"create-component-template-cli": "bin/cli.mjs"
|
|
11
12
|
},
|
|
12
13
|
"access": "public",
|
|
13
14
|
"dependencies": {
|