specweave 0.24.6 → 0.24.9
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/CLAUDE.md +64 -0
- package/README.md +34 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +3 -1
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts +5 -2
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +90 -8
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github.d.ts +2 -1
- package/dist/src/cli/helpers/issue-tracker/github.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github.js +4 -3
- package/dist/src/cli/helpers/issue-tracker/github.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/index.js +26 -9
- package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/types.d.ts +1 -0
- package/dist/src/cli/helpers/issue-tracker/types.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/types.js.map +1 -1
- package/dist/src/core/repo-structure/git-error-handler.d.ts +37 -0
- package/dist/src/core/repo-structure/git-error-handler.d.ts.map +1 -0
- package/dist/src/core/repo-structure/git-error-handler.js +214 -0
- package/dist/src/core/repo-structure/git-error-handler.js.map +1 -0
- package/dist/src/core/repo-structure/git-provider.d.ts +183 -0
- package/dist/src/core/repo-structure/git-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/git-provider.js +57 -0
- package/dist/src/core/repo-structure/git-provider.js.map +1 -0
- package/dist/src/core/repo-structure/github-validator.d.ts +1 -0
- package/dist/src/core/repo-structure/github-validator.d.ts.map +1 -1
- package/dist/src/core/repo-structure/github-validator.js +35 -9
- package/dist/src/core/repo-structure/github-validator.js.map +1 -1
- package/dist/src/core/repo-structure/platform-registry.d.ts +114 -0
- package/dist/src/core/repo-structure/platform-registry.d.ts.map +1 -0
- package/dist/src/core/repo-structure/platform-registry.js +206 -0
- package/dist/src/core/repo-structure/platform-registry.js.map +1 -0
- package/dist/src/core/repo-structure/prompt-consolidator.d.ts +42 -0
- package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
- package/dist/src/core/repo-structure/prompt-consolidator.js +102 -0
- package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
- package/dist/src/core/repo-structure/providers/azure-devops-provider.d.ts +64 -0
- package/dist/src/core/repo-structure/providers/azure-devops-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/azure-devops-provider.js +263 -0
- package/dist/src/core/repo-structure/providers/azure-devops-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts +55 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.js +238 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/github-provider.d.ts +53 -0
- package/dist/src/core/repo-structure/providers/github-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/github-provider.js +239 -0
- package/dist/src/core/repo-structure/providers/github-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts +51 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.js +251 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/index.d.ts +35 -0
- package/dist/src/core/repo-structure/providers/index.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/index.js +68 -0
- package/dist/src/core/repo-structure/providers/index.js.map +1 -0
- package/dist/src/core/repo-structure/providers/local-provider.d.ts +61 -0
- package/dist/src/core/repo-structure/providers/local-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/local-provider.js +148 -0
- package/dist/src/core/repo-structure/providers/local-provider.js.map +1 -0
- package/dist/src/core/repo-structure/repo-structure-manager.d.ts +21 -4
- package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
- package/dist/src/core/repo-structure/repo-structure-manager.js +380 -113
- package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
- package/dist/src/core/repo-structure/url-generator.d.ts +80 -0
- package/dist/src/core/repo-structure/url-generator.d.ts.map +1 -0
- package/dist/src/core/repo-structure/url-generator.js +110 -0
- package/dist/src/core/repo-structure/url-generator.js.map +1 -0
- package/package.json +1 -1
- package/plugins/specweave/hooks/post-task-completion.sh +69 -175
- package/plugins/specweave/lib/hooks/consolidated-sync.js +183 -0
- package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +64 -0
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +96 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Provider Implementation
|
|
3
|
+
*
|
|
4
|
+
* Implements GitProvider interface for GitHub.com and GitHub Enterprise.
|
|
5
|
+
* Handles repository validation, creation, and management via GitHub API.
|
|
6
|
+
*
|
|
7
|
+
* @module providers/github-provider
|
|
8
|
+
*/
|
|
9
|
+
import { BaseGitProvider } from '../git-provider.js';
|
|
10
|
+
import { getActionableError, formatActionableError } from '../git-error-handler.js';
|
|
11
|
+
/**
|
|
12
|
+
* GitHub Provider
|
|
13
|
+
*
|
|
14
|
+
* Implements Git operations for GitHub platform.
|
|
15
|
+
*/
|
|
16
|
+
export class GitHubProvider extends BaseGitProvider {
|
|
17
|
+
constructor(config) {
|
|
18
|
+
super({
|
|
19
|
+
type: 'github',
|
|
20
|
+
name: 'GitHub',
|
|
21
|
+
host: config?.host || 'github.com',
|
|
22
|
+
apiBaseUrl: config?.apiBaseUrl || 'https://api.github.com',
|
|
23
|
+
selfHosted: config?.selfHosted || false,
|
|
24
|
+
customDomain: config?.customDomain
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validate if a repository exists on GitHub
|
|
29
|
+
*/
|
|
30
|
+
async validateRepository(owner, repo, token) {
|
|
31
|
+
try {
|
|
32
|
+
const headers = {
|
|
33
|
+
'Accept': 'application/vnd.github.v3+json'
|
|
34
|
+
};
|
|
35
|
+
if (token) {
|
|
36
|
+
headers['Authorization'] = `token ${token}`;
|
|
37
|
+
}
|
|
38
|
+
const response = await fetch(this.getApiUrl(`/repos/${owner}/${repo}`), { headers });
|
|
39
|
+
if (response.status === 404) {
|
|
40
|
+
// Repository does not exist (good for creation)
|
|
41
|
+
return { exists: false, valid: true };
|
|
42
|
+
}
|
|
43
|
+
if (response.status === 200) {
|
|
44
|
+
// Repository already exists
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
return {
|
|
47
|
+
exists: true,
|
|
48
|
+
valid: true,
|
|
49
|
+
url: data.html_url
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (response.status === 401 || response.status === 403) {
|
|
53
|
+
// Authentication or permission error
|
|
54
|
+
const apiError = {
|
|
55
|
+
status: response.status,
|
|
56
|
+
message: response.statusText,
|
|
57
|
+
platform: 'github',
|
|
58
|
+
operation: 'validate_repo',
|
|
59
|
+
resourceType: 'repository',
|
|
60
|
+
resourceName: `${owner}/${repo}`
|
|
61
|
+
};
|
|
62
|
+
const actionable = getActionableError(apiError);
|
|
63
|
+
return { exists: false, valid: false, error: formatActionableError(actionable) };
|
|
64
|
+
}
|
|
65
|
+
// Other error
|
|
66
|
+
const apiError = {
|
|
67
|
+
status: response.status,
|
|
68
|
+
message: response.statusText,
|
|
69
|
+
platform: 'github',
|
|
70
|
+
operation: 'validate_repo',
|
|
71
|
+
resourceType: 'repository',
|
|
72
|
+
resourceName: `${owner}/${repo}`
|
|
73
|
+
};
|
|
74
|
+
const actionable = getActionableError(apiError);
|
|
75
|
+
return {
|
|
76
|
+
exists: false,
|
|
77
|
+
valid: false,
|
|
78
|
+
error: formatActionableError(actionable)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
exists: false,
|
|
84
|
+
valid: false,
|
|
85
|
+
error: `Network error: ${error instanceof Error ? error.message : String(error)}`
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate if a GitHub owner (user or organization) exists
|
|
91
|
+
*/
|
|
92
|
+
async validateOwner(owner, token) {
|
|
93
|
+
const headers = {
|
|
94
|
+
'Accept': 'application/vnd.github.v3+json'
|
|
95
|
+
};
|
|
96
|
+
if (token) {
|
|
97
|
+
headers['Authorization'] = `token ${token}`;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
// Try as user first
|
|
101
|
+
const userResponse = await fetch(this.getApiUrl(`/users/${owner}`), { headers });
|
|
102
|
+
if (userResponse.status === 200) {
|
|
103
|
+
const data = await userResponse.json();
|
|
104
|
+
const type = data.type === 'Organization' ? 'organization' : 'user';
|
|
105
|
+
return { valid: true, type };
|
|
106
|
+
}
|
|
107
|
+
// Try as organization
|
|
108
|
+
const orgResponse = await fetch(this.getApiUrl(`/orgs/${owner}`), { headers });
|
|
109
|
+
if (orgResponse.status === 200) {
|
|
110
|
+
return { valid: true, type: 'organization' };
|
|
111
|
+
}
|
|
112
|
+
// Not found
|
|
113
|
+
const apiError = {
|
|
114
|
+
status: 404,
|
|
115
|
+
message: 'Not Found',
|
|
116
|
+
platform: 'github',
|
|
117
|
+
operation: 'validate_owner',
|
|
118
|
+
resourceType: 'user',
|
|
119
|
+
resourceName: owner
|
|
120
|
+
};
|
|
121
|
+
const actionable = getActionableError(apiError);
|
|
122
|
+
return { valid: false, error: formatActionableError(actionable) };
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
return {
|
|
126
|
+
valid: false,
|
|
127
|
+
error: `Network error: ${error instanceof Error ? error.message : String(error)}`
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Create a new repository on GitHub
|
|
133
|
+
*/
|
|
134
|
+
async createRepository(options, token) {
|
|
135
|
+
// Check if it's an organization or user
|
|
136
|
+
const isOrg = await this.isOrganization(options.owner, token);
|
|
137
|
+
const endpoint = isOrg
|
|
138
|
+
? this.getApiUrl(`/orgs/${options.owner}/repos`)
|
|
139
|
+
: this.getApiUrl('/user/repos');
|
|
140
|
+
const response = await fetch(endpoint, {
|
|
141
|
+
method: 'POST',
|
|
142
|
+
headers: {
|
|
143
|
+
'Authorization': `token ${token}`,
|
|
144
|
+
'Accept': 'application/vnd.github.v3+json',
|
|
145
|
+
'Content-Type': 'application/json'
|
|
146
|
+
},
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
name: options.name,
|
|
149
|
+
description: options.description,
|
|
150
|
+
private: options.visibility === 'private',
|
|
151
|
+
auto_init: options.autoInit || false,
|
|
152
|
+
has_issues: options.hasIssues !== false,
|
|
153
|
+
has_wiki: options.hasWiki || false
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
if (!response.ok) {
|
|
157
|
+
const error = await response.json();
|
|
158
|
+
// Handle "already exists" error
|
|
159
|
+
if (error.errors?.[0]?.message?.includes('already exists')) {
|
|
160
|
+
// Repository already exists, return URL
|
|
161
|
+
return `https://${this.config.host}/${options.owner}/${options.name}`;
|
|
162
|
+
}
|
|
163
|
+
// Handle other errors with actionable messages
|
|
164
|
+
const apiError = {
|
|
165
|
+
status: response.status,
|
|
166
|
+
message: error.message || response.statusText,
|
|
167
|
+
platform: 'github',
|
|
168
|
+
operation: 'create_repo',
|
|
169
|
+
resourceType: 'repository',
|
|
170
|
+
resourceName: `${options.owner}/${options.name}`
|
|
171
|
+
};
|
|
172
|
+
const actionable = getActionableError(apiError);
|
|
173
|
+
throw new Error(formatActionableError(actionable));
|
|
174
|
+
}
|
|
175
|
+
const data = await response.json();
|
|
176
|
+
return data.html_url;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Check if an account is an organization
|
|
180
|
+
*/
|
|
181
|
+
async isOrganization(account, token) {
|
|
182
|
+
try {
|
|
183
|
+
const headers = {
|
|
184
|
+
'Accept': 'application/vnd.github.v3+json'
|
|
185
|
+
};
|
|
186
|
+
if (token) {
|
|
187
|
+
headers['Authorization'] = `token ${token}`;
|
|
188
|
+
}
|
|
189
|
+
const response = await fetch(this.getApiUrl(`/users/${account}`), { headers });
|
|
190
|
+
if (response.ok) {
|
|
191
|
+
const data = await response.json();
|
|
192
|
+
return data.type === 'Organization';
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
// Assume user if we can't determine
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get token creation URL
|
|
202
|
+
*/
|
|
203
|
+
getTokenUrl() {
|
|
204
|
+
if (this.config.selfHosted) {
|
|
205
|
+
return `https://${this.config.customDomain || this.config.host}/settings/tokens/new`;
|
|
206
|
+
}
|
|
207
|
+
return 'https://github.com/settings/tokens/new';
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get required token scopes
|
|
211
|
+
*/
|
|
212
|
+
getRequiredScopes(isOrganization) {
|
|
213
|
+
const scopes = ['repo'];
|
|
214
|
+
if (isOrganization) {
|
|
215
|
+
scopes.push('admin:org');
|
|
216
|
+
}
|
|
217
|
+
return scopes;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Override getAuthHeaders for GitHub-specific auth
|
|
221
|
+
*/
|
|
222
|
+
getAuthHeaders(token) {
|
|
223
|
+
return {
|
|
224
|
+
'Authorization': `token ${token}`,
|
|
225
|
+
'Accept': 'application/vnd.github.v3+json',
|
|
226
|
+
'Content-Type': 'application/json'
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create a GitHub provider instance
|
|
232
|
+
*
|
|
233
|
+
* @param config - Optional platform configuration
|
|
234
|
+
* @returns GitHub provider instance
|
|
235
|
+
*/
|
|
236
|
+
export function createGitHubProvider(config) {
|
|
237
|
+
return new GitHubProvider(config);
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=github-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-provider.js","sourceRoot":"","sources":["../../../../../src/core/repo-structure/providers/github-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAsG,MAAM,oBAAoB,CAAC;AACzJ,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAoB,MAAM,yBAAyB,CAAC;AAGtG;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,eAAe;IACjD,YAAY,MAAgC;QAC1C,KAAK,CAAC;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,YAAY;YAClC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,wBAAwB;YAC1D,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,KAAK;YACvC,YAAY,EAAE,MAAM,EAAE,YAAY;SACnC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CACtB,KAAa,EACb,IAAY,EACZ,KAAc;QAEd,IAAI,CAAC;YACH,MAAM,OAAO,GAA2B;gBACtC,QAAQ,EAAE,gCAAgC;aAC3C,CAAC;YAEF,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,KAAK,EAAE,CAAC;YAC9C,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,IAAI,CAAC,SAAS,CAAC,UAAU,KAAK,IAAI,IAAI,EAAE,CAAC,EACzC,EAAE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G;IACO,cAAc,CAAC,KAAa;QACpC,OAAO;YACL,eAAe,EAAE,SAAS,KAAK,EAAE;YACjC,QAAQ,EAAE,gCAAgC;YAC1C,cAAc,EAAE,kBAAkB;SACnC,CAAC;IACJ,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAgC;IACnE,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitLab Provider Implementation
|
|
3
|
+
*
|
|
4
|
+
* Implements GitProvider interface for GitLab.com and self-hosted GitLab instances.
|
|
5
|
+
* Handles project validation, creation, and management via GitLab API v4.
|
|
6
|
+
*
|
|
7
|
+
* @module providers/gitlab-provider
|
|
8
|
+
*/
|
|
9
|
+
import { BaseGitProvider, type PlatformConfig, type RepoValidationResult, type OwnerValidationResult, type CreateRepoOptions } from '../git-provider.js';
|
|
10
|
+
/**
|
|
11
|
+
* GitLab Provider
|
|
12
|
+
*
|
|
13
|
+
* Implements Git operations for GitLab platform.
|
|
14
|
+
* Supports both GitLab.com and self-hosted GitLab instances.
|
|
15
|
+
*/
|
|
16
|
+
export declare class GitLabProvider extends BaseGitProvider {
|
|
17
|
+
constructor(config?: Partial<PlatformConfig>);
|
|
18
|
+
/**
|
|
19
|
+
* Validate if a project exists on GitLab
|
|
20
|
+
*/
|
|
21
|
+
validateRepository(owner: string, repo: string, token?: string): Promise<RepoValidationResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Validate if a GitLab namespace (user or group) exists
|
|
24
|
+
*/
|
|
25
|
+
validateOwner(owner: string, token?: string): Promise<OwnerValidationResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new project on GitLab
|
|
28
|
+
*/
|
|
29
|
+
createRepository(options: CreateRepoOptions, token: string): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a namespace is a group (organization)
|
|
32
|
+
*/
|
|
33
|
+
isOrganization(account: string, token?: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Get token creation URL
|
|
36
|
+
*/
|
|
37
|
+
getTokenUrl(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get required token scopes
|
|
40
|
+
*/
|
|
41
|
+
getRequiredScopes(isOrganization?: boolean): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Override getAuthHeaders for GitLab-specific auth (PRIVATE-TOKEN)
|
|
44
|
+
*/
|
|
45
|
+
protected getAuthHeaders(token: string): Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a GitLab provider instance
|
|
49
|
+
*/
|
|
50
|
+
export declare function createGitLabProvider(config?: Partial<PlatformConfig>): GitLabProvider;
|
|
51
|
+
//# sourceMappingURL=gitlab-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlab-provider.d.ts","sourceRoot":"","sources":["../../../../../src/core/repo-structure/providers/gitlab-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGzJ;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,eAAe;gBACrC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAW5C;;OAEG;IACG,kBAAkB,CACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,CAAC;IA0EhC;;OAEG;IACG,aAAa,CACjB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,qBAAqB,CAAC;IAsDjC;;OAEG;IACG,gBAAgB,CACpB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC;IA6ElB;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAsBvE;;OAEG;IACH,WAAW,IAAI,MAAM;IAOrB;;OAEG;IACH,iBAAiB,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE;IAIrD;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAOhE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAErF"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitLab Provider Implementation
|
|
3
|
+
*
|
|
4
|
+
* Implements GitProvider interface for GitLab.com and self-hosted GitLab instances.
|
|
5
|
+
* Handles project validation, creation, and management via GitLab API v4.
|
|
6
|
+
*
|
|
7
|
+
* @module providers/gitlab-provider
|
|
8
|
+
*/
|
|
9
|
+
import { BaseGitProvider } from '../git-provider.js';
|
|
10
|
+
import { getActionableError, formatActionableError } from '../git-error-handler.js';
|
|
11
|
+
/**
|
|
12
|
+
* GitLab Provider
|
|
13
|
+
*
|
|
14
|
+
* Implements Git operations for GitLab platform.
|
|
15
|
+
* Supports both GitLab.com and self-hosted GitLab instances.
|
|
16
|
+
*/
|
|
17
|
+
export class GitLabProvider extends BaseGitProvider {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
super({
|
|
20
|
+
type: 'gitlab',
|
|
21
|
+
name: 'GitLab',
|
|
22
|
+
host: config?.host || 'gitlab.com',
|
|
23
|
+
apiBaseUrl: config?.apiBaseUrl || 'https://gitlab.com/api/v4',
|
|
24
|
+
selfHosted: config?.selfHosted || false,
|
|
25
|
+
customDomain: config?.customDomain
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validate if a project exists on GitLab
|
|
30
|
+
*/
|
|
31
|
+
async validateRepository(owner, repo, token) {
|
|
32
|
+
try {
|
|
33
|
+
const headers = {
|
|
34
|
+
'Accept': 'application/json'
|
|
35
|
+
};
|
|
36
|
+
if (token) {
|
|
37
|
+
headers['PRIVATE-TOKEN'] = token;
|
|
38
|
+
}
|
|
39
|
+
// GitLab uses namespace/project format for project IDs
|
|
40
|
+
const projectPath = encodeURIComponent(`${owner}/${repo}`);
|
|
41
|
+
const response = await fetch(this.getApiUrl(`/projects/${projectPath}`), { headers });
|
|
42
|
+
if (response.status === 404) {
|
|
43
|
+
// Project does not exist (good for creation)
|
|
44
|
+
return { exists: false, valid: true };
|
|
45
|
+
}
|
|
46
|
+
if (response.status === 200) {
|
|
47
|
+
// Project already exists
|
|
48
|
+
const data = await response.json();
|
|
49
|
+
return {
|
|
50
|
+
exists: true,
|
|
51
|
+
valid: true,
|
|
52
|
+
url: data.web_url
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (response.status === 401 || response.status === 403) {
|
|
56
|
+
// Authentication or permission error
|
|
57
|
+
const apiError = {
|
|
58
|
+
status: response.status,
|
|
59
|
+
message: response.statusText,
|
|
60
|
+
platform: 'gitlab',
|
|
61
|
+
operation: 'validate_repo',
|
|
62
|
+
resourceType: 'project',
|
|
63
|
+
resourceName: `${owner}/${repo}`
|
|
64
|
+
};
|
|
65
|
+
const actionable = getActionableError(apiError);
|
|
66
|
+
return { exists: false, valid: false, error: formatActionableError(actionable) };
|
|
67
|
+
}
|
|
68
|
+
// Other error
|
|
69
|
+
const apiError = {
|
|
70
|
+
status: response.status,
|
|
71
|
+
message: response.statusText,
|
|
72
|
+
platform: 'gitlab',
|
|
73
|
+
operation: 'validate_repo',
|
|
74
|
+
resourceType: 'project',
|
|
75
|
+
resourceName: `${owner}/${repo}`
|
|
76
|
+
};
|
|
77
|
+
const actionable = getActionableError(apiError);
|
|
78
|
+
return {
|
|
79
|
+
exists: false,
|
|
80
|
+
valid: false,
|
|
81
|
+
error: formatActionableError(actionable)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
exists: false,
|
|
87
|
+
valid: false,
|
|
88
|
+
error: `Network error: ${error instanceof Error ? error.message : String(error)}`
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validate if a GitLab namespace (user or group) exists
|
|
94
|
+
*/
|
|
95
|
+
async validateOwner(owner, token) {
|
|
96
|
+
const headers = {
|
|
97
|
+
'Accept': 'application/json'
|
|
98
|
+
};
|
|
99
|
+
if (token) {
|
|
100
|
+
headers['PRIVATE-TOKEN'] = token;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
// Try as user first
|
|
104
|
+
const userResponse = await fetch(this.getApiUrl(`/users?username=${encodeURIComponent(owner)}`), { headers });
|
|
105
|
+
if (userResponse.status === 200) {
|
|
106
|
+
const users = await userResponse.json();
|
|
107
|
+
if (users.length > 0) {
|
|
108
|
+
return { valid: true, type: 'user' };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Try as group
|
|
112
|
+
const groupResponse = await fetch(this.getApiUrl(`/groups/${encodeURIComponent(owner)}`), { headers });
|
|
113
|
+
if (groupResponse.status === 200) {
|
|
114
|
+
return { valid: true, type: 'organization' };
|
|
115
|
+
}
|
|
116
|
+
// Not found
|
|
117
|
+
const apiError = {
|
|
118
|
+
status: 404,
|
|
119
|
+
message: 'Not Found',
|
|
120
|
+
platform: 'gitlab',
|
|
121
|
+
operation: 'validate_owner',
|
|
122
|
+
resourceType: 'namespace',
|
|
123
|
+
resourceName: owner
|
|
124
|
+
};
|
|
125
|
+
const actionable = getActionableError(apiError);
|
|
126
|
+
return { valid: false, error: formatActionableError(actionable) };
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
return {
|
|
130
|
+
valid: false,
|
|
131
|
+
error: `Network error: ${error instanceof Error ? error.message : String(error)}`
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Create a new project on GitLab
|
|
137
|
+
*/
|
|
138
|
+
async createRepository(options, token) {
|
|
139
|
+
// Check if it's a group or user namespace
|
|
140
|
+
const isGroup = await this.isOrganization(options.owner, token);
|
|
141
|
+
const payload = {
|
|
142
|
+
name: options.name,
|
|
143
|
+
description: options.description,
|
|
144
|
+
visibility: options.visibility === 'private' ? 'private' :
|
|
145
|
+
options.visibility === 'internal' ? 'internal' : 'public',
|
|
146
|
+
initialize_with_readme: options.autoInit || false,
|
|
147
|
+
issues_enabled: options.hasIssues !== false,
|
|
148
|
+
wiki_enabled: options.hasWiki || false
|
|
149
|
+
};
|
|
150
|
+
// For group projects, specify the namespace_id
|
|
151
|
+
if (isGroup) {
|
|
152
|
+
try {
|
|
153
|
+
const groupResponse = await fetch(this.getApiUrl(`/groups/${encodeURIComponent(options.owner)}`), {
|
|
154
|
+
headers: {
|
|
155
|
+
'PRIVATE-TOKEN': token,
|
|
156
|
+
'Accept': 'application/json'
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
if (groupResponse.ok) {
|
|
160
|
+
const group = await groupResponse.json();
|
|
161
|
+
payload.namespace_id = group.id;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// Continue without namespace_id, will use user's namespace
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const response = await fetch(this.getApiUrl('/projects'), {
|
|
169
|
+
method: 'POST',
|
|
170
|
+
headers: {
|
|
171
|
+
'PRIVATE-TOKEN': token,
|
|
172
|
+
'Accept': 'application/json',
|
|
173
|
+
'Content-Type': 'application/json'
|
|
174
|
+
},
|
|
175
|
+
body: JSON.stringify(payload)
|
|
176
|
+
});
|
|
177
|
+
if (!response.ok) {
|
|
178
|
+
const error = await response.json();
|
|
179
|
+
// Handle "already exists" error
|
|
180
|
+
if (error.message?.name?.[0]?.includes('has already been taken')) {
|
|
181
|
+
// Project already exists, return URL
|
|
182
|
+
const host = this.config.customDomain || this.config.host;
|
|
183
|
+
return `https://${host}/${options.owner}/${options.name}`;
|
|
184
|
+
}
|
|
185
|
+
// Handle other errors with actionable messages
|
|
186
|
+
const apiError = {
|
|
187
|
+
status: response.status,
|
|
188
|
+
message: error.message || response.statusText,
|
|
189
|
+
platform: 'gitlab',
|
|
190
|
+
operation: 'create_repo',
|
|
191
|
+
resourceType: 'project',
|
|
192
|
+
resourceName: `${options.owner}/${options.name}`
|
|
193
|
+
};
|
|
194
|
+
const actionable = getActionableError(apiError);
|
|
195
|
+
throw new Error(formatActionableError(actionable));
|
|
196
|
+
}
|
|
197
|
+
const data = await response.json();
|
|
198
|
+
return data.web_url;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Check if a namespace is a group (organization)
|
|
202
|
+
*/
|
|
203
|
+
async isOrganization(account, token) {
|
|
204
|
+
try {
|
|
205
|
+
const headers = {
|
|
206
|
+
'Accept': 'application/json'
|
|
207
|
+
};
|
|
208
|
+
if (token) {
|
|
209
|
+
headers['PRIVATE-TOKEN'] = token;
|
|
210
|
+
}
|
|
211
|
+
const response = await fetch(this.getApiUrl(`/groups/${encodeURIComponent(account)}`), { headers });
|
|
212
|
+
return response.ok;
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
// Assume user if we can't determine
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get token creation URL
|
|
221
|
+
*/
|
|
222
|
+
getTokenUrl() {
|
|
223
|
+
if (this.config.selfHosted) {
|
|
224
|
+
return `https://${this.config.customDomain || this.config.host}/-/profile/personal_access_tokens`;
|
|
225
|
+
}
|
|
226
|
+
return 'https://gitlab.com/-/profile/personal_access_tokens';
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get required token scopes
|
|
230
|
+
*/
|
|
231
|
+
getRequiredScopes(isOrganization) {
|
|
232
|
+
return ['api', 'read_repository', 'write_repository'];
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Override getAuthHeaders for GitLab-specific auth (PRIVATE-TOKEN)
|
|
236
|
+
*/
|
|
237
|
+
getAuthHeaders(token) {
|
|
238
|
+
return {
|
|
239
|
+
'PRIVATE-TOKEN': token,
|
|
240
|
+
'Accept': 'application/json',
|
|
241
|
+
'Content-Type': 'application/json'
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Create a GitLab provider instance
|
|
247
|
+
*/
|
|
248
|
+
export function createGitLabProvider(config) {
|
|
249
|
+
return new GitLabProvider(config);
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=gitlab-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlab-provider.js","sourceRoot":"","sources":["../../../../../src/core/repo-structure/providers/gitlab-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAsG,MAAM,oBAAoB,CAAC;AACzJ,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAoB,MAAM,yBAAyB,CAAC;AAEtG;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,eAAe;IACjD,YAAY,MAAgC;QAC1C,KAAK,CAAC;YACJ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,YAAY;YAClC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,2BAA2B;YAC7D,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,KAAK;YACvC,YAAY,EAAE,MAAM,EAAE,YAAY;SACnC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB,CACtB,KAAa,EACb,IAAY,EACZ,KAAc;QAEd,IAAI,CAAC;YACH,MAAM,OAAO,GAA2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;YAEF,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC;YACnC,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,IAAI,CAAC,SAAS,CAAC,WAAW,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,EACxD,EAAE,OAAO,EAAE,CACZ,CAAC;YAEF,OAAO,QAAQ,CAAC,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,oCAAoC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC3B,OAAO,WAAW,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,mCAAmC,CAAC;QACpG,CAAC;QACD,OAAO,qDAAqD,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,cAAwB;QACxC,OAAO,CAAC,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,KAAa;QACpC,OAAO;YACL,eAAe,EAAE,KAAK;YACtB,QAAQ,EAAE,kBAAkB;YAC5B,cAAc,EAAE,kBAAkB;SACnC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAgC;IACnE,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Providers Index
|
|
3
|
+
*
|
|
4
|
+
* Exports all Git provider implementations and provides
|
|
5
|
+
* initialization functions.
|
|
6
|
+
*
|
|
7
|
+
* @module providers
|
|
8
|
+
*/
|
|
9
|
+
export { GitHubProvider, createGitHubProvider } from './github-provider.js';
|
|
10
|
+
export { GitLabProvider, createGitLabProvider } from './gitlab-provider.js';
|
|
11
|
+
export { BitbucketProvider, createBitbucketProvider } from './bitbucket-provider.js';
|
|
12
|
+
export { AzureDevOpsProvider, createAzureDevOpsProvider } from './azure-devops-provider.js';
|
|
13
|
+
export { LocalGitProvider, createLocalGitProvider } from './local-provider.js';
|
|
14
|
+
/**
|
|
15
|
+
* Initialize and register all Git providers
|
|
16
|
+
*
|
|
17
|
+
* Call this once during application initialization to make
|
|
18
|
+
* all providers available through the platform registry.
|
|
19
|
+
*
|
|
20
|
+
* Idempotent: Safe to call multiple times - only initializes once.
|
|
21
|
+
*/
|
|
22
|
+
export declare function initializeProviders(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Reset provider initialization state (for testing only)
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function resetProviders(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get provider by platform type (convenience function)
|
|
30
|
+
*
|
|
31
|
+
* @param platform - Platform type
|
|
32
|
+
* @returns Provider instance or undefined
|
|
33
|
+
*/
|
|
34
|
+
export declare function getProvider(platform: 'github' | 'gitlab' | 'bitbucket' | 'azure-devops' | 'local'): import("../git-provider.js").GitProvider;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/repo-structure/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAe/E;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAwB1C;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,GAAG,OAAO,4CAGjG"}
|