-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1224 from rainlanguage/1223-optionally-provide-en…
…tire-dotrian-document-in-deploy-mode Add textbox for raw strat
- Loading branch information
Showing
8 changed files
with
197 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { writable } from 'svelte/store'; | ||
|
||
export const rawDotrain = writable(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { writable } from 'svelte/store'; | ||
|
||
export const registryUrl = writable<string>( | ||
'https://raw.githubusercontent.com/rainlanguage/rain.strategies/refs/heads/main/strategies/dev/registry' | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 46 additions & 47 deletions
93
packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
export const getFileRegistry = async (url: string) => { | ||
try { | ||
const response = await fetch(url); | ||
if (!response.ok) { | ||
throw new Error('Failed to fetch registry.'); | ||
} | ||
const filesList = await response.text(); | ||
const files = filesList | ||
.split('\n') | ||
.filter((line) => line.trim()) | ||
.map((line) => { | ||
const [name, url] = line.split(' '); | ||
return { name, url }; | ||
}); | ||
if (!files) { | ||
throw new Error('Invalid stategy registry.'); | ||
} | ||
return files; | ||
} catch (e) { | ||
throw new Error(e instanceof Error ? e.message : 'Unknown error.'); | ||
} | ||
}; | ||
|
||
if (import.meta.vitest) { | ||
const { describe, it, expect, vi } = import.meta.vitest; | ||
|
||
describe('getFileRegistry', () => { | ||
it('should parse registry file content correctly', async () => { | ||
const mockResponse = `file1.js https://example.com/file1.js | ||
file2.js https://example.com/file2.js`; | ||
|
||
global.fetch = vi.fn().mockResolvedValue({ | ||
ok: true, | ||
text: () => Promise.resolve(mockResponse) | ||
}); | ||
|
||
const result = await getFileRegistry('https://example.com/registry'); | ||
expect(result).toEqual([ | ||
{ name: 'file1.js', url: 'https://example.com/file1.js' }, | ||
{ name: 'file2.js', url: 'https://example.com/file2.js' } | ||
]); | ||
}); | ||
|
||
it('should handle failed fetch response', async () => { | ||
global.fetch = vi.fn().mockResolvedValue({ | ||
ok: false | ||
}); | ||
|
||
await expect(getFileRegistry('https://example.com/registry')).rejects.toThrow( | ||
'Failed to fetch registry' | ||
); | ||
}); | ||
|
||
it('should handle network errors', async () => { | ||
global.fetch = vi.fn().mockRejectedValue(new Error('Network error')); | ||
|
||
await expect(getFileRegistry('https://example.com/registry')).rejects.toThrow( | ||
'Network error' | ||
); | ||
}); | ||
}); | ||
} |