@hanzo/build 0.2.117 → 0.2.118
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/lib/api/github.d.ts +12 -1
- package/lib/api/github.js +27 -2
- package/lib/sync.js +8 -4
- package/package.json +1 -1
package/lib/api/github.d.ts
CHANGED
|
@@ -116,6 +116,8 @@ export interface Grants {
|
|
|
116
116
|
repos: Grant[];
|
|
117
117
|
/** Accounts the connection could not read. */
|
|
118
118
|
unread: string[];
|
|
119
|
+
/** The accounts the organization added (`added`), each listed even before any of its repositories is. */
|
|
120
|
+
added?: string[];
|
|
119
121
|
}
|
|
120
122
|
export interface Account {
|
|
121
123
|
name: string;
|
|
@@ -131,7 +133,7 @@ export interface Account {
|
|
|
131
133
|
* `imported` is decided by `grants` from the links and the forge.
|
|
132
134
|
*/
|
|
133
135
|
export declare function grant(raw: unknown): Grant | null;
|
|
134
|
-
/** Accounts the grant names, plus any account that could not be read. */
|
|
136
|
+
/** Accounts the grant names, plus any account that could not be read or that the organization added. */
|
|
135
137
|
export declare function accounts(g: Grants): Account[];
|
|
136
138
|
/**
|
|
137
139
|
* Every repository the GitHub connection grants, every page, with whether the
|
|
@@ -139,6 +141,15 @@ export declare function accounts(g: Grants): Account[];
|
|
|
139
141
|
* state), or a forge repository under its codebase name (GET /v1/git/repos).
|
|
140
142
|
*/
|
|
141
143
|
export declare function grants(t: Target, signal?: AbortSignal): Promise<Grants>;
|
|
144
|
+
/**
|
|
145
|
+
* The repositories this organization can bring in: `grants`, narrowed to the
|
|
146
|
+
* accounts the organization has added (`installations`, `connected`). The list
|
|
147
|
+
* is the person's own GitHub, which reaches accounts another Hanzo workspace
|
|
148
|
+
* added; the import goes through this organization's own, so it refuses every
|
|
149
|
+
* repository of those. With the organization's accounts unreadable, `grants` as
|
|
150
|
+
* it is: the import still says which it refuses.
|
|
151
|
+
*/
|
|
152
|
+
export declare function added(t: Target, signal?: AbortSignal): Promise<Grants>;
|
|
142
153
|
/** What an import queued: how many, and the name each takes on the forge, by `owner/name`. */
|
|
143
154
|
export interface Queued {
|
|
144
155
|
queued: number;
|
package/lib/api/github.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* POST /v1/provider/github/user/connect {return} → {authorizeUrl}
|
|
8
8
|
* POST /v1/provider/github/user/complete {grant} → the connection
|
|
9
9
|
* POST /v1/provider/github/user/disconnect
|
|
10
|
-
* GET /v1/provider/github/installations the accounts this org has bound the App on
|
|
10
|
+
* GET /v1/provider/github/installations the accounts this org has bound the App on (`added` narrows to them)
|
|
11
11
|
* POST /v1/provider/github/issues/backfill {state, repo?} → mirror GitHub issues onto the board
|
|
12
12
|
*
|
|
13
13
|
* Paged by an opaque `after` cursor; `next` is the cursor for the page after
|
|
@@ -152,7 +152,7 @@ export function grant(raw) {
|
|
|
152
152
|
status: '',
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
/** Accounts the grant names, plus any account that could not be read. */
|
|
155
|
+
/** Accounts the grant names, plus any account that could not be read or that the organization added. */
|
|
156
156
|
export function accounts(g) {
|
|
157
157
|
const counts = new Map();
|
|
158
158
|
for (const r of g.repos) {
|
|
@@ -162,6 +162,14 @@ export function accounts(g) {
|
|
|
162
162
|
}
|
|
163
163
|
const unread = new Set(g.unread.filter(Boolean));
|
|
164
164
|
const names = new Set([...counts.keys(), ...unread]);
|
|
165
|
+
// GitHub's logins are case-blind: an added account is named once, as its repositories spell it.
|
|
166
|
+
const seen = new Set([...names].map((n) => n.toLowerCase()));
|
|
167
|
+
for (const n of g.added ?? []) {
|
|
168
|
+
if (!n || seen.has(n.toLowerCase()))
|
|
169
|
+
continue;
|
|
170
|
+
names.add(n);
|
|
171
|
+
seen.add(n.toLowerCase());
|
|
172
|
+
}
|
|
165
173
|
return [...names]
|
|
166
174
|
.sort((a, b) => a.localeCompare(b))
|
|
167
175
|
.map((name) => {
|
|
@@ -211,6 +219,23 @@ export async function grants(t, signal) {
|
|
|
211
219
|
unread: unread.filter(Boolean),
|
|
212
220
|
};
|
|
213
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* The repositories this organization can bring in: `grants`, narrowed to the
|
|
224
|
+
* accounts the organization has added (`installations`, `connected`). The list
|
|
225
|
+
* is the person's own GitHub, which reaches accounts another Hanzo workspace
|
|
226
|
+
* added; the import goes through this organization's own, so it refuses every
|
|
227
|
+
* repository of those. With the organization's accounts unreadable, `grants` as
|
|
228
|
+
* it is: the import still says which it refuses.
|
|
229
|
+
*/
|
|
230
|
+
export async function added(t, signal) {
|
|
231
|
+
const [g, mine] = await Promise.all([grants(t, signal), installations(t).catch(() => null)]);
|
|
232
|
+
if (!mine)
|
|
233
|
+
return g;
|
|
234
|
+
const logins = mine.filter((i) => i.connected).map((i) => i.login);
|
|
235
|
+
const held = new Set(logins.map((l) => l.toLowerCase()));
|
|
236
|
+
const ours = (name) => held.has(name.toLowerCase());
|
|
237
|
+
return { repos: g.repos.filter((r) => ours(r.owner)), unread: g.unread.filter(ours), added: logins };
|
|
238
|
+
}
|
|
214
239
|
/** Queue a mirror of the named repositories onto the forge. The names are `owner/name`. */
|
|
215
240
|
export async function bring(t, repos) {
|
|
216
241
|
const names = repos.map((n) => n.trim()).filter(Boolean);
|
package/lib/sync.js
CHANGED
|
@@ -2,7 +2,9 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
/**
|
|
3
3
|
* Bring repositories the GitHub connection already grants onto the forge.
|
|
4
4
|
*
|
|
5
|
-
* The list is GET /v1/provider/github/repos
|
|
5
|
+
* The list is GET /v1/provider/github/repos, narrowed to the accounts this
|
|
6
|
+
* organization added (github.ts `added`): those are the only ones the import
|
|
7
|
+
* brings repositories in through. The queue is POST
|
|
6
8
|
* /v1/provider/github/repos/import, which mirrors `owner/name` into this
|
|
7
9
|
* organization's forge in the background. An account named unread and holding
|
|
8
10
|
* no repositories is shown as needing an organization admin. One repository
|
|
@@ -18,7 +20,7 @@ import { Button, Input } from '@hanzo/ui';
|
|
|
18
20
|
import { useEffect, useMemo, useState } from 'react';
|
|
19
21
|
import { here, useBack } from './back.js';
|
|
20
22
|
import { Refusal } from './api/call.js';
|
|
21
|
-
import { accounts, bring, grants } from './api/github.js';
|
|
23
|
+
import { accounts, added, bring, grants } from './api/github.js';
|
|
22
24
|
import { authorize } from './api/provider.js';
|
|
23
25
|
import { pinHub, readPending, writePending } from './choice.js';
|
|
24
26
|
import { useRead } from './data.js';
|
|
@@ -39,7 +41,7 @@ export function Sync() {
|
|
|
39
41
|
const [error, setError] = useState('');
|
|
40
42
|
// The import was refused because this organization holds no GitHub account of its own (the list is the person's).
|
|
41
43
|
const [unbound, setUnbound] = useState(false);
|
|
42
|
-
const list = useRead(signed ? () =>
|
|
44
|
+
const list = useRead(signed ? () => added(target) : null, EMPTY, [target, signed]);
|
|
43
45
|
const rows = list.value.repos;
|
|
44
46
|
const orgs = useMemo(() => accounts(list.value), [list.value]);
|
|
45
47
|
const needle = q.trim().toLowerCase();
|
|
@@ -136,7 +138,9 @@ export function Sync() {
|
|
|
136
138
|
window.clearInterval(id);
|
|
137
139
|
};
|
|
138
140
|
}, [syncing, target, host.org, host.go, picked]);
|
|
139
|
-
return (_jsxs(YStack, { flex: 1, minH: 0, overflow: "scroll", children: [_jsxs(XStack, { px: "$6", pt: "$5", pb: "$2", gap: "$2", items: "center", children: [_jsx(XStack, { render: "button", "aria-label": t('Back to projects'), onPress: back, children: _jsx(SizableText, { size: "$2", color: "$soft", children: t('Projects') }) }), _jsx(SizableText, { size: "$2", color: "$soft", children: "/" }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Sync') })] }), _jsxs(YStack, { flex: 1, items: "center", justify: "center", px: "$6", pb: "$10", gap: "$5", children: [_jsxs(XStack, { justify: "center", gap: "$6", children: [_jsx(Step, { label: t('Select repositories'), done: step === 'access', current: step === 'pick' }), _jsx(Step, { label: t('Repository access'), done: false, current: step === 'access' })] }), _jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$5", bg: "$panel", px: "$6", py: "$6", gap: "$4", width: "100%", maxW: 460, children: [step === 'pick' && !owner ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Select repositories') }), _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: t('Choose repositories to bring into {place}', { place: dest }) })] }), _jsxs(Panel, { children: [_jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Search organizations'), "aria-label": t('Search organizations'), disabled: !signed }), signed ? (_jsx(SizableText, { size: "$1", color: "$soft", children: orgs.length === 1 ? t('1 organization') : t('{n} organizations', { n: orgs.length }) })) : null, list.error ? _jsx(Soft, { children: t('The GitHub connection could not be read right now.') }) : null, !signed ? (_jsx(Soft, { children: t('Sign in to choose repositories the GitHub connection can read.') })) : list.loading && rows.length === 0 && orgs.length === 0 ? (_jsx(Soft, { children: t('Reading the connection…') })) :
|
|
141
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, overflow: "scroll", children: [_jsxs(XStack, { px: "$6", pt: "$5", pb: "$2", gap: "$2", items: "center", children: [_jsx(XStack, { render: "button", "aria-label": t('Back to projects'), onPress: back, children: _jsx(SizableText, { size: "$2", color: "$soft", children: t('Projects') }) }), _jsx(SizableText, { size: "$2", color: "$soft", children: "/" }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Sync') })] }), _jsxs(YStack, { flex: 1, items: "center", justify: "center", px: "$6", pb: "$10", gap: "$5", children: [_jsxs(XStack, { justify: "center", gap: "$6", children: [_jsx(Step, { label: t('Select repositories'), done: step === 'access', current: step === 'pick' }), _jsx(Step, { label: t('Repository access'), done: false, current: step === 'access' })] }), _jsxs(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$5", bg: "$panel", px: "$6", py: "$6", gap: "$4", width: "100%", maxW: 460, children: [step === 'pick' && !owner ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Select repositories') }), _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: t('Choose repositories to bring into {place}', { place: dest }) })] }), _jsxs(Panel, { children: [_jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Search organizations'), "aria-label": t('Search organizations'), disabled: !signed }), signed && !(list.loading && orgs.length === 0) ? (_jsx(SizableText, { size: "$1", color: "$soft", children: orgs.length === 1 ? t('1 organization') : t('{n} organizations', { n: orgs.length }) })) : null, list.error ? _jsx(Soft, { children: t('The GitHub connection could not be read right now.') }) : null, !signed ? (_jsx(Soft, { children: t('Sign in to choose repositories the GitHub connection can read.') })) : list.loading && rows.length === 0 && orgs.length === 0 ? (_jsx(Soft, { children: t('Reading the connection…') })) : list.error && orgs.length === 0 ? null : shownOrgs.length === 0 ? (_jsx(Soft, { children: orgs.length === 0
|
|
142
|
+
? t('No GitHub account is added to {place} yet. Add organization installs the Hanzo app on one.', { place: dest })
|
|
143
|
+
: t('Nothing matches.') })) : (shownOrgs.map((a) => (_jsxs(XStack, { render: "button", "aria-label": a.blocked ? t('{name} needs an organization admin', { name: a.name }) : t('Open {name}', { name: a.name }), disabled: a.blocked, items: "center", gap: "$2", py: "$2", borderTopWidth: 1, borderColor: "$borderColor", onPress: () => {
|
|
140
144
|
setOwner(a.name);
|
|
141
145
|
setQ('');
|
|
142
146
|
}, children: [_jsx(SizableText, { flex: 1, size: "$2", color: a.blocked ? '$soft' : '$ink', numberOfLines: 1, children: a.name }), a.blocked ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Needs organization admin') })) : (_jsx(ChevronRight, { size: 14, 'data-i18n-mirror': '' }))] }, a.name)))), _jsxs(XStack, { render: "button", "aria-label": t('Add organization'), items: "center", gap: "$2", py: "$2", onPress: () => void addOrg(), disabled: !signed, children: [_jsx(Plus, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Add organization') })] })] })] })) : null, step === 'pick' && owner ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Select repositories') }), _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: t('Choose repositories to bring into {place}', { place: dest }) })] }), _jsxs(Panel, { children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(XStack, { render: "button", "aria-label": t('All organizations'), onPress: () => setOwner(''), children: _jsx(ChevronLeft, { size: 16, 'data-i18n-mirror': '' }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$ink", numberOfLines: 1, children: owner })] }), _jsx(Input, { value: q, onChangeText: setQ, placeholder: t('Search repositories'), "aria-label": t('Search repositories') }), _jsxs(XStack, { justify: "space-between", items: "center", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: ofOwner.length === 1 ? t('1 repository') : t('{n} repositories', { n: ofOwner.length }) }), _jsx(XStack, { render: "button", "aria-label": t('Select all'), onPress: selectShown, disabled: shownRepos.length === 0, children: _jsx(SizableText, { size: "$1", color: "$ink", children: t('Select all') }) })] }), shownRepos.length === 0 ? (_jsx(Soft, { children: t('Nothing matches.') })) : (shownRepos.map((r) => (_jsx(RepoRow, { repo: r, on: picked.includes(r.fullName), onPress: () => toggle(r.fullName) }, r.fullName)))), _jsxs(XStack, { render: "button", "aria-label": t('Grant more repositories'), items: "center", gap: "$2", py: "$2", onPress: () => void addOrg(), children: [_jsx(Plus, { size: 14 }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Add repositories') })] })] })] })) : null, step === 'access' ? (_jsxs(_Fragment, { children: [_jsxs(YStack, { gap: "$1", items: "center", children: [_jsx(SizableText, { size: "$5", color: "$ink", children: t('Repository access') }), _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: t('Review who can read these repositories') })] }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsxs(XStack, { flex: 1, items: "center", gap: "$2", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(XStack, { render: "button", "aria-label": t('Clear the selection'), onPress: () => { setPicked([]); setStep('pick'); }, children: _jsx(X, { size: 12 }) }), _jsx(SizableText, { flex: 1, size: "$2", color: "$ink", numberOfLines: 1, children: more ? t('{name}, +{n} more', { name: lead, n: more }) : lead })] }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => setStep('pick'), children: t('Edit') })] }), _jsxs(XStack, { justify: "space-between", gap: "$4", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Who gets access') }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('{name} · You', { name: host.person?.name || host.person?.email || t('You') }) })] }), _jsxs(YStack, { gap: "$1", items: "flex-end", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Role') }), _jsx(SizableText, { size: "$2", color: "$ink", children: host.admin ? t('Repository admin') : t('Member') })] })] }), _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: t('Anyone with access to {place}', { place: dest }) })] })) : null, error ? _jsx(Soft, { children: error }) : null, unbound && step === 'access' ? (_jsxs(Button, { width: "100%", variant: "outline", onPress: () => void addOrg(), children: [_jsx(Plus, { size: 14 }), t('Add organization')] })) : null, step === 'pick' ? (_jsx(Button, { width: "100%", disabled: !owner || picked.length === 0, onPress: () => setStep('access'), children: t('Continue') })) : (_jsxs(YStack, { gap: "$3", items: "center", width: "100%", children: [_jsx(Button, { width: "100%", disabled: busy || syncing || picked.length === 0, onPress: () => void send(), children: syncing || busy
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.118",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.",
|