@aspruyt/xfg 7.1.0 → 7.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/dist/cli/secrets-command.d.ts +3 -1
- package/dist/cli/secrets-command.js +66 -15
- package/dist/cli/settings-report-builder.d.ts +6 -5
- package/dist/cli/settings-report-builder.js +11 -0
- package/dist/cli/sync-command.js +2 -7
- package/dist/cli/unified-summary.js +21 -97
- package/dist/output/index.d.ts +2 -1
- package/dist/output/index.js +2 -1
- package/dist/output/lifecycle-report.d.ts +0 -3
- package/dist/output/lifecycle-report.js +1 -11
- package/dist/output/settings-report.d.ts +9 -13
- package/dist/output/settings-report.js +41 -72
- package/dist/output/sync-report.js +2 -11
- package/dist/settings/index.d.ts +1 -1
- package/dist/settings/index.js +0 -6
- package/dist/settings/secrets/formatter.d.ts +11 -0
- package/dist/settings/secrets/formatter.js +36 -0
- package/dist/settings/secrets/index.d.ts +1 -0
- package/dist/settings/secrets/index.js +1 -0
- package/dist/settings/secrets/processor.d.ts +5 -1
- package/dist/settings/secrets/processor.js +45 -18
- package/dist/shared/count-format.d.ts +10 -0
- package/dist/shared/count-format.js +17 -0
- package/dist/shared/gh-token-utils.d.ts +18 -6
- package/dist/shared/gh-token-utils.js +23 -1
- package/dist/sync/auth-options-builder.js +2 -2
- package/dist/vcs/commit-strategy-selector.d.ts +1 -0
- package/dist/vcs/commit-strategy-selector.js +5 -0
- package/dist/vcs/github-app-token-manager.js +32 -20
- package/dist/vcs/index.d.ts +1 -1
- package/dist/vcs/index.js +1 -1
- package/package.json +3 -1
|
@@ -55,30 +55,35 @@ export class GitHubAppTokenManager {
|
|
|
55
55
|
* Stores installations in an internal map for later lookup.
|
|
56
56
|
*/
|
|
57
57
|
async discoverInstallations(apiHost) {
|
|
58
|
-
const url = `https://${apiHost}/app/installations`;
|
|
59
58
|
const jwt = this.generateJWT();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
let url = `https://${apiHost}/app/installations?per_page=100`;
|
|
60
|
+
while (url) {
|
|
61
|
+
const pageUrl = url;
|
|
62
|
+
const response = await withRetry(async () => {
|
|
63
|
+
const res = await fetch(pageUrl, {
|
|
64
|
+
method: "GET",
|
|
65
|
+
headers: {
|
|
66
|
+
Authorization: `Bearer ${jwt}`,
|
|
67
|
+
Accept: "application/vnd.github+json",
|
|
68
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
await assertOkResponse(res, "GitHub App installations");
|
|
72
|
+
return res;
|
|
68
73
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const installations = (await response.json());
|
|
75
|
+
for (const installation of installations) {
|
|
76
|
+
const login = installation.account?.login;
|
|
77
|
+
if (!login)
|
|
78
|
+
continue;
|
|
79
|
+
this.installations.set(installationKey(apiHost, login), installation.id);
|
|
80
|
+
}
|
|
81
|
+
url = nextPageUrl(response.headers.get("link"));
|
|
76
82
|
}
|
|
77
83
|
this.discoveredHosts.add(apiHost);
|
|
78
84
|
}
|
|
79
85
|
getInstallationId(apiHost, owner) {
|
|
80
|
-
|
|
81
|
-
return this.installations.get(key);
|
|
86
|
+
return this.installations.get(installationKey(apiHost, owner));
|
|
82
87
|
}
|
|
83
88
|
/**
|
|
84
89
|
* Gets an installation access token for the given owner.
|
|
@@ -90,7 +95,7 @@ export class GitHubAppTokenManager {
|
|
|
90
95
|
if (installationId === undefined) {
|
|
91
96
|
return null;
|
|
92
97
|
}
|
|
93
|
-
const cacheKey =
|
|
98
|
+
const cacheKey = installationKey(apiHost, owner);
|
|
94
99
|
// Check cache
|
|
95
100
|
const cached = this.tokenCache.get(cacheKey);
|
|
96
101
|
if (cached && cached.expiresAt > Date.now()) {
|
|
@@ -136,13 +141,20 @@ export class GitHubAppTokenManager {
|
|
|
136
141
|
* FOR TESTING ONLY: Manually expire a cached token.
|
|
137
142
|
*/
|
|
138
143
|
_expireCacheForTesting(apiHost, owner) {
|
|
139
|
-
const cacheKey =
|
|
144
|
+
const cacheKey = installationKey(apiHost, owner);
|
|
140
145
|
const cached = this.tokenCache.get(cacheKey);
|
|
141
146
|
if (cached) {
|
|
142
147
|
cached.expiresAt = 0;
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
}
|
|
151
|
+
// GitHub logins are case-insensitive; config URLs may not match the canonical casing.
|
|
152
|
+
function installationKey(apiHost, owner) {
|
|
153
|
+
return `${apiHost}:${owner.toLowerCase()}`;
|
|
154
|
+
}
|
|
155
|
+
function nextPageUrl(linkHeader) {
|
|
156
|
+
return linkHeader?.match(/<([^>]+)>;\s*rel="next"/)?.[1];
|
|
157
|
+
}
|
|
146
158
|
/**
|
|
147
159
|
* Encodes data as base64url (no padding).
|
|
148
160
|
*/
|
package/dist/vcs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { PRMergeConfig, FileChange, FileAction, FileActionKind, IGitOps, ILocalGitOps, IPRStrategy, GitAuthOptions, PRResult, ICommitStrategy, } from "./types.js";
|
|
2
2
|
export type { GitOpsOptions } from "./git-ops.js";
|
|
3
|
-
export { createCommitStrategy, createTokenManager, } from "./commit-strategy-selector.js";
|
|
3
|
+
export { createCommitStrategy, createTokenManager, createTokenManagerFromEnv, } from "./commit-strategy-selector.js";
|
|
4
4
|
export { FileModeFixupCommitStrategy } from "./file-mode-fixup-commit-strategy.js";
|
|
5
5
|
export type { GitHubAppTokenManager } from "./github-app-token-manager.js";
|
|
6
6
|
export { GitOps } from "./git-ops.js";
|
package/dist/vcs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Commit strategies
|
|
2
|
-
export { createCommitStrategy, createTokenManager, } from "./commit-strategy-selector.js";
|
|
2
|
+
export { createCommitStrategy, createTokenManager, createTokenManagerFromEnv, } from "./commit-strategy-selector.js";
|
|
3
3
|
export { FileModeFixupCommitStrategy } from "./file-mode-fixup-commit-strategy.js";
|
|
4
4
|
// Git operations
|
|
5
5
|
export { GitOps } from "./git-ops.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aspruyt/xfg",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Manage files, settings, and repositories across GitHub, Azure DevOps, and GitLab — declaratively, from a single YAML config",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"build": "tsc",
|
|
36
36
|
"start": "node dist/cli.js",
|
|
37
37
|
"dev": "tsx src/cli.ts",
|
|
38
|
+
"docs:generate": "tsx scripts/docs/generate-docs.ts",
|
|
39
|
+
"docs:check": "tsx scripts/docs/generate-docs.ts --check",
|
|
38
40
|
"test": "node --import tsx scripts/run-tests.js",
|
|
39
41
|
"test:coverage": "c8 --check-coverage --lines 95 --reporter=text --reporter=lcov --all --src=src --exclude='test/**/*.test.ts' --exclude='scripts/**' --exclude='src/vcs/types.ts' --exclude='src/settings/rulesets/types.ts' --exclude='src/settings/repo-settings/types.ts' --exclude='src/settings/labels/types.ts' --exclude='src/**/index.ts' --exclude='test/mocks/**' --exclude='src/sync/types.ts' --exclude='src/lifecycle/types.ts' --exclude='src/cli/program.ts' --exclude='src/cli/types.ts' --exclude='src/cli.ts' --exclude='src/index.ts' npm test",
|
|
40
42
|
"test:integration:github": "npm run build && node --import tsx --test test/integration/github.test.ts",
|