@ankhorage/repository 0.4.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.
Files changed (140) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE +21 -0
  3. package/README.md +53 -0
  4. package/dist/cli/commands/connect/definitions/ConnectCommandOptions.d.ts +8 -0
  5. package/dist/cli/commands/connect/definitions/ConnectCommandOptions.d.ts.map +1 -0
  6. package/dist/cli/commands/connect/definitions/ConnectCommandOptions.js +2 -0
  7. package/dist/cli/commands/connect/definitions/ConnectCommandOptions.js.map +1 -0
  8. package/dist/cli/commands/connect/parseConnectCommandOptions.d.ts +4 -0
  9. package/dist/cli/commands/connect/parseConnectCommandOptions.d.ts.map +1 -0
  10. package/dist/cli/commands/connect/parseConnectCommandOptions.js +38 -0
  11. package/dist/cli/commands/connect/parseConnectCommandOptions.js.map +1 -0
  12. package/dist/cli/commands/connect/runConnectCommandAsync.d.ts +10 -0
  13. package/dist/cli/commands/connect/runConnectCommandAsync.d.ts.map +1 -0
  14. package/dist/cli/commands/connect/runConnectCommandAsync.js +29 -0
  15. package/dist/cli/commands/connect/runConnectCommandAsync.js.map +1 -0
  16. package/dist/cli/index.d.ts +5 -0
  17. package/dist/cli/index.d.ts.map +1 -0
  18. package/dist/cli/index.js +5 -0
  19. package/dist/cli/index.js.map +1 -0
  20. package/dist/cli/provider/createRepositoryRuntimeProvider.d.ts +25 -0
  21. package/dist/cli/provider/createRepositoryRuntimeProvider.d.ts.map +1 -0
  22. package/dist/cli/provider/createRepositoryRuntimeProvider.js +20 -0
  23. package/dist/cli/provider/createRepositoryRuntimeProvider.js.map +1 -0
  24. package/dist/cli/provider/createRepositoryRuntimeProvider.test.d.ts +2 -0
  25. package/dist/cli/provider/createRepositoryRuntimeProvider.test.d.ts.map +1 -0
  26. package/dist/cli/provider/createRepositoryRuntimeProvider.test.js +12 -0
  27. package/dist/cli/provider/createRepositoryRuntimeProvider.test.js.map +1 -0
  28. package/dist/connection/adapters/createLocalProjectSnapshotReader.d.ts +4 -0
  29. package/dist/connection/adapters/createLocalProjectSnapshotReader.d.ts.map +1 -0
  30. package/dist/connection/adapters/createLocalProjectSnapshotReader.js +123 -0
  31. package/dist/connection/adapters/createLocalProjectSnapshotReader.js.map +1 -0
  32. package/dist/connection/adapters/createLocalRepositoryManifestStore.d.ts +4 -0
  33. package/dist/connection/adapters/createLocalRepositoryManifestStore.d.ts.map +1 -0
  34. package/dist/connection/adapters/createLocalRepositoryManifestStore.js +75 -0
  35. package/dist/connection/adapters/createLocalRepositoryManifestStore.js.map +1 -0
  36. package/dist/connection/adapters/createLocalRepositoryManifestStore.test.d.ts +2 -0
  37. package/dist/connection/adapters/createLocalRepositoryManifestStore.test.d.ts.map +1 -0
  38. package/dist/connection/adapters/createLocalRepositoryManifestStore.test.js +25 -0
  39. package/dist/connection/adapters/createLocalRepositoryManifestStore.test.js.map +1 -0
  40. package/dist/connection/definitions/ProjectSnapshot.d.ts +8 -0
  41. package/dist/connection/definitions/ProjectSnapshot.d.ts.map +1 -0
  42. package/dist/connection/definitions/ProjectSnapshot.js +2 -0
  43. package/dist/connection/definitions/ProjectSnapshot.js.map +1 -0
  44. package/dist/connection/definitions/ProjectSnapshotEntry.d.ts +10 -0
  45. package/dist/connection/definitions/ProjectSnapshotEntry.d.ts.map +1 -0
  46. package/dist/connection/definitions/ProjectSnapshotEntry.js +2 -0
  47. package/dist/connection/definitions/ProjectSnapshotEntry.js.map +1 -0
  48. package/dist/connection/definitions/RepositoryConnectionOptions.d.ts +8 -0
  49. package/dist/connection/definitions/RepositoryConnectionOptions.d.ts.map +1 -0
  50. package/dist/connection/definitions/RepositoryConnectionOptions.js +2 -0
  51. package/dist/connection/definitions/RepositoryConnectionOptions.js.map +1 -0
  52. package/dist/connection/definitions/RepositoryConnectionResult.d.ts +17 -0
  53. package/dist/connection/definitions/RepositoryConnectionResult.d.ts.map +1 -0
  54. package/dist/connection/definitions/RepositoryConnectionResult.js +2 -0
  55. package/dist/connection/definitions/RepositoryConnectionResult.js.map +1 -0
  56. package/dist/connection/ports/ProjectSnapshotReader.d.ts +6 -0
  57. package/dist/connection/ports/ProjectSnapshotReader.d.ts.map +1 -0
  58. package/dist/connection/ports/ProjectSnapshotReader.js +2 -0
  59. package/dist/connection/ports/ProjectSnapshotReader.js.map +1 -0
  60. package/dist/connection/ports/RepositoryManifestStore.d.ts +6 -0
  61. package/dist/connection/ports/RepositoryManifestStore.d.ts.map +1 -0
  62. package/dist/connection/ports/RepositoryManifestStore.js +2 -0
  63. package/dist/connection/ports/RepositoryManifestStore.js.map +1 -0
  64. package/dist/connection/services/connectRepositoryAsync.d.ts +5 -0
  65. package/dist/connection/services/connectRepositoryAsync.d.ts.map +1 -0
  66. package/dist/connection/services/connectRepositoryAsync.js +55 -0
  67. package/dist/connection/services/connectRepositoryAsync.js.map +1 -0
  68. package/dist/connection/services/connectRepositoryAsync.test.d.ts +2 -0
  69. package/dist/connection/services/connectRepositoryAsync.test.d.ts.map +1 -0
  70. package/dist/connection/services/connectRepositoryAsync.test.js +27 -0
  71. package/dist/connection/services/connectRepositoryAsync.test.js.map +1 -0
  72. package/dist/connection/utils/getProjectSnapshotPaths.d.ts +5 -0
  73. package/dist/connection/utils/getProjectSnapshotPaths.d.ts.map +1 -0
  74. package/dist/connection/utils/getProjectSnapshotPaths.js +5 -0
  75. package/dist/connection/utils/getProjectSnapshotPaths.js.map +1 -0
  76. package/dist/github/index.d.ts +5 -0
  77. package/dist/github/index.d.ts.map +1 -0
  78. package/dist/github/index.js +2 -0
  79. package/dist/github/index.js.map +1 -0
  80. package/dist/index.d.ts +4 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +2 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/index.test.d.ts +2 -0
  85. package/dist/index.test.d.ts.map +1 -0
  86. package/dist/index.test.js +35 -0
  87. package/dist/index.test.js.map +1 -0
  88. package/dist/metadata/index.d.ts +12 -0
  89. package/dist/metadata/index.d.ts.map +1 -0
  90. package/dist/metadata/index.js +12 -0
  91. package/dist/metadata/index.js.map +1 -0
  92. package/dist/metadata/repositoryPackageMetadata.d.ts +13 -0
  93. package/dist/metadata/repositoryPackageMetadata.d.ts.map +1 -0
  94. package/dist/metadata/repositoryPackageMetadata.js +14 -0
  95. package/dist/metadata/repositoryPackageMetadata.js.map +1 -0
  96. package/dist/providers/github/adapters/createGhCliRepositoryGateway.d.ts +13 -0
  97. package/dist/providers/github/adapters/createGhCliRepositoryGateway.d.ts.map +1 -0
  98. package/dist/providers/github/adapters/createGhCliRepositoryGateway.js +228 -0
  99. package/dist/providers/github/adapters/createGhCliRepositoryGateway.js.map +1 -0
  100. package/dist/providers/github/adapters/ghCliJson.d.ts +22 -0
  101. package/dist/providers/github/adapters/ghCliJson.d.ts.map +1 -0
  102. package/dist/providers/github/adapters/ghCliJson.js +44 -0
  103. package/dist/providers/github/adapters/ghCliJson.js.map +1 -0
  104. package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.d.ts +16 -0
  105. package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.d.ts.map +1 -0
  106. package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.js +2 -0
  107. package/dist/providers/github/definitions/GitHubRepositoryConnectionOptions.js.map +1 -0
  108. package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.d.ts +23 -0
  109. package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.d.ts.map +1 -0
  110. package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.js +2 -0
  111. package/dist/providers/github/definitions/GitHubRepositoryConnectionResult.js.map +1 -0
  112. package/dist/providers/github/definitions/GitHubRepositoryVisibility.d.ts +2 -0
  113. package/dist/providers/github/definitions/GitHubRepositoryVisibility.d.ts.map +1 -0
  114. package/dist/providers/github/definitions/GitHubRepositoryVisibility.js +2 -0
  115. package/dist/providers/github/definitions/GitHubRepositoryVisibility.js.map +1 -0
  116. package/dist/providers/github/definitions/index.d.ts +3 -0
  117. package/dist/providers/github/definitions/index.d.ts.map +1 -0
  118. package/dist/providers/github/definitions/index.js +2 -0
  119. package/dist/providers/github/definitions/index.js.map +1 -0
  120. package/dist/providers/github/ports/GitHubRepositoryGateway.d.ts +42 -0
  121. package/dist/providers/github/ports/GitHubRepositoryGateway.d.ts.map +1 -0
  122. package/dist/providers/github/ports/GitHubRepositoryGateway.js +2 -0
  123. package/dist/providers/github/ports/GitHubRepositoryGateway.js.map +1 -0
  124. package/dist/providers/github/services/connectGitHubRepositoryAsync.d.ts +5 -0
  125. package/dist/providers/github/services/connectGitHubRepositoryAsync.d.ts.map +1 -0
  126. package/dist/providers/github/services/connectGitHubRepositoryAsync.js +70 -0
  127. package/dist/providers/github/services/connectGitHubRepositoryAsync.js.map +1 -0
  128. package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.d.ts +21 -0
  129. package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.d.ts.map +1 -0
  130. package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.js +72 -0
  131. package/dist/providers/github/services/inspectGitHubRepositoryPreflightAsync.js.map +1 -0
  132. package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.d.ts +8 -0
  133. package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.d.ts.map +1 -0
  134. package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.js +12 -0
  135. package/dist/providers/github/services/publishGitHubProjectSnapshotAsync.js.map +1 -0
  136. package/dist/readme-usage.d.ts +2 -0
  137. package/dist/readme-usage.d.ts.map +1 -0
  138. package/dist/readme-usage.js +32 -0
  139. package/dist/readme-usage.js.map +1 -0
  140. package/package.json +89 -0
