@@ -45,47 +45,51 @@ export const updaterRouter = router({
45
45
const api = await ( await import ( "@/lib/api/server" ) ) . createCaller ( ctx ) ;
46
46
47
47
for ( const pkg of input . pkgs ) {
48
- const plugin = await db . swcPlugin . upsert ( {
49
- where : {
50
- name : pkg . name ,
51
- } ,
52
- create : {
53
- name : pkg . name ,
54
- } ,
55
- update : { } ,
56
- } ) ;
57
-
58
- for ( const version of pkg . versions ) {
59
- const swcCoreVersion = version . swcCoreVersion ;
60
- const compatRange = await api . compatRange . byCoreVersion ( {
61
- version : swcCoreVersion ,
48
+ try {
49
+ const plugin = await db . swcPlugin . upsert ( {
50
+ where : {
51
+ name : pkg . name ,
52
+ } ,
53
+ create : {
54
+ name : pkg . name ,
55
+ } ,
56
+ update : { } ,
62
57
} ) ;
63
58
64
- if ( ! compatRange ) {
65
- throw new TRPCError ( {
66
- code : "NOT_FOUND" ,
67
- message : `Compat range not found for SWC core version ${ swcCoreVersion } ` ,
59
+ for ( const version of pkg . versions ) {
60
+ const swcCoreVersion = version . swcCoreVersion ;
61
+ const compatRange = await api . compatRange . byCoreVersion ( {
62
+ version : swcCoreVersion ,
68
63
} ) ;
69
- }
70
64
71
- await db . swcPluginVersion . upsert ( {
72
- where : {
73
- pluginId_version : {
65
+ if ( ! compatRange ) {
66
+ throw new TRPCError ( {
67
+ code : "NOT_FOUND" ,
68
+ message : `Compat range not found for SWC core version ${ swcCoreVersion } ` ,
69
+ } ) ;
70
+ }
71
+
72
+ await db . swcPluginVersion . upsert ( {
73
+ where : {
74
+ pluginId_version : {
75
+ pluginId : plugin . id ,
76
+ version : version . version ,
77
+ } ,
78
+ } ,
79
+ create : {
74
80
pluginId : plugin . id ,
75
81
version : version . version ,
82
+ compatRangeId : compatRange . id ,
83
+ swcCoreVersion,
76
84
} ,
77
- } ,
78
- create : {
79
- pluginId : plugin . id ,
80
- version : version . version ,
81
- compatRangeId : compatRange . id ,
82
- swcCoreVersion,
83
- } ,
84
- update : {
85
- compatRangeId : compatRange . id ,
86
- swcCoreVersion,
87
- } ,
88
- } ) ;
85
+ update : {
86
+ compatRangeId : compatRange . id ,
87
+ swcCoreVersion,
88
+ } ,
89
+ } ) ;
90
+ }
91
+ } catch ( e ) {
92
+ console . error ( `Error updating wasm plugins for ${ pkg . name } ` , e ) ;
89
93
}
90
94
}
91
95
} ) ,
@@ -117,45 +121,49 @@ export const updaterRouter = router({
117
121
}
118
122
119
123
for ( const pkg of input . pkgs ) {
120
- const runtime = await db . swcRuntime . upsert ( {
121
- where : {
122
- name : pkg . name ,
123
- } ,
124
- create : {
125
- name : pkg . name ,
126
- } ,
127
- update : { } ,
128
- } ) ;
129
-
130
- for ( const version of pkg . versions ) {
131
- const swcCoreVersion = version . swcCoreVersion ;
132
- const compatRange = byVersion ( swcCoreVersion ) ;
133
-
134
- if ( ! compatRange ) {
135
- throw new TRPCError ( {
136
- code : "NOT_FOUND" ,
137
- message : `Compat range not found for SWC core version ${ swcCoreVersion } ` ,
138
- } ) ;
139
- }
140
-
141
- await db . swcRuntimeVersion . upsert ( {
124
+ try {
125
+ const runtime = await db . swcRuntime . upsert ( {
142
126
where : {
143
- runtimeId_version : {
144
- runtimeId : runtime . id ,
145
- version : version . version ,
146
- } ,
127
+ name : pkg . name ,
147
128
} ,
148
129
create : {
149
- runtimeId : runtime . id ,
150
- version : version . version ,
151
- compatRangeId : compatRange . id ,
152
- swcCoreVersion,
153
- } ,
154
- update : {
155
- compatRangeId : compatRange . id ,
156
- swcCoreVersion,
130
+ name : pkg . name ,
157
131
} ,
132
+ update : { } ,
158
133
} ) ;
134
+
135
+ for ( const version of pkg . versions ) {
136
+ const swcCoreVersion = version . swcCoreVersion ;
137
+ const compatRange = byVersion ( swcCoreVersion ) ;
138
+
139
+ if ( ! compatRange ) {
140
+ throw new TRPCError ( {
141
+ code : "NOT_FOUND" ,
142
+ message : `Compat range not found for SWC core version ${ swcCoreVersion } ` ,
143
+ } ) ;
144
+ }
145
+
146
+ await db . swcRuntimeVersion . upsert ( {
147
+ where : {
148
+ runtimeId_version : {
149
+ runtimeId : runtime . id ,
150
+ version : version . version ,
151
+ } ,
152
+ } ,
153
+ create : {
154
+ runtimeId : runtime . id ,
155
+ version : version . version ,
156
+ compatRangeId : compatRange . id ,
157
+ swcCoreVersion,
158
+ } ,
159
+ update : {
160
+ compatRangeId : compatRange . id ,
161
+ swcCoreVersion,
162
+ } ,
163
+ } ) ;
164
+ }
165
+ } catch ( e ) {
166
+ console . error ( `Error updating runtimes for ${ pkg . name } ` , e ) ;
159
167
}
160
168
}
161
169
} ) ,
0 commit comments