@astra-kit/rp 0.0.0-stage → 0.10.0

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +196 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +352 -2
  4. package/bin/astra-rp.js +51 -0
  5. package/package.json +93 -4
  6. package/src/build-gate.js +157 -0
  7. package/src/changelog-blocks.js +53 -0
  8. package/src/changelog.js +108 -0
  9. package/src/constants/build-gate.js +30 -0
  10. package/src/constants/changelog-draft.js +180 -0
  11. package/src/constants/changelog.js +74 -0
  12. package/src/constants/ci-release.js +346 -0
  13. package/src/constants/cli.js +12 -0
  14. package/src/constants/create-version.js +523 -0
  15. package/src/constants/guard-publish.js +29 -0
  16. package/src/constants/index.js +18 -0
  17. package/src/constants/monorepo.js +57 -0
  18. package/src/constants/package-manager.js +56 -0
  19. package/src/constants/registry.js +72 -0
  20. package/src/constants/terminal-ui.js +93 -0
  21. package/src/constants/version-files.js +63 -0
  22. package/src/constants/versions.js +60 -0
  23. package/src/create-version/artifact.js +343 -0
  24. package/src/create-version/changelog-draft-workspace.js +124 -0
  25. package/src/create-version/changelog-draft.js +380 -0
  26. package/src/create-version/changelog.js +264 -0
  27. package/src/create-version/ci-config.js +54 -0
  28. package/src/create-version/ci-publication-history.js +113 -0
  29. package/src/create-version/ci-release-identity-step.js +58 -0
  30. package/src/create-version/ci-setup.js +794 -0
  31. package/src/create-version/ci.js +555 -0
  32. package/src/create-version/committed-tree.js +75 -0
  33. package/src/create-version/config.js +489 -0
  34. package/src/create-version/errors.js +46 -0
  35. package/src/create-version/github-workflow.js +199 -0
  36. package/src/create-version/index.js +54 -0
  37. package/src/create-version/json.js +32 -0
  38. package/src/create-version/jsonc.js +76 -0
  39. package/src/create-version/jsr.js +96 -0
  40. package/src/create-version/local-changes.js +178 -0
  41. package/src/create-version/npm-auth.js +142 -0
  42. package/src/create-version/npm.js +812 -0
  43. package/src/create-version/plan.js +1200 -0
  44. package/src/create-version/process.js +334 -0
  45. package/src/create-version/registry-config.js +121 -0
  46. package/src/create-version/registry-http.js +62 -0
  47. package/src/create-version/registry.js +220 -0
  48. package/src/create-version/release-execution.js +45 -0
  49. package/src/create-version/release-tag-config.js +76 -0
  50. package/src/create-version/run.js +2087 -0
  51. package/src/create-version/state.js +461 -0
  52. package/src/create-version/strict-utf8.js +11 -0
  53. package/src/create-version/templates/release.yml +52 -0
  54. package/src/create-version/templates/vercel-ignore-build.mjs +66 -0
  55. package/src/guard-publish.js +77 -0
  56. package/src/index.js +42 -0
  57. package/src/monorepo/plan.js +475 -0
  58. package/src/monorepo/release-commit.js +46 -0
  59. package/src/monorepo/run.js +927 -0
  60. package/src/monorepo/state.js +206 -0
  61. package/src/monorepo/workspaces.js +327 -0
  62. package/src/package-manager.js +107 -0
  63. package/src/terminal-ui.js +548 -0
  64. package/src/testing.js +70 -0
  65. package/src/version-files.js +142 -0
  66. package/src/versions.js +303 -0
  67. package/types/build-gate.d.ts +43 -0
  68. package/types/changelog-blocks.d.ts +33 -0
  69. package/types/changelog.d.ts +61 -0
  70. package/types/constants/build-gate.d.ts +23 -0
  71. package/types/constants/changelog-draft.d.ts +138 -0
  72. package/types/constants/changelog.d.ts +56 -0
  73. package/types/constants/ci-release.d.ts +284 -0
  74. package/types/constants/cli.d.ts +11 -0
  75. package/types/constants/create-version.d.ts +397 -0
  76. package/types/constants/guard-publish.d.ts +25 -0
  77. package/types/constants/index.d.ts +17 -0
  78. package/types/constants/monorepo.d.ts +45 -0
  79. package/types/constants/package-manager.d.ts +40 -0
  80. package/types/constants/registry.d.ts +79 -0
  81. package/types/constants/terminal-ui.d.ts +73 -0
  82. package/types/constants/version-files.d.ts +51 -0
  83. package/types/constants/versions.d.ts +47 -0
  84. package/types/create-version/artifact.d.ts +113 -0
  85. package/types/create-version/changelog-draft-workspace.d.ts +33 -0
  86. package/types/create-version/changelog-draft.d.ts +127 -0
  87. package/types/create-version/changelog.d.ts +141 -0
  88. package/types/create-version/ci-config.d.ts +33 -0
  89. package/types/create-version/ci-publication-history.d.ts +51 -0
  90. package/types/create-version/ci-release-identity-step.d.ts +12 -0
  91. package/types/create-version/ci-setup.d.ts +148 -0
  92. package/types/create-version/ci.d.ts +145 -0
  93. package/types/create-version/committed-tree.d.ts +55 -0
  94. package/types/create-version/config.d.ts +128 -0
  95. package/types/create-version/errors.d.ts +39 -0
  96. package/types/create-version/github-workflow.d.ts +41 -0
  97. package/types/create-version/index.d.ts +28 -0
  98. package/types/create-version/json.d.ts +21 -0
  99. package/types/create-version/jsonc.d.ts +21 -0
  100. package/types/create-version/jsr.d.ts +52 -0
  101. package/types/create-version/local-changes.d.ts +52 -0
  102. package/types/create-version/npm-auth.d.ts +60 -0
  103. package/types/create-version/npm.d.ts +331 -0
  104. package/types/create-version/plan.d.ts +369 -0
  105. package/types/create-version/process.d.ts +151 -0
  106. package/types/create-version/registry-config.d.ts +56 -0
  107. package/types/create-version/registry-http.d.ts +22 -0
  108. package/types/create-version/registry.d.ts +86 -0
  109. package/types/create-version/release-execution.d.ts +22 -0
  110. package/types/create-version/release-tag-config.d.ts +18 -0
  111. package/types/create-version/run.d.ts +407 -0
  112. package/types/create-version/state.d.ts +204 -0
  113. package/types/create-version/strict-utf8.d.ts +10 -0
  114. package/types/guard-publish.d.ts +49 -0
  115. package/types/index.d.ts +23 -0
  116. package/types/monorepo/plan.d.ts +68 -0
  117. package/types/monorepo/release-commit.d.ts +29 -0
  118. package/types/monorepo/run.d.ts +68 -0
  119. package/types/monorepo/state.d.ts +96 -0
  120. package/types/monorepo/workspaces.d.ts +86 -0
  121. package/types/package-manager.d.ts +58 -0
  122. package/types/terminal-ui.d.ts +196 -0
  123. package/types/testing.d.ts +31 -0
  124. package/types/version-files.d.ts +59 -0
  125. package/types/versions.d.ts +158 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Detects the package manager of a project and builds the commands astra-rp
