@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,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure explanations of the npm credential check of `astra-rp create-version`:
|
|
3
|
+
* the blocker the planner shows before anything is touched, and the error of a
|
|
4
|
+
* failed `npm publish`, whose output cannot be parsed because npm inherits the
|
|
5
|
+
* terminal (2FA). They name where `NPM_TOKEN` came from, never the token.
|
|
6
|
+
*
|
|
7
|
+
* @module create-version/npm-auth
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
NPM_AUTH_STATUS,
|
|
12
|
+
NPM_NOT_FOUND_CODE,
|
|
13
|
+
NPM_PUT_NOT_FOUND_NOTE,
|
|
14
|
+
NPM_READ_ONLY_TOKEN_NOTE,
|
|
15
|
+
NPM_TOKEN_LOCATIONS,
|
|
16
|
+
NPM_TOKEN_SOURCE_LABEL,
|
|
17
|
+
NPM_TOKEN_VARIABLE,
|
|
18
|
+
PROJECT_NPM_CONFIG_FILE,
|
|
19
|
+
buildNpmAuthRerunAction,
|
|
20
|
+
buildNpmPublishRetryAction,
|
|
21
|
+
} from "../constants/create-version.js";
|
|
22
|
+
import { DEFAULT_PROJECT_COMMANDS } from "../package-manager.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {import("./npm.js").NpmAuthCheck} NpmAuthCheck
|
|
26
|
+
* @typedef {import("../package-manager.js").ProjectCommands} ProjectCommands
|
|
27
|
+
* @typedef {{ title: string, details: string[] }} NpmAuthProblem
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Names the source of the token for messages.
|
|
32
|
+
*
|
|
33
|
+
* @param {NpmAuthCheck} npmAuth - Check result.
|
|
34
|
+
* @returns {string} Source label, or a generic name when it is unknown.
|
|
35
|
+
*/
|
|
36
|
+
export function describeNpmTokenSource(npmAuth) {
|
|
37
|
+
return npmAuth.source ? NPM_TOKEN_SOURCE_LABEL[/** @type {keyof typeof NPM_TOKEN_SOURCE_LABEL} */ (npmAuth.source)] ?? npmAuth.source : NPM_TOKEN_VARIABLE;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Describes the owners npm reported, for the not-owner messages.
|
|
42
|
+
*
|
|
43
|
+
* @param {NpmAuthCheck} npmAuth - Check result.
|
|
44
|
+
* @returns {string} Comma-separated owners, or a placeholder when npm listed none.
|
|
45
|
+
*/
|
|
46
|
+
function describeOwners(npmAuth) {
|
|
47
|
+
return npmAuth.owners.length > 0 ? npmAuth.owners.join(", ") : "ninguno visible";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Builds the title and the fix of a credential problem.
|
|
52
|
+
*
|
|
53
|
+
* @param {NpmAuthCheck} npmAuth - Check result.
|
|
54
|
+
* @param {string} nextAction - What to run once fixed.
|
|
55
|
+
* @returns {{ title: string, reason: string | null, fix: string } | null} Problem, or `null` when the check does not block.
|
|
56
|
+
*/
|
|
57
|
+
function describeCredentialProblem(npmAuth, nextAction) {
|
|
58
|
+
const sourceLabel = describeNpmTokenSource(npmAuth);
|
|
59
|
+
const tokenVariable = npmAuth.tokenVariable ?? NPM_TOKEN_VARIABLE;
|
|
60
|
+
|
|
61
|
+
switch (npmAuth.status) {
|
|
62
|
+
case NPM_AUTH_STATUS.missingToken:
|
|
63
|
+
return { title: `Falta ${tokenVariable} para publicar ${npmAuth.packageName}`, reason: null, fix: `Definilo en ${tokenVariable === NPM_TOKEN_VARIABLE ? NPM_TOKEN_LOCATIONS : `la variable de entorno ${tokenVariable}, el .env del repo o ~/.config/astra-rp/.env`} y ${nextAction}.` };
|
|
64
|
+
case NPM_AUTH_STATUS.unsupportedAuth:
|
|
65
|
+
return { title: npmAuth.reason ?? "La autenticación configurada no está disponible", reason: null, fix: `Corregí publication.authentication o el entorno del CI y ${nextAction}.` };
|
|
66
|
+
case NPM_AUTH_STATUS.invalidToken:
|
|
67
|
+
return {
|
|
68
|
+
title: `El ${tokenVariable} (${sourceLabel}) es inválido o venció`,
|
|
69
|
+
reason: `${npmAuth.reason ?? "npm whoami rechazó el token"} (registry ${npmAuth.registryUrl}).`,
|
|
70
|
+
fix: `Generá uno nuevo con permiso de publicación (npm → Access Tokens), reemplazalo (${sourceLabel}) y ${nextAction}.`,
|
|
71
|
+
};
|
|
72
|
+
case NPM_AUTH_STATUS.notOwner:
|
|
73
|
+
return {
|
|
74
|
+
title: `El token autentica como ${npmAuth.user}, que no puede publicar ${npmAuth.packageName} (dueños: ${describeOwners(npmAuth)})`,
|
|
75
|
+
reason: `${npmAuth.reason ? `${npmAuth.reason} ` : ""}Origen del token: ${sourceLabel}.`,
|
|
76
|
+
fix: `Usá el token de un dueño o pedí que te agreguen (npm owner add ${npmAuth.user} ${npmAuth.packageName}) y ${nextAction}.`,
|
|
77
|
+
};
|
|
78
|
+
case NPM_AUTH_STATUS.projectCredentials:
|
|
79
|
+
return {
|
|
80
|
+
title: `El ${PROJECT_NPM_CONFIG_FILE} del proyecto define credenciales para ${npmAuth.registryUrl} que tienen prioridad sobre ${tokenVariable}`,
|
|
81
|
+
reason: `${npmAuth.reason ?? `${PROJECT_NPM_CONFIG_FILE} del proyecto con credenciales`}.`,
|
|
82
|
+
fix: `Sacalas: astra-rp usa ${tokenVariable} con una config temporal. Después ${nextAction}.`,
|
|
83
|
+
};
|
|
84
|
+
default:
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Explains an npm credential check that must stop the release before anything is touched.
|
|
91
|
+
*
|
|
92
|
+
* @param {NpmAuthCheck} npmAuth - Result of `checkNpmPublishAccess`.
|
|
93
|
+
* @param {ProjectCommands} [commands] - Project commands quoted by the fix (pnpm when omitted).
|
|
94
|
+
* @returns {NpmAuthProblem | null} Blocker, or `null` when the check passed or could not decide (`unknown`).
|
|
95
|
+
*/
|
|
96
|
+
export function describeNpmAuthProblem(npmAuth, commands = DEFAULT_PROJECT_COMMANDS) {
|
|
97
|
+
const problem = describeCredentialProblem(npmAuth, buildNpmAuthRerunAction(commands.createVersion));
|
|
98
|
+
return problem ? { title: problem.title, details: [...(problem.reason ? [problem.reason] : []), problem.fix] } : null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Warns about a first publication that cannot be told apart from a hidden package: `npm view` and
|
|
103
|
+
* `npm owner ls` answered E404, which is what a registry answers both for a new package and for a
|
|
104
|
+
* private package the token has no access to.
|
|
105
|
+
*
|
|
106
|
+
* @param {NpmAuthCheck} npmAuth - Result of `checkNpmPublishAccess`, confirmed against `npm view`.
|
|
107
|
+
* @returns {string | null} Warning, or `null` when the check is not a first publication.
|
|
108
|
+
*/
|
|
109
|
+
export function describeNpmFirstPublicationWarning(npmAuth) {
|
|
110
|
+
if (npmAuth.status !== NPM_AUTH_STATUS.ok || !npmAuth.firstPublication) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return `El registry ${npmAuth.registryUrl} no muestra ${npmAuth.packageName} (npm view y npm owner ls responden ${NPM_NOT_FOUND_CODE}): se toma como primera publicación. Si ya existe como paquete privado, el token (${describeNpmTokenSource(npmAuth)}) no tiene acceso y npm publish va a fallar después de crear y pushear el commit y el tag.`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Explains a failed `npm publish` from the credential check re-run after it: an invalid token, a
|
|
119
|
+
* user without permission on the package or, when the user can publish, the generic failure, which
|
|
120
|
+
* still names a read-only or granular token without write permission as a possible cause.
|
|
121
|
+
*
|
|
122
|
+
* @param {NpmAuthCheck} npmAuth - Result of `checkNpmPublishAccess` after the failure.
|
|
123
|
+
* @param {{ exitCode: number, version: string }} publication - npm exit code and version being published.
|
|
124
|
+
* @param {ProjectCommands} [commands] - Project commands quoted by the hint (pnpm when omitted).
|
|
125
|
+
* @returns {{ message: string, hint: string }} Spanish message and next action for `ReleaseStepError`.
|
|
126
|
+
*/
|
|
127
|
+
export function describeNpmPublishFailure(npmAuth, { exitCode, version }, commands = DEFAULT_PROJECT_COMMANDS) {
|
|
128
|
+
const failed = `npm publish terminó con código ${exitCode}`;
|
|
129
|
+
const retryAction = buildNpmPublishRetryAction(commands.createVersion);
|
|
130
|
+
const problem = describeCredentialProblem(npmAuth, retryAction);
|
|
131
|
+
|
|
132
|
+
if (problem) {
|
|
133
|
+
const notFoundNote = npmAuth.status === NPM_AUTH_STATUS.notOwner ? `${NPM_PUT_NOT_FOUND_NOTE} ` : "";
|
|
134
|
+
return { message: `${failed}: ${problem.title}.`, hint: `${notFoundNote}${problem.fix}` };
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const credentials =
|
|
138
|
+
npmAuth.status === NPM_AUTH_STATUS.ok
|
|
139
|
+
? `Las credenciales (${describeNpmTokenSource(npmAuth)}) autentican como ${npmAuth.user}${npmAuth.firstPublication ? "" : `, dueño de ${npmAuth.packageName}`}. ${NPM_READ_ONLY_TOKEN_NOTE}`
|
|
140
|
+
: `No se pudieron verificar las credenciales (${npmAuth.reason ?? "motivo desconocido"}).`;
|
|
141
|
+
return { message: `${failed}.`, hint: `Comprobá en npm si ${version} llegó; si no, ${retryAction}. ${credentials} ${NPM_PUT_NOT_FOUND_NOTE}` };
|
|
142
|
+
}
|