@@ -0,0 +1,228 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { getProjectSnapshotPaths } from '../../../connection/utils/getProjectSnapshotPaths.js';
3
+ import { getGhNestedSha, isGhNotFound, isRecord, isString, runGhJsonAsync, sanitizeGhError, tryGhJsonAsync, } from './ghCliJson.js';
4
+ const bootstrapBranch = 'ankh-bootstrap';
5
+ const bootstrapMarker = 'ankhorage bootstrap marker';
6
+ /** Create the GitHub gateway backed exclusively by the local `gh` executable. */
7
+ export function createGhCliRepositoryGateway(runner = createGhRunner()) {
8
+ return {
9
+ assertAvailableAsync: () => runner.runAsync(['--version']).then(() => undefined),
10
+ assertAuthenticatedAsync: () => runner.runAsync(['auth', 'status']).then(() => undefined),
11
+ getAuthenticatedOwnerAsync: async () => {
12
+ const value = await runGhJsonAsync(runner, ['api', 'user']);
13
+ if (!isRecord(value) || typeof value.login !== 'string' || value.login.length === 0) {
14
+ throw new Error('GitHub returned an invalid authenticated user.');
15
+ }
16
+ return value.login;
17
+ },
18
+ inspectRepositoryAsync: (target) => inspectRepositoryAsync(runner, target),
19
+ createRepositoryAsync: async (target) => {
20
+ await runner.runAsync([
21
+ 'repo',
22
+ 'create',
23
+ `${target.owner}/${target.name}`,
24
+ `--${target.visibility}`,
25
+ ]);
26
+ },
27
+ initializeBootstrapAsync: (target) => initializeBootstrapAsync(runner, target),
28
+ publishSnapshotAsync: (target, snapshot, parentCommitSha) => publishSnapshotAsync(runner, target, snapshot, parentCommitSha),
29
+ verifyPublishedSnapshotAsync: (target, snapshot, commitSha) => verifyPublishedSnapshotAsync(runner, target, snapshot, commitSha),
30
+ setDefaultBranchAsync: async (target) => {
31
+ await runner.runAsync(['api', `repos/${target.owner}/${target.name}`, '--method', 'PATCH', '--input', '-'], JSON.stringify({ default_branch: target.defaultBranch }));
32
+ },
33
+ deleteBootstrapAsync: async (target, bootstrap) => {
34
+ const ref = `repos/${target.owner}/${target.name}/git/refs/heads/${bootstrap.branch}`;
35
+ const current = await runGhJsonAsync(runner, ['api', ref]);
36
+ if (!isRecord(current) ||
37
+ !isRecord(current.object) ||
38
+ current.object.sha !== bootstrap.commitSha) {
39
+ throw new Error('Bootstrap reference changed before cleanup.');
40
+ }
41
+ await runner.runAsync(['api', ref, '--method', 'DELETE']);
42
+ },
43
+ };
44
+ }
45
+ /** Spawn `gh` without a shell and with prompts, paging, and color disabled. */
46
+ function createGhRunner() {
47
+ return {
48
+ runAsync: (args, input) => new Promise((resolve, reject) => {
49
+ assertSafeArguments(args);
50
+ const child = spawn('gh', args, {
51
+ env: {
52
+ ...process.env,
53
+ GH_PROMPT_DISABLED: '1',
54
+ GH_PAGER: 'cat',
55
+ NO_COLOR: '1',
56
+ },
57
+ stdio: ['pipe', 'pipe', 'pipe'],
58
+ });
59
+ let stdout = '';
60
+ let stderr = '';
61
+ child.stdout.on('data', (chunk) => {
62
+ stdout += chunk.toString();
63
+ });
64
+ child.stderr.on('data', (chunk) => {
65
+ stderr += chunk.toString();
66
+ });
67
+ child.once('error', reject);
68
+ child.once('close', (code) => {
69
+ if (code === 0) {
70
+ resolve({ stdout, stderr });
71
+ }
72
+ else {
73
+ reject(new Error(`gh command failed (${code ?? 'unknown'}): ${sanitizeGhError(stderr)}`));
74
+ }
75
+ });
76
+ if (input !== undefined)
77
+ child.stdin.end(input);
78
+ else
79
+ child.stdin.end();
80
+ }),
81
+ };
82
+ }
83
+ /** Reject command arguments that could accidentally invoke local Git workflows. */
84
+ function assertSafeArguments(args) {
85
+ const forbidden = new Set(['git', '--source', '--push', '--clone']);
86
+ if (args.some((argument) => forbidden.has(argument))) {
87
+ throw new Error('Unsafe gh arguments rejected.');
88
+ }
89
+ }
90
+ /** Inspect repository metadata and the two operation-specific refs. */
91
+ async function inspectRepositoryAsync(runner, target) {
92
+ const prefix = `repos/${target.owner}/${target.name}`;
93
+ let repository;
94
+ try {
95
+ repository = await runGhJsonAsync(runner, ['api', prefix]);
96
+ }
97
+ catch (error) {
98
+ if (isGhNotFound(error)) {
99
+ return {
100
+ exists: false,
101
+ owner: target.owner,
102
+ name: target.name,
103
+ url: target.url,
104
+ };
105
+ }
106
+ throw error;
107
+ }
108
+ if (!isRecord(repository))
109
+ throw new Error('GitHub returned invalid repository metadata.');
110
+ const mainRef = await tryGhJsonAsync(runner, ['api', `${prefix}/git/ref/heads/main`]);
111
+ const bootstrapRef = await tryGhJsonAsync(runner, [
112
+ 'api',
113
+ `${prefix}/git/ref/heads/${bootstrapBranch}`,
114
+ ]);
115
+ const mainCommitSha = getGhNestedSha(mainRef);
116
+ const bootstrapCommitSha = getGhNestedSha(bootstrapRef);
117
+ const mainManifest = mainCommitSha
118
+ ? await readRemoteRepositoryManifestAsync(runner, prefix, mainCommitSha)
119
+ : undefined;
120
+ const bootstrapMarkerValue = bootstrapCommitSha
121
+ ? await readRemoteTextFileAsync(runner, prefix, '.ankhorage-bootstrap', bootstrapBranch)
122
+ : undefined;
123
+ return {
124
+ exists: true,
125
+ owner: target.owner,
126
+ name: target.name,
127
+ url: typeof repository.html_url === 'string' ? repository.html_url : target.url,
128
+ visibility: repository.private === true ? 'private' : 'public',
129
+ defaultBranch: typeof repository.default_branch === 'string' ? repository.default_branch : undefined,
130
+ mainCommitSha,
131
+ mainManifest,
132
+ bootstrapCommitSha,
133
+ bootstrapMarker: bootstrapMarkerValue,
134
+ };
135
+ }
136
+ /** Create the internal bootstrap commit through the contents endpoint. */
137
+ async function initializeBootstrapAsync(runner, target) {
138
+ const prefix = `repos/${target.owner}/${target.name}`;
139
+ await runner.runAsync(['api', `${prefix}/contents/.ankhorage-bootstrap`, '--method', 'PUT', '--input', '-'], JSON.stringify({
140
+ message: '[skip eas] chore: initialize repository',
141
+ content: Buffer.from(bootstrapMarker, 'utf8').toString('base64'),
142
+ branch: bootstrapBranch,
143
+ }));
144
+ const ref = await runGhJsonAsync(runner, ['api', `${prefix}/git/ref/heads/${bootstrapBranch}`]);
145
+ const commitSha = getGhNestedSha(ref);
146
+ if (!commitSha)
147
+ throw new Error('GitHub did not return the bootstrap commit.');
148
+ return { branch: bootstrapBranch, commitSha };
149
+ }
150
+ /** Upload blobs, create one complete tree and commit, then create `main` once. */
151
+ async function publishSnapshotAsync(runner, target, snapshot, parentCommitSha) {
152
+ const prefix = `repos/${target.owner}/${target.name}`;
153
+ const blobs = await Promise.all(snapshot.entries.map(async (entry) => {
154
+ const body = {
155
+ content: entry.encoding === 'base64'
156
+ ? entry.content
157
+ : Buffer.from(entry.content, 'utf8').toString('base64'),
158
+ encoding: 'base64',
159
+ };
160
+ const response = await runGhJsonAsync(runner, ['api', `${prefix}/git/blobs`, '--method', 'POST', '--input', '-'], JSON.stringify(body));
161
+ const sha = isRecord(response) && typeof response.sha === 'string' ? response.sha : undefined;
162
+ if (!sha)
163
+ throw new Error(`GitHub did not return a blob SHA for ${entry.path}.`);
164
+ return { path: entry.path, mode: entry.mode, type: 'blob', sha };
165
+ }));
166
+ const tree = await runGhJsonAsync(runner, ['api', `${prefix}/git/trees`, '--method', 'POST', '--input', '-'], JSON.stringify({ base_tree: parentCommitSha, tree: blobs }));
167
+ const treeSha = isRecord(tree) && typeof tree.sha === 'string' ? tree.sha : undefined;
168
+ if (!treeSha)
169
+ throw new Error('GitHub did not return a tree SHA.');
170
+ const commit = await runGhJsonAsync(runner, ['api', `${prefix}/git/commits`, '--method', 'POST', '--input', '-'], JSON.stringify({
171
+ message: 'chore: initialize standalone app',
172
+ tree: treeSha,
173
+ parents: [parentCommitSha],
174
+ }));
175
+ const commitSha = isRecord(commit) && typeof commit.sha === 'string' ? commit.sha : undefined;
176
+ if (!commitSha)
177
+ throw new Error('GitHub did not return an app commit SHA.');
178
+ await runner.runAsync(['api', `${prefix}/git/refs`, '--method', 'POST', '--input', '-'], JSON.stringify({ ref: 'refs/heads/main', sha: commitSha }));
179
+ return { commitSha };
180
+ }
181
+ /** Verify the final commit tree and canonical manifest before cleanup. */
182
+ async function verifyPublishedSnapshotAsync(runner, target, snapshot, commitSha) {
183
+ const prefix = `repos/${target.owner}/${target.name}`;
184
+ const ref = await runGhJsonAsync(runner, ['api', `${prefix}/git/ref/heads/main`]);
185
+ if (getGhNestedSha(ref) !== commitSha)
186
+ throw new Error('Published main ref does not match the app commit.');
187
+ const repository = await readRemoteRepositoryManifestAsync(runner, prefix, commitSha);
188
+ if (JSON.stringify(repository) !== JSON.stringify(snapshot.repository)) {
189
+ throw new Error('Published repository manifest does not match the prospective manifest.');
190
+ }
191
+ const tree = await runGhJsonAsync(runner, [
192
+ 'api',
193
+ `${prefix}/git/trees/${commitSha}?recursive=1`,
194
+ ]);
195
+ const paths = isRecord(tree) && Array.isArray(tree.tree)
196
+ ? tree.tree
197
+ .filter(isRecord)
198
+ .map((entry) => entry.path)
199
+ .filter(isString)
200
+ : [];
201
+ const expected = getProjectSnapshotPaths(snapshot.entries);
202
+ if (JSON.stringify(paths.sort()) !== JSON.stringify(expected)) {
203
+ throw new Error('Published tree does not match the complete project snapshot.');
204
+ }
205
+ }
206
+ /** Read the remote repository manifest from a commit. */
207
+ async function readRemoteRepositoryManifestAsync(runner, prefix, ref) {
208
+ const value = await tryGhJsonAsync(runner, [
209
+ 'api',
210
+ `${prefix}/contents/.ankhorage/repository.json?ref=${ref}`,
211
+ ]);
212
+ if (!isRecord(value) || typeof value.content !== 'string')
213
+ return undefined;
214
+ try {
215
+ return JSON.parse(Buffer.from(value.content.replaceAll('\n', ''), 'base64').toString('utf8'));
216
+ }
217
+ catch {
218
+ return undefined;
219
+ }
220
+ }
221
+ /** Read a text marker from an exact branch. */
222
+ async function readRemoteTextFileAsync(runner, prefix, path, ref) {
223
+ const value = await tryGhJsonAsync(runner, ['api', `${prefix}/contents/${path}?ref=${ref}`]);
224
+ if (!isRecord(value) || typeof value.content !== 'string')
225
+ return undefined;
226
+ return Buffer.from(value.content.replaceAll('\n', ''), 'base64').toString('utf8');
227
+ }
228
+ //# sourceMappingURL=createGhCliRepositoryGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGhCliRepositoryGateway.js","sourceRoot":"","sources":["../../../../src/providers/github/adapters/createGhCliRepositoryGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAK3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAQ/F,OAAO,EACL,cAAc,EAEd,YAAY,EAC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OAAO,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC5E,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CACf,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CACrD,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,+CAA+C;AAC/C,KAAK,UAAU,uBAAuB,CACpC,MAAgB,EAChB,MAAc,EACd,IAAY,EACZ,GAAW;IAEX,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,MAAM,aAAa,IAAI,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;IAC7F,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC5E,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpF,CAAC"}
@@ -0,0 +1,22 @@
1
+ interface GhRunnerResult {
2
+ readonly stdout: string;
3
+ }
4
+ export interface GhJsonRunner {
5
+ runAsync(args: readonly string[], input?: string): Promise<GhRunnerResult>;
6
+ }
7
+ /** Parse a JSON response from the GitHub CLI. */
8
+ export declare function runGhJsonAsync(runner: GhJsonRunner, args: readonly string[], input?: string): Promise<unknown>;
9
+ /** Return undefined for GitHub's not-found responses. */
10
+ export declare function tryGhJsonAsync(runner: GhJsonRunner, args: readonly string[]): Promise<unknown>;
11
+ /** Extract a SHA from a GitHub ref response. */
12
+ export declare function getGhNestedSha(value: unknown): string | undefined;
13
+ /** Identify a not-found response without exposing command output. */
14
+ export declare function isGhNotFound(error: unknown): boolean;
15
+ /** Restrict diagnostics to stable, non-sensitive process error text. */
16
+ export declare function sanitizeGhError(value: string): string;
17
+ /** Narrow unknown JSON objects. */
18
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
19
+ /** Narrow unknown strings. */
20
+ export declare function isString(value: unknown): value is string;
21
+ export {};
22
+ //# sourceMappingURL=ghCliJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ghCliJson.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/adapters/ghCliJson.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5E;AAED,iDAAiD;AACjD,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,yDAAyD;AACzD,wBAAsB,cAAc,CAClC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,gDAAgD;AAChD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAIjE;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,mCAAmC;AACnC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,8BAA8B;AAC9B,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD"}
@@ -0,0 +1,44 @@
1
+ /** Parse a JSON response from the GitHub CLI. */
2
+ export async function runGhJsonAsync(runner, args, input) {
3
+ const result = await runner.runAsync(args, input);
4
+ try {
5
+ return JSON.parse(result.stdout);
6
+ }
7
+ catch (error) {
8
+ throw new Error('GitHub returned malformed JSON.', { cause: error });
9
+ }
10
+ }
11
+ /** Return undefined for GitHub's not-found responses. */
12
+ export async function tryGhJsonAsync(runner, args) {
13
+ try {
14
+ return await runGhJsonAsync(runner, args);
15
+ }
16
+ catch (error) {
17
+ if (isGhNotFound(error))
18
+ return undefined;
19
+ throw error;
20
+ }
21
+ }
22
+ /** Extract a SHA from a GitHub ref response. */
23
+ export function getGhNestedSha(value) {
24
+ return isRecord(value) && isRecord(value.object) && typeof value.object.sha === 'string'
25
+ ? value.object.sha
26
+ : undefined;
27
+ }
28
+ /** Identify a not-found response without exposing command output. */
29
+ export function isGhNotFound(error) {
30
+ return error instanceof Error && /\b404\b|not found/iu.test(error.message);
31
+ }
32
+ /** Restrict diagnostics to stable, non-sensitive process error text. */
33
+ export function sanitizeGhError(value) {
34
+ return value.replaceAll(/\bgh[pousr]_[A-Za-z0-9_]+/gu, '[redacted]').slice(0, 500);
35
+ }
36
+ /** Narrow unknown JSON objects. */
37
+ export function isRecord(value) {
38
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
39
+ }
40
+ /** Narrow unknown strings. */
41
+ export function isString(value) {
42
+ return typeof value === 'string';
43
+ }
44
+ //# sourceMappingURL=ghCliJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ghCliJson.js","sourceRoot":"","sources":["../../../../src/providers/github/adapters/ghCliJson.ts"],"names":[],"mappings":"AAQA,iDAAiD;AACjD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAoB,EACpB,IAAuB,EACvB,KAAc;IAEd,MAAM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ACnC,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ProjectSnapshotReader } from '../../../connection/ports/ProjectSnapshotReader.js';
2
+ import type { RepositoryManifestStore } from '../../../connection/ports/RepositoryManifestStore.js';
3
+ import type { GitHubRepositoryGateway } from '../ports/GitHubRepositoryGateway.js';
4
+ import type { GitHubRepositoryVisibility } from './GitHubRepositoryVisibility.js';
5
+ export interface GitHubRepositoryConnectionOptions {
6
+ readonly projectPath?: string;
7
+ readonly owner?: string;
8
+ readonly name?: string;
9
+ readonly visibility?: GitHubRepositoryVisibility;
10
+ }
11
+ export interface GitHubRepositoryConnectionDependencies {
12
+ readonly gateway?: GitHubRepositoryGateway;
13
+ readonly snapshotReader?: ProjectSnapshotReader;
14
+ readonly manifestStore?: RepositoryManifestStore;
15
+ }
16
+ //# sourceMappingURL=GitHubRepositoryConnectionOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryConnectionOptions.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/definitions/GitHubRepositoryConnectionOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AACpG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAElF,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,0BAA0B,CAAC;CAClD;AAED,MAAM,WAAW,sCAAsC;IACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAC3C,QAAQ,CAAC,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAChD,QAAQ,CAAC,aAAa,CAAC,EAAE,uBAAuB,CAAC;CAClD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GitHubRepositoryConnectionOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryConnectionOptions.js","sourceRoot":"","sources":["../../../../src/providers/github/definitions/GitHubRepositoryConnectionOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ export type GitHubRepositoryConnectionStatus = 'connected' | 'already-connected';
2
+ export interface GitHubRepositoryConnectionIdentity {
3
+ readonly owner: string;
4
+ readonly name: string;
5
+ readonly url: string;
6
+ readonly defaultBranch: 'main';
7
+ }
8
+ interface GitHubRepositoryConnectionSuccess {
9
+ readonly status: GitHubRepositoryConnectionStatus;
10
+ readonly repository: GitHubRepositoryConnectionIdentity;
11
+ readonly appCommitSha?: string;
12
+ }
13
+ type GitHubRepositoryConnectionFailureKind = 'recoverable-failure' | 'conflict';
14
+ export interface GitHubRepositoryConnectionFailure {
15
+ readonly status: GitHubRepositoryConnectionFailureKind;
16
+ readonly stage: string;
17
+ readonly code: string;
18
+ readonly message: string;
19
+ readonly repository?: GitHubRepositoryConnectionIdentity;
20
+ }
21
+ export type GitHubRepositoryConnectionResult = GitHubRepositoryConnectionSuccess | GitHubRepositoryConnectionFailure;
22
+ export {};
23
+ //# sourceMappingURL=GitHubRepositoryConnectionResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryConnectionResult.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/definitions/GitHubRepositoryConnectionResult.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gCAAgC,GAAG,WAAW,GAAG,mBAAmB,CAAC;AAEjF,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,UAAU,iCAAiC;IACzC,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC;IAClD,QAAQ,CAAC,UAAU,EAAE,kCAAkC,CAAC;IACxD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,KAAK,qCAAqC,GAAG,qBAAqB,GAAG,UAAU,CAAC;AAEhF,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,MAAM,EAAE,qCAAqC,CAAC;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,kCAAkC,CAAC;CAC1D;AAED,MAAM,MAAM,gCAAgC,GAC1C,iCAAiC,GAAG,iCAAiC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GitHubRepositoryConnectionResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryConnectionResult.js","sourceRoot":"","sources":["../../../../src/providers/github/definitions/GitHubRepositoryConnectionResult.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type GitHubRepositoryVisibility = 'private' | 'public';
2
+ //# sourceMappingURL=GitHubRepositoryVisibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryVisibility.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/definitions/GitHubRepositoryVisibility.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GitHubRepositoryVisibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryVisibility.js","sourceRoot":"","sources":["../../../../src/providers/github/definitions/GitHubRepositoryVisibility.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export type { GitHubRepositoryConnectionOptions } from './GitHubRepositoryConnectionOptions.js';
2
+ export type { GitHubRepositoryConnectionIdentity } from './GitHubRepositoryConnectionResult.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/definitions/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAChG,YAAY,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/github/definitions/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ import type { RepositoryManifest } from '@ankhorage/contracts/repository';
2
+ import type { ProjectSnapshot } from '../../../connection/definitions/ProjectSnapshot.js';
3
+ import type { GitHubRepositoryVisibility } from '../definitions/GitHubRepositoryVisibility.js';
4
+ export interface GitHubRepositoryTarget {
5
+ readonly owner: string;
6
+ readonly name: string;
7
+ readonly visibility: GitHubRepositoryVisibility;
8
+ readonly url: string;
9
+ readonly defaultBranch: 'main';
10
+ }
11
+ export interface GitHubRemoteRepository {
12
+ readonly exists: boolean;
13
+ readonly owner: string;
14
+ readonly name: string;
15
+ readonly url: string;
16
+ readonly visibility?: GitHubRepositoryVisibility;
17
+ readonly defaultBranch?: string;
18
+ readonly mainCommitSha?: string;
19
+ readonly mainManifest?: RepositoryManifest;
20
+ readonly bootstrapCommitSha?: string;
21
+ readonly bootstrapMarker?: string;
22
+ }
23
+ export interface GitHubBootstrap {
24
+ readonly commitSha: string;
25
+ readonly branch: 'ankh-bootstrap';
26
+ }
27
+ export interface GitHubPublishedSnapshot {
28
+ readonly commitSha: string;
29
+ }
30
+ export interface GitHubRepositoryGateway {
31
+ assertAvailableAsync(): Promise<void>;
32
+ assertAuthenticatedAsync(): Promise<void>;
33
+ getAuthenticatedOwnerAsync(): Promise<string>;
34
+ inspectRepositoryAsync(target: GitHubRepositoryTarget): Promise<GitHubRemoteRepository>;
35
+ createRepositoryAsync(target: GitHubRepositoryTarget): Promise<void>;
36
+ initializeBootstrapAsync(target: GitHubRepositoryTarget): Promise<GitHubBootstrap>;
37
+ publishSnapshotAsync(target: GitHubRepositoryTarget, snapshot: ProjectSnapshot, parentCommitSha: string): Promise<GitHubPublishedSnapshot>;
38
+ verifyPublishedSnapshotAsync(target: GitHubRepositoryTarget, snapshot: ProjectSnapshot, commitSha: string): Promise<void>;
39
+ setDefaultBranchAsync(target: GitHubRepositoryTarget): Promise<void>;
40
+ deleteBootstrapAsync(target: GitHubRepositoryTarget, bootstrap: GitHubBootstrap): Promise<void>;
41
+ }
42
+ //# sourceMappingURL=GitHubRepositoryGateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryGateway.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/ports/GitHubRepositoryGateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAE/F,MAAM,WAAW,sBAAsB;IACr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OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACnF,oBAAoB,CAClB,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,EAAE,eAAe,EACzB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACpC,4BAA4B,CAC1B,MAAM,EAAE,sBAAsB,EAC9B,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,qBAAqB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GitHubRepositoryGateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitHubRepositoryGateway.js","sourceRoot":"","sources":["../../../../src/providers/github/ports/GitHubRepositoryGateway.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { GitHubRepositoryConnectionDependencies, GitHubRepositoryConnectionOptions } from '../definitions/GitHubRepositoryConnectionOptions.js';
2
+ import type { GitHubRepositoryConnectionResult } from '../definitions/GitHubRepositoryConnectionResult.js';
3
+ /** Connect a standalone app to GitHub and publish its complete snapshot on `main`. */
4
+ export declare function connectGitHubRepositoryAsync(options?: GitHubRepositoryConnectionOptions, dependencies?: GitHubRepositoryConnectionDependencies): Promise<GitHubRepositoryConnectionResult>;
5
+ //# sourceMappingURL=connectGitHubRepositoryAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectGitHubRepositoryAsync.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/connectGitHubRepositoryAsync.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,sCAAsC,EACtC,iCAAiC,EAClC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,KAAK,EAGV,gCAAgC,EACjC,MAAM,oDAAoD,CAAC;AAY5D,sFAAsF;AACtF,wBAAsB,4BAA4B,CAChD,OAAO,GAAE,iCAAsC,EAC/C,YAAY,GAAE,sCAA2C,GACxD,OAAO,CAAC,gCAAgC,CAAC,CA+B3C"}
@@ -0,0 +1,70 @@
1
+ import { createLocalProjectSnapshotReader } from '../../../connection/adapters/createLocalProjectSnapshotReader.js';
2
+ import { createLocalRepositoryManifestStore } from '../../../connection/adapters/createLocalRepositoryManifestStore.js';
3
+ import { createGhCliRepositoryGateway } from '../adapters/createGhCliRepositoryGateway.js';
4
+ import { inspectGitHubRepositoryPreflightAsync, PreflightError, } from './inspectGitHubRepositoryPreflightAsync.js';
5
+ import { publishGitHubProjectSnapshotAsync } from './publishGitHubProjectSnapshotAsync.js';
6
+ /** Connect a standalone app to GitHub and publish its complete snapshot on `main`. */
7
+ export async function connectGitHubRepositoryAsync(options = {}, dependencies = {}) {
8
+ const gateway = dependencies.gateway ?? createGhCliRepositoryGateway();
9
+ const snapshotReader = dependencies.snapshotReader ?? createLocalProjectSnapshotReader();
10
+ const manifestStore = dependencies.manifestStore ?? createLocalRepositoryManifestStore();
11
+ let preflight;
12
+ try {
13
+ preflight = await inspectGitHubRepositoryPreflightAsync(options, gateway, snapshotReader, manifestStore);
14
+ }
15
+ catch (error) {
16
+ return toFailure(error, 'preflight');
17
+ }
18
+ const { target, identity, remote, snapshot } = preflight;
19
+ const existing = await finishAlreadyConnectedAsync(gateway, target, identity, remote);
20
+ if (existing)
21
+ return existing;
22
+ try {
23
+ return await publishConnectionAsync(gateway, manifestStore, options.projectPath ?? process.cwd(), target, identity, remote, snapshot);
24
+ }
25
+ catch (error) {
26
+ return toFailure(error, 'publish', identity);
27
+ }
28
+ }
29
+ /** Finish an idempotent connection and clean up its recognized bootstrap ref. */
30
+ async function finishAlreadyConnectedAsync(gateway, target, identity, remote) {
31
+ if (!remote.mainManifest ||
32
+ !remote.mainCommitSha ||
33
+ remote.mainManifest.owner !== identity.owner ||
34
+ remote.mainManifest.name !== identity.name) {
35
+ return undefined;
36
+ }
37
+ if (remote.bootstrapCommitSha) {
38
+ await gateway.deleteBootstrapAsync(target, {
39
+ branch: 'ankh-bootstrap',
40
+ commitSha: remote.bootstrapCommitSha,
41
+ });
42
+ }
43
+ return {
44
+ status: 'already-connected',
45
+ repository: identity,
46
+ appCommitSha: remote.mainCommitSha,
47
+ };
48
+ }
49
+ /** Persist the connection and publish the complete snapshot. */
50
+ async function publishConnectionAsync(gateway, manifestStore, projectPath, target, identity, remote, snapshot) {
51
+ await manifestStore.updateRepositoryAsync(projectPath, { provider: 'github', ...identity });
52
+ if (!remote.exists)
53
+ await gateway.createRepositoryAsync(target);
54
+ const publication = await publishGitHubProjectSnapshotAsync(gateway, target, snapshot, remote.bootstrapCommitSha);
55
+ return { status: 'connected', repository: identity, appCommitSha: publication.commitSha };
56
+ }
57
+ /** Convert provider and validation errors into a stable public failure result. */
58
+ function toFailure(error, stage, repository) {
59
+ if (error instanceof PreflightError && error.kind === 'conflict') {
60
+ return { status: 'conflict', stage, code: error.code, message: error.message, repository };
61
+ }
62
+ return {
63
+ status: 'recoverable-failure',
64
+ stage,
65
+ code: error instanceof PreflightError ? error.code : 'operation-failed',
66
+ message: error instanceof Error ? error.message : 'GitHub connection failed.',
67
+ repository,
68
+ };
69
+ }
70
+ //# sourceMappingURL=connectGitHubRepositoryAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectGitHubRepositoryAsync.js","sourceRoot":"","sources":["../../../../src/providers/github/services/connectGitHubRepositoryAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,kEAAkE,CAAC;AACpH,OAAO,EAAE,kCAAkC,EAAE,MAAM,oEAAoE,CAAC;AAGxH,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,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c,EACd,KAAa,EACb,UAAgF;IAEhF,IAAI,KAAK,YAAY,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACjE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC;IAC7F,CAAC;IACD,OAAO;QACL,MAAM,EAAE,qBAAqB;QAC7B,KAAK;QACL,IAAI,EAAE,KAAK,YAAY,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB;QACvE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAA2B;QAC7E,UAAU;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { RepositoryManifest } from '@ankhorage/contracts/repository';
2
+ import type { ProjectSnapshot } from '../../../connection/definitions/ProjectSnapshot.js';
3
+ import type { ProjectSnapshotReader } from '../../../connection/ports/ProjectSnapshotReader.js';
4
+ import type { RepositoryManifestStore } from '../../../connection/ports/RepositoryManifestStore.js';
5
+ import type { GitHubRepositoryConnectionIdentity, GitHubRepositoryConnectionOptions } from '../definitions/index.js';
6
+ import type { GitHubRemoteRepository, GitHubRepositoryGateway, GitHubRepositoryTarget } from '../ports/GitHubRepositoryGateway.js';
7
+ export interface GitHubRepositoryPreflight {
8
+ readonly target: GitHubRepositoryTarget;
9
+ readonly identity: GitHubRepositoryConnectionIdentity;
10
+ readonly manifest?: RepositoryManifest;
11
+ readonly snapshot: ProjectSnapshot;
12
+ readonly remote: GitHubRemoteRepository;
13
+ }
14
+ /** Inspect all local and remote state before allowing a repository mutation. */
15
+ export declare function inspectGitHubRepositoryPreflightAsync(options: GitHubRepositoryConnectionOptions, gateway: GitHubRepositoryGateway, snapshotReader: ProjectSnapshotReader, manifestStore: RepositoryManifestStore): Promise<GitHubRepositoryPreflight>;
16
+ export declare class PreflightError extends Error {
17
+ readonly kind: 'conflict' | 'recoverable-failure';
18
+ readonly code: string;
19
+ constructor(kind: 'conflict' | 'recoverable-failure', code: string, message: string);
20
+ }
21
+ //# sourceMappingURL=inspectGitHubRepositoryPreflightAsync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspectGitHubRepositoryPreflightAsync.d.ts","sourceRoot":"","sources":["../../../../src/providers/github/services/inspectGitHubRepositoryPreflightAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AACpG,OAAO,KAAK,EACV,kCAAkC,EAClC,iCAAiC,EAClC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,kCAAkC,CAAC;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;CACzC;AAED,gFAAgF;AAChF,wBAAsB,qCAAqC,CACzD,OAAO,EAAE,iCAAiC,EAC1C,OAAO,EAAE,uBAAuB,EAChC,cAAc,EAAE,qBAAqB,EACrC,aAAa,EAAE,uBAAuB,GACrC,OAAO,CAAC,yBAAyB,CAAC,CA4BpC;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,qBAAqB,CAAC;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,UAAU,GAAG,qBAAqB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMpF"}