@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,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coordinates one selected registry through a shared lookup/authentication/publication contract.
|
|
3
|
+
*
|
|
4
|
+
* @module create-version/registry
|
|
5
|
+
*/
|
|
6
|
+
import { checkNpmPublishAccess, lookupPublishedVersions } from "./npm.js";
|
|
7
|
+
export type RegistrySelection = {
|
|
8
|
+
provider: import("./registry-config.js").RegistryProvider;
|
|
9
|
+
options: import("./registry-config.js").ResolvedPublicationOptions;
|
|
10
|
+
};
|
|
11
|
+
export type SelectedRegistry = RegistrySelection & {
|
|
12
|
+
registryUrl: string;
|
|
13
|
+
packageName: string;
|
|
14
|
+
label: string;
|
|
15
|
+
tag: string | null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {{ provider: import("./registry-config.js").RegistryProvider, options: import("./registry-config.js").ResolvedPublicationOptions }} RegistrySelection
|
|
19
|
+
* @typedef {RegistrySelection & { registryUrl: string, packageName: string, label: string, tag: string | null }} SelectedRegistry
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Selects the configured provider without changing legacy npm hooks or disabled tracking.
|
|
23
|
+
*
|
|
24
|
+
* @param {import("./config.js").ResolvedCreateVersionConfig} config - Project configuration.
|
|
25
|
+
* @returns {RegistrySelection} Selected provider and options.
|
|
26
|
+
*/
|
|
27
|
+
export declare function selectProjectRegistry(config: import("./config.js").ResolvedCreateVersionConfig): RegistrySelection;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves package identity and endpoint once for the operation; known npm endpoints use their provider policy.
|
|
30
|
+
*
|
|
31
|
+
* @param {RegistrySelection} selection - Project selection.
|
|
32
|
+
* @param {Record<string, unknown>} manifest - Node package manifest.
|
|
33
|
+
* @param {string} repositoryRoot - Root where registry routing and credentials are read.
|
|
34
|
+
* @param {string} [packageRoot] - Workspace or checkout directory.
|
|
35
|
+
* @returns {Promise<SelectedRegistry>} Registry descriptor without secret values.
|
|
36
|
+
* @throws {Error} When the endpoint or package identity is invalid for its provider.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveRegistry(selection: RegistrySelection, manifest: Record<string, unknown>, repositoryRoot: string, packageRoot?: string): Promise<SelectedRegistry>;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the selected registry through the common version contract, preserving injected legacy npm adapters.
|
|
41
|
+
*
|
|
42
|
+
* @param {RegistrySelection} selection - Selected provider.
|
|
43
|
+
* @param {Record<string, unknown>} manifest - Source manifest.
|
|
44
|
+
* @param {string} repositoryRoot - Repository containing credentials and routing.
|
|
45
|
+
* @param {string} [packageRoot] - Workspace package root.
|
|
46
|
+
* @param {typeof lookupPublishedVersions} [lookupNpm] - Legacy npm boundary.
|
|
47
|
+
* @returns {Promise<import("./npm.js").NpmLookup>} Published-version state.
|
|
48
|
+
*/
|
|
49
|
+
export declare function lookupRegistryVersions(selection: RegistrySelection, manifest: Record<string, unknown>, repositoryRoot: string, packageRoot?: string, lookupNpm?: typeof lookupPublishedVersions): Promise<import("./npm.js").NpmLookup>;
|
|
50
|
+
/**
|
|
51
|
+
* Checks the destination of an npm-protocol OIDC publication: npm trusted publishing only exists on
|
|
52
|
+
* the public npm registry, so GitHub Packages, GitLab and any other endpoint can never accept it.
|
|
53
|
+
* Shared by the worker and by CI preparation, which must reject it before the release tag exists.
|
|
54
|
+
*
|
|
55
|
+
* @param {SelectedRegistry} registry - Resolved descriptor of a non-JSR provider.
|
|
56
|
+
* @returns {string | null} Blocking reason, or `null` when the destination is the public npm registry.
|
|
57
|
+
*/
|
|
58
|
+
export declare function findNpmOidcRegistryProblem(registry: SelectedRegistry): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Checks only capabilities the selected provider exposes; unsupported permission checks remain unknown.
|
|
61
|
+
*
|
|
62
|
+
* @param {RegistrySelection} selection - Project selection.
|
|
63
|
+
* @param {Record<string, unknown>} manifest - Node package manifest.
|
|
64
|
+
* @param {string} repositoryRoot - Credential root.
|
|
65
|
+
* @param {string} [packageRoot] - Package checkout.
|
|
66
|
+
* @param {typeof checkNpmPublishAccess} [checkNpmAccess] - Legacy npm check boundary.
|
|
67
|
+
* @returns {Promise<import("./npm.js").NpmAuthCheck>} Safe credential diagnostic.
|
|
68
|
+
*/
|
|
69
|
+
export declare function checkRegistryAccess(selection: RegistrySelection, manifest: Record<string, unknown>, repositoryRoot: string, packageRoot?: string, checkNpmAccess?: typeof checkNpmPublishAccess): Promise<import("./npm.js").NpmAuthCheck>;
|
|
70
|
+
/**
|
|
71
|
+
* Publishes with the chosen protocol and reconciles a failed client before declaring an unpublished version.
|
|
72
|
+
*
|
|
73
|
+
* @param {RegistrySelection} selection - One configured provider.
|
|
74
|
+
* @param {Record<string, unknown>} manifest - Release manifest.
|
|
75
|
+
* @param {string} repositoryRoot - Routing and credential root.
|
|
76
|
+
* @param {string} packageRoot - Actual release checkout.
|
|
77
|
+
* @param {string} version - Stable release version.
|
|
78
|
+
* @param {string | null} [artifactPath] - Verified npm archive; unused by native JSR.
|
|
79
|
+
* @returns {Promise<{ registry: SelectedRegistry, exitCode: number, missingToken: boolean, confirmed: boolean }>} Publication and reconciliation result.
|
|
80
|
+
*/
|
|
81
|
+
export declare function publishRegistryRelease(selection: RegistrySelection, manifest: Record<string, unknown>, repositoryRoot: string, packageRoot: string, version: string, artifactPath?: string | null): Promise<{
|
|
82
|
+
registry: SelectedRegistry;
|
|
83
|
+
exitCode: number;
|
|
84
|
+
missingToken: boolean;
|
|
85
|
+
confirmed: boolean;
|
|
86
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records and reads, in the release commit itself, where a release was prepared (`local` or `ci`).
|
|
3
|
+
* The mark lives in a commit trailer so it covers every release without adding tracked files that the
|
|
4
|
+
* Vercel build gate would interpret.
|
|
5
|
+
* @module create-version/release-execution
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Builds the trailer paragraph appended to the release commit message.
|
|
9
|
+
* @param {"local" | "ci"} execution - Location where the release commit is prepared.
|
|
10
|
+
* @returns {string} Trailer line such as `Astra-Rp-Execution: ci`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatReleaseExecutionTrailer(execution: "local" | "ci"): string;
|
|
13
|
+
/**
|
|
14
|
+
* Reads the execution location recorded in the trailer of a release commit.
|
|
15
|
+
* Commits created before the trailer existed (or by other tools) have none and yield null.
|
|
16
|
+
* @param {import("./process.js").GitReader} reader - Git reader of the release checkout.
|
|
17
|
+
* @param {string} version - Version of the release commit, used in diagnostics.
|
|
18
|
+
* @param {string} [revision] - Commit holding the trailer; defaults to `HEAD`.
|
|
19
|
+
* @returns {Promise<"local" | "ci" | null>} Recorded location, or null when the commit carries no trailer.
|
|
20
|
+
* @throws {ReleaseStepError} When the commit cannot be read, or its trailers are unknown or contradictory.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readReleaseExecutionTrailer(reader: import("./process.js").GitReader, version: string, revision?: string): Promise<"local" | "ci" | null>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the `create-version` configuration stored in a release tag. `--retry-ci` dispatches the
|
|
3
|
+
* workflow of the tag with `--ref <tag>` and the worker reloads its configuration from that tag, so
|
|
4
|
+
* the workflow name and the Actions bindings checked before the retry must come from the tag too,
|
|
5
|
+
* not from a working tree that later commits may have changed without bumping the version.
|
|
6
|
+
* @module create-version/release-tag-config
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Checks out a release tag into a temporary directory inside the repository's Git directory and
|
|
10
|
+
* loads the configuration stored there. The checkout uses its own index, so the project's index,
|
|
11
|
+
* working tree and refs stay untouched, and it is removed before returning. Placing it under the
|
|
12
|
+
* project lets the tagged configuration import the dependencies installed in the project root.
|
|
13
|
+
* @param {string} repositoryRoot - Project root.
|
|
14
|
+
* @param {string} tag - Release tag already verified against origin, such as `v1.2.4`.
|
|
15
|
+
* @returns {Promise<import("./config.js").ResolvedCreateVersionConfig>} Configuration the worker loads from the tag.
|
|
16
|
+
* @throws {ReleaseStepError} When the tag cannot be checked out or its configuration is missing or invalid.
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadReleaseTagConfig(repositoryRoot: string, tag: string): Promise<import("./config.js").ResolvedCreateVersionConfig>;
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `astra-rp create-version`: one command that diagnoses a repository, shows
|
|
3
|
+
* what is still missing and ships the release from `main`.
|
|
4
|
+
*
|
|
5
|
+
* 1. Diagnosis: fetches `origin`, reads the branch, working tree, `main`
|
|
6
|
+
* versus `origin/main`, the last release, unreleased commits, the
|
|
7
|
+
* published versions, the npm credentials (when the plan would publish to
|
|
8
|
+
* npm) and pending migrations (`state.js`).
|
|
9
|
+
* 2. Plan: `plan.js` turns that snapshot into ordered steps, or into blockers
|
|
10
|
+
* that explain what to fix.
|
|
11
|
+
* 3. Execution: runs each step; project-specific work (checks, migrations,
|
|
12
|
+
* preparation, publication) comes from `astra-rp.config.js`.
|
|
13
|
+
*
|
|
14
|
+
* Every step is derived from the current state, so running the command again
|
|
15
|
+
* after a failure resumes from the first missing step.
|
|
16
|
+
*
|
|
17
|
+
* @module create-version/run
|
|
18
|
+
*/
|
|
19
|
+
import { setAsideLocalChanges } from "./local-changes.js";
|
|
20
|
+
export type ResolvedCreateVersionConfig = import("./config.js").ResolvedCreateVersionConfig;
|
|
21
|
+
export type HookContext = import("./config.js").HookContext;
|
|
22
|
+
export type ReleaseSnapshot = import("./state.js").ReleaseSnapshot;
|
|
23
|
+
export type GitReader = import("./process.js").GitReader;
|
|
24
|
+
export type ReleaseContext = {
|
|
25
|
+
repositoryRoot: string;
|
|
26
|
+
config: ResolvedCreateVersionConfig;
|
|
27
|
+
state: ReleaseSnapshot;
|
|
28
|
+
options: import("./plan.js").ReleaseOptions;
|
|
29
|
+
reader: GitReader;
|
|
30
|
+
version: string | null;
|
|
31
|
+
pushed: boolean;
|
|
32
|
+
published: boolean;
|
|
33
|
+
commitCount: number | null;
|
|
34
|
+
packageName: string;
|
|
35
|
+
registryUrl: string | null;
|
|
36
|
+
registryLabel: string | null;
|
|
37
|
+
commands: import("../package-manager.js").ProjectCommands;
|
|
38
|
+
changelogFiles: import("./changelog.js").PreservedReleaseFile[];
|
|
39
|
+
execution?: "local" | "ci";
|
|
40
|
+
ciWorker?: boolean;
|
|
41
|
+
ciSetupFiles?: ReleaseFileUpdate[];
|
|
42
|
+
workflowClient?: import("./github-workflow.js").GithubWorkflowClient;
|
|
43
|
+
};
|
|
44
|
+
export type StepContext = {
|
|
45
|
+
repositoryRoot: string;
|
|
46
|
+
reader: GitReader;
|
|
47
|
+
config: ResolvedCreateVersionConfig;
|
|
48
|
+
commands: import("../package-manager.js").ProjectCommands;
|
|
49
|
+
state: {
|
|
50
|
+
migrations: import("./config.js").MigrationCheck | null;
|
|
51
|
+
};
|
|
52
|
+
execution?: "local" | "ci";
|
|
53
|
+
ciWorker?: boolean;
|
|
54
|
+
version?: string | null;
|
|
55
|
+
};
|
|
56
|
+
export type RenderablePlan = {
|
|
57
|
+
mode: string;
|
|
58
|
+
steps: import("./plan.js").ReleasePlanStep[];
|
|
59
|
+
blockers: import("./plan.js").ReleaseBlocker[];
|
|
60
|
+
warnings: string[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {import("./config.js").ResolvedCreateVersionConfig} ResolvedCreateVersionConfig
|
|
64
|
+
* @typedef {import("./config.js").HookContext} HookContext
|
|
65
|
+
* @typedef {import("./state.js").ReleaseSnapshot} ReleaseSnapshot
|
|
66
|
+
* @typedef {import("./process.js").GitReader} GitReader
|
|
67
|
+
* @typedef {{
|
|
68
|
+
* repositoryRoot: string,
|
|
69
|
+
* config: ResolvedCreateVersionConfig,
|
|
70
|
+
* state: ReleaseSnapshot,
|
|
71
|
+
* options: import("./plan.js").ReleaseOptions,
|
|
72
|
+
* reader: GitReader,
|
|
73
|
+
* version: string | null,
|
|
74
|
+
* pushed: boolean,
|
|
75
|
+
* published: boolean,
|
|
76
|
+
* commitCount: number | null,
|
|
77
|
+
* packageName: string,
|
|
78
|
+
* registryUrl: string | null,
|
|
79
|
+
* registryLabel: string | null,
|
|
80
|
+
* commands: import("../package-manager.js").ProjectCommands,
|
|
81
|
+
* changelogFiles: import("./changelog.js").PreservedReleaseFile[],
|
|
82
|
+
* execution?: "local" | "ci",
|
|
83
|
+
* ciWorker?: boolean,
|
|
84
|
+
* ciSetupFiles?: ReleaseFileUpdate[],
|
|
85
|
+
* workflowClient?: import("./github-workflow.js").GithubWorkflowClient,
|
|
86
|
+
* }} ReleaseContext
|
|
87
|
+
* @typedef {{
|
|
88
|
+
* repositoryRoot: string,
|
|
89
|
+
* reader: GitReader,
|
|
90
|
+
* config: ResolvedCreateVersionConfig,
|
|
91
|
+
* commands: import("../package-manager.js").ProjectCommands,
|
|
92
|
+
* state: { migrations: import("./config.js").MigrationCheck | null },
|
|
93
|
+
* execution?: "local" | "ci",
|
|
94
|
+
* ciWorker?: boolean,
|
|
95
|
+
* version?: string | null,
|
|
96
|
+
* }} StepContext
|
|
97
|
+
* What the steps shared with the monorepo mode read: both release contexts satisfy it.
|
|
98
|
+
* @typedef {{ mode: string, steps: import("./plan.js").ReleasePlanStep[], blockers: import("./plan.js").ReleaseBlocker[], warnings: string[] }} RenderablePlan
|
|
99
|
+
*/
|
|
100
|
+
/** Raised when the user cancels on purpose; ends the run without an error box. */
|
|
101
|
+
export declare class ReleaseCancelledError extends Error {
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Raised after syncing `main` brought new commits: the diagnosis, the plan and the configuration
|
|
105
|
+
* (with every module it imports) belong to the previous `main`, so the run ends without an error
|
|
106
|
+
* and asks to run the command again in a new process.
|
|
107
|
+
*/
|
|
108
|
+
export declare class MainSyncedRestartError extends Error {
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Prints a failure that ends the run before any step: its message and, for a {@link ReleaseStepError}, its hint.
|
|
112
|
+
*
|
|
113
|
+
* @param {unknown} error - Thrown value.
|
|
114
|
+
* @param {{ red?: boolean }} [display] - Whether the message and hint are painted red.
|
|
115
|
+
* @returns {void}
|
|
116
|
+
*/
|
|
117
|
+
export declare function printFailure(error: unknown, { red }?: {
|
|
118
|
+
red?: boolean;
|
|
119
|
+
}): void;
|
|
120
|
+
/**
|
|
121
|
+
* Lists the uncommitted changes and asks whether to set them aside for this release, as
|
|
122
|
+
* `--ignore-local-changes` does. Nothing is preselected, so a stray Enter never ignores them.
|
|
123
|
+
*
|
|
124
|
+
* @param {string[]} changes - `git status --porcelain` lines that would be set aside.
|
|
125
|
+
* @returns {Promise<boolean>} `true` to set them aside and go on.
|
|
126
|
+
*/
|
|
127
|
+
export declare function askToIgnoreLocalChanges(changes: string[]): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* Creates the context passed to project hooks.
|
|
130
|
+
*
|
|
131
|
+
* @param {string} repositoryRoot - Repository root.
|
|
132
|
+
* @param {GitReader} reader - Git reader.
|
|
133
|
+
* @param {string | null} version - Version being released, when known.
|
|
134
|
+
* @returns {HookContext} Hook context.
|
|
135
|
+
*/
|
|
136
|
+
export declare function createHookContext(repositoryRoot: string, reader: GitReader, version: string | null): HookContext;
|
|
137
|
+
/**
|
|
138
|
+
* Renders a list of commit subjects inside a box.
|
|
139
|
+
*
|
|
140
|
+
* @param {{ subject: string }[]} commits - Commits, newest first.
|
|
141
|
+
* @param {string} title - Box title.
|
|
142
|
+
* @returns {string} Box.
|
|
143
|
+
*/
|
|
144
|
+
export declare function renderCommitList(commits: {
|
|
145
|
+
subject: string;
|
|
146
|
+
}[], title: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Compares the running Node.js with `.nvmrc`, which may pin a full version or only a major.
|
|
149
|
+
*
|
|
150
|
+
* @param {string} repositoryRoot - Repository root.
|
|
151
|
+
* @returns {{ matches: boolean, pinned: string } | null} Comparison, or `null` without `.nvmrc`.
|
|
152
|
+
*/
|
|
153
|
+
export declare function checkPinnedNodeVersion(repositoryRoot: string): {
|
|
154
|
+
matches: boolean;
|
|
155
|
+
pinned: string;
|
|
156
|
+
} | null;
|
|
157
|
+
/**
|
|
158
|
+
* Renders the repository rows both diagnoses start with: the branch, the working tree and `main`
|
|
159
|
+
* compared with `origin/main`.
|
|
160
|
+
*
|
|
161
|
+
* @param {{ currentBranch: string | null, workingTreeChanges: string[], main: { aheadCommits: unknown[], behindCount: number } }} state - Repository part of a snapshot.
|
|
162
|
+
* @param {string | null} [detachedTag] - Release tag a detached `HEAD` sits on, which is only a warning.
|
|
163
|
+
* @returns {string[]} Rows.
|
|
164
|
+
*/
|
|
165
|
+
export declare function renderRepositoryRows(state: {
|
|
166
|
+
currentBranch: string | null;
|
|
167
|
+
workingTreeChanges: string[];
|
|
168
|
+
main: {
|
|
169
|
+
aheadCommits: unknown[];
|
|
170
|
+
behindCount: number;
|
|
171
|
+
};
|
|
172
|
+
}, detachedTag?: string | null): string[];
|
|
173
|
+
/**
|
|
174
|
+
* Renders the Node.js row of the diagnosis when the project pins a version in `.nvmrc`.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} repositoryRoot - Repository root.
|
|
177
|
+
* @returns {string | null} Row, or `null` without `.nvmrc`.
|
|
178
|
+
*/
|
|
179
|
+
export declare function renderNodeVersionRow(repositoryRoot: string): string | null;
|
|
180
|
+
/**
|
|
181
|
+
* Renders the npm credential row of the diagnosis: the user and where the token came from, or the problem.
|
|
182
|
+
* An owner passes without claiming that the token can write, which npm cannot check before publishing.
|
|
183
|
+
*
|
|
184
|
+
* @param {import("./npm.js").NpmAuthCheck} npmAuth - Credential check.
|
|
185
|
+
* @returns {string} Row.
|
|
186
|
+
*/
|
|
187
|
+
export declare function renderNpmAuthRow(npmAuth: import("./npm.js").NpmAuthCheck): string;
|
|
188
|
+
/**
|
|
189
|
+
* Renders the plan or its blockers.
|
|
190
|
+
*
|
|
191
|
+
* @param {RenderablePlan} plan - Plan.
|
|
192
|
+
* @returns {string} Box.
|
|
193
|
+
*/
|
|
194
|
+
export declare function renderPlan(plan: RenderablePlan): string;
|
|
195
|
+
/**
|
|
196
|
+
* Runs Git with visible output and fails the step on error.
|
|
197
|
+
*
|
|
198
|
+
* @param {StepContext} context - Release context.
|
|
199
|
+
* @param {string[]} gitArguments - Git arguments.
|
|
200
|
+
* @param {string} failureMessage - Spanish message when it fails.
|
|
201
|
+
* @param {string} hint - Spanish next action.
|
|
202
|
+
* @returns {Promise<void>}
|
|
203
|
+
*/
|
|
204
|
+
export declare function runGitStep(context: StepContext, gitArguments: string[], failureMessage: string, hint: string): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Creates an annotated release tag, failing the step when Git rejects it.
|
|
207
|
+
*
|
|
208
|
+
* @param {StepContext} context - Release context.
|
|
209
|
+
* @param {string} tag - Tag to create.
|
|
210
|
+
* @param {string} annotation - Tag message.
|
|
211
|
+
* @param {string} hint - Spanish next action when it fails.
|
|
212
|
+
* @param {string | null} [target] - Commit to tag; `HEAD` when `null`.
|
|
213
|
+
* @returns {Promise<void>}
|
|
214
|
+
*/
|
|
215
|
+
export declare function createAnnotatedTag(context: StepContext, tag: string, annotation: string, hint: string, target?: string | null): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Runs configured command lines in order, stopping at the first failure.
|
|
218
|
+
*
|
|
219
|
+
* @param {StepContext} context - Release context.
|
|
220
|
+
* @param {string[]} commandLines - Commands from `astra-rp.config.js`.
|
|
221
|
+
* @param {string} hint - Spanish next action when one fails.
|
|
222
|
+
* @returns {Promise<void>}
|
|
223
|
+
*/
|
|
224
|
+
export declare function runConfiguredCommands(context: StepContext, commandLines: string[], hint: string): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* Steps a configuration adds to the release plan.
|
|
227
|
+
*
|
|
228
|
+
* @param {ResolvedCreateVersionConfig} config - Resolved configuration.
|
|
229
|
+
* @param {string} [registryLabel] - Provider discovered from the resolved endpoint.
|
|
230
|
+
* @returns {import("./plan.js").ReleaseCapabilities} Capabilities for `buildReleasePlan`.
|
|
231
|
+
*/
|
|
232
|
+
export declare function describeReleaseCapabilities(config: ResolvedCreateVersionConfig, registryLabel?: string): import("./plan.js").ReleaseCapabilities;
|
|
233
|
+
/**
|
|
234
|
+
* Fast-forwards local `main` to `origin/main`. When that brings new commits the release stops
|
|
235
|
+
* before touching the version: the diagnosis, the plan and `astra-rp.config.(m)js` (imported with
|
|
236
|
+
* its modules at startup) come from the previous `main`, so the command must run again in a new
|
|
237
|
+
* process to diagnose with the new code and configuration.
|
|
238
|
+
*
|
|
239
|
+
* @param {StepContext} context - Release context.
|
|
240
|
+
* @returns {Promise<void>}
|
|
241
|
+
* @throws {ReleaseStepError} When the fast-forward fails.
|
|
242
|
+
* @throws {MainSyncedRestartError} When `main` moved and the command has to run again.
|
|
243
|
+
*/
|
|
244
|
+
export declare function syncMainStep(context: StepContext): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Shows the pending migrations, asks for confirmation and applies them through the project adapter.
|
|
247
|
+
*
|
|
248
|
+
* @param {StepContext} context - Release context.
|
|
249
|
+
* @returns {Promise<void>}
|
|
250
|
+
*/
|
|
251
|
+
export declare function applyMigrationsStep(context: StepContext): Promise<void>;
|
|
252
|
+
/**
|
|
253
|
+
* Runs the configured checks before touching the version.
|
|
254
|
+
*
|
|
255
|
+
* @param {StepContext} context - Release context.
|
|
256
|
+
* @returns {Promise<void>}
|
|
257
|
+
*/
|
|
258
|
+
export declare function runChecksStep(context: StepContext): Promise<void>;
|
|
259
|
+
export type ReleaseFileUpdate = {
|
|
260
|
+
filePath: string;
|
|
261
|
+
originalBytes: Buffer | null;
|
|
262
|
+
content: string;
|
|
263
|
+
};
|
|
264
|
+
export type VersionFilesContext = Pick<StepContext, "repositoryRoot" | "config" | "reader" | "commands">;
|
|
265
|
+
/**
|
|
266
|
+
* Reads a file the release rewrites, as its exact bytes and as strict UTF-8 text: writing back the
|
|
267
|
+
* text of a file that is not UTF-8 (such as ISO-8859-1) would replace its other bytes.
|
|
268
|
+
*
|
|
269
|
+
* @param {VersionFilesContext} context - Release context.
|
|
270
|
+
* @param {string} filePath - File relative to the root, `/`-separated.
|
|
271
|
+
* @param {string} fileLabel - How the messages name the file, such as `src/cli.js (versionFiles)`.
|
|
272
|
+
* @returns {{ originalBytes: Buffer, text: string }} Bytes on disk and their text.
|
|
273
|
+
* @throws {ReleaseStepError} When the file is not valid UTF-8.
|
|
274
|
+
*/
|
|
275
|
+
export declare function readReleaseFile(context: VersionFilesContext, filePath: string, fileLabel: string): {
|
|
276
|
+
originalBytes: Buffer;
|
|
277
|
+
text: string;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Writes a new version into the top-level `version` of a manifest, keeping the rest of its bytes.
|
|
281
|
+
* The text replacement changes the first `"version"` field of the file, so the result is parsed to
|
|
282
|
+
* confirm it was the top-level one and not nested metadata.
|
|
283
|
+
*
|
|
284
|
+
* @param {VersionFilesContext} context - Release context.
|
|
285
|
+
* @param {string} filePath - Manifest path relative to the root, as the messages name it.
|
|
286
|
+
* @param {string} text - Manifest content.
|
|
287
|
+
* @param {string} version - Version to write.
|
|
288
|
+
* @returns {string} Manifest content with the new top-level `version`.
|
|
289
|
+
* @throws {ReleaseStepError} When the first `"version"` of the file is not the top-level one.
|
|
290
|
+
*/
|
|
291
|
+
export declare function rewriteManifestVersion(context: VersionFilesContext, filePath: string, text: string, version: string): string;
|
|
292
|
+
/**
|
|
293
|
+
* Computes the new content of `versionFiles` entries before anything is written, so
|
|
294
|
+
* a missing, non-regular (symlink or directory), untracked, non-UTF-8 or unmarked file stops the release with the version untouched.
|
|
295
|
+
*
|
|
296
|
+
* @param {VersionFilesContext} context - Release context.
|
|
297
|
+
* @param {readonly string[]} versionFiles - Entries that get `version`: every configured one, or in a
|
|
298
|
+
* monorepo the ones inside the package being released.
|
|
299
|
+
* @param {string} version - Version being released.
|
|
300
|
+
* @returns {Promise<ReleaseFileUpdate[]>} Files to write, with their bytes before the release.
|
|
301
|
+
* @throws {ReleaseStepError} When a file is missing, is not a regular file, is not tracked by Git, is not valid UTF-8, has
|
|
302
|
+
* block markers paired wrongly or none of its lines is marked.
|
|
303
|
+
*/
|
|
304
|
+
export declare function prepareVersionFileUpdates(context: VersionFilesContext, versionFiles: readonly string[], version: string): Promise<ReleaseFileUpdate[]>;
|
|
305
|
+
/**
|
|
306
|
+
* Stops the release when an earlier step (such as a check running a formatter with `--fix`) changed
|
|
307
|
+
* a `package.json` or a `versionFiles` entry: the plan requires them clean, so any difference from
|
|
308
|
+
* `HEAD` would be read as the original content and shipped in the release commit.
|
|
309
|
+
*
|
|
310
|
+
* @param {VersionFilesContext} context - Release context.
|
|
311
|
+
* @param {readonly string[]} filePaths - Manifests and `versionFiles` entries the release rewrites.
|
|
312
|
+
* @returns {Promise<void>}
|
|
313
|
+
* @throws {ReleaseStepError} When any of those files differs from `HEAD`.
|
|
314
|
+
*/
|
|
315
|
+
export declare function assertReleaseFilesMatchHead(context: VersionFilesContext, filePaths: readonly string[]): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* Writes the release files (versions and closed changelogs), stages them literally and creates the
|
|
318
|
+
* release commit, checking that it holds exactly the prepared tree. Any failure (or a hook that changes
|
|
319
|
+
* the commit, or rewrites a closed changelog in the working tree) rolls the files and their staging
|
|
320
|
+
* back and undoes the commit, so no tag is created.
|
|
321
|
+
*
|
|
322
|
+
* @param {StepContext} context - Release context.
|
|
323
|
+
* @param {ReleaseFileUpdate[]} releaseFiles - Files of the release commit, with their bytes before the release.
|
|
324
|
+
* @param {string} subject - Subject of the release commit.
|
|
325
|
+
* @param {readonly ReleaseFileUpdate[]} [closedChangelogs] - Changelogs among `releaseFiles` whose working-tree bytes
|
|
326
|
+
* must still hold their closed `[Unreleased]` after the commit.
|
|
327
|
+
* @param {readonly string[]} [trailers] - Trailer lines (`Key: value`) appended as the last paragraph of the commit message.
|
|
328
|
+
* @returns {Promise<void>}
|
|
329
|
+
* @throws {ReleaseStepError} When writing, staging or committing fails, or the commit differs from the prepared tree.
|
|
330
|
+
*/
|
|
331
|
+
export declare function commitReleaseFiles(context: StepContext, releaseFiles: ReleaseFileUpdate[], subject: string, closedChangelogs?: readonly ReleaseFileUpdate[], trailers?: readonly string[]): Promise<void>;
|
|
332
|
+
/**
|
|
333
|
+
* Checks that no tracked file differs from `HEAD` before publishing. `prepare` may create untracked
|
|
334
|
+
* or ignored output (`dist/`, `releases/`), but a modified tracked file (such as `package.json`)
|
|
335
|
+
* means the publication would no longer be the release commit.
|
|
336
|
+
*
|
|
337
|
+
* @param {{ reader: GitReader, commands: import("../package-manager.js").ProjectCommands }} context - Git reader of
|
|
338
|
+
* the checkout being published and the project commands quoted by the hint.
|
|
339
|
+
* @returns {Promise<void>}
|
|
340
|
+
* @throws {ReleaseStepError} When Git cannot report the working tree state or a tracked file changed.
|
|
341
|
+
*/
|
|
342
|
+
export declare function assertNoTrackedChanges(context: {
|
|
343
|
+
reader: GitReader;
|
|
344
|
+
commands: import("../package-manager.js").ProjectCommands;
|
|
345
|
+
}): Promise<void>;
|
|
346
|
+
/**
|
|
347
|
+
* Runs `create-version` in a repository.
|
|
348
|
+
*
|
|
349
|
+
* @param {{ repositoryRoot: string, argv: string[] }} options - Repository root and arguments after the command name.
|
|
350
|
+
* @returns {Promise<number>} Process exit code.
|
|
351
|
+
*/
|
|
352
|
+
export declare function runCreateVersion({ repositoryRoot, argv }: {
|
|
353
|
+
repositoryRoot: string;
|
|
354
|
+
argv: string[];
|
|
355
|
+
}): Promise<number>;
|
|
356
|
+
/**
|
|
357
|
+
* Sets the uncommitted changes aside while an operation runs and restores them afterwards, whatever
|
|
358
|
+
* its outcome; shared with the monorepo mode.
|
|
359
|
+
*
|
|
360
|
+
* @param {{
|
|
361
|
+
* reader: GitReader,
|
|
362
|
+
* repositoryRoot: string,
|
|
363
|
+
* changeCount: number,
|
|
364
|
+
* setAsideOptions: Parameters<typeof setAsideLocalChanges>[1],
|
|
365
|
+
* messages: { setAside: string, restored: string, recovery: string },
|
|
366
|
+
* }} localChanges - Repository, how many changes to set aside (none skips it), the options of
|
|
367
|
+
* {@link setAsideLocalChanges} and the Spanish messages printed after setting aside, after
|
|
368
|
+
* restoring and when the restore fails.
|
|
369
|
+
* @param {() => Promise<number>} operation - Work run with the changes set aside.
|
|
370
|
+
* @returns {Promise<number>} Exit code of the operation, or a failure when the changes could not be set aside.
|
|
371
|
+
*/
|
|
372
|
+
export declare function withLocalChangesSetAside({ reader, repositoryRoot, changeCount, setAsideOptions, messages }: {
|
|
373
|
+
reader: GitReader;
|
|
374
|
+
repositoryRoot: string;
|
|
375
|
+
changeCount: number;
|
|
376
|
+
setAsideOptions: Parameters<typeof setAsideLocalChanges>[1];
|
|
377
|
+
messages: {
|
|
378
|
+
setAside: string;
|
|
379
|
+
restored: string;
|
|
380
|
+
recovery: string;
|
|
381
|
+
};
|
|
382
|
+
}, operation: () => Promise<number>): Promise<number>;
|
|
383
|
+
/**
|
|
384
|
+
* Runs the plan steps in order and prints the outcome; shared with the monorepo mode.
|
|
385
|
+
*
|
|
386
|
+
* @template {{ commands: import("../package-manager.js").ProjectCommands }} Context
|
|
387
|
+
* @param {Context} context - Release context passed to every step.
|
|
388
|
+
* @param {{
|
|
389
|
+
* steps: import("./plan.js").ReleasePlanStep[],
|
|
390
|
+
* executors: Record<string, (context: Context) => Promise<void>>,
|
|
391
|
+
* untouchedNote: string,
|
|
392
|
+
* describeFailureFollowUp: (context: Context) => Promise<string[]>,
|
|
393
|
+
* renderSummary: (context: Context) => string | null,
|
|
394
|
+
* }} planRun - Steps and their executors, what a restart after syncing `main` left untouched, the lines
|
|
395
|
+
* that close a failure box, and the closing summary (`null` for the generic one).
|
|
396
|
+
* @param {number} startedAt - Start time of the command, in milliseconds.
|
|
397
|
+
* @returns {Promise<number>} Process exit code.
|
|
398
|
+
*/
|
|
399
|
+
export declare function runPlanSteps<Context extends {
|
|
400
|
+
commands: import("../package-manager.js").ProjectCommands;
|
|
401
|
+
}>(context: Context, { steps, executors, untouchedNote, describeFailureFollowUp, renderSummary }: {
|
|
402
|
+
steps: import("./plan.js").ReleasePlanStep[];
|
|
403
|
+
executors: Record<string, (context: Context) => Promise<void>>;
|
|
404
|
+
untouchedNote: string;
|
|
405
|
+
describeFailureFollowUp: (context: Context) => Promise<string[]>;
|
|
406
|
+
renderSummary: (context: Context) => string | null;
|
|
407
|
+
}, startedAt: number): Promise<number>;
|