shiplane 0.0.0 โ†’ 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arnaud Zheng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # ๐Ÿšข shiplane
2
+
3
+ The release core: it finds what changed, versions it, tags it and ships each app in order. It talks
4
+ to no host itself. You inject one adapter per port in `shiplane.config.ts`.
5
+
6
+ ```mermaid
7
+ flowchart LR
8
+ ADP["Adapters: a plugin or your own"] --> CFG["shiplane.config.ts"]
9
+ CFG --> FLOW["releaseFlow: source control, code host, CI, versioning"]
10
+ CFG --> MODS["Modules: server, static, mobile, package"]
11
+ FLOW --> CORE["shiplane core: changes, versions, tags, order, undo"]
12
+ MODS --> CORE
13
+ ```
14
+
15
+ ## โšก Three commands
16
+
17
+ ```sh
18
+ pnpm shiplane init # find what ships, write the config
19
+ pnpm shiplane # release PR, merge, tags, ship to preview
20
+ pnpm shiplane promote # what preview validated, to production
21
+ ```
22
+
23
+ ## ๐Ÿ”Œ Ports
24
+
25
+ The core only knows these interfaces. Each one is filled by the adapter you give it.
26
+
27
+ | Port | What it does | Filled by |
28
+ | ------------------- | ---------------------------------------------- | -------------------------------- |
29
+ | Source control | The history: tags, commits, branches, push | `releaseFlow({ sourceControl })` |
30
+ | Code host | Pull requests, release notes, deploy records | `releaseFlow({ codeHost })` |
31
+ | CI pipeline | Dispatches the ship workflow, reads its runs | `releaseFlow({ ciPipeline })` |
32
+ | Versioning | Pending changes, the next versions, changelogs | `releaseFlow({ versioning })` |
33
+ | Server hosting | Runs a service from a tag | `backendService(...)` |
34
+ | Static hosting | Serves a static build per environment | `webApp(...)` |
35
+ | Mobile distribution | Ships a store build or an over-the-air update | `mobileApp(...)` |
36
+ | Package registry | Publishes a package, moves its dist-tag | `publishedPackage(...)` |
37
+
38
+ Source: `src/ports/*.port.ts`.
39
+
40
+ ## ๐Ÿงฉ Modules
41
+
42
+ A module is a kind of app. Each app's `shiplane.unit.yml` names its module.
43
+
44
+ | Module | `module:` | Takes |
45
+ | --------------------------------------- | ------------------- | -------------------- |
46
+ | `backendService({ serverHosting })` | `backend-service` | Server hosting |
47
+ | `webApp({ staticHosting })` | `web-app` | Static hosting |
48
+ | `mobileApp({ mobileDistribution })` | `mobile-app` | Mobile distribution |
49
+ | `publishedPackage({ packageRegistry })` | `published-package` | Package registry |
50
+ | `internalTool()` | `internal-tool` | Nothing: tagged only |
51
+
52
+ Source: `src/modules/`.
53
+
54
+ ## ๐Ÿ’‰ Inject the adapters
55
+
56
+ From [`examples/repository/shiplane.config.ts`](./examples/repository/shiplane.config.ts):
57
+
58
+ ```ts
59
+ // Each port gets an adapter; a module per kind of app takes the adapter that ships it.
60
+ import { changesetsVersioning } from "@shiplane/changesets";
61
+ import { cloudflarePagesStaticHosting } from "@shiplane/cloudflare-pages";
62
+ import { easMobileDistribution } from "@shiplane/eas";
63
+ import { flyServerHosting } from "@shiplane/fly";
64
+ import { gitSourceControl } from "@shiplane/git";
65
+ import { gitHubActionsCiPipeline, gitHubCodeHost } from "@shiplane/github";
66
+ import { npmPackageRegistry } from "@shiplane/npm";
67
+ import {
68
+ backendService,
69
+ defineRelease,
70
+ internalTool,
71
+ mobileApp,
72
+ publishedPackage,
73
+ releaseFlow,
74
+ webApp,
75
+ } from "shiplane";
76
+
77
+ export default defineRelease({
78
+ flow: releaseFlow({
79
+ sourceControl: gitSourceControl(),
80
+ codeHost: gitHubCodeHost(),
81
+ ciPipeline: gitHubActionsCiPipeline(),
82
+ versioning: changesetsVersioning(),
83
+ }),
84
+ modules: [
85
+ backendService({ serverHosting: flyServerHosting() }),
86
+ webApp({ staticHosting: cloudflarePagesStaticHosting() }),
87
+ mobileApp({ mobileDistribution: easMobileDistribution() }),
88
+ publishedPackage({ packageRegistry: npmPackageRegistry() }),
89
+ internalTool(),
90
+ ],
91
+ });
92
+ ```
93
+
94
+ `pnpm shiplane plugins` in that repository shows what got injected where:
95
+
96
+ ```text
97
+ Flow in shiplane.config.ts
98
+
99
+ sourceControl git
100
+ codeHost github
101
+ ciPipeline github-actions
102
+ versioning changesets
103
+
104
+ Modules, in release order
105
+
106
+ backend-service fly app, config, dockerfile, url, buildSecrets
107
+ used by api
108
+ web-app cloudflare-pages project, dist, build, branch, wrangler
109
+ used by site
110
+ mobile-app eas versionFile, update
111
+ used by mobile
112
+ published-package npm publishAs, access, tag
113
+ used by toolkit
114
+ internal-tool release-only no options
115
+ used by cli
116
+
117
+ Features, after the ship
118
+
119
+ none
120
+ ```
121
+
122
+ The adapters come from separate packages:
123
+ **[the adapters you can inject](../../docs/shiplane/plugins.md)**. The core carries one,
124
+ `shellServerHosting()`, for a host with no adapter yet.
125
+
126
+ ## ๐Ÿ“š Docs
127
+
128
+ - ๐Ÿš€ **[Tutorial](../../docs/shiplane/tutorial.md)**: release your first package
129
+ - ๐Ÿ› ๏ธ **[How-to](../../docs/shiplane/how-to.md)**: add an app, promote, ship from CI, write a plugin
130
+ - ๐Ÿ“– **[Reference](../../docs/shiplane/reference.md)**: commands, flags, the config and unit files
131
+ - ๐Ÿ”Œ **[Plugins](../../docs/shiplane/plugins.md)**: the adapters you can inject, and how to write
132
+ one
133
+ - ๐Ÿ’ก **[Explanation](../../docs/shiplane/explanation.md)**: why it works this way
@@ -0,0 +1,328 @@
1
+ import { z } from "zod";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { parse } from "yaml";
5
+ //#region src/application/config/workspaceFolders.ts
6
+ const PnpmWorkspaceSchema = z.object({ packages: z.array(z.string()).optional() }).nullish();
7
+ const PackageWorkspacesSchema = z.object({ workspaces: z.union([z.array(z.string()), z.object({ packages: z.array(z.string()) })]).optional() });
8
+ const readText = (file) => fs.existsSync(file) ? fs.readFileSync(file, "utf8") : null;
9
+ /** The folders the workspace file lists: pnpm's first, then package.json, else the root alone. */
10
+ const workspacePatterns = (root) => {
11
+ const pnpm = readText(path.join(root, "pnpm-workspace.yaml"));
12
+ const fromPnpm = pnpm === null ? void 0 : PnpmWorkspaceSchema.parse(parse(pnpm))?.packages;
13
+ if (fromPnpm && fromPnpm.length > 0) return fromPnpm;
14
+ const manifest = readText(path.join(root, "package.json"));
15
+ const { workspaces } = manifest === null ? { workspaces: void 0 } : PackageWorkspacesSchema.parse(JSON.parse(manifest));
16
+ if (workspaces) return Array.isArray(workspaces) ? workspaces : workspaces.packages;
17
+ return ["."];
18
+ };
19
+ const childFolders = (root, parent) => {
20
+ const absolute = path.join(root, parent);
21
+ if (!fs.existsSync(absolute)) return [];
22
+ return fs.readdirSync(absolute, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => path.posix.join(parent, entry.name));
23
+ };
24
+ /** Folders matching `dir/*` or an exact path, sorted. Negations and deeper globs are skipped. */
25
+ const expandPatterns = (root, patterns) => {
26
+ const folders = patterns.filter((pattern) => !pattern.startsWith("!")).map((pattern) => pattern.replace(/\/+$/, "")).flatMap((pattern) => {
27
+ if (pattern.endsWith("/*")) return childFolders(root, pattern.slice(0, -2));
28
+ if (pattern.includes("*")) return [];
29
+ return fs.existsSync(path.join(root, pattern)) ? [path.posix.normalize(pattern)] : [];
30
+ });
31
+ return [...new Set(folders)].sort();
32
+ };
33
+ //#endregion
34
+ //#region src/domain/tags.ts
35
+ /** How a tag names a unit's version unless the config says otherwise. */
36
+ const DEFAULT_TAG_FORMAT = "{name}@{version}";
37
+ /** A unit's tag for a version, through a format like `v{version}` or `{name}--v{version}`. */
38
+ const tagName = (app, version, format = DEFAULT_TAG_FORMAT) => format.replaceAll("{name}", app).replaceAll("{version}", version);
39
+ /**
40
+ * No tag names any version of the unit yet: the version it holds is its first release. 0.0.0 is a
41
+ * unit never versioned, waiting for its first changeset.
42
+ */
43
+ const firstRelease = (app, version, tags, format = DEFAULT_TAG_FORMAT) => {
44
+ const prefix = tagName(app, "", format);
45
+ return version !== "0.0.0" && ![...tags].some((tag) => tag.startsWith(prefix));
46
+ };
47
+ const literal = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48
+ /** A release pull request's subject: `chore(api): release v0.0.4`, or `chore(release): ...` for several. */
49
+ const isReleaseSubject = (subject) => subject.startsWith("chore(release):") || /^chore\([^)]+\): release v\d/.test(subject);
50
+ const cameWithRelease = ({ app, version, commit }) => {
51
+ const exact = `${literal(version)}(?![\\w.])`;
52
+ return new RegExp(`^chore\\(${literal(app)}\\): release v${exact}`).test(commit.subject) || commit.subject.startsWith("chore(release):") && (new RegExp(`\\b${literal(app)} v?${exact}`).test(commit.subject) || /^chore\(release\): \d+ apps\b/.test(commit.subject));
53
+ };
54
+ /** The tags and release notes still missing for the versions releases brought. */
55
+ const releaseTags = (candidates, tags, notes, format = DEFAULT_TAG_FORMAT) => candidates.filter((candidate) => candidate.first === true || cameWithRelease(candidate)).flatMap(({ app, version, commit }) => {
56
+ const tag = tagName(app, version, format);
57
+ const needsTag = !tags.has(tag);
58
+ const needsNotes = !notes.has(tag);
59
+ return needsTag || needsNotes ? [{
60
+ app,
61
+ version,
62
+ tag,
63
+ sha: commit.sha,
64
+ needsTag,
65
+ needsNotes
66
+ }] : [];
67
+ });
68
+ /** One version's section of a changesets CHANGELOG.md, used as its release notes. */
69
+ const changelogSection = (changelog, version) => {
70
+ return changelog.split(`\n## ${version}\n`)[1]?.split("\n## ")[0]?.trim() || `No changelog entry for ${version}.`;
71
+ };
72
+ //#endregion
73
+ //#region src/domain/governance.ts
74
+ /**
75
+ * A binary ships what it was built from, so builds start from main as it is on origin. Preview
76
+ * updates may come from a branch for testers; production updates only from main.
77
+ */
78
+ const releaseSource = (intent, channel, { branch, head, originMain }) => {
79
+ if (!(intent === "build" || intent === "update" && channel === "production")) return { allowed: true };
80
+ if (branch !== "main") return {
81
+ allowed: false,
82
+ why: "not-main"
83
+ };
84
+ if (head !== originMain) return {
85
+ allowed: false,
86
+ why: "behind-main"
87
+ };
88
+ return { allowed: true };
89
+ };
90
+ /** Production never runs a step nobody confirmed. */
91
+ const yesAllowed = (channel, yes) => !(yes && channel === "production");
92
+ //#endregion
93
+ //#region src/ports/shell.port.ts
94
+ /** A command that exited non-zero, carrying all it printed so a failure can show why. */
95
+ var CommandFailed = class extends Error {
96
+ output;
97
+ constructor(message, output) {
98
+ super(message);
99
+ this.name = "CommandFailed";
100
+ this.output = output;
101
+ }
102
+ };
103
+ //#endregion
104
+ //#region src/domain/versions.ts
105
+ const toParts = (version) => version.split(".").map((part) => Number.parseInt(part, 10) || 0);
106
+ /** Negative, zero or positive, like a sort comparator: "0.1.10" is after "0.1.9". */
107
+ const compareVersions = (left, right) => {
108
+ const leftParts = toParts(left);
109
+ const rightParts = toParts(right);
110
+ const length = Math.max(leftParts.length, rightParts.length);
111
+ for (let index = 0; index < length; index += 1) {
112
+ const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
113
+ if (difference !== 0) return difference;
114
+ }
115
+ return 0;
116
+ };
117
+ const nextPatch = (version) => {
118
+ const [major = 0, minor = 0, patch = 0] = version.split(".").map(Number);
119
+ return `${major}.${minor}.${patch + 1}`;
120
+ };
121
+ //#endregion
122
+ //#region src/domain/changes.ts
123
+ /** The units a release moves, in `units` order, each with its notes or the packages it moves with. */
124
+ const appBumps = ({ changesets, releases }, dependencies, units) => {
125
+ const moving = new Set(releases.map(({ name }) => name));
126
+ return units.flatMap(({ name: app, packageName }) => {
127
+ const release = releases.find(({ name }) => name === packageName);
128
+ if (!release) return [];
129
+ const notes = changesets.filter(({ id }) => release.changesets.includes(id)).map(({ summary }) => summary);
130
+ const movedWith = notes.length > 0 ? [] : (dependencies[release.name] ?? []).filter((dep) => moving.has(dep));
131
+ return [{
132
+ app,
133
+ from: release.oldVersion,
134
+ to: release.newVersion,
135
+ notes,
136
+ movedWith
137
+ }];
138
+ });
139
+ };
140
+ /** How many internal packages a release moves: they get changelogs, nothing ships. */
141
+ const packageBumps = ({ releases }, units) => releases.filter(({ name }) => !units.some(({ packageName }) => packageName === name)).length;
142
+ /**
143
+ * Holding an app back keeps its lines pending, with any package line they came with so the package
144
+ * does not drag the held app along. The picked apps' lines ship under the same summary.
145
+ */
146
+ const splitChangesets = (changesets, held, units) => {
147
+ const packageOf = (name) => units.find((unit) => unit.name === name)?.packageName;
148
+ const heldNames = new Set(held.map(packageOf));
149
+ const isUnit = (name) => units.some(({ packageName }) => packageName === name);
150
+ return changesets.reduce((split, changeset) => {
151
+ if (!changeset.releases.some(({ name }) => heldNames.has(name))) return {
152
+ ...split,
153
+ ships: [...split.ships, changeset]
154
+ };
155
+ const picked = changeset.releases.filter(({ name }) => isUnit(name) && !heldNames.has(name));
156
+ const waiting = changeset.releases.filter(({ name }) => !picked.some((line) => line.name === name));
157
+ return {
158
+ ships: picked.length > 0 ? [...split.ships, {
159
+ ...changeset,
160
+ releases: picked
161
+ }] : split.ships,
162
+ waits: [...split.waits, {
163
+ ...changeset,
164
+ releases: waiting
165
+ }]
166
+ };
167
+ }, {
168
+ ships: [],
169
+ waits: []
170
+ });
171
+ };
172
+ /** The units a changeset file releases, read from its frontmatter. */
173
+ const changesetApps = (text, units) => {
174
+ const frontmatter = text.split("---")[1] ?? "";
175
+ return units.filter(({ packageName }) => frontmatter.includes(`"${packageName}":`)).map(({ name }) => name);
176
+ };
177
+ /** Apps that changed since their current version came out, with no changeset to ship it. */
178
+ const unreleasedApps = (history, named) => history.map((entry) => ({
179
+ ...entry,
180
+ commits: entry.commits.filter((subject) => !isReleaseSubject(subject))
181
+ })).filter(({ app, commits }) => commits.length > 0 && !named.has(app));
182
+ const USER_FACING = /^(feat|fix|perf)(\(.+?\))?!?:/;
183
+ const asSentence = (subject) => {
184
+ const text = subject.replace(/^\w+(\(.+?\))?!?:\s*/, "").replace(/\s*\(#\d+\)$/, "").trim();
185
+ const sentence = `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
186
+ return /[.!?]$/.test(sentence) ? sentence : `${sentence}.`;
187
+ };
188
+ /**
189
+ * The patch changesets the release writes for an unreleased app the person picked: one changelog
190
+ * line per feature or fix since its release, or its latest commit when there are only chores.
191
+ */
192
+ const unreleasedChangesets = ({ name: app, packageName }, version, commits) => {
193
+ const userFacing = commits.filter((commit) => USER_FACING.test(commit));
194
+ return (userFacing.length > 0 ? userFacing : commits.slice(0, 1)).map((subject, index) => ({
195
+ id: `${app}-${nextPatch(version)}-${index + 1}`,
196
+ releases: [{
197
+ name: packageName,
198
+ type: "patch"
199
+ }],
200
+ summary: asSentence(subject)
201
+ }));
202
+ };
203
+ //#endregion
204
+ //#region src/domain/deploys.ts
205
+ /** The run name the deploy workflows set, so the Actions list says which version went where. */
206
+ const deployRunTitle = (tag, environment) => `Deploy ${tag} to ${environment}`;
207
+ const DEPLOYED = new Set([
208
+ "SUCCESS",
209
+ "ACTIVE",
210
+ "INACTIVE"
211
+ ]);
212
+ const DEPLOYING = new Set([
213
+ "IN_PROGRESS",
214
+ "QUEUED",
215
+ "PENDING",
216
+ "WAITING"
217
+ ]);
218
+ /** One version on one environment, from the states of its GitHub deployments. */
219
+ const deployState = (states) => {
220
+ if (states.some((state) => DEPLOYED.has(state))) return "done";
221
+ return states.some((state) => DEPLOYING.has(state)) ? "running" : "none";
222
+ };
223
+ /** What one web app's tagged version still needs on an environment. */
224
+ const webShip = ({ environment, run, onPreview }) => {
225
+ if (run === "done") return "shipped";
226
+ if (run === "running") return "deploying";
227
+ if (environment === "production" && !onPreview) return "not-on-preview";
228
+ return "deploy";
229
+ };
230
+ /** Whether a diff only moves version files: the code is still the code a release named. */
231
+ const onlyVersionFiles = (files, versionFiles) => files.every((file) => versionFiles.has(file));
232
+ /** This machine builds its checkout, so it ships only while that is the tagged code. */
233
+ const shipsFrom = (path, { sinceTagOnlyVersionFiles }) => path === "github" || sinceTagOnlyVersionFiles;
234
+ //#endregion
235
+ //#region src/domain/budget.ts
236
+ const INCLUDED_MINUTES = {
237
+ free: 2e3,
238
+ team: 3e3,
239
+ enterprise: 5e4
240
+ };
241
+ const MINUTE_WEIGHT = {
242
+ actions_windows: 2,
243
+ actions_macos: 10
244
+ };
245
+ /** This month's Actions minutes against the plan's allowance, from GitHub's usage summary. */
246
+ const actionsMinutes = (plan, usage) => {
247
+ const included = INCLUDED_MINUTES[plan];
248
+ if (!included) return null;
249
+ const used = Math.round(usage.filter(({ unitType }) => unitType === "minutes").reduce((sum, { sku, grossQuantity }) => sum + grossQuantity * (MINUTE_WEIGHT[sku] ?? 1), 0));
250
+ return {
251
+ used,
252
+ included,
253
+ left: Math.max(0, included - used)
254
+ };
255
+ };
256
+ const LOW_MINUTES = 100;
257
+ const STATUS = {
258
+ green: "โ— enough minutes this month",
259
+ yellow: "โ— running short this month",
260
+ red: "โ— about to run out: deploy from this machine"
261
+ };
262
+ /**
263
+ * The minutes as the deploy question draws them: a bar of what is left, what this release spends,
264
+ * and where this month ends if the pace so far holds. GitHub resets the allowance on the 1st, UTC.
265
+ */
266
+ const minutesBudget = (budget, now, width = 30, spend = 0) => {
267
+ const { used, included, left } = budget;
268
+ const start = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1);
269
+ const end = Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1);
270
+ const elapsed = Math.max((now.getTime() - start) / (end - start), 1 / 744);
271
+ const projected = Math.round(used / elapsed) + spend;
272
+ const leftAfter = Math.max(0, left - spend);
273
+ const month = (format) => new Date(start).toLocaleDateString("en-US", {
274
+ ...format,
275
+ timeZone: "UTC"
276
+ });
277
+ const lastDay = (/* @__PURE__ */ new Date(end - 1)).getUTCDate();
278
+ const filled = Math.round(left / included * width);
279
+ const filledAfter = Math.round(leftAfter / included * width);
280
+ const number = (value) => value.toLocaleString("en-US");
281
+ const tone = leftAfter < LOW_MINUTES ? "red" : leftAfter / included < .5 || projected > included ? "yellow" : "green";
282
+ const pace = `At this pace${spend > 0 ? ", with this release," : ""} about ${number(projected)} used by ${month({ month: "long" })} ${lastDay}`;
283
+ return {
284
+ tone,
285
+ title: `GitHub Actions minutes ยท ${month({
286
+ month: "long",
287
+ year: "numeric"
288
+ })}`,
289
+ bar: `${"โ–ˆ".repeat(filledAfter)}${"โ–’".repeat(filled - filledAfter)}${"โ–‘".repeat(width - filled)}`,
290
+ amount: `${number(left)} of ${number(included)} left ยท ${Math.round(used / included * 100)}% used`,
291
+ pace: projected > included ? `${pace}, over the ${number(included)} included: prefer this machine.` : `${pace}, within the ${number(included)} included.`,
292
+ status: STATUS[tone],
293
+ after: spend > 0 ? `This release: about ${spend} min on GitHub, about ${number(leftAfter)} left after it` : null
294
+ };
295
+ };
296
+ /** Minutes GitHub bills for a run: each job rounds up to the minute; unfinished jobs are skipped. */
297
+ const billedMinutes = (jobs) => jobs.reduce((sum, { startedAt, completedAt }) => {
298
+ if (!startedAt || !completedAt) return sum;
299
+ const seconds = (Date.parse(completedAt) - Date.parse(startedAt)) / 1e3;
300
+ return sum + Math.max(1, Math.ceil(seconds / 60));
301
+ }, 0);
302
+ const FALLBACK_MINUTES = 5;
303
+ /**
304
+ * What the GitHub path costs for these items: each workflow's recent runs when measured, typical
305
+ * figures otherwise. An EAS build runs on EAS and costs no Actions minutes.
306
+ */
307
+ const deployEstimate = (items, measured, typical) => {
308
+ const lines = items.filter(({ kind }) => kind !== "build").map(({ app }) => {
309
+ const runs = measured[app] ?? [];
310
+ return runs.length > 0 ? {
311
+ app,
312
+ minutes: Math.ceil(runs.reduce((a, b) => a + b, 0) / runs.length),
313
+ measured: true
314
+ } : {
315
+ app,
316
+ minutes: typical[app] ?? FALLBACK_MINUTES,
317
+ measured: false
318
+ };
319
+ });
320
+ return {
321
+ total: lines.reduce((sum, { minutes }) => sum + minutes, 0),
322
+ lines
323
+ };
324
+ };
325
+ //#endregion
326
+ export { changelogSection as C, tagName as D, releaseTags as E, expandPatterns as O, cameWithRelease as S, isReleaseSubject as T, nextPatch as _, deployRunTitle as a, yesAllowed as b, shipsFrom as c, changesetApps as d, packageBumps as f, compareVersions as g, unreleasedChangesets as h, minutesBudget as i, workspacePatterns as k, webShip as l, unreleasedApps as m, billedMinutes as n, deployState as o, splitChangesets as p, deployEstimate as r, onlyVersionFiles as s, actionsMinutes as t, appBumps as u, CommandFailed as v, firstRelease as w, DEFAULT_TAG_FORMAT as x, releaseSource as y };
327
+
328
+ //# sourceMappingURL=budget-C8_aayQk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget-C8_aayQk.js","names":[],"sources":["../src/application/config/workspaceFolders.ts","../src/domain/tags.ts","../src/domain/governance.ts","../src/ports/shell.port.ts","../src/domain/versions.ts","../src/domain/changes.ts","../src/domain/deploys.ts","../src/domain/budget.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { parse } from \"yaml\";\nimport { z } from \"zod\";\n\nconst PnpmWorkspaceSchema = z.object({ packages: z.array(z.string()).optional() }).nullish();\nconst PackageWorkspacesSchema = z.object({\n workspaces: z\n .union([z.array(z.string()), z.object({ packages: z.array(z.string()) })])\n .optional(),\n});\n\nconst readText = (file: string) => (fs.existsSync(file) ? fs.readFileSync(file, \"utf8\") : null);\n\n/** The folders the workspace file lists: pnpm's first, then package.json, else the root alone. */\nexport const workspacePatterns = (root: string): string[] => {\n const pnpm = readText(path.join(root, \"pnpm-workspace.yaml\"));\n const fromPnpm = pnpm === null ? undefined : PnpmWorkspaceSchema.parse(parse(pnpm))?.packages;\n if (fromPnpm && fromPnpm.length > 0) return fromPnpm;\n const manifest = readText(path.join(root, \"package.json\"));\n const { workspaces } =\n manifest === null\n ? { workspaces: undefined }\n : PackageWorkspacesSchema.parse(JSON.parse(manifest));\n if (workspaces) return Array.isArray(workspaces) ? workspaces : workspaces.packages;\n return [\".\"];\n};\n\nconst childFolders = (root: string, parent: string) => {\n const absolute = path.join(root, parent);\n if (!fs.existsSync(absolute)) return [];\n return fs\n .readdirSync(absolute, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() && !entry.name.startsWith(\".\") && entry.name !== \"node_modules\",\n )\n .map((entry) => path.posix.join(parent, entry.name));\n};\n\n/** Folders matching `dir/*` or an exact path, sorted. Negations and deeper globs are skipped. */\nexport const expandPatterns = (root: string, patterns: readonly string[]): string[] => {\n const folders = patterns\n .filter((pattern) => !pattern.startsWith(\"!\"))\n .map((pattern) => pattern.replace(/\\/+$/, \"\"))\n .flatMap((pattern) => {\n if (pattern.endsWith(\"/*\")) return childFolders(root, pattern.slice(0, -2));\n if (pattern.includes(\"*\")) return [];\n return fs.existsSync(path.join(root, pattern)) ? [path.posix.normalize(pattern)] : [];\n });\n return [...new Set(folders)].sort();\n};\n","/** How a tag names a unit's version unless the config says otherwise. */\nexport const DEFAULT_TAG_FORMAT = \"{name}@{version}\";\n\n/** A unit's tag for a version, through a format like `v{version}` or `{name}--v{version}`. */\nexport const tagName = (app: string, version: string, format = DEFAULT_TAG_FORMAT) =>\n format.replaceAll(\"{name}\", app).replaceAll(\"{version}\", version);\n\nexport interface TagCandidate {\n /** The unit's name. */\n app: string;\n version: string;\n /** The commit that brought this version, as `git log -S` finds it. */\n commit: { sha: string; subject: string };\n /** No version of the unit was ever tagged: the commit that added it brings its first release. */\n first?: boolean;\n}\n\n/**\n * No tag names any version of the unit yet: the version it holds is its first release. 0.0.0 is a\n * unit never versioned, waiting for its first changeset.\n */\nexport const firstRelease = (\n app: string,\n version: string,\n tags: ReadonlySet<string>,\n format = DEFAULT_TAG_FORMAT,\n) => {\n const prefix = tagName(app, \"\", format);\n return version !== \"0.0.0\" && ![...tags].some((tag) => tag.startsWith(prefix));\n};\n\nexport interface ReleaseTag {\n /** The unit's name. */\n app: string;\n version: string;\n tag: string;\n sha: string;\n needsTag: boolean;\n needsNotes: boolean;\n}\n\nconst literal = (text: string) => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\n/** A release pull request's subject: `chore(api): release v0.0.4`, or `chore(release): ...` for several. */\nexport const isReleaseSubject = (subject: string) =>\n subject.startsWith(\"chore(release):\") || /^chore\\([^)]+\\): release v\\d/.test(subject);\n\n// Older titles named versions without the v (\"chore(release): api 0.0.3 brings ...\"): both count.\nexport const cameWithRelease = ({ app, version, commit }: TagCandidate) => {\n const exact = `${literal(version)}(?![\\\\w.])`;\n return (\n new RegExp(`^chore\\\\(${literal(app)}\\\\): release v${exact}`).test(commit.subject) ||\n (commit.subject.startsWith(\"chore(release):\") &&\n (new RegExp(`\\\\b${literal(app)} v?${exact}`).test(commit.subject) ||\n // Too many apps for one header names none: the commit that changed the version is it.\n /^chore\\(release\\): \\d+ apps\\b/.test(commit.subject)))\n );\n};\n\n/** The tags and release notes still missing for the versions releases brought. */\nexport const releaseTags = (\n candidates: TagCandidate[],\n tags: Set<string>,\n notes: Set<string>,\n format = DEFAULT_TAG_FORMAT,\n): ReleaseTag[] =>\n candidates\n .filter((candidate) => candidate.first === true || cameWithRelease(candidate))\n .flatMap(({ app, version, commit }) => {\n const tag = tagName(app, version, format);\n const needsTag = !tags.has(tag);\n const needsNotes = !notes.has(tag);\n return needsTag || needsNotes\n ? [{ app, version, tag, sha: commit.sha, needsTag, needsNotes }]\n : [];\n });\n\n/** One version's section of a changesets CHANGELOG.md, used as its release notes. */\nexport const changelogSection = (changelog: string, version: string) => {\n const section = changelog.split(`\\n## ${version}\\n`)[1]?.split(\"\\n## \")[0]?.trim();\n return section || `No changelog entry for ${version}.`;\n};\n","import type { Environment } from \"./environment\";\n\nexport type ReleaseIntent = \"build\" | \"update\" | \"submit\";\n\nexport interface GitPosition {\n branch: string;\n head: string;\n /** origin/main after a fetch. */\n originMain: string;\n}\n\nexport type SourceResult = { allowed: true } | { allowed: false; why: \"not-main\" | \"behind-main\" };\n\n/**\n * A binary ships what it was built from, so builds start from main as it is on origin. Preview\n * updates may come from a branch for testers; production updates only from main.\n */\nexport const releaseSource = (\n intent: ReleaseIntent,\n channel: Environment,\n { branch, head, originMain }: GitPosition,\n): SourceResult => {\n const needsMain = intent === \"build\" || (intent === \"update\" && channel === \"production\");\n if (!needsMain) return { allowed: true };\n if (branch !== \"main\") return { allowed: false, why: \"not-main\" };\n if (head !== originMain) return { allowed: false, why: \"behind-main\" };\n return { allowed: true };\n};\n\n/** Where `pnpm shiplane` goes: --channel when given, preview under --yes or with no terminal, else asked. */\nexport const channelChoice = ({\n flag,\n yes,\n interactive,\n}: {\n flag: Environment | undefined;\n yes: boolean;\n interactive: boolean;\n}): Environment | null => flag ?? (yes || !interactive ? \"preview\" : null);\n\n/** Production never runs a step nobody confirmed. */\nexport const yesAllowed = (channel: Environment, yes: boolean) =>\n !(yes && channel === \"production\");\n","export interface RunOptions {\n cwd?: string;\n env?: Record<string, string>;\n input?: string;\n}\n\nexport interface ShellResult {\n status: number;\n stdout: string;\n stderr: string;\n}\n\n/** Every vendor tool this CLI drives (git, gh, eas, flyctl, wrangler) goes through here. */\nexport interface Shell {\n /** Runs and captures its output; a non-zero exit is a result, never an error. */\n capture: (command: string, args: readonly string[], options?: RunOptions) => Promise<ShellResult>;\n /** Runs in the person's terminal with its output shown; resolves with the exit status. */\n attach: (command: string, args: readonly string[], options?: RunOptions) => Promise<number>;\n /** A variable of this process's environment, such as a token a command needs. */\n env: (name: string) => string | undefined;\n}\n\n/** A command that exited non-zero, carrying all it printed so a failure can show why. */\nexport class CommandFailed extends Error {\n readonly output: string;\n\n constructor(message: string, output: string) {\n super(message);\n this.name = \"CommandFailed\";\n this.output = output;\n }\n}\n","const toParts = (version: string) =>\n version.split(\".\").map((part) => Number.parseInt(part, 10) || 0);\n\n/** Negative, zero or positive, like a sort comparator: \"0.1.10\" is after \"0.1.9\". */\nexport const compareVersions = (left: string, right: string): number => {\n const leftParts = toParts(left);\n const rightParts = toParts(right);\n const length = Math.max(leftParts.length, rightParts.length);\n\n for (let index = 0; index < length; index += 1) {\n const difference = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);\n if (difference !== 0) return difference;\n }\n\n return 0;\n};\n\nexport const nextPatch = (version: string) => {\n const [major = 0, minor = 0, patch = 0] = version.split(\".\").map(Number);\n return `${major}.${minor}.${patch + 1}`;\n};\n","import { isReleaseSubject } from \"./tags\";\nimport { nextPatch } from \"./versions\";\n\n/** A unit as changesets know it: its name here, its package name there. */\nexport interface UnitRef {\n name: string;\n packageName: string;\n}\n\nexport type BumpType = \"major\" | \"minor\" | \"patch\" | \"none\";\n\n/** One changeset, as `changeset status --output` lists it. */\nexport interface PlannedChangeset {\n id: string;\n summary: string;\n releases: { name: string; type: BumpType }[];\n}\n\n/** One package's version move, as `changeset status --output` lists it. */\nexport interface PlannedRelease {\n name: string;\n type: BumpType;\n oldVersion: string;\n newVersion: string;\n /** Empty when the package only moves because a workspace dependency did. */\n changesets: string[];\n}\n\nexport interface StatusPlan {\n changesets: PlannedChangeset[];\n releases: PlannedRelease[];\n}\n\nexport interface AppBump {\n /** The unit's name. */\n app: string;\n from: string;\n to: string;\n /** What the app's users get: the summaries of the changesets naming it. */\n notes: string[];\n /** The workspace packages it moves with, when no changeset names it. */\n movedWith: string[];\n}\n\n/** The units a release moves, in `units` order, each with its notes or the packages it moves with. */\nexport const appBumps = (\n { changesets, releases }: StatusPlan,\n dependencies: Record<string, string[]>,\n units: readonly UnitRef[],\n): AppBump[] => {\n const moving = new Set(releases.map(({ name }) => name));\n return units.flatMap(({ name: app, packageName }) => {\n const release = releases.find(({ name }) => name === packageName);\n if (!release) return [];\n const notes = changesets\n .filter(({ id }) => release.changesets.includes(id))\n .map(({ summary }) => summary);\n const movedWith =\n notes.length > 0 ? [] : (dependencies[release.name] ?? []).filter((dep) => moving.has(dep));\n return [{ app, from: release.oldVersion, to: release.newVersion, notes, movedWith }];\n });\n};\n\n/** How many internal packages a release moves: they get changelogs, nothing ships. */\nexport const packageBumps = ({ releases }: StatusPlan, units: readonly UnitRef[]) =>\n releases.filter(({ name }) => !units.some(({ packageName }) => packageName === name)).length;\n\n/**\n * Holding an app back keeps its lines pending, with any package line they came with so the package\n * does not drag the held app along. The picked apps' lines ship under the same summary.\n */\nexport const splitChangesets = (\n changesets: PlannedChangeset[],\n held: readonly string[],\n units: readonly UnitRef[],\n) => {\n const packageOf = (name: string) => units.find((unit) => unit.name === name)?.packageName;\n const heldNames = new Set(held.map(packageOf));\n const isUnit = (name: string) => units.some(({ packageName }) => packageName === name);\n return changesets.reduce<{ ships: PlannedChangeset[]; waits: PlannedChangeset[] }>(\n (split, changeset) => {\n if (!changeset.releases.some(({ name }) => heldNames.has(name))) {\n return { ...split, ships: [...split.ships, changeset] };\n }\n const picked = changeset.releases.filter(({ name }) => isUnit(name) && !heldNames.has(name));\n const waiting = changeset.releases.filter(\n ({ name }) => !picked.some((line) => line.name === name),\n );\n return {\n ships:\n picked.length > 0 ? [...split.ships, { ...changeset, releases: picked }] : split.ships,\n waits: [...split.waits, { ...changeset, releases: waiting }],\n };\n },\n { ships: [], waits: [] },\n );\n};\n\n/** The units a changeset file releases, read from its frontmatter. */\nexport const changesetApps = (text: string, units: readonly UnitRef[]): string[] => {\n const frontmatter = text.split(\"---\")[1] ?? \"\";\n return units\n .filter(({ packageName }) => frontmatter.includes(`\"${packageName}\":`))\n .map(({ name }) => name);\n};\n\nexport interface UnreleasedApp {\n /** The unit's name. */\n app: string;\n version: string;\n /** Subjects of the commits that touched it since its current version, newest first. */\n commits: string[];\n}\n\n/** Apps that changed since their current version came out, with no changeset to ship it. */\nexport const unreleasedApps = (\n history: UnreleasedApp[],\n named: ReadonlySet<string>,\n): UnreleasedApp[] =>\n history\n .map((entry) => ({\n ...entry,\n commits: entry.commits.filter((subject) => !isReleaseSubject(subject)),\n }))\n .filter(({ app, commits }) => commits.length > 0 && !named.has(app));\n\nconst USER_FACING = /^(feat|fix|perf)(\\(.+?\\))?!?:/;\n\n// Commit subjects here are written as user value already: drop the type, scope and PR number.\nconst asSentence = (subject: string) => {\n const text = subject\n .replace(/^\\w+(\\(.+?\\))?!?:\\s*/, \"\")\n .replace(/\\s*\\(#\\d+\\)$/, \"\")\n .trim();\n const sentence = `${text.charAt(0).toUpperCase()}${text.slice(1)}`;\n return /[.!?]$/.test(sentence) ? sentence : `${sentence}.`;\n};\n\n/**\n * The patch changesets the release writes for an unreleased app the person picked: one changelog\n * line per feature or fix since its release, or its latest commit when there are only chores.\n */\nexport const unreleasedChangesets = (\n { name: app, packageName }: UnitRef,\n version: string,\n commits: string[],\n): PlannedChangeset[] => {\n const userFacing = commits.filter((commit) => USER_FACING.test(commit));\n const lines = userFacing.length > 0 ? userFacing : commits.slice(0, 1);\n return lines.map((subject, index) => ({\n id: `${app}-${nextPatch(version)}-${index + 1}`,\n releases: [{ name: packageName, type: \"patch\" }],\n summary: asSentence(subject),\n }));\n};\n","import type { Environment } from \"./environment\";\n\n/** The run name the deploy workflows set, so the Actions list says which version went where. */\nexport const deployRunTitle = (tag: string, environment: Environment) =>\n `Deploy ${tag} to ${environment}`;\n\nexport type DeployState = \"none\" | \"running\" | \"done\";\n\n// INACTIVE: a later deploy to the same environment superseded a successful one.\nconst DEPLOYED = new Set([\"SUCCESS\", \"ACTIVE\", \"INACTIVE\"]);\nconst DEPLOYING = new Set([\"IN_PROGRESS\", \"QUEUED\", \"PENDING\", \"WAITING\"]);\n\n/** One version on one environment, from the states of its GitHub deployments. */\nexport const deployState = (states: string[]): DeployState => {\n if (states.some((state) => DEPLOYED.has(state))) return \"done\";\n return states.some((state) => DEPLOYING.has(state)) ? \"running\" : \"none\";\n};\n\nexport type WebShip = \"deploy\" | \"deploying\" | \"shipped\" | \"not-on-preview\";\n\n/** What one web app's tagged version still needs on an environment. */\nexport const webShip = ({\n environment,\n run,\n onPreview,\n}: {\n environment: Environment;\n /** Its deploy on that environment: none yet, queued or waiting on the approval gate, or done. */\n run: DeployState;\n onPreview: boolean;\n}): WebShip => {\n if (run === \"done\") return \"shipped\";\n if (run === \"running\") return \"deploying\";\n if (environment === \"production\" && !onPreview) return \"not-on-preview\";\n return \"deploy\";\n};\n\n/** Whether a diff only moves version files: the code is still the code a release named. */\nexport const onlyVersionFiles = (files: string[], versionFiles: ReadonlySet<string>) =>\n files.every((file) => versionFiles.has(file));\n\nexport type DeployPath = \"github\" | \"local\";\n\n/** How this run deploys: --via when given, GitHub Actions under --yes, otherwise asked (null). */\nexport const deployVia = ({ via, yes }: { via: DeployPath | undefined; yes: boolean }) =>\n via ?? (yes ? (\"github\" as const) : null);\n\nexport interface ShipItem {\n /** The unit's name. */\n app: string;\n tag: string;\n /** An EAS build, an over-the-air update, or a web deploy. */\n kind: \"build\" | \"update\" | \"deploy\";\n}\n\n/** An EAS build runs on EAS whichever way: only updates and web deploys have a path to pick. */\nexport const needsPath = (items: ShipItem[]) => items.some(({ kind }) => kind !== \"build\");\n\n/** This machine builds its checkout, so it ships only while that is the tagged code. */\nexport const shipsFrom = (\n path: DeployPath,\n { sinceTagOnlyVersionFiles }: { sinceTagOnlyVersionFiles: boolean },\n) => path === \"github\" || sinceTagOnlyVersionFiles;\n","import type { ShipItem } from \"./deploys\";\n\n// Minutes a private repository's plan includes each month, and how GitHub weighs each runner.\nconst INCLUDED_MINUTES: Record<string, number> = { free: 2000, team: 3000, enterprise: 50000 };\nconst MINUTE_WEIGHT: Record<string, number> = { actions_windows: 2, actions_macos: 10 };\n\nexport interface ActionsMinutes {\n used: number;\n included: number;\n left: number;\n}\n\n/** This month's Actions minutes against the plan's allowance, from GitHub's usage summary. */\nexport const actionsMinutes = (\n plan: string,\n usage: { sku: string; grossQuantity: number; unitType: string }[],\n): ActionsMinutes | null => {\n const included = INCLUDED_MINUTES[plan];\n if (!included) return null;\n const used = Math.round(\n usage\n .filter(({ unitType }) => unitType === \"minutes\")\n .reduce((sum, { sku, grossQuantity }) => sum + grossQuantity * (MINUTE_WEIGHT[sku] ?? 1), 0),\n );\n return { used, included, left: Math.max(0, included - used) };\n};\n\nexport interface MinutesBudget {\n tone: \"green\" | \"yellow\" | \"red\";\n title: string;\n /** What is left, with what this release will spend shaded in. */\n bar: string;\n amount: string;\n pace: string;\n /** The status chip: enough, running short, or about to run out. */\n status: string;\n /** What is left after this release, or null when it spends nothing on GitHub. */\n after: string | null;\n}\n\nconst LOW_MINUTES = 100;\n\nconst STATUS: Record<MinutesBudget[\"tone\"], string> = {\n green: \"โ— enough minutes this month\",\n yellow: \"โ— running short this month\",\n red: \"โ— about to run out: deploy from this machine\",\n};\n\n/**\n * The minutes as the deploy question draws them: a bar of what is left, what this release spends,\n * and where this month ends if the pace so far holds. GitHub resets the allowance on the 1st, UTC.\n */\nexport const minutesBudget = (\n budget: ActionsMinutes,\n now: Date,\n width = 30,\n spend = 0,\n): MinutesBudget => {\n const { used, included, left } = budget;\n const start = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1);\n const end = Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + 1, 1);\n const elapsed = Math.max((now.getTime() - start) / (end - start), 1 / (31 * 24));\n const projected = Math.round(used / elapsed) + spend;\n const leftAfter = Math.max(0, left - spend);\n const month = (format: Intl.DateTimeFormatOptions) =>\n new Date(start).toLocaleDateString(\"en-US\", { ...format, timeZone: \"UTC\" });\n const lastDay = new Date(end - 1).getUTCDate();\n const filled = Math.round((left / included) * width);\n const filledAfter = Math.round((leftAfter / included) * width);\n const number = (value: number) => value.toLocaleString(\"en-US\");\n const tone: MinutesBudget[\"tone\"] =\n leftAfter < LOW_MINUTES\n ? \"red\"\n : leftAfter / included < 0.5 || projected > included\n ? \"yellow\"\n : \"green\";\n const pace = `At this pace${spend > 0 ? \", with this release,\" : \"\"} about ${number(projected)} used by ${month({ month: \"long\" })} ${lastDay}`;\n return {\n tone,\n title: `GitHub Actions minutes ยท ${month({ month: \"long\", year: \"numeric\" })}`,\n bar: `${\"โ–ˆ\".repeat(filledAfter)}${\"โ–’\".repeat(filled - filledAfter)}${\"โ–‘\".repeat(width - filled)}`,\n amount: `${number(left)} of ${number(included)} left ยท ${Math.round((used / included) * 100)}% used`,\n pace:\n projected > included\n ? `${pace}, over the ${number(included)} included: prefer this machine.`\n : `${pace}, within the ${number(included)} included.`,\n status: STATUS[tone],\n after:\n spend > 0\n ? `This release: about ${spend} min on GitHub, about ${number(leftAfter)} left after it`\n : null,\n };\n};\n\n/** Minutes GitHub bills for a run: each job rounds up to the minute; unfinished jobs are skipped. */\nexport const billedMinutes = (jobs: { startedAt: string | null; completedAt: string | null }[]) =>\n jobs.reduce((sum, { startedAt, completedAt }) => {\n if (!startedAt || !completedAt) return sum;\n const seconds = (Date.parse(completedAt) - Date.parse(startedAt)) / 1000;\n return sum + Math.max(1, Math.ceil(seconds / 60));\n }, 0);\n\n// A deploy with no measured run and no typical figure: about what a small web deploy bills.\nconst FALLBACK_MINUTES = 5;\n\n/**\n * What the GitHub path costs for these items: each workflow's recent runs when measured, typical\n * figures otherwise. An EAS build runs on EAS and costs no Actions minutes.\n */\nexport const deployEstimate = (\n items: ShipItem[],\n measured: Partial<Record<string, number[]>>,\n typical: Record<string, number>,\n) => {\n const lines = items\n .filter(({ kind }) => kind !== \"build\")\n .map(({ app }) => {\n const runs = measured[app] ?? [];\n return runs.length > 0\n ? { app, minutes: Math.ceil(runs.reduce((a, b) => a + b, 0) / runs.length), measured: true }\n : { app, minutes: typical[app] ?? FALLBACK_MINUTES, measured: false };\n });\n return { total: lines.reduce((sum, { minutes }) => sum + minutes, 0), lines };\n};\n"],"mappings":";;;;;AAKA,MAAM,sBAAsB,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,SAAS;AAC5F,MAAM,0BAA0B,EAAE,OAAO,EACvC,YAAY,EACT,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CACzE,UAAU,EACd,CAAC;AAEF,MAAM,YAAY,SAAkB,GAAG,WAAW,KAAK,GAAG,GAAG,aAAa,MAAM,OAAO,GAAG;;AAG1F,MAAa,qBAAqB,SAA2B;CAC3D,MAAM,OAAO,SAAS,KAAK,KAAK,MAAM,sBAAsB,CAAC;CAC7D,MAAM,WAAW,SAAS,OAAO,KAAA,IAAY,oBAAoB,MAAM,MAAM,KAAK,CAAC,EAAE;AACrF,KAAI,YAAY,SAAS,SAAS,EAAG,QAAO;CAC5C,MAAM,WAAW,SAAS,KAAK,KAAK,MAAM,eAAe,CAAC;CAC1D,MAAM,EAAE,eACN,aAAa,OACT,EAAE,YAAY,KAAA,GAAW,GACzB,wBAAwB,MAAM,KAAK,MAAM,SAAS,CAAC;AACzD,KAAI,WAAY,QAAO,MAAM,QAAQ,WAAW,GAAG,aAAa,WAAW;AAC3E,QAAO,CAAC,IAAI;;AAGd,MAAM,gBAAgB,MAAc,WAAmB;CACrD,MAAM,WAAW,KAAK,KAAK,MAAM,OAAO;AACxC,KAAI,CAAC,GAAG,WAAW,SAAS,CAAE,QAAO,EAAE;AACvC,QAAO,GACJ,YAAY,UAAU,EAAE,eAAe,MAAM,CAAC,CAC9C,QACE,UACC,MAAM,aAAa,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