@git.zone/cli 6.11.0 → 6.13.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/gitzone.cli.js +6 -1
- package/dist_ts/helpers.changelog.d.ts +4 -0
- package/dist_ts/helpers.changelog.js +73 -24
- package/dist_ts/helpers.climode.js +47 -3
- package/dist_ts/helpers.workflow.d.ts +2 -2
- package/dist_ts/helpers.workflow.js +42 -6
- package/dist_ts/mod_commit/helpers.manual.d.ts +10 -0
- package/dist_ts/mod_commit/helpers.manual.js +97 -0
- package/dist_ts/mod_commit/index.js +156 -35
- package/dist_ts/mod_commit/mod.plugins.d.ts +7 -7
- package/dist_ts/mod_commit/mod.plugins.js +9 -8
- package/dist_ts/mod_release/helpers.releasepreparation.d.ts +2 -0
- package/dist_ts/mod_release/helpers.releasepreparation.js +12 -8
- package/dist_ts/mod_release/index.js +23 -4
- package/dist_ts/mod_standard/index.js +8 -2
- package/dist_ts/mod_testing/classes.commands.d.ts +27 -0
- package/dist_ts/mod_testing/classes.commands.js +407 -0
- package/dist_ts/mod_testing/classes.runtime.d.ts +37 -0
- package/dist_ts/mod_testing/classes.runtime.js +252 -0
- package/dist_ts/mod_testing/index.d.ts +4 -0
- package/dist_ts/mod_testing/index.js +149 -0
- package/dist_ts/plugins.d.ts +7 -1
- package/dist_ts/plugins.js +6 -2
- package/package.json +3 -1
- package/readme.md +161 -10
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/gitzone.cli.ts +5 -0
- package/ts/helpers.changelog.ts +108 -32
- package/ts/helpers.climode.ts +51 -2
- package/ts/helpers.workflow.ts +46 -5
- package/ts/mod_commit/helpers.manual.ts +156 -0
- package/ts/mod_commit/index.ts +272 -53
- package/ts/mod_commit/mod.plugins.ts +8 -7
- package/ts/mod_release/helpers.releasepreparation.ts +17 -7
- package/ts/mod_release/index.ts +26 -2
- package/ts/mod_standard/index.ts +7 -1
- package/ts/mod_testing/classes.commands.ts +620 -0
- package/ts/mod_testing/classes.runtime.ts +310 -0
- package/ts/mod_testing/index.ts +197 -0
- package/ts/plugins.ts +10 -0
package/readme.md
CHANGED
|
@@ -107,6 +107,12 @@ gitzone commit -ytbp
|
|
|
107
107
|
|
|
108
108
|
# Show the resolved workflow without mutating anything
|
|
109
109
|
gitzone commit --plan
|
|
110
|
+
|
|
111
|
+
# Supply a message and changelog entry without AI
|
|
112
|
+
gitzone commit -y --message 'fix(cache): expire stale entries' --changelog 'Expired entries are removed before lookup.'
|
|
113
|
+
|
|
114
|
+
# Preserve a multiline message and custom Pending Markdown
|
|
115
|
+
gitzone commit -y --message-file /tmp/commit.txt --changelog-file /tmp/pending.md
|
|
110
116
|
```
|
|
111
117
|
|
|
112
118
|
The commit flow:
|
|
@@ -128,6 +134,43 @@ Commit flags:
|
|
|
128
134
|
| `-p`, `--push` | Push after the source commit |
|
|
129
135
|
| `-f`, `--format` | Run `gitzone format --write` before commit |
|
|
130
136
|
| `--plan` | Show resolved workflow only |
|
|
137
|
+
| `-m`, `--message <text>` | Use a complete semantic commit message without AI |
|
|
138
|
+
| `--message-file <path>` | Read the complete message from a UTF-8 file |
|
|
139
|
+
| `--changelog <text>` | Supply custom Pending text with a manual message |
|
|
140
|
+
| `--changelog-file <path>` | Read custom Pending text from a UTF-8 file |
|
|
141
|
+
|
|
142
|
+
Manual messages start with `type(scope): description`; the scope is optional.
|
|
143
|
+
Conventional `!` subjects and `BREAKING CHANGE:` footers are supported. The entire
|
|
144
|
+
message, including its body, is passed literally to Git. File inputs preserve
|
|
145
|
+
multiline text; CRLF becomes LF and terminal newlines are normalized. Each input
|
|
146
|
+
is limited to 128 KiB. Use `--message` or `--message-file` once, and at most one
|
|
147
|
+
changelog option. Changelog overrides require a manual message.
|
|
148
|
+
|
|
149
|
+
Without a changelog override, GitZone derives the Pending entry from the semantic
|
|
150
|
+
subject and body. Custom text becomes an entry in the message's semantic bucket.
|
|
151
|
+
For complete Markdown, supply a Pending fragment such as:
|
|
152
|
+
|
|
153
|
+
```markdown
|
|
154
|
+
### Fixes
|
|
155
|
+
|
|
156
|
+
- Remove expired entries before lookup.
|
|
157
|
+
- Preserve entries whose validity has not expired.
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Fragments may contain `### Breaking Changes`, `### Features`, `### Fixes`,
|
|
161
|
+
`### Documentation`, and `### Maintenance`. Omit the document title, `## Pending`,
|
|
162
|
+
and version headings. GitZone merges entries into the existing Pending buckets
|
|
163
|
+
and preserves previous entries and release history. Pending headings continue to
|
|
164
|
+
determine the release bump; a breaking message requires a Breaking Changes entry,
|
|
165
|
+
and either a breaking message or new breaking changelog text requires the usual
|
|
166
|
+
interactive confirmation or `-y --allow-breaking`.
|
|
167
|
+
|
|
168
|
+
Manual mode replaces the AI analysis step with `manual`. It keeps the configured
|
|
169
|
+
format, test, build, staging and push behavior. `--plan` validates and displays the
|
|
170
|
+
message and changelog without mutation or AI access. A clean repository remains
|
|
171
|
+
unchanged. Input is validated before workflow steps run; it never falls back to AI
|
|
172
|
+
after an input error. Place input files outside the repository if they should not
|
|
173
|
+
be included by the existing stage-all workflow.
|
|
131
174
|
|
|
132
175
|
`-r` is intentionally not part of commit anymore. Use `gitzone release`.
|
|
133
176
|
|
|
@@ -414,34 +457,46 @@ Resume probes remotely observable targets before acting. Exact state is accepted
|
|
|
414
457
|
|
|
415
458
|
Schema 1 resumes final Git release-ref and npm publication after the journal is atomically installed. Schema 2 additionally resumes Docker qualification, ordered promotion, and cleanup. Schema 3 resumes the complete npm package set. `--merge` remains available only for non-Docker releases because its pre-release Git push would violate qualification-before-publication ordering.
|
|
416
459
|
|
|
417
|
-
For a root npm
|
|
418
|
-
but whose build or pack failed before journal
|
|
460
|
+
For a Git release with root npm and/or Docker targets whose local release commit
|
|
461
|
+
and annotated tag already exist, but whose build or pack failed before journal
|
|
462
|
+
installation, use:
|
|
419
463
|
|
|
420
464
|
```bash
|
|
421
465
|
gitzone release recover 6.0.0 --plan
|
|
422
466
|
gitzone release recover 6.0.0 -y
|
|
423
467
|
```
|
|
424
468
|
|
|
425
|
-
Recovery supports configured Git
|
|
426
|
-
`main`, the exact annotated tag at that commit, matching package and completed
|
|
469
|
+
Recovery supports configured Git with root npm and/or Docker targets. It requires
|
|
470
|
+
clean `main`, the exact annotated tag at that commit, matching package and completed
|
|
427
471
|
changelog versions, and no pending changes. The metadata commit must not change
|
|
428
472
|
release configuration. It also checks remote ancestry, requires the release tag
|
|
429
473
|
to be absent remotely, and requires an anonymous HTTP 404 for the version at every
|
|
430
|
-
npm registry. Published or uncertain state cannot be
|
|
431
|
-
journal.
|
|
474
|
+
npm registry when npm is selected. Published or uncertain Git/npm state cannot be
|
|
475
|
+
adopted without its original journal. Tspublish and Gitea asset preparation recovery
|
|
476
|
+
are not supported.
|
|
432
477
|
|
|
433
478
|
The first attempt records the exact refs, destination and resolved workflow under
|
|
434
479
|
the common Git directory in `gitzone/releases/v1/v<version>.preparation.json`.
|
|
480
|
+
For Docker, this binding also includes the exact canonical qualification request.
|
|
435
481
|
Retries must match that binding. Recovery creates a disposable detached worktree
|
|
436
482
|
from the tagged commit, runs `pnpm install --frozen-lockfile`, and runs the configured
|
|
437
483
|
tests and build before packing. Ignored runtime data and local project secrets are
|
|
438
484
|
not copied. A build that depends on those files must be made reproducible through
|
|
439
485
|
the project's normal configuration before it can recover.
|
|
440
486
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
487
|
+
Prepared npm artifacts are installed through the normal journal API. Docker
|
|
488
|
+
recovery verifies the project-local tSDocker capabilities and configuration before
|
|
489
|
+
preparation and validates again before installing a schema-2 journal. Its complete
|
|
490
|
+
qualification, including a fresh build and configured image tests, runs from the
|
|
491
|
+
unchanged canonical checkout before Git or npm publication. Candidate state stays
|
|
492
|
+
at that stable project identity for later resume; images from the disposable
|
|
493
|
+
preflight build are not adopted. Docker destinations retain the normal qualified
|
|
494
|
+
digest, observed alias predecessor, probe and conflict checks.
|
|
495
|
+
|
|
496
|
+
Recovery never creates another version or moves refs. Once the journal exists,
|
|
497
|
+
another `recover` call uses `resume`
|
|
498
|
+
without repeating preparation. Any unfinished Docker qualification remains part
|
|
499
|
+
of the normal resume workflow. Use `resume --recover-attempt` for an interrupted
|
|
445
500
|
publisher that still owns a journaled attempt, after proving that process stopped.
|
|
446
501
|
|
|
447
502
|
Concurrent preparations are excluded by `v<version>.prepare.lock`. A process crash
|
|
@@ -1044,6 +1099,102 @@ gitzone --version --json
|
|
|
1044
1099
|
in legacy global roots, provided the active root already supplies them and no
|
|
1045
1100
|
command shim still points there.
|
|
1046
1101
|
|
|
1102
|
+
## Approved Testing Domains
|
|
1103
|
+
|
|
1104
|
+
`gitzone testing` uses the testing API in dcrouter 19.1.1 or later. An operator
|
|
1105
|
+
first enables an explicit testing-zone policy, provisions a machine registration,
|
|
1106
|
+
and approves each exact hostname requested by that registration. Approved grants
|
|
1107
|
+
survive credential rotation. Wildcards, parent domains, arbitrary TXT records,
|
|
1108
|
+
and production routes are outside this command's authority.
|
|
1109
|
+
|
|
1110
|
+
Inject `GITZONE_TESTING_BASE_URL` and `GITZONE_TESTING_TOKEN` from your environment
|
|
1111
|
+
or secret manager. Admin commands select `GITZONE_TESTING_ADMIN_TOKEN` instead.
|
|
1112
|
+
The URL must be an HTTPS origin; plain HTTP is accepted only on loopback for
|
|
1113
|
+
isolated tests. Credentials are never accepted as command arguments or saved to
|
|
1114
|
+
project/global configuration. `--token-stdin` reads at most 8192 bytes from a
|
|
1115
|
+
non-terminal stdin and requires the selected environment credential to be absent.
|
|
1116
|
+
|
|
1117
|
+
```sh
|
|
1118
|
+
gitzone testing --help
|
|
1119
|
+
gitzone help testing --json
|
|
1120
|
+
gitzone testing whoami --json
|
|
1121
|
+
gitzone testing zone list --limit 25 --json
|
|
1122
|
+
gitzone testing grant request --zone ZONE_ID --hostname alice.testing.example.com --idempotency-key grant-alice-1 --json
|
|
1123
|
+
gitzone testing grant status --grant GRANT_ID --json
|
|
1124
|
+
gitzone testing cert ensure --grant GRANT_ID --idempotency-key cert-alice-1 --wait --json
|
|
1125
|
+
gitzone testing cert status --job JOB_ID --json
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
Mutation keys are supplied explicitly. Repeat the same key and payload after a
|
|
1129
|
+
lost response; use a new key only for a new operation. Certificate requests reuse
|
|
1130
|
+
usable cached material. `--wait` follows queued/running/retry-wait jobs while
|
|
1131
|
+
respecting their polling and retry times. `--timeout-ms` bounds acquisition and
|
|
1132
|
+
requests (default five minutes, maximum one hour). A local deadline or signal
|
|
1133
|
+
does not cancel durable server work. Poll the returned operation ID or repeat
|
|
1134
|
+
the original idempotency key to find its outcome. Unknown or abandoned outcomes
|
|
1135
|
+
require operator recovery and never trigger automatic mutation resubmission.
|
|
1136
|
+
|
|
1137
|
+
Run a development server with disposable certificate files:
|
|
1138
|
+
|
|
1139
|
+
```sh
|
|
1140
|
+
gitzone testing cert run --grant GRANT_ID --idempotency-key cert-alice-1 -- node server.js --port 8443
|
|
1141
|
+
```
|
|
1142
|
+
|
|
1143
|
+
The child receives `GITZONE_TESTING_CERTIFICATE_FILE`,
|
|
1144
|
+
`GITZONE_TESTING_PRIVATE_KEY_FILE`, and `GITZONE_TESTING_HOSTNAME`. Its environment
|
|
1145
|
+
excludes the parent's `GITZONE_TESTING_*` values, including both credentials.
|
|
1146
|
+
The directory has mode 0700 and both files have mode 0600. GitZone invokes the
|
|
1147
|
+
program directly, preserves every argument after `--`, returns its exit status,
|
|
1148
|
+
and removes the directory after exit or termination. SIGINT/SIGTERM are forwarded
|
|
1149
|
+
to the child; a child that does not stop is killed after five seconds. JSON output
|
|
1150
|
+
is rejected for `cert run` because child stdout is inherited. Certificate renewal
|
|
1151
|
+
is on demand: this command obtains material once; restart it to obtain renewed
|
|
1152
|
+
material when due. It does not save a permanent certificate cache.
|
|
1153
|
+
|
|
1154
|
+
DNS operations are restricted to records owned by the approved grant. Use `new`
|
|
1155
|
+
for creation and the current record revision for replacement/deletion:
|
|
1156
|
+
|
|
1157
|
+
```sh
|
|
1158
|
+
gitzone testing dns upsert --grant GRANT_ID --record-key web-v4 --revision new --type A --value 192.0.2.10 --ttl 60 --idempotency-key dns-web-1 --wait --json
|
|
1159
|
+
gitzone testing dns list --grant GRANT_ID --json
|
|
1160
|
+
gitzone testing dns delete --grant GRANT_ID --record-key web-v4 --revision 1 --idempotency-key dns-delete-1 --wait --json
|
|
1161
|
+
gitzone testing dns status --mutation MUTATION_ID --json
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
Admin enrollment and rotation require a caller-preopened writable non-terminal
|
|
1165
|
+
descriptor of at least 3. Supply it through the parent secret-manager integration;
|
|
1166
|
+
GitZone writes exactly the new token plus a newline to that descriptor, and only
|
|
1167
|
+
registration metadata to ordinary output. No credential can be retrieved again
|
|
1168
|
+
after a lost delivery; list registrations and rotate the relevant credential.
|
|
1169
|
+
|
|
1170
|
+
```sh
|
|
1171
|
+
# Descriptor 3 must already be connected to the caller's secret store.
|
|
1172
|
+
gitzone testing admin registration create --name developer-alice --expires-at 2027-01-01T00:00:00Z --idempotency-key enroll-alice-1 --secret-fd 3 --json
|
|
1173
|
+
gitzone testing admin registration list --json
|
|
1174
|
+
gitzone testing admin registration rotate --registration REGISTRATION_ID --generation 1 --expires-at 2027-01-01T00:00:00Z --secret-fd 3 --json
|
|
1175
|
+
gitzone testing admin zone put --domain DOMAIN_ID --revision new --enabled true --record-types A,AAAA,CNAME --min-ttl 60 --max-ttl 3600 --max-grants 25 --json
|
|
1176
|
+
gitzone testing admin grant list --state pending --json
|
|
1177
|
+
gitzone testing admin grant review --grant GRANT_ID --revision 1 --action approve --reason 'Approved development hostname' --json
|
|
1178
|
+
```
|
|
1179
|
+
|
|
1180
|
+
`admin registration revoke` and `admin grant review --action revoke` require a
|
|
1181
|
+
revision and reason. Revocation blocks future access and schedules cleanup of
|
|
1182
|
+
proven-owned DNS records; already delivered keys cannot be recalled. Operator
|
|
1183
|
+
recovery remains revision checked and audited:
|
|
1184
|
+
|
|
1185
|
+
```sh
|
|
1186
|
+
gitzone testing admin recovery list --kind certificate --state indeterminate --json
|
|
1187
|
+
gitzone testing admin recovery status --kind certificate --operation JOB_ID --json
|
|
1188
|
+
gitzone testing admin recovery action --kind certificate --operation JOB_ID --revision 3 --action recheck --reason 'Inspect interrupted issuance' --idempotency-key recovery-1 --json
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
For DNS recovery, `--operation` may identify a mutation or a grant's retained
|
|
1192
|
+
cleanup operation. Only actions listed by the server are supported. Abandonment
|
|
1193
|
+
retains unknown effects and their reservations; it does not make them safe to
|
|
1194
|
+
repeat. Lists accept `--after` and `--limit` (25 by default, at most 100) and return
|
|
1195
|
+
`nextAfterId`. Exit codes are 0 for success/admitted work, 1 for failure or an
|
|
1196
|
+
unresolved terminal operation, 2 for invalid input, and 130/143 for interruption.
|
|
1197
|
+
|
|
1047
1198
|
## Templates
|
|
1048
1199
|
|
|
1049
1200
|
Start new projects with built-in scaffolds:
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@git.zone/cli',
|
|
6
|
-
version: '6.
|
|
6
|
+
version: '6.13.1',
|
|
7
7
|
description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
|
|
8
8
|
}
|
package/ts/gitzone.cli.ts
CHANGED
|
@@ -95,6 +95,11 @@ const runParsedCommand = async (argvArg: any): Promise<void> => {
|
|
|
95
95
|
await modServices.run(argvArg);
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
|
+
case "testing": {
|
|
99
|
+
const modTesting = await import("./mod_testing/index.js");
|
|
100
|
+
await modTesting.run(argvArg);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
98
103
|
default: {
|
|
99
104
|
const modStandard = await import("./mod_standard/index.js");
|
|
100
105
|
await modStandard.run(argvArg);
|
package/ts/helpers.changelog.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import * as plugins from "./plugins.js";
|
|
2
2
|
|
|
3
3
|
export type TChangelogBucket =
|
|
4
|
-
|
|
5
|
-
| "Features"
|
|
6
|
-
| "Fixes"
|
|
7
|
-
| "Documentation"
|
|
8
|
-
| "Maintenance";
|
|
4
|
+
"Breaking Changes" | "Features" | "Fixes" | "Documentation" | "Maintenance";
|
|
9
5
|
|
|
10
6
|
export interface IChangelogEntry {
|
|
11
7
|
type: string;
|
|
@@ -25,7 +21,7 @@ interface IChangelogSection {
|
|
|
25
21
|
end: number;
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
const bucketForCommitType = (commitType: string): TChangelogBucket => {
|
|
24
|
+
export const bucketForCommitType = (commitType: string): TChangelogBucket => {
|
|
29
25
|
switch (commitType) {
|
|
30
26
|
case "BREAKING CHANGE":
|
|
31
27
|
return "Breaking Changes";
|
|
@@ -44,18 +40,30 @@ const readChangelog = async (filePath: string): Promise<string> => {
|
|
|
44
40
|
if (!(await plugins.smartfs.file(filePath).exists())) {
|
|
45
41
|
return "# Changelog\n\n";
|
|
46
42
|
}
|
|
47
|
-
return (await plugins.smartfs
|
|
43
|
+
return (await plugins.smartfs
|
|
44
|
+
.file(filePath)
|
|
45
|
+
.encoding("utf8")
|
|
46
|
+
.read()) as string;
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
const writeChangelog = async (
|
|
51
|
-
|
|
49
|
+
const writeChangelog = async (
|
|
50
|
+
filePath: string,
|
|
51
|
+
content: string,
|
|
52
|
+
): Promise<void> => {
|
|
53
|
+
await plugins.smartfs
|
|
54
|
+
.file(filePath)
|
|
55
|
+
.encoding("utf8")
|
|
56
|
+
.write(content.endsWith("\n") ? content : `${content}\n`);
|
|
52
57
|
};
|
|
53
58
|
|
|
54
59
|
const findPendingSection = (
|
|
55
60
|
content: string,
|
|
56
61
|
sectionName: string,
|
|
57
62
|
): IChangelogSection | null => {
|
|
58
|
-
const headingRegex = new RegExp(
|
|
63
|
+
const headingRegex = new RegExp(
|
|
64
|
+
`^##\\s+${sectionName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`,
|
|
65
|
+
"m",
|
|
66
|
+
);
|
|
59
67
|
const match = headingRegex.exec(content);
|
|
60
68
|
if (!match || match.index === undefined) {
|
|
61
69
|
return null;
|
|
@@ -64,7 +72,9 @@ const findPendingSection = (
|
|
|
64
72
|
const bodyStart = match.index + match[0].length;
|
|
65
73
|
const rest = content.slice(bodyStart);
|
|
66
74
|
const nextHeadingMatch = /^##\s+/m.exec(rest);
|
|
67
|
-
const end = nextHeadingMatch
|
|
75
|
+
const end = nextHeadingMatch
|
|
76
|
+
? bodyStart + nextHeadingMatch.index
|
|
77
|
+
: content.length;
|
|
68
78
|
return { start: match.index, bodyStart, end };
|
|
69
79
|
};
|
|
70
80
|
|
|
@@ -95,30 +105,89 @@ export const appendPendingChangelogEntry = async (
|
|
|
95
105
|
sectionName: string,
|
|
96
106
|
entry: IChangelogEntry,
|
|
97
107
|
): Promise<void> => {
|
|
98
|
-
let content = await ensurePendingSection(filePath, sectionName);
|
|
99
|
-
const pendingSection = findPendingSection(content, sectionName)!;
|
|
100
|
-
let pendingBody = content.slice(pendingSection.bodyStart, pendingSection.end);
|
|
101
108
|
const bucket = bucketForCommitType(entry.type);
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
const entryLines = [
|
|
110
|
+
`- ${entry.message}${entry.scope ? ` (${entry.scope})` : ""}`,
|
|
111
|
+
];
|
|
105
112
|
for (const detail of entry.details || []) {
|
|
106
113
|
entryLines.push(` - ${detail}`);
|
|
107
114
|
}
|
|
108
115
|
const renderedEntry = entryLines.join("\n");
|
|
116
|
+
await appendPendingChangelogMarkdown(
|
|
117
|
+
filePath,
|
|
118
|
+
sectionName,
|
|
119
|
+
`### ${bucket}\n\n${renderedEntry}`,
|
|
120
|
+
);
|
|
121
|
+
};
|
|
109
122
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
/** A Pending fragment contains canonical buckets, never the document/version headings. */
|
|
124
|
+
export const validatePendingChangelogMarkdown = (markdown: string): void => {
|
|
125
|
+
const headings = [...markdown.matchAll(/^#{1,3}\s+.*$/gm)].map(
|
|
126
|
+
(match) => match[0],
|
|
127
|
+
);
|
|
128
|
+
const allowed = new Set(
|
|
129
|
+
[
|
|
130
|
+
"Breaking Changes",
|
|
131
|
+
"Features",
|
|
132
|
+
"Fixes",
|
|
133
|
+
"Documentation",
|
|
134
|
+
"Maintenance",
|
|
135
|
+
].map((bucket) => `### ${bucket}`),
|
|
136
|
+
);
|
|
137
|
+
if (
|
|
138
|
+
!markdown.startsWith("### ") ||
|
|
139
|
+
headings.length === 0 ||
|
|
140
|
+
headings.some((heading) => !allowed.has(heading))
|
|
141
|
+
) {
|
|
142
|
+
throw new Error(
|
|
143
|
+
"Changelog fragments must use canonical ### bucket headings, without title, Pending or version headings.",
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
for (const block of markdown.split(/^### .+\n?/m).slice(1)) {
|
|
147
|
+
if (!block.trim())
|
|
148
|
+
throw new Error("Changelog buckets must contain an entry.");
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const appendPendingChangelogMarkdown = async (
|
|
153
|
+
filePath: string,
|
|
154
|
+
sectionName: string,
|
|
155
|
+
markdown: string,
|
|
156
|
+
): Promise<void> => {
|
|
157
|
+
validatePendingChangelogMarkdown(markdown);
|
|
158
|
+
let content = await ensurePendingSection(filePath, sectionName);
|
|
159
|
+
const pendingSection = findPendingSection(content, sectionName)!;
|
|
160
|
+
let pendingBody = content.slice(pendingSection.bodyStart, pendingSection.end);
|
|
161
|
+
const sections = [...markdown.matchAll(/^### (.+)\n/gm)];
|
|
162
|
+
for (let index = 0; index < sections.length; index++) {
|
|
163
|
+
const section = sections[index];
|
|
164
|
+
const bucket = section[1];
|
|
165
|
+
const bucketHeading = `### ${bucket}`;
|
|
166
|
+
const renderedEntry = markdown
|
|
167
|
+
.slice(
|
|
168
|
+
section.index! + section[0].length,
|
|
169
|
+
sections[index + 1]?.index ?? markdown.length,
|
|
170
|
+
)
|
|
171
|
+
.trim();
|
|
172
|
+
|
|
173
|
+
const bucketRegex = new RegExp(
|
|
174
|
+
`^###\\s+${bucket.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`,
|
|
175
|
+
"m",
|
|
176
|
+
);
|
|
177
|
+
const bucketMatch = bucketRegex.exec(pendingBody);
|
|
178
|
+
if (!bucketMatch || bucketMatch.index === undefined) {
|
|
179
|
+
pendingBody = `${pendingBody.trimEnd()}\n\n${bucketHeading}\n\n${renderedEntry}\n`;
|
|
180
|
+
} else {
|
|
181
|
+
const bucketBodyStart = bucketMatch.index + bucketMatch[0].length;
|
|
182
|
+
const afterBucket = pendingBody.slice(bucketBodyStart);
|
|
183
|
+
const nextBucketMatch = /^###\s+/m.exec(afterBucket);
|
|
184
|
+
const insertAt = nextBucketMatch
|
|
185
|
+
? bucketBodyStart + nextBucketMatch.index
|
|
186
|
+
: pendingBody.length;
|
|
187
|
+
const beforeInsert = pendingBody.slice(0, insertAt).trimEnd();
|
|
188
|
+
const afterInsert = pendingBody.slice(insertAt).replace(/^\n+/, "");
|
|
189
|
+
pendingBody = `${beforeInsert}\n${renderedEntry}\n\n${afterInsert}`;
|
|
190
|
+
}
|
|
122
191
|
}
|
|
123
192
|
|
|
124
193
|
content = `${content.slice(0, pendingSection.bodyStart)}\n${pendingBody.trim()}\n\n${content.slice(pendingSection.end).replace(/^\n+/, "")}`;
|
|
@@ -140,7 +209,9 @@ export const readPendingChangelog = async (
|
|
|
140
209
|
};
|
|
141
210
|
};
|
|
142
211
|
|
|
143
|
-
export const inferVersionTypeFromPending = (
|
|
212
|
+
export const inferVersionTypeFromPending = (
|
|
213
|
+
pendingBlock: string,
|
|
214
|
+
): "patch" | "minor" | "major" => {
|
|
144
215
|
if (/^###\s+Breaking Changes\s*$/m.test(pendingBlock)) {
|
|
145
216
|
return "major";
|
|
146
217
|
}
|
|
@@ -162,7 +233,9 @@ export const movePendingToVersion = async (
|
|
|
162
233
|
if (!pendingSection) {
|
|
163
234
|
throw new Error("No pending changelog entries. Nothing to release.");
|
|
164
235
|
}
|
|
165
|
-
const pendingBlock = content
|
|
236
|
+
const pendingBlock = content
|
|
237
|
+
.slice(pendingSection.bodyStart, pendingSection.end)
|
|
238
|
+
.trim();
|
|
166
239
|
if (!pendingBlock) {
|
|
167
240
|
throw new Error("No pending changelog entries. Nothing to release.");
|
|
168
241
|
}
|
|
@@ -171,7 +244,10 @@ export const movePendingToVersion = async (
|
|
|
171
244
|
.replaceAll("{{version}}", version)
|
|
172
245
|
.replaceAll("{{date}}", dateString);
|
|
173
246
|
const beforePending = content.slice(0, pendingSection.start).trimEnd();
|
|
174
|
-
const afterPending = content
|
|
247
|
+
const afterPending = content
|
|
248
|
+
.slice(pendingSection.end)
|
|
249
|
+
.replace(/^\n+/, "")
|
|
250
|
+
.trimEnd();
|
|
175
251
|
content = [beforePending, renderedHeading, pendingBlock, afterPending]
|
|
176
252
|
.filter((block) => block.length > 0)
|
|
177
253
|
.join("\n\n");
|
package/ts/helpers.climode.ts
CHANGED
|
@@ -24,6 +24,13 @@ interface ICliConfigSettings {
|
|
|
24
24
|
|
|
25
25
|
type TArgSource = Record<string, any> & { _?: string[] };
|
|
26
26
|
|
|
27
|
+
const commitValueFlags = new Set([
|
|
28
|
+
"message",
|
|
29
|
+
"message-file",
|
|
30
|
+
"changelog",
|
|
31
|
+
"changelog-file",
|
|
32
|
+
]);
|
|
33
|
+
|
|
27
34
|
const booleanLongFlags = new Set([
|
|
28
35
|
"agent",
|
|
29
36
|
"allow-breaking",
|
|
@@ -44,6 +51,8 @@ const booleanLongFlags = new Set([
|
|
|
44
51
|
"push",
|
|
45
52
|
"quiet",
|
|
46
53
|
"test",
|
|
54
|
+
"token-stdin",
|
|
55
|
+
"wait",
|
|
47
56
|
"yes",
|
|
48
57
|
]);
|
|
49
58
|
|
|
@@ -65,10 +74,27 @@ const getArgValue = (argvArg: TArgSource, key: string): any => {
|
|
|
65
74
|
|
|
66
75
|
const parseRawArgv = (argv: string[]): TArgSource => {
|
|
67
76
|
const parsedArgv: TArgSource = { _: [] };
|
|
77
|
+
const setCommitValue = (key: string, value: string | undefined): void => {
|
|
78
|
+
if (Object.hasOwn(parsedArgv, key))
|
|
79
|
+
throw new Error(`--${key} may only be supplied once.`);
|
|
80
|
+
if (value === undefined || value.length === 0)
|
|
81
|
+
throw new Error(`--${key} requires a value.`);
|
|
82
|
+
parsedArgv[key] = value;
|
|
83
|
+
parsedArgv[camelCase(key)] = value;
|
|
84
|
+
};
|
|
68
85
|
|
|
69
86
|
for (let i = 0; i < argv.length; i++) {
|
|
70
87
|
const currentArg = argv[i];
|
|
71
88
|
|
|
89
|
+
if (currentArg === "--") {
|
|
90
|
+
if (parsedArgv._?.[0] === "testing") {
|
|
91
|
+
parsedArgv["--"] = argv.slice(i + 1);
|
|
92
|
+
} else {
|
|
93
|
+
parsedArgv._!.push(...argv.slice(i + 1));
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
72
98
|
if (currentArg.startsWith("--no-")) {
|
|
73
99
|
const key = currentArg.slice(5);
|
|
74
100
|
parsedArgv[key] = false;
|
|
@@ -80,9 +106,20 @@ const parseRawArgv = (argv: string[]): TArgSource => {
|
|
|
80
106
|
const withoutPrefix = currentArg.slice(2);
|
|
81
107
|
const equalsIndex = withoutPrefix.indexOf("=");
|
|
82
108
|
const rawKey =
|
|
83
|
-
equalsIndex === -1
|
|
109
|
+
equalsIndex === -1
|
|
110
|
+
? withoutPrefix
|
|
111
|
+
: withoutPrefix.slice(0, equalsIndex);
|
|
84
112
|
const inlineValue =
|
|
85
113
|
equalsIndex === -1 ? undefined : withoutPrefix.slice(equalsIndex + 1);
|
|
114
|
+
if (commitValueFlags.has(rawKey)) {
|
|
115
|
+
const next = argv[i + 1];
|
|
116
|
+
setCommitValue(
|
|
117
|
+
rawKey,
|
|
118
|
+
inlineValue ?? (next && !next.startsWith("-") ? next : undefined),
|
|
119
|
+
);
|
|
120
|
+
if (inlineValue === undefined) i++;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
86
123
|
if (inlineValue !== undefined) {
|
|
87
124
|
parsedArgv[rawKey] = inlineValue;
|
|
88
125
|
parsedArgv[camelCase(rawKey)] = inlineValue;
|
|
@@ -108,7 +145,19 @@ const parseRawArgv = (argv: string[]): TArgSource => {
|
|
|
108
145
|
}
|
|
109
146
|
|
|
110
147
|
if (currentArg.startsWith("-") && currentArg.length > 1) {
|
|
111
|
-
|
|
148
|
+
const flags = currentArg.slice(1);
|
|
149
|
+
for (let flagIndex = 0; flagIndex < flags.length; flagIndex++) {
|
|
150
|
+
const shortFlag = flags[flagIndex];
|
|
151
|
+
if (shortFlag === "m") {
|
|
152
|
+
const attached = flags.slice(flagIndex + 1);
|
|
153
|
+
const next = argv[i + 1];
|
|
154
|
+
setCommitValue(
|
|
155
|
+
"message",
|
|
156
|
+
attached || (next && !next.startsWith("-") ? next : undefined),
|
|
157
|
+
);
|
|
158
|
+
if (!attached) i++;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
112
161
|
parsedArgv[shortFlag] = true;
|
|
113
162
|
}
|
|
114
163
|
continue;
|
package/ts/helpers.workflow.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getCliConfigValue } from "./helpers.smartconfig.js";
|
|
2
|
+
import { getProcessUserArgv } from "./helpers.climode.js";
|
|
2
3
|
|
|
3
4
|
export type TConfirmationMode = "prompt" | "auto" | "plan";
|
|
4
5
|
|
|
@@ -171,7 +172,7 @@ export interface IReleaseWorkflowConfig {
|
|
|
171
172
|
export interface IResolvedCommitWorkflow {
|
|
172
173
|
confirmation: TConfirmationMode;
|
|
173
174
|
allowBreaking: boolean;
|
|
174
|
-
steps: TCommitStep
|
|
175
|
+
steps: Array<TCommitStep | "manual">;
|
|
175
176
|
staging: "all";
|
|
176
177
|
testCommand: string;
|
|
177
178
|
buildCommand: string;
|
|
@@ -479,7 +480,7 @@ const readCliWorkflowConfig = async (): Promise<ICliWorkflowConfig> => {
|
|
|
479
480
|
};
|
|
480
481
|
|
|
481
482
|
const getOrderedArgsAfterCommand = (commandName: string): string[] => {
|
|
482
|
-
const rawArgs =
|
|
483
|
+
const rawArgs = getProcessUserArgv();
|
|
483
484
|
const commandIndex = rawArgs.indexOf(commandName);
|
|
484
485
|
if (commandIndex === -1) {
|
|
485
486
|
return rawArgs;
|
|
@@ -489,15 +490,29 @@ const getOrderedArgsAfterCommand = (commandName: string): string[] => {
|
|
|
489
490
|
|
|
490
491
|
const getOrderedShortFlags = (commandName: string): string[] => {
|
|
491
492
|
const orderedFlags: string[] = [];
|
|
492
|
-
|
|
493
|
+
const args = getOrderedArgsAfterCommand(commandName);
|
|
494
|
+
const valueFlags = new Set([
|
|
495
|
+
"--message",
|
|
496
|
+
"--message-file",
|
|
497
|
+
"--changelog",
|
|
498
|
+
"--changelog-file",
|
|
499
|
+
]);
|
|
500
|
+
for (let index = 0; index < args.length; index++) {
|
|
501
|
+
const arg = args[index];
|
|
493
502
|
if (arg === "--") {
|
|
494
503
|
break;
|
|
495
504
|
}
|
|
496
505
|
if (arg.startsWith("--")) {
|
|
506
|
+
if (valueFlags.has(arg)) index++;
|
|
497
507
|
continue;
|
|
498
508
|
}
|
|
499
509
|
if (arg.startsWith("-") && arg.length > 1) {
|
|
500
|
-
|
|
510
|
+
const flags = arg.slice(1);
|
|
511
|
+
const messageIndex = flags.indexOf("m");
|
|
512
|
+
orderedFlags.push(
|
|
513
|
+
...(messageIndex < 0 ? flags : flags.slice(0, messageIndex)).split(""),
|
|
514
|
+
);
|
|
515
|
+
if (messageIndex === flags.length - 1) index++;
|
|
501
516
|
}
|
|
502
517
|
}
|
|
503
518
|
return orderedFlags;
|
|
@@ -545,6 +560,9 @@ const normalizeCommitSteps = (rawSteps: TCommitStep[]): TCommitStep[] => {
|
|
|
545
560
|
}
|
|
546
561
|
|
|
547
562
|
const changelogIndex = prePushSteps.indexOf("changelog");
|
|
563
|
+
if (analyzeIndex > changelogIndex) {
|
|
564
|
+
throw new Error("Commit workflow requires analyze before changelog.");
|
|
565
|
+
}
|
|
548
566
|
if (changelogIndex === -1 || changelogIndex > commitIndex) {
|
|
549
567
|
throw new Error("Commit workflow requires changelog before commit.");
|
|
550
568
|
}
|
|
@@ -633,7 +651,28 @@ const buildReleasePlan = (options: {
|
|
|
633
651
|
|
|
634
652
|
export const resolveCommitWorkflow = async (
|
|
635
653
|
argvArg: any,
|
|
654
|
+
inputMode: "ai" | "manual" = "ai",
|
|
636
655
|
): Promise<IResolvedCommitWorkflow> => {
|
|
656
|
+
for (const flag of [
|
|
657
|
+
"y",
|
|
658
|
+
"yes",
|
|
659
|
+
"allow-breaking",
|
|
660
|
+
"allowBreaking",
|
|
661
|
+
"plan",
|
|
662
|
+
"f",
|
|
663
|
+
"format",
|
|
664
|
+
"t",
|
|
665
|
+
"test",
|
|
666
|
+
"b",
|
|
667
|
+
"build",
|
|
668
|
+
"p",
|
|
669
|
+
"push",
|
|
670
|
+
]) {
|
|
671
|
+
if (argvArg[flag] !== undefined && typeof argvArg[flag] !== "boolean")
|
|
672
|
+
throw new Error(
|
|
673
|
+
`Commit option ${flag} must be a bare Boolean flag without a value.`,
|
|
674
|
+
);
|
|
675
|
+
}
|
|
637
676
|
const cliConfig = await readCliWorkflowConfig();
|
|
638
677
|
const commitConfig = cliConfig.commit || {};
|
|
639
678
|
const releaseFlagRequested = Boolean(argvArg.r || argvArg.release);
|
|
@@ -677,7 +716,9 @@ export const resolveCommitWorkflow = async (
|
|
|
677
716
|
return {
|
|
678
717
|
confirmation,
|
|
679
718
|
allowBreaking: Boolean(argvArg["allow-breaking"] || argvArg.allowBreaking),
|
|
680
|
-
steps: normalizeCommitSteps(rawSteps)
|
|
719
|
+
steps: normalizeCommitSteps(rawSteps).map((step) =>
|
|
720
|
+
inputMode === "manual" && step === "analyze" ? "manual" : step,
|
|
721
|
+
),
|
|
681
722
|
staging: commitConfig.staging || "all",
|
|
682
723
|
testCommand: commitConfig.test?.command || "pnpm test",
|
|
683
724
|
buildCommand: commitConfig.build?.command || "pnpm build",
|