@pc360/chlog 0.1.7 → 0.1.9

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/CHANGELOG.md CHANGED
@@ -11,6 +11,18 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
11
11
  - Removed Ink card border lines so help and status output no longer render inside a box.
12
12
  - Added blank lines before and after help and error output to improve readability.
13
13
 
14
+ ## [0.1.9] - 2026-02-14
15
+
16
+ ### Changed
17
+
18
+ - Update docs with a global installation and add --version option
19
+
20
+ ## [0.1.8] - 2026-02-14
21
+
22
+ ### Changed
23
+
24
+ - Update docs
25
+
14
26
  ## [0.1.7] - 2026-02-14
15
27
 
16
28
  ### Changed
package/README.md CHANGED
@@ -17,16 +17,80 @@ Each entry file is automatically:
17
17
 
18
18
  ---
19
19
 
20
- ## 🚀 Usage
20
+ ## 📦 Install
21
+
22
+ ```bash
23
+ npm i -g @pc360/chlog
24
+ ```
25
+
26
+ ## ✅ After Installation
27
+
28
+ If `chlog` is not recognized after global install, add your npm global `bin` path to `PATH`.
29
+
30
+ 1. Get your npm prefix:
31
+
32
+ ```bash
33
+ npm get prefix
34
+ ```
35
+
36
+ 2. Use the output as `<prefix>`, then add this to your shell config:
37
+
38
+ ```bash
39
+ export PATH="$PATH:<prefix>/bin"
40
+ ```
41
+
42
+ For `zsh`, add it to `~/.zshrc`.
43
+ For `bash`, add it to `~/.bashrc`.
44
+
45
+ 3. Reload your shell config (or open a new terminal):
21
46
 
47
+ ```bash
48
+ source ~/.zshrc
49
+ # or
50
+ source ~/.bashrc
22
51
  ```
52
+
53
+ Then run:
54
+
55
+ ```bash
56
+ # Dry run (preview only)
57
+ chlog --type <added|changed|fixed|removed> \
58
+ --scope <scope> \
59
+ --message "<description>" \
60
+ [--frontend] \
61
+ --dry-run
62
+
63
+ # Dry run short form (preview only)
64
+ chlog -t <added|changed|fixed|removed> -s <scope> -m "<description>" [-f] -d
65
+
66
+ # Create entry
67
+ chlog --type <added|changed|fixed|removed> \
68
+ --scope <scope> \
69
+ --message "<description>" \
70
+ [--frontend]
71
+ ```
72
+
73
+ You can also run it without global install:
74
+
75
+ ```bash
23
76
  npx @pc360/chlog --type <added|changed|fixed|removed> \
24
- --scope <scope> \
25
- --message "<description>" \
26
- [--frontend]
77
+ --scope <scope> \
78
+ --message "<description>" \
79
+ [--frontend]
80
+ ```
81
+
82
+ ---
83
+
84
+ ## 🚀 Usage
85
+
86
+ ```bash
87
+ chlog --type <added|changed|fixed|removed> \
88
+ --scope <scope> \
89
+ --message "<description>" \
90
+ [--frontend]
27
91
 
28
92
  # Short form
29
- npx @pc360/chlog -t <added|changed|fixed|removed> -s <scope> -m "<description>" [-f]
93
+ chlog -t <added|changed|fixed|removed> -s <scope> -m "<description>" [-f]
30
94
  ```
31
95
 
32
96
  ---
@@ -41,6 +105,7 @@ npx @pc360/chlog -t <added|changed|fixed|removed> -s <scope> -m "<description>"
41
105
  | `-f, --frontend` | ❌ | Uses `[Front-End]` instead of `[Back-End]` |
42
106
  | `-d, --dry-run` | ❌ | Preview file creation without writing |
43
107
  | `-h, --help` | ❌ | Show help |
108
+ | `-v, --version` | ❌ | Show CLI version |
44
109
 
45
110
  ---
46
111
 
@@ -49,7 +114,7 @@ npx @pc360/chlog -t <added|changed|fixed|removed> -s <scope> -m "<description>"
49
114
  ### Back-End Change (Default)
50
115
 
51
116
  ```
52
- npx @pc360/chlog --type added --scope JES-33 --message "Add daily consolidated JE job"
117
+ chlog --type added --scope JES-33 --message "Add daily consolidated JE job"
53
118
  ```
54
119
 
55
120
  Creates:
@@ -69,7 +134,7 @@ File content:
69
134
  ### Front-End Change
70
135
 
71
136
  ```
72
- npx @pc360/chlog --type fixed --scope JES-45 --frontend --message "Fix table pagination issue"
137
+ chlog --type fixed --scope JES-45 --frontend --message "Fix table pagination issue"
73
138
  ```
