@event4u/agent-switch 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -68
- package/dist/activity.js +97 -0
- package/dist/args.js +23 -3
- package/dist/auth-status.js +149 -0
- package/dist/balance.js +52 -0
- package/dist/browsers.js +90 -0
- package/dist/config-transfer.js +12 -2
- package/dist/daemon.js +89 -38
- package/dist/desktop-sessions.js +115 -0
- package/dist/dir-resolve.js +151 -0
- package/dist/doctor.js +209 -52
- package/dist/gui-settings.js +67 -0
- package/dist/hooks.js +21 -0
- package/dist/index.js +921 -71
- package/dist/mappings.js +48 -9
- package/dist/pools.js +144 -0
- package/dist/profiles.js +84 -5
- package/dist/protection.js +93 -0
- package/dist/providers.js +3 -0
- package/dist/rebind.js +108 -11
- package/dist/release-notes.js +154 -0
- package/dist/service.js +24 -9
- package/dist/sessions.js +101 -13
- package/dist/share.js +92 -13
- package/dist/shellenv.js +131 -18
- package/dist/single-load.js +176 -0
- package/dist/tooling.js +73 -0
- package/dist/updates.js +37 -3
- package/package.json +1 -1
package/dist/updates.js
CHANGED
|
@@ -47,8 +47,10 @@ export function isNewer(latest, current) {
|
|
|
47
47
|
return compareVersions(latest, current) > 0;
|
|
48
48
|
}
|
|
49
49
|
/** Reshape a raw GitHub `releases/latest` payload into {@link ReleaseInfo}, or
|
|
50
|
-
* null for a draft/prerelease or a payload without a tag. Pure — no network.
|
|
51
|
-
|
|
50
|
+
* null for a draft/prerelease or a payload without a tag. Pure — no network.
|
|
51
|
+
* `repo` only supplies the fallback URL for a payload missing `html_url`; it
|
|
52
|
+
* defaults to this app's own repo so existing callers are unaffected. */
|
|
53
|
+
export function parseRelease(raw, repo = UPDATE_REPO) {
|
|
52
54
|
if (!raw || typeof raw !== "object")
|
|
53
55
|
return null;
|
|
54
56
|
const r = raw;
|
|
@@ -60,11 +62,43 @@ export function parseRelease(raw) {
|
|
|
60
62
|
return {
|
|
61
63
|
tag,
|
|
62
64
|
name: typeof r.name === "string" && r.name ? r.name : tag,
|
|
63
|
-
url: typeof r.html_url === "string" ? r.html_url : `https://github.com/${
|
|
65
|
+
url: typeof r.html_url === "string" ? r.html_url : `https://github.com/${repo}/releases`,
|
|
64
66
|
notes: typeof r.body === "string" ? r.body : "",
|
|
65
67
|
publishedAt: typeof r.published_at === "string" ? r.published_at : "",
|
|
66
68
|
};
|
|
67
69
|
}
|
|
70
|
+
/** Reshape a raw GitHub `/releases` array (drafts and prereleases dropped by
|
|
71
|
+
* {@link parseRelease}'s existing rule) and order it newest version first, so
|
|
72
|
+
* the ordering is the version math rather than GitHub's creation order. Pure. */
|
|
73
|
+
export function parseReleases(raw, repo = UPDATE_REPO) {
|
|
74
|
+
if (!Array.isArray(raw))
|
|
75
|
+
return [];
|
|
76
|
+
return raw
|
|
77
|
+
.map((r) => parseRelease(r, repo))
|
|
78
|
+
.filter((r) => r !== null)
|
|
79
|
+
.sort((a, b) => compareVersions(b.tag, a.tag));
|
|
80
|
+
}
|
|
81
|
+
/** The releases strictly newer than `current`, newest first — i.e. everything
|
|
82
|
+
* the user has not seen yet, which is what "what changed" actually means for
|
|
83
|
+
* someone several versions behind. Pure. */
|
|
84
|
+
export function releasesNewerThan(releases, current) {
|
|
85
|
+
return releases.filter((r) => isNewer(r.tag, current)).sort((a, b) => compareVersions(b.tag, a.tag));
|
|
86
|
+
}
|
|
87
|
+
/** Recent releases for a repo, newest first. `[]` when the repo has none (404)
|
|
88
|
+
* — a normal empty state. Throws on any other network/HTTP failure so the
|
|
89
|
+
* caller can fall back to {@link fetchLatestRelease} rather than silently
|
|
90
|
+
* reporting "nothing new". One request; the unauthenticated endpoint is
|
|
91
|
+
* rate-limited (60/h per IP), ample for an hourly check. */
|
|
92
|
+
export async function fetchReleases(repo = UPDATE_REPO, perPage = 20) {
|
|
93
|
+
const res = await fetch(`https://api.github.com/repos/${repo}/releases?per_page=${perPage}`, {
|
|
94
|
+
headers: { Accept: "application/vnd.github+json", "User-Agent": `${PACKAGE_NAME} cli-updater` },
|
|
95
|
+
});
|
|
96
|
+
if (res.status === 404)
|
|
97
|
+
return [];
|
|
98
|
+
if (!res.ok)
|
|
99
|
+
throw new Error(`GitHub API returned ${res.status}`);
|
|
100
|
+
return parseReleases(await res.json(), repo);
|
|
101
|
+
}
|
|
68
102
|
/** The running CLI's version, from the package's own package.json (one level up
|
|
69
103
|
* from the compiled dist/). "0.0.0" if unreadable so callers never crash. */
|
|
70
104
|
export function currentVersion() {
|
package/package.json
CHANGED