@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.
- package/CHANGELOG.md +196 -0
- package/LICENSE.md +21 -0
- package/README.md +352 -2
- package/bin/astra-rp.js +51 -0
- package/package.json +93 -4
- package/src/build-gate.js +157 -0
- package/src/changelog-blocks.js +53 -0
- package/src/changelog.js +108 -0
- package/src/constants/build-gate.js +30 -0
- package/src/constants/changelog-draft.js +180 -0
- package/src/constants/changelog.js +74 -0
- package/src/constants/ci-release.js +346 -0
- package/src/constants/cli.js +12 -0
- package/src/constants/create-version.js +523 -0
- package/src/constants/guard-publish.js +29 -0
- package/src/constants/index.js +18 -0
- package/src/constants/monorepo.js +57 -0
- package/src/constants/package-manager.js +56 -0
- package/src/constants/registry.js +72 -0
- package/src/constants/terminal-ui.js +93 -0
- package/src/constants/version-files.js +63 -0
- package/src/constants/versions.js +60 -0
- package/src/create-version/artifact.js +343 -0
- package/src/create-version/changelog-draft-workspace.js +124 -0
- package/src/create-version/changelog-draft.js +380 -0
- package/src/create-version/changelog.js +264 -0
- package/src/create-version/ci-config.js +54 -0
- package/src/create-version/ci-publication-history.js +113 -0
- package/src/create-version/ci-release-identity-step.js +58 -0
- package/src/create-version/ci-setup.js +794 -0
- package/src/create-version/ci.js +555 -0
- package/src/create-version/committed-tree.js +75 -0
- package/src/create-version/config.js +489 -0
- package/src/create-version/errors.js +46 -0
- package/src/create-version/github-workflow.js +199 -0
- package/src/create-version/index.js +54 -0
- package/src/create-version/json.js +32 -0
- package/src/create-version/jsonc.js +76 -0
- package/src/create-version/jsr.js +96 -0
- package/src/create-version/local-changes.js +178 -0
- package/src/create-version/npm-auth.js +142 -0
- package/src/create-version/npm.js +812 -0
- package/src/create-version/plan.js +1200 -0
- package/src/create-version/process.js +334 -0
- package/src/create-version/registry-config.js +121 -0
- package/src/create-version/registry-http.js +62 -0
- package/src/create-version/registry.js +220 -0
- package/src/create-version/release-execution.js +45 -0
- package/src/create-version/release-tag-config.js +76 -0
- package/src/create-version/run.js +2087 -0
- package/src/create-version/state.js +461 -0
- package/src/create-version/strict-utf8.js +11 -0
- package/src/create-version/templates/release.yml +52 -0
- package/src/create-version/templates/vercel-ignore-build.mjs +66 -0
- package/src/guard-publish.js +77 -0
- package/src/index.js +42 -0
- package/src/monorepo/plan.js +475 -0
- package/src/monorepo/release-commit.js +46 -0
- package/src/monorepo/run.js +927 -0
- package/src/monorepo/state.js +206 -0
- package/src/monorepo/workspaces.js +327 -0
- package/src/package-manager.js +107 -0
- package/src/terminal-ui.js +548 -0
- package/src/testing.js +70 -0
- package/src/version-files.js +142 -0
- package/src/versions.js +303 -0
- package/types/build-gate.d.ts +43 -0
- package/types/changelog-blocks.d.ts +33 -0
- package/types/changelog.d.ts +61 -0
- package/types/constants/build-gate.d.ts +23 -0
- package/types/constants/changelog-draft.d.ts +138 -0
- package/types/constants/changelog.d.ts +56 -0
- package/types/constants/ci-release.d.ts +284 -0
- package/types/constants/cli.d.ts +11 -0
- package/types/constants/create-version.d.ts +397 -0
- package/types/constants/guard-publish.d.ts +25 -0
- package/types/constants/index.d.ts +17 -0
- package/types/constants/monorepo.d.ts +45 -0
- package/types/constants/package-manager.d.ts +40 -0
- package/types/constants/registry.d.ts +79 -0
- package/types/constants/terminal-ui.d.ts +73 -0
- package/types/constants/version-files.d.ts +51 -0
- package/types/constants/versions.d.ts +47 -0
- package/types/create-version/artifact.d.ts +113 -0
- package/types/create-version/changelog-draft-workspace.d.ts +33 -0
- package/types/create-version/changelog-draft.d.ts +127 -0
- package/types/create-version/changelog.d.ts +141 -0
- package/types/create-version/ci-config.d.ts +33 -0
- package/types/create-version/ci-publication-history.d.ts +51 -0
- package/types/create-version/ci-release-identity-step.d.ts +12 -0
- package/types/create-version/ci-setup.d.ts +148 -0
- package/types/create-version/ci.d.ts +145 -0
- package/types/create-version/committed-tree.d.ts +55 -0
- package/types/create-version/config.d.ts +128 -0
- package/types/create-version/errors.d.ts +39 -0
- package/types/create-version/github-workflow.d.ts +41 -0
- package/types/create-version/index.d.ts +28 -0
- package/types/create-version/json.d.ts +21 -0
- package/types/create-version/jsonc.d.ts +21 -0
- package/types/create-version/jsr.d.ts +52 -0
- package/types/create-version/local-changes.d.ts +52 -0
- package/types/create-version/npm-auth.d.ts +60 -0
- package/types/create-version/npm.d.ts +331 -0
- package/types/create-version/plan.d.ts +369 -0
- package/types/create-version/process.d.ts +151 -0
- package/types/create-version/registry-config.d.ts +56 -0
- package/types/create-version/registry-http.d.ts +22 -0
- package/types/create-version/registry.d.ts +86 -0
- package/types/create-version/release-execution.d.ts +22 -0
- package/types/create-version/release-tag-config.d.ts +18 -0
- package/types/create-version/run.d.ts +407 -0
- package/types/create-version/state.d.ts +204 -0
- package/types/create-version/strict-utf8.d.ts +10 -0
- package/types/guard-publish.d.ts +49 -0
- package/types/index.d.ts +23 -0
- package/types/monorepo/plan.d.ts +68 -0
- package/types/monorepo/release-commit.d.ts +29 -0
- package/types/monorepo/run.d.ts +68 -0
- package/types/monorepo/state.d.ts +96 -0
- package/types/monorepo/workspaces.d.ts +86 -0
- package/types/package-manager.d.ts +58 -0
- package/types/terminal-ui.d.ts +196 -0
- package/types/testing.d.ts +31 -0
- package/types/version-files.d.ts +59 -0
- package/types/versions.d.ts +158 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure release planning of `astra-rp create-version`.
|
|
3
|
+
*
|
|
4
|
+
* Receives the snapshot gathered by `state.js` and the project capabilities,
|
|
5
|
+
* and decides without touching Git, npm or databases what is still missing
|
|
6
|
+
* to ship a release from `main`:
|
|
7
|
+
*
|
|
8
|
+
* - a new release: sync `main`, verify the manual changelog and its `[Unreleased]` entries, apply migrations, run the
|
|
9
|
+
* checks, bump (commit `X.Y.Z` + tag `vX.Y.Z`), prepare, push and publish;
|
|
10
|
+
* - the resume of a release commit that never reached `origin` or the registry,
|
|
11
|
+
* including the publication of a tagged release from a detached `HEAD`;
|
|
12
|
+
* - nothing, when every commit is already released;
|
|
13
|
+
* - blockers that explain what to fix first (feature branch, uncommitted
|
|
14
|
+
* files, foreign commits on `main`, unreachable registry, invalid changelog,
|
|
15
|
+
* npm credentials that cannot publish, a last release missing from npm).
|
|
16
|
+
*
|
|
17
|
+
* @module create-version/plan
|
|
18
|
+
*/
|
|
19
|
+
export type ReleaseCommit = {
|
|
20
|
+
sha?: string;
|
|
21
|
+
subject: string;
|
|
22
|
+
body?: string;
|
|
23
|
+
};
|
|
24
|
+
export type FeatureBranchSnapshot = {
|
|
25
|
+
name: string;
|
|
26
|
+
headSha: string;
|
|
27
|
+
hasUpstream: boolean;
|
|
28
|
+
unpushedCount: number;
|
|
29
|
+
aheadOfMainCount: number;
|
|
30
|
+
};
|
|
31
|
+
export type PullRequestSnapshot = {
|
|
32
|
+
number: number;
|
|
33
|
+
url: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
state: string;
|
|
36
|
+
isDraft: boolean;
|
|
37
|
+
headRefOid: string;
|
|
38
|
+
};
|
|
39
|
+
export type NpmLookup = import("./npm.js").NpmLookup;
|
|
40
|
+
export type NpmAuthCheck = import("./npm.js").NpmAuthCheck;
|
|
41
|
+
export type MigrationCheck = import("./config.js").MigrationCheck;
|
|
42
|
+
export type LastReleaseSnapshot = {
|
|
43
|
+
sha: string;
|
|
44
|
+
version: string | null;
|
|
45
|
+
subject?: string | null;
|
|
46
|
+
tagged?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type ReleaseState = {
|
|
49
|
+
currentBranch: string | null;
|
|
50
|
+
workingTreeChanges: string[];
|
|
51
|
+
branch?: FeatureBranchSnapshot | null;
|
|
52
|
+
pullRequest?: PullRequestSnapshot | null;
|
|
53
|
+
githubError?: string | null;
|
|
54
|
+
main: {
|
|
55
|
+
aheadCommits: ReleaseCommit[];
|
|
56
|
+
behindCount: number;
|
|
57
|
+
};
|
|
58
|
+
headVersion: string | null;
|
|
59
|
+
headSubject: string | null;
|
|
60
|
+
headSha?: string | null;
|
|
61
|
+
headReleaseTag?: string | null;
|
|
62
|
+
remoteReleaseTagSha?: string | null;
|
|
63
|
+
headOnRemoteMain?: boolean;
|
|
64
|
+
releasedVersion?: string | null;
|
|
65
|
+
lastRelease?: LastReleaseSnapshot | null;
|
|
66
|
+
unreleasedCommits: ReleaseCommit[];
|
|
67
|
+
npm: NpmLookup | null;
|
|
68
|
+
npmAuth?: NpmAuthCheck | null;
|
|
69
|
+
migrations: MigrationCheck | null;
|
|
70
|
+
changelog: {
|
|
71
|
+
exists: boolean;
|
|
72
|
+
entryCount: number;
|
|
73
|
+
unknownSections: string[];
|
|
74
|
+
updated: boolean;
|
|
75
|
+
reason: string | null;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export type ProjectCommands = import("../package-manager.js").ProjectCommands;
|
|
79
|
+
export type ReleaseCapabilities = {
|
|
80
|
+
checks: boolean;
|
|
81
|
+
checksMissing?: boolean;
|
|
82
|
+
prepare: boolean;
|
|
83
|
+
publish: boolean;
|
|
84
|
+
publishTitle: string;
|
|
85
|
+
commands?: ProjectCommands;
|
|
86
|
+
};
|
|
87
|
+
export type ReleasePlanStep = {
|
|
88
|
+
id: string;
|
|
89
|
+
title: string;
|
|
90
|
+
detail?: string;
|
|
91
|
+
};
|
|
92
|
+
export type ReleaseBlocker = {
|
|
93
|
+
code?: "changelog-update-required";
|
|
94
|
+
title: string;
|
|
95
|
+
details: string[];
|
|
96
|
+
};
|
|
97
|
+
export type ReleasePlan = {
|
|
98
|
+
mode: string;
|
|
99
|
+
steps: ReleasePlanStep[];
|
|
100
|
+
blockers: ReleaseBlocker[];
|
|
101
|
+
warnings: string[];
|
|
102
|
+
pendingVersion: string | null;
|
|
103
|
+
};
|
|
104
|
+
export type ReleaseOptions = {
|
|
105
|
+
bump: "patch" | "minor" | "major" | null;
|
|
106
|
+
setVersion: string | null;
|
|
107
|
+
dryRun: boolean;
|
|
108
|
+
skipUnpublished: boolean;
|
|
109
|
+
ignoreLocalChanges: boolean;
|
|
110
|
+
acceptSuggested: boolean;
|
|
111
|
+
help: boolean;
|
|
112
|
+
execution?: "local" | "ci" | null;
|
|
113
|
+
setupCi?: boolean;
|
|
114
|
+
ciRelease?: string | null;
|
|
115
|
+
retryCi?: string | null;
|
|
116
|
+
};
|
|
117
|
+
export type UnpublishedRelease = {
|
|
118
|
+
version: string;
|
|
119
|
+
latestPublished: string | null;
|
|
120
|
+
resumable: boolean;
|
|
121
|
+
registryLabel?: string;
|
|
122
|
+
};
|
|
123
|
+
export type PlanOptions = {
|
|
124
|
+
skipUnpublished?: boolean;
|
|
125
|
+
ignoreLocalChanges?: boolean;
|
|
126
|
+
ciWorkerFiles?: readonly string[];
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* @typedef {{ sha?: string, subject: string, body?: string }} ReleaseCommit
|
|
130
|
+
* @typedef {{ name: string, headSha: string, hasUpstream: boolean, unpushedCount: number, aheadOfMainCount: number }} FeatureBranchSnapshot
|
|
131
|
+
* @typedef {{ number: number, url: string, title?: string, state: string, isDraft: boolean, headRefOid: string }} PullRequestSnapshot
|
|
132
|
+
* @typedef {import("./npm.js").NpmLookup} NpmLookup
|
|
133
|
+
* @typedef {import("./npm.js").NpmAuthCheck} NpmAuthCheck
|
|
134
|
+
* @typedef {import("./config.js").MigrationCheck} MigrationCheck
|
|
135
|
+
* @typedef {{ sha: string, version: string | null, subject?: string | null, tagged?: boolean }} LastReleaseSnapshot
|
|
136
|
+
* Newest commit of `origin/main` that changed `version`; `tagged` when `vX.Y.Z` points at it.
|
|
137
|
+
* @typedef {{
|
|
138
|
+
* currentBranch: string | null,
|
|
139
|
+
* workingTreeChanges: string[],
|
|
140
|
+
* branch?: FeatureBranchSnapshot | null,
|
|
141
|
+
* pullRequest?: PullRequestSnapshot | null,
|
|
142
|
+
* githubError?: string | null,
|
|
143
|
+
* main: { aheadCommits: ReleaseCommit[], behindCount: number },
|
|
144
|
+
* headVersion: string | null,
|
|
145
|
+
* headSubject: string | null,
|
|
146
|
+
* headSha?: string | null,
|
|
147
|
+
* headReleaseTag?: string | null,
|
|
148
|
+
* remoteReleaseTagSha?: string | null,
|
|
149
|
+
* headOnRemoteMain?: boolean,
|
|
150
|
+
* releasedVersion?: string | null,
|
|
151
|
+
* lastRelease?: LastReleaseSnapshot | null,
|
|
152
|
+
* unreleasedCommits: ReleaseCommit[],
|
|
153
|
+
* npm: NpmLookup | null,
|
|
154
|
+
* npmAuth?: NpmAuthCheck | null,
|
|
155
|
+
* migrations: MigrationCheck | null,
|
|
156
|
+
* changelog: { exists: boolean, entryCount: number, unknownSections: string[], updated: boolean, reason: string | null },
|
|
157
|
+
* }} ReleaseState
|
|
158
|
+
* @typedef {import("../package-manager.js").ProjectCommands} ProjectCommands
|
|
159
|
+
* @typedef {{ checks: boolean, checksMissing?: boolean, prepare: boolean, publish: boolean, publishTitle: string, commands?: ProjectCommands }} ReleaseCapabilities
|
|
160
|
+
* `checksMissing` means the project configures no checks, has no `ci` script and did not skip
|
|
161
|
+
* them with `checks: false`: a new release is blocked. `commands` are the project's package
|
|
162
|
+
* manager commands quoted by every hint (pnpm when omitted).
|
|
163
|
+
* @typedef {{ id: string, title: string, detail?: string }} ReleasePlanStep
|
|
164
|
+
* @typedef {{ code?: "changelog-update-required", title: string, details: string[] }} ReleaseBlocker
|
|
165
|
+
* @typedef {{ mode: string, steps: ReleasePlanStep[], blockers: ReleaseBlocker[], warnings: string[], pendingVersion: string | null }} ReleasePlan
|
|
166
|
+
* @typedef {{ bump: "patch" | "minor" | "major" | null, setVersion: string | null, dryRun: boolean, skipUnpublished: boolean, ignoreLocalChanges: boolean, acceptSuggested: boolean, help: boolean, execution?: "local" | "ci" | null, setupCi?: boolean, ciRelease?: string | null, retryCi?: string | null }} ReleaseOptions
|
|
167
|
+
* `acceptSuggested` takes the release type the commits suggest instead of asking.
|
|
168
|
+
* @typedef {{ version: string, latestPublished: string | null, resumable: boolean, registryLabel?: string }} UnpublishedRelease
|
|
169
|
+
* @typedef {{ skipUnpublished?: boolean, ignoreLocalChanges?: boolean, ciWorkerFiles?: readonly string[] }} PlanOptions
|
|
170
|
+
* `skipUnpublished` plans a new release even when the last release is missing from npm.
|
|
171
|
+
* `ignoreLocalChanges` plans the release despite uncommitted changes, which the run sets aside.
|
|
172
|
+
* `ciWorkerFiles` lists, only for CI preparation, the root-relative files the worker reads from the
|
|
173
|
+
* release tag; `ignoreLocalChanges` cannot set changes to them aside.
|
|
174
|
+
*/
|
|
175
|
+
/** Capabilities of a project without checks, preparation or publication. */
|
|
176
|
+
export declare const DEFAULT_CAPABILITIES: Readonly<{
|
|
177
|
+
checks: false;
|
|
178
|
+
checksMissing: false;
|
|
179
|
+
prepare: false;
|
|
180
|
+
publish: false;
|
|
181
|
+
publishTitle: "Publicar el release";
|
|
182
|
+
commands: Readonly<import("../package-manager.js").ProjectCommands>;
|
|
183
|
+
}>;
|
|
184
|
+
/** Usage printed by `create-version --help` in a pnpm project. */
|
|
185
|
+
export declare const RELEASE_USAGE: string;
|
|
186
|
+
/**
|
|
187
|
+
* Builds the usage printed by `create-version --help` for the project's package manager.
|
|
188
|
+
*
|
|
189
|
+
* @param {ProjectCommands} [commands] - Project commands (pnpm when omitted).
|
|
190
|
+
* @returns {string} Usage.
|
|
191
|
+
*/
|
|
192
|
+
export declare function buildReleaseUsage(commands?: ProjectCommands): string;
|
|
193
|
+
/**
|
|
194
|
+
* Parses the command-line arguments of `create-version`.
|
|
195
|
+
*
|
|
196
|
+
* @param {string[]} argv - Arguments after the command name.
|
|
197
|
+
* @returns {ReleaseOptions} Options.
|
|
198
|
+
* @throws {Error} With a Spanish message when an argument is unknown or invalid.
|
|
199
|
+
*/
|
|
200
|
+
export declare function parseReleaseArguments(argv: string[]): ReleaseOptions;
|
|
201
|
+
/**
|
|
202
|
+
* Describes what is still missing for a feature branch to reach `main`, so
|
|
203
|
+
* the blocker tells the user the next concrete action.
|
|
204
|
+
*
|
|
205
|
+
* @param {FeatureBranchSnapshot} branch - Branch snapshot.
|
|
206
|
+
* @param {PullRequestSnapshot | null} pullRequest - Pull request of the branch.
|
|
207
|
+
* @param {string | null} githubError - Why the pull request could not be read.
|
|
208
|
+
* @param {ProjectCommands} [commands] - Project commands quoted by the hints (pnpm when omitted).
|
|
209
|
+
* @returns {string[]} Spanish lines, most urgent first.
|
|
210
|
+
*/
|
|
211
|
+
export declare function describeFeatureBranchGaps(branch: FeatureBranchSnapshot, pullRequest: PullRequestSnapshot | null, githubError: string | null, commands?: ProjectCommands): string[];
|
|
212
|
+
/**
|
|
213
|
+
* Tells whether the npm lookup of the diagnosis ran and failed, so the plan is blocked before it
|
|
214
|
+
* could show a publication step; shared with the monorepo mode and the run.
|
|
215
|
+
*
|
|
216
|
+
* @param {{ npm?: NpmLookup | null }} snapshot - Repository or package snapshot.
|
|
217
|
+
* @returns {boolean} `true` when npm was queried and did not answer with the published versions.
|
|
218
|
+
*/
|
|
219
|
+
export declare function hasFailedNpmLookup(snapshot: {
|
|
220
|
+
npm?: NpmLookup | null;
|
|
221
|
+
}): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Explains a failed npm lookup; shared with the monorepo mode. When the registry answered it and
|
|
224
|
+
* rejected the credential (an invalid or expired token, or a user that cannot publish), an
|
|
225
|
+
* authenticated `npm view` fails with E401/E403, so the credential blocker explains it: replacing
|
|
226
|
+
* the token is the fix, not the connection. A missing token never reached the registry, so it does
|
|
227
|
+
* not explain the lookup.
|
|
228
|
+
*
|
|
229
|
+
* @param {NpmLookup} npm - Failed lookup.
|
|
230
|
+
* @param {NpmAuthCheck | null | undefined} npmAuth - Credential check, when it ran.
|
|
231
|
+
* @param {ProjectCommands} commands - Project commands quoted by the hints.
|
|
232
|
+
* @param {{ subject?: string, defaultReason: string }} description - Text after the registry name in the
|
|
233
|
+
* title (such as ` para <paquete>`) and the reason shown when the lookup has none.
|
|
234
|
+
* @returns {ReleaseBlocker} Credential blocker, or the generic lookup blocker.
|
|
235
|
+
*/
|
|
236
|
+
export declare function failedNpmLookupBlocker(npm: NpmLookup, npmAuth: NpmAuthCheck | null | undefined, commands: ProjectCommands, { subject, defaultReason }: {
|
|
237
|
+
subject?: string;
|
|
238
|
+
defaultReason: string;
|
|
239
|
+
}): ReleaseBlocker;
|
|
240
|
+
/**
|
|
241
|
+
* Explains that the releases only leave from `main`; shared with the monorepo mode.
|
|
242
|
+
*
|
|
243
|
+
* @param {Pick<ReleaseState, "branch" | "pullRequest" | "githubError"> & { currentBranch: string }} state - Snapshot on a feature branch.
|
|
244
|
+
* @param {ProjectCommands} commands - Project commands quoted by the hints.
|
|
245
|
+
* @returns {ReleaseBlocker} Blocker with what is still missing for the branch to reach `main`.
|
|
246
|
+
*/
|
|
247
|
+
export declare function featureBranchBlocker(state: Pick<ReleaseState, "branch" | "pullRequest" | "githubError"> & {
|
|
248
|
+
currentBranch: string;
|
|
249
|
+
}, commands: ProjectCommands): ReleaseBlocker;
|
|
250
|
+
/**
|
|
251
|
+
* Lists the uncommitted files that block the release without `--ignore-local-changes`; shared with the monorepo mode.
|
|
252
|
+
*
|
|
253
|
+
* @param {string[]} blockingChanges - `git status --porcelain` lines that block.
|
|
254
|
+
* @param {ProjectCommands} commands - Project commands quoted by the hints.
|
|
255
|
+
* @returns {ReleaseBlocker} Blocker.
|
|
256
|
+
*/
|
|
257
|
+
export declare function uncommittedFilesBlocker(blockingChanges: string[], commands: ProjectCommands): ReleaseBlocker;
|
|
258
|
+
/**
|
|
259
|
+
* Stops a new release whose manual changelog was not updated since the last release; shared with the monorepo mode.
|
|
260
|
+
*
|
|
261
|
+
* @param {string | null} reason - Why the changelog check failed, when it says so.
|
|
262
|
+
* @param {string} changelogPath - Changelog path relative to the root.
|
|
263
|
+
* @param {ProjectCommands} commands - Project commands quoted by the hints.
|
|
264
|
+
* @returns {ReleaseBlocker} Blocker with {@link CHANGELOG_UPDATE_REQUIRED_CODE}.
|
|
265
|
+
*/
|
|
266
|
+
export declare function changelogUpdateRequiredBlocker(reason: string | null, changelogPath: string, commands: ProjectCommands): ReleaseBlocker;
|
|
267
|
+
/**
|
|
268
|
+
* Stops a new release whose changelog has no `## [Unreleased]` block or no entry in it: the release
|
|
269
|
+
* commit closes that block as the new version. Shared with the monorepo mode.
|
|
270
|
+
*
|
|
271
|
+
* @param {{ exists: boolean, entryCount: number }} changelog - `[Unreleased]` block of the changelog.
|
|
272
|
+
* @param {string} changelogPath - Changelog path relative to the root.
|
|
273
|
+
* @param {ProjectCommands} commands - Project commands quoted by the hints.
|
|
274
|
+
* @returns {ReleaseBlocker | null} Blocker with {@link CHANGELOG_UPDATE_REQUIRED_CODE}, or `null` when `[Unreleased]` has entries.
|
|
275
|
+
*/
|
|
276
|
+
export declare function unreleasedEntriesRequiredBlocker(changelog: {
|
|
277
|
+
exists: boolean;
|
|
278
|
+
entryCount: number;
|
|
279
|
+
}, changelogPath: string, commands: ProjectCommands): ReleaseBlocker | null;
|
|
280
|
+
/**
|
|
281
|
+
* Builds the step that fast-forwards `main` before a new release; shared with the monorepo mode.
|
|
282
|
+
*
|
|
283
|
+
* @param {number} behindCount - Commits `origin/main` has and `main` lacks.
|
|
284
|
+
* @param {ProjectCommands} commands - Project commands quoted by the detail.
|
|
285
|
+
* @returns {ReleasePlanStep} Sync step.
|
|
286
|
+
*/
|
|
287
|
+
export declare function syncMainPlanStep(behindCount: number, commands: ProjectCommands): ReleasePlanStep;
|
|
288
|
+
/**
|
|
289
|
+
* Adds the migrations step when migrations are pending, or a warning when they could not be checked;
|
|
290
|
+
* shared with the monorepo mode.
|
|
291
|
+
*
|
|
292
|
+
* @param {MigrationCheck | null | undefined} migrations - Migration state of the diagnosis.
|
|
293
|
+
* @param {ReleasePlanStep[]} steps - Steps of the plan, extended in place.
|
|
294
|
+
* @param {string[]} warnings - Warnings of the plan, extended in place.
|
|
295
|
+
* @returns {void}
|
|
296
|
+
*/
|
|
297
|
+
export declare function addMigrationsPlanStep(migrations: MigrationCheck | null | undefined, steps: ReleasePlanStep[], warnings: string[]): void;
|
|
298
|
+
/**
|
|
299
|
+
* Classifies the npm credential check of a package the plan would publish; shared with the monorepo mode.
|
|
300
|
+
*
|
|
301
|
+
* @param {NpmAuthCheck} npmAuth - Credential check.
|
|
302
|
+
* @param {ProjectCommands} commands - Project commands quoted by the fix.
|
|
303
|
+
* @param {string} [subject] - Text after the registry name in the unverified warning (such as ` de <paquete>`).
|
|
304
|
+
* @returns {{ problem: ReleaseBlocker | null, warning: string | null }} Blocker when the credentials cannot publish,
|
|
305
|
+
* otherwise a warning when they could not be verified or the first publication cannot be confirmed.
|
|
306
|
+
*/
|
|
307
|
+
export declare function classifyNpmAuth(npmAuth: NpmAuthCheck, commands: ProjectCommands, subject?: string): {
|
|
308
|
+
problem: ReleaseBlocker | null;
|
|
309
|
+
warning: string | null;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Lists the uncommitted changes a run with `--ignore-local-changes` sets aside: every change,
|
|
313
|
+
* except `CHANGELOG.md` in a new release, whose bump commits it.
|
|
314
|
+
*
|
|
315
|
+
* @param {ReleaseState} state - Snapshot.
|
|
316
|
+
* @param {string} mode - Planned {@link RELEASE_MODE}.
|
|
317
|
+
* @returns {string[]} `git status --porcelain` lines to set aside.
|
|
318
|
+
*/
|
|
319
|
+
export declare function listLocalChangesToSetAside(state: ReleaseState, mode: string): string[];
|
|
320
|
+
/**
|
|
321
|
+
* Lists the paths of a `git status --porcelain` line: the path, or both the original and the new
|
|
322
|
+
* path of a rename or copy (`R old.js -> new.js`), without the quotes Git adds to unusual names.
|
|
323
|
+
*
|
|
324
|
+
* @param {string} line - Porcelain line.
|
|
325
|
+
* @returns {string[]} Paths the line reports.
|
|
326
|
+
*/
|
|
327
|
+
export declare function listPorcelainPaths(line: string): string[];
|
|
328
|
+
/**
|
|
329
|
+
* Tells whether a `git status --porcelain` line touches code or data the loaded configuration may
|
|
330
|
+
* import (see {@link UNSETTABLE_ASIDE_EXTENSIONS}), or a `.npmrc` the diagnosis already read to
|
|
331
|
+
* resolve the registry and credentials.
|
|
332
|
+
*
|
|
333
|
+
* @param {string} line - Porcelain line.
|
|
334
|
+
* @returns {boolean} `true` when any of its paths has one of those extensions or is a `.npmrc`.
|
|
335
|
+
*/
|
|
336
|
+
export declare function isCodeChange(line: string): boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Explains why `--ignore-local-changes` cannot set aside code or data changes (see
|
|
339
|
+
* {@link UNSETTABLE_ASIDE_EXTENSIONS}); shared with the monorepo mode.
|
|
340
|
+
*
|
|
341
|
+
* @param {string[]} codeChanges - `git status --porcelain` lines of the code or data changes.
|
|
342
|
+
* @param {ProjectCommands} commands - Project commands quoted by the hints.
|
|
343
|
+
* @returns {ReleaseBlocker} Blocker listing them.
|
|
344
|
+
*/
|
|
345
|
+
export declare function codeChangesToSetAsideBlocker(codeChanges: string[], commands: ProjectCommands): ReleaseBlocker;
|
|
346
|
+
/**
|
|
347
|
+
* Builds the blocker for local `main` commits that are not release commits.
|
|
348
|
+
*
|
|
349
|
+
* @param {ReleaseCommit[]} commits - Foreign commits.
|
|
350
|
+
* @returns {ReleaseBlocker} Blocker.
|
|
351
|
+
*/
|
|
352
|
+
export declare function foreignCommitsBlocker(commits: ReleaseCommit[]): ReleaseBlocker;
|
|
353
|
+
/**
|
|
354
|
+
* Stops a new release that nothing would validate before the version is touched.
|
|
355
|
+
*
|
|
356
|
+
* @param {ProjectCommands} commands - Project commands quoted by the hints.
|
|
357
|
+
* @returns {ReleaseBlocker} Blocker.
|
|
358
|
+
*/
|
|
359
|
+
export declare function missingChecksBlocker(commands: ProjectCommands): ReleaseBlocker;
|
|
360
|
+
/**
|
|
361
|
+
* Decides what is still missing to publish a release from `main` (or, from a detached `HEAD` on
|
|
362
|
+
* a release tag, to publish that release).
|
|
363
|
+
*
|
|
364
|
+
* @param {ReleaseState} state - Snapshot gathered by `state.js`.
|
|
365
|
+
* @param {ReleaseCapabilities} [capabilities] - Steps the project configured.
|
|
366
|
+
* @param {PlanOptions} [planOptions] - Options chosen on the command line.
|
|
367
|
+
* @returns {ReleasePlan} Ordered plan.
|
|
368
|
+
*/
|
|
369
|
+
export declare function buildReleasePlan(state: ReleaseState, capabilities?: ReleaseCapabilities, planOptions?: PlanOptions): ReleasePlan;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process and Git helpers of `astra-rp create-version`: captured and inherited
|
|
3
|
+
* commands that never reject, a Git reader bound to a repository, commit
|
|
4
|
+
* listing and manifest reads at any revision.
|
|
5
|
+
*
|
|
6
|
+
* @module create-version/process
|
|
7
|
+
*/
|
|
8
|
+
export type CapturedResult = {
|
|
9
|
+
status: number;
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
};
|
|
13
|
+
export type CommandOptions = {
|
|
14
|
+
cwd?: string;
|
|
15
|
+
shell?: boolean;
|
|
16
|
+
env?: NodeJS.ProcessEnv;
|
|
17
|
+
};
|
|
18
|
+
export type GitReader = {
|
|
19
|
+
git: (gitArguments: string[]) => Promise<string>;
|
|
20
|
+
tryGit: (gitArguments: string[]) => Promise<string | null>;
|
|
21
|
+
};
|
|
22
|
+
export type CommitRecord = {
|
|
23
|
+
sha: string;
|
|
24
|
+
subject: string;
|
|
25
|
+
body: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {{ status: number, stdout: string, stderr: string }} CapturedResult
|
|
29
|
+
* @typedef {{ cwd?: string, shell?: boolean, env?: NodeJS.ProcessEnv }} CommandOptions
|
|
30
|
+
* @typedef {{ git: (gitArguments: string[]) => Promise<string>, tryGit: (gitArguments: string[]) => Promise<string | null> }} GitReader
|
|
31
|
+
* @typedef {{ sha: string, subject: string, body: string }} CommitRecord
|
|
32
|
+
*/
|
|
33
|
+
/** Windows resolves `pnpm.cmd` and `npm.cmd` only through a shell. */
|
|
34
|
+
export declare const USES_SHELL_FOR_PACKAGE_MANAGERS: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Double-quotes every argument for a Windows shell command line; callers validate them first against
|
|
37
|
+
* characters that could break out of the quotes.
|
|
38
|
+
*
|
|
39
|
+
* @param {readonly string[]} commandArguments - Validated arguments.
|
|
40
|
+
* @returns {string} Arguments quoted and joined with spaces.
|
|
41
|
+
*/
|
|
42
|
+
export declare function quoteShellArguments(commandArguments: readonly string[]): string;
|
|
43
|
+
/**
|
|
44
|
+
* Runs a command and captures its output. Leading whitespace is kept because
|
|
45
|
+
* `git status --porcelain` encodes the file state in the first columns.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} command - Executable name, or a full command line when `shell` is set.
|
|
48
|
+
* @param {string[]} commandArguments - Arguments.
|
|
49
|
+
* @param {CommandOptions} [options] - Spawn options.
|
|
50
|
+
* @returns {Promise<CapturedResult>} Result; never rejects.
|
|
51
|
+
*/
|
|
52
|
+
export declare function runCaptured(command: string, commandArguments: string[], options?: CommandOptions): Promise<CapturedResult>;
|
|
53
|
+
export type InputCommandOptions = CommandOptions & {
|
|
54
|
+
input: string;
|
|
55
|
+
timeoutMs: number;
|
|
56
|
+
};
|
|
57
|
+
export type InputCommandResult = CapturedResult & {
|
|
58
|
+
timedOut: boolean;
|
|
59
|
+
spawnErrorCode: string | null;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Runs a command that reads `input` from stdin and captures its output, stopping it after
|
|
63
|
+
* `timeoutMs`. Used for agent CLIs that receive their prompt through stdin. Outside Windows the
|
|
64
|
+
* command runs in its own process group so a timeout also stops the processes it started; the
|
|
65
|
+
* promise still waits for its pipes to close when it ends normally, so no `unref` is needed.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} command - Executable name, or a full command line when `shell` is set.
|
|
68
|
+
* @param {string[]} commandArguments - Arguments.
|
|
69
|
+
* @param {InputCommandOptions} options - Spawn options, stdin contents and time limit.
|
|
70
|
+
* @returns {Promise<InputCommandResult>} Result, whether it was stopped for taking too long and the
|
|
71
|
+
* spawn error code (such as `ENOENT`); never rejects.
|
|
72
|
+
*/
|
|
73
|
+
export declare function runCapturedWithInput(command: string, commandArguments: string[], options: InputCommandOptions): Promise<InputCommandResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Runs a command with inherited stdio so its progress stays visible.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} command - Executable name, or a full command line when `shell` is set.
|
|
78
|
+
* @param {string[]} commandArguments - Arguments.
|
|
79
|
+
* @param {CommandOptions} [options] - Spawn options.
|
|
80
|
+
* @returns {Promise<number>} Exit code; never rejects.
|
|
81
|
+
*/
|
|
82
|
+
export declare function runInherited(command: string, commandArguments: string[], options?: CommandOptions): Promise<number>;
|
|
83
|
+
/**
|
|
84
|
+
* Streams a client that may print its own command on failure, redacting credentials across chunks.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} command - Executable or trusted shell command.
|
|
87
|
+
* @param {string[]} commandArguments - Client arguments.
|
|
88
|
+
* @param {CommandOptions} options - Child environment and checkout.
|
|
89
|
+
* @param {string[]} secrets - Values to redact; never included in diagnostics.
|
|
90
|
+
* @returns {Promise<number>} Exit code with interactive stdin and safe terminal output.
|
|
91
|
+
*/
|
|
92
|
+
export declare function runRedactedInherited(command: string, commandArguments: string[], options: CommandOptions, secrets: string[]): Promise<number>;
|
|
93
|
+
/**
|
|
94
|
+
* Runs a trusted, configured command line (for example `pnpm check`) through the shell.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} commandLine - Command line written in the project configuration, never user input.
|
|
97
|
+
* @param {string} cwd - Working directory.
|
|
98
|
+
* @returns {Promise<number>} Exit code; never rejects.
|
|
99
|
+
*/
|
|
100
|
+
export declare function runCommandLine(commandLine: string, cwd: string): Promise<number>;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a Git reader bound to a repository.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} repositoryRoot - Repository root.
|
|
105
|
+
* @returns {GitReader} Readers.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createGitReader(repositoryRoot: string): GitReader;
|
|
108
|
+
/**
|
|
109
|
+
* Parses `git log` records produced with {@link FIELD_SEPARATOR} and {@link RECORD_SEPARATOR}.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} output - Raw `git log` output.
|
|
112
|
+
* @returns {CommitRecord[]} Commits, newest first.
|
|
113
|
+
*/
|
|
114
|
+
export declare function parseCommitLog(output: string): CommitRecord[];
|
|
115
|
+
/**
|
|
116
|
+
* Lists the commits of a revision range, optionally only those touching some paths.
|
|
117
|
+
*
|
|
118
|
+
* @param {GitReader} reader - Git reader.
|
|
119
|
+
* @param {string} range - Revision range such as `abc..origin/main`.
|
|
120
|
+
* @param {readonly string[]} [paths] - Paths relative to the root; every commit when empty.
|
|
121
|
+
* @returns {Promise<CommitRecord[]>} Commits, newest first.
|
|
122
|
+
*/
|
|
123
|
+
export declare function listCommits(reader: GitReader, range: string, paths?: readonly string[]): Promise<CommitRecord[]>;
|
|
124
|
+
/**
|
|
125
|
+
* Reads a `package.json` at a revision.
|
|
126
|
+
*
|
|
127
|
+
* @param {GitReader} reader - Git reader.
|
|
128
|
+
* @param {string} revision - Revision such as `HEAD`, `v1.2.0` or `origin/main`.
|
|
129
|
+
* @param {string} [manifestPath] - Manifest path relative to the root, with `/` separators (a
|
|
130
|
+
* workspace package's `packages/x/package.json`); the root `package.json` by default.
|
|
131
|
+
* @returns {Promise<Record<string, unknown> | null>} Parsed manifest, or `null` when missing, unreadable or not a JSON object.
|
|
132
|
+
*/
|
|
133
|
+
export declare function readPackageManifestAt(reader: GitReader, revision: string, manifestPath?: string): Promise<Record<string, unknown> | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Reads the `version` field of a `package.json` at a revision.
|
|
136
|
+
*
|
|
137
|
+
* @param {GitReader} reader - Git reader.
|
|
138
|
+
* @param {string} revision - Revision such as `HEAD` or `origin/main`.
|
|
139
|
+
* @param {string} [manifestPath] - Manifest path relative to the root; the root `package.json` by default.
|
|
140
|
+
* @returns {Promise<string | null>} Version, or `null` when unreadable.
|
|
141
|
+
*/
|
|
142
|
+
export declare function readPackageVersionAt(reader: GitReader, revision: string, manifestPath?: string): Promise<string | null>;
|
|
143
|
+
/**
|
|
144
|
+
* Finds the newest top-level version change, including compact JSON and excluding edits to nested versions.
|
|
145
|
+
*
|
|
146
|
+
* @param {GitReader} reader - Read-only Git boundary.
|
|
147
|
+
* @param {string} revision - History to inspect.
|
|
148
|
+
* @param {string} [manifestPath] - Package manifest path.
|
|
149
|
+
* @returns {Promise<string | null>} Commit that actually changed the top-level version.
|
|
150
|
+
*/
|
|
151
|
+
export declare function findVersionChangeCommit(reader: GitReader, revision: string, manifestPath?: string): Promise<string | null>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates provider-specific publication options while keeping legacy npm configuration intact.
|
|
3
|
+
*
|
|
4
|
+
* @module create-version/registry-config
|
|
5
|
+
*/
|
|
6
|
+
export type RegistryProvider = "npm" | "github" | "gitlab" | "jsr";
|
|
7
|
+
export type RegistryAuthentication = "token" | "oidc" | "browser";
|
|
8
|
+
export type PublicationOptions = {
|
|
9
|
+
registryUrl?: string;
|
|
10
|
+
packageName?: string;
|
|
11
|
+
authentication?: RegistryAuthentication;
|
|
12
|
+
tokenEnv?: string;
|
|
13
|
+
access?: "public" | "restricted";
|
|
14
|
+
tag?: string;
|
|
15
|
+
configFile?: string;
|
|
16
|
+
jsrClient?: "npx" | "deno";
|
|
17
|
+
};
|
|
18
|
+
export type ResolvedPublicationOptions = {
|
|
19
|
+
registryUrl: string | null;
|
|
20
|
+
packageName: string | null;
|
|
21
|
+
authentication: RegistryAuthentication;
|
|
22
|
+
tokenEnv: string;
|
|
23
|
+
access: "public" | "restricted" | null;
|
|
24
|
+
tag: string | null;
|
|
25
|
+
configFile: string | null;
|
|
26
|
+
jsrClient: "npx" | "deno";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {"npm" | "github" | "gitlab" | "jsr"} RegistryProvider
|
|
30
|
+
* @typedef {"token" | "oidc" | "browser"} RegistryAuthentication
|
|
31
|
+
* @typedef {{ registryUrl?: string, packageName?: string, authentication?: RegistryAuthentication, tokenEnv?: string, access?: "public" | "restricted", tag?: string, configFile?: string, jsrClient?: "npx" | "deno" }} PublicationOptions
|
|
32
|
+
* @typedef {{ registryUrl: string | null, packageName: string | null, authentication: RegistryAuthentication, tokenEnv: string, access: "public" | "restricted" | null, tag: string | null, configFile: string | null, jsrClient: "npx" | "deno" }} ResolvedPublicationOptions
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Identifies one of the four built-in publishers.
|
|
36
|
+
*
|
|
37
|
+
* @param {unknown} value - Configured publisher or registry.
|
|
38
|
+
* @returns {value is RegistryProvider} Whether it is a provider name.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isRegistryProvider(value: unknown): value is RegistryProvider;
|
|
41
|
+
/**
|
|
42
|
+
* Tells whether a URL is a plain http(s) URL: without credentials, query nor fragment.
|
|
43
|
+
*
|
|
44
|
+
* @param {URL} url - Parsed URL.
|
|
45
|
+
* @returns {boolean} Whether a registry can be addressed by it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isPlainHttpUrl(url: URL): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Resolves publication options for a single selected provider; arrays are deliberately unsupported.
|
|
50
|
+
*
|
|
51
|
+
* @param {unknown} value - Raw `publication` configuration.
|
|
52
|
+
* @param {RegistryProvider} [provider] - Selected publisher or monitored registry.
|
|
53
|
+
* @returns {ResolvedPublicationOptions} Validated options and provider defaults.
|
|
54
|
+
* @throws {Error} When a field is invalid or unsupported by the selected provider.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolvePublicationOptions(value: unknown, provider?: RegistryProvider): ResolvedPublicationOptions;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads provider metadata without following registry forwarding redirects or exposing upstream bodies.
|
|
3
|
+
*
|
|
4
|
+
* @module create-version/registry-http
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Fetches versions directly from GitLab or JSR; a forwarding redirect means absent in this registry.
|
|
8
|
+
*
|
|
9
|
+
* @param {{ provider: import("./registry-config.js").RegistryProvider, registryUrl: string, packageName: string, label: string, tag: string | null, options?: { tokenEnv: string } }} registry - Selected registry.
|
|
10
|
+
* @param {string | null} token - Read credential, never included in returned state.
|
|
11
|
+
* @returns {Promise<import("./npm.js").NpmLookup>} Shared published-version contract.
|
|
12
|
+
*/
|
|
13
|
+
export declare function lookupHttpRegistry(registry: {
|
|
14
|
+
provider: import("./registry-config.js").RegistryProvider;
|
|
15
|
+
registryUrl: string;
|
|
16
|
+
packageName: string;
|
|
17
|
+
label: string;
|
|
18
|
+
tag: string | null;
|
|
19
|
+
options?: {
|
|
20
|
+
tokenEnv: string;
|
|
21
|
+
};
|
|
22
|
+
}, token: string | null): Promise<import("./npm.js").NpmLookup>;
|