@lovelybunch/api 1.0.69-alpha.5 → 1.0.69-alpha.6

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/lib/git.d.ts CHANGED
@@ -43,7 +43,8 @@ export declare function getCredentialConfig(): Promise<{
43
43
  helper?: string;
44
44
  origin?: string;
45
45
  }>;
46
- export declare function storeCredentials(username: string, password: string): Promise<void>;
46
+ export declare function setRemoteUrl(remoteUrl: string): Promise<void>;
47
+ export declare function storeCredentials(username: string, password: string, remoteUrl?: string): Promise<void>;
47
48
  export interface WorktreeInfo {
48
49
  name: string;
49
50
  path: string;
package/dist/lib/git.js CHANGED
@@ -211,10 +211,41 @@ export async function getCredentialConfig() {
211
211
  return {};
212
212
  }
213
213
  }
214
- export async function storeCredentials(username, password) {
214
+ export async function setRemoteUrl(remoteUrl) {
215
+ // Validate the remote URL
216
+ if (!remoteUrl.trim()) {
217
+ throw new Error('Remote URL is required');
218
+ }
219
+ const trimmed = remoteUrl.trim();
220
+ // Check if it's a valid URL format
221
+ if (!trimmed.startsWith('https://') && !trimmed.startsWith('http://') && !trimmed.startsWith('git@')) {
222
+ throw new Error('Remote URL must start with https://, http://, or git@');
223
+ }
224
+ // Check if origin already exists
225
+ try {
226
+ await runGit(['config', '--get', 'remote.origin.url']);
227
+ // If we get here, origin exists, so update it
228
+ await runGit(['remote', 'set-url', 'origin', trimmed]);
229
+ }
230
+ catch {
231
+ // Origin doesn't exist, add it
232
+ await runGit(['remote', 'add', 'origin', trimmed]);
233
+ }
234
+ }
235
+ export async function storeCredentials(username, password, remoteUrl) {
236
+ // If a remote URL is provided, set it first
237
+ if (remoteUrl && remoteUrl.trim()) {
238
+ await setRemoteUrl(remoteUrl);
239
+ }
215
240
  // Get remote URL to determine protocol and host
216
- const { stdout: remoteUrl } = await runGit(['config', '--get', 'remote.origin.url']);
217
- const remote = remoteUrl.trim();
241
+ let remote;
242
+ try {
243
+ const { stdout: remoteUrlOutput } = await runGit(['config', '--get', 'remote.origin.url']);
244
+ remote = remoteUrlOutput.trim();
245
+ }
246
+ catch {
247
+ throw new Error('No git remote configured. Please provide a remote URL.');
248
+ }
218
249
  // Parse the remote URL to extract protocol and host
219
250
  let protocol = 'https';
220
251
  let host = '';
@@ -84,10 +84,11 @@ app.post('/credentials', async (c) => {
84
84
  const body = await c.req.json();
85
85
  const username = String(body?.username || '');
86
86
  const password = String(body?.password || '');
87
+ const remoteUrl = body?.remoteUrl ? String(body.remoteUrl) : undefined;
87
88
  if (!username || !password) {
88
89
  return c.json({ success: false, error: { message: 'Username and password are required' } }, 400);
89
90
  }
90
- await storeCredentials(username, password);
91
+ await storeCredentials(username, password, remoteUrl);
91
92
  return c.json({ success: true, data: { message: 'Credentials stored successfully' } });
92
93
  }
93
94
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovelybunch/api",
3
- "version": "1.0.69-alpha.5",
3
+ "version": "1.0.69-alpha.6",
4
4
  "type": "module",
5
5
  "main": "dist/server-with-static.js",
6
6
  "exports": {
@@ -36,9 +36,9 @@
36
36
  "dependencies": {
37
37
  "@hono/node-server": "^1.13.7",
38
38
  "@hono/node-ws": "^1.0.6",
39
- "@lovelybunch/core": "^1.0.69-alpha.5",
40
- "@lovelybunch/mcp": "^1.0.69-alpha.5",
41
- "@lovelybunch/types": "^1.0.69-alpha.5",
39
+ "@lovelybunch/core": "^1.0.69-alpha.6",
40
+ "@lovelybunch/mcp": "^1.0.69-alpha.6",
41
+ "@lovelybunch/types": "^1.0.69-alpha.6",
42
42
  "arctic": "^1.9.2",
43
43
  "bcrypt": "^5.1.1",
44
44
  "cookie": "^0.6.0",