@carllee1983/tagsmith 0.2.0 → 0.2.1

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,28 +1,55 @@
1
1
  # Tagsmith
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@carllee1983/tagsmith.svg)](https://www.npmjs.com/package/@carllee1983/tagsmith)
4
+
3
5
  定義專案的 git tag 規格、檢視現有 tag,並安全地產生下一個 git tag——避免順序錯亂或格式不一致。
4
6
 
5
7
  支援 **SemVer**、**CalVer** 與 **build number** 三種版本模型,tag 樣式可自訂(例如 `v{version}`、`release/{version}`)。
6
8
 
7
- - 🏷️ **規格化** — 用一個 `.tagsmith.json` 定義全專案的 tag 樣式與版本模型
9
+ - 🏷️ **規格化** — `.tagsmith.json` 定義全專案的 tag 樣式與版本模型(可選)
8
10
  - 🔍 **可檢視** — 依語義排序列出 tag,標示格式 / 順序 / 重複異常
9
11
  - 🛡️ **防呆** — 建立前驗證格式、版本可解析、嚴格遞增、tag 不重複
12
+ - 🚀 **零設定** — 無設定檔時自動以 semver 推斷 pattern,讀 repo 既有 tag 即可用
10
13
  - 🧩 **可擴充** — 版本模型走介面抽象,新增不動核心邏輯
11
14
 
12
15
  ## 安裝
13
16
 
14
17
  ```bash
15
- npm install -g tagsmith
18
+ # 全域安裝(指令名稱仍為 tagsmith
19
+ npm install -g @carllee1983/tagsmith
20
+
16
21
  # 或免安裝直接執行
17
- npx tagsmith <command>
22
+ npx @carllee1983/tagsmith <command>
23
+
24
+ # 專案相依(CI / husky hook 常用)
25
+ npm install -D @carllee1983/tagsmith
26
+ # 裝在本機後可直接:npx tagsmith <command>
18
27
  ```
19
28
 
29
+ npm:[https://www.npmjs.com/package/@carllee1983/tagsmith](https://www.npmjs.com/package/@carllee1983/tagsmith)
30
+
20
31
  需求:Node.js ≥ 18、git。
21
32
 
22
33
  ## 快速開始
23
34
 
35
+ ### 零設定(無 `.tagsmith.json`)
36
+
37
+ 已有 semver 風格 tag(如 `v0.1.0`)的 repo 可直接使用:
38
+
39
+ ```bash
40
+ tagsmith list # 檢視既有 tag
41
+ tagsmith next # 預覽下一個 tag(預設 patch bump)
42
+ tagsmith next --level minor # 例如 v0.1.0 → v0.2.0
43
+ tagsmith create --push # 建立並推送
44
+ ```
45
+
46
+ 無設定檔時預設 semver、`v{version}` pattern;會從既有 tag 自動推斷格式(如 `{version}`)。
47
+ 團隊協作建議仍執行 `init` 並 commit `.tagsmith.json` 以固定規格。
48
+
49
+ ### 完整流程(自訂規格)
50
+
24
51
  ```bash
25
- # 1. 在 repo 內定義 tag 規格(互動式)
52
+ # 1. 在 repo 內定義 tag 規格(互動式,可選)
26
53
  tagsmith init
27
54
 
28
55
  # 不熟指令?走一次互動式導覽
@@ -99,7 +126,7 @@ tagsmith create --level minor -m "Release 1.2.0" --push
99
126
 
100
127
  Tagsmith 載入時會自動將其視為一條名為 `default` 的單線設定;現有使用者**零修改**即可繼續使用。
101
128
 
102
- 可在檔案加上 `"$schema": "./node_modules/tagsmith/schema.json"` 取得編輯器補全與驗證。
129
+ 可在檔案加上 `"$schema": "./node_modules/@carllee1983/tagsmith/schema.json"` 取得編輯器補全與驗證。
103
130
 
104
131
  ### 三種版本模型
105
132
 
@@ -154,7 +181,7 @@ Tagsmith 載入時會自動將其視為一條名為 `default` 的單線設定;
154
181
  ## 指令
155
182
 
156
183
  ### `tagsmith init`
157
- 互動式產生 `.tagsmith.json`。
184
+ 互動式產生 `.tagsmith.json`(**可選**;zero-config 模式下可略過,團隊協作仍建議 commit 設定檔)。
158
185
 
159
186
  | 旗標 | 說明 |
160
187
  |------|------|
@@ -296,14 +323,14 @@ tagsmith list --all
296
323
  ## 搭配 husky 守 tag
297
324
 
298
325
  可用 git `pre-push` hook 在推送時自動驗證 tag,擋下不符規格者。
299
- 詳見 [docs/husky-pre-push.md](docs/husky-pre-push.md)
326
+ 詳見 [docs/husky-pre-push.md](docs/husky-pre-push.md)(需安裝 `@carllee1983/tagsmith`)。
300
327
 
301
328
  ## 結束代碼
302
329
 
303
330
  | 代碼 | 意義 |
304
331
  |:---:|------|
305
332
  | `0` | 成功(含 `--dry-run`) |
306
- | `1` | 失敗:缺設定檔、非 git repo、驗證未通過、git 指令錯誤等(訊息走 stderr) |
333
+ | `1` | 失敗:非 git repo、驗證未通過、git 指令錯誤等(訊息走 stderr) |
307
334
 
308
335
  ## 設計
309
336
 
package/dist/cli/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
2
3
  import { Command } from "commander";
3
4
  import { runInit } from "./init.js";
4
5
  import { runList } from "./list.js";
@@ -7,13 +8,15 @@ import { runCreate } from "./create.js";
7
8
  import { runGuide } from "./guide.js";
8
9
  import { runCheck } from "./check.js";
9
10
  import { printError } from "./ui.js";
11
+ const require = createRequire(import.meta.url);
12
+ const { version } = require("../../package.json");
10
13
  const program = new Command();
11
14
  program
12
15
  .name("tagsmith")
13
16
  .description("Define git tag specs, view tags, and generate the next git tag safely.")
14
- .version("0.1.0");
15
- program.addHelpText("beforeAll", "\n Tagsmith — define a tag spec, then safely compute and create git tags.\n" +
16
- " First time here? Run `tagsmith init`, or `tagsmith guide` for a walkthrough.\n");
17
+ .version(version);
18
+ program.addHelpText("beforeAll", "\n Tagsmith (@carllee1983/tagsmith) — define a tag spec, then safely compute and create git tags.\n" +
19
+ " No config yet? Try `tagsmith next` (zero-config semver), `tagsmith init`, or `tagsmith guide`.\n");
17
20
  program.addHelpText("after", `
18
21
  Examples:
19
22
  $ tagsmith init Define the tag spec (interactive)
@@ -26,7 +29,7 @@ Examples:
26
29
  `);
27
30
  program
28
31
  .command("init")
29
- .description("Create a .tagsmith.json tag spec for this repo")
32
+ .description("Create a .tagsmith.json tag spec for this repo (optional; zero-config works without it)")
30
33
  .option("--pattern <pattern>", "tag pattern, must contain {version}")
31
34
  .option("--model <type>", "version model: semver | calver | build")
32
35
  .option("--initial-version <version>", "initial version")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carllee1983/tagsmith",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Define git tag specs, view tags, and generate the next git tag safely — avoiding ordering or format anomalies.",
5
5
  "type": "module",
6
6
  "publishConfig": { "access": "public" },
package/schema.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://github.com/CMG/tagsmith/schema.json",
3
+ "$id": "https://github.com/CarlLee1983/Tagsmith/schema.json",
4
4
  "title": "Tagsmith config",
5
5
  "description": "Tag specification for the tagsmith CLI (.tagsmith.json).",
6
6
  "type": "object",