funicular 0.0.1 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +79 -0
- data/README.md +66 -20
- data/Rakefile +103 -2
- data/demo/keymap_editor.html +582 -0
- data/demo/test_cable.html +179 -0
- data/demo/test_chartjs.html +235 -0
- data/demo/test_component.html +201 -0
- data/demo/test_diff_patch.html +146 -0
- data/demo/test_error_boundary.html +284 -0
- data/demo/test_router.html +257 -0
- data/demo/test_vdom.html +100 -0
- data/demo/tic-tac-toe.html +201 -0
- data/docs/architecture.md +118 -0
- data/exe/funicular +32 -0
- data/lib/funicular/assets/funicular.css +23 -0
- data/lib/funicular/assets/funicular.rb +21 -0
- data/lib/funicular/assets/funicular_debug.css +73 -0
- data/lib/funicular/assets/funicular_debug.js +183 -0
- data/lib/funicular/commands/routes.rb +69 -0
- data/lib/funicular/compiler.rb +143 -0
- data/lib/funicular/configuration.rb +76 -0
- data/lib/funicular/helpers/picoruby_helper.rb +112 -0
- data/lib/funicular/middleware.rb +123 -0
- data/lib/funicular/plugin.rb +147 -0
- data/lib/funicular/railtie.rb +26 -0
- data/lib/funicular/route_parser.rb +137 -0
- data/lib/funicular/schema.rb +167 -0
- data/lib/funicular/ssr/runtime.rb +101 -0
- data/lib/funicular/ssr.rb +51 -0
- data/lib/funicular/testing/node_runner.mjs +293 -0
- data/lib/funicular/testing/node_runner.rb +190 -0
- data/lib/funicular/testing.rb +22 -0
- data/lib/funicular/vendor/picorbc/VERSION +1 -0
- data/lib/funicular/vendor/picorbc/picorbc.js +5283 -0
- data/lib/funicular/vendor/picorbc/picorbc.wasm +0 -0
- data/lib/funicular/vendor/picoruby/VERSION +1 -0
- data/lib/funicular/vendor/picoruby/debug/init.iife.js +130 -0
- data/lib/funicular/vendor/picoruby/debug/picoruby.js +6423 -0
- data/lib/funicular/vendor/picoruby/debug/picoruby.wasm +0 -0
- data/lib/funicular/vendor/picoruby/dist/init.iife.js +130 -0
- data/lib/funicular/vendor/picoruby/dist/picoruby.js +2 -0
- data/lib/funicular/vendor/picoruby/dist/picoruby.wasm +0 -0
- data/lib/funicular/vendor/picoruby-test-node/VERSION +1 -0
- data/lib/funicular/vendor/picoruby-test-node/picoruby.js +6885 -0
- data/lib/funicular/vendor/picoruby-test-node/picoruby.wasm +0 -0
- data/lib/funicular/vendor/picoruby-test-node/picoruby.wasm.map +1 -0
- data/lib/funicular/version.rb +1 -1
- data/lib/funicular.rb +32 -1
- data/lib/generators/funicular/chat/chat_generator.rb +104 -0
- data/lib/generators/funicular/chat/templates/application_cable_channel.rb.tt +4 -0
- data/lib/generators/funicular/chat/templates/application_cable_connection.rb.tt +4 -0
- data/lib/generators/funicular/chat/templates/create_funicular_chat_messages.rb.tt +10 -0
- data/lib/generators/funicular/chat/templates/funicular_chat.css.tt +141 -0
- data/lib/generators/funicular/chat/templates/funicular_chat_channel.rb.tt +5 -0
- data/lib/generators/funicular/chat/templates/funicular_chat_component.rb.tt +135 -0
- data/lib/generators/funicular/chat/templates/funicular_chat_component_picotest.rb.tt +64 -0
- data/lib/generators/funicular/chat/templates/funicular_chat_controller.rb.tt +4 -0
- data/lib/generators/funicular/chat/templates/funicular_chat_message.rb.tt +13 -0
- data/lib/generators/funicular/chat/templates/funicular_chat_messages_controller.rb.tt +23 -0
- data/lib/generators/funicular/chat/templates/initializer.rb.tt +4 -0
- data/lib/generators/funicular/chat/templates/show.html.erb.tt +6 -0
- data/lib/tasks/funicular.rake +218 -0
- data/minitest/fixtures/funicular_app/components/greeting_component.rb +16 -0
- data/minitest/fixtures/funicular_app/initializer.rb +5 -0
- data/minitest/funicular_test.rb +13 -0
- data/minitest/hydration_test.rb +87 -0
- data/minitest/plugin_test.rb +51 -0
- data/minitest/schema_test.rb +106 -0
- data/minitest/ssr_test.rb +94 -0
- data/minitest/test_helper.rb +7 -0
- data/minitest/validations_test.rb +183 -0
- data/mrbgem.rake +16 -0
- data/mrblib/0_validations.rb +206 -0
- data/mrblib/1_validators.rb +180 -0
- data/mrblib/cable.rb +432 -0
- data/mrblib/component.rb +1050 -0
- data/mrblib/debug.rb +208 -0
- data/mrblib/differ.rb +254 -0
- data/mrblib/environment_inquirer.rb +34 -0
- data/mrblib/error_boundary.rb +125 -0
- data/mrblib/file_upload.rb +192 -0
- data/mrblib/form_builder.rb +300 -0
- data/mrblib/funicular.rb +245 -0
- data/mrblib/html_serializer.rb +121 -0
- data/mrblib/http.rb +183 -0
- data/mrblib/model.rb +196 -0
- data/mrblib/patcher.rb +269 -0
- data/mrblib/router.rb +266 -0
- data/mrblib/store.rb +304 -0
- data/mrblib/store_collection.rb +171 -0
- data/mrblib/store_singleton.rb +79 -0
- data/mrblib/styles.rb +83 -0
- data/mrblib/vdom.rb +273 -0
- data/sig/cable.rbs +66 -0
- data/sig/component.rbs +149 -0
- data/sig/debug.rbs +28 -0
- data/sig/differ.rbs +18 -0
- data/sig/environment_iquirer.rbs +10 -0
- data/sig/error_boundary.rbs +14 -0
- data/sig/file_upload.rbs +18 -0
- data/sig/form_builder.rbs +29 -0
- data/sig/funicular.rbs +24 -1
- data/sig/html_serializer.rbs +20 -0
- data/sig/http.rbs +37 -0
- data/sig/model.rbs +28 -0
- data/sig/patcher.rbs +18 -0
- data/sig/router.rbs +44 -0
- data/sig/store.rbs +89 -0
- data/sig/store_collection.rbs +43 -0
- data/sig/store_singleton.rbs +19 -0
- data/sig/styles.rbs +25 -0
- data/sig/validations.rbs +103 -0
- data/sig/vdom.rbs +59 -0
- metadata +154 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 42012485f28870d0316fa30ba1fbebd4699c07cb8e61e5d201874d2eafd50d04
|
|
4
|
+
data.tar.gz: ab7f7e473a32d0a00b8bca5b0c67fc7e7b91a9a7860724e53631ea7d08dbcc41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5488c967e48dd01768dc05acba5a350e07fb2fb5fc9ede01f5e06dd1274c1c4ee1fd7f0f4e76a2c616b74b8eff10260f5a14108d83798a34e25c3f785c4be7c7
|
|
7
|
+
data.tar.gz: 653010659b471071850c77dd459ff17984b906485cfcc9b396c3ecf1558686c353ca2ec65cc3940dad4497c79318515b833ff4219f7f9e301e93a041abbfbb30
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **Funicular::Store DSL**: Declarative client-side stores backed by
|
|
6
|
+
IndexedDB. Subclass `Funicular::Store::Singleton` (one value per scope)
|
|
7
|
+
or `Funicular::Store::Collection` (ordered list per scope) and use
|
|
8
|
+
class-level DSL (`database`, `scope`, `limit`, `key`, `expires_in`,
|
|
9
|
+
`cleared_on`, `subscribes_to`) to wire up persistence, TTL, event-based
|
|
10
|
+
clearing, and ActionCable integration.
|
|
11
|
+
- `Funicular::Store.dispatch(:event)` for coordinated store clearing
|
|
12
|
+
(e.g., logout wipes all stores registered with `cleared_on :logout`)
|
|
13
|
+
- `subscribes_to` DSL for embedding Cable message handling directly in
|
|
14
|
+
store classes; scopes gain `subscribe!` / `unsubscribe!` / `subscribed?`
|
|
15
|
+
- Lazy KVS initialization: stores open IndexedDB on first access, removing
|
|
16
|
+
the need for explicit `init!` calls in application initializers
|
|
17
|
+
- `Funicular::Store::Scope#on_change` / `off_change` for reactive UI
|
|
18
|
+
updates when store data changes
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- `Funicular::Cable::Consumer` now automatically resubscribes all active
|
|
23
|
+
subscriptions after WebSocket reconnect (`resubscribe_all`)
|
|
24
|
+
|
|
25
|
+
## [0.1.0] - 2026-04-20
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Consolidated with picoruby-funicular: merged the full PicoRuby frontend
|
|
30
|
+
framework into this gem, including Component, Cable, VDOM, Router,
|
|
31
|
+
FormBuilder, Model, HTTP, FileUpload, ErrorBoundary, Styles, Differ,
|
|
32
|
+
Patcher, Debug, and EnvironmentInquirer, along with RBS signatures and
|
|
33
|
+
comprehensive test suite
|
|
34
|
+
- Bundle PicoRuby.wasm and picorbc WASM artifacts into the gem via a
|
|
35
|
+
`rake copy_wasm` task; artifacts are vendored at build time so no
|
|
36
|
+
runtime npm lookup is required
|
|
37
|
+
- `Funicular::Configuration` with per-environment PicoRuby.wasm source
|
|
38
|
+
selection (`:local_debug`, `:local_dist`, `:cdn`) and optional
|
|
39
|
+
`cdn_version` override
|
|
40
|
+
- `picoruby_include_tag` view helper (auto-registered via Railtie) that
|
|
41
|
+
serves the appropriate PicoRuby.wasm build per environment
|
|
42
|
+
- `funicular:install:wasm` rake sub-task to copy dist/debug WASM builds
|
|
43
|
+
into `public/picoruby/`
|
|
44
|
+
- Rails Asset Pipeline integration: Rack middleware, compiler, and
|
|
45
|
+
`funicular:compile` / `funicular:install` rake tasks
|
|
46
|
+
- `funicular routes` CLI command and `Funicular::RouteParser` to inspect
|
|
47
|
+
Rails routes from the command line
|
|
48
|
+
- Component Debug Highlighter: CSS/JS assets (`funicular_debug.css`,
|
|
49
|
+
`funicular_debug.js`) that highlight the selected component in the
|
|
50
|
+
browser
|
|
51
|
+
- `ENV['FUNICULAR_ENV']` is now set from `Rails.env` in generated
|
|
52
|
+
`application.rb`
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
|
|
56
|
+
- picorbc is now resolved from a vendored WASM artifact; removed
|
|
57
|
+
npm-based picorbc lookup and all `PICORBC_VERSION` environment variable
|
|
58
|
+
logic
|
|
59
|
+
- Upgraded picorbc to the latest version
|
|
60
|
+
- Switched test framework from test/unit to minitest
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
|
|
64
|
+
- Asset pipeline: middleware now detects whether `app.mrb` has actually
|
|
65
|
+
changed before recompiling, preventing unnecessary rebuilds
|
|
66
|
+
- XSS vulnerabilities in VDOM attribute handling: expanded
|
|
67
|
+
`URL_ATTRIBUTES` constant, applied case-insensitive `javascript:` URI
|
|
68
|
+
blocking, and added the same URL validation to `Patcher#update_props`
|
|
69
|
+
and `Patcher#create_element`
|
|
70
|
+
- XSS vulnerability in Debug module: replaced manual JSON string
|
|
71
|
+
concatenation with `JSON.generate` to eliminate escaping gaps
|
|
72
|
+
- `funicular:compile` rake task
|
|
73
|
+
- `funicular:install` rake task
|
|
74
|
+
- Rack middleware
|
|
75
|
+
- RBS type signatures
|
|
76
|
+
|
|
77
|
+
### Removed
|
|
78
|
+
|
|
79
|
+
- Debugger Chrome extension (`debugger/` directory)
|
|
80
|
+
- `.ruby-version` file
|
|
81
|
+
|
|
3
82
|
## [0.0.1] - 2025-11-27
|
|
4
83
|
|
|
5
84
|
- Initial release
|
data/README.md
CHANGED
|
@@ -1,43 +1,89 @@
|
|
|
1
1
|
# Funicular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> 🎵Funicu-lì, Funicu-là!🚊🚊🚊
|
|
4
|
+
>
|
|
5
|
+
> 🎵Funicu-lì, Funicu-là!🚞🚞🚞
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
**Funicular** is a single-page application (SPA) framework powered by PicoRuby.wasm.
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## Features
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
- Write client-side code in Ruby instead of JavaScript
|
|
12
|
+
- Seamless Rails integration
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
## Combined Gem
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
This repository consists of three relevant projects:
|
|
17
|
+
|
|
18
|
+
- PicoGem "picoruby-funicular" ... Core implementation
|
|
19
|
+
- CRubyGem "funicular" ... Rails integration
|
|
20
|
+
- Chrome extension "PicoRuby Debugger"
|
|
21
|
+
|
|
22
|
+
### PicoGem "picoruby-funicular"
|
|
23
|
+
|
|
24
|
+
```console
|
|
25
|
+
.
|
|
26
|
+
├── mrbgem.rake
|
|
27
|
+
├── mrblib/
|
|
28
|
+
└── test/
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### CRubyGem "funicular"
|
|
32
|
+
|
|
33
|
+
```console
|
|
34
|
+
.
|
|
35
|
+
├── bin/
|
|
36
|
+
├── exe/
|
|
37
|
+
├── funicular.gemspec
|
|
38
|
+
├── Gemfile
|
|
39
|
+
├── Gemfile.lock
|
|
40
|
+
├── lib/
|
|
41
|
+
├── minitest/
|
|
42
|
+
└── Rakefile
|
|
15
43
|
```
|
|
16
44
|
|
|
17
|
-
|
|
45
|
+
### Chrome extention "PicoRuby.wasm debugger"
|
|
18
46
|
|
|
19
|
-
```
|
|
20
|
-
|
|
47
|
+
```console
|
|
48
|
+
.
|
|
49
|
+
└── debugger/
|
|
21
50
|
```
|
|
22
51
|
|
|
23
|
-
|
|
52
|
+
----
|
|
53
|
+
|
|
54
|
+
The others are common resources.
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
|
|
58
|
+
User documentation is hosted on **picoruby.org**:
|
|
24
59
|
|
|
25
|
-
|
|
60
|
+
- [Getting Started with Funicular](https://picoruby.org/funicular-getting-started) — a standalone, no-Rails tutorial
|
|
61
|
+
- [Funicular on Rails](https://picoruby.org/funicular-on-rails) — installation, the asset pipeline, and a feature-by-feature tutorial plus reference (components, routing, forms, data fetching, stores, realtime, SSR, styling, debugging)
|
|
62
|
+
|
|
63
|
+
For contributors working on the gem itself, see [docs/architecture.md](docs/architecture.md).
|
|
26
64
|
|
|
27
65
|
## Development
|
|
28
66
|
|
|
29
|
-
|
|
67
|
+
This repository is a submodule of [picoruby/picoruby](https://github.com/picoruby/picoruby).
|
|
68
|
+
Do not check it out standalone. Instead, clone the parent repository and work from there:
|
|
30
69
|
|
|
31
|
-
|
|
70
|
+
```console
|
|
71
|
+
git clone --recurse-submodules https://github.com/picoruby/picoruby.git
|
|
72
|
+
cd picoruby/mrbgems/picoruby-funicular
|
|
73
|
+
```
|
|
32
74
|
|
|
33
|
-
|
|
75
|
+
The CRubyGem side (`lib/`, `funicular.gemspec`, etc.) can be developed and tested independently inside that directory, but `rake copy_wasm` — which vendorsthe PicoRuby.wasm and picorbc wasm artifacts into the gem — relies on sibling directories within the picoruby repository (`mrbgems/picoruby-wasm/npm/`).
|
|
76
|
+
Running it from a standalone checkout will fail.
|
|
34
77
|
|
|
35
|
-
|
|
78
|
+
## Testing
|
|
36
79
|
|
|
37
|
-
|
|
80
|
+
- CRubygem (Rails integration) test: `rake test` in this repository
|
|
81
|
+
- PicoGem Funicular test: `rake test:gems:picoruby[picoruby-funicular]` in picoruby where mrbgems/picoruby-funicular exists as a submodule
|
|
38
82
|
|
|
39
|
-
|
|
83
|
+
## Contributing
|
|
84
|
+
|
|
85
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/picoruby/funicular.
|
|
40
86
|
|
|
41
|
-
##
|
|
87
|
+
## License
|
|
42
88
|
|
|
43
|
-
|
|
89
|
+
Copyright © 2025- HASUMI Hitoshi. See MIT-LICENSE for further details.
|
data/Rakefile
CHANGED
|
@@ -4,9 +4,110 @@ require "bundler/gem_tasks"
|
|
|
4
4
|
require "rake/testtask"
|
|
5
5
|
|
|
6
6
|
Rake::TestTask.new(:test) do |t|
|
|
7
|
-
t.libs << "
|
|
7
|
+
t.libs << "minitest"
|
|
8
8
|
t.libs << "lib"
|
|
9
|
-
t.test_files = FileList["
|
|
9
|
+
t.test_files = FileList["minitest/**/*_test.rb"]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
task default: :test
|
|
13
|
+
|
|
14
|
+
desc "Copy picoruby and picorbc wasm artifacts from picoruby-wasm into the gem"
|
|
15
|
+
task :copy_wasm do
|
|
16
|
+
require "fileutils"
|
|
17
|
+
require "json"
|
|
18
|
+
|
|
19
|
+
vendor_root = File.expand_path("lib/funicular/vendor", __dir__)
|
|
20
|
+
|
|
21
|
+
# PICORUBY_WASM_NPM_DIR overrides the default search path.
|
|
22
|
+
# Default: picoruby-wasm is a sibling of picoruby-funicular under mrbgems/.
|
|
23
|
+
npm_root = ENV["PICORUBY_WASM_NPM_DIR"] ||
|
|
24
|
+
File.expand_path("../picoruby-wasm/npm", __dir__)
|
|
25
|
+
|
|
26
|
+
unless Dir.exist?(npm_root)
|
|
27
|
+
abort "picoruby-wasm npm directory not found: #{npm_root}\n" \
|
|
28
|
+
"Set PICORUBY_WASM_NPM_DIR to override, and ensure picoruby-wasm has been built."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# ------------------------------------------------------------------
|
|
32
|
+
# 1) PicoRuby runtime (browser): dist + debug
|
|
33
|
+
# ------------------------------------------------------------------
|
|
34
|
+
picoruby_src = File.join(npm_root, "picoruby")
|
|
35
|
+
picoruby_dest = File.join(vendor_root, "picoruby")
|
|
36
|
+
abort "Missing #{picoruby_src}" unless Dir.exist?(picoruby_src)
|
|
37
|
+
|
|
38
|
+
picoruby_version = JSON.parse(File.read(File.join(picoruby_src, "package.json"))).fetch("version")
|
|
39
|
+
picoruby_files = %w[picoruby.wasm picoruby.js init.iife.js]
|
|
40
|
+
|
|
41
|
+
%w[dist debug].each do |variant|
|
|
42
|
+
src = File.join(picoruby_src, variant)
|
|
43
|
+
dst = File.join(picoruby_dest, variant)
|
|
44
|
+
abort "Missing source variant: #{src}" unless Dir.exist?(src)
|
|
45
|
+
|
|
46
|
+
FileUtils.rm_rf(dst)
|
|
47
|
+
FileUtils.mkdir_p(dst)
|
|
48
|
+
picoruby_files.each do |fname|
|
|
49
|
+
src_file = File.join(src, fname)
|
|
50
|
+
abort "Missing file: #{src_file}" unless File.exist?(src_file)
|
|
51
|
+
# FileUtils.copy_file follows symlinks, so debug/init.iife.js
|
|
52
|
+
# (a symlink to ../dist/init.iife.js) is materialized.
|
|
53
|
+
FileUtils.copy_file(src_file, File.join(dst, fname))
|
|
54
|
+
end
|
|
55
|
+
puts " copied picoruby/#{variant}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
File.write(File.join(picoruby_dest, "VERSION"), "#{picoruby_version}\n")
|
|
59
|
+
puts " wrote picoruby/VERSION (#{picoruby_version})"
|
|
60
|
+
|
|
61
|
+
# ------------------------------------------------------------------
|
|
62
|
+
# 2) picorbc compiler (node CLI, run by Funicular::Compiler)
|
|
63
|
+
# ------------------------------------------------------------------
|
|
64
|
+
picorbc_src = File.join(npm_root, "picorbc", "debug")
|
|
65
|
+
picorbc_dest = File.join(vendor_root, "picorbc")
|
|
66
|
+
abort "Missing #{picorbc_src}" unless Dir.exist?(picorbc_src)
|
|
67
|
+
|
|
68
|
+
picorbc_version = JSON.parse(File.read(File.join(npm_root, "picorbc", "package.json"))).fetch("version")
|
|
69
|
+
picorbc_files = %w[picorbc.js picorbc.wasm]
|
|
70
|
+
|
|
71
|
+
FileUtils.rm_rf(picorbc_dest)
|
|
72
|
+
FileUtils.mkdir_p(picorbc_dest)
|
|
73
|
+
picorbc_files.each do |fname|
|
|
74
|
+
src_file = File.join(picorbc_src, fname)
|
|
75
|
+
abort "Missing file: #{src_file}" unless File.exist?(src_file)
|
|
76
|
+
FileUtils.copy_file(src_file, File.join(picorbc_dest, fname))
|
|
77
|
+
end
|
|
78
|
+
File.chmod(0755, File.join(picorbc_dest, "picorbc.js"))
|
|
79
|
+
File.write(File.join(picorbc_dest, "VERSION"), "#{picorbc_version}\n")
|
|
80
|
+
puts " copied picorbc (#{picorbc_version})"
|
|
81
|
+
|
|
82
|
+
# ------------------------------------------------------------------
|
|
83
|
+
# 3) PicoRuby runtime for DOM-backed Node.js tests
|
|
84
|
+
# ------------------------------------------------------------------
|
|
85
|
+
test_runtime_src = ENV["PICORUBY_WASM_TEST_DIR"] ||
|
|
86
|
+
File.expand_path("../../build/picoruby-wasm-test/bin", __dir__)
|
|
87
|
+
test_runtime_dest = File.join(vendor_root, "picoruby-test-node")
|
|
88
|
+
test_runtime_files = %w[picoruby.js picoruby.wasm]
|
|
89
|
+
optional_test_runtime_files = %w[picoruby.wasm.map]
|
|
90
|
+
|
|
91
|
+
unless Dir.exist?(test_runtime_src)
|
|
92
|
+
abort "PicoRuby WASM test runtime not found: #{test_runtime_src}\n" \
|
|
93
|
+
"Run `MRUBY_CONFIG=picoruby-wasm-test rake all` from the picoruby checkout, " \
|
|
94
|
+
"or set PICORUBY_WASM_TEST_DIR to the directory containing picoruby.js."
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
FileUtils.rm_rf(test_runtime_dest)
|
|
98
|
+
FileUtils.mkdir_p(test_runtime_dest)
|
|
99
|
+
test_runtime_files.each do |fname|
|
|
100
|
+
src_file = File.join(test_runtime_src, fname)
|
|
101
|
+
abort "Missing file: #{src_file}" unless File.exist?(src_file)
|
|
102
|
+
FileUtils.copy_file(src_file, File.join(test_runtime_dest, fname))
|
|
103
|
+
end
|
|
104
|
+
optional_test_runtime_files.each do |fname|
|
|
105
|
+
src_file = File.join(test_runtime_src, fname)
|
|
106
|
+
FileUtils.copy_file(src_file, File.join(test_runtime_dest, fname)) if File.exist?(src_file)
|
|
107
|
+
end
|
|
108
|
+
File.write(File.join(test_runtime_dest, "VERSION"), "#{picoruby_version}\n")
|
|
109
|
+
puts " copied picoruby-test-node (#{picoruby_version})"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Make sure the wasm artifacts are refreshed before the gem is packaged for release.
|
|
113
|
+
Rake::Task["build"].enhance([:copy_wasm])
|