@@ -2,7 +2,7 @@ wasi_vfs = RubyWasm::WasiVfsProduct.new(File.join(Dir.pwd, "build"))
22wasi_sdk = TOOLCHAINS [ "wasi-sdk" ]
33tools = {
44 "WASI_VFS_CLI" => wasi_vfs . cli_bin_path ,
5- "WASMOPT" => wasi_sdk . wasm_opt ,
5+ "WASMOPT" => wasi_sdk . wasm_opt
66}
77
88namespace :npm do
@@ -39,7 +39,7 @@ namespace :npm do
3939 end
4040
4141 desc "Bump version"
42- task :bump_version , [ : package, : version] do |t , args |
42+ task :bump_version , %i[ package version ] do |t , args |
4343 require "json"
4444 package = args [ :package ] or raise "package name is required"
4545 version = args [ :version ] or raise "version is required"
@@ -54,17 +54,20 @@ namespace :npm do
5454 # Update package-lock.json
5555 Dir . chdir ( pkg_dir ) { sh "npm install" }
5656 # Update README.md and other docs
57- %x( git grep -l #{ pkg_name } @#{ old_version } ) . split . each do |file |
57+ ` git grep -l #{ pkg_name } @#{ old_version } ` . split . each do |file |
5858 content = File . read ( file )
5959 next_nightly = Date . today . strftime ( "%Y-%m-%d" )
60- content . gsub! ( /#{ pkg_name } @#{ old_version } -\d {4}-\d {2}-\d {2}-a/ , "#{ pkg_name } @#{ version } -#{ next_nightly } -a" )
60+ content . gsub! (
61+ /#{ pkg_name } @#{ old_version } -\d {4}-\d {2}-\d {2}-a/ ,
62+ "#{ pkg_name } @#{ version } -#{ next_nightly } -a"
63+ )
6164 content . gsub! ( /#{ pkg_name } @#{ old_version } / , "#{ pkg_name } @#{ version } " )
6265 File . write ( file , content )
6366 end
6467 end
6568
6669 desc "Build all npm packages"
67- multitask : all => NPM_PACKAGES . map { |pkg | pkg [ :name ] }
70+ multitask all : NPM_PACKAGES . map { |pkg | pkg [ :name ] }
6871end
6972
7073namespace :wapm do
@@ -76,7 +79,9 @@ namespace :wapm do
7679 wasi_vfs . install_cli
7780 wasi_sdk . install_binaryen
7881 base_dir = Dir . pwd
79- sh tools , "./build-package.sh #{ base_dir } /rubies/#{ pkg [ :build ] } " , chdir : pkg_dir
82+ sh tools ,
83+ "./build-package.sh #{ base_dir } /rubies/#{ pkg [ :build ] } " ,
84+ chdir : pkg_dir
8085 end
8186
8287 desc "Publish wapm package #{ pkg [ :name ] } "
@@ -87,10 +92,10 @@ namespace :wapm do
8792 end
8893end
8994
90- NPM_RELEASE_ARTIFACTS = [
91- " npm-ruby-head-wasm-emscripten" ,
92- " npm-ruby-head-wasm-wasi" ,
93- " npm-ruby-3_2-wasm-wasi" ,
95+ NPM_RELEASE_ARTIFACTS = %w [
96+ npm-ruby-head-wasm-emscripten
97+ npm-ruby-head-wasm-wasi
98+ npm-ruby-3_2-wasm-wasi
9499]
95100RELASE_ARTIFACTS =
96101 BUILD_TASKS . map do |build |
@@ -106,11 +111,11 @@ EOS
106111 BUILD_SOURCES . each do |name , source |
107112 case source [ :type ]
108113 when "github"
109- url = "https://api.github.com/repos/ #{ source [ :repo ] } /commits/ #{ source [ :rev ] } "
110- commit = OpenURI . open_uri ( url ) do | f |
111- JSON . load ( f . read )
112- end
113- output += "| #{ name } | [`#{ source [ :repo ] } @#{ commit [ "sha" ] } `](https://github.com/ruby/ruby/tree/#{ commit [ "sha" ] } ) |\n "
114+ url =
115+ "https://api.github.com/repos/ #{ source [ :repo ] } /commits/ #{ source [ :rev ] } "
116+ commit = OpenURI . open_uri ( url ) { | f | JSON . load ( f . read ) }
117+ output +=
118+ "| #{ name } | [`#{ source [ :repo ] } @#{ commit [ "sha" ] } `](https://github.com/ruby/ruby/tree/#{ commit [ "sha" ] } ) |\n "
114119 else
115120 raise "unknown source type: #{ source [ :type ] } "
116121 end
@@ -122,8 +127,12 @@ desc "Fetch artifacts of a run of GitHub Actions"
122127task :fetch_artifacts , [ :run_id ] do |t , args |
123128 RubyWasm ::Toolchain . check_executable ( "gh" )
124129
125- artifacts = JSON . load ( %x(gh api repos/{owner}/{repo}/actions/runs/#{ args [ :run_id ] } /artifacts) )
126- artifacts = artifacts [ "artifacts" ] . filter { RELASE_ARTIFACTS . include? ( _1 [ "name" ] ) }
130+ artifacts =
131+ JSON . load (
132+ `gh api repos/{owner}/{repo}/actions/runs/#{ args [ :run_id ] } /artifacts`
133+ )
134+ artifacts =
135+ artifacts [ "artifacts" ] . filter { RELASE_ARTIFACTS . include? ( _1 [ "name" ] ) }
127136 mkdir_p "release"
128137 Dir . chdir ( "release" ) do
129138 artifacts . each do |artifact |
@@ -141,12 +150,9 @@ task :publish, [:tag] do |t, args|
141150 RubyWasm ::Toolchain . check_executable ( "gh" )
142151
143152 nightly = /^\d {4}-\d {2}-\d {2}-.$/ . match? ( args [ :tag ] )
144- files = RELASE_ARTIFACTS . flat_map do |artifact |
145- Dir . glob ( "release/#{ artifact } /*" )
146- end
147- File . open ( "release/note.md" , "w" ) do |f |
148- f . print release_note
149- end
153+ files =
154+ RELASE_ARTIFACTS . flat_map { |artifact | Dir . glob ( "release/#{ artifact } /*" ) }
155+ File . open ( "release/note.md" , "w" ) { |f | f . print release_note }
150156 NPM_RELEASE_ARTIFACTS . each do |artifact |
151157 tarball = Dir . glob ( "release/#{ artifact } /*" )
152158 next if tarball . empty?
0 commit comments