launchset 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/README.md +100 -2
- package/dist/appstore-bVSJnUv2.js +143 -0
- package/dist/cli.js +6889 -0
- package/dist/errors-CHdD4g_K.js +58 -0
- package/dist/gitlab-child-girdQprO.js +6071 -0
- package/dist/http-dQt8kfON.js +127 -0
- package/dist/index.d.ts +854 -0
- package/dist/index.js +29 -0
- package/dist/init-Cv748KKZ.js +8222 -0
- package/dist/launchset.schema.json +1473 -0
- package/dist/play-D7nv0n-W.js +123 -0
- package/dist/prompts-S8h8cgml.js +52 -0
- package/dist/schema-CKljQNeI.js +1202 -0
- package/dist/store-BCwWrhhY.js +73 -0
- package/package.json +88 -4
- package/skills/launchset/AGENTS-snippet.md +24 -0
- package/skills/launchset/SKILL.md +205 -0
- package/skills/launchset-adopt/SKILL.md +222 -0
- package/templates/gitlab/child/build.yml +17 -0
- package/templates/gitlab/child/cli.yml +14 -0
- package/templates/gitlab/child/comment.yml +14 -0
- package/templates/gitlab/child/finalize.yml +14 -0
- package/templates/gitlab/child/header.yml +4 -0
- package/templates/gitlab/child/include.yml +6 -0
- package/templates/gitlab/child/nothing.yml +11 -0
- package/templates/gitlab/gitlab-ci.yml +23 -0
- package/templates/gitlab/launchset-preview.yml +62 -0
- package/templates/gitlab/launchset-targets.yml +44 -0
- package/templates/gitlab/launchset.yml +133 -0
- package/templates/gitlab/targets/android.yml +25 -0
- package/templates/gitlab/targets/custom-npm.yml +15 -0
- package/templates/gitlab/targets/custom.yml +23 -0
- package/templates/gitlab/targets/docker.yml +23 -0
- package/templates/gitlab/targets/ios.yml +33 -0
- package/templates/gitlab/targets/web.yml +13 -0
- package/templates/launchset-readme.md +23 -0
- package/templates/workflows/launchset-check.yml +33 -0
- package/templates/workflows/launchset-preview.yml +157 -0
- package/templates/workflows/launchset-release.yml +181 -0
- package/templates/workflows/snippets/android.yml +41 -0
- package/templates/workflows/snippets/custom-example.yml +12 -0
- package/templates/workflows/snippets/custom-npm.yml +19 -0
- package/templates/workflows/snippets/custom.yml +9 -0
- package/templates/workflows/snippets/docker-login.yml +9 -0
- package/templates/workflows/snippets/docker.yml +17 -0
- package/templates/workflows/snippets/ios.yml +46 -0
- package/templates/workflows/snippets/web.yml +20 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { a as paren, c as VerifyError, i as missingEnv, n as decodeSecret, o as readJson, r as errorDetail, s as send } from "./http-dQt8kfON.js";
|
|
2
|
+
import { i as requireBuildNumber, n as decideStore } from "./store-BCwWrhhY.js";
|
|
3
|
+
import { SignJWT, importPKCS8 } from "jose";
|
|
4
|
+
// src/verify/play.ts
|
|
5
|
+
/**
|
|
6
|
+
* Google Play check (spec 7.3): open an edit, list bundles and APKs, take the max
|
|
7
|
+
* `versionCode`, delete the edit. Auth: OAuth 2 JWT bearer grant with a service account.
|
|
8
|
+
*
|
|
9
|
+
* Play doesn't report `versionName` per bundle, so "this exact build exists" means the
|
|
10
|
+
* `versionCode` exists.
|
|
11
|
+
*/
|
|
12
|
+
const PLAY_ENV = "LAUNCHSET_PLAY_SERVICE_ACCOUNT_JSON";
|
|
13
|
+
const PLAY_SCOPE = "https://www.googleapis.com/auth/androidpublisher";
|
|
14
|
+
const PLAY_API = "https://androidpublisher.googleapis.com/androidpublisher/v3";
|
|
15
|
+
const DEFAULT_TOKEN_URI = "https://oauth2.googleapis.com/token";
|
|
16
|
+
const API = "Google Play";
|
|
17
|
+
/** Read and validate the service account from `LAUNCHSET_PLAY_SERVICE_ACCOUNT_JSON`. */
|
|
18
|
+
function readServiceAccount(env) {
|
|
19
|
+
if (missingEnv(env, ["LAUNCHSET_PLAY_SERVICE_ACCOUNT_JSON"]).length > 0) throw new VerifyError(`Google Play verification needs the environment variable ${PLAY_ENV} (the service account JSON key, raw or base64-encoded). Set it from a repository secret in the verify step.`);
|
|
20
|
+
const text = decodeSecret(env["LAUNCHSET_PLAY_SERVICE_ACCOUNT_JSON"] ?? "", (t) => t.startsWith("{"));
|
|
21
|
+
let json;
|
|
22
|
+
if (text) try {
|
|
23
|
+
json = JSON.parse(text);
|
|
24
|
+
} catch {}
|
|
25
|
+
if (!json || typeof json !== "object") throw new VerifyError(`${PLAY_ENV} isn't valid JSON or base64-encoded JSON. Paste the whole service account key file (from Google Cloud → IAM → Service accounts → Keys) into the secret.`);
|
|
26
|
+
const missingFields = ["client_email", "private_key"].filter((key) => typeof json[key] !== "string" || !json[key]);
|
|
27
|
+
if (missingFields.length > 0) throw new VerifyError(`${PLAY_ENV} is missing ${missingFields.join(" and ")}. Use a service account key file of type "service_account" (JSON key), not an OAuth client file.`);
|
|
28
|
+
return {
|
|
29
|
+
client_email: json.client_email,
|
|
30
|
+
private_key: json.private_key,
|
|
31
|
+
private_key_id: typeof json.private_key_id === "string" ? json.private_key_id : void 0,
|
|
32
|
+
token_uri: typeof json.token_uri === "string" && json.token_uri ? json.token_uri : DEFAULT_TOKEN_URI
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Exchange a signed RS256 assertion for an access token (JWT bearer grant). */
|
|
36
|
+
async function getPlayAccessToken(account, ctx) {
|
|
37
|
+
let key;
|
|
38
|
+
try {
|
|
39
|
+
key = await importPKCS8(account.private_key, "RS256");
|
|
40
|
+
} catch (error) {
|
|
41
|
+
throw new VerifyError(`The private_key in ${PLAY_ENV} isn't a valid PKCS#8 RSA key (${error.message}). Download a new JSON key for the service account.`);
|
|
42
|
+
}
|
|
43
|
+
const now = Math.floor((ctx.now?.() ?? /* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
44
|
+
const assertion = await new SignJWT({ scope: PLAY_SCOPE }).setProtectedHeader({
|
|
45
|
+
alg: "RS256",
|
|
46
|
+
typ: "JWT",
|
|
47
|
+
...account.private_key_id ? { kid: account.private_key_id } : {}
|
|
48
|
+
}).setIssuer(account.client_email).setAudience(account.token_uri).setIssuedAt(now).setExpirationTime(now + 3600).sign(key);
|
|
49
|
+
const response = await send(ctx, `${API} token exchange`, account.token_uri, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
headers: {
|
|
52
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
53
|
+
accept: "application/json"
|
|
54
|
+
},
|
|
55
|
+
body: new URLSearchParams({
|
|
56
|
+
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
57
|
+
assertion
|
|
58
|
+
}).toString()
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) throw new VerifyError(`${API}: the token exchange at ${account.token_uri} failed with HTTP ${response.status}${paren(await errorDetail(response))}. Check that the service account key in ${PLAY_ENV} is current and not deleted or disabled.`);
|
|
61
|
+
const body = await readJson(response, `${API} token exchange`, account.token_uri);
|
|
62
|
+
if (typeof body.access_token !== "string" || !body.access_token) throw new VerifyError(`${API}: the token exchange at ${account.token_uri} answered without an access_token. Try again; if it persists, create a new service account key.`);
|
|
63
|
+
return body.access_token;
|
|
64
|
+
}
|
|
65
|
+
function playHint(status, packageName) {
|
|
66
|
+
if (status === 401 || status === 403) return ` Check that the service account has access to ${packageName} in Play Console (Users and permissions) and that the Google Play Android Developer API is enabled in its Google Cloud project.`;
|
|
67
|
+
if (status === 404) return ` Check the package name (store.packageName) and that the app exists in Play Console with at least one upload (the API can't see apps that were never uploaded by hand).`;
|
|
68
|
+
return "";
|
|
69
|
+
}
|
|
70
|
+
/** Google Play check for one app (spec 7.3). */
|
|
71
|
+
async function verifyPlay(check, ctx) {
|
|
72
|
+
const store = `Google Play (${check.packageName})`;
|
|
73
|
+
const ours = requireBuildNumber(check, store);
|
|
74
|
+
const auth = {
|
|
75
|
+
authorization: `Bearer ${await getPlayAccessToken(readServiceAccount(ctx.env), ctx)}`,
|
|
76
|
+
accept: "application/json"
|
|
77
|
+
};
|
|
78
|
+
const base = `${PLAY_API}/applications/${encodeURIComponent(check.packageName)}`;
|
|
79
|
+
const call = async (what, url, init = {}) => {
|
|
80
|
+
const response = await send(ctx, API, url, {
|
|
81
|
+
...init,
|
|
82
|
+
headers: auth
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) throw new VerifyError(`${API}: ${what} (${init.method ?? "GET"} ${url}) failed with HTTP ${response.status}${paren(await errorDetail(response))}.${playHint(response.status, check.packageName)}`);
|
|
85
|
+
return readJson(response, API, url);
|
|
86
|
+
};
|
|
87
|
+
const edit = await call("opening an edit", `${base}/edits`, { method: "POST" });
|
|
88
|
+
if (typeof edit.id !== "string" || !edit.id) throw new VerifyError(`${API}: opening an edit for ${check.packageName} returned no edit id.`);
|
|
89
|
+
const editUrl = `${base}/edits/${encodeURIComponent(edit.id)}`;
|
|
90
|
+
let numbers;
|
|
91
|
+
let deleteWarning;
|
|
92
|
+
try {
|
|
93
|
+
const [bundlesResult, apksResult] = await Promise.allSettled([call("listing bundles", `${editUrl}/bundles`), call("listing APKs", `${editUrl}/apks`)]);
|
|
94
|
+
if (bundlesResult.status === "rejected") throw bundlesResult.reason;
|
|
95
|
+
if (apksResult.status === "rejected") throw apksResult.reason;
|
|
96
|
+
const bundles = bundlesResult.value;
|
|
97
|
+
const apks = apksResult.value;
|
|
98
|
+
numbers = [...bundles.bundles ?? [], ...apks.apks ?? []].map((entry) => entry.versionCode).filter((code) => typeof code === "number" || typeof code === "string").map(String);
|
|
99
|
+
} finally {
|
|
100
|
+
deleteWarning = await deleteEdit(ctx, editUrl, auth);
|
|
101
|
+
}
|
|
102
|
+
return decideStore(check, ours, {
|
|
103
|
+
store,
|
|
104
|
+
unit: "versionCode",
|
|
105
|
+
numbers,
|
|
106
|
+
exact: numbers.some((n) => Number(n) === ours),
|
|
107
|
+
notes: deleteWarning ? [deleteWarning] : []
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** Delete the edit. A failure is only a warning: edits expire on their own. */
|
|
111
|
+
async function deleteEdit(ctx, editUrl, headers) {
|
|
112
|
+
try {
|
|
113
|
+
const response = await send(ctx, API, editUrl, {
|
|
114
|
+
method: "DELETE",
|
|
115
|
+
headers
|
|
116
|
+
});
|
|
117
|
+
if (response.ok) return void 0;
|
|
118
|
+
return `warning: deleting the temporary edit failed with HTTP ${response.status}${paren(await errorDetail(response))}; it expires on its own`;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return `warning: deleting the temporary edit failed (${error.message}); it expires on its own`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export { verifyPlay };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { n as LaunchsetError } from "./errors-CHdD4g_K.js";
|
|
2
|
+
import { cancel, isCancel, select, text } from "@clack/prompts";
|
|
3
|
+
// src/cli/prompts.ts
|
|
4
|
+
/** Interactive prompts for `launchset add` (only used when stdin is a terminal). */
|
|
5
|
+
function cancelled() {
|
|
6
|
+
cancel("Cancelled.");
|
|
7
|
+
throw new LaunchsetError("cancelled", "add was cancelled; no changeset was written.");
|
|
8
|
+
}
|
|
9
|
+
function clackAddPrompts() {
|
|
10
|
+
return {
|
|
11
|
+
async bump() {
|
|
12
|
+
const value = await select({
|
|
13
|
+
message: "What kind of change is this?",
|
|
14
|
+
initialValue: "patch",
|
|
15
|
+
options: [
|
|
16
|
+
{
|
|
17
|
+
value: "patch",
|
|
18
|
+
label: "patch",
|
|
19
|
+
hint: "bug fix, small change"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: "minor",
|
|
23
|
+
label: "minor",
|
|
24
|
+
hint: "new feature, backwards compatible"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
value: "major",
|
|
28
|
+
label: "major",
|
|
29
|
+
hint: "breaking change"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: "none",
|
|
33
|
+
label: "none",
|
|
34
|
+
hint: "no release needed"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
if (isCancel(value)) cancelled();
|
|
39
|
+
return value;
|
|
40
|
+
},
|
|
41
|
+
async summary() {
|
|
42
|
+
const value = await text({
|
|
43
|
+
message: "Summary (goes into the changelog)",
|
|
44
|
+
placeholder: "Fix the crash when opening the settings screen",
|
|
45
|
+
validate: (input) => (input ?? "").trim() === "" ? "Write a short summary." : void 0
|
|
46
|
+
});
|
|
47
|
+
if (isCancel(value)) cancelled();
|
|
48
|
+
return String(value);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export { clackAddPrompts };
|