FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
opencode/packages/opencode/script/build-node.ts at dev · codedeep/opencode · GitHub
codedeep
/
opencode
Public
forked from
anomalyco/opencode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
opencode
/
packages
/
opencode
/
script
/
build-node.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (49 loc) · 1.45 KB
Breadcrumbs
opencode
/
packages
/
opencode
/
script
/
build-node.ts
Copy path
File metadata and controls
56 lines (49 loc) · 1.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bun
import
{
Script
}
from
"@opencode-ai/script"
import
fs
from
"fs"
import
path
from
"path"
import
{
fileURLToPath
}
from
"url"
const
__filename
=
fileURLToPath
(
import
.
meta
.
url
)
const
__dirname
=
path
.
dirname
(
__filename
)
const
dir
=
path
.
resolve
(
__dirname
,
".."
)
process
.
chdir
(
dir
)
// Load migrations from migration directories
const
migrationDirs
=
(
await
fs
.
promises
.
readdir
(
path
.
join
(
dir
,
"migration"
)
,
{
withFileTypes
:
true
,
}
)
)
.
filter
(
(
entry
)
=>
entry
.
isDirectory
(
)
&&
/
^
\d
{
4
}
\d
{
2
}
\d
{
2
}
\d
{
2
}
\d
{
2
}
\d
{
2
}
/
.
test
(
entry
.
name
)
)
.
map
(
(
entry
)
=>
entry
.
name
)
.
sort
(
)
const
migrations
=
await
Promise
.
all
(
migrationDirs
.
map
(
async
(
name
)
=>
{
const
file
=
path
.
join
(
dir
,
"migration"
,
name
,
"migration.sql"
)
const
sql
=
await
Bun
.
file
(
file
)
.
text
(
)
const
match
=
/
^
(
\d
{
4
}
)
(
\d
{
2
}
)
(
\d
{
2
}
)
(
\d
{
2
}
)
(
\d
{
2
}
)
(
\d
{
2
}
)
/
.
exec
(
name
)
const
timestamp
=
match
?
Date
.
UTC
(
Number
(
match
[
1
]
)
,
Number
(
match
[
2
]
)
-
1
,
Number
(
match
[
3
]
)
,
Number
(
match
[
4
]
)
,
Number
(
match
[
5
]
)
,
Number
(
match
[
6
]
)
,
)
:
0
return
{
sql
,
timestamp
,
name
}
}
)
,
)
console
.
log
(
`Loaded
${
migrations
.
length
}
migrations`
)
await
Bun
.
build
(
{
target
:
"node"
,
entrypoints
:
[
"./src/node.ts"
]
,
outdir
:
"./dist"
,
format
:
"esm"
,
external
:
[
"jsonc-parser"
]
,
define
:
{
OPENCODE_MIGRATIONS
:
JSON
.
stringify
(
migrations
)
,
OPENCODE_CHANNEL
:
`'
${
Script
.
channel
}
'`
,
}
,
}
)
console
.
log
(
"Build complete"
)
Back
|
FazBrowse Home
|
New Git URL