@pc360/chlog 0.1.7 → 0.1.8
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 +6 -0
- package/lib/chlog-ui.js +1 -1
- package/package.json +11 -1
- package/test/chlog-cli.integration.test.js +0 -161
- package/test/chlog-lib.test.js +0 -170
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,12 @@ 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.8] - 2026-02-14
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Update docs
|
|
19
|
+
|
|
14
20
|
## [0.1.7] - 2026-02-14
|
|
15
21
|
|
|
16
22
|
### Changed
|
package/lib/chlog-ui.js
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pc360/chlog",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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
|
-
});
|
package/test/chlog-lib.test.js
DELETED
|
@@ -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
|
-
});
|