@imenam/mcp-dependabot-tracker 1.0.26 → 1.0.28
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 +41 -13
- package/dist/shared/schemas/deploy.schema.d.ts +5 -1
- package/dist/shared/schemas/settings.schema.d.ts +36 -1
- package/dist/shared/schemas/settings.schema.js +22 -1
- package/dist/src/core/config.d.ts +6 -2
- package/dist/src/core/config.js +11 -9
- package/dist/src/core/deploy-servers.d.ts +2 -0
- package/dist/src/core/deploy-servers.js +10 -1
- package/dist/src/core/deployments.d.ts +22 -3
- package/dist/src/core/deployments.js +46 -4
- package/dist/src/core/github.d.ts +15 -2
- package/dist/src/core/github.js +21 -4
- package/dist/src/core/settings.d.ts +24 -1
- package/dist/src/core/settings.js +64 -8
- package/dist/src/server/app.d.ts +4 -1
- package/dist/src/server/app.js +13 -9
- package/dist/src/server/serve.js +29 -7
- package/gui/dist/assets/{index-FrRzRTkV.js → index-CAOy2g1q.js} +8 -8
- package/gui/dist/assets/{index-o3l3BAZD.css → index-CYU7-6kP.css} +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { type SaveSettingsBody, type Settings, type SettingsView } from "../../shared/schemas/settings.schema.js";
|
|
2
|
+
import type { TokenCheck } from "./github.js";
|
|
2
3
|
import { type OrganizerConnection, type OrganizerSpace } from "./organizer.js";
|
|
3
4
|
/** Vérifications faites à l'enregistrement : remplacées dans les tests. */
|
|
4
5
|
export interface SettingsChecks {
|
|
5
6
|
organizer: (connection: OrganizerConnection) => Promise<OrganizerSpace>;
|
|
6
7
|
claudeToken: (token: string) => Promise<void>;
|
|
8
|
+
/** Vérifie un token auprès de GitHub et relève son compte et son expiration. */
|
|
9
|
+
githubToken: (token: string) => Promise<TokenCheck>;
|
|
7
10
|
}
|
|
8
11
|
/** Réglages, tokens déchiffrés avec `vaultKey` ; un token que la clé ne déchiffre pas lève une erreur. */
|
|
9
12
|
export declare function readSettings(dataDir: string, vaultKey: Buffer): Settings;
|
|
@@ -14,12 +17,32 @@ export declare function readSettings(dataDir: string, vaultKey: Buffer): Setting
|
|
|
14
17
|
export declare function encryptStoredTokens(dataDir: string, vaultKey: Buffer): boolean;
|
|
15
18
|
/** Connexion à l'organizer, null tant que l'adresse ou le token manque. */
|
|
16
19
|
export declare function organizerConnection(settings: Settings): OrganizerConnection | null;
|
|
20
|
+
/** Résultat de la reprise de GITHUB_TOKEN au démarrage. */
|
|
21
|
+
export type EnvTokenAdoption = {
|
|
22
|
+
status: "none";
|
|
23
|
+
} | {
|
|
24
|
+
status: "ignored";
|
|
25
|
+
} | {
|
|
26
|
+
status: "adopted";
|
|
27
|
+
warning: string | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Reprend dans les réglages le GITHUB_TOKEN de l'environnement tant que les
|
|
31
|
+
* réglages n'ont pas de token du tracker : il y est vérifié auprès de GitHub
|
|
32
|
+
* (un refus est rendu en avertissement, le token est repris quand même) et
|
|
33
|
+
* chiffré. Avec un token déjà réglé, la variable est ignorée.
|
|
34
|
+
*/
|
|
35
|
+
export declare function adoptEnvGitHubToken(dataDir: string, vaultKey: Buffer, envToken: string | undefined, checks: SettingsChecks): Promise<EnvTokenAdoption>;
|
|
36
|
+
/** Token GitHub du tracker, null sans token enregistré. */
|
|
37
|
+
export declare function githubToken(settings: Settings): string | null;
|
|
38
|
+
/** Token GitHub transmis aux scripts de déploiement, null sans token enregistré. */
|
|
39
|
+
export declare function deployToken(settings: Settings): string | null;
|
|
17
40
|
/** Vrai quand l'organizer (connexion testée) et Claude sont configurés. */
|
|
18
41
|
export declare function analysisReady(settings: Settings): boolean;
|
|
19
42
|
export declare function settingsView(settings: Settings): SettingsView;
|
|
20
43
|
/**
|
|
21
44
|
* Enregistre les réglages de la GUI. Une connexion à l'organizer modifiée est
|
|
22
|
-
* testée, un nouveau token Claude vérifié : un échec refuse tout
|
|
45
|
+
* testée, un nouveau token Claude ou GitHub vérifié : un échec refuse tout
|
|
23
46
|
* l'enregistrement.
|
|
24
47
|
*/
|
|
25
48
|
export declare function saveSettings(dataDir: string, vaultKey: Buffer, body: SaveSettingsBody, checks: SettingsChecks): Promise<SettingsView>;
|
|
@@ -6,10 +6,10 @@ import { TrackerError } from "./errors.js";
|
|
|
6
6
|
import { organizerUrl } from "./organizer.js";
|
|
7
7
|
import { decryptSecret, encryptSecret, isEncrypted } from "./vault.js";
|
|
8
8
|
/**
|
|
9
|
-
* Réglages
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* en entier.
|
|
9
|
+
* Réglages du tracker, dans `<données>/settings.json`, lisible par le seul
|
|
10
|
+
* compte du serveur : ils portent le token GitHub du tracker, le token de
|
|
11
|
+
* déploiement, le token de l'organizer et celui de Claude, chiffrés avec
|
|
12
|
+
* VAULT_KEY dans le fichier, que la GUI ne reçoit jamais en entier.
|
|
13
13
|
*/
|
|
14
14
|
/** Durée de validité d'un token créé par `claude setup-token`. */
|
|
15
15
|
const CLAUDE_TOKEN_VALIDITY_MS = 365 * 24 * 3600_000;
|
|
@@ -36,7 +36,13 @@ function readSettingsFile(dataDir) {
|
|
|
36
36
|
/** Applique `fn` à chaque token des réglages, null laissé tel quel. */
|
|
37
37
|
function mapTokens(settings, fn) {
|
|
38
38
|
const map = (token) => (token === null ? null : fn(token));
|
|
39
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
...settings,
|
|
41
|
+
organizer: { ...settings.organizer, token: map(settings.organizer.token) },
|
|
42
|
+
claude: { ...settings.claude, token: map(settings.claude.token) },
|
|
43
|
+
github: { ...settings.github, token: map(settings.github.token) },
|
|
44
|
+
deploy: { ...settings.deploy, token: map(settings.deploy.token) },
|
|
45
|
+
};
|
|
40
46
|
}
|
|
41
47
|
/** Réglages, tokens déchiffrés avec `vaultKey` ; un token que la clé ne déchiffre pas lève une erreur. */
|
|
42
48
|
export function readSettings(dataDir, vaultKey) {
|
|
@@ -60,7 +66,7 @@ export function encryptStoredTokens(dataDir, vaultKey) {
|
|
|
60
66
|
const stored = readSettingsFile(dataDir);
|
|
61
67
|
if (stored === null)
|
|
62
68
|
return false;
|
|
63
|
-
const tokens = [stored.organizer.token, stored.claude.token].filter((token) => token !== null);
|
|
69
|
+
const tokens = [stored.organizer.token, stored.claude.token, stored.github.token, stored.deploy.token].filter((token) => token !== null);
|
|
64
70
|
if (tokens.every(isEncrypted))
|
|
65
71
|
return false;
|
|
66
72
|
writeSettingsFile(dataDir, mapTokens(stored, (token) => (isEncrypted(token) ? token : encryptSecret(token, vaultKey))));
|
|
@@ -86,6 +92,38 @@ export function organizerConnection(settings) {
|
|
|
86
92
|
const { url, token } = settings.organizer;
|
|
87
93
|
return url && token ? { url, token } : null;
|
|
88
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Reprend dans les réglages le GITHUB_TOKEN de l'environnement tant que les
|
|
97
|
+
* réglages n'ont pas de token du tracker : il y est vérifié auprès de GitHub
|
|
98
|
+
* (un refus est rendu en avertissement, le token est repris quand même) et
|
|
99
|
+
* chiffré. Avec un token déjà réglé, la variable est ignorée.
|
|
100
|
+
*/
|
|
101
|
+
export async function adoptEnvGitHubToken(dataDir, vaultKey, envToken, checks) {
|
|
102
|
+
const token = envToken?.trim();
|
|
103
|
+
if (!token)
|
|
104
|
+
return { status: "none" };
|
|
105
|
+
const current = readSettings(dataDir, vaultKey);
|
|
106
|
+
if (current.github.token !== null)
|
|
107
|
+
return { status: "ignored" };
|
|
108
|
+
let check = null;
|
|
109
|
+
let warning = null;
|
|
110
|
+
try {
|
|
111
|
+
check = await checks.githubToken(token);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
warning = err?.message ?? String(err);
|
|
115
|
+
}
|
|
116
|
+
writeSettings(dataDir, vaultKey, { ...current, github: { token, savedAt: new Date().toISOString(), login: check?.login ?? null, expiresAt: check?.expiresAt ?? null } });
|
|
117
|
+
return { status: "adopted", warning };
|
|
118
|
+
}
|
|
119
|
+
/** Token GitHub du tracker, null sans token enregistré. */
|
|
120
|
+
export function githubToken(settings) {
|
|
121
|
+
return settings.github.token;
|
|
122
|
+
}
|
|
123
|
+
/** Token GitHub transmis aux scripts de déploiement, null sans token enregistré. */
|
|
124
|
+
export function deployToken(settings) {
|
|
125
|
+
return settings.deploy.token;
|
|
126
|
+
}
|
|
89
127
|
/** Vrai quand l'organizer (connexion testée) et Claude sont configurés. */
|
|
90
128
|
export function analysisReady(settings) {
|
|
91
129
|
return organizerConnection(settings) !== null && settings.organizer.space !== null && settings.claude.token !== null;
|
|
@@ -93,6 +131,14 @@ export function analysisReady(settings) {
|
|
|
93
131
|
function tokenHint(token) {
|
|
94
132
|
return token === null ? null : token.slice(-4);
|
|
95
133
|
}
|
|
134
|
+
function tokenView({ token, savedAt, login, expiresAt }) {
|
|
135
|
+
return { tokenHint: tokenHint(token), savedAt, login, expiresAt };
|
|
136
|
+
}
|
|
137
|
+
/** Token GitHub vérifié, avec son compte et son expiration, prêt à enregistrer. */
|
|
138
|
+
async function checkedGitHubToken(token, checks) {
|
|
139
|
+
const { login, expiresAt } = await checks.githubToken(token);
|
|
140
|
+
return { token, savedAt: new Date().toISOString(), login, expiresAt };
|
|
141
|
+
}
|
|
96
142
|
export function settingsView(settings) {
|
|
97
143
|
const { savedAt } = settings.claude;
|
|
98
144
|
return {
|
|
@@ -104,6 +150,8 @@ export function settingsView(settings) {
|
|
|
104
150
|
},
|
|
105
151
|
analysis: settings.analysis,
|
|
106
152
|
ready: analysisReady(settings),
|
|
153
|
+
github: tokenView(settings.github),
|
|
154
|
+
deploy: tokenView(settings.deploy),
|
|
107
155
|
};
|
|
108
156
|
}
|
|
109
157
|
/** Espace et propriétaire relevés par un test de la connexion, ou rien sans connexion. */
|
|
@@ -115,7 +163,7 @@ async function checkedOrganizer(organizer, checks) {
|
|
|
115
163
|
}
|
|
116
164
|
/**
|
|
117
165
|
* Enregistre les réglages de la GUI. Une connexion à l'organizer modifiée est
|
|
118
|
-
* testée, un nouveau token Claude vérifié : un échec refuse tout
|
|
166
|
+
* testée, un nouveau token Claude ou GitHub vérifié : un échec refuse tout
|
|
119
167
|
* l'enregistrement.
|
|
120
168
|
*/
|
|
121
169
|
export async function saveSettings(dataDir, vaultKey, body, checks) {
|
|
@@ -129,7 +177,15 @@ export async function saveSettings(dataDir, vaultKey, body, checks) {
|
|
|
129
177
|
await checks.claudeToken(body.claudeToken);
|
|
130
178
|
claude = { token: body.claudeToken, savedAt: new Date().toISOString() };
|
|
131
179
|
}
|
|
132
|
-
const
|
|
180
|
+
const github = body.githubToken === undefined ? current.github : await checkedGitHubToken(body.githubToken, checks);
|
|
181
|
+
let deploy = current.deploy;
|
|
182
|
+
if (body.deployToken === null) {
|
|
183
|
+
deploy = DEFAULT_SETTINGS.deploy;
|
|
184
|
+
}
|
|
185
|
+
else if (body.deployToken !== undefined) {
|
|
186
|
+
deploy = await checkedGitHubToken(body.deployToken, checks);
|
|
187
|
+
}
|
|
188
|
+
const next = { organizer, claude, analysis: body.analysis, github, deploy };
|
|
133
189
|
writeSettings(dataDir, vaultKey, next);
|
|
134
190
|
return settingsView(next);
|
|
135
191
|
}
|
package/dist/src/server/app.d.ts
CHANGED
|
@@ -10,7 +10,10 @@ import type { Store } from "../core/store.js";
|
|
|
10
10
|
export interface ServerContext {
|
|
11
11
|
store: Store;
|
|
12
12
|
dataDir: string;
|
|
13
|
-
|
|
13
|
+
/** Configuration GitHub, avec le token du tracker relu dans les réglages ; lève une erreur sans token. */
|
|
14
|
+
github: () => GitHubConfig;
|
|
15
|
+
/** Adresse web du serveur GitHub, connue même sans token. */
|
|
16
|
+
githubServerUrl: string;
|
|
14
17
|
operations: OperationContext;
|
|
15
18
|
auditAll: AuditAll;
|
|
16
19
|
/** Serveurs de déploiement, scripts et déploiements des dépôts. */
|
package/dist/src/server/app.js
CHANGED
|
@@ -148,7 +148,7 @@ export function createApp(ctx) {
|
|
|
148
148
|
}
|
|
149
149
|
return { repos: active.filter((view) => view.repo.categoryId === category.id), category };
|
|
150
150
|
}));
|
|
151
|
-
app.post("/api/agent/repos/:owner/:name/sync", (c) => respond(c, async () => repoView(store, await syncRepository(store, github, store.getRepo(repoId(c)).id))));
|
|
151
|
+
app.post("/api/agent/repos/:owner/:name/sync", (c) => respond(c, async () => repoView(store, await syncRepository(store, github(), store.getRepo(repoId(c)).id))));
|
|
152
152
|
app.post("/api/agent/repos/:owner/:name/audits", (c) => withBody(c, ScopeBodySchema, (body) => agentOperation(startAudit(operations, repoId(c), "agent", body.scope))));
|
|
153
153
|
app.post("/api/agent/repos/:owner/:name/fixes", (c) => withBody(c, AgentFixBodySchema, (body) => agentOperation(startFix(operations, repoId(c), "agent", { scope: body.scope, claude: body.claude }))));
|
|
154
154
|
app.get("/api/agent/operations/:id", (c) => respond(c, () => agentOperation(store.getOperation(c.req.param("id")))));
|
|
@@ -165,18 +165,18 @@ export function createApp(ctx) {
|
|
|
165
165
|
return c.json({ error: "Sign in to use the interface." }, 401);
|
|
166
166
|
await next();
|
|
167
167
|
});
|
|
168
|
-
app.get("/api/config", (c) => respond(c, () => ({ version: APP_VERSION, dataDir, githubServerUrl:
|
|
168
|
+
app.get("/api/config", (c) => respond(c, () => ({ version: APP_VERSION, dataDir, githubServerUrl: ctx.githubServerUrl })));
|
|
169
169
|
app.get("/api/repos", (c) => respond(c, reposResponse));
|
|
170
|
-
app.post("/api/repos", (c) => withBody(c, AddRepoBodySchema, async (body) => repoView(store, await addRepository(store, github, body.repository, body.categoryId))));
|
|
170
|
+
app.post("/api/repos", (c) => withBody(c, AddRepoBodySchema, async (body) => repoView(store, await addRepository(store, github(), body.repository, body.categoryId))));
|
|
171
171
|
app.post("/api/sync", (c) => respond(c, async () => {
|
|
172
|
-
await syncAllRepositories(store, github);
|
|
172
|
+
await syncAllRepositories(store, github());
|
|
173
173
|
return reposResponse();
|
|
174
174
|
}));
|
|
175
175
|
app.get("/api/audit-all", (c) => respond(c, () => ({ auditAll: auditAll.status() })));
|
|
176
176
|
app.post("/api/audit-all", (c) => withBody(c, AuditAllBodySchema, ({ scope, target }) => ({
|
|
177
177
|
auditAll: auditAll.start(auditTargetRepos(store, target).map((repo) => repo.id), scope, target),
|
|
178
178
|
})));
|
|
179
|
-
app.get("/api/github/repos", (c) => respond(c, async () => ({ repositories: await listAddableRepositories(store, github) })));
|
|
179
|
+
app.get("/api/github/repos", (c) => respond(c, async () => ({ repositories: await listAddableRepositories(store, github()) })));
|
|
180
180
|
app.get("/api/repos/:owner/:name", (c) => respond(c, () => repoView(store, store.getRepo(repoId(c)))));
|
|
181
181
|
app.delete("/api/repos/:owner/:name", (c) => respond(c, () => {
|
|
182
182
|
const repo = store.getRepo(repoId(c));
|
|
@@ -187,7 +187,7 @@ export function createApp(ctx) {
|
|
|
187
187
|
return { removed: true };
|
|
188
188
|
}));
|
|
189
189
|
app.put("/api/repos/:owner/:name/deprecated", (c) => respond(c, () => repoView(store, deprecateRepository(store, repoId(c)))));
|
|
190
|
-
app.delete("/api/repos/:owner/:name/deprecated", (c) => respond(c, async () => repoView(store, await restoreRepository(store, github, repoId(c)))));
|
|
190
|
+
app.delete("/api/repos/:owner/:name/deprecated", (c) => respond(c, async () => repoView(store, await restoreRepository(store, github(), repoId(c)))));
|
|
191
191
|
app.put("/api/repos/:owner/:name/queued", (c) => respond(c, () => repoView(store, queueRepository(store, repoId(c)))));
|
|
192
192
|
app.delete("/api/repos/:owner/:name/queued", (c) => respond(c, () => repoView(store, unqueueRepository(store, repoId(c)))));
|
|
193
193
|
app.put("/api/repos/:owner/:name/deploy-pending", (c) => respond(c, () => repoView(store, markDeployPending(store, repoId(c)))));
|
|
@@ -202,8 +202,8 @@ export function createApp(ctx) {
|
|
|
202
202
|
startMergeAudit(operations, repo.id, merged);
|
|
203
203
|
return repoView(store, repo);
|
|
204
204
|
}));
|
|
205
|
-
app.get("/api/repos/:owner/:name/branches", (c) => respond(c, async () => ({ branches: await listRepoBranches(store, github, repoId(c)) })));
|
|
206
|
-
app.put("/api/repos/:owner/:name/branch", (c) => withBody(c, SetBranchBodySchema, async (body) => repoView(store, await setBranch(store, github, repoId(c), body.branch))));
|
|
205
|
+
app.get("/api/repos/:owner/:name/branches", (c) => respond(c, async () => ({ branches: await listRepoBranches(store, github(), repoId(c)) })));
|
|
206
|
+
app.put("/api/repos/:owner/:name/branch", (c) => withBody(c, SetBranchBodySchema, async (body) => repoView(store, await setBranch(store, github(), repoId(c), body.branch))));
|
|
207
207
|
app.put("/api/repos/:owner/:name/category", (c) => withBody(c, SetCategoryBodySchema, (body) => repoView(store, setCategory(store, repoId(c), body.categoryId))));
|
|
208
208
|
app.put("/api/repos/:owner/:name/alerts/:number/handled", (c) => respond(c, () => repoView(store, markAlertHandled(store, repoId(c), alertNumber(c)))));
|
|
209
209
|
app.delete("/api/repos/:owner/:name/alerts/:number/handled", (c) => respond(c, () => repoView(store, unmarkAlertHandled(store, repoId(c), alertNumber(c)))));
|
|
@@ -225,9 +225,13 @@ export function createApp(ctx) {
|
|
|
225
225
|
}));
|
|
226
226
|
app.get("/api/operations/:id", (c) => respond(c, () => ({ operation: store.getOperation(c.req.param("id")) })));
|
|
227
227
|
app.post("/api/operations/:id/cancel", (c) => respond(c, () => ({ operation: cancelOperation(operations, c.req.param("id")) })));
|
|
228
|
-
app.get("/api/deploy-servers", (c) => respond(c, () => ({ servers: deployer.
|
|
228
|
+
app.get("/api/deploy-servers", (c) => respond(c, () => ({ servers: deployer.listServers() })));
|
|
229
229
|
app.post("/api/deploy-servers", (c) => withBody(c, DeployServerBodySchema, (body) => deployer.servers.view(deployer.servers.create(body))));
|
|
230
230
|
app.put("/api/deploy-servers/:id", (c) => withBody(c, DeployServerBodySchema, (body) => deployer.servers.view(deployer.servers.update(c.req.param("id"), body))));
|
|
231
|
+
app.delete("/api/deploy-servers/:id", (c) => respond(c, () => {
|
|
232
|
+
deployer.removeServer(c.req.param("id"));
|
|
233
|
+
return { deleted: true };
|
|
234
|
+
}));
|
|
231
235
|
app.post("/api/deploy-servers/:id/test", (c) => respond(c, () => deployer.servers.test(c.req.param("id"))));
|
|
232
236
|
/** Opération sur la clé d'un serveur, refusée pendant un déploiement qui l'utilise. */
|
|
233
237
|
const withIdleServer = (c, fn) => {
|
package/dist/src/server/serve.js
CHANGED
|
@@ -7,7 +7,8 @@ import { createLogger, setupLogging } from "@imenam/mcp-gui-interface";
|
|
|
7
7
|
import { AuditAll } from "../core/audit-all.js";
|
|
8
8
|
import { createAuth, listUsers, migrateAuth } from "../core/auth.js";
|
|
9
9
|
import { checkClaudeToken, packagedClaudeCommand } from "../core/claude.js";
|
|
10
|
-
import {
|
|
10
|
+
import { gitHubConfig, readGitHubServers } from "../core/config.js";
|
|
11
|
+
import { GitHubClient } from "../core/github.js";
|
|
11
12
|
import { resolveCloneDir, resolveDataDir } from "../core/data-dir.js";
|
|
12
13
|
import { DeployServerStore } from "../core/deploy-servers.js";
|
|
13
14
|
import { Deployer, DeploymentStore } from "../core/deployments.js";
|
|
@@ -16,7 +17,7 @@ import { runDefaultBranchAudit } from "../core/operations.js";
|
|
|
16
17
|
import { OrganizerClient } from "../core/organizer.js";
|
|
17
18
|
import { refreshReportTask } from "../core/repair.js";
|
|
18
19
|
import { SYNC_INTERVAL_MS, staleRepos, syncRepository } from "../core/repos.js";
|
|
19
|
-
import { encryptStoredTokens, readSettings } from "../core/settings.js";
|
|
20
|
+
import { adoptEnvGitHubToken, deployToken, encryptStoredTokens, githubToken, readSettings } from "../core/settings.js";
|
|
20
21
|
import { readServerConfig } from "../core/server-config.js";
|
|
21
22
|
import { Store } from "../core/store.js";
|
|
22
23
|
import { parseVaultKey } from "../core/vault.js";
|
|
@@ -75,12 +76,10 @@ export async function serve() {
|
|
|
75
76
|
logger.error(`Unhandled rejection: ${reason?.stack ?? reason}`);
|
|
76
77
|
process.exit(1);
|
|
77
78
|
});
|
|
78
|
-
let github;
|
|
79
79
|
let cloneDir;
|
|
80
80
|
let config;
|
|
81
81
|
let vaultKey;
|
|
82
82
|
try {
|
|
83
|
-
github = readGitHubConfig();
|
|
84
83
|
cloneDir = resolveCloneDir(dataDir);
|
|
85
84
|
config = readServerConfig();
|
|
86
85
|
vaultKey = parseVaultKey(process.env.VAULT_KEY);
|
|
@@ -110,15 +109,27 @@ export async function serve() {
|
|
|
110
109
|
logger.error(err.message);
|
|
111
110
|
process.exit(1);
|
|
112
111
|
}
|
|
113
|
-
const
|
|
112
|
+
const githubServers = readGitHubServers();
|
|
113
|
+
/** Configuration GitHub avec le token du tracker, relu dans les réglages à chaque usage. */
|
|
114
|
+
const github = () => gitHubConfig(githubServers, githubToken(readSettings(dataDir, vaultKey)));
|
|
114
115
|
const claude = { command: packagedClaudeCommand(), home: path.join(dataDir, "claude") };
|
|
115
116
|
const settingsChecks = {
|
|
116
117
|
organizer: (connection) => new OrganizerClient(connection).space(),
|
|
117
118
|
claudeToken: (token) => checkClaudeToken(claude, token),
|
|
119
|
+
githubToken: (token) => new GitHubClient({ ...githubServers, token }, "the token").checkToken(),
|
|
118
120
|
};
|
|
121
|
+
const adoption = await adoptEnvGitHubToken(dataDir, vaultKey, process.env.GITHUB_TOKEN, settingsChecks);
|
|
122
|
+
if (adoption.status === "adopted") {
|
|
123
|
+
logger.info("GITHUB_TOKEN is now the GitHub token of the tracker in the settings, encrypted with VAULT_KEY: it can be removed from the environment.");
|
|
124
|
+
if (adoption.warning)
|
|
125
|
+
logger.warn(`GITHUB_TOKEN was taken over, but GitHub did not accept it: ${adoption.warning}`);
|
|
126
|
+
}
|
|
127
|
+
if (adoption.status === "ignored")
|
|
128
|
+
logger.warn("GITHUB_TOKEN is ignored: the GitHub token of the tracker is the one of the settings. Remove the variable from the environment.");
|
|
129
|
+
const deployer = new Deployer(store, deployServers, new DeploymentStore(dataDir), github, (message) => logger.error(message), () => deployToken(readSettings(dataDir, vaultKey)));
|
|
119
130
|
const operations = {
|
|
120
131
|
store,
|
|
121
|
-
githubConfig:
|
|
132
|
+
githubConfig: github,
|
|
122
133
|
cloneDir: () => cloneDir,
|
|
123
134
|
logError: (message) => logger.error(message),
|
|
124
135
|
settings: () => readSettings(dataDir, vaultKey),
|
|
@@ -129,6 +140,7 @@ export async function serve() {
|
|
|
129
140
|
store,
|
|
130
141
|
dataDir,
|
|
131
142
|
github,
|
|
143
|
+
githubServerUrl: githubServers.serverUrl,
|
|
132
144
|
operations,
|
|
133
145
|
auditAll,
|
|
134
146
|
deployer,
|
|
@@ -159,15 +171,25 @@ export async function serve() {
|
|
|
159
171
|
for (const user of users.filter((candidate) => !candidate.twoFactor)) {
|
|
160
172
|
logger.warn(`The account ${user.email} signs in with its password alone: enable two-factor authentication with "mcp-dependabot-tracker user totp ${user.email}".`);
|
|
161
173
|
}
|
|
174
|
+
if (githubToken(readSettings(dataDir, vaultKey)) === null) {
|
|
175
|
+
logger.warn("The GitHub token of the tracker is not set: enter it in the settings of the interface (Réglages › GitHub). Until then, nothing is synced, audited or fixed.");
|
|
176
|
+
}
|
|
162
177
|
let syncing = false;
|
|
163
178
|
/** Relit les alertes des dépôts lus il y a plus de 10 minutes, et le statut de la tâche organizer du dernier rapport de Claude. */
|
|
164
179
|
const syncStaleRepos = async () => {
|
|
165
180
|
if (syncing)
|
|
166
181
|
return;
|
|
182
|
+
let config;
|
|
183
|
+
try {
|
|
184
|
+
config = github();
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
167
189
|
syncing = true;
|
|
168
190
|
try {
|
|
169
191
|
for (const repo of staleRepos(store, SYNC_INTERVAL_MS)) {
|
|
170
|
-
const synced = await syncRepository(store,
|
|
192
|
+
const synced = await syncRepository(store, config, repo.id);
|
|
171
193
|
if (synced.syncError)
|
|
172
194
|
logger.warn(`Dependabot alerts of ${repo.id} not synced: ${synced.syncError}`);
|
|
173
195
|
await refreshReportTask(store, readSettings(dataDir, vaultKey), repo.id).catch((err) => logger.warn(`Organizer task of ${repo.id} not refreshed: ${err?.message ?? err}`));
|