3
+ * prints or runs for it, so a bun, npm or yarn project is told to run its own
4
+ * commands instead of pnpm ones.
5
+ *
6
+ * @module package-manager
7
+ */
8
+ export type PackageManagerName = "pnpm" | "npm" | "yarn" | "bun";
9
+ export type ProjectCommands = {
10
+ packageManager: PackageManagerName;
11
+ runScript: (script: string) => string;
12
+ createVersion: string;
13
+ };
14
+ /**
15
+ * @typedef {"pnpm" | "npm" | "yarn" | "bun"} PackageManagerName
16
+ * @typedef {{
17
+ * packageManager: PackageManagerName,
18
+ * runScript: (script: string) => string,
19
+ * createVersion: string,
20
+ * }} ProjectCommands
21
+ * `runScript("ci")` is the command line that runs a `package.json` script; `createVersion` is how
22
+ * the project runs `astra-rp create-version` through its script.
23
+ */
24
+ /**
25
+ * Reads the package manager a `packageManager` value declares.
26
+ *
27
+ * @param {unknown} value - `packageManager` field of `package.json`.
28
+ * @returns {PackageManagerName | null} Package manager, or `null` when the value is missing or unknown.
29
+ */
30
+ export declare function parsePackageManagerField(value: unknown): PackageManagerName | null;
31
+ /**
32
+ * Detects the package manager of a project: the `packageManager` field of its `package.json`,
33
+ * else its lockfile, else pnpm (the historical default).
34
+ *
35
+ * @param {string} repositoryRoot - Project root.
36
+ * @param {Record<string, unknown>} [manifest] - Its `package.json`, when already read.
37
+ * @returns {PackageManagerName} Package manager.
38
+ */
39
+ export declare function detectPackageManager(repositoryRoot: string, manifest?: Record<string, unknown>): PackageManagerName;
40
+ /**
41
+ * Builds the commands printed or run for a package manager.
42
+ *
43
+ * @param {PackageManagerName} packageManager - Package manager.
44
+ * @returns {ProjectCommands} Commands.
45
+ */
46
+ export declare function describeProjectCommands(packageManager: PackageManagerName): ProjectCommands;
47
+ /**
48
+ * Builds the command that runs `create-version` with options. npm reads every option before its
49
+ * `--` separator as its own configuration (`npm run create-version --retry-ci v1.2.3` forwards only
50
+ * `v1.2.3`), so npm projects need `npm run create-version -- <opciones>`; pnpm, bun and yarn forward
51
+ * them as is. Every printed or dispatched command that carries options must start with it.
52
+ *
53
+ * @param {ProjectCommands} commands - Project commands.
54
+ * @returns {string} Command to which the options are appended.
55
+ */
56
+ export declare function describeCreateVersionWithOptions(commands: ProjectCommands): string;
57
+ /** Commands of a pnpm project: the default when a project cannot be inspected. */
58
+ export declare const DEFAULT_PROJECT_COMMANDS: Readonly<ProjectCommands>;
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Dependency-free terminal UI for release commands: colors, banner, rounded
3
+ * boxes, step headers, spinners and the interactive select prompt.
4
+ *
5
+ * Colors go through `util.styleText`, which drops ANSI codes automatically
6
+ * when stdout is not a TTY or `NO_COLOR` is set. Interactive prompts fall
7
+ * back to their default answer when stdin is not a TTY, so a command never
8
+ * hangs in a pipe.
9
+ *
10
+ * @module terminal-ui
11
+ */
12
+ import { styleText } from "node:util";
13
+ import { BOX_TONE, INTERRUPTED_EXIT_CODE } from "./constants/terminal-ui.js";
14
+ export type TextFormat = Parameters<typeof styleText>[0];
15
+ export type SelectOption = {
16
+ label: string;
17
+ hint?: string;
18
+ description?: string;
19
+ value: string;
20
+ };
21
+ /**
22
+ * Icons shared by status lines, colored once at import. They use Nerd Font
23
+ * glyphs, so the terminal needs a Nerd Font.
24
+ */
25
+ export declare const ICON: {
26
+ success: string;
27
+ failure: string;
28
+ warning: string;
29
+ info: string;
30
+ pending: string;
31
+ arrow: string;
32
+ bullet: string;
33
+ star: string;
34
+ rocket: "";
35
+ };
36
+ /**
37
+ * Returns how long the command has waited for the user's answers.
38
+ *
39
+ * @returns {number} Milliseconds spent with a prompt open.
40
+ */
41
+ export declare function getPromptWaitMs(): number;
42
+ /**
43
+ * Measures the elapsed time since a start, without the time spent waiting for answers.
44
+ *
45
+ * @param {number} startedAt - `Date.now()` when the measured work started.
46
+ * @param {number} [promptWaitAtStart] - {@link getPromptWaitMs} at that moment.
47
+ * @returns {number} Active milliseconds.
48
+ */
49
+ export declare function measureActiveMs(startedAt: number, promptWaitAtStart?: number): number;
50
+ /**
51
+ * Applies one or more `util.styleText` formats.
52
+ *
53
+ * @param {TextFormat} format - Format names such as `"bold"` or `["cyan", "bold"]`.
54
+ * @param {string} text - Text to style.
55
+ * @returns {string} Styled text (plain when colors are disabled).
56
+ */
57
+ export declare function paint(format: TextFormat, text: string): string;
58
+ /**
59
+ * Measures the visible width of a string, ignoring ANSI codes.
60
+ *
61
+ * @param {string} text - Possibly styled text.
62
+ * @returns {number} Visible column count.
63
+ */
64
+ export declare function visibleWidth(text: string): number;
65
+ /**
66
+ * Word-wraps a styled line to a visible width without ever cutting it off:
67
+ * words move to the next line, continuation lines align after a leading
68
+ * marker (icon, arrow, bullet or `1.`), styles are closed at each break and
69
+ * reopened on the next line, and a word longer than the width is split.
70
+ *
71
+ * @param {string} text - Possibly styled line.
72
+ * @param {number} width - Maximum visible width.
73
+ * @returns {string[]} Lines that each fit in `width` columns.
74
+ */
75
+ export declare function wrapStyledLine(text: string, width: number): string[];
76
+ /**
77
+ * Returns the box width for the current terminal.
78
+ *
79
+ * @returns {number} Outer width in columns.
80
+ */
81
+ export declare function resolveBoxWidth(): number;
82
+ /**
83
+ * Renders a rounded box with an optional title in its top border. Long lines
84
+ * are word-wrapped, never truncated; a title that does not fit in the border
85
+ * moves inside the box as its first lines.
86
+ *
87
+ * @param {{ title?: string, lines: string[], tone?: TextFormat, width?: number }} options - Box content.
88
+ * @returns {string} Multi-line box.
89
+ */
90
+ export declare function renderBox({ title, lines, tone, width }: {
91
+ title?: string;
92
+ lines: string[];
93
+ tone?: TextFormat;
94
+ width?: number;
95
+ }): string;
96
+ /**
97
+ * Renders a label/value row aligned for status panels.
98
+ *
99
+ * @param {string} icon - Leading icon.
100
+ * @param {string} label - Left column.
101
+ * @param {string} value - Right column.
102
+ * @param {number} [labelWidth] - Width of the label column.
103
+ * @returns {string} Row.
104
+ */
105
+ export declare function renderRow(icon: string, label: string, value: string, labelWidth?: number): string;
106
+ /**
107
+ * Renders the one-line header shown when a release command starts: an
108
+ * inverted `RELEASE` label, the project name, the published version aligned
109
+ * to the right and a rule underneath.
110
+ *
111
+ * @param {{ projectName: string, publishedLabel: string | null }} options - Header content.
112
+ * @returns {string} Header.
113
+ */
114
+ export declare function renderBanner({ projectName, publishedLabel }: {
115
+ projectName: string;
116
+ publishedLabel: string | null;
117
+ }): string;
118
+ /**
119
+ * Renders the header that introduces each executed step: a blank line, the `━━ PASO N/M ━ title ━…`
120
+ * rule (only the step label in bold) and a blank line that separates it from the step output.
121
+ *
122
+ * @param {number} stepNumber - 1-based index.
123
+ * @param {number} stepCount - Total steps.
124
+ * @param {string} title - Step title, in regular weight.
125
+ * @returns {string} Header lines.
126
+ */
127
+ export declare function renderStepHeader(stepNumber: number, stepCount: number, title: string): string;
128
+ /**
129
+ * Writes a line to stdout.
130
+ *
131
+ * @param {string} [text] - Line content.
132
+ */
133
+ export declare function print(text?: string): void;
134
+ /**
135
+ * Formats a duration in a compact Spanish form.
136
+ *
137
+ * @param {number} milliseconds - Duration.
138
+ * @returns {string} Such as `3.2 s` or `4 min 05 s`.
139
+ */
140
+ export declare function formatDuration(milliseconds: number): string;
141
+ /**
142
+ * Starts a spinner; on non-TTY outputs it prints the label once instead.
143
+ *
144
+ * @param {string} label - Initial label.
145
+ * @returns {{ update: (label: string) => void, succeed: (label?: string) => void, fail: (label?: string) => void }} Controls.
146
+ */
147
+ export declare function startSpinner(label: string): {
148
+ update: (label: string) => void;
149
+ succeed: (label?: string) => void;
150
+ fail: (label?: string) => void;
151
+ };
152
+ /**
153
+ * Counts the terminal rows that lines occupy, including the extra rows of
154
+ * lines wider than the terminal, so a prompt can erase exactly what it drew.
155
+ *
156
+ * @param {string[]} lines - Rendered lines, possibly styled.
157
+ * @param {number} columns - Terminal width in columns.
158
+ * @returns {number} Physical rows.
159
+ */
160
+ export declare function countTerminalRows(lines: string[], columns: number): number;
161
+ /**
162
+ * Maps a typed character to the option it selects.
163
+ *
164
+ * @param {string | undefined} text - Character typed by the user.
165
+ * @param {number} optionCount - Number of options in the prompt.
166
+ * @returns {number} Zero-based option index, or -1 when the key does not pick an option.
167
+ */
168
+ export declare function resolveNumberKey(text: string | undefined, optionCount: number): number;
169
+ /**
170
+ * Moves the selection of a prompt for a navigation key. Up and `k` go to the previous option;
171
+ * down, `j` and Tab to the next one, wrapping around. With nothing selected yet, the
172
+ * first "next" selects the first option and the first "previous" the last one.
173
+ *
174
+ * @param {number | null} selectedIndex - Selected option, or `null` when none is.
175
+ * @param {{ name?: string }} key - Parsed key.
176
+ * @param {number} optionCount - Number of options in the prompt.
177
+ * @returns {number | null} New selection; the same one when the key does not navigate.
178
+ */
179
+ export declare function moveSelection(selectedIndex: number | null, key: {
180
+ name?: string;
181
+ }, optionCount: number): number | null;
182
+ /**
183
+ * Asks the user to choose one option: its number picks it right away, or the
184
+ * arrow keys move the selection and Enter confirms it. With `defaultIndex: null`
185
+ * nothing starts selected, so Enter does nothing until an option is picked.
186
+ *
187
+ * @param {{ message: string, options: SelectOption[], defaultIndex?: number | null }} prompt - Prompt; `description` renders on its own line below the option.
188
+ * @returns {Promise<string>} Selected value (the default one when stdin is not a TTY).
189
+ * @throws {Error} When stdin is not a TTY and there is no default option to answer with.
190
+ */
191
+ export declare function select({ message, options, defaultIndex }: {
192
+ message: string;
193
+ options: SelectOption[];
194
+ defaultIndex?: number | null;
195
+ }): Promise<string>;
196
+ export { BOX_TONE, INTERRUPTED_EXIT_CODE };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Version bump fixtures for the test suites of every repository that uses
3
+ * `astra-rp`, so `create-version`, the Vercel build gate and any custom release
4
+ * command are checked against the same rule: from a stable version only the
5
+ * next patch, minor or major is allowed.
6
+ *
7
+ * @module testing
8
+ */
9
+ /** Stable version every fixture bumps from. */
10
+ export declare const CURRENT_STABLE_VERSION = "1.2.3";
11
+ /** The only versions allowed after {@link CURRENT_STABLE_VERSION}: next patch, minor and major. */
12
+ export declare const ALLOWED_NEXT_VERSIONS: readonly string[];
13
+ /** Every rejected kind of bump from {@link CURRENT_STABLE_VERSION}, grouped by why it is rejected. */
14
+ export declare const REJECTED_VERSION_BUMPS: Readonly<{
15
+ unchanged: readonly string[];
16
+ lower: readonly string[];
17
+ "skips patches": readonly string[];
18
+ "skips minors": readonly string[];
19
+ "skips majors": readonly string[];
20
+ "minor bump without resetting the patch": readonly string[];
21
+ "major bump without resetting minor and patch": readonly string[];
22
+ prerelease: readonly string[];
23
+ "build metadata": readonly string[];
24
+ "not a plain X.Y.Z": readonly string[];
25
+ }>;
26
+ /**
27
+ * All rejected bumps as `[reason, version]` pairs for table-driven tests.
28
+ *
29
+ * @type {ReadonlyArray<readonly [string, string]>}
30
+ */
31
+ export declare const REJECTED_VERSION_BUMP_CASES: ReadonlyArray<readonly [string, string]>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * `versionFiles`: files besides `package.json` that carry the version (a CLI
3
+ * `--version`, a user agent, a constant) and are rewritten in the release
4
+ * commit. Only marked lines change:
5
+ *
6
+ * - a line with `astra-rp-version` (or release-please's `x-release-please-version`);
7
+ * - every line between `astra-rp-start-version` and `astra-rp-end` (or
8
+ * `x-release-please-start-version` / `x-release-please-end`).
9
+ *
10
+ * @module version-files
11
+ */
12
+ export type VersionFileUpdate = {
13
+ content: string;
14
+ markedLines: number;
15
+ replacements: number;
16
+ };
17
+ export type VersionBlockProblem = "unterminated" | "unopened" | "nested" | "mismatched";
18
+ /**
19
+ * @typedef {{ content: string, markedLines: number, replacements: number }} VersionFileUpdate
20
+ * `markedLines` counts the lines the markers selected; `replacements` the versions rewritten.
21
+ */
22
+ /**
23
+ * @typedef {"unterminated" | "unopened" | "nested" | "mismatched"} VersionBlockProblem
24
+ * How the block markers are paired wrongly; see `VERSION_BLOCK_PROBLEM`.
25
+ */
26
+ /**
27
+ * Version block markers paired wrongly: nothing is rewritten, since guessing where the block ends
28
+ * could change versions outside the intended section.
29
+ */
30
+ export declare class VersionBlockError extends Error {
31
+ problem: VersionBlockProblem;
32
+ lineNumber: number;
33
+ marker: string;
34
+ openingLineNumber: number | undefined;
35
+ openingMarker: string | undefined;
36
+ /**
37
+ * @param {{ problem: VersionBlockProblem, lineNumber: number, marker: string, openingLineNumber?: number, openingMarker?: string }} details
38
+ * `lineNumber` (1-based) and `marker` locate the offending marker; `openingLineNumber` and
39
+ * `openingMarker` the start marker of the block still open, when there is one.
40
+ */
41
+ constructor({ problem, lineNumber, marker, openingLineNumber, openingMarker }: {
42
+ problem: VersionBlockProblem;
43
+ lineNumber: number;
44
+ marker: string;
45
+ openingLineNumber?: number;
46
+ openingMarker?: string;
47
+ });
48
+ }
49
+ /**
50
+ * Rewrites the versions of the marked lines of a file, keeping everything else (line endings
51
+ * included) byte for byte. `\n`, `\r\n` and a lone `\r` all end a line.
52
+ *
53
+ * @param {string} content - File content.
54
+ * @param {string} version - Version to write.
55
+ * @returns {VersionFileUpdate} New content and what the markers selected.
56
+ * @throws {VersionBlockError} When a block is left open, closed without being opened, opened
57
+ * inside another block or closed with the end marker of the other tool.
58
+ */
59
+ export declare function updateVersionMarkers(content: string, version: string): VersionFileUpdate;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Release version rules: only stable `X.Y.Z` versions exist, and after a
3
+ * version only its next patch, minor or major is allowed (from `1.2.3`:
4
+ * `1.2.4`, `1.3.0` or `2.0.0`). No version can be skipped, repeated or
5
+ * lowered, and prereleases or build metadata are never released.
6
+ *
7
+ * @module versions
8
+ */
9
+ export type ReleaseType = "patch" | "minor" | "major";
10
+ export type NextVersion = {
11
+ releaseType: ReleaseType;
12
+ version: string;
13
+ };
14
+ /**
15
+ * @typedef {"patch" | "minor" | "major"} ReleaseType
16
+ * @typedef {{ releaseType: ReleaseType, version: string }} NextVersion
17
+ */
18
+ /**
19
+ * Returns whether a value is a stable `X.Y.Z` release version.
20
+ *
21
+ * @param {unknown} version - Candidate version.
22
+ * @returns {boolean} `true` only for plain `X.Y.Z` without prerelease, metadata, prefix or leading zeros.
23
+ */
24
+ export declare function isStableReleaseVersion(version: unknown): boolean;
25
+ /**
26
+ * Parses a stable `X.Y.Z` version.
27
+ *
28
+ * @param {string} version - Version such as `0.93.0`.
29
+ * @returns {[number, number, number]} Major, minor and patch numbers.
30
+ * @throws {Error} When the version is not a stable release version.
31
+ */
32
+ export declare function parseReleaseVersion(version: string): [number, number, number];
33
+ /**
34
+ * Compares two stable `X.Y.Z` versions numerically.
35
+ *
36
+ * @param {string} leftVersion - First version.
37
+ * @param {string} rightVersion - Second version.
38
+ * @returns {number} Negative when `leftVersion` is lower, `0` when equal, positive when higher.
39
+ * @throws {Error} When either version is not a stable release version.
40
+ */
41
+ export declare function compareReleaseVersions(leftVersion: string, rightVersion: string): number;
42
+ /**
43
+ * Tells whether a stable version is above any semver version, prereleases included: `1.0.0` is
44
+ * above `1.0.0-beta.1` and `0.9.0`, but not above `1.1.0-beta.1`.
45
+ *
46
+ * @param {string} stableVersion - Stable `X.Y.Z` version.
47
+ * @param {string} otherVersion - Version to compare with, such as the `latest` dist-tag of npm.
48
+ * @returns {boolean} `true` when `stableVersion` is higher; `false` otherwise or when `otherVersion` is not semver.
49
+ */
50
+ export declare function isStableVersionAbove(stableVersion: string, otherVersion: string): boolean;
51
+ /**
52
+ * Returns the highest stable version of a list, ignoring prereleases and invalid entries.
53
+ *
54
+ * @param {unknown[]} versions - Versions, such as the ones `npm view <pkg> versions` lists.
55
+ * @returns {string | null} Highest stable `X.Y.Z` version, or `null` when there is none.
56
+ */
57
+ export declare function findHighestStableVersion(versions: unknown[]): string | null;
58
+ /**
59
+ * Returns the next version for a semver release type.
60
+ *
61
+ * @param {string} version - Current `X.Y.Z` version.
62
+ * @param {ReleaseType} releaseType - One of {@link RELEASE_TYPE}.
63
+ * @returns {string} Next `X.Y.Z` version.
64
+ * @throws {Error} When the version is not stable or the release type is unknown.
65
+ */
66
+ export declare function bumpReleaseVersion(version: string, releaseType: ReleaseType): string;
67
+ /**
68
+ * Lists the only versions allowed after the current one: the next patch,
69
+ * minor and major. Anything else would skip versions or go backwards.
70
+ *
71
+ * @param {string} currentVersion - Current `X.Y.Z` version.
72
+ * @returns {NextVersion[]} Allowed next versions, patch first.
73
+ */
74
+ export declare function listNextVersions(currentVersion: string): NextVersion[];
75
+ /**
76
+ * Lists the versions allowed after any previous semver version. A previous
77
+ * prerelease is also followed by its own stable release (`1.0.0-beta.1` →
78
+ * `1.0.0`).
79
+ *
80
+ * @param {string} previousVersion - Previous version, stable or prerelease.
81
+ * @returns {string[] | null} Allowed versions, or `null` when the previous version is not semver.
82
+ */
83
+ export declare function listAllowedVersionsAfter(previousVersion: string): string[] | null;
84
+ /**
85
+ * Resolves the version requested through `--bump` or `--set-version`.
86
+ *
87
+ * @param {string} currentVersion - Current `X.Y.Z` version.
88
+ * @param {{ bump: ReleaseType | null, setVersion: string | null }} request - Parsed CLI options.
89
+ * @returns {NextVersion | null} Requested version, or `null` to ask interactively.
90
+ * @throws {Error} With a Spanish message when the request is invalid.
91
+ */
92
+ export declare function resolveRequestedVersion(currentVersion: string, { bump, setVersion }: {
93
+ bump: ReleaseType | null;
94
+ setVersion: string | null;
95
+ }): NextVersion | null;
96
+ /**
97
+ * Builds the Git tag name of a release version.
98
+ *
99
+ * @param {string} version - `X.Y.Z` version.
100
+ * @returns {string} Tag such as `v0.94.0`.
101
+ */
102
+ export declare function toReleaseTag(version: string): string;
103
+ /**
104
+ * Returns whether a commit subject is a release bump commit (`0.93.0`).
105
+ *
106
+ * @param {string} subject - Commit subject.
107
+ * @returns {boolean} `true` for version-only subjects.
108
+ */
109
+ export declare function isReleaseCommitSubject(subject: string): boolean;
110
+ /**
111
+ * Suggests the semver release type for the commits that will ship.
112
+ *
113
+ * Breaking changes suggest `major`; features (conventional `feat` or legacy
114
+ * imperative subjects such as "Add ...") suggest `minor`; a set made only of
115
+ * conventional maintenance commits (`fix`, `chore`, `docs`, ...) suggests
116
+ * `patch`. Unknown legacy subjects suggest `minor`.
117
+ *
118
+ * @param {{ subject: string, body?: string }[]} commits - Commits since the last release.
119
+ * @returns {{ releaseType: ReleaseType, reason: string }} Suggested type and a Spanish explanation.
120
+ */
121
+ export declare function suggestReleaseType(commits: {
122
+ subject: string;
123
+ body?: string;
124
+ }[]): {
125
+ releaseType: ReleaseType;
126
+ reason: string;
127
+ };
128
+ /**
129
+ * Tells whether `preMajorShift` lowers the release levels after `currentVersion`: only when the
130
+ * option is on and the version is `0.x`, except the `0.0.0` placeholder of a package never released.
131
+ *
132
+ * @param {string} currentVersion - Current `X.Y.Z` version.
133
+ * @param {{ preMajorShift?: boolean }} [options] - Project versioning options.
134
+ * @returns {boolean} `true` when the release levels move one level down.
135
+ */
136
+ export declare function isPreMajorShiftActive(currentVersion: string, { preMajorShift }?: {
137
+ preMajorShift?: boolean;
138
+ }): boolean;
139
+ /**
140
+ * Suggests the release type of the next version after `currentVersion`: {@link suggestReleaseType},
141
+ * shifted one level down while the version is `0.x` when `preMajorShift` is on (breaking changes
142
+ * suggest `minor` and features `patch`, so a suggestion never jumps to `1.0.0`). The first release
143
+ * of a `0.0.0` package is not shifted.
144
+ *
145
+ * @param {{ subject: string, body?: string }[]} commits - Commits since the last release.
146
+ * @param {string} currentVersion - Current `X.Y.Z` version.
147
+ * @param {{ preMajorShift?: boolean }} [options] - Project versioning options.
148
+ * @returns {{ releaseType: ReleaseType, reason: string }} Suggested type and a Spanish explanation.
149
+ */
150
+ export declare function suggestNextReleaseType(commits: {
151
+ subject: string;
152
+ body?: string;
153
+ }[], currentVersion: string, { preMajorShift }?: {
154
+ preMajorShift?: boolean;
155
+ }): {
156
+ releaseType: ReleaseType;
157
+ reason: string;
158
+ };