@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,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contracts shared by local release preparation and the GitHub Actions worker.
|
|
3
|
+
* @module constants/ci-release
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CREATE_VERSION_CONFIG_FILES, PACKAGE_MANIFEST_FILE, PINNED_NODE_VERSION_FILE, PROJECT_NPM_CONFIG_FILE } from "./create-version.js";
|
|
7
|
+
import { LOCKFILE_NAMES, PACKAGE_MANAGER } from "./package-manager.js";
|
|
8
|
+
import { GITHUB_PACKAGES_HOST, GITHUB_REGISTRY_TOKEN_VARIABLE } from "./registry.js";
|
|
9
|
+
|
|
10
|
+
/** Release execution locations offered by the CLI. */
|
|
11
|
+
export const RELEASE_EXECUTION = Object.freeze({ local: "local", ci: "ci" });
|
|
12
|
+
|
|
13
|
+
/** Choices offered when the repository has no CI release configuration. */
|
|
14
|
+
export const CI_SETUP_CHOICE = Object.freeze({ configure: "configure", local: "local", cancel: "cancel" });
|
|
15
|
+
|
|
16
|
+
/** Default workflow filename, relative to GitHub's workflow directory. */
|
|
17
|
+
export const DEFAULT_CI_WORKFLOW = "release.yml";
|
|
18
|
+
|
|
19
|
+
/** Directory GitHub reads for versioned workflows. */
|
|
20
|
+
export const CI_WORKFLOW_DIRECTORY = ".github/workflows";
|
|
21
|
+
|
|
22
|
+
/** Named configuration export used by automatic setup without rewriting existing hooks. */
|
|
23
|
+
export const CI_CONFIG_EXPORT = "ci";
|
|
24
|
+
|
|
25
|
+
/** Workflow filenames accepted as a configuration value or CLI argument. */
|
|
26
|
+
export const CI_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*\.ya?ml$/u;
|
|
27
|
+
|
|
28
|
+
/** Environment variable names allowed in generated secret and variable bindings. */
|
|
29
|
+
export const CI_ENVIRONMENT_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/u;
|
|
30
|
+
|
|
31
|
+
/** Full Git commit identity passed to the worker. */
|
|
32
|
+
export const CI_COMMIT_SHA_PATTERN = /^[a-f0-9]{40,64}$/u;
|
|
33
|
+
|
|
34
|
+
/** Worker inputs exposed through environment variables instead of shell interpolation. */
|
|
35
|
+
export const CI_RELEASE_ENVIRONMENT = Object.freeze({ version: "ASTRA_RP_RELEASE_VERSION", sha: "ASTRA_RP_RELEASE_SHA" });
|
|
36
|
+
|
|
37
|
+
/** Environment variable carrying the dispatched release tag into generated workflow steps. */
|
|
38
|
+
export const CI_RELEASE_TAG_ENVIRONMENT = "RELEASE_TAG";
|
|
39
|
+
|
|
40
|
+
/** Step that authenticates the dispatched tag, commit and `origin/main` ancestry before any project code runs. */
|
|
41
|
+
export const CI_RELEASE_IDENTITY_STEP_NAME = "Verificar identidad del release";
|
|
42
|
+
|
|
43
|
+
/** POSIX ERE equivalent of `RELEASE_VERSION_PATTERN` for the dependency-free identity step (Bash has no `\d`). */
|
|
44
|
+
export const CI_RELEASE_VERSION_SHELL_PATTERN = "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$";
|
|
45
|
+
|
|
46
|
+
/** Environment signals that prevent a CI worker from dispatching another workflow. */
|
|
47
|
+
export const CI_RUNTIME_ENVIRONMENT = Object.freeze(["CI", "GITHUB_ACTIONS", "GITLAB_CI"]);
|
|
48
|
+
|
|
49
|
+
/** Normalized (trimmed, lowercase) CI signal values that explicitly mean "not a CI runtime"; any other non-empty value enables it. */
|
|
50
|
+
export const CI_RUNTIME_DISABLED_VALUES = Object.freeze(["", "0", "false", "no", "off"]);
|
|
51
|
+
|
|
52
|
+
/** Relative template path from the CI setup module. */
|
|
53
|
+
export const CI_RELEASE_TEMPLATE_FILE = "./templates/release.yml";
|
|
54
|
+
|
|
55
|
+
/** Placeholders owned by the release workflow template. */
|
|
56
|
+
export const CI_TEMPLATE_PLACEHOLDER = Object.freeze({ node: "__NODE_SETUP__", install: "__PACKAGE_SETUP__", environment: "__RELEASE_ENVIRONMENT__", permissions: "__RELEASE_PERMISSIONS__", command: "__RELEASE_COMMAND__", deploymentSetup: "__DEPLOYMENT_SETUP__", deployment: "__DEPLOYMENT_STEP__", deno: "__DENO_SETUP__", identity: "__RELEASE_IDENTITY_CHECK__" });
|
|
57
|
+
|
|
58
|
+
/** Version pin formats safe to place in generated package manager setup commands. */
|
|
59
|
+
export const CI_PACKAGE_MANAGER_VERSION_PATTERN = /^(?:pnpm|npm|yarn|bun)@([0-9]+(?:\.[0-9]+){0,2}(?:-[a-zA-Z0-9.-]+)?)(?:\+sha\d+\.[a-fA-F0-9]+)?$/u;
|
|
60
|
+
|
|
61
|
+
/** Numeric Node.js pins (`22`, `22.14`, `v22.14.0` without its `v`) that setup-node resolves to a comparable release; aliases such as `lts/*` stay unverifiable. */
|
|
62
|
+
export const CI_NODE_VERSION_PIN_PATTERN = /^[0-9]+(?:\.[0-9]+){0,2}(?:-[a-zA-Z0-9.-]+)?$/u;
|
|
63
|
+
|
|
64
|
+
/** Git tree modes of regular files (non-executable and executable); symlinks (`120000`) and submodules are excluded. */
|
|
65
|
+
export const GIT_REGULAR_FILE_MODES = Object.freeze(["100644", "100755"]);
|
|
66
|
+
|
|
67
|
+
/** Maximum external diagnostic length displayed by the CLI, in characters. */
|
|
68
|
+
export const CI_DIAGNOSTIC_LIMIT = 800;
|
|
69
|
+
|
|
70
|
+
/** Credentials that must be redacted from GitHub CLI diagnostics. */
|
|
71
|
+
export const CI_GITHUB_TOKEN_VARIABLES = Object.freeze(["GH_TOKEN", GITHUB_REGISTRY_TOKEN_VARIABLE, "GH_ENTERPRISE_TOKEN", "GITHUB_ENTERPRISE_TOKEN"]);
|
|
72
|
+
|
|
73
|
+
/** Maximum workflow runs considered when reconciling an uncertain dispatch. */
|
|
74
|
+
export const CI_RUN_LOOKUP_LIMIT = 100;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* REST resources (under `repos/{owner}/{repo}/actions/`) listing organization bindings that GitHub
|
|
78
|
+
* exposes to one repository, keyed by `gh` binding kind. Unlike `gh secret list --org`, they honor
|
|
79
|
+
* each binding's repository visibility, so they match what `${{ secrets.* }}`/`${{ vars.* }}` resolve.
|
|
80
|
+
*/
|
|
81
|
+
export const CI_ORGANIZATION_BINDING_RESOURCE = Object.freeze({
|
|
82
|
+
secret: Object.freeze({ path: "organization-secrets", collection: "secrets" }),
|
|
83
|
+
variable: Object.freeze({ path: "organization-variables", collection: "variables" }),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/** Page size requested when listing organization bindings shared with a repository. */
|
|
87
|
+
export const CI_ORGANIZATION_BINDING_PAGE_SIZE = 100;
|
|
88
|
+
|
|
89
|
+
/** Git override that delegates hooks to the worker during local CI preparation. */
|
|
90
|
+
export const CI_GIT_HOOKS_OPTION = "core.hooksPath=/dev/null";
|
|
91
|
+
|
|
92
|
+
/** Release step that submits the already-pushed release to GitHub Actions. */
|
|
93
|
+
export const DISPATCH_CI_RELEASE_STEP = "dispatch-ci-release";
|
|
94
|
+
|
|
95
|
+
/** Stable failure categories of the GitHub workflow boundary. */
|
|
96
|
+
export const CI_FAILURE_CODE = Object.freeze({ preflight: "ci-preflight-failed", lookup: "ci-run-lookup-failed", dispatch: "ci-dispatch-unconfirmed" });
|
|
97
|
+
|
|
98
|
+
/** Default Yarn Classic pin when the project does not declare a package manager version. */
|
|
99
|
+
export const CI_DEFAULT_YARN_VERSION = "1.22.22";
|
|
100
|
+
|
|
101
|
+
/** pnpm setup pin for repositories detected only through their lockfile. */
|
|
102
|
+
export const CI_DEFAULT_PNPM_VERSION = "12.6.0";
|
|
103
|
+
|
|
104
|
+
/** Deno runtime installed when JSR publication selects its native client. */
|
|
105
|
+
export const CI_DENO_VERSION = "v2.9.7";
|
|
106
|
+
|
|
107
|
+
/** Native JSR client that needs a Deno runtime in the generated workflow. */
|
|
108
|
+
export const CI_DENO_JSR_CLIENT = "deno";
|
|
109
|
+
|
|
110
|
+
/** Observable acceptance outcomes returned by the workflow adapter. */
|
|
111
|
+
export const CI_DISPATCH_STATUS = Object.freeze({ submitted: "submitted", existing: "existing" });
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Prefix of the temporary directory, created inside the repository's Git directory, where `--retry-ci`
|
|
115
|
+
* checks out the release tag to load the configuration stored in it; living under the checkout lets the
|
|
116
|
+
* tagged configuration resolve the project's installed dependencies while staying outside the working tree.
|
|
117
|
+
*/
|
|
118
|
+
export const CI_RELEASE_TAG_CONFIG_DIRECTORY_PREFIX = "astra-rp-release-tag-config-";
|
|
119
|
+
|
|
120
|
+
/** Early-build metadata; its version and the commit that changes it scope the decision to exactly one release commit. */
|
|
121
|
+
export const CI_RELEASE_METADATA_FILE = ".astra-rp/release.json";
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Git trailer of the release commit naming where it was prepared (`local` or `ci`), so a resume after a
|
|
125
|
+
* failed push keeps that location for every release, not only those whose Vercel metadata records it.
|
|
126
|
+
*/
|
|
127
|
+
export const RELEASE_EXECUTION_TRAILER = "Astra-Rp-Execution";
|
|
128
|
+
|
|
129
|
+
/** Vercel project configuration used to offer deployment setup for applications. */
|
|
130
|
+
export const CI_VERCEL_CONFIG_FILE = "vercel.json";
|
|
131
|
+
|
|
132
|
+
/** Provider handled by the generated application deployment steps. */
|
|
133
|
+
export const CI_VERCEL_DEPLOYMENT = "vercel";
|
|
134
|
+
|
|
135
|
+
/** Generated step that lets dependency installs (including `vercel build`) read GitHub Packages. */
|
|
136
|
+
export const CI_GITHUB_PACKAGES_AUTHENTICATION_STEP = "Autenticar GitHub Packages";
|
|
137
|
+
|
|
138
|
+
/** Step-scoped variable carrying the built-in Actions token into the GitHub Packages authentication step. */
|
|
139
|
+
export const CI_GITHUB_PACKAGES_TOKEN_VARIABLE = "GITHUB_PACKAGES_TOKEN";
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* User npm config key bound to GitHub Packages. The user config (`~/.npmrc`) is read by npm and pnpm (which
|
|
143
|
+
* ignores credentials in the repository `.npmrc`), the only package managers the generated workflow authenticates.
|
|
144
|
+
*/
|
|
145
|
+
export const CI_GITHUB_PACKAGES_AUTH_TOKEN_KEY = `//${GITHUB_PACKAGES_HOST}/:_authToken`;
|
|
146
|
+
|
|
147
|
+
/** Shell path of the runner's user npm config, where the generated step stores the GitHub Packages token. */
|
|
148
|
+
export const CI_RUNNER_NPM_USER_CONFIG_PATH = "$HOME/.npmrc";
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Variables that locate the runner's user config outside the package managers' own settings: `HOME` (the
|
|
152
|
+
* generated step writes `$HOME/.npmrc`) and `XDG_CONFIG_HOME` (pnpm reads its global config under it). A job
|
|
153
|
+
* binding of one of them would hide the token the workflow stores there from the install.
|
|
154
|
+
*/
|
|
155
|
+
export const CI_NPM_USER_CONFIG_LOCATION_VARIABLES = Object.freeze(["HOME", "XDG_CONFIG_HOME"]);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Uppercase prefixes of the variables through which npm and pnpm (`NPM_CONFIG_*`, `PNPM_CONFIG_*`, read in any
|
|
159
|
+
* casing) take any setting from the environment, outranking the committed `.npmrc`: the registry, the user or
|
|
160
|
+
* global config file, credentials, TLS and so on. None can be proven safe before dispatch, so the generated
|
|
161
|
+
* workflow rejects every job binding with one of them whenever it hands the package manager the Actions token.
|
|
162
|
+
*/
|
|
163
|
+
export const CI_PACKAGE_MANAGER_CONFIG_VARIABLE_PREFIXES = Object.freeze(["NPM_CONFIG_", "PNPM_CONFIG_"]);
|
|
164
|
+
|
|
165
|
+
/** Only URL protocol accepted for a GitHub Packages registry, so the workflow token never travels in clear text. */
|
|
166
|
+
export const CI_GITHUB_PACKAGES_REGISTRY_PROTOCOL = "https:";
|
|
167
|
+
|
|
168
|
+
/** Quote character whose wrapped `.npmrc` key or value npm's INI parser decodes as a JSON string. */
|
|
169
|
+
export const NPM_CONFIG_JSON_QUOTE = '"';
|
|
170
|
+
|
|
171
|
+
/** `.npmrc` key selecting a registry, default (`registry`) or scoped (`@scope:registry`). */
|
|
172
|
+
export const NPM_CONFIG_REGISTRY_KEY_PATTERN = /^(?:@[^\s:]+:)?registry$/u;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Every project `.npmrc` key bound to the GitHub Packages host, whatever its path or field (owner paths,
|
|
176
|
+
* `certfile`, pnpm's `:@scope:_authToken`, array keys...). The host must end right there (followed by `/`,
|
|
177
|
+
* `:` or nothing), so another host that only starts with the same name, such as `//npm.pkg.github.com.corp.example/`,
|
|
178
|
+
* is not bound to GitHub Packages. Only `CI_GITHUB_PACKAGES_AUTH_TOKEN_KEY` is accepted among them.
|
|
179
|
+
* The pattern spells {@link GITHUB_PACKAGES_HOST} literally, escaped for a regular expression.
|
|
180
|
+
*/
|
|
181
|
+
export const NPM_CONFIG_GITHUB_PACKAGES_KEY_PATTERN = /^\/\/npm\.pkg\.github\.com(?:[/:]|$)/u;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Package managers whose GitHub Packages install the generated workflow authenticates through the runner's `~/.npmrc`.
|
|
185
|
+
* @type {readonly import("../package-manager.js").PackageManagerName[]}
|
|
186
|
+
*/
|
|
187
|
+
export const CI_GITHUB_PACKAGES_AUTHENTICATED_PACKAGE_MANAGERS = Object.freeze([PACKAGE_MANAGER.npm, PACKAGE_MANAGER.pnpm]);
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Committed configuration files of the package managers the generated workflow does not authenticate, whose
|
|
191
|
+
* uncommented mention of the GitHub Packages host is a GitHub Packages signal: Yarn reads `.yarnrc` (Yarn 1) and
|
|
192
|
+
* `.yarnrc.yml` (Yarn 2+), Bun reads `bunfig.toml`. Other package managers never read them, so they are not inspected.
|
|
193
|
+
* @type {Readonly<Partial<Record<import("../package-manager.js").PackageManagerName, readonly string[]>>>}
|
|
194
|
+
*/
|
|
195
|
+
export const CI_UNAUTHENTICATED_PACKAGE_MANAGER_CONFIG_FILES = Object.freeze({
|
|
196
|
+
[PACKAGE_MANAGER.yarn]: Object.freeze([".yarnrc", ".yarnrc.yml"]),
|
|
197
|
+
[PACKAGE_MANAGER.bun]: Object.freeze(["bunfig.toml"]),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
/** Prefix of a comment line (after trimming) in `.yarnrc`, `.yarnrc.yml`, `bunfig.toml` and `pnpm-workspace.yaml`. */
|
|
201
|
+
export const PACKAGE_MANAGER_CONFIG_COMMENT_PREFIX = "#";
|
|
202
|
+
|
|
203
|
+
/** Mention of the GitHub Packages host ({@link GITHUB_PACKAGES_HOST}, spelled literally) in a package manager config line, in any casing. */
|
|
204
|
+
export const GITHUB_PACKAGES_HOST_MENTION_PATTERN = /npm\.pkg\.github\.com/iu;
|
|
205
|
+
|
|
206
|
+
/** pnpm workspace config, from which pnpm 11+ reads registries and network settings besides the `.npmrc`. */
|
|
207
|
+
export const PNPM_WORKSPACE_CONFIG_FILE = "pnpm-workspace.yaml";
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* `pnpm-workspace.yaml` line defining a registry or network setting (`registry`, `registries`, TLS, certificates or
|
|
211
|
+
* proxies) as a key at the start of the line, with or without indentation or quotes, followed by `:`. The generated
|
|
212
|
+
* workflow only validates registries in the `.npmrc`, so any of them could send the token somewhere unchecked.
|
|
213
|
+
*/
|
|
214
|
+
export const PNPM_WORKSPACE_NETWORK_SETTING_LINE_PATTERN = /^\s*(["']?)(?:registry|registries|strictSsl|strict-ssl|ca|cafile|cert|key|proxy|httpsProxy|https-proxy|noProxy)\1\s*:/u;
|
|
215
|
+
|
|
216
|
+
/** GitHub Packages origin over plain HTTP, named in the error about a lockfile that resolves packages from it. */
|
|
217
|
+
export const LOCKFILE_GITHUB_PACKAGES_HTTP_URL = `http://${GITHUB_PACKAGES_HOST}`;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* {@link LOCKFILE_GITHUB_PACKAGES_HTTP_URL} inside a lockfile, matched as text in any casing. The host must end right
|
|
221
|
+
* there (followed by `/`, `:`, a quote, whitespace or the end of the text), so another host that only starts with the
|
|
222
|
+
* same name, such as `http://npm.pkg.github.com.corp.example/`, never receives the generated credential and is not matched.
|
|
223
|
+
* The pattern spells {@link GITHUB_PACKAGES_HOST} literally, escaped for a regular expression.
|
|
224
|
+
*/
|
|
225
|
+
export const LOCKFILE_GITHUB_PACKAGES_HTTP_URL_PATTERN = /http:\/\/npm\.pkg\.github\.com(?=[/:"'\s]|$)/iu;
|
|
226
|
+
|
|
227
|
+
/** `.npmrc` key that turns TLS certificate verification on or off. */
|
|
228
|
+
export const NPM_CONFIG_STRICT_SSL_KEY = "strict-ssl";
|
|
229
|
+
|
|
230
|
+
/** Effective `.npmrc` value that turns a boolean setting such as {@link NPM_CONFIG_STRICT_SSL_KEY} off. */
|
|
231
|
+
export const NPM_CONFIG_DISABLED_VALUE = "false";
|
|
232
|
+
|
|
233
|
+
/** Environment variables that turn off Node.js TLS certificate verification for every request of the install. */
|
|
234
|
+
export const CI_TLS_VERIFICATION_DISABLING_VARIABLES = Object.freeze(["NODE_TLS_REJECT_UNAUTHORIZED"]);
|
|
235
|
+
|
|
236
|
+
/** Indentation and marker opening each job step in the generated workflow. */
|
|
237
|
+
export const CI_WORKFLOW_STEP_PREFIX = " - ";
|
|
238
|
+
|
|
239
|
+
/** Job-level binding of the built-in Actions token in the generated workflow. */
|
|
240
|
+
export const CI_GITHUB_TOKEN_JOB_BINDING = ` ${GITHUB_REGISTRY_TOKEN_VARIABLE}: \${{ github.token }}`;
|
|
241
|
+
|
|
242
|
+
/** Permission line the generated workflow adds to read or publish GitHub Packages. */
|
|
243
|
+
export const CI_GITHUB_PACKAGES_PERMISSION_LINE_PATTERN = /^ {2}packages: (?:read|write)$/u;
|
|
244
|
+
|
|
245
|
+
/** Value npm's INI parser gives a `.npmrc` key written without `=`. */
|
|
246
|
+
export const NPM_CONFIG_VALUELESS_KEY_VALUE = true;
|
|
247
|
+
|
|
248
|
+
/** Line terminators npm's INI parser splits a `.npmrc` on: CRLF, LF or a lone CR. */
|
|
249
|
+
export const NPM_CONFIG_LINE_BREAK_PATTERN = /\r\n|[\r\n]/u;
|
|
250
|
+
|
|
251
|
+
/** `.npmrc` value that is exactly one `${NAME}` environment reference; captures the variable name. */
|
|
252
|
+
export const NPM_CONFIG_ENVIRONMENT_REFERENCE_PATTERN = /^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/u;
|
|
253
|
+
|
|
254
|
+
/** Every `${NAME}` environment reference inside a `.npmrc` value, as npm expands them; captures each variable name. */
|
|
255
|
+
export const NPM_CONFIG_ENVIRONMENT_REFERENCES_PATTERN = /\$\{([^${}]+)\}/gu;
|
|
256
|
+
|
|
257
|
+
/** Start of an inline comment in an unquoted `.npmrc` value (INI syntax: an unescaped `;` or `#`). */
|
|
258
|
+
export const NPM_CONFIG_INLINE_COMMENT_PATTERN = /(?<!\\)[;#]/u;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* `.npmrc` INI section header (`[name]`), matched against the raw, untrimmed line exactly as npm's INI parser
|
|
262
|
+
* does: the bracket must open the line, the name cannot contain `]` and only whitespace may follow. npm nests
|
|
263
|
+
* every later key under that section, so those keys never configure the top-level registries or credentials;
|
|
264
|
+
* any other bracketed line (indented or malformed) is a plain key.
|
|
265
|
+
*/
|
|
266
|
+
export const NPM_CONFIG_SECTION_HEADER_PATTERN = /^\[[^\]]*\]\s*$/u;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Suffix npm's INI parser removes from an array key (`key[]=value`), so the entry still configures `key`.
|
|
270
|
+
* Keys bound to GitHub Packages keep it, so they are always rejected instead of read as their last assignment.
|
|
271
|
+
*/
|
|
272
|
+
export const NPM_CONFIG_ARRAY_KEY_SUFFIX = "[]";
|
|
273
|
+
|
|
274
|
+
/** Prefixes of `.npmrc` comment lines. */
|
|
275
|
+
export const NPM_CONFIG_COMMENT_PREFIXES = Object.freeze([PACKAGE_MANAGER_CONFIG_COMMENT_PREFIX, ";"]);
|
|
276
|
+
|
|
277
|
+
/** Quote characters that may wrap a whole `.npmrc` key or value. */
|
|
278
|
+
export const NPM_CONFIG_QUOTES = Object.freeze([NPM_CONFIG_JSON_QUOTE, "'"]);
|
|
279
|
+
|
|
280
|
+
/** Vercel CLI version used by generated workflows. */
|
|
281
|
+
export const CI_VERCEL_CLI_VERSION = "62.2.0";
|
|
282
|
+
|
|
283
|
+
/** Repository secrets required to deploy prebuilt output to Vercel. */
|
|
284
|
+
export const CI_VERCEL_SECRETS = Object.freeze(["VERCEL_TOKEN", "VERCEL_ORG_ID", "VERCEL_PROJECT_ID"]);
|
|
285
|
+
|
|
286
|
+
/** Paths the generated Vercel worker writes after checkout; they must stay untracked to keep the release tree clean. */
|
|
287
|
+
export const CI_VERCEL_WORKER_WRITTEN_PATHS = Object.freeze([".env", ".vercel"]);
|
|
288
|
+
|
|
289
|
+
/** Environment names explicitly mentioned by a project's migration target hint. */
|
|
290
|
+
export const CI_MIGRATION_ENVIRONMENT_PATTERN = /\b[A-Z][A-Z0-9_]*(?:URL|TOKEN|KEY|SECRET|PASSWORD)\b/gu;
|
|
291
|
+
|
|
292
|
+
/** Bindings owned by the worker protocol and unavailable for user overrides. */
|
|
293
|
+
export const CI_RESERVED_ENVIRONMENT_NAMES = Object.freeze([CI_RELEASE_TAG_ENVIRONMENT, "HUSKY", ...Object.values(CI_RELEASE_ENVIRONMENT)]);
|
|
294
|
+
|
|
295
|
+
/** Generated Vercel gate; it runs before dependencies are installed. */
|
|
296
|
+
export const CI_VERCEL_GATE_FILE = ".astra-rp/vercel-ignore-build.mjs";
|
|
297
|
+
|
|
298
|
+
/** Relative template path for the dependency-free Vercel gate. */
|
|
299
|
+
export const CI_VERCEL_GATE_TEMPLATE = "./templates/vercel-ignore-build.mjs";
|
|
300
|
+
|
|
301
|
+
/** Template placeholder preserving the project's original ignoreCommand. */
|
|
302
|
+
export const CI_VERCEL_IGNORE_PLACEHOLDER = "__ORIGINAL_IGNORE_COMMAND__";
|
|
303
|
+
|
|
304
|
+
/** Rendered workflow lines quoted when a committed generated workflow drifted from the current configuration. */
|
|
305
|
+
export const CI_WORKFLOW_DRIFT_PREVIEW_LINES = 3;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Root-relative files that shape what the CI worker runs besides the configured workflow: the
|
|
309
|
+
* configuration modules, the manifest, the project npm config, the Node.js pin and every lockfile.
|
|
310
|
+
* Local preparation reads them from the working tree while the worker checks them out from the
|
|
311
|
+
* release tag, so `--ignore-local-changes` must not set changes to them aside during CI preparation.
|
|
312
|
+
*/
|
|
313
|
+
export const CI_WORKER_CONFIGURATION_FILES = Object.freeze([
|
|
314
|
+
...CREATE_VERSION_CONFIG_FILES,
|
|
315
|
+
PACKAGE_MANIFEST_FILE,
|
|
316
|
+
PROJECT_NPM_CONFIG_FILE,
|
|
317
|
+
PINNED_NODE_VERSION_FILE,
|
|
318
|
+
...LOCKFILE_NAMES,
|
|
319
|
+
]);
|
|
320
|
+
|
|
321
|
+
/** Prefix of the `run-name` the generated workflow gives each dispatched release, followed by its tag and commit. */
|
|
322
|
+
export const CI_RELEASE_RUN_TITLE_PREFIX = "astra-rp release";
|
|
323
|
+
|
|
324
|
+
/** Generated workflow step that runs `--ci-release`; its success proves checks, preparation and publication finished. */
|
|
325
|
+
export const CI_RELEASE_WORKER_STEP_NAME = "Checks y publicación del release";
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Environment the worker reads to query its own GitHub Actions history (set by Actions, plus the bound
|
|
329
|
+
* job token); the run id and attempt identify the attempt executing the worker, excluded from that history.
|
|
330
|
+
*/
|
|
331
|
+
export const CI_ACTIONS_HISTORY_ENVIRONMENT = Object.freeze({ apiUrl: "GITHUB_API_URL", repository: "GITHUB_REPOSITORY", token: GITHUB_REGISTRY_TOKEN_VARIABLE, runId: "GITHUB_RUN_ID", runAttempt: "GITHUB_RUN_ATTEMPT" });
|
|
332
|
+
|
|
333
|
+
/** GitHub REST API used when the runner does not provide `GITHUB_API_URL`. */
|
|
334
|
+
export const CI_DEFAULT_GITHUB_API_URL = "https://api.github.com";
|
|
335
|
+
|
|
336
|
+
/** REST API version pinned for the worker's Actions history requests. */
|
|
337
|
+
export const CI_GITHUB_API_VERSION = "2022-11-28";
|
|
338
|
+
|
|
339
|
+
/** Page size of the worker's Actions history requests; one release has far fewer runs, attempts or jobs. */
|
|
340
|
+
export const CI_ACTIONS_HISTORY_PAGE_SIZE = 100;
|
|
341
|
+
|
|
342
|
+
/** Maximum wait for each Actions history request before the worker stops without publishing, in milliseconds. */
|
|
343
|
+
export const CI_ACTIONS_HISTORY_TIMEOUT_MS = 30_000;
|
|
344
|
+
|
|
345
|
+
/** Step conclusion GitHub Actions reports for a step that finished successfully. */
|
|
346
|
+
export const CI_STEP_SUCCESS_CONCLUSION = "success";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commands understood by the `astra-rp` command line.
|
|
3
|
+
*
|
|
4
|
+
* @module constants/cli
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Command names accepted as the first `astra-rp` argument. */
|
|
8
|
+
export const CLI_COMMAND = Object.freeze({
|
|
9
|
+
ignoreBuild: "ignore-build",
|
|
10
|
+
createVersion: "create-version",
|
|
11
|
+
guardPublish: "guard-publish",
|
|
12
|
+
});
|