74
139
 
75
140
  File content:
@@ -83,7 +148,7 @@ File content:
83
148
  ### Module-Based Scope
84
149
 
85
150
  ```
86
- npx @pc360/chlog --type changed --scope "Credit Validation" --message "Improve credit limit computation"
151
+ chlog --type changed --scope "Credit Validation" --message "Improve credit limit computation"
87
152
  ```
88
153
 
89
154
  File content:
@@ -153,7 +218,7 @@ Fix FR status blocking issue
153
218
  Preview without creating file:
154
219
 
155
220
  ```
156
- npx @pc360/chlog --type added --scope JES-99 --message "Test entry" --dry-run
221
+ chlog --type added --scope JES-99 --message "Test entry" --dry-run
157
222
  ```
158
223
 
159
224
  ---
package/bin/chlog.js CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  const fs = require("fs/promises");
5
5
  const path = require("path");
6
+ const { version } = require("../package.json");
6
7
 
7
8
  const {
8
9
  parseArgs,
@@ -39,6 +40,7 @@ Options:
39
40
  --tz "<iana>" Timezone (default: Asia/Manila)
40
41
  -d, --dry-run Preview only
41
42
  -h, --help Show help
43
+ -v, --version Show version
42
44
  `.trim();
43
45
  }
44
46
 
@@ -51,6 +53,11 @@ async function main() {
51
53
  process.exit(0);
52
54
  }
53
55
 
56
+ if (args.version) {
57
+ process.stdout.write(`${version}\n`);
58
+ process.exit(0);
59
+ }
60
+
54
61
  validateArgs(args);
55
62
 
56
63
  const timestamp = generateTimestamp(new Date(), args.tz);
package/lib/chlog-lib.js CHANGED
@@ -11,6 +11,7 @@ function parseArgs(argv) {
11
11
  frontend: false,
12
12
  dryRun: false,
13
13
  help: false,
14
+ version: false,
14
15
  };
15
16
 
16
17
  for (let i = 2; i < argv.length; i++) {
@@ -21,6 +22,11 @@ function parseArgs(argv) {
21
22
  break;
22
23
  }
23
24
 
25
+ if (arg === "-v" || arg === "--version") {
26
+ args.version = true;
27
+ break;
28
+ }
29
+
24
30
  if (arg === "--dry-run" || arg === "-d") {
25
31
  args.dryRun = true;
26
32
  continue;
package/lib/chlog-ui.js CHANGED
@@ -136,7 +136,7 @@ async function renderHelp(helpText) {
136
136
 
137
137
  const rendered = await renderInkCard(
138
138
  {
139
- title: "PC360 Changelog CLI - v0.1.7",
139
+ title: "PC360 Changelog CLI",
140
140
  subtitle: "Usage & options",
141
141
  lines: styledLines,
142
142
  tone: "info",
package/package.json CHANGED
@@ -1,16 +1,26 @@
1
1
  {
2
2
  "name": "@pc360/chlog",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "PC360 Changelog CLI Tool",
5
5
  "author": "aalmazan@pcdsi.ph",
6
6
  "bin": {
7
7
  "chlog": "bin/chlog.js"
8
8
  },
9
+ "files": [
10
+ "bin",
11
+ "lib",
12
+ "README.md",
13
+ "CHANGELOG.md"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
9
18
  "license": "UNLICENSED",
10
19
  "engines": {
11
20
  "node": ">=18"
12
21
  },
13
22
  "dependencies": {
23
+ "@pc360/chlog": "^0.1.7",
14
24
  "ink": "^4.4.1",
15
25
  "react": "^18.3.1"
16
26
  },
@@ -1,161 +0,0 @@
1
- "use strict";
2
-
3
- const test = require("node:test");
4
- const assert = require("node:assert/strict");
5
- const fs = require("fs");
6
- const os = require("os");
7
- const path = require("path");
8
- const { spawnSync } = require("child_process");
9
-
10
- const { generateTimestamp } = require("../lib/chlog-lib");
11
-
12
- const BIN_PATH = path.resolve(__dirname, "../bin/chlog.js");
13
-
14
- function createTempDir() {
15
- return fs.mkdtempSync(path.join(os.tmpdir(), "chlog-cli-"));
16
- }
17
-
18
- function runCli(args, cwd) {
19
- return spawnSync(process.execPath, [BIN_PATH, ...args], {
20
- cwd,
21
- encoding: "utf8",
22
- });
23
- }
24
-
25
- function cleanup(dir) {
26
- fs.rmSync(dir, { recursive: true, force: true });
27
- }
28
-
29
- test("CLI dry-run previews target path/content and exits 0", () => {
30
- const cwd = createTempDir();
31
-
32
- try {
33
- const res = runCli(
34
- [
35
- "--type",
36
- "added",
37
- "--scope",
38
- "JES-99",
39
- "--message",
40
- "Test entry",
41
- "--dry-run",
42
- ],
43
- cwd,
44
- );
45
-
46
- assert.equal(res.status, 0);
47
- assert.match(res.stdout, /\[Dry Run\]/);
48
- assert.match(
49
- res.stdout,
50
- /Would create: .*changelog[\/\\]unreleased[\/\\]added[\/\\]\d{14}/,
51
- );
52
- assert.match(res.stdout, /\[JES-99\] \[Back-End\] Test entry/);
53
- assert.equal(fs.existsSync(path.join(cwd, "changelog")), false);
54
- } finally {
55
- cleanup(cwd);
56
- }
57
- });
58
-
59
- test("CLI supports short flags for required values and toggles", () => {
60
- const cwd = createTempDir();
61
-
62
- try {
63
- const res = runCli(
64
- ["-t", "added", "-s", "JES-100", "-m", "Use short options", "-f", "-d"],
65
- cwd,
66
- );
67
-
68
- assert.equal(res.status, 0);
69
- assert.match(res.stdout, /\[Dry Run\]/);
70
- assert.match(
71
- res.stdout,
72
- /Would create: .*changelog[\/\\]unreleased[\/\\]added[\/\\]\d{14}/,
73
- );
74
- assert.match(res.stdout, /\[JES-100\] \[Front-End\] Use short options/);
75
- assert.equal(fs.existsSync(path.join(cwd, "changelog")), false);
76
- } finally {
77
- cleanup(cwd);
78
- }
79
- });
80
-
81
- test("CLI creates changelog file with expected content and exits 0", () => {
82
- const cwd = createTempDir();
83
-
84
- try {
85
- const res = runCli(
86
- [
87
- "--type",
88
- "fixed",
89
- "--scope",
90
- "JES-45",
91
- "--message",
92
- "Fix pagination",
93
- "--frontend",
94
- ],
95
- cwd,
96
- );
97
-
98
- assert.equal(res.status, 0);
99
- assert.match(
100
- res.stdout,
101
- /Created: changelog[\/\\]unreleased[\/\\]fixed[\/\\]\d{14}/,
102
- );
103
-
104
- const entryDir = path.join(cwd, "changelog", "unreleased", "fixed");
105
- const files = fs.readdirSync(entryDir);
106
- assert.equal(files.length, 1);
107
- assert.match(files[0], /^\d{14}$/);
108
-
109
- const content = fs.readFileSync(path.join(entryDir, files[0]), "utf8");
110
- assert.equal(content, "[JES-45] [Front-End] Fix pagination\n");
111
- } finally {
112
- cleanup(cwd);
113
- }
114
- });
115
-
116
- test("CLI returns exit code 1 for missing required flags", () => {
117
- const cwd = createTempDir();
118
-
119
- try {
120
- const res = runCli(["--type", "added", "--scope", "JES-1"], cwd);
121
-
122
- assert.equal(res.status, 1);
123
- assert.match(res.stderr, /--message is required/);
124
- assert.match(res.stderr, /Run: chlog --help/);
125
- } finally {
126
- cleanup(cwd);
127
- }
128
- });
129
-
130
- test("CLI surfaces timestamp collision errors and exits 1", () => {
131
- const cwd = createTempDir();
132
-
133
- try {
134
- const entryDir = path.join(cwd, "changelog", "unreleased", "changed");
135
- fs.mkdirSync(entryDir, { recursive: true });
136
-
137
- const now = Date.now();
138
- for (let offset = -5; offset <= 5; offset++) {
139
- const ts = generateTimestamp(new Date(now + offset * 1000), "Asia/Manila");
140
- fs.writeFileSync(path.join(entryDir, ts), "existing\n", "utf8");
141
- }
142
-
143
- const res = runCli(
144
- [
145
- "--type",
146
- "changed",
147
- "--scope",
148
- "JES-77",
149
- "--message",
150
- "Update report formatting",
151
- ],
152
- cwd,
153
- );
154
-
155
- assert.equal(res.status, 1);
156
- assert.match(res.stderr, /EEXIST|file already exists/i);
157
- assert.match(res.stderr, /Run: chlog --help/);
158
- } finally {
159
- cleanup(cwd);
160
- }
161
- });
@@ -1,170 +0,0 @@
1
- "use strict";
2
-
3
- const test = require("node:test");
4
- const assert = require("node:assert/strict");
5
-
6
- const {
7
- parseArgs,
8
- validateArgs,
9
- generateTimestamp,
10
- buildLine,
11
- } = require("../lib/chlog-lib");
12
-
13
- test("parseArgs parses required flags and defaults", () => {
14
- const args = parseArgs([
15
- "node",
16
- "chlog",
17
- "--type",
18
- "added",
19
- "--scope",
20
- "JES-33",
21
- "--message",
22
- "Hello",
23
- ]);
24
-
25
- assert.equal(args.type, "added");
26
- assert.equal(args.scope, "JES-33");
27
- assert.equal(args.message, "Hello");
28
- assert.equal(args.tz, "Asia/Manila");
29
- assert.equal(args.frontend, false);
30
- assert.equal(args.dryRun, false);
31
- assert.equal(args.help, false);
32
- });
33
-
34
- test("parseArgs supports --frontend and --dry-run", () => {
35
- const args = parseArgs([
36
- "node",
37
- "chlog",
38
- "--type",
39
- "fixed",
40
- "--scope",
41
- "JES-45",
42
- "--message",
43
- "Fix thing",
44
- "--frontend",
45
- "--dry-run",
46
- ]);
47
-
48
- assert.equal(args.frontend, true);
49
- assert.equal(args.dryRun, true);
50
- });
51
-
52
- test("parseArgs supports short flags", () => {
53
- const args = parseArgs([
54
- "node",
55
- "chlog",
56
- "-t",
57
- "changed",
58
- "-s",
59
- "JES-50",
60
- "-m",
61
- "Update validation flow",
62
- "-f",
63
- "-d",
64
- ]);
65
-
66
- assert.equal(args.type, "changed");
67
- assert.equal(args.scope, "JES-50");
68
- assert.equal(args.message, "Update validation flow");
69
- assert.equal(args.frontend, true);
70
- assert.equal(args.dryRun, true);
71
- });
72
-
73
- test("parseArgs supports mixed long/short flags", () => {
74
- const args = parseArgs([
75
- "node",
76
- "chlog",
77
- "--type",
78
- "fixed",
79
- "-s",
80
- "JES-88",
81
- "--message",
82
- "Mixed flags",
83
- "-d",
84
- ]);
85
-
86
- assert.equal(args.type, "fixed");
87
- assert.equal(args.scope, "JES-88");
88
- assert.equal(args.message, "Mixed flags");
89
- assert.equal(args.dryRun, true);
90
- assert.equal(args.frontend, false);
91
- });
92
-
93
- test("parseArgs supports -h short help flag", () => {
94
- const args = parseArgs(["node", "chlog", "-h"]);
95
- assert.equal(args.help, true);
96
- });
97
-
98
- test("validateArgs throws if missing scope", () => {
99
- assert.throws(
100
- () =>
101
- validateArgs({
102
- type: "added",
103
- scope: null,
104
- message: "x",
105
- tz: "Asia/Manila",
106
- }),
107
- /--scope is required/,
108
- );
109
- });
110
-
111
- test("validateArgs throws if invalid type", () => {
112
- assert.throws(
113
- () =>
114
- validateArgs({
115
- type: "nope",
116
- scope: "JES-1",
117
- message: "x",
118
- tz: "Asia/Manila",
119
- }),
120
- /--type must be one of/,
121
- );
122
- });
123
-
124
- test("validateArgs throws if invalid timezone", () => {
125
- assert.throws(
126
- () =>
127
- validateArgs({
128
- type: "added",
129
- scope: "JES-1",
130
- message: "x",
131
- tz: "Not/A_Timezone",
132
- }),
133
- /Invalid time zone|timeZone/i,
134
- );
135
- });
136
-
137
- test("generateTimestamp returns 14 digits", () => {
138
- const ts = generateTimestamp(new Date("2026-02-13T00:00:00Z"), "Asia/Manila");
139
- assert.match(ts, /^\d{14}$/);
140
- });
141
-
142
- test("buildLine defaults to [Back-End] prefix and includes scope", () => {
143
- const line = buildLine({
144
- scope: "JES-33",
145
- message: "Add daily consolidated JE job",
146
- frontend: false,
147
- });
148
-
149
- assert.equal(line, "[JES-33] [Back-End] Add daily consolidated JE job\n");
150
- });
151
-
152
- test("buildLine uses [Front-End] when frontend=true", () => {
153
- const line = buildLine({
154
- scope: "JES-45",
155
- message: "Fix pagination",
156
- frontend: true,
157
- });
158
-
159
- assert.equal(line, "[JES-45] [Front-End] Fix pagination\n");
160
- });
161
-
162
- test("buildLine does not double-prefix if message already starts with label", () => {
163
- const line = buildLine({
164
- scope: "JES-99",
165
- message: "[Back-End] Already prefixed",
166
- frontend: false,
167
- });
168
-
169
- assert.equal(line, "[JES-99] [Back-End] Already prefixed\n");
170
- });