dsh-supermesh 0.0.2 → 0.0.3
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.
|
@@ -793,6 +793,12 @@ var Project = class extends Model {
|
|
|
793
793
|
if (enabled) query = query.where("remoteUrl", "is not", null).where("remoteUrl", "!=", "");
|
|
794
794
|
return query.returningAll().executeTakeFirst();
|
|
795
795
|
}
|
|
796
|
+
async setRemoteUrl(id, remoteUrl, updatedAt) {
|
|
797
|
+
await this.db.updateTable("project").set({
|
|
798
|
+
remoteUrl,
|
|
799
|
+
updatedAt
|
|
800
|
+
}).where("id", "=", id).execute();
|
|
801
|
+
}
|
|
796
802
|
async disableUnavailable(workspaceIds, updatedAt) {
|
|
797
803
|
let query = this.db.updateTable("project").set({
|
|
798
804
|
enabled: 0,
|
|
@@ -854,6 +860,19 @@ var SourceState = class {
|
|
|
854
860
|
async remove(channelId, name) {
|
|
855
861
|
await this.db.deleteFrom("source_state").where("channelId", "=", channelId).where("name", "=", name).execute();
|
|
856
862
|
}
|
|
863
|
+
/**
|
|
864
|
+
* 仓库改名后把旧作用域的游标整体搬到新作用域。
|
|
865
|
+
* 不搬的话采集会从「此刻」重新开始,改名瞬间未采集的增量就永久丢了。
|
|
866
|
+
*/
|
|
867
|
+
async renameScope(channelId, from, to, updatedAt) {
|
|
868
|
+
for (const row of await this.listByChannel(channelId)) {
|
|
869
|
+
if (!row.name.startsWith(`${from}:`)) continue;
|
|
870
|
+
const name = `${to}:${row.name.slice(from.length + 1)}`;
|
|
871
|
+
if (await this.find(channelId, name)) continue;
|
|
872
|
+
await this.set(channelId, name, row.value, updatedAt);
|
|
873
|
+
await this.remove(channelId, row.name);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
857
876
|
};
|
|
858
877
|
// src/database/models/supervisor.ts
|
|
859
878
|
var Supervisor = class extends Model {
|
|
@@ -2645,14 +2664,14 @@ const devops = defineService({
|
|
|
2645
2664
|
},
|
|
2646
2665
|
save(kind, patch) {
|
|
2647
2666
|
return channel.serialize(() => save(kind, patch)).then(async (view) => {
|
|
2648
|
-
const { shell } = await import("./shell-
|
|
2667
|
+
const { shell } = await import("./shell-Bj-vzt4e.js");
|
|
2649
2668
|
await shell.refresh();
|
|
2650
2669
|
return view;
|
|
2651
2670
|
});
|
|
2652
2671
|
},
|
|
2653
2672
|
removeCredentials(kind) {
|
|
2654
2673
|
return channel.serialize(() => removeCredentials(kind)).then(async (view) => {
|
|
2655
|
-
const { shell } = await import("./shell-
|
|
2674
|
+
const { shell } = await import("./shell-Bj-vzt4e.js");
|
|
2656
2675
|
await shell.refresh();
|
|
2657
2676
|
return view;
|
|
2658
2677
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as project, c as shell, d as singlet, f as setting, g as db, h as channelProxyEnvironment, i as archive, l as inbox, m as DSH_PLUGIN_HOME, n as server, o as worktree, p as defineService, r as worker$1, s as devops, t as channel, u as session } from "./channel-
|
|
1
|
+
import { a as project, c as shell, d as singlet, f as setting, g as db, h as channelProxyEnvironment, i as archive, l as inbox, m as DSH_PLUGIN_HOME, n as server, o as worktree, p as defineService, r as worker$1, s as devops, t as channel, u as session } from "./channel-eDqcOvFj.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
@@ -483,6 +483,15 @@ const resource$1 = defineService({
|
|
|
483
483
|
return null;
|
|
484
484
|
}
|
|
485
485
|
},
|
|
486
|
+
/**
|
|
487
|
+
* 仓库改名或转移后,GitHub 对旧全名仍返回 200,只是 full_name 变成新名。
|
|
488
|
+
* 返回新全名,未改名时返回 null;调用方必须跟随,否则采集会在 probe 阶段永久失败。
|
|
489
|
+
*/
|
|
490
|
+
renamed(configured, fullName) {
|
|
491
|
+
const canonical = resource$1.of(`https://github.com/${fullName}`);
|
|
492
|
+
if (!canonical) throw new GhError("invalid_response");
|
|
493
|
+
return canonical === configured ? null : canonical;
|
|
494
|
+
},
|
|
486
495
|
parse(value) {
|
|
487
496
|
const short = /^github:([^/:]+\/[^/:]+):(issue|pull):([1-9]\d*)$/.exec(value);
|
|
488
497
|
if (short) return {
|
|
@@ -864,6 +873,7 @@ const courier = defineService({
|
|
|
864
873
|
return singlet.immediate(`${port.channel}:exclusive:collect:${projectId}`, async () => {
|
|
865
874
|
const errors = [];
|
|
866
875
|
let scope;
|
|
876
|
+
let project;
|
|
867
877
|
const context = {
|
|
868
878
|
channel: port.channel,
|
|
869
879
|
projectId,
|
|
@@ -888,9 +898,9 @@ const courier = defineService({
|
|
|
888
898
|
}
|
|
889
899
|
};
|
|
890
900
|
try {
|
|
891
|
-
|
|
901
|
+
project = await port.project(projectId);
|
|
892
902
|
const environment = await port.probe(projectId, signal);
|
|
893
|
-
const resolved = await port.scope(project);
|
|
903
|
+
const resolved = await port.scope(await port.project(projectId));
|
|
894
904
|
if (!resolved) throw new ChannelError("unknown_repository");
|
|
895
905
|
scope = resolved;
|
|
896
906
|
const baseline = await courier.state(port.channel, scope, "baseline") ?? now();
|
|
@@ -903,7 +913,8 @@ const courier = defineService({
|
|
|
903
913
|
if (signal?.aborted) throw error;
|
|
904
914
|
errors.push(courier.failure(error, port.detail));
|
|
905
915
|
}
|
|
906
|
-
|
|
916
|
+
const status = scope ?? (project ? await port.scope(project).catch(() => null) : null);
|
|
917
|
+
if (port.status && status) await courier.record(port.channel, status, "collection_status", {
|
|
907
918
|
ok: !errors.length,
|
|
908
919
|
reasons: [...new Set(errors)],
|
|
909
920
|
collectedAt: now()
|
|
@@ -1033,7 +1044,8 @@ const binding$1 = defineService({ of(channel) {
|
|
|
1033
1044
|
project: (projectId) => channel.project(projectId),
|
|
1034
1045
|
probe: (projectId, signal) => channel.probe(projectId, signal),
|
|
1035
1046
|
collect: (context, signal) => channel.collectProject(context, signal),
|
|
1036
|
-
collectBranch: (projectId, branch, signal) => ci$1.branch(channel, projectId, branch, signal)
|
|
1047
|
+
collectBranch: (projectId, branch, signal) => ci$1.branch(channel, projectId, branch, signal),
|
|
1048
|
+
onFailure: (project, reason) => console.error(`[github:collect] ${project.name} ${project.remoteUrl} -> ${reason}`)
|
|
1037
1049
|
},
|
|
1038
1050
|
ingestor: {
|
|
1039
1051
|
channel: "github",
|
|
@@ -1276,16 +1288,24 @@ var GitHubChannel = class {
|
|
|
1276
1288
|
if (!bots.some((bot) => bot.name.toLowerCase() === login.toLowerCase())) throw new GhError("account_mismatch");
|
|
1277
1289
|
const repository = resource$1.of(project.remoteUrl);
|
|
1278
1290
|
const remote = record(await this.request(`repos/${repository}`, signal));
|
|
1279
|
-
|
|
1291
|
+
const canonical = resource$1.renamed(repository, text(remote.full_name)) ?? repository;
|
|
1292
|
+
if (canonical !== repository) {
|
|
1293
|
+
await db.project.setRemoteUrl(project.id, `https://github.com/${canonical}`, now());
|
|
1294
|
+
await db.sourceState.renameScope("github", repository, canonical, now());
|
|
1295
|
+
await courier.record("github", canonical, "repository_renamed", {
|
|
1296
|
+
from: repository,
|
|
1297
|
+
to: canonical
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1280
1300
|
const result = {
|
|
1281
1301
|
providerId,
|
|
1282
1302
|
login,
|
|
1283
1303
|
repositoryId: identity(remote.id),
|
|
1284
1304
|
defaultBranch: typeof remote.default_branch === "string" ? remote.default_branch : null
|
|
1285
1305
|
};
|
|
1286
|
-
const previous = await courier.state("github",
|
|
1306
|
+
const previous = await courier.state("github", canonical, "verified_environment");
|
|
1287
1307
|
if (previous && (previous.providerId !== providerId || previous.repositoryId !== result.repositoryId)) throw new GhError("environment_identity_changed");
|
|
1288
|
-
await courier.record("github",
|
|
1308
|
+
await courier.record("github", canonical, "verified_environment", result);
|
|
1289
1309
|
return result;
|
|
1290
1310
|
}
|
|
1291
1311
|
async pages(path, signal) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { c as shell } from "./channel-eDqcOvFj.js";
|
package/package.json
CHANGED
package/dist/shell-6EeRyaxQ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { c as shell } from "./channel-C_93wtiQ.js";
|