@@ -16,10 +16,10 @@ export const GET: RequestHandler = async ({ platform, params }) => {
1616 }
1717
1818 const config = await env . DB . prepare (
19- 'SELECT slug, name, base_preset, packages, is_public, dotfiles_repo FROM configs WHERE user_id = ? AND slug = ?'
19+ 'SELECT slug, name, base_preset, packages, snapshot, is_public, dotfiles_repo FROM configs WHERE user_id = ? AND slug = ?'
2020 )
2121 . bind ( user . id , params . slug )
22- . first < { slug : string ; name : string ; base_preset : string ; packages : string ; is_public : number ; dotfiles_repo : string } > ( ) ;
22+ . first < { slug : string ; name : string ; base_preset : string ; packages : string ; snapshot : string ; is_public : number ; dotfiles_repo : string } > ( ) ;
2323
2424 if ( ! config ) {
2525 return json ( { error : 'Config not found' } , { status : 404 } ) ;
@@ -29,13 +29,32 @@ export const GET: RequestHandler = async ({ platform, params }) => {
2929 return json ( { error : 'Config is private' } , { status : 403 } ) ;
3030 }
3131
32+ const tapsSet = new Set < string > ( ) ;
33+ const snapshotCasks = new Set < string > ( ) ;
34+
35+ if ( config . snapshot ) {
36+ try {
37+ const snapshot = JSON . parse ( config . snapshot ) ;
38+ for ( const tap of snapshot . packages ?. taps || [ ] ) {
39+ tapsSet . add ( tap ) ;
40+ }
41+ for ( const cask of snapshot . packages ?. casks || [ ] ) {
42+ snapshotCasks . add ( cask ) ;
43+ }
44+ } catch {
45+ }
46+ }
47+
3248 const rawPackages : any [ ] = JSON . parse ( config . packages || '[]' ) ;
3349 const packageNames : string [ ] = [ ] ;
3450 const caskNames : string [ ] = [ ] ;
3551
3652 for ( const pkg of rawPackages ) {
3753 if ( typeof pkg === 'string' ) {
3854 packageNames . push ( pkg ) ;
55+ if ( snapshotCasks . has ( pkg ) ) {
56+ caskNames . push ( pkg ) ;
57+ }
3958 } else {
4059 packageNames . push ( pkg . name ) ;
4160 if ( pkg . type === 'cask' ) {
@@ -44,32 +63,13 @@ export const GET: RequestHandler = async ({ platform, params }) => {
4463 }
4564 }
4665
47- const tapsSet = new Set < string > ( ) ;
48-
4966 for ( const pkg of packageNames ) {
5067 const parts = pkg . split ( '/' ) ;
5168 if ( parts . length === 3 ) {
5269 tapsSet . add ( `${ parts [ 0 ] } /${ parts [ 1 ] } ` ) ;
5370 }
5471 }
5572
56- const snapshotRow = await env . DB . prepare (
57- 'SELECT snapshot FROM configs WHERE user_id = ? AND slug = ?'
58- )
59- . bind ( user . id , params . slug )
60- . first < { snapshot : string } > ( ) ;
61-
62- if ( snapshotRow ?. snapshot ) {
63- try {
64- const snapshot = JSON . parse ( snapshotRow . snapshot ) ;
65- const snapshotTaps = snapshot . packages ?. taps || [ ] ;
66- for ( const tap of snapshotTaps ) {
67- tapsSet . add ( tap ) ;
68- }
69- } catch {
70- }
71- }
72-
7373 const taps = Array . from ( tapsSet ) ;
7474
7575 return json ( {
0 commit comments