ref0-git 0.6.0 → 0.8.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/app/apps/github/README.md +3 -7
- package/app/apps/github/generated/git-rest.ts +17 -20
- package/app/apps/github/src/clients/allowed.ts +7 -9
- package/app/apps/github/src/clients/avatars.ts +5 -3
- package/app/apps/github/src/clients/graphql.ts +12 -2
- package/app/apps/github/src/clients/host-calls.ts +2 -1
- package/app/apps/github/src/clients/transfers.ts +56 -19
- package/app/apps/github/src/components/signin/device-card.tsx +2 -2
- package/app/apps/github/src/context/context.ts +5 -5
- package/app/apps/github/src/context/host.ts +115 -0
- package/app/apps/github/src/ingress.ts +28 -0
- package/app/apps/github/src/policy.ts +113 -78
- package/app/apps/github/src/private-repos.ts +7 -7
- package/app/apps/github/src/pulls/review.ts +2 -1
- package/app/apps/github/src/releases/release-form.tsx +40 -4
- package/app/apps/github/src/releases/releases.ts +148 -22
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +9 -2
- package/app/apps/github/src/seed/seed.ts +68 -38
- package/app/apps/github/src/server.ts +28 -11
- package/app/apps/github/src/signin/approval.ts +20 -15
- package/app/apps/github/src/signin/attempts.ts +306 -0
- package/app/apps/github/src/signin/auth.ts +9 -0
- package/app/apps/github/src/signin/device-code.ts +2 -2
- package/app/apps/github/src/signin/device-prompt.ts +6 -6
- package/app/apps/github/src/signin/host-session.ts +30 -18
- package/app/apps/github/src/signin/limits.ts +35 -0
- package/app/pnpm-workspace.yaml +39 -38
- package/dist/cli/events.mjs +10 -13
- package/dist/cli/failure.mjs +4 -10
- package/dist/cli/hosts.mjs +2 -2
- package/dist/cli/queue.mjs +14 -23
- package/dist/cli/repos.mjs +10 -19
- package/dist/cli/resources.mjs +2 -2
- package/dist/cli/setup.mjs +33 -40
- package/dist/cli/sign-in.mjs +4 -4
- package/dist/cli/tokens.mjs +7 -11
- package/dist/cli/vendor.mjs +21 -1
- package/dist/init/app.mjs +45 -23
- package/dist/init/astro.mjs +2 -2
- package/dist/init/cloudflare.mjs +100 -51
- package/dist/init/create.mjs +1 -1
- package/dist/init/detect.mjs +7 -5
- package/dist/init/files.mjs +6 -1
- package/dist/init/git-module.mjs +89 -32
- package/dist/init/metadata.mjs +12 -7
- package/dist/init/mounts.mjs +12 -20
- package/dist/init/next.mjs +1 -1
- package/dist/init/node-app.mjs +5 -2
- package/dist/init/node.mjs +24 -35
- package/dist/init/nuxt.mjs +6 -7
- package/dist/init/react-router.mjs +2 -2
- package/dist/init/routes.mjs +13 -22
- package/dist/init/stores.mjs +3 -2
- package/dist/init/sveltekit.mjs +3 -3
- package/dist/init/template.mjs +14 -15
- package/dist/init/templates.mjs +76 -81
- package/dist/init/vercel.mjs +18 -22
- package/dist/init/versions.mjs +32 -4
- package/package.json +13 -13
package/app/pnpm-workspace.yaml
CHANGED
|
@@ -17,9 +17,9 @@ catalog:
|
|
|
17
17
|
'@base-ui/react': 1.9.0
|
|
18
18
|
# The app's Worker build: Cloudflare's Vite plugin at the release that runs wrangler's workerd, so
|
|
19
19
|
# the app and its tests share one miniflare.
|
|
20
|
-
'@cloudflare/vite-plugin': 1.70.
|
|
20
|
+
'@cloudflare/vite-plugin': 1.70.2
|
|
21
21
|
# Workers' runtime types, for @ref0/infra/cloudflare. Moves with wrangler's workerd.
|
|
22
|
-
'@cloudflare/workers-types': 5.
|
|
22
|
+
'@cloudflare/workers-types': 5.20261123.1
|
|
23
23
|
# The app's profile pictures, drawn from each login in the page, with no avatar service. MIT.
|
|
24
24
|
'@dicebear/core': 10.7.0
|
|
25
25
|
# The pictures' styles, of which the app imports two by subpath: Pixelbot for people and Planets
|
|
@@ -27,21 +27,21 @@ catalog:
|
|
|
27
27
|
'@dicebear/styles': 10.6.0
|
|
28
28
|
# Effect's Node platform, which Alchemy's CLI runs on: for examples/git-alchemy alone, at
|
|
29
29
|
# Effect's own version. MIT.
|
|
30
|
-
'@effect/platform-node': 4.1.
|
|
30
|
+
'@effect/platform-node': 4.1.7
|
|
31
31
|
# Effect's Node services without the Redis and undici platform-node brings: the CLI's file
|
|
32
32
|
# system, child processes, terminal and path, at Effect's own version (Q802). MIT.
|
|
33
|
-
'@effect/platform-node-shared': 4.1.
|
|
34
|
-
'@effect/tsgo': 0.
|
|
33
|
+
'@effect/platform-node-shared': 4.1.7
|
|
34
|
+
'@effect/tsgo': 0.74.0
|
|
35
35
|
# Effect's Vitest helpers, `it.effect` and `it.prop`, at Effect's own version.
|
|
36
|
-
'@effect/vitest': 4.1.
|
|
36
|
+
'@effect/vitest': 4.1.7
|
|
37
37
|
# GitHub's REST shapes as TypeScript types, which @ref0/github's contracts serve. MIT. Built from
|
|
38
38
|
# @octokit/openapi 23.0.1. The shapes' tests check answers against 24.0.0's description, whose
|
|
39
39
|
# label fields `RestLabel` adds until a release built from it exists.
|
|
40
40
|
'@octokit/openapi-types': 29.0.1
|
|
41
41
|
# GitHub's GraphQL schema, as Octokit packages it from GitHub's public schema. MIT. The test
|
|
42
42
|
# data @ref0/github's served GraphQL schema is checked against: every type and field it serves
|
|
43
|
-
# is GitHub's at this pin. The latest release on
|
|
44
|
-
'@octokit/graphql-schema':
|
|
43
|
+
# is GitHub's at this pin. The latest release on 29 Nov 2026.
|
|
44
|
+
'@octokit/graphql-schema': 16.0.0
|
|
45
45
|
# Octokit's GitHub App auth, which @ref0/github's App tests sign JWTs and mint installation
|
|
46
46
|
# tokens with, as a CI job would. MIT.
|
|
47
47
|
'@octokit/auth-app': 8.3.1
|
|
@@ -56,7 +56,7 @@ catalog:
|
|
|
56
56
|
# MIT.
|
|
57
57
|
'@octokit/webhooks': 14.2.0
|
|
58
58
|
# The app's diff view: virtualized, highlighted by Shiki, which only the browser loads. Apache-2.0.
|
|
59
|
-
'@pierre/diffs': 1.
|
|
59
|
+
'@pierre/diffs': 1.7.2
|
|
60
60
|
# Folder, submodule and symlink icons on the code pages and in the diff headers. Apache-2.0. A
|
|
61
61
|
# 2.0 beta, pinned: 0.9.0, the newest release, imports without extensions, which Node can't load.
|
|
62
62
|
'@pierre/icons': 2.0.0-beta.6
|
|
@@ -67,16 +67,16 @@ catalog:
|
|
|
67
67
|
# The app's Markdown renderer: words, a WebAssembly parser, with hooks for GitHub's alerts,
|
|
68
68
|
# anchors, references and URLs (Q213). Apache-2.0.
|
|
69
69
|
'@pierre/words': 0.3.0
|
|
70
|
-
'@ref0/workspace': 0.
|
|
70
|
+
'@ref0/workspace': 0.9.0
|
|
71
71
|
'@tailwindcss/vite': 4.3.5
|
|
72
72
|
# The app's stack: TanStack Start, its router and Query, and React, as spike F ran them, at the
|
|
73
73
|
# newest releases past pnpm's minimum release age.
|
|
74
|
-
'@tanstack/react-query': 5.108.
|
|
74
|
+
'@tanstack/react-query': 5.108.4
|
|
75
75
|
'@tanstack/react-router': 1.170.46
|
|
76
76
|
# The router's integration with Query: the server's page sends the queries its loaders read, so
|
|
77
77
|
# the browser hydrates from the same data. MIT.
|
|
78
78
|
'@tanstack/react-router-ssr-query': 1.167.3
|
|
79
|
-
'@tanstack/react-start': 1.169.
|
|
79
|
+
'@tanstack/react-start': 1.169.7
|
|
80
80
|
# hast's types, for the app's Markdown tests, which read renders as hast. MIT.
|
|
81
81
|
'@types/hast': 3.0.5
|
|
82
82
|
# libSQL's client, which a host passes to @ref0/infra/turso's turso() as createClient, and its
|
|
@@ -85,10 +85,10 @@ catalog:
|
|
|
85
85
|
'@libsql/kysely-libsql': 0.4.1
|
|
86
86
|
# better-sqlite3's types, for @ref0/infra/sqlite's tests over it. MIT.
|
|
87
87
|
'@types/better-sqlite3': 9.6.0
|
|
88
|
-
'@types/node': 24.19.
|
|
88
|
+
'@types/node': 24.19.4
|
|
89
89
|
# pg's types, for @ref0/infra/postgres's `listen` and its tests. MIT.
|
|
90
90
|
'@types/pg': 8.23.1
|
|
91
|
-
'@types/react': 19.3.
|
|
91
|
+
'@types/react': 19.3.3
|
|
92
92
|
# semver's types, for ref0-git's property over npm's version ranges, beside semver. MIT.
|
|
93
93
|
'@types/semver': 7.8.0
|
|
94
94
|
'@types/react-dom': 19.3.0
|
|
@@ -106,43 +106,44 @@ catalog:
|
|
|
106
106
|
diff: 9.0.0
|
|
107
107
|
# Exact, as ref0 pins it: npm ignores pnpm's lockfile, so a range would let a consumer pull a
|
|
108
108
|
# newer Effect than the one tested.
|
|
109
|
-
effect: 4.1.
|
|
109
|
+
effect: 4.1.7
|
|
110
110
|
# Postgres 17's binaries, which @ref0/infra/postgres's tests start a server from, with no Docker.
|
|
111
111
|
# The package is MIT, and the binaries in its platform packages are under the PostgreSQL License.
|
|
112
112
|
# The tests never import it: on `beforeExit` it calls `process.exit(0)`.
|
|
113
|
-
embedded-postgres: 17.
|
|
114
|
-
# The app's people, sign-up and sessions, over D1 through its own Kysely dialect: 1.7.19,
|
|
115
|
-
# 10 Nov 2026 (Q639),
|
|
116
|
-
# second connection beside it. Its username plugin is the login. No install scripts. MIT.
|
|
117
|
-
better-auth: 1.7.
|
|
113
|
+
embedded-postgres: 17.12.0-beta.19
|
|
114
|
+
# The app's people, sign-up and sessions, over D1 through its own Kysely dialect: from 1.7.19,
|
|
115
|
+
# published 10 Nov 2026 (Q639), its username plugin checks a login on a sign-up's transaction, not
|
|
116
|
+
# on a second connection beside it. Its username plugin is the login. No install scripts. MIT.
|
|
117
|
+
better-auth: 1.7.28
|
|
118
118
|
# Better Auth's passkeys, at its own release, over @simplewebauthn/server and /browser. No install
|
|
119
119
|
# scripts. MIT.
|
|
120
|
-
'@better-auth/passkey': 1.7.
|
|
120
|
+
'@better-auth/passkey': 1.7.28
|
|
121
121
|
# The query builder Better Auth's adapter runs on, at the release it resolves: a platform's file hands
|
|
122
122
|
# the app's people a Kysely dialect, such as libSQL's or Postgres's. MIT.
|
|
123
123
|
kysely: 0.29.9
|
|
124
124
|
# A SQLite driver @ref0/infra/sqlite's conformance runs on, beside node:sqlite. MIT.
|
|
125
|
-
better-sqlite3: 13.0
|
|
125
|
+
better-sqlite3: 13.2.0
|
|
126
126
|
# bun:sqlite's types, which @ref0/infra/sqlite's type test checks its database shape against. MIT.
|
|
127
|
-
bun-types: 1.4.
|
|
127
|
+
bun-types: 1.4.5
|
|
128
128
|
# A DOM for the app's mounted tests, at ref0's version. MIT.
|
|
129
129
|
happy-dom: 21.0.4
|
|
130
130
|
# IndexedDB in Node, which the app's saved-read tests run code/saved-reads.ts's store on, since
|
|
131
|
-
# happy-dom has none. 6.2.
|
|
131
|
+
# happy-dom has none. 6.2.8, published 8 Nov 2026: no dependencies, no install scripts, no
|
|
132
132
|
# network or `process` use, and no eval but two `Function` calls on fixed strings, which find the
|
|
133
133
|
# global under jsdom. Apache-2.0.
|
|
134
|
-
fake-indexeddb: 6.2.
|
|
134
|
+
fake-indexeddb: 6.2.8
|
|
135
135
|
# HTML read as hast, which the app's Markdown tests compare GitHub's render with. MIT.
|
|
136
|
-
hast-util-from-html: 2.0
|
|
137
|
-
# The app's icons
|
|
138
|
-
lucide-react: 1.
|
|
136
|
+
hast-util-from-html: 2.1.0
|
|
137
|
+
# The app's icons. ISC.
|
|
138
|
+
lucide-react: 1.82.0
|
|
139
139
|
# The app's fonts, from its shadcn preset: Inter for text and Geist for headings, bundled. OFL-1.1.
|
|
140
140
|
'@fontsource-variable/geist': 5.3.0
|
|
141
141
|
'@fontsource-variable/inter': 5.3.0
|
|
142
|
+
nitro: 3.0.261103-rc
|
|
142
143
|
# A pack's zlib members inflated one at a time, through its low-level API alone, in @ref0/git's
|
|
143
144
|
# `protocol/bytes/inflate.ts`, which reports the input each consumed. pako 3 exports no
|
|
144
|
-
# low-level API.
|
|
145
|
-
|
|
145
|
+
# low-level API. Pinned at 2.1.0: `inflate.ts` and `deflate.ts` reset its state field by field,
|
|
146
|
+
# and `inflate.fuzz.test.ts` holds the version a move to another must re-read.
|
|
146
147
|
pako: 2.1.0
|
|
147
148
|
# node-postgres: the pool @ref0/infra/postgres's tests run on, and the client its `listen` opens,
|
|
148
149
|
# an optional peer loaded only when `listen` is given. MIT.
|
|
@@ -178,7 +179,7 @@ catalog:
|
|
|
178
179
|
# package.json spec as npm does. ISC. At the release already in the lockfile.
|
|
179
180
|
semver: 7.8.6
|
|
180
181
|
# shadcn's CLI, which copies the app's components, and its `tailwind.css`. MIT.
|
|
181
|
-
shadcn: 4.23.
|
|
182
|
+
shadcn: 4.23.1
|
|
182
183
|
# Toasts, through shadcn's `sonner` component in the app. MIT.
|
|
183
184
|
sonner: 2.0.8
|
|
184
185
|
# Tailwind, which styles shadcn's components. MIT.
|
|
@@ -192,21 +193,21 @@ catalog:
|
|
|
192
193
|
github-slugger: 2.0.0
|
|
193
194
|
# A TLA+ model checker in TypeScript, for the models in verification/. MIT.
|
|
194
195
|
tla-ts: 0.0.10
|
|
195
|
-
tsrs: 7.1.0-beta.
|
|
196
|
+
tsrs: 7.1.0-beta.tsrs4
|
|
196
197
|
typescript: 7.0.2
|
|
197
|
-
vite-plus: 1.
|
|
198
|
-
# The Vitest that Vite+ 1.
|
|
198
|
+
vite-plus: 1.8.0
|
|
199
|
+
# The Vitest that Vite+ 1.8.0 bundles, `vp --version`'s, for `@effect/vitest`'s peer. Moves with
|
|
199
200
|
# `vite-plus`.
|
|
200
|
-
vitest: 5.1.
|
|
201
|
+
vitest: 5.1.1
|
|
201
202
|
# A YAML parser for scripts/detect-tables.ts, which reads linguist's tables into
|
|
202
203
|
# @ref0/github's language table. ISC.
|
|
203
204
|
yaml: 2.9.1
|
|
204
205
|
# Runs @ref0/infra/cloudflare's objects in workerd for its tests, through `createTestHarness`.
|
|
205
|
-
wrangler: 4.
|
|
206
|
+
wrangler: 4.168.0
|
|
206
207
|
|
|
207
208
|
# Vite+ is Vite here: Vitest, which Vite+ bundles, asks for Vite as its peer, and gets Vite+'s core.
|
|
208
209
|
overrides:
|
|
209
|
-
vite@*: npm:@voidzero-dev/vite-plus-core@8.3.
|
|
210
|
+
vite@*: npm:@voidzero-dev/vite-plus-core@8.3.8001
|
|
210
211
|
vitest@*: 'catalog:'
|
|
211
212
|
|
|
212
213
|
# wrangler's: esbuild fetches its binary, and workerd its runtime, on install. better-sqlite3
|
|
@@ -220,4 +221,4 @@ allowBuilds:
|
|
|
220
221
|
workerd: true
|
|
221
222
|
|
|
222
223
|
minimumReleaseAgeExclude:
|
|
223
|
-
- '@ref0/workspace@0.
|
|
224
|
+
- '@ref0/workspace@0.9.0'
|
package/dist/cli/events.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { failure, refused } from "./failure.mjs";
|
|
2
2
|
import { hostFlag } from "./hosts.mjs";
|
|
3
3
|
import { printable, streamed } from "./output.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { durationOf, remoteFor, repoArgument } from "./resources.mjs";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Stream from "effect/Stream";
|
|
6
7
|
import * as Option from "effect/Option";
|
|
7
8
|
import * as Predicate from "effect/Predicate";
|
|
8
9
|
import * as Command from "effect/cli/Command";
|
|
@@ -32,20 +33,16 @@ const listen = Command.make("listen", {
|
|
|
32
33
|
onSome: (set) => set.has(event.type)
|
|
33
34
|
}) && (entry === void 0 || namesEntry(event, entry));
|
|
34
35
|
const reading = Effect.gen(function* () {
|
|
35
|
-
const
|
|
36
|
-
const reader = yield* Effect.acquireRelease(Effect.sync(() => opened.value.getReader()), (held) => Effect.promise(() => held.cancel().catch(() => void 0)));
|
|
36
|
+
const remote = yield* remoteFor(flags.host);
|
|
37
37
|
let left = flags.follow ? Number.POSITIVE_INFINITY : Math.max(flags.count, 1);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
try: () => reader.read(),
|
|
41
|
-
catch: (error) => Predicate.hasProperty(error, "code") ? refused(error, opened.host) : failure("unreachable", `Lost ${opened.host}'s event stream`)
|
|
42
|
-
});
|
|
43
|
-
if (read.done) return yield* failure("stream_closed", `${printable(flags.repo)} was deleted before the events came`);
|
|
44
|
-
if (!matches(read.value)) continue;
|
|
45
|
-
if (!(yield* streamed(read.value))) return;
|
|
38
|
+
let done = false;
|
|
39
|
+
yield* remote.client.events.listen(flags.repo).pipe(Stream.filter(matches), Stream.mapError((error) => refused(error, remote.host)), Stream.runForEachWhile((event) => Effect.map(streamed(event), (printed) => {
|
|
46
40
|
left -= 1;
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
done = !printed || left <= 0;
|
|
42
|
+
return !done;
|
|
43
|
+
})), Effect.catchDefect(() => Effect.fail(failure("unreachable", `Lost ${remote.host}'s event stream`))));
|
|
44
|
+
if (!done) return yield* failure("stream_closed", `${printable(flags.repo)} was deleted before the events came`);
|
|
45
|
+
});
|
|
49
46
|
yield* within === void 0 ? reading : Effect.timeoutOrElse(reading, {
|
|
50
47
|
duration: within,
|
|
51
48
|
orElse: () => Effect.fail(failure("timeout", `No matching event came within ${Option.getOrElse(flags.timeout, () => "")}`))
|
package/dist/cli/failure.mjs
CHANGED
|
@@ -100,19 +100,13 @@ const tooManyWritesPause = (tried) => Duration.millis(250 * 2 ** tried);
|
|
|
100
100
|
const wroteNothing = (error) => error.code === "UNAVAILABLE" && Predicate.hasProperty(error.context, "reason") && error.context.reason === "too-many-writes";
|
|
101
101
|
/**
|
|
102
102
|
* A call's answer, or its refusal as the CLI's failure, sent again on `too-many-writes` at most
|
|
103
|
-
* `tooManyWritesTriesMost` times, each try said on stderr.
|
|
104
|
-
* so a cancel stops its request.
|
|
103
|
+
* `tooManyWritesTriesMost` times, each try said on stderr. Interrupting the run stops its request.
|
|
105
104
|
*/
|
|
106
105
|
const answered = (host, call) => {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
catch: () => failure("unreachable", `Couldn't reach ${host}`)
|
|
110
|
-
});
|
|
111
|
-
const tried = (tries) => Effect.flatMap(sent, (result) => {
|
|
112
|
-
if (result.kind === "success") return Effect.succeed(result.value);
|
|
113
|
-
if (tries >= 3 || !wroteNothing(result.error)) return Effect.fail(refused(result.error, host));
|
|
106
|
+
const tried = (tries) => Effect.catch(call, (error) => {
|
|
107
|
+
if (tries >= 3 || !wroteNothing(error)) return Effect.fail(refused(error, host));
|
|
114
108
|
return say(`${host} had too many writes at once. Trying again (${tries + 1} of 3)`).pipe(Effect.andThen(Effect.sleep(tooManyWritesPause(tries))), Effect.andThen(tried(tries + 1)));
|
|
115
109
|
});
|
|
116
|
-
return tried(0);
|
|
110
|
+
return Effect.catchDefect(tried(0), () => Effect.fail(failure("unreachable", `Couldn't reach ${host}`)));
|
|
117
111
|
};
|
|
118
112
|
export { CliFailure, answered, cancelled, diskFailed, exitCodes, failure, forget, leftBehind, leftovers, notPutBack, refused, snakeCase, unsafeCredential, usageFailure };
|
package/dist/cli/hosts.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import * as Redacted from "effect/Redacted";
|
|
|
9
9
|
import * as Option from "effect/Option";
|
|
10
10
|
import * as Schema from "effect/Schema";
|
|
11
11
|
import * as Flag from "effect/cli/Flag";
|
|
12
|
-
import {
|
|
12
|
+
import { RestClient } from "@ref0/git";
|
|
13
13
|
// src/cli/hosts.ts
|
|
14
14
|
/**
|
|
15
15
|
* The hosts `ref0-git` is signed in to, and the one a command talks to. Git's helpers can't list
|
|
@@ -118,7 +118,7 @@ const remoteOf = /* @__PURE__ */ Effect.fnUntraced(function* (chosen) {
|
|
|
118
118
|
endpoint,
|
|
119
119
|
origin,
|
|
120
120
|
host,
|
|
121
|
-
client:
|
|
121
|
+
client: yield* RestClient.make({
|
|
122
122
|
url: endpoint,
|
|
123
123
|
credentials: { token }
|
|
124
124
|
})
|
package/dist/cli/queue.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import * as Effect from "effect/Effect";
|
|
|
6
6
|
import * as Option from "effect/Option";
|
|
7
7
|
import * as Command from "effect/cli/Command";
|
|
8
8
|
import * as Flag from "effect/cli/Flag";
|
|
9
|
-
import * as Argument from "effect/cli/Argument";
|
|
10
9
|
import { branchRef, shortTarget } from "@ref0/git";
|
|
10
|
+
import * as Argument from "effect/cli/Argument";
|
|
11
11
|
// src/cli/queue.ts
|
|
12
12
|
/**
|
|
13
13
|
* `queue`: a repo's merge queue. An entry's, a hold's and a candidate's ID names its repo, so the
|
|
@@ -17,7 +17,7 @@ import { branchRef, shortTarget } from "@ref0/git";
|
|
|
17
17
|
const idArgument = (name, what) => Argument.String(name).pipe(Argument.withDescription(`The ${what}'s ID, as the queue printed it`));
|
|
18
18
|
const targetFlag = Flag.String("target").pipe(Flag.withDescription("The branch it merges into: the repo's default branch when it's left out"), Flag.withMetavar("BRANCH"), Flag.optional);
|
|
19
19
|
/** The branch `--target` names, else the repo's default branch, as the host says it. */
|
|
20
|
-
const targetOf = (remote, repo, target) => Option.isSome(target) ? Effect.succeed(branchRef(target.value)) : Effect.flatMap(answered(remote.host,
|
|
20
|
+
const targetOf = (remote, repo, target) => Option.isSome(target) ? Effect.succeed(branchRef(target.value)) : Effect.flatMap(answered(remote.host, remote.client.repos.get(repo, {})), (info) => info.defaultBranch === void 0 ? Effect.fail(usageFailure("no_default_branch", `${printable(repo)} shows you no default branch`, "Name the branch with --target")) : Effect.succeed(info.defaultBranch));
|
|
21
21
|
const add = Command.make("add", {
|
|
22
22
|
repo: repoArgument,
|
|
23
23
|
host: hostFlag,
|
|
@@ -31,22 +31,18 @@ const add = Command.make("add", {
|
|
|
31
31
|
const ask = (call) => answered(remote.host, call);
|
|
32
32
|
const source = branchRef(flags.source);
|
|
33
33
|
const target = yield* targetOf(remote, flags.repo, flags.target);
|
|
34
|
-
const tip = yield* ask(
|
|
35
|
-
|
|
36
|
-
signal
|
|
37
|
-
}));
|
|
38
|
-
const added = yield* ask((signal) => {
|
|
34
|
+
const tip = yield* ask(remote.client.refs.get(flags.repo, { ref: source }));
|
|
35
|
+
const added = yield* ask(Effect.suspend(() => {
|
|
39
36
|
const input = {
|
|
40
37
|
target,
|
|
41
38
|
source,
|
|
42
39
|
head: tip.oid,
|
|
43
|
-
key: Option.getOrElse(flags.key, () => shortTarget(source))
|
|
44
|
-
signal
|
|
40
|
+
key: Option.getOrElse(flags.key, () => shortTarget(source))
|
|
45
41
|
};
|
|
46
42
|
if (Option.isSome(flags.priority)) input.priority = flags.priority.value;
|
|
47
43
|
if (flags.jump) input.jump = true;
|
|
48
44
|
return remote.client.queue.add(flags.repo, input);
|
|
49
|
-
});
|
|
45
|
+
}));
|
|
50
46
|
const entry = added.entry.id;
|
|
51
47
|
yield* changed(added, entry, {
|
|
52
48
|
done: `${added.repeat ? "Already added" : "Added"} ${printable(shortTarget(source))} to the queue for ${printable(shortTarget(target))} in ${printable(flags.repo)}`,
|
|
@@ -76,7 +72,7 @@ const remove = Command.make("remove", {
|
|
|
76
72
|
entry: idArgument("ENTRY", "entry"),
|
|
77
73
|
host: hostFlag
|
|
78
74
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
79
|
-
const done = yield* called(flags.host, (client
|
|
75
|
+
const done = yield* called(flags.host, (client) => client.queue.remove(flags.entry, {}));
|
|
80
76
|
yield* changed(done.value, flags.entry, { done: `Removed ${printable(flags.entry)} from the queue on ${done.host}` });
|
|
81
77
|
})).pipe(Command.withDescription("Take an entry out of the queue"));
|
|
82
78
|
/** An entry's row, as `queue list` prints it. */
|
|
@@ -104,10 +100,9 @@ const list = Command.make("list", {
|
|
|
104
100
|
"--target",
|
|
105
101
|
shortTarget(target)
|
|
106
102
|
]];
|
|
107
|
-
const read = yield* pagesOf(remote, flags, command, entryLine, (client, page
|
|
103
|
+
const read = yield* pagesOf(remote, flags, command, entryLine, (client, page) => client.queue.list(flags.repo, {
|
|
108
104
|
target,
|
|
109
|
-
page
|
|
110
|
-
signal
|
|
105
|
+
page
|
|
111
106
|
}));
|
|
112
107
|
yield* listed(read, {
|
|
113
108
|
line: entryLine,
|
|
@@ -120,7 +115,7 @@ const show = Command.make("show", {
|
|
|
120
115
|
entry: idArgument("ENTRY", "entry"),
|
|
121
116
|
host: hostFlag
|
|
122
117
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
123
|
-
const entry = (yield* called(flags.host, (client
|
|
118
|
+
const entry = (yield* called(flags.host, (client) => client.queue.get(flags.entry, {}))).value;
|
|
124
119
|
if ((yield* CliModes).json) return yield* document(entry);
|
|
125
120
|
const rows = [
|
|
126
121
|
["Entry", printable(entry.id)],
|
|
@@ -165,13 +160,9 @@ const hold = Command.make("hold", {
|
|
|
165
160
|
"--help"
|
|
166
161
|
]]
|
|
167
162
|
});
|
|
168
|
-
const held = yield* called(flags.host, (client
|
|
169
|
-
reason: flags.reason,
|
|
170
|
-
signal
|
|
171
|
-
}) : client.queue.hold(what.repo, {
|
|
163
|
+
const held = yield* called(flags.host, (client) => what.entry !== void 0 ? client.queue.hold(what.entry, { reason: flags.reason }) : client.queue.hold(what.repo, {
|
|
172
164
|
target: branchRef(what.target),
|
|
173
|
-
reason: flags.reason
|
|
174
|
-
signal
|
|
165
|
+
reason: flags.reason
|
|
175
166
|
}));
|
|
176
167
|
const id = held.value.hold.id;
|
|
177
168
|
yield* changed(held.value, id, {
|
|
@@ -193,14 +184,14 @@ const release = Command.make("release", {
|
|
|
193
184
|
hold: idArgument("HOLD", "hold"),
|
|
194
185
|
host: hostFlag
|
|
195
186
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
196
|
-
const done = yield* called(flags.host, (client
|
|
187
|
+
const done = yield* called(flags.host, (client) => client.queue.release(flags.hold, {}));
|
|
197
188
|
yield* changed(done.value, flags.hold, { done: `Released ${printable(flags.hold)} on ${done.host}` });
|
|
198
189
|
})).pipe(Command.withDescription("Release a hold"));
|
|
199
190
|
const retry = Command.make("retry", {
|
|
200
191
|
candidate: idArgument("CANDIDATE", "candidate"),
|
|
201
192
|
host: hostFlag
|
|
202
193
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
203
|
-
const done = yield* called(flags.host, (client
|
|
194
|
+
const done = yield* called(flags.host, (client) => client.queue.retry(flags.candidate, {}));
|
|
204
195
|
yield* changed(done.value, done.value.candidate, { done: `Closed ${printable(done.value.candidate)} to try its entries again, on ${done.host}` });
|
|
205
196
|
})).pipe(Command.withDescription("Close a candidate and try its entries again"));
|
|
206
197
|
const queueCommand = Command.make("queue").pipe(Command.withDescription("A repo's merge queue (experimental)"), Command.withSubcommands([
|
package/dist/cli/repos.mjs
CHANGED
|
@@ -5,8 +5,7 @@ import * as Effect from "effect/Effect";
|
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
6
|
import * as Command from "effect/cli/Command";
|
|
7
7
|
import * as Flag from "effect/cli/Flag";
|
|
8
|
-
import { jobStates } from "@ref0/git
|
|
9
|
-
import { branchRef } from "@ref0/git";
|
|
8
|
+
import { branchRef, jobStates } from "@ref0/git";
|
|
10
9
|
import * as Record from "effect/Record";
|
|
11
10
|
// src/cli/repos.ts
|
|
12
11
|
/** `repos` and `work`: a host's repos, and a repo's saved work. */
|
|
@@ -16,11 +15,10 @@ const create = Command.make("create", {
|
|
|
16
15
|
public: Flag.Boolean("public").pipe(Flag.withDescription("Let anyone read it"), Flag.withDefault(false)),
|
|
17
16
|
defaultBranch: Flag.String("default-branch").pipe(Flag.withDescription("Its default branch, the host's default when it's left out"), Flag.withMetavar("BRANCH"), Flag.optional)
|
|
18
17
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
19
|
-
const made = yield* called(flags.host, (client
|
|
18
|
+
const made = yield* called(flags.host, (client) => {
|
|
20
19
|
const input = {
|
|
21
20
|
name: flags.repo,
|
|
22
|
-
public: flags.public
|
|
23
|
-
signal
|
|
21
|
+
public: flags.public
|
|
24
22
|
};
|
|
25
23
|
if (Option.isSome(flags.defaultBranch)) input.defaultBranch = branchRef(flags.defaultBranch.value);
|
|
26
24
|
return client.repos.create(input);
|
|
@@ -67,11 +65,10 @@ const list = Command.make("list", {
|
|
|
67
65
|
...prefix === void 0 ? [] : ["--prefix", prefix],
|
|
68
66
|
...flags.order === "name" ? [] : ["--order", flags.order]
|
|
69
67
|
];
|
|
70
|
-
const read = yield* pagesOf(flags.host, flags, command, printable, (client, page
|
|
68
|
+
const read = yield* pagesOf(flags.host, flags, command, printable, (client, page) => {
|
|
71
69
|
const input = {
|
|
72
70
|
page,
|
|
73
|
-
order: repoOrders[flags.order]
|
|
74
|
-
signal
|
|
71
|
+
order: repoOrders[flags.order]
|
|
75
72
|
};
|
|
76
73
|
if (prefix !== void 0) input.prefix = prefix;
|
|
77
74
|
return client.repos.list(input);
|
|
@@ -87,7 +84,7 @@ const show = Command.make("show", {
|
|
|
87
84
|
repo: repoArgument,
|
|
88
85
|
host: hostFlag
|
|
89
86
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
90
|
-
const shown = yield* called(flags.host, (client
|
|
87
|
+
const shown = yield* called(flags.host, (client) => client.repos.get(flags.repo, {}));
|
|
91
88
|
const info = shown.value;
|
|
92
89
|
if ((yield* CliModes).json) return yield* document(info);
|
|
93
90
|
const rows = [
|
|
@@ -104,7 +101,7 @@ const remove = Command.make("delete", {
|
|
|
104
101
|
repo: repoArgument,
|
|
105
102
|
host: hostFlag
|
|
106
103
|
}, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
|
|
107
|
-
const done = yield* called(flags.host, (client
|
|
104
|
+
const done = yield* called(flags.host, (client) => client.repos.delete(flags.repo, {}));
|
|
108
105
|
yield* changed(done.value, flags.repo, { done: `Deleted repo ${printable(flags.repo)} on ${done.host}` });
|
|
109
106
|
})).pipe(Command.withDescription("Delete a repo, its refs and its objects"));
|
|
110
107
|
const jobState = Flag.Literals("state", jobStates).pipe(Flag.withDescription("Only work in this state"), Flag.optional);
|
|
@@ -129,11 +126,8 @@ const workList = Command.make("list", {
|
|
|
129
126
|
"--host",
|
|
130
127
|
host
|
|
131
128
|
], ...state === void 0 ? [] : ["--state", state]];
|
|
132
|
-
const read = yield* pagesOf(flags.host, flags, command, jobLine, (client, page
|
|
133
|
-
const input = {
|
|
134
|
-
page,
|
|
135
|
-
signal
|
|
136
|
-
};
|
|
129
|
+
const read = yield* pagesOf(flags.host, flags, command, jobLine, (client, page) => {
|
|
130
|
+
const input = { page };
|
|
137
131
|
if (state !== void 0) input.state = state;
|
|
138
132
|
return client.work.list(flags.repo, input);
|
|
139
133
|
});
|
|
@@ -156,10 +150,7 @@ const workWrite = (verb, description) => Command.make(verb, jobFlags, Effect.fnU
|
|
|
156
150
|
name: flags.name,
|
|
157
151
|
key: flags.key
|
|
158
152
|
};
|
|
159
|
-
const done = yield* called(flags.host, (client
|
|
160
|
-
...job,
|
|
161
|
-
signal
|
|
162
|
-
}));
|
|
153
|
+
const done = yield* called(flags.host, (client) => client.work[verb](flags.repo, { ...job }));
|
|
163
154
|
yield* changed({
|
|
164
155
|
repo: flags.repo,
|
|
165
156
|
...job
|
package/dist/cli/resources.mjs
CHANGED
|
@@ -22,7 +22,7 @@ const remoteFor = (host) => Effect.flatMap(chosenHost(host), remoteOf);
|
|
|
22
22
|
/** The host's answer to `call`, made with its client: its refusal as the CLI's failure. */
|
|
23
23
|
const called = /* @__PURE__ */ Effect.fnUntraced(function* (host, call) {
|
|
24
24
|
const remote = yield* remoteFor(host);
|
|
25
|
-
const value = yield* answered(remote.host,
|
|
25
|
+
const value = yield* answered(remote.host, call(remote.client));
|
|
26
26
|
return {
|
|
27
27
|
...remote,
|
|
28
28
|
value
|
|
@@ -62,7 +62,7 @@ const pagesOf = /* @__PURE__ */ Effect.fnUntraced(function* (from, choice, comma
|
|
|
62
62
|
if (wanted !== void 0) page.limit = wanted - items.length;
|
|
63
63
|
if (after !== void 0) page.after = after;
|
|
64
64
|
const resumeAt = after;
|
|
65
|
-
const listing = yield* answered(remote.host,
|
|
65
|
+
const listing = yield* answered(remote.host, call(remote.client, page)).pipe(Effect.catch((failed) => withRows(failed, (rows) => resumable(failed, rows, resumeAt, command(remote.host), wanted))));
|
|
66
66
|
items.push(...listing.items);
|
|
67
67
|
after = listing.next;
|
|
68
68
|
if (wanted === void 0 || after === void 0 || items.length >= wanted) return {
|