-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
373 lines (358 loc) · 14.3 KB
/
index.html
File metadata and controls
373 lines (358 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Git Automation Dashboard</title>
<script src="https://cdn.tailwindcss.com?plugins=typography"></script>
<script>
// Must be in the <head> to configure Tailwind before it loads.
tailwind.config = {
darkMode: 'class',
}
</script>
<style>
:root {
--title-bar-height: 2rem; /* h-8 */
--status-bar-height: 1.75rem; /* Equivalent to h-7 in Tailwind */
}
</style>
<script>
(function bootstrapBrowserMocks() {
if (window.electronAPI) {
return;
}
const storageKeys = {
settings: 'ga-browser-globalSettings',
repositories: 'ga-browser-repositories',
categories: 'ga-browser-categories',
uncategorized: 'ga-browser-uncategorizedOrder',
};
const readFromStorage = (key, fallback) => {
try {
const raw = localStorage.getItem(key);
return raw ? JSON.parse(raw) : fallback;
} catch (error) {
console.warn('Failed to read demo data from localStorage', error);
return fallback;
}
};
const writeToStorage = (key, value) => {
try {
localStorage.setItem(key, JSON.stringify(value));
} catch (error) {
console.warn('Failed to persist demo data to localStorage', error);
}
};
const sampleRepositories = [
{
id: 'repo-ui-stability',
name: 'UI Stability Dashboard',
remoteUrl: 'https://example.com/engineering/ui-stability.git',
localPath: '/Users/dev/projects/ui-stability',
status: 'Idle',
lastUpdated: new Date(Date.now() - 1000 * 60 * 42).toISOString(),
buildHealth: 'Healthy',
tasks: [
{ id: 'task-run-tests', name: 'Run Tests', steps: [], variables: [], environmentVariables: [], showOnDashboard: true },
{ id: 'task-build-app', name: 'Build App', steps: [], variables: [], environmentVariables: [], showOnDashboard: true },
],
webLinks: [
{ id: 'docs', name: 'Design System', url: 'https://example.com/design-system' },
],
launchConfigs: [
{ id: 'launch-dev', name: 'Start Dev Server', type: 'command', command: 'npm run dev', showOnDashboard: true },
{ id: 'launch-storybook', name: 'Storybook', type: 'command', command: 'npm run storybook', showOnDashboard: false },
],
vcs: 'git',
branch: 'main',
},
{
id: 'repo-automation-service',
name: 'Automation Service',
remoteUrl: 'https://example.com/platform/automation.git',
localPath: '/Users/dev/projects/automation-service',
status: 'Success',
lastUpdated: new Date(Date.now() - 1000 * 60 * 5).toISOString(),
buildHealth: 'Healthy',
tasks: [
{ id: 'task-deploy', name: 'Deploy', steps: [], variables: [], environmentVariables: [], showOnDashboard: true },
],
webLinks: [
{ id: 'status', name: 'Status Page', url: 'https://status.example.com' },
],
launchConfigs: [
{ id: 'launch-api', name: 'Run API', type: 'command', command: 'npm run start', showOnDashboard: true },
],
vcs: 'git',
branch: 'develop',
},
];
const sampleCategories = [
{
id: 'category-frontend',
name: 'Frontend',
repositoryIds: ['repo-ui-stability'],
backgroundColor: 'rgba(59, 130, 246, 0.08)',
darkBackgroundColor: 'rgba(59, 130, 246, 0.18)',
},
];
const defaultData = {
globalSettings: null,
repositories: sampleRepositories,
categories: sampleCategories,
uncategorizedOrder: ['repo-automation-service'],
};
const ensureSeedData = () => {
const repositories = readFromStorage(storageKeys.repositories, null);
if (!repositories) {
writeToStorage(storageKeys.repositories, defaultData.repositories);
writeToStorage(storageKeys.categories, defaultData.categories);
writeToStorage(storageKeys.uncategorized, defaultData.uncategorizedOrder);
}
if (!readFromStorage(storageKeys.settings, null)) {
writeToStorage(storageKeys.settings, defaultData.globalSettings);
}
};
ensureSeedData();
const repoIdByPath = new Map(sampleRepositories.map(repo => [repo.localPath, repo.id]));
const refreshIndexByRepo = new Map(sampleRepositories.map(repo => [repo.id, 0]));
const detailedStatusSamples = [
{
files: { added: 0, modified: 3, deleted: 0, conflicted: 0, untracked: 1, renamed: 0 },
isDirty: true,
branchInfo: { ahead: 0, behind: 2, tracking: 'origin/main' },
updatesAvailable: false,
},
{
files: { added: 1, modified: 1, deleted: 0, conflicted: 0, untracked: 0, renamed: 0 },
isDirty: true,
branchInfo: { ahead: 1, behind: 0, tracking: 'origin/main' },
updatesAvailable: false,
},
];
const branchSamples = [
{
current: 'main',
local: ['main', 'feature/stable-refresh', 'release/1.2.0'],
remote: ['origin/main', 'origin/feature/stable-refresh', 'origin/release/1.2.0'],
},
{
current: 'feature/stable-refresh',
local: ['main', 'feature/stable-refresh', 'release/1.2.0'],
remote: ['origin/main', 'origin/feature/stable-refresh', 'origin/release/1.2.0'],
},
];
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
window.electronAPI = {
async getAllData() {
return {
globalSettings: readFromStorage(storageKeys.settings, defaultData.globalSettings),
repositories: readFromStorage(storageKeys.repositories, defaultData.repositories),
categories: readFromStorage(storageKeys.categories, defaultData.categories),
uncategorizedOrder: readFromStorage(storageKeys.uncategorized, defaultData.uncategorizedOrder),
};
},
async saveAllData(payload) {
writeToStorage(storageKeys.settings, payload.globalSettings);
writeToStorage(storageKeys.repositories, payload.repositories);
writeToStorage(storageKeys.categories, payload.categories);
writeToStorage(storageKeys.uncategorized, payload.uncategorizedOrder);
},
async checkLocalPath() {
await delay(150);
return 'valid';
},
async getProjectInfo(repoPath) {
await delay(200);
const repoId = repoIdByPath.get(repoPath);
const nodeCapabilities = {
engine: 'node@20.10.0',
declaredManager: 'npm',
packageManagers: { pnpm: true, yarn: false, npm: true, bun: false },
typescript: true,
testFrameworks: ['vitest'],
linters: ['eslint', 'prettier'],
bundlers: ['vite'],
monorepo: { workspaces: false, turbo: false, nx: false, yarnBerryPnp: false },
};
if (repoId === 'repo-ui-stability') {
return {
tags: ['node', 'react', 'frontend'],
files: { dproj: [], pomXml: [], csproj: [], sln: [] },
nodejs: nodeCapabilities,
};
}
return {
tags: ['node', 'service'],
files: { dproj: [], pomXml: [], csproj: [], sln: [] },
nodejs: {
...nodeCapabilities,
testFrameworks: ['jest'],
},
docker: {
composeFiles: ['docker-compose.yml'],
dockerfiles: ['Dockerfile'],
},
};
},
async getProjectSuggestions({ repoPath }) {
await delay(120);
const repoId = repoIdByPath.get(repoPath);
if (repoId === 'repo-ui-stability') {
return [
{ label: 'Run lint', value: 'npm run lint', group: 'npm scripts' },
{ label: 'Launch Storybook', value: 'npm run storybook', group: 'npm scripts' },
];
}
return [
{ label: 'Run integration tests', value: 'npm run test:integration', group: 'npm scripts' },
{ label: 'Start API locally', value: 'npm run dev', group: 'npm scripts' },
];
},
async getDelphiVersions() {
await delay(50);
return [];
},
async getDetailedVcsStatus(repo) {
await delay(350);
const nextIndex = refreshIndexByRepo.get(repo.id) === 1 ? 0 : 1;
refreshIndexByRepo.set(repo.id, nextIndex);
return detailedStatusSamples[nextIndex];
},
async listBranches({ repoPath }) {
await delay(250);
const repoId = repoIdByPath.get(repoPath);
const index = repoId ? refreshIndexByRepo.get(repoId) ?? 0 : 0;
return branchSamples[index];
},
async pruneRemoteBranches() {
await delay(150);
console.info('Simulated pruning stale remote branches');
return { success: true, message: 'Simulated prune completed.' };
},
async cleanupLocalBranches() {
await delay(150);
console.info('Simulated cleanup of merged or stale local branches');
return { success: true, message: 'Simulated cleanup completed.' };
},
async getGithubPat() {
await delay(100);
return '';
},
async getAllReleases() {
await delay(200);
return [
{
id: 1,
tagName: 'v1.1.0',
name: 'Stability Improvements',
body: 'Improved caching and added new dashboards.',
isDraft: false,
isPrerelease: false,
url: 'https://example.com/releases/v1.1.0',
createdAt: new Date(Date.now() - 1000 * 60 * 60 * 24 * 14).toISOString(),
},
];
},
async updateRelease() {
await delay(150);
return { success: true };
},
async createRelease() {
await delay(150);
return { success: true };
},
async deleteRelease() {
await delay(150);
return { success: true };
},
async discoverRemoteUrl({ localPath }) {
await delay(120);
const repoId = repoIdByPath.get(localPath);
const repo = sampleRepositories.find(r => r.id === repoId);
return { url: repo?.remoteUrl ?? null };
},
async showDirectoryPicker() {
await delay(80);
return { canceled: false, filePaths: ['/Users/dev/projects'] };
},
async getLatestRelease() {
await delay(200);
return {
id: 1,
tagName: 'v1.2.0',
name: 'Stable Refresh',
body: null,
isDraft: false,
isPrerelease: false,
url: 'https://example.com/releases/v1.2.0',
createdAt: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(),
};
},
async openWeblink(url) {
window.open(url, '_blank', 'noopener');
},
async openInstallationFolder() {
console.info('Requested to open installation folder');
},
async openLocalPath(path) {
console.info('Requested to open local path:', path);
},
async openTerminal(path) {
console.info('Requested to open terminal at:', path);
},
async runTaskStep() {
console.info('Simulated task step execution');
},
onWindowMaximizedStatus() {},
removeWindowMaximizedStatusListener() {},
windowMinimize() {},
windowMaximize() {},
windowClose() {},
onTaskLog() {},
removeTaskLogListener() {},
onTaskStepEnd() {},
removeTaskStepEndListener() {},
cancelTaskExecution() {},
cloneRepository() {},
launchApplication() {},
launchExecutable() {},
checkVcsStatus: async () => ({ status: 'clean' }),
detectExecutables: async () => ['npm', 'pnpm'],
onUpdateStatusChange() {},
removeUpdateStatusChangeListener() {},
getAppVersion: async () => 'browser-demo',
onLogFromMain() {},
removeLogFromMainListener() {},
};
})();
</script>
<script type="importmap">
{
"imports": {
"react/": "https://aistudiocdn.com/react@^19.1.1/",
"react": "https://aistudiocdn.com/react@^19.1.1",
"electron": "https://aistudiocdn.com/electron@^37.4.0",
"react-dom/": "https://aistudiocdn.com/react-dom@^19.1.1/",
"path": "https://aistudiocdn.com/path@^0.12.7",
"os": "https://aistudiocdn.com/os@^0.1.2",
"electron-updater": "https://aistudiocdn.com/electron-updater@^6.6.2",
"react-markdown": "https://aistudiocdn.com/react-markdown@^10.1.0",
"remark-gfm": "https://aistudiocdn.com/remark-gfm@^4.0.1",
"fs/": "https://aistudiocdn.com/fs@^0.0.1-security/",
"child_process": "https://aistudiocdn.com/child_process@^1.0.2",
"react-dom": "https://aistudiocdn.com/react-dom@^19.1.1",
"fs": "https://aistudiocdn.com/fs@^0.0.1-security",
"@google/genai": "https://aistudiocdn.com/@google/genai@^1.16.0",
"jszip": "https://aistudiocdn.com/jszip@^3.10.1"
}
}
</script>
</head>
<body class="bg-gray-100 dark:bg-gray-900 text-gray-800 dark:text-gray-100">
<div id="root"></div>
<script defer src="./renderer.js"></script>
</body>
</html>