-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.jl
52 lines (40 loc) · 1.48 KB
/
build.jl
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
using Pkg.Artifacts
using JSON
using URIs
function build()
package_dict = JSON.parsefile(joinpath(@__DIR__, "package.json"))
pkgname = package_dict["name"]
version = VersionNumber(package_dict["version"])
host = "https://github.com/MichaelHatherly/NomnomlJS.jl/releases/download"
build_path = joinpath(@__DIR__, "build")
if ispath(build_path)
rm(build_path, force=true, recursive=true)
end
mkpath(build_path)
artifact_toml = joinpath(build_path, "..", "Artifacts.toml")
product_hash = mktempdir() do dir
cp(joinpath(@__DIR__, "index.js"), joinpath(dir, "index.js"))
cp(joinpath(@__DIR__, "package.json"), joinpath(dir, "package.json"))
cp(joinpath(@__DIR__, "package-lock.json"), joinpath(dir, "package-lock.json"))
run(Cmd(`npm ci`; dir=dir))
run(Cmd(`npx esbuild index.js --bundle --outfile=bundle.js --platform=node --target=node10`; dir=dir))
return create_artifact() do artifact_dir
cp(joinpath(dir, "bundle.js"), joinpath(artifact_dir, "index.js"))
end
end
archive_filename = "$pkgname-$version.tar.gz"
download_hash = archive_artifact(product_hash, joinpath(build_path, archive_filename))
bind_artifact!(
artifact_toml,
"nomnoml",
product_hash,
force=true,
download_info=Tuple[
(
"$host/$(escapeuri(string(version)))/$archive_filename",
download_hash,
),
],
)
end
build()