@git.zone/cli 8.1.0 → 8.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/helpers.prompts.d.ts +23 -0
- package/dist_ts/helpers.prompts.js +30 -0
- package/dist_ts/mod_commit/index.js +30 -41
- package/dist_ts/mod_commit/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_commit/mod.plugins.js +2 -3
- package/dist_ts/mod_config/index.js +45 -61
- package/dist_ts/mod_deprecate/helpers.deprecation.d.ts +14 -4
- package/dist_ts/mod_deprecate/helpers.deprecation.js +34 -15
- package/dist_ts/mod_deprecate/index.js +38 -18
- package/dist_ts/mod_deprecate/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_deprecate/mod.plugins.js +2 -3
- package/dist_ts/mod_docker/index.js +4 -4
- package/dist_ts/mod_format/formatters/smartconfig.formatter.js +10 -16
- package/dist_ts/mod_format/index.js +6 -6
- package/dist_ts/mod_format/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_format/mod.plugins.js +2 -3
- package/dist_ts/mod_meta/meta.classes.meta.js +5 -4
- package/dist_ts/mod_meta/meta.plugins.d.ts +1 -2
- package/dist_ts/mod_meta/meta.plugins.js +2 -3
- package/dist_ts/mod_release/index.js +5 -4
- package/dist_ts/mod_services/classes.servicemanager.js +9 -13
- package/dist_ts/mod_services/index.js +10 -17
- package/dist_ts/mod_services/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_services/mod.plugins.js +2 -3
- package/dist_ts/mod_standard/index.js +3 -4
- package/dist_ts/mod_template/index.js +5 -6
- package/dist_ts/mod_template/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_template/mod.plugins.js +2 -3
- package/dist_ts/mod_tools/index.js +5 -10
- package/dist_ts/plugins.d.ts +2 -3
- package/dist_ts/plugins.js +3 -4
- package/package.json +3 -4
- package/readme.md +10 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/helpers.prompts.ts +70 -0
- package/ts/mod_commit/index.ts +37 -48
- package/ts/mod_commit/mod.plugins.ts +1 -2
- package/ts/mod_config/index.ts +44 -63
- package/ts/mod_deprecate/helpers.deprecation.ts +54 -22
- package/ts/mod_deprecate/index.ts +43 -17
- package/ts/mod_deprecate/mod.plugins.ts +1 -2
- package/ts/mod_docker/index.ts +3 -3
- package/ts/mod_format/formatters/smartconfig.formatter.ts +15 -22
- package/ts/mod_format/index.ts +9 -5
- package/ts/mod_format/mod.plugins.ts +0 -2
- package/ts/mod_meta/meta.classes.meta.ts +7 -3
- package/ts/mod_meta/meta.plugins.ts +1 -2
- package/ts/mod_release/index.ts +4 -3
- package/ts/mod_services/classes.servicemanager.ts +8 -14
- package/ts/mod_services/index.ts +17 -24
- package/ts/mod_services/mod.plugins.ts +1 -2
- package/ts/mod_standard/index.ts +2 -4
- package/ts/mod_template/index.ts +4 -5
- package/ts/mod_template/mod.plugins.ts +1 -2
- package/ts/mod_tools/index.ts +4 -10
- package/ts/plugins.ts +2 -4
package/dist_ts/plugins.js
CHANGED
|
@@ -10,7 +10,7 @@ import * as fsSync from 'node:fs';
|
|
|
10
10
|
import * as childProcess from 'node:child_process';
|
|
11
11
|
import * as tty from 'node:tty';
|
|
12
12
|
import * as projectinfo from '@push.rocks/projectinfo';
|
|
13
|
-
import * as
|
|
13
|
+
import * as smartconsole from '@push.rocks/smartconsole';
|
|
14
14
|
import * as smartpath from '@push.rocks/smartpath';
|
|
15
15
|
import * as smartpromise from '@push.rocks/smartpromise';
|
|
16
16
|
import * as smartupdate from '@push.rocks/smartupdate';
|
|
@@ -18,7 +18,6 @@ import * as smartshell from '@push.rocks/smartshell';
|
|
|
18
18
|
import * as smartnetwork from '@push.rocks/smartnetwork';
|
|
19
19
|
import * as smartfile from '@push.rocks/smartfile';
|
|
20
20
|
import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
|
|
21
|
-
import * as smartinteract from '@push.rocks/smartinteract';
|
|
22
21
|
import * as smartdelay from '@push.rocks/smartdelay';
|
|
23
22
|
// @lossless.org scope
|
|
24
23
|
import * as objectstorage from '@lossless.org/client/objectstorage';
|
|
@@ -28,5 +27,5 @@ import * as tspublish from '@git.zone/tspublish';
|
|
|
28
27
|
// Create smartfs instance for filesystem operations
|
|
29
28
|
export const smartfs = new SmartFs(new SmartFsProviderNode());
|
|
30
29
|
export const loadDcrouterApi = () => import('@serve.zone/dcrouter-apiclient');
|
|
31
|
-
export { smartlog, smartlogDestinationLocal, smartconfig, path, os, fs, fsConstants, crypto, fsSync, childProcess, tty, projectinfo,
|
|
32
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
30
|
+
export { smartlog, smartlogDestinationLocal, smartconfig, path, os, fs, fsConstants, crypto, fsSync, childProcess, tty, projectinfo, smartconsole, smartpath, smartpromise, smartupdate, smartshell, smartnetwork, smartfile, smartdelay, objectstorage, s3, tsdockerReleaseProtocol, tspublish, };
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLFFBQVEsTUFBTSxzQkFBc0IsQ0FBQztBQUNqRCxPQUFPLEtBQUssd0JBQXdCLE1BQU0sd0NBQXdDLENBQUM7QUFDbkYsT0FBTyxLQUFLLFdBQVcsTUFBTSx5QkFBeUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssSUFBSSxNQUFNLE1BQU0sQ0FBQztBQUM3QixPQUFPLEtBQUssRUFBRSxNQUFNLFNBQVMsQ0FBQztBQUM5QixPQUFPLEtBQUssRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ3ZDLE9BQU8sRUFBRSxTQUFTLElBQUksV0FBVyxFQUFFLE1BQU0sU0FBUyxDQUFDO0FBQ25ELE9BQU8sS0FBSyxNQUFNLE1BQU0sYUFBYSxDQUFDO0FBQ3RDLE9BQU8sS0FBSyxNQUFNLE1BQU0sU0FBUyxDQUFDO0FBQ2xDLE9BQU8sS0FBSyxZQUFZLE1BQU0sb0JBQW9CLENBQUM7QUFDbkQsT0FBTyxLQUFLLEdBQUcsTUFBTSxVQUFVLENBQUM7QUFDaEMsT0FBTyxLQUFLLFdBQVcsTUFBTSx5QkFBeUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssWUFBWSxNQUFNLDBCQUEwQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxTQUFTLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxLQUFLLFlBQVksTUFBTSwwQkFBMEIsQ0FBQztBQUN6RCxPQUFPLEtBQUssV0FBVyxNQUFNLHlCQUF5QixDQUFDO0FBQ3ZELE9BQU8sS0FBSyxVQUFVLE1BQU0sd0JBQXdCLENBQUM7QUFDckQsT0FBTyxLQUFLLFlBQVksTUFBTSwwQkFBMEIsQ0FBQztBQUN6RCxPQUFPLEtBQUssU0FBUyxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sRUFBRSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNuRSxPQUFPLEtBQUssVUFBVSxNQUFNLHdCQUF3QixDQUFDO0FBRXJELHNCQUFzQjtBQUN0QixPQUFPLEtBQUssYUFBYSxNQUFNLG9DQUFvQyxDQUFDO0FBRXBFLE9BQU8sS0FBSyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDekMsT0FBTyxLQUFLLHVCQUF1QixNQUFNLHVEQUF1RCxDQUFDO0FBQ2pHLE9BQU8sS0FBSyxTQUFTLE1BQU0scUJBQXFCLENBQUM7QUFnQmpELG9EQUFvRDtBQUNwRCxNQUFNLENBQUMsTUFBTSxPQUFPLEdBQUcsSUFBSSxPQUFPLENBQUMsSUFBSSxtQkFBbUIsRUFBRSxDQUFDLENBQUM7QUFFOUQsTUFBTSxDQUFDLE1BQU0sZUFBZSxHQUFHLEdBQUcsRUFBRSxDQUFDLE1BQU0sQ0FBQyxnQ0FBZ0MsQ0FBQyxDQUFDO0FBSTlFLE9BQU8sRUFDTCxRQUFRLEVBQ1Isd0JBQXdCLEVBQ3hCLFdBQVcsRUFDWCxJQUFJLEVBQ0osRUFBRSxFQUNGLEVBQUUsRUFDRixXQUFXLEVBQ1gsTUFBTSxFQUNOLE1BQU0sRUFDTixZQUFZLEVBQ1osR0FBRyxFQUNILFdBQVcsRUFDWCxZQUFZLEVBQ1osU0FBUyxFQUNULFlBQVksRUFDWixXQUFXLEVBQ1gsVUFBVSxFQUNWLFlBQVksRUFDWixTQUFTLEVBQ1QsVUFBVSxFQUNWLGFBQWEsRUFDYixFQUFFLEVBQ0YsdUJBQXVCLEVBQ3ZCLFNBQVMsR0FDVixDQUFDIn0=
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git.zone/cli",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "8.1
|
|
4
|
+
"version": "8.2.1",
|
|
5
5
|
"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.",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
7
7
|
"typings": "dist_ts/index.d.ts",
|
|
@@ -55,18 +55,16 @@
|
|
|
55
55
|
"@push.rocks/commitinfo": "^1.1.1",
|
|
56
56
|
"@push.rocks/early": "^4.0.4",
|
|
57
57
|
"@push.rocks/projectinfo": "^5.1.0",
|
|
58
|
-
"@push.rocks/smartcli": "^4.3.1",
|
|
59
58
|
"@push.rocks/smartconfig": "^6.2.4",
|
|
59
|
+
"@push.rocks/smartconsole": "^2.0.1",
|
|
60
60
|
"@push.rocks/smartdelay": "^3.0.5",
|
|
61
61
|
"@push.rocks/smartdiff": "^1.1.0",
|
|
62
62
|
"@push.rocks/smartfile": "^13.1.2",
|
|
63
63
|
"@push.rocks/smartfs": "^1.5.0",
|
|
64
|
-
"@push.rocks/smartinteract": "^2.0.16",
|
|
65
64
|
"@push.rocks/smartjson": "^6.0.0",
|
|
66
65
|
"@push.rocks/smartlegal": "^1.0.27",
|
|
67
66
|
"@push.rocks/smartlog": "^3.2.1 || ^4.0.0",
|
|
68
67
|
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
|
69
|
-
"@push.rocks/smartmustache": "^3.0.2",
|
|
70
68
|
"@push.rocks/smartnetwork": "^4.4.0",
|
|
71
69
|
"@push.rocks/smartnpm": "^2.0.6",
|
|
72
70
|
"@push.rocks/smartobject": "^1.0.12",
|
|
@@ -78,6 +76,7 @@
|
|
|
78
76
|
"@push.rocks/smartunique": "^3.0.9",
|
|
79
77
|
"@push.rocks/smartupdate": "^2.0.7",
|
|
80
78
|
"@serve.zone/dcrouter-apiclient": "32.3.0",
|
|
79
|
+
"inquirer": "^12.11.1",
|
|
81
80
|
"prettier": "^3.9.6"
|
|
82
81
|
},
|
|
83
82
|
"files": [
|
package/readme.md
CHANGED
|
@@ -1852,6 +1852,9 @@ gitzone deprecate
|
|
|
1852
1852
|
# Preview an explicit deprecation across both registries
|
|
1853
1853
|
gitzone deprecate --package @example/old --replacement @example/new --registries https://registry.npmjs.org,https://mirror.example.test --plan
|
|
1854
1854
|
|
|
1855
|
+
# Preview a deprecation for a package without a successor
|
|
1856
|
+
gitzone deprecate --package @example/old --registries https://registry.npmjs.org,https://mirror.example.test --message "@example/old is no longer maintained; use the platform fetch API instead." --plan
|
|
1857
|
+
|
|
1855
1858
|
# Prepare a project for local work
|
|
1856
1859
|
gitzone start
|
|
1857
1860
|
|
|
@@ -1861,8 +1864,13 @@ gitzone helpers shortid
|
|
|
1861
1864
|
|
|
1862
1865
|
For explicit deprecation, replace `--plan` with `-y` to apply the reviewed
|
|
1863
1866
|
operation. `--message` supplies migration instructions; otherwise the message
|
|
1864
|
-
names the replacement.
|
|
1865
|
-
|
|
1867
|
+
names the replacement. A package without an honest successor is deprecated
|
|
1868
|
+
without `--replacement`; `--message` is then required and should say what
|
|
1869
|
+
users do instead, and the plan shows `replacement: none` (`--json`:
|
|
1870
|
+
`"replacement": null`). Interactive mode accepts an empty replacement and then
|
|
1871
|
+
asks for the message. Deprecation applies to every version. GitZone verifies
|
|
1872
|
+
that the old package exists on all registries, and that the replacement, when
|
|
1873
|
+
named, has an active latest version there, before issuing any change, invokes
|
|
1866
1874
|
`pnpm deprecate` with literal arguments, and verifies the old versions' metadata
|
|
1867
1875
|
after each registry operation. Verification uses up to five fresh metadata reads,
|
|
1868
1876
|
one second apart, to allow registry propagation. A rerun skips any registry where
|
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: '8.1
|
|
6
|
+
version: '8.2.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
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as plugins from "./plugins.js";
|
|
2
|
+
|
|
3
|
+
type TPromptOptions = plugins.smartconsole.IPromptOptions;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Without an interactive terminal the question takes its declared default, as gitzone's prompts
|
|
7
|
+
* did in CI. Only for questions whose default is the safe answer.
|
|
8
|
+
*/
|
|
9
|
+
export const answerDefaultsWithoutTerminal: TPromptOptions = {
|
|
10
|
+
nonInteractive: { mode: "defaults" },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Asks on a console that lives for the call, so the terminal input is released as soon as the
|
|
15
|
+
* questions are answered. Without an interactive terminal the questions reject unless the
|
|
16
|
+
* options name a non-interactive policy.
|
|
17
|
+
*/
|
|
18
|
+
export const withPrompts = async <T>(
|
|
19
|
+
askArg: (promptsArg: plugins.smartconsole.ConsolePrompts) => Promise<T>,
|
|
20
|
+
): Promise<T> => {
|
|
21
|
+
const out = new plugins.smartconsole.SmartConsole();
|
|
22
|
+
try {
|
|
23
|
+
return await askArg(out.prompts);
|
|
24
|
+
} finally {
|
|
25
|
+
await out.dispose();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Asks one question and resolves its answer. */
|
|
30
|
+
export function ask(
|
|
31
|
+
questionArg: plugins.smartconsole.TTextQuestion,
|
|
32
|
+
optionsArg?: TPromptOptions,
|
|
33
|
+
): Promise<string>;
|
|
34
|
+
export function ask(
|
|
35
|
+
questionArg: plugins.smartconsole.IConfirmQuestion,
|
|
36
|
+
optionsArg?: TPromptOptions,
|
|
37
|
+
): Promise<boolean>;
|
|
38
|
+
export function ask<T>(
|
|
39
|
+
questionArg:
|
|
40
|
+
| plugins.smartconsole.ISelectQuestion<T>
|
|
41
|
+
| plugins.smartconsole.IExpandQuestion<T>,
|
|
42
|
+
optionsArg?: TPromptOptions,
|
|
43
|
+
): Promise<T>;
|
|
44
|
+
export function ask<T>(
|
|
45
|
+
questionArg: plugins.smartconsole.ICheckboxQuestion<T>,
|
|
46
|
+
optionsArg?: TPromptOptions,
|
|
47
|
+
): Promise<T[]>;
|
|
48
|
+
export function ask(
|
|
49
|
+
questionArg: plugins.smartconsole.TQuestion,
|
|
50
|
+
optionsArg?: TPromptOptions,
|
|
51
|
+
): Promise<unknown> {
|
|
52
|
+
return withPrompts((promptsArg) => promptsArg.ask(questionArg, optionsArg));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Asks a yes/no question. */
|
|
56
|
+
export const confirm = (
|
|
57
|
+
messageArg: string,
|
|
58
|
+
defaultArg: boolean,
|
|
59
|
+
optionsArg?: TPromptOptions,
|
|
60
|
+
): Promise<boolean> =>
|
|
61
|
+
ask(
|
|
62
|
+
{ type: "confirm", name: "confirm", message: messageArg, default: defaultArg },
|
|
63
|
+
optionsArg,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
/** Choices whose label is their value. */
|
|
67
|
+
export const stringChoices = <T extends string>(
|
|
68
|
+
valuesArg: readonly T[],
|
|
69
|
+
): plugins.smartconsole.IPromptChoice<T>[] =>
|
|
70
|
+
valuesArg.map((valueArg) => ({ name: valueArg, value: valueArg }));
|
package/ts/mod_commit/index.ts
CHANGED
|
@@ -23,6 +23,14 @@ import {
|
|
|
23
23
|
loadManualCommitInput,
|
|
24
24
|
type IManualCommitInput,
|
|
25
25
|
} from "./helpers.manual.js";
|
|
26
|
+
import { confirm, stringChoices, withPrompts } from "../helpers.prompts.js";
|
|
27
|
+
|
|
28
|
+
/** The commit the workflow creates: accepted AI recommendations, interactive answers or manual input. */
|
|
29
|
+
interface ICommitAnswers {
|
|
30
|
+
commitType: string;
|
|
31
|
+
commitScope: string;
|
|
32
|
+
commitDescription: string;
|
|
33
|
+
}
|
|
26
34
|
|
|
27
35
|
const isNoChangesError = (error: unknown): boolean => {
|
|
28
36
|
return error instanceof Error && error.name === "NoChangesError";
|
|
@@ -76,7 +84,7 @@ export const run = async (argvArg: any) => {
|
|
|
76
84
|
});
|
|
77
85
|
|
|
78
86
|
let nextCommitObject: any;
|
|
79
|
-
let
|
|
87
|
+
let commitAnswers: ICommitAnswers | undefined;
|
|
80
88
|
if (manual && !(await hasManualCommitChanges(smartshellInstance))) return;
|
|
81
89
|
if (manual && !(await confirmManualCommit(manual, workflow, mode))) return;
|
|
82
90
|
|
|
@@ -112,7 +120,7 @@ export const run = async (argvArg: any) => {
|
|
|
112
120
|
}
|
|
113
121
|
throw error;
|
|
114
122
|
}
|
|
115
|
-
|
|
123
|
+
commitAnswers = await buildCommitAnswers(
|
|
116
124
|
nextCommitObject,
|
|
117
125
|
workflow,
|
|
118
126
|
mode,
|
|
@@ -123,15 +131,15 @@ export const run = async (argvArg: any) => {
|
|
|
123
131
|
if (!manual) throw new Error("Manual commit input is required.");
|
|
124
132
|
if (!(await hasManualCommitChanges(smartshellInstance))) return;
|
|
125
133
|
nextCommitObject = { manual: true };
|
|
126
|
-
|
|
134
|
+
commitAnswers = {
|
|
127
135
|
commitType: manual.type,
|
|
128
136
|
commitScope: manual.scope,
|
|
129
137
|
commitDescription: manual.summary,
|
|
130
|
-
}
|
|
138
|
+
};
|
|
131
139
|
break;
|
|
132
140
|
}
|
|
133
141
|
case "changelog":
|
|
134
|
-
assertAnalysisComplete(
|
|
142
|
+
assertAnalysisComplete(commitAnswers, nextCommitObject);
|
|
135
143
|
if (manual) {
|
|
136
144
|
await appendPendingChangelogMarkdown(
|
|
137
145
|
plugins.path.join(paths.cwd, workflow.changelogFile),
|
|
@@ -143,12 +151,12 @@ export const run = async (argvArg: any) => {
|
|
|
143
151
|
`Updated ${workflow.changelogFile} pending section.`,
|
|
144
152
|
);
|
|
145
153
|
} else {
|
|
146
|
-
await runChangelogStep(workflow,
|
|
154
|
+
await runChangelogStep(workflow, commitAnswers!, nextCommitObject);
|
|
147
155
|
}
|
|
148
156
|
break;
|
|
149
157
|
case "commit":
|
|
150
|
-
assertAnalysisComplete(
|
|
151
|
-
await runCommitStep(smartshellInstance,
|
|
158
|
+
assertAnalysisComplete(commitAnswers, nextCommitObject);
|
|
159
|
+
await runCommitStep(smartshellInstance, commitAnswers!, manual?.message);
|
|
152
160
|
break;
|
|
153
161
|
case "push":
|
|
154
162
|
await runPushStep(smartshellInstance, workflow);
|
|
@@ -163,9 +171,9 @@ export const run = async (argvArg: any) => {
|
|
|
163
171
|
ui.printSummary({
|
|
164
172
|
projectType: "source",
|
|
165
173
|
branch: currentBranch,
|
|
166
|
-
commitType:
|
|
167
|
-
commitScope:
|
|
168
|
-
commitMessage:
|
|
174
|
+
commitType: commitAnswers!.commitType,
|
|
175
|
+
commitScope: commitAnswers!.commitScope,
|
|
176
|
+
commitMessage: commitAnswers!.commitDescription,
|
|
169
177
|
commitSha: commitShaResult.stdout.trim(),
|
|
170
178
|
pushed: workflow.steps.includes("push"),
|
|
171
179
|
});
|
|
@@ -203,7 +211,7 @@ async function confirmManualCommit(
|
|
|
203
211
|
: "Commit confirmation requires an interactive terminal. Use `-y` or set commit.confirmation to `auto`.",
|
|
204
212
|
);
|
|
205
213
|
}
|
|
206
|
-
return
|
|
214
|
+
return confirm(
|
|
207
215
|
manual.breaking
|
|
208
216
|
? "Create this breaking commit and changelog entry?"
|
|
209
217
|
: "Create this commit and changelog entry?",
|
|
@@ -251,12 +259,12 @@ async function runAnalyzeStep(): Promise<any> {
|
|
|
251
259
|
}
|
|
252
260
|
}
|
|
253
261
|
|
|
254
|
-
async function
|
|
262
|
+
async function buildCommitAnswers(
|
|
255
263
|
nextCommitObject: any,
|
|
256
264
|
workflow: IResolvedCommitWorkflow,
|
|
257
265
|
mode: ICliMode,
|
|
258
266
|
argvArg: any,
|
|
259
|
-
): Promise<
|
|
267
|
+
): Promise<ICommitAnswers> {
|
|
260
268
|
const isBreakingChange =
|
|
261
269
|
nextCommitObject.recommendedNextVersionLevel === "BREAKING CHANGE";
|
|
262
270
|
const canAutoAccept =
|
|
@@ -270,11 +278,11 @@ async function buildAnswerBucket(
|
|
|
270
278
|
? "Auto-accepting BREAKING CHANGE recommendation because --allow-breaking was provided"
|
|
271
279
|
: "Auto-accepting AI recommendations",
|
|
272
280
|
);
|
|
273
|
-
return
|
|
281
|
+
return {
|
|
274
282
|
commitType: nextCommitObject.recommendedNextVersionLevel,
|
|
275
283
|
commitScope: nextCommitObject.recommendedNextVersionScope,
|
|
276
284
|
commitDescription: nextCommitObject.recommendedNextVersionMessage,
|
|
277
|
-
}
|
|
285
|
+
};
|
|
278
286
|
}
|
|
279
287
|
|
|
280
288
|
if (
|
|
@@ -298,13 +306,12 @@ async function buildAnswerBucket(
|
|
|
298
306
|
);
|
|
299
307
|
}
|
|
300
308
|
|
|
301
|
-
|
|
302
|
-
commitInteract.addQuestions([
|
|
309
|
+
return await withPrompts((prompts) => prompts.askAll([
|
|
303
310
|
{
|
|
304
311
|
type: "list",
|
|
305
312
|
name: "commitType",
|
|
306
313
|
message: "Choose TYPE of the commit:",
|
|
307
|
-
choices: ["fix", "feat", "BREAKING CHANGE"],
|
|
314
|
+
choices: stringChoices(["fix", "feat", "BREAKING CHANGE"]),
|
|
308
315
|
default: nextCommitObject.recommendedNextVersionLevel,
|
|
309
316
|
},
|
|
310
317
|
{
|
|
@@ -319,34 +326,21 @@ async function buildAnswerBucket(
|
|
|
319
326
|
message: "What is the DESCRIPTION of the commit?",
|
|
320
327
|
default: nextCommitObject.recommendedNextVersionMessage,
|
|
321
328
|
},
|
|
322
|
-
]);
|
|
323
|
-
return await commitInteract.runQueue();
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function createAnswerBucket(answers: {
|
|
327
|
-
commitType: string;
|
|
328
|
-
commitScope: string;
|
|
329
|
-
commitDescription: string;
|
|
330
|
-
}): plugins.smartinteract.AnswerBucket {
|
|
331
|
-
const answerBucket = new plugins.smartinteract.AnswerBucket();
|
|
332
|
-
for (const [name, value] of Object.entries(answers)) {
|
|
333
|
-
answerBucket.addAnswer({ name, value });
|
|
334
|
-
}
|
|
335
|
-
return answerBucket;
|
|
329
|
+
]));
|
|
336
330
|
}
|
|
337
331
|
|
|
338
332
|
async function runChangelogStep(
|
|
339
333
|
workflow: IResolvedCommitWorkflow,
|
|
340
|
-
|
|
334
|
+
commitAnswers: ICommitAnswers,
|
|
341
335
|
nextCommitObject: any,
|
|
342
336
|
): Promise<void> {
|
|
343
337
|
await appendPendingChangelogEntry(
|
|
344
338
|
plugins.path.join(paths.cwd, workflow.changelogFile),
|
|
345
339
|
workflow.changelogSection,
|
|
346
340
|
{
|
|
347
|
-
type:
|
|
348
|
-
scope:
|
|
349
|
-
message:
|
|
341
|
+
type: commitAnswers.commitType,
|
|
342
|
+
scope: commitAnswers.commitScope,
|
|
343
|
+
message: commitAnswers.commitDescription,
|
|
350
344
|
details: nextCommitObject.recommendedNextVersionDetails || [],
|
|
351
345
|
},
|
|
352
346
|
);
|
|
@@ -355,12 +349,12 @@ async function runChangelogStep(
|
|
|
355
349
|
|
|
356
350
|
async function runCommitStep(
|
|
357
351
|
smartshellInstance: plugins.smartshell.Smartshell,
|
|
358
|
-
|
|
352
|
+
commitAnswers: ICommitAnswers,
|
|
359
353
|
manualMessage?: string,
|
|
360
354
|
): Promise<void> {
|
|
361
355
|
ui.printHeader("Creating Semantic Commit");
|
|
362
356
|
const commitString =
|
|
363
|
-
manualMessage ??
|
|
357
|
+
manualMessage ?? createCommitString(commitAnswers);
|
|
364
358
|
ui.printCommitMessage(commitString);
|
|
365
359
|
let messageDirectory: string | undefined;
|
|
366
360
|
try {
|
|
@@ -417,10 +411,10 @@ async function detectCurrentBranch(
|
|
|
417
411
|
}
|
|
418
412
|
|
|
419
413
|
function assertAnalysisComplete(
|
|
420
|
-
|
|
414
|
+
commitAnswers: ICommitAnswers | undefined,
|
|
421
415
|
nextCommitObject: any,
|
|
422
416
|
): void {
|
|
423
|
-
if (!
|
|
417
|
+
if (!commitAnswers || !nextCommitObject) {
|
|
424
418
|
throw new Error(
|
|
425
419
|
"Commit workflow requires analyze before changelog and commit steps.",
|
|
426
420
|
);
|
|
@@ -492,13 +486,8 @@ async function handleRecommend(mode: ICliMode): Promise<void> {
|
|
|
492
486
|
);
|
|
493
487
|
}
|
|
494
488
|
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
) => {
|
|
498
|
-
const commitType = answerBucket.getAnswerFor("commitType");
|
|
499
|
-
const commitScope = answerBucket.getAnswerFor("commitScope");
|
|
500
|
-
const commitDescription = answerBucket.getAnswerFor("commitDescription");
|
|
501
|
-
return `${commitType}(${commitScope}): ${commitDescription}`;
|
|
489
|
+
const createCommitString = (commitAnswers: ICommitAnswers) => {
|
|
490
|
+
return `${commitAnswers.commitType}(${commitAnswers.commitScope}): ${commitAnswers.commitDescription}`;
|
|
502
491
|
};
|
|
503
492
|
|
|
504
493
|
export function showHelp(mode?: ICliMode): void {
|
|
@@ -2,10 +2,9 @@ export * from "../plugins.js";
|
|
|
2
2
|
|
|
3
3
|
import * as commitinfo from "@push.rocks/commitinfo";
|
|
4
4
|
import * as smartfile from "@push.rocks/smartfile";
|
|
5
|
-
import * as smartinteract from "@push.rocks/smartinteract";
|
|
6
5
|
import * as smartshell from "@push.rocks/smartshell";
|
|
7
6
|
|
|
8
7
|
// Manual commits must not load or initialize the AI dependency chain.
|
|
9
8
|
export const loadTsdoc = () => import("@git.zone/tsdoc");
|
|
10
9
|
|
|
11
|
-
export { commitinfo, smartfile,
|
|
10
|
+
export { commitinfo, smartfile, smartshell };
|