aiex-cli 0.0.0
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/LICENSE.md +21 -0
- package/README.md +118 -0
- package/bin/cli.mjs +2 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +9948 -0
- package/dist/core/schema-sqlite/migrate-helper.d.mts +1 -0
- package/dist/core/schema-sqlite/migrate-helper.mjs +190 -0
- package/dist/doctor-Wic10PLt.mjs +711 -0
- package/dist/index.d.mts +281 -0
- package/dist/index.mjs +3 -0
- package/dist/table-schema.json +220 -0
- package/dist/web/assets/abap-Cry0R76c.js +1 -0
- package/dist/web/assets/apex-xqbJ58nJ.js +1 -0
- package/dist/web/assets/azcli-D7JTNGKs.js +1 -0
- package/dist/web/assets/bat-Cuq6hn0K.js +1 -0
- package/dist/web/assets/bicep-eTuQjz9F.js +2 -0
- package/dist/web/assets/cameligo-DKgCRl36.js +1 -0
- package/dist/web/assets/chunk-BEqpzyXh.js +1 -0
- package/dist/web/assets/clojure-B_aTBtVh.js +1 -0
- package/dist/web/assets/codicon-DCmgc-ay.ttf +0 -0
- package/dist/web/assets/coffee-BWAYpIPu.js +1 -0
- package/dist/web/assets/cpp-BduBQE8d.js +1 -0
- package/dist/web/assets/csharp-CMqOVYKK.js +1 -0
- package/dist/web/assets/csp-6cGliXw2.js +1 -0
- package/dist/web/assets/css-CHnKqS9Q.js +3 -0
- package/dist/web/assets/cssMode-BloHqzZF.js +4 -0
- package/dist/web/assets/cypher-DMzZBj2L.js +1 -0
- package/dist/web/assets/dart-7hYfJ1Dv.js +1 -0
- package/dist/web/assets/dockerfile-BflvjnJW.js +1 -0
- package/dist/web/assets/ecl-BEt6xb2p.js +1 -0
- package/dist/web/assets/editor-BR-TvLsg.css +1 -0
- package/dist/web/assets/editor-DPKWm9GW.css +1 -0
- package/dist/web/assets/editor.api-BG499EJF.js +642 -0
- package/dist/web/assets/editor.main-BhEWG0_P.js +53 -0
- package/dist/web/assets/editor.worker-DwXe4U6w.js +12 -0
- package/dist/web/assets/elixir-CnrQCt6o.js +1 -0
- package/dist/web/assets/flow9-CfLCoUuB.js +1 -0
- package/dist/web/assets/freemarker2-DOHaFATh.js +3 -0
- package/dist/web/assets/fsharp-BQqR9uQ6.js +1 -0
- package/dist/web/assets/go-C3AlMVwy.js +1 -0
- package/dist/web/assets/graphql-O_-hDldf.js +1 -0
- package/dist/web/assets/handlebars-BIFWety9.js +1 -0
- package/dist/web/assets/hcl-BQQD6Mtj.js +1 -0
- package/dist/web/assets/html-YGaqGZNd.js +1 -0
- package/dist/web/assets/htmlMode-Bu3PyHjq.js +4 -0
- package/dist/web/assets/index-Bi376XVf.css +2 -0
- package/dist/web/assets/index-c6KB-9C-.js +3262 -0
- package/dist/web/assets/ini-Bf0RDfP_.js +1 -0
- package/dist/web/assets/java-nqX2KEDD.js +1 -0
- package/dist/web/assets/javascript-N0gZqDK0.js +1 -0
- package/dist/web/assets/json.worker-DhD1Scrm.js +51 -0
- package/dist/web/assets/jsonMode-z5YscjcG.js +10 -0
- package/dist/web/assets/julia-B6P9U5er.js +1 -0
- package/dist/web/assets/kotlin-B-LRk09-.js +1 -0
- package/dist/web/assets/less-CEaIdW1f.js +2 -0
- package/dist/web/assets/lexon-Qv4pvFSW.js +1 -0
- package/dist/web/assets/liquid-BHfNNVLs.js +1 -0
- package/dist/web/assets/lua-CFpyR7YN.js +1 -0
- package/dist/web/assets/m3-CvKhVPQn.js +1 -0
- package/dist/web/assets/markdown-qldG3Vc4.js +1 -0
- package/dist/web/assets/mdx-Dqu2t0et.js +1 -0
- package/dist/web/assets/mips-0D8PRyHq.js +1 -0
- package/dist/web/assets/monaco.contribution-ByQ3yI-W.js +2 -0
- package/dist/web/assets/msdax-DwZXSC5M.js +1 -0
- package/dist/web/assets/mysql-BWq85KY4.js +1 -0
- package/dist/web/assets/objective-c-D653JUMG.js +1 -0
- package/dist/web/assets/pascal-rWjRDdnR.js +1 -0
- package/dist/web/assets/pascaligo-Db8EehaF.js +1 -0
- package/dist/web/assets/perl-C68oq8-D.js +1 -0
- package/dist/web/assets/pgsql-BXeHe33s.js +1 -0
- package/dist/web/assets/php-CDVsAbfl.js +1 -0
- package/dist/web/assets/pla-DnryFT0q.js +1 -0
- package/dist/web/assets/postiats-CDg_4Ev-.js +1 -0
- package/dist/web/assets/powerquery-CWPi8ROz.js +1 -0
- package/dist/web/assets/powershell-C5A0QX3-.js +1 -0
- package/dist/web/assets/preload-helper-DSXbuxSR.js +1 -0
- package/dist/web/assets/primeicons-C6QP2o4f.woff2 +0 -0
- package/dist/web/assets/primeicons-DMOk5skT.eot +0 -0
- package/dist/web/assets/primeicons-Dr5RGzOO.svg +345 -0
- package/dist/web/assets/primeicons-MpK4pl85.ttf +0 -0
- package/dist/web/assets/primeicons-WjwUDZjB.woff +0 -0
- package/dist/web/assets/protobuf-Cgt-BQbL.js +2 -0
- package/dist/web/assets/pug-RPYJC9QB.js +1 -0
- package/dist/web/assets/python-icfse9Ji.js +1 -0
- package/dist/web/assets/qsharp-BZ3S7fu_.js +1 -0
- package/dist/web/assets/r-CN875f1X.js +1 -0
- package/dist/web/assets/razor-DwVkryG9.js +1 -0
- package/dist/web/assets/redis-BLesvTwR.js +1 -0
- package/dist/web/assets/redshift-Byf_0XqD.js +1 -0
- package/dist/web/assets/restructuredtext-DYg_6BiZ.js +1 -0
- package/dist/web/assets/ruby-C4OkxbC-.js +1 -0
- package/dist/web/assets/rust-xAoaEFMh.js +1 -0
- package/dist/web/assets/sb-C8dHOW_y.js +1 -0
- package/dist/web/assets/scala-Spx0wP1o.js +1 -0
- package/dist/web/assets/scheme-D2mZlAUz.js +1 -0
- package/dist/web/assets/scss-DDCn3Ylu.js +3 -0
- package/dist/web/assets/shell-M6px0EWn.js +1 -0
- package/dist/web/assets/solidity-DUWMJi-f.js +1 -0
- package/dist/web/assets/sophia-DwJbUG-2.js +1 -0
- package/dist/web/assets/sparql-ClQxbRPI.js +1 -0
- package/dist/web/assets/sql-BQdjW7Vy.js +1 -0
- package/dist/web/assets/st-BpISyZ_v.js +1 -0
- package/dist/web/assets/swift-CMbl5gM4.js +1 -0
- package/dist/web/assets/systemverilog-jx2Xs7uO.js +1 -0
- package/dist/web/assets/tcl-GIGnfs89.js +1 -0
- package/dist/web/assets/tsMode-CLrI3bdf.js +11 -0
- package/dist/web/assets/twig-Bc0mxc_m.js +1 -0
- package/dist/web/assets/typescript-BzuZVF7m.js +1 -0
- package/dist/web/assets/typespec-CEioAsEm.js +1 -0
- package/dist/web/assets/vb-BPk67J-d.js +1 -0
- package/dist/web/assets/wgsl-DOnyt8_J.js +298 -0
- package/dist/web/assets/xml-Cr85kdqA.js +1 -0
- package/dist/web/assets/yaml-D3RbJnnO.js +1 -0
- package/dist/web/index.html +25 -0
- package/package.json +86 -0
- package/src/core/schema-sqlite/migrate-helper.ts +246 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
var e={comments:{lineComment:`//`,blockComment:[`/*`,`*/`]},brackets:[[`{`,`}`],[`[`,`]`],[`(`,`)`]],autoClosingPairs:[{open:`[`,close:`]`},{open:`{`,close:`}`},{open:`(`,close:`)`}],surroundingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`}]};function t(e){let t=[],n=e.split(/\t+|\r+|\n+| +/);for(let e=0;e<n.length;++e)n[e].length>0&&t.push(n[e]);return t}var n=t(`true false`),r=t(`
|
|
2
|
+
alias
|
|
3
|
+
break
|
|
4
|
+
case
|
|
5
|
+
const
|
|
6
|
+
const_assert
|
|
7
|
+
continue
|
|
8
|
+
continuing
|
|
9
|
+
default
|
|
10
|
+
diagnostic
|
|
11
|
+
discard
|
|
12
|
+
else
|
|
13
|
+
enable
|
|
14
|
+
fn
|
|
15
|
+
for
|
|
16
|
+
if
|
|
17
|
+
let
|
|
18
|
+
loop
|
|
19
|
+
override
|
|
20
|
+
requires
|
|
21
|
+
return
|
|
22
|
+
struct
|
|
23
|
+
switch
|
|
24
|
+
var
|
|
25
|
+
while
|
|
26
|
+
`),i=t(`
|
|
27
|
+
NULL
|
|
28
|
+
Self
|
|
29
|
+
abstract
|
|
30
|
+
active
|
|
31
|
+
alignas
|
|
32
|
+
alignof
|
|
33
|
+
as
|
|
34
|
+
asm
|
|
35
|
+
asm_fragment
|
|
36
|
+
async
|
|
37
|
+
attribute
|
|
38
|
+
auto
|
|
39
|
+
await
|
|
40
|
+
become
|
|
41
|
+
binding_array
|
|
42
|
+
cast
|
|
43
|
+
catch
|
|
44
|
+
class
|
|
45
|
+
co_await
|
|
46
|
+
co_return
|
|
47
|
+
co_yield
|
|
48
|
+
coherent
|
|
49
|
+
column_major
|
|
50
|
+
common
|
|
51
|
+
compile
|
|
52
|
+
compile_fragment
|
|
53
|
+
concept
|
|
54
|
+
const_cast
|
|
55
|
+
consteval
|
|
56
|
+
constexpr
|
|
57
|
+
constinit
|
|
58
|
+
crate
|
|
59
|
+
debugger
|
|
60
|
+
decltype
|
|
61
|
+
delete
|
|
62
|
+
demote
|
|
63
|
+
demote_to_helper
|
|
64
|
+
do
|
|
65
|
+
dynamic_cast
|
|
66
|
+
enum
|
|
67
|
+
explicit
|
|
68
|
+
export
|
|
69
|
+
extends
|
|
70
|
+
extern
|
|
71
|
+
external
|
|
72
|
+
fallthrough
|
|
73
|
+
filter
|
|
74
|
+
final
|
|
75
|
+
finally
|
|
76
|
+
friend
|
|
77
|
+
from
|
|
78
|
+
fxgroup
|
|
79
|
+
get
|
|
80
|
+
goto
|
|
81
|
+
groupshared
|
|
82
|
+
highp
|
|
83
|
+
impl
|
|
84
|
+
implements
|
|
85
|
+
import
|
|
86
|
+
inline
|
|
87
|
+
instanceof
|
|
88
|
+
interface
|
|
89
|
+
layout
|
|
90
|
+
lowp
|
|
91
|
+
macro
|
|
92
|
+
macro_rules
|
|
93
|
+
match
|
|
94
|
+
mediump
|
|
95
|
+
meta
|
|
96
|
+
mod
|
|
97
|
+
module
|
|
98
|
+
move
|
|
99
|
+
mut
|
|
100
|
+
mutable
|
|
101
|
+
namespace
|
|
102
|
+
new
|
|
103
|
+
nil
|
|
104
|
+
noexcept
|
|
105
|
+
noinline
|
|
106
|
+
nointerpolation
|
|
107
|
+
noperspective
|
|
108
|
+
null
|
|
109
|
+
nullptr
|
|
110
|
+
of
|
|
111
|
+
operator
|
|
112
|
+
package
|
|
113
|
+
packoffset
|
|
114
|
+
partition
|
|
115
|
+
pass
|
|
116
|
+
patch
|
|
117
|
+
pixelfragment
|
|
118
|
+
precise
|
|
119
|
+
precision
|
|
120
|
+
premerge
|
|
121
|
+
priv
|
|
122
|
+
protected
|
|
123
|
+
pub
|
|
124
|
+
public
|
|
125
|
+
readonly
|
|
126
|
+
ref
|
|
127
|
+
regardless
|
|
128
|
+
register
|
|
129
|
+
reinterpret_cast
|
|
130
|
+
require
|
|
131
|
+
resource
|
|
132
|
+
restrict
|
|
133
|
+
self
|
|
134
|
+
set
|
|
135
|
+
shared
|
|
136
|
+
sizeof
|
|
137
|
+
smooth
|
|
138
|
+
snorm
|
|
139
|
+
static
|
|
140
|
+
static_assert
|
|
141
|
+
static_cast
|
|
142
|
+
std
|
|
143
|
+
subroutine
|
|
144
|
+
super
|
|
145
|
+
target
|
|
146
|
+
template
|
|
147
|
+
this
|
|
148
|
+
thread_local
|
|
149
|
+
throw
|
|
150
|
+
trait
|
|
151
|
+
try
|
|
152
|
+
type
|
|
153
|
+
typedef
|
|
154
|
+
typeid
|
|
155
|
+
typename
|
|
156
|
+
typeof
|
|
157
|
+
union
|
|
158
|
+
unless
|
|
159
|
+
unorm
|
|
160
|
+
unsafe
|
|
161
|
+
unsized
|
|
162
|
+
use
|
|
163
|
+
using
|
|
164
|
+
varying
|
|
165
|
+
virtual
|
|
166
|
+
volatile
|
|
167
|
+
wgsl
|
|
168
|
+
where
|
|
169
|
+
with
|
|
170
|
+
writeonly
|
|
171
|
+
yield
|
|
172
|
+
`),a=t(`
|
|
173
|
+
read write read_write
|
|
174
|
+
function private workgroup uniform storage
|
|
175
|
+
perspective linear flat
|
|
176
|
+
center centroid sample
|
|
177
|
+
vertex_index instance_index position front_facing frag_depth
|
|
178
|
+
local_invocation_id local_invocation_index
|
|
179
|
+
global_invocation_id workgroup_id num_workgroups
|
|
180
|
+
sample_index sample_mask
|
|
181
|
+
rgba8unorm
|
|
182
|
+
rgba8snorm
|
|
183
|
+
rgba8uint
|
|
184
|
+
rgba8sint
|
|
185
|
+
rgba16uint
|
|
186
|
+
rgba16sint
|
|
187
|
+
rgba16float
|
|
188
|
+
r32uint
|
|
189
|
+
r32sint
|
|
190
|
+
r32float
|
|
191
|
+
rg32uint
|
|
192
|
+
rg32sint
|
|
193
|
+
rg32float
|
|
194
|
+
rgba32uint
|
|
195
|
+
rgba32sint
|
|
196
|
+
rgba32float
|
|
197
|
+
bgra8unorm
|
|
198
|
+
`),o=t(`
|
|
199
|
+
bool
|
|
200
|
+
f16
|
|
201
|
+
f32
|
|
202
|
+
i32
|
|
203
|
+
sampler sampler_comparison
|
|
204
|
+
texture_depth_2d
|
|
205
|
+
texture_depth_2d_array
|
|
206
|
+
texture_depth_cube
|
|
207
|
+
texture_depth_cube_array
|
|
208
|
+
texture_depth_multisampled_2d
|
|
209
|
+
texture_external
|
|
210
|
+
texture_external
|
|
211
|
+
u32
|
|
212
|
+
`),s=t(`
|
|
213
|
+
array
|
|
214
|
+
atomic
|
|
215
|
+
mat2x2
|
|
216
|
+
mat2x3
|
|
217
|
+
mat2x4
|
|
218
|
+
mat3x2
|
|
219
|
+
mat3x3
|
|
220
|
+
mat3x4
|
|
221
|
+
mat4x2
|
|
222
|
+
mat4x3
|
|
223
|
+
mat4x4
|
|
224
|
+
ptr
|
|
225
|
+
texture_1d
|
|
226
|
+
texture_2d
|
|
227
|
+
texture_2d_array
|
|
228
|
+
texture_3d
|
|
229
|
+
texture_cube
|
|
230
|
+
texture_cube_array
|
|
231
|
+
texture_multisampled_2d
|
|
232
|
+
texture_storage_1d
|
|
233
|
+
texture_storage_2d
|
|
234
|
+
texture_storage_2d_array
|
|
235
|
+
texture_storage_3d
|
|
236
|
+
vec2
|
|
237
|
+
vec3
|
|
238
|
+
vec4
|
|
239
|
+
`),c=t(`
|
|
240
|
+
vec2i vec3i vec4i
|
|
241
|
+
vec2u vec3u vec4u
|
|
242
|
+
vec2f vec3f vec4f
|
|
243
|
+
vec2h vec3h vec4h
|
|
244
|
+
mat2x2f mat2x3f mat2x4f
|
|
245
|
+
mat3x2f mat3x3f mat3x4f
|
|
246
|
+
mat4x2f mat4x3f mat4x4f
|
|
247
|
+
mat2x2h mat2x3h mat2x4h
|
|
248
|
+
mat3x2h mat3x3h mat3x4h
|
|
249
|
+
mat4x2h mat4x3h mat4x4h
|
|
250
|
+
`),l=t(`
|
|
251
|
+
bitcast all any select arrayLength abs acos acosh asin asinh atan atanh atan2
|
|
252
|
+
ceil clamp cos cosh countLeadingZeros countOneBits countTrailingZeros cross
|
|
253
|
+
degrees determinant distance dot exp exp2 extractBits faceForward firstLeadingBit
|
|
254
|
+
firstTrailingBit floor fma fract frexp inverseBits inverseSqrt ldexp length
|
|
255
|
+
log log2 max min mix modf normalize pow quantizeToF16 radians reflect refract
|
|
256
|
+
reverseBits round saturate sign sin sinh smoothstep sqrt step tan tanh transpose
|
|
257
|
+
trunc dpdx dpdxCoarse dpdxFine dpdy dpdyCoarse dpdyFine fwidth fwidthCoarse fwidthFine
|
|
258
|
+
textureDimensions textureGather textureGatherCompare textureLoad textureNumLayers
|
|
259
|
+
textureNumLevels textureNumSamples textureSample textureSampleBias textureSampleCompare
|
|
260
|
+
textureSampleCompareLevel textureSampleGrad textureSampleLevel textureSampleBaseClampToEdge
|
|
261
|
+
textureStore atomicLoad atomicStore atomicAdd atomicSub atomicMax atomicMin
|
|
262
|
+
atomicAnd atomicOr atomicXor atomicExchange atomicCompareExchangeWeak pack4x8snorm
|
|
263
|
+
pack4x8unorm pack2x16snorm pack2x16unorm pack2x16float unpack4x8snorm unpack4x8unorm
|
|
264
|
+
unpack2x16snorm unpack2x16unorm unpack2x16float storageBarrier workgroupBarrier
|
|
265
|
+
workgroupUniformLoad
|
|
266
|
+
`),u=t(`
|
|
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
|
+
`),d=/enable|requires|diagnostic/,f=/[_\p{XID_Start}]\p{XID_Continue}*/u,p=`variable.predefined`,m={tokenPostfix:`.wgsl`,defaultToken:`invalid`,unicode:!0,atoms:n,keywords:r,reserved:i,predeclared_enums:a,predeclared_types:o,predeclared_type_generators:s,predeclared_type_aliases:c,predeclared_intrinsics:l,operators:u,symbols:/[!%&*+\-\.\/:;<=>^|_~,]+/,tokenizer:{root:[[d,`keyword`,`@directive`],[f,{cases:{"@atoms":p,"@keywords":`keyword`,"@reserved":`invalid`,"@predeclared_enums":p,"@predeclared_types":p,"@predeclared_type_generators":p,"@predeclared_type_aliases":p,"@predeclared_intrinsics":p,"@default":`identifier`}}],{include:`@commentOrSpace`},{include:`@numbers`},[/[{}()\[\]]/,`@brackets`],[`@`,`annotation`,`@attribute`],[/@symbols/,{cases:{"@operators":`operator`,"@default":`delimiter`}}],[/./,`invalid`]],commentOrSpace:[[/\s+/,`white`],[/\/\*/,`comment`,`@blockComment`],[/\/\/.*$/,`comment`]],blockComment:[[/[^\/*]+/,`comment`],[/\/\*/,`comment`,`@push`],[/\*\//,`comment`,`@pop`],[/[\/*]/,`comment`]],attribute:[{include:`@commentOrSpace`},[/\w+/,`annotation`,`@pop`]],directive:[{include:`@commentOrSpace`},[/[()]/,`@brackets`],[/,/,`delimiter`],[f,`meta.content`],[/;/,`delimiter`,`@pop`]],numbers:[[/0[fh]/,`number.float`],[/[1-9][0-9]*[fh]/,`number.float`],[/[0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[fh]?/,`number.float`],[/[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?[fh]?/,`number.float`],[/[0-9]+[eE][+-]?[0-9]+[fh]?/,`number.float`],[/0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+(?:[pP][+-]?[0-9]+[fh]?)?/,`number.hex`],[/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*(?:[pP][+-]?[0-9]+[fh]?)?/,`number.hex`],[/0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+[fh]?/,`number.hex`],[/0[xX][0-9a-fA-F]+[iu]?/,`number.hex`],[/[1-9][0-9]*[iu]?/,`number`],[/0[iu]?/,`number`]]}};export{e as conf,m as language};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as e}from"./editor.api-BG499EJF.js";var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of r(a))!i.call(e,c)&&c!==o&&t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e},o=(e,t,n)=>(a(e,t,`default`),n&&a(n,t,`default`)),s={};o(s,e);var c={comments:{blockComment:[`<!--`,`-->`]},brackets:[[`<`,`>`]],autoClosingPairs:[{open:`<`,close:`>`},{open:`'`,close:`'`},{open:`"`,close:`"`}],surroundingPairs:[{open:`<`,close:`>`},{open:`'`,close:`'`},{open:`"`,close:`"`}],onEnterRules:[{beforeText:RegExp(`<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`,`i`),afterText:/^<\/([_:\w][_:\w-.\d]*)\s*>$/i,action:{indentAction:s.languages.IndentAction.IndentOutdent}},{beforeText:RegExp(`<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`,`i`),action:{indentAction:s.languages.IndentAction.Indent}}]},l={defaultToken:``,tokenPostfix:`.xml`,ignoreCase:!0,qualifiedName:/(?:[\w\.\-]+:)?[\w\.\-]+/,tokenizer:{root:[[/[^<&]+/,``],{include:`@whitespace`},[/(<)(@qualifiedName)/,[{token:`delimiter`},{token:`tag`,next:`@tag`}]],[/(<\/)(@qualifiedName)(\s*)(>)/,[{token:`delimiter`},{token:`tag`},``,{token:`delimiter`}]],[/(<\?)(@qualifiedName)/,[{token:`delimiter`},{token:`metatag`,next:`@tag`}]],[/(<\!)(@qualifiedName)/,[{token:`delimiter`},{token:`metatag`,next:`@tag`}]],[/<\!\[CDATA\[/,{token:`delimiter.cdata`,next:`@cdata`}],[/&\w+;/,`string.escape`]],cdata:[[/[^\]]+/,``],[/\]\]>/,{token:`delimiter.cdata`,next:`@pop`}],[/\]/,``]],tag:[[/[ \t\r\n]+/,``],[/(@qualifiedName)(\s*=\s*)("[^"]*"|'[^']*')/,[`attribute.name`,``,`attribute.value`]],[/(@qualifiedName)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/,[`attribute.name`,``,`attribute.value`]],[/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/,[`attribute.name`,``,`attribute.value`]],[/@qualifiedName/,`attribute.name`],[/\?>/,{token:`delimiter`,next:`@pop`}],[/(\/)(>)/,[{token:`tag`},{token:`delimiter`,next:`@pop`}]],[/>/,{token:`delimiter`,next:`@pop`}]],whitespace:[[/[ \t\r\n]+/,``],[/<!--/,{token:`comment`,next:`@comment`}]],comment:[[/[^<\-]+/,`comment.content`],[/-->/,{token:`comment`,next:`@pop`}],[/<!--/,`comment.content.invalid`],[/[<\-]/,`comment.content`]]}};export{c as conf,l as language};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as e}from"./editor.api-BG499EJF.js";var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of r(a))!i.call(e,c)&&c!==o&&t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e},o=(e,t,n)=>(a(e,t,`default`),n&&a(n,t,`default`)),s={};o(s,e);var c={comments:{lineComment:`#`},brackets:[[`{`,`}`],[`[`,`]`],[`(`,`)`]],autoClosingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`},{open:`'`,close:`'`}],surroundingPairs:[{open:`{`,close:`}`},{open:`[`,close:`]`},{open:`(`,close:`)`},{open:`"`,close:`"`},{open:`'`,close:`'`}],folding:{offSide:!0},onEnterRules:[{beforeText:/:\s*$/,action:{indentAction:s.languages.IndentAction.Indent}}]},l={tokenPostfix:`.yaml`,brackets:[{token:`delimiter.bracket`,open:`{`,close:`}`},{token:`delimiter.square`,open:`[`,close:`]`}],keywords:[`true`,`True`,`TRUE`,`false`,`False`,`FALSE`,`null`,`Null`,`Null`,`~`],numberInteger:/(?:0|[+-]?[0-9]+)/,numberFloat:/(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,numberOctal:/0o[0-7]+/,numberHex:/0x[0-9a-fA-F]+/,numberInfinity:/[+-]?\.(?:inf|Inf|INF)/,numberNaN:/\.(?:nan|Nan|NAN)/,numberDate:/\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,escapes:/\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,tokenizer:{root:[{include:`@whitespace`},{include:`@comment`},[/%[^ ]+.*$/,`meta.directive`],[/---/,`operators.directivesEnd`],[/\.{3}/,`operators.documentEnd`],[/[-?:](?= )/,`operators`],{include:`@anchor`},{include:`@tagHandle`},{include:`@flowCollections`},{include:`@blockStyle`},[/@numberInteger(?![ \t]*\S+)/,`number`],[/@numberFloat(?![ \t]*\S+)/,`number.float`],[/@numberOctal(?![ \t]*\S+)/,`number.octal`],[/@numberHex(?![ \t]*\S+)/,`number.hex`],[/@numberInfinity(?![ \t]*\S+)/,`number.infinity`],[/@numberNaN(?![ \t]*\S+)/,`number.nan`],[/@numberDate(?![ \t]*\S+)/,`number.date`],[/(".*?"|'.*?'|[^#'"]*?)([ \t]*)(:)( |$)/,[`type`,`white`,`operators`,`white`]],{include:`@flowScalars`},[/.+?(?=(\s+#|$))/,{cases:{"@keywords":`keyword`,"@default":`string`}}]],object:[{include:`@whitespace`},{include:`@comment`},[/\}/,`@brackets`,`@pop`],[/,/,`delimiter.comma`],[/:(?= )/,`operators`],[/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/,`type`],{include:`@flowCollections`},{include:`@flowScalars`},{include:`@tagHandle`},{include:`@anchor`},{include:`@flowNumber`},[/[^\},]+/,{cases:{"@keywords":`keyword`,"@default":`string`}}]],array:[{include:`@whitespace`},{include:`@comment`},[/\]/,`@brackets`,`@pop`],[/,/,`delimiter.comma`],{include:`@flowCollections`},{include:`@flowScalars`},{include:`@tagHandle`},{include:`@anchor`},{include:`@flowNumber`},[/[^\],]+/,{cases:{"@keywords":`keyword`,"@default":`string`}}]],multiString:[[/^( +).+$/,`string`,`@multiStringContinued.$1`]],multiStringContinued:[[/^( *).+$/,{cases:{"$1==$S2":`string`,"@default":{token:`@rematch`,next:`@popall`}}}]],whitespace:[[/[ \t\r\n]+/,`white`]],comment:[[/#.*$/,`comment`]],flowCollections:[[/\[/,`@brackets`,`@array`],[/\{/,`@brackets`,`@object`]],flowScalars:[[/"([^"\\]|\\.)*$/,`string.invalid`],[/'([^'\\]|\\.)*$/,`string.invalid`],[/'[^']*'/,`string`],[/"/,`string`,`@doubleQuotedString`]],doubleQuotedString:[[/[^\\"]+/,`string`],[/@escapes/,`string.escape`],[/\\./,`string.escape.invalid`],[/"/,`string`,`@pop`]],blockStyle:[[/[>|][0-9]*[+-]?$/,`operators`,`@multiString`]],flowNumber:[[/@numberInteger(?=[ \t]*[,\]\}])/,`number`],[/@numberFloat(?=[ \t]*[,\]\}])/,`number.float`],[/@numberOctal(?=[ \t]*[,\]\}])/,`number.octal`],[/@numberHex(?=[ \t]*[,\]\}])/,`number.hex`],[/@numberInfinity(?=[ \t]*[,\]\}])/,`number.infinity`],[/@numberNaN(?=[ \t]*[,\]\}])/,`number.nan`],[/@numberDate(?=[ \t]*[,\]\}])/,`number.date`]],tagHandle:[[/\![^ ]*/,`tag`]],anchor:[[/[&*][^ ]+/,`namespace`]]}};export{c as conf,l as language};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>aiex Schema Editor</title>
|
|
7
|
+
<script>
|
|
8
|
+
;(function () {
|
|
9
|
+
var key = "jscb-color-scheme"
|
|
10
|
+
var stored = localStorage.getItem(key)
|
|
11
|
+
var dark =
|
|
12
|
+
stored === "dark" ||
|
|
13
|
+
((!stored || stored === "auto") && window.matchMedia("(prefers-color-scheme: dark)").matches)
|
|
14
|
+
if (dark) document.documentElement.classList.add("jscb-dark")
|
|
15
|
+
})()
|
|
16
|
+
</script>
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-c6KB-9C-.js"></script>
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/chunk-BEqpzyXh.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/preload-helper-DSXbuxSR.js">
|
|
20
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Bi376XVf.css">
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<div id="app"></div>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aiex-cli",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "JSON Schema → SQLite with AI-powered data extraction",
|
|
6
|
+
"author": "OSpoon <zxin088@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/OSpoon/aiex-cli#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/OSpoon/aiex-cli.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": "https://github.com/OSpoon/aiex-cli/issues",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"json-schema",
|
|
16
|
+
"sqlite",
|
|
17
|
+
"drizzle",
|
|
18
|
+
"orm",
|
|
19
|
+
"ai-extraction",
|
|
20
|
+
"cli",
|
|
21
|
+
"database-migration",
|
|
22
|
+
"schema-editor",
|
|
23
|
+
"code-generation",
|
|
24
|
+
"structured-output"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"exports": {
|
|
28
|
+
".": "./dist/index.mjs",
|
|
29
|
+
"./cli": "./dist/cli.mjs",
|
|
30
|
+
"./core/schema-sqlite/migrate-helper": "./dist/core/schema-sqlite/migrate-helper.mjs",
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"main": "./dist/index.mjs",
|
|
34
|
+
"module": "./dist/index.mjs",
|
|
35
|
+
"types": "./dist/index.d.mts",
|
|
36
|
+
"bin": {
|
|
37
|
+
"aiex": "./bin/cli.mjs"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"bin",
|
|
41
|
+
"dist",
|
|
42
|
+
"src/core/schema-sqlite/migrate-helper.ts"
|
|
43
|
+
],
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@ai-sdk/openai-compatible": "^2.0.47",
|
|
46
|
+
"@clack/prompts": "^1.2.0",
|
|
47
|
+
"@hono/node-server": "^1.0.0",
|
|
48
|
+
"ai": "^6.0.182",
|
|
49
|
+
"better-sqlite3": "^11.0.0",
|
|
50
|
+
"citty": "^0.2.2",
|
|
51
|
+
"cli-table3": "^0.6.5",
|
|
52
|
+
"conf": "^13.1.0",
|
|
53
|
+
"consola": "^3.4.2",
|
|
54
|
+
"date-fns": "^4.1.0",
|
|
55
|
+
"drizzle-kit": "^0.30.0",
|
|
56
|
+
"drizzle-orm": "^0.38.4",
|
|
57
|
+
"es-toolkit": "^1.46.1",
|
|
58
|
+
"esbuild": "^0.19.12",
|
|
59
|
+
"hono": "^4.0.0",
|
|
60
|
+
"picocolors": "^1.1.1",
|
|
61
|
+
"tsx": "^4.21.0",
|
|
62
|
+
"update-notifier": "^7.3.1",
|
|
63
|
+
"zod": "^3.23.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@antfu/eslint-config": "^8.1.1",
|
|
67
|
+
"@antfu/ni": "^30.1.0",
|
|
68
|
+
"@types/better-sqlite3": "^7.6.0",
|
|
69
|
+
"@types/node": "^25.6.0",
|
|
70
|
+
"@types/update-notifier": "^6.0.8",
|
|
71
|
+
"eslint": "^10.2.0",
|
|
72
|
+
"publint": "^0.3.18",
|
|
73
|
+
"tsdown": "^0.17.3",
|
|
74
|
+
"tsnapi": "^0.1.1",
|
|
75
|
+
"typescript": "^6.0.2",
|
|
76
|
+
"vitest": "^4.1.4"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"build": "tsdown && pnpm --filter aiex-web build",
|
|
80
|
+
"dev": "tsdown --watch",
|
|
81
|
+
"start": "tsx src/index.ts",
|
|
82
|
+
"test": "vitest",
|
|
83
|
+
"typecheck": "tsc",
|
|
84
|
+
"lint": "eslint ."
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type { DrizzleSQLiteSnapshotJSON } from 'drizzle-kit/api'
|
|
2
|
+
import fs from 'node:fs/promises'
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import process from 'node:process'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import Database from 'better-sqlite3'
|
|
8
|
+
import * as esbuild from 'esbuild'
|
|
9
|
+
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
12
|
+
const __dirname = path.dirname(__filename)
|
|
13
|
+
const { generateSQLiteDrizzleJson, generateSQLiteMigration } = require('drizzle-kit/api') as typeof import('drizzle-kit/api')
|
|
14
|
+
|
|
15
|
+
const EMPTY_SNAPSHOT: DrizzleSQLiteSnapshotJSON = {
|
|
16
|
+
version: '6',
|
|
17
|
+
dialect: 'sqlite',
|
|
18
|
+
tables: {},
|
|
19
|
+
views: {},
|
|
20
|
+
enums: {},
|
|
21
|
+
_meta: { tables: {}, columns: {} },
|
|
22
|
+
internal: { indexes: {} },
|
|
23
|
+
id: '00000000-0000-0000-0000-000000000000',
|
|
24
|
+
prevId: '00000000-0000-0000-0000-000000000000',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function loadSchemaExports(schemaPath: string): Promise<Record<string, unknown>> {
|
|
28
|
+
// Find the CLI package root for module resolution
|
|
29
|
+
let cliDir: string
|
|
30
|
+
try {
|
|
31
|
+
const pkgPath = require.resolve('aiex-cli/package.json')
|
|
32
|
+
cliDir = path.dirname(pkgPath)
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
cliDir = path.dirname(path.dirname(path.dirname(path.dirname(__dirname))))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Bundle the schema with esbuild, resolving drizzle-orm from CLI's node_modules
|
|
39
|
+
const result = await esbuild.build({
|
|
40
|
+
entryPoints: [schemaPath],
|
|
41
|
+
bundle: true,
|
|
42
|
+
platform: 'node',
|
|
43
|
+
format: 'cjs',
|
|
44
|
+
write: false,
|
|
45
|
+
nodePaths: [path.join(cliDir, 'node_modules')],
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const tempPath = schemaPath.replace('.ts', '.__bundled__.cjs')
|
|
49
|
+
await fs.writeFile(tempPath, result.outputFiles[0].text)
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const exports = require(tempPath) as Record<string, unknown>
|
|
53
|
+
await fs.unlink(tempPath)
|
|
54
|
+
return exports
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
await fs.unlink(tempPath).catch(() => {})
|
|
58
|
+
throw e
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function loadPrevSnapshot(migrationsPath: string): Promise<DrizzleSQLiteSnapshotJSON | null> {
|
|
63
|
+
const metaPath = path.join(migrationsPath, 'meta', '_journal.json')
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const journal = JSON.parse(await fs.readFile(metaPath, 'utf-8'))
|
|
67
|
+
if (!journal.entries?.length)
|
|
68
|
+
return null
|
|
69
|
+
|
|
70
|
+
const latestEntry = journal.entries[journal.entries.length - 1]
|
|
71
|
+
const snapshotPath = path.join(migrationsPath, 'meta', `${latestEntry.tag}_snapshot.json`)
|
|
72
|
+
|
|
73
|
+
return JSON.parse(await fs.readFile(snapshotPath, 'utf-8'))
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function saveSnapshot(
|
|
81
|
+
migrationsPath: string,
|
|
82
|
+
snapshot: DrizzleSQLiteSnapshotJSON,
|
|
83
|
+
): Promise<string> {
|
|
84
|
+
const metaPath = path.join(migrationsPath, 'meta')
|
|
85
|
+
await fs.mkdir(metaPath, { recursive: true })
|
|
86
|
+
|
|
87
|
+
const journalPath = path.join(metaPath, '_journal.json')
|
|
88
|
+
let journal: { version: string, dialect: string, entries: Array<{ idx: number, version: string, when: number, tag: string, breakpoints: boolean }> }
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
journal = JSON.parse(await fs.readFile(journalPath, 'utf-8'))
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
journal = { version: '6', dialect: 'sqlite', entries: [] }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const idx = journal.entries.length + 1
|
|
98
|
+
const tag = `${String(idx).padStart(4, '0')}_${snapshot.id.replace(/-/g, '_').substring(0, 8)}`
|
|
99
|
+
|
|
100
|
+
const snapshotPath = path.join(metaPath, `${tag}_snapshot.json`)
|
|
101
|
+
await fs.writeFile(snapshotPath, JSON.stringify(snapshot, null, 2))
|
|
102
|
+
|
|
103
|
+
journal.entries.push({
|
|
104
|
+
idx,
|
|
105
|
+
version: snapshot.id,
|
|
106
|
+
when: Date.now(),
|
|
107
|
+
tag,
|
|
108
|
+
breakpoints: true,
|
|
109
|
+
})
|
|
110
|
+
await fs.writeFile(journalPath, JSON.stringify(journal, null, 2))
|
|
111
|
+
|
|
112
|
+
return tag
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function saveMigrationFile(
|
|
116
|
+
migrationsPath: string,
|
|
117
|
+
tag: string,
|
|
118
|
+
sqlStatements: string[],
|
|
119
|
+
): Promise<string> {
|
|
120
|
+
await fs.mkdir(migrationsPath, { recursive: true })
|
|
121
|
+
|
|
122
|
+
const sqlPath = path.join(migrationsPath, `${tag}.sql`)
|
|
123
|
+
const sqlContent = sqlStatements.join('\n--> statement-breakpoint\n')
|
|
124
|
+
|
|
125
|
+
await fs.writeFile(sqlPath, sqlContent)
|
|
126
|
+
return sqlPath
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function applyMigrationWithTransaction(dbPath: string, sqlStatements: string[]): void {
|
|
130
|
+
const db = new Database(dbPath)
|
|
131
|
+
|
|
132
|
+
// Use transaction to ensure atomicity
|
|
133
|
+
const transaction = db.transaction(() => {
|
|
134
|
+
for (const sql of sqlStatements) {
|
|
135
|
+
db.exec(sql)
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
transaction()
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
db.close()
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Simple file lock mechanism
|
|
148
|
+
const LOCK_FILE = '.migrate.lock'
|
|
149
|
+
|
|
150
|
+
async function acquireLock(aiexDir: string): Promise<void> {
|
|
151
|
+
const lockPath = path.join(aiexDir, LOCK_FILE)
|
|
152
|
+
await fs.mkdir(aiexDir, { recursive: true })
|
|
153
|
+
|
|
154
|
+
// Try to create lock file atomically using exclusive write
|
|
155
|
+
try {
|
|
156
|
+
const fd = await fs.open(lockPath, 'wx') // 'wx' = exclusive write, fails if exists
|
|
157
|
+
await fd.write(`${process.pid}\n${Date.now()}`)
|
|
158
|
+
await fd.close()
|
|
159
|
+
}
|
|
160
|
+
catch (e: any) {
|
|
161
|
+
if (e.code === 'EEXIST') {
|
|
162
|
+
// Lock exists, read it and check if it's stale
|
|
163
|
+
try {
|
|
164
|
+
const content = await fs.readFile(lockPath, 'utf-8')
|
|
165
|
+
const [pidStr, timestampStr] = content.split('\n')
|
|
166
|
+
const lockPid = Number.parseInt(pidStr, 10)
|
|
167
|
+
const lockTime = Number.parseInt(timestampStr, 10)
|
|
168
|
+
|
|
169
|
+
// Check if lock is stale (> 5 minutes old) or process is dead
|
|
170
|
+
const lockAge = Date.now() - lockTime
|
|
171
|
+
if (lockAge > 300000) {
|
|
172
|
+
// Lock is stale, remove it and retry
|
|
173
|
+
await fs.unlink(lockPath)
|
|
174
|
+
return acquireLock(aiexDir)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
throw new Error(`Migration is already running (PID ${lockPid}, started ${Math.round(lockAge / 1000)}s ago). Wait for it to complete or remove ${lockPath} if stale.`)
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
// Can't read lock file, it might be corrupted - remove and retry
|
|
181
|
+
await fs.unlink(lockPath).catch(() => {})
|
|
182
|
+
return acquireLock(aiexDir)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
throw e
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function releaseLock(aiexDir: string): Promise<void> {
|
|
190
|
+
const lockPath = path.join(aiexDir, LOCK_FILE)
|
|
191
|
+
await fs.unlink(lockPath).catch(() => {})
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function main(): Promise<void> {
|
|
195
|
+
const args = process.argv.slice(2)
|
|
196
|
+
const schemaPath = args[0]
|
|
197
|
+
const migrationsPath = args[1]
|
|
198
|
+
const dbPath = args[2]
|
|
199
|
+
|
|
200
|
+
if (!schemaPath || !migrationsPath || !dbPath) {
|
|
201
|
+
console.error('Usage: migrate-helper.ts <schemaPath> <migrationsPath> <dbPath>')
|
|
202
|
+
process.exit(1)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
// Acquire lock to prevent concurrent migrations
|
|
207
|
+
const aiexDir = path.dirname(path.dirname(migrationsPath))
|
|
208
|
+
await acquireLock(aiexDir)
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
const exports = await loadSchemaExports(schemaPath)
|
|
212
|
+
const prevSnapshot = await loadPrevSnapshot(migrationsPath)
|
|
213
|
+
const currentSnapshot = await generateSQLiteDrizzleJson(exports, prevSnapshot?.id)
|
|
214
|
+
|
|
215
|
+
const prev = prevSnapshot || EMPTY_SNAPSHOT
|
|
216
|
+
const sqlStatements = await generateSQLiteMigration(prev, currentSnapshot)
|
|
217
|
+
|
|
218
|
+
if (sqlStatements.length === 0) {
|
|
219
|
+
// eslint-disable-next-line no-console
|
|
220
|
+
console.log(JSON.stringify({ success: true, changes: 0 }))
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Execute SQL in transaction FIRST
|
|
225
|
+
// If this fails, database is unchanged and we don't save snapshot
|
|
226
|
+
applyMigrationWithTransaction(dbPath, sqlStatements)
|
|
227
|
+
|
|
228
|
+
// Only save snapshot and migration file AFTER successful DB update
|
|
229
|
+
const tag = await saveSnapshot(migrationsPath, currentSnapshot)
|
|
230
|
+
await saveMigrationFile(migrationsPath, tag, sqlStatements)
|
|
231
|
+
|
|
232
|
+
// eslint-disable-next-line no-console
|
|
233
|
+
console.log(JSON.stringify({ success: true, changes: sqlStatements.length, tag }))
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
await releaseLock(aiexDir)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (error: unknown) {
|
|
240
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
241
|
+
console.error(JSON.stringify({ success: false, error: message }))
|
|
242
|
+
process.exit(1)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
main()
|