Compare commits

..

404 Commits

Author SHA1 Message Date
Lucien Greathouse
38cd13dc0c 0.5.0-alpha.1 2019-01-25 18:01:37 -08:00
Lucien Greathouse
14fd470363 Upgrade all dependencies, including new rbx_ crates 2019-01-25 17:54:16 -08:00
Lucien Greathouse
fc8d9dc1fe Wrap main call in a panic handler to show a nice error message on panic 2019-01-25 10:54:54 -08:00
Lucien Greathouse
1659adb419 Refactor entrypoint to be a bit easier to read 2019-01-25 10:32:10 -08:00
Lucien Greathouse
6490b77d4c plugin: Hide placeholder inputs when focused 2019-01-23 18:18:00 -08:00
Lucien Greathouse
23463b620e Rename test-plugin-project to place-project.json 2019-01-23 18:14:05 -08:00
Lucien Greathouse
6bc331be75 Update formatting of test plugin project 2019-01-23 18:10:59 -08:00
Lucien Greathouse
87f6410877 Clean up error handling in plugin 2019-01-23 18:10:53 -08:00
Lucien Greathouse
b1ddfc3a49 Fix adding/removing files in folders that have init scripts 2019-01-23 18:10:29 -08:00
Lucien Greathouse
d01e757d2f UI visual tweaks 2019-01-21 18:34:10 -08:00
Lucien Greathouse
e593ce0420 Redesign UI 2019-01-21 17:50:49 -08:00
Lucien Greathouse
578abfabb3 Partial plugin retheme 2019-01-21 16:02:51 -08:00
Lucien Greathouse
aa7b7e43ff Move CHANGELOG closer to keepachangelog.com format 2019-01-21 13:08:50 -08:00
Lucien Greathouse
af4d4e0246 Revamp CHANGES, rename to CHANGELOG 2019-01-21 13:06:14 -08:00
Lucien Greathouse
fecb11cba4 Adjust logging and error handling in the client
* HTTP responses in the error range (400+) now properly turn into errors
* ROJO_EPIPHANY_DEV_CREATE now creates more verbose configuration
* Default configuration values are now much more explicit
* Errors that cause session termination are labeled more clearly.
2019-01-21 10:57:03 -08:00
Lucien Greathouse
614f886008 Fix misnamed metadata coming from server 2019-01-21 10:56:01 -08:00
Lucien Greathouse
6fcb895d70 Tweak bottom of README, move LICENSE to LICENSE.txt 2019-01-18 20:57:19 -08:00
Lucien Greathouse
5a98ede45e Tweak features section of README 2019-01-18 13:49:47 -08:00
Lucien Greathouse
779d462932 Rename Session to LiveSession, a better name 2019-01-17 18:24:49 -08:00
Lucien Greathouse
e301116e87 Make rbx visualization less noisy, removing paths 2019-01-17 17:45:24 -08:00
Lucien Greathouse
bd3a4a719d Normalize metadata into metadata per instance and metadata per path (#107)
* Begin the metadata merge trek

* Tidy up path metadata, entry API, begin implementing

* Flesh out use of PathMap Entry API

* Metadata per instance is a go

* Tidy up naming for metadata per instance

* SnapshotMetadata -> SnapshotContext
2019-01-17 16:48:49 -08:00
Lucien Greathouse
4cfdc72c00 Fix folders having empty names 2019-01-16 17:28:06 -08:00
Lucien Greathouse
3620a9d256 Thread Cow<'str> through for naming nodes 2019-01-16 16:36:22 -08:00
Lucien Greathouse
f254a51d59 Remove unused config button 2019-01-16 00:01:40 -08:00
Lucien Greathouse
99bbe58255 Fix server to correctly resolve module script names 2019-01-15 23:58:25 -08:00
Lucien Greathouse
a400abff4c Switch assets to use custom rounded rectangle 2019-01-15 23:58:10 -08:00
Lucien Greathouse
585806837e Port over to new snapshot system 2019-01-15 18:04:06 -08:00
Lucien Greathouse
249aa999a3 Refactor mostly complete 2019-01-15 17:26:51 -08:00
Lucien Greathouse
aae1d8b34f Add impl_from! macro to shorten up error code 2019-01-15 13:08:02 -08:00
Lucien Greathouse
9d3638fa46 Remove remaining 'extern crate' declarations 2019-01-15 12:44:49 -08:00
Lucien Greathouse
5b2a830d2d Remove #[macro_use] from log crate 2019-01-15 12:43:02 -08:00
Lucien Greathouse
b87943e39d Clean up and document code throughout the server 2019-01-15 12:38:31 -08:00
Lucien Greathouse
c421fd0b25 Add docs link for 0.5.x to complement 0.4.x 2019-01-14 18:36:04 -08:00
Lucien Greathouse
a1395a382a Support semver metadata in plugin version 2019-01-14 18:23:10 -08:00
Lucien Greathouse
a54364642a Upgrade to rbx_tree and friends 0.1.0 2019-01-14 18:21:01 -08:00
Lucien Greathouse
14ab85adbd Remove instanceMetadataMap from ApiContext 2019-01-14 17:23:43 -08:00
Lucien Greathouse
c284b7de40 Remove instanceMetadataMap from plugin 2019-01-14 17:23:43 -08:00
Lucien Greathouse
e23056ac2f Change API to message metadata inline and add visualization 2019-01-14 17:23:43 -08:00
Lucien Greathouse
8ce2e605a2 Remove site_url 2019-01-12 16:34:02 -08:00
Lucien Greathouse
9408247708 Update CHANGELOG 2019-01-12 15:58:45 -08:00
Lucien Greathouse
3e1c467b65 Upgrade and pin deps so that rbx-tree can break some APIs 2019-01-11 18:19:06 -08:00
Lucien Greathouse
811db2e668 0.5.0-alpha.0 2019-01-11 17:53:47 -08:00
Lucien Greathouse
f833642733 Adjust sizing on connection box 2019-01-11 15:51:25 -08:00
Lucien Greathouse
30ce927621 Refactor Session and ApiContext to allow cancelation 2019-01-11 15:45:32 -08:00
Lucien Greathouse
f21f01be1a Factor out form text input 2019-01-11 15:26:25 -08:00
Lucien Greathouse
d81eaa6c13 Revamp UI using Kenney UI assets 2019-01-11 14:10:02 -08:00
Lucien Greathouse
5ad830a6d7 Set up icons, make UI a little more resiliant 2019-01-11 11:57:15 -08:00
Lucien Greathouse
14e1829164 Upgrade dependencies, which makes some rbxm models now work 2019-01-10 18:31:43 -08:00
Lucien Greathouse
0a2810a98b Scaffold out model file support, still needs working decoders 2019-01-10 17:48:19 -08:00
Lucien Greathouse
7b84fce737 Fix syncing projects that mention properties with elevated permissions.
Permission errors aren't reported since I'm not sure what the user could do about them.
Some properties can be set in the model format but not in live-sync mode, like HttpEnabled.
2019-01-10 16:57:44 -08:00
Lucien Greathouse
1e1b409f8b Add support for StringValue instances
Closes #93.
2019-01-10 16:56:43 -08:00
Lucien Greathouse
5f91a8fdfe Fix bug where HTTP being disabled would cause stickiness 2019-01-10 16:12:52 -08:00
Lucien Greathouse
5bb70c2675 Fix up plugin project naming 2019-01-10 15:32:50 -08:00
Lucien Greathouse
ed6d8415bd Make plugin output less verbose 2019-01-10 15:29:38 -08:00
Lucien Greathouse
d53ffd8da2 Add support for uploading models, rename place_id to asset_id 2019-01-10 14:31:41 -08:00
Lucien Greathouse
d52ecaa050 Stop building documentation root, only version-specific docs 2019-01-10 11:15:11 -08:00
Lucien Greathouse
9ac001bd3e Stupid workaround for Git statting files on branch switch 2019-01-09 23:22:42 -08:00
Lucien Greathouse
4b81166782 Pull after switching branches in generate-docs 2019-01-09 23:19:52 -08:00
Lucien Greathouse
95866d0f2e Multiple versions of the docs 2019-01-09 23:14:59 -08:00
Lucien Greathouse
54b8a1aea5 Upgrade to latest MkDocs 2019-01-09 23:10:15 -08:00
Lucien Greathouse
0822aa9240 Update docs for Epiphany 2019-01-09 22:25:04 -08:00
Lucien Greathouse
c883850142 Support -o for build as an --output alias 2019-01-09 22:04:24 -08:00
Lucien Greathouse
54da826447 Implement rojo init for models 2019-01-09 21:30:00 -08:00
Lucien Greathouse
ce5ea92076 Add maplit, flesh out 'init' place command 2019-01-09 21:27:10 -08:00
Lucien Greathouse
98f8c5c0f2 Working 'init' command for places 2019-01-09 21:16:08 -08:00
Lucien Greathouse
6ced8f32b1 Make rojo-e2e a lib so 'cargo run' works again 2019-01-09 20:52:00 -08:00
Lucien Greathouse
f870107c66 Foundations for actual 'rojo init' implementation 2019-01-09 18:16:58 -08:00
Lucien Greathouse
4e7aa5d0a9 Expand changelog 2019-01-09 16:56:39 -08:00
Lucien Greathouse
779bcaeccb Fix CI build (hopefully), migrate to using Cargo workspace 2019-01-09 16:49:23 -08:00
Lucien Greathouse
f2849357f8 Remove crusty example, add property to single-sync-point 2019-01-09 16:28:44 -08:00
Lucien Greathouse
998fca721a Add support for properties metadata in project files 2019-01-09 16:28:31 -08:00
Lucien Greathouse
a83c68f2fc Update dependencies 2019-01-09 16:28:17 -08:00
Lucien Greathouse
665809e11a Remove accidental place file 2019-01-09 16:18:56 -08:00
Lucien Greathouse
a306fa26e0 Add extra diagnostic trace for path_created_or_updated 2019-01-09 13:47:58 -08:00
Lucien Greathouse
9574f8ebd7 Improve snapshot error robustness
* Unknown files are now ignored
* Errors bubble up a level higher
2019-01-09 13:40:46 -08:00
Lucien Greathouse
b62d946f83 Stub out new 'init' command 2019-01-09 11:23:00 -08:00
Lucien Greathouse
b26b36da5d Update CHANGES 2019-01-09 10:52:18 -08:00
Lucien Greathouse
8d640ab467 Add more alternative projects to README 2019-01-09 10:18:21 -08:00
Lucien Greathouse
eff4301027 Add case in reconciler to handle LocalizationTable Contents 2019-01-08 18:30:09 -08:00
Lucien Greathouse
0be4e6921d Implement CSV-format LocalizationTable serialization 2019-01-08 18:16:04 -08:00
Lucien Greathouse
049875e8fc Update plugin config to work with Git master Rojo 2019-01-08 17:19:26 -08:00
Lucien Greathouse
b9f7d3d889 Smarter reconciliation algorithm 2019-01-08 14:23:48 -08:00
Lucien Greathouse
70ba101fe1 Add more types in rbx_snapshot 2019-01-08 11:28:57 -08:00
Lucien Greathouse
b2753cb268 Tidy and document RbxSession more 2019-01-08 11:18:35 -08:00
Lucien Greathouse
11f398b553 Improve init script support
- init.server.lua and init.client.lua are now supported again
- Updating an init script no longer nukes its parent
2019-01-08 10:53:36 -08:00
Lucien Greathouse
24a4099d82 Add TODOs to upload 2019-01-07 14:13:02 -08:00
Lucien Greathouse
99ea374fc5 Add 'upload' command to publish places to Roblox for you 2019-01-07 14:01:53 -08:00
Lucien Greathouse
1992ce1cfb server: Update dependencies 2019-01-07 14:01:34 -08:00
Lucien Greathouse
2724534156 Factor out reconciliation into separate module 2019-01-04 18:34:48 -08:00
Lucien Greathouse
c57989a790 plugin: Title bar in session window, clean up Config 2019-01-04 18:23:11 -08:00
Lucien Greathouse
1888c83b6e server: Update dependencies 2019-01-04 18:22:53 -08:00
Lucien Greathouse
837fd22254 Update README to indicate that the new year happened 2019-01-04 15:44:59 -08:00
Lucien Greathouse
02a3da111a plugin: Fix test runner for new TestEZ 2019-01-04 14:55:53 -08:00
Lucien Greathouse
5c2bf65eaa protocol/config: ignoreUnknown -> ignoreUnknownInstances 2019-01-04 14:30:00 -08:00
Lucien Greathouse
b5ae6a5785 server: Fix broken test from adding more Project fields 2019-01-04 14:21:16 -08:00
Lucien Greathouse
699e07a0f7 plugin: Add support for expectedPlaceIds in the protocol 2019-01-04 14:11:33 -08:00
Lucien Greathouse
b8025452bf server: Make servePlaceId into a list of IDs, servePlaceIds 2019-01-04 14:11:06 -08:00
Lucien Greathouse
1138c05dff plugin: Remove unused import 2019-01-04 13:49:08 -08:00
Lucien Greathouse
ae36688bf2 server: Add servePlaceId for verifying correct place IDs 2019-01-04 13:48:50 -08:00
Lucien Greathouse
64e2ef3d3b Fix build issue, add servePort project option 2019-01-04 13:40:10 -08:00
Lucien Greathouse
9cfeee0577 server: Make 'rojo serve' respect --port option 2019-01-04 13:26:09 -08:00
Lucien Greathouse
86e0f3fabe plugin: UI pretty much done 2019-01-04 11:54:12 -08:00
Lucien Greathouse
edcb3d8638 plugin: ConnectPanel now accepts button callbacks 2019-01-04 11:02:54 -08:00
Lucien Greathouse
1582d8f504 plugin: Migrate 'merge' utility into Dictionary module 2019-01-04 10:59:47 -08:00
Lucien Greathouse
5816bb64dc Start work on plugin UI, this is pretty painful 2019-01-03 18:06:24 -08:00
Lucien Greathouse
b7a28aa511 Upgrade all plugin dependencies 2019-01-03 18:06:11 -08:00
Lucien Greathouse
37ed80055b Remove unused import 2019-01-03 16:28:25 -08:00
Lucien Greathouse
e6c2f1c15d Cleaned up and polished session flow
- Sessions can now be restarted if they error
- Terminology is much easier to follow in the plugin
- More change cases are handled correctly
2019-01-03 15:23:23 -08:00
Lucien Greathouse
a74c11aef5 Expand visualization to show IDs 2019-01-03 15:22:38 -08:00
Lucien Greathouse
ad3999066d Expand diagnostics and exploratively fix some edge cases 2019-01-02 15:16:23 -08:00
Lucien Greathouse
77c10d14c9 Support changing instance ClassName 2019-01-02 14:19:41 -08:00
Lucien Greathouse
8c2e430a56 Add more diagnostics 2019-01-02 14:19:26 -08:00
Lucien Greathouse
0aaefe9a66 C:/Program Files/Git/api/visualize -> /visualize/rbx, added /visualize/imfs 2019-01-02 14:00:35 -08:00
Lucien Greathouse
14db86e4b7 Fix luacheck errors 2019-01-02 13:11:29 -08:00
Lucien Greathouse
9949a6c9ee Implement more reconciliation 2019-01-02 00:21:19 -08:00
Lucien Greathouse
9bf5bd11e2 Add visualization stuff using GraphViz at /api/visualize 2019-01-02 00:18:28 -08:00
Lucien Greathouse
a3cc39cd92 Attempt to preserve sync point names 2019-01-01 23:46:15 -08:00
Lucien Greathouse
45af35cccd Enable stable Rust again 2019-01-01 17:02:46 -08:00
Lucien Greathouse
20e9688268 Fininsh config -> metadata migration 2019-01-01 15:59:26 -08:00
Lucien Greathouse
3be5988083 config_map -> instance_metadata_map 2019-01-01 14:13:21 -08:00
Lucien Greathouse
474d877290 Plugin half of configMap 2018-12-30 22:58:12 -08:00
Lucien Greathouse
b6a2b7dded Fix naming for InstanceProjectNodeConfig 2018-12-30 22:57:22 -08:00
Lucien Greathouse
2e42c28485 Add execute permission to test-scratch-project 2018-12-30 22:57:08 -08:00
Lucien Greathouse
4453211c0d Server component of config maps 2018-12-30 22:43:23 -08:00
Lucien Greathouse
01dd603bd5 Vertically align output for monospace consoles 2018-12-30 21:25:40 -08:00
Lucien Greathouse
fff71e1de0 Accept connections from all addresses 2018-12-30 21:25:22 -08:00
Lucien Greathouse
c0ffbd360e Fix name assignment for sync points 2018-12-30 20:21:46 -08:00
Lucien Greathouse
2f1aadd497 Tinkering with zero testing 2018-12-29 22:59:41 -08:00
Lucien Greathouse
645ab0ae98 Fix up test scratch project snippet to accept a project as an arg 2018-12-17 18:38:29 -08:00
Lucien Greathouse
9ac7ebc335 Hacky reify/reconcile stuff, mostly works 2018-12-17 18:37:38 -08:00
Lucien Greathouse
d807d22350 Basic reification, works for model-like projects but not place-like ones 2018-12-17 17:52:00 -08:00
Lucien Greathouse
05594ecca0 Update timeout detection 2018-12-17 17:51:25 -08:00
Lucien Greathouse
a511a5b259 Upgrade dependencies 2018-12-17 17:36:03 -08:00
Lucien Greathouse
9125f96302 Get rid of intermediate 'modules' folder in plugin 2018-12-17 17:23:07 -08:00
Lucien Greathouse
1b9ab43b6d Path and change tracking working 2018-12-17 17:06:14 -08:00
Lucien Greathouse
1176c9bbf1 Add little harness to test against a new project without accidentally committing junk 2018-12-17 17:05:58 -08:00
Lucien Greathouse
65e551c5cf Move InstanceChanges into rbx_snapshot 2018-12-17 14:20:19 -08:00
Lucien Greathouse
8fadafcd24 Track instance changes inside rbx_snapshot 2018-12-17 14:18:32 -08:00
Lucien Greathouse
57442a4848 Make MessageQueue generic, collapse Message into a single struct 2018-12-17 13:22:29 -08:00
Lucien Greathouse
7154f2c328 Reorganize and clean up rbx_snapshot a bit 2018-12-17 13:02:40 -08:00
Lucien Greathouse
e3e4809446 Flesh out project loading tests 2018-12-17 12:50:40 -08:00
Lucien Greathouse
5707b8c7e8 Descent-based create/update mechanism 2018-12-14 23:34:31 -08:00
Lucien Greathouse
f125814847 Trim up dead/dying code 2018-12-14 21:42:38 -08:00
Lucien Greathouse
893587040d Permute order of FS change events semi-exhaustively 2018-12-14 21:31:48 -08:00
Lucien Greathouse
308369b14f Implement more tests, fix up removal 2018-12-14 18:37:11 -08:00
Lucien Greathouse
9516a1aeea Rework Imfs and expand tests a bit 2018-12-14 18:03:56 -08:00
Lucien Greathouse
f43dc99f7a Imfs test 2018-12-14 14:33:45 -08:00
Lucien Greathouse
3feb8c3344 Fix midnight naming 2018-12-13 15:39:39 -08:00
Lucien Greathouse
4d0a2b806c Remove RbxSnapshotValue for RbxValue
We can always change RbxValue to use Cow<'a, str> instead of String later if perf needs it
2018-12-13 10:53:32 -08:00
Lucien Greathouse
a89fff1a22 Add missing pieces of commit 2018-12-12 23:37:06 -08:00
Lucien Greathouse
52f01da400 Flesh out reconciler routine 2018-12-12 23:11:59 -08:00
Lucien Greathouse
b732c43274 Trimming of stuff to get into the snapshotting mood 2018-12-12 13:56:11 -08:00
Lucien Greathouse
ee0a5cada3 Snapshot madness 2018-12-11 23:30:53 -08:00
Lucien Greathouse
dbd499701f Snapshot tinkering, this is an idea 2018-12-11 18:23:20 -08:00
Lucien Greathouse
fc3f750efb Tweak logic in RbxSession to distinguish create and update 2018-12-03 18:09:01 -08:00
Lucien Greathouse
457f3c8f54 Break out PathMap from RbxSession 2018-12-03 17:39:55 -08:00
Lucien Greathouse
e4d3c3b045 Field name fix, clean up project paths 2018-12-03 17:19:44 -08:00
Lucien Greathouse
e4379e29af Refactor upgrade messaging and version display 2018-12-03 17:04:08 -08:00
Lucien Greathouse
4542febaaf Remove global logging variable 2018-12-03 16:59:04 -08:00
Lucien Greathouse
f691d8a6a5 Clean up DevSettings 2018-12-03 16:57:28 -08:00
Lucien Greathouse
503d7400f3 Add a dev settings feature, keyed off codename right now 2018-12-03 16:54:21 -08:00
Lucien Greathouse
061ea0e7a3 Unify logging 2018-12-03 16:24:28 -08:00
Lucien Greathouse
dd4d542d7e Clean up and start work on Epiphany plugin 2018-12-03 13:54:54 -08:00
Lucien Greathouse
75359e2b83 Upgrade to latest rbx_tree (underscores! ) 2018-12-03 11:58:09 -08:00
Lucien Greathouse
db7f8ffb1b Update to latest rbx-tree 2018-12-03 11:52:06 -08:00
Lucien Greathouse
f59a9040fc Update plugin project files, remove outdated DESIGN doc 2018-12-03 11:48:30 -08:00
Lucien Greathouse
5114d12daf Start using failure for error management 2018-12-03 10:38:26 -08:00
boyned//Kampfkarren
13a7c1ba81 Fixed clippy warnings (#90)
* Fixed clippy warnings

* Fix as per review
2018-12-03 10:35:40 -08:00
Lucien Greathouse
26a7bb9746 Stub out RbxSession::path_updated a bit 2018-12-01 00:01:31 -08:00
Lucien Greathouse
d427f01224 Add Rojo 0.5.0+ config to plugin 2018-11-30 20:33:41 -08:00
Lucien Greathouse
25c73ed917 Add support for binary (rbxl and rbxm) build output 2018-11-30 18:08:03 -08:00
Lucien Greathouse
ce6a9dc448 Update dependencies 2018-11-30 18:02:30 -08:00
Lucien Greathouse
c50922e90c Add ignoreUnknown to project nodes 2018-11-27 23:21:16 -08:00
Lucien Greathouse
bcd5fab33c Add $properties to project nodes, unsure the full ramifications yet 2018-11-27 23:08:37 -08:00
Lucien Greathouse
49a2bc8ace Fix example test 2018-11-27 21:17:38 -08:00
Lucien Greathouse
f1c5268670 Support init.lua and client/server scripts 2018-11-27 17:44:17 -08:00
Lucien Greathouse
29fe7492cc Generate correct names for Lua scripts 2018-11-27 15:51:25 -08:00
Lucien Greathouse
2340a07408 Use project name for root object name 2018-11-27 15:16:48 -08:00
Lucien Greathouse
797c39347f Upgrade dependencies 2018-11-27 15:15:02 -08:00
Lucien Greathouse
5a9d3959e2 Rework RbxSession to drop top-level garbage node, upgrade test-model 2018-11-27 15:11:10 -08:00
Lucien Greathouse
1e0a7dea73 Add test model, shore up 'build' command more 2018-11-27 14:40:19 -08:00
Lucien Greathouse
c61d6a5804 Build out 'build' command 2018-11-27 14:22:06 -08:00
Lucien Greathouse
8aee5c769f Implement build command, shuffle around some internals to make it easier 2018-11-27 14:07:00 -08:00
Lucien Greathouse
7c585fcbce Clean up bin, print better help text 2018-11-27 13:28:43 -08:00
Lucien Greathouse
f7689f3154 Take advantage of 2018 edition.
- Remove explicit 'extern crate' fields where useful
- Fix mutability of variable (unrelated?)
- Add rbxmx dependency, which needs 2018 edition
2018-11-27 10:50:52 -08:00
Lucien Greathouse
6617b8b6c4 Move server to (temporarily) require Rust Beta or stable 1.31+ 2018-11-27 10:45:02 -08:00
Lucien Greathouse
9db31c9191 Stub out build command for generating rbxmx files 2018-11-27 10:38:44 -08:00
Lucien Greathouse
767a59a481 Handle removing folders and their path-to-ID associations better 2018-11-17 20:17:24 -08:00
Lucien Greathouse
f632444a0e Update design graph 2018-11-17 14:58:07 -08:00
Lucien Greathouse
16c3c1f498 Vfs -> Imfs, clean up and document a bit 2018-11-17 13:51:22 -08:00
Lucien Greathouse
c8bb9bf2e9 Break out file watching into FsWatcher object 2018-11-17 13:46:56 -08:00
Lucien Greathouse
729ab25581 Expose more project stuff via the API 2018-11-17 01:14:07 -08:00
Lucien Greathouse
38e0f82812 Clean up VFS code to make it much more robust 2018-11-17 00:04:44 -08:00
Lucien Greathouse
b4fd2e31b3 Cleanup old modules and create more focused code 2018-11-16 23:27:19 -08:00
Lucien Greathouse
e09d23d6c2 RbxSession refactoring stuff 2018-11-16 23:14:32 -08:00
Lucien Greathouse
9ad0eabb85 Syncing sort of works 2018-11-16 20:32:39 -08:00
Lucien Greathouse
fb950cb007 Update test projects 2018-11-16 15:11:24 -08:00
Lucien Greathouse
60c5c2d344 Iterating on project format to make it friendlier 2018-11-16 14:51:14 -08:00
Lucien Greathouse
a29c4f2b65 Fix test warning 2018-11-08 13:25:50 -08:00
Lucien Greathouse
5a99281e23 Make Rojo build with rbx_tree 2018-11-08 13:22:09 -08:00
Lucien Greathouse
31e1f61548 Start refining RbxTree operations, going to be a new crate 2018-10-31 18:07:02 -07:00
Lucien Greathouse
dbad0a16c4 Comment out roblox_studio mechanisms for now, start using env_logger 2018-09-21 18:00:41 -07:00
Lucien Greathouse
a69cbf45df Remove line break in HTTP debug output that studio messes up anyways 2018-08-26 22:17:30 -07:00
Lucien Greathouse
284f423220 Rename 'integration' to 'rojo-e2e' 2018-08-26 01:13:57 -07:00
Lucien Greathouse
81a18e88ad Cooler sounding README 2018-08-26 01:13:20 -07:00
Lucien Greathouse
72bc77f1d5 WIP: Epiphany Refactor (#85) 2018-08-26 01:03:53 -07:00
Lucien Greathouse
80b9b7594b Fix test failure due to bad test 2018-08-14 00:48:53 -07:00
Lucien Greathouse
7e671ee76a Update to latest Lemur 2018-08-14 00:41:37 -07:00
Lucien Greathouse
5d608cb498 Remove old garbage code 2018-08-14 00:41:09 -07:00
Lucien Greathouse
c6982f70b4 Move test projects out of server folder 2018-08-13 15:35:04 -07:00
Lucien Greathouse
ef0d1e7cec Update to latest Lemur 2018-08-13 15:31:36 -07:00
Lucien Greathouse
1db06194c7 Fix module layout to make more sense 2018-08-13 15:24:35 -07:00
Lucien Greathouse
f3e7e54675 Add useless comment 2018-07-17 20:25:04 -07:00
Lucien Greathouse
2bd64db8d9 Add test for modifying file a partition is pointing at directly 2018-07-03 16:32:45 -07:00
Lucien Greathouse
ae8098b80a Do a bit of tinkering with instance names relative to files and partitions 2018-07-03 16:01:34 -07:00
Lucien Greathouse
bfe8dcd224 Try out some nonsense with services being special-ish cased 2018-07-02 18:34:12 -07:00
Lucien Greathouse
8a26994084 Simplify plugin installation by using Plugins instead of InstalledPlugins 2018-06-25 22:10:03 -07:00
Lucien Greathouse
77d0865d58 Remove redundnant comment and unused variable 2018-06-25 18:22:36 -07:00
Lucien Greathouse
bece337d79 Implement rudimentary reifer against new APIs 2018-06-25 17:58:30 -07:00
Lucien Greathouse
5a5da3240f Add plugin bundling, sourced from target/plugin.rbxm 2018-06-25 00:53:21 -07:00
Lucien Greathouse
4138bb7ee1 install_location -> get_install_location 2018-06-24 23:55:13 -07:00
Lucien Greathouse
4088bb47f0 Add comment about roblox_studio::install_location 2018-06-24 23:54:40 -07:00
Lucien Greathouse
d10b6d324e Add roblox_studio module for locating and interacting with install 2018-06-24 21:06:00 -07:00
Lucien Greathouse
43b27831eb Update Lemur and TestEZ 2018-06-24 20:29:51 -07:00
Lucien Greathouse
20c9c89b27 RbxTree robustness
* delete_instance is no longer O(n)
* renamed get_instance to get_instance_and_descendants, which is more accurate
2018-06-24 20:26:58 -07:00
Lucien Greathouse
e1c420d37d Switch RbxValue to an enum 2018-06-24 19:40:50 -07:00
Lucien Greathouse
be58598a3e Make web tests no longer mutate original files 2018-06-24 19:37:30 -07:00
Lucien Greathouse
5e08093609 Update README and CHANGES from 0.4.12 release 2018-06-24 14:09:57 -07:00
Lucien Greathouse
f5599b95b3 Add TODOs to web tests 2018-06-11 15:37:59 -07:00
Lucien Greathouse
ba930ea584 Add TODO 2018-06-11 00:15:49 -07:00
Lucien Greathouse
ba3fa24f9a Tests for modifying projects and using /subscribe 2018-06-11 00:15:15 -07:00
Lucien Greathouse
ff0f5cd49c Test for children, make child matching more robust 2018-06-10 23:44:03 -07:00
Lucien Greathouse
284f5cfb71 Test /read endpoint for single partition case 2018-06-10 23:36:38 -07:00
Lucien Greathouse
871796f172 Merge branch 'master' of github.com:LPGhatguy/rojo 2018-06-10 23:24:19 -07:00
Lucien Greathouse
9733f059c2 Do something wrong instead of crashing for partitions pointing at files 2018-06-10 23:22:07 -07:00
Lucien Greathouse
db71bdfde7 Protocol v2 (0.5.0) (#56) 2018-06-10 23:11:10 -07:00
Lucien Greathouse
9aa27f4c11 Finish merging impl-v2 2018-06-10 23:10:41 -07:00
Lucien Greathouse
8893d0ddde Update README 2018-06-10 23:07:33 -07:00
Lucien Greathouse
0b46860cdd merge impl-v2: DESIGN.md and design.gv 2018-06-10 23:00:51 -07:00
Lucien Greathouse
ec1f9bd706 merge impl-v2: server 2018-06-10 22:59:04 -07:00
Lucien Greathouse
e30545c132 merge impl-v2: plugin 2018-06-10 22:53:22 -07:00
Lucien Greathouse
7d7f671920 merge impl-v2: .editorconfig 2018-06-10 22:50:37 -07:00
Lucien Greathouse
fb7bfa928a Release 0.4.11 2018-06-10 15:54:57 -07:00
Lucien Greathouse
100d69262c Update CHANGES 2018-06-10 15:52:42 -07:00
Lucien Greathouse
5e01658846 Remove straggling debug message 2018-06-10 15:50:30 -07:00
Lucien Greathouse
ccec93aee8 Untangle route terminology a bit 2018-06-10 15:50:03 -07:00
Lucien Greathouse
a089d82023 Fix incorrect route being assigned to init.lua and init.model.json files 2018-06-10 15:44:56 -07:00
Lucien Greathouse
82ba583fa0 Fix incorrect synchronization for Plugin:_pull that would make polling flaky 2018-06-10 15:13:49 -07:00
Lucien Greathouse
1b82044d7d Defensively insert existing instances into RouteMap 2018-06-10 15:03:36 -07:00
Lucien Greathouse
0d49a2e0af Mention VS Code extension in getting started guide 2018-06-02 01:04:31 -07:00
Lucien Greathouse
1343d3a2a9 Pick up rest of changes for 0.4.10, oops 2018-06-02 00:50:35 -07:00
Lucien Greathouse
a86001b85c Release 0.4.10 2018-06-01 23:51:35 -07:00
Lucien Greathouse
d6dd46c467 Fix JsonModelPlugin marking paths as changed correctly 2018-06-01 23:38:49 -07:00
Lucien Greathouse
320974074c Update docs 2018-06-01 23:33:36 -07:00
Lucien Greathouse
7b824abe52 Update CHANGES 2018-06-01 23:30:59 -07:00
Lucien Greathouse
bfd33f4b8d Support init.model.json
Closes #66.
2018-06-01 23:29:39 -07:00
Lucien Greathouse
d5a21a0513 Update plugin .luacheckrc to be more strict 2018-06-01 23:11:58 -07:00
Lucien Greathouse
c894b38f06 Improve plugin API robustness 2018-06-01 23:11:50 -07:00
Lucien Greathouse
a86347ea32 Add typechecks to reconciler and improve robustness a touch 2018-06-01 22:34:11 -07:00
Lucien Greathouse
b60bfc7495 Make nil checks more robust.
This represents an evolution in how I've been thinking about Lua -- using boolean coercion
is generally a bad idea I think because it obscures the underlying types.

It also makes it so that if a boolean is eronneously passed into a function, and it
happens to be a 'false' value, it will be coerced into the nil case instead of being
reported as an error, no matter how unintuitive the resulting error might be.
2018-06-01 22:21:59 -07:00
Lucien Greathouse
4b2f27b26d Fix error when targeting invalid services 2018-06-01 22:17:54 -07:00
Lucien Greathouse
f4d7dda8e3 Make docs on JSON model versioning more explicit 2018-05-26 17:19:37 -07:00
Lucien Greathouse
0d6e3e66ce Release 0.4.9 2018-05-26 17:02:04 -07:00
Lucien Greathouse
7e4d451765 Update Sync Details docs 2018-05-26 17:00:23 -07:00
Lucien Greathouse
804bbc93b7 Make JSON models less strict 2018-05-26 16:59:09 -07:00
Lucien Greathouse
e7fe4ac3ec Remove vestigial backwards syncing functionality.
This functionality won't be present until the refactor in 0.5.0
2018-05-26 16:44:25 -07:00
Lucien Greathouse
40c41b4400 Update Sync Details docs to mention how JSON models work.
Closes #71.
2018-05-26 16:41:38 -07:00
Lucien Greathouse
0936c7c97d Fix indentation in CHANGES 2018-05-26 16:23:13 -07:00
Lucien Greathouse
9ac537d38f Add entry to CHANGES 2018-05-26 16:23:09 -07:00
Lucien Greathouse
fcfd55ff76 Fix error in RouteMap
Closes #72.
2018-05-26 16:19:58 -07:00
Lucien Greathouse
c2495ed57f Release 0.4.8 (oops) 2018-05-25 23:42:31 -07:00
Lucien Greathouse
6ad763fc01 Fix flip-flopped arguments in RouteMap:_removeInternal 2018-05-25 23:40:34 -07:00
Lucien Greathouse
c856a3e361 Release 0.4.7 2018-05-25 23:31:01 -07:00
Lucien Greathouse
aa5f0cc335 Issue a warning if no partitions are specified during serve.
Closes #40
2018-05-22 11:04:53 -07:00
Lucien Greathouse
b067335bbf Update CHANGES 2018-05-22 10:55:23 -07:00
Jonathan Holmes
7d24a14004 Added plugin icons to Rojo (#70) 2018-05-22 10:52:55 -07:00
Lucien Greathouse
910be640e9 Release 0.4.6 2018-05-21 13:26:25 -07:00
Lucien Greathouse
3137753afa Update CHANGES 2018-05-21 13:09:00 -07:00
Lucien Greathouse
000ff351a5 Improve plugin handling with regards to restarts and UI
Closes #67.
2018-05-21 13:05:52 -07:00
Lucien Greathouse
533c8ddaf7 Update CHANGES 2018-05-21 12:55:41 -07:00
Lucien Greathouse
f777d1b6c6 Update CHANGES 2018-05-21 12:52:46 -07:00
Lucien Greathouse
8b17d3b7d9 Intense robustness pass 2018-05-21 12:48:25 -07:00
Lucien Greathouse
6fbe1daf8e Add folder for testing script duplication bug 2018-05-21 12:47:51 -07:00
Lucien Greathouse
3bd191414b Update CHANGES 2018-05-21 11:45:55 -07:00
Lucien Greathouse
fd2cb3495b Make reconciler more robust with regards to RouteMap 2018-05-21 11:21:31 -07:00
Lucien Greathouse
e9d33bdc02 Skip reparenting if parent is the same 2018-05-21 11:16:56 -07:00
Lucien Greathouse
c0f4b31ab3 Make sure all descendants get removed from the RouteMap 2018-05-21 10:40:06 -07:00
Lucien Greathouse
78de30dcf2 Fix missing colon in plugin stopped polling message 2018-05-01 14:36:25 -07:00
Lucien Greathouse
23c59dcae7 0.4.5 2018-05-01 12:29:48 -07:00
Lucien Greathouse
274ba5810b Update to Rouille 2.1 and latest dependencies 2018-04-22 17:35:21 -07:00
Lucien Greathouse
3661d0daec Show name of project when starting server 2018-04-22 17:19:21 -07:00
Lucien Greathouse
f215df891c Decrease debounce timeout, which will make polling much snappier 2018-04-22 16:43:32 -07:00
Lucien Greathouse
ce5fe00a66 Delete Promise.spec.lua 2018-04-21 01:16:19 -07:00
Lucien Greathouse
2d71e3ebea Switch to library version of Promise 2018-04-20 23:26:50 -07:00
Lucien Greathouse
187194a615 Keep track of actual file name in VfsItem.
This should fix the case of a partition pointed directly at a file
turning the object into a `StringValue`.

Fixes #57.
2018-04-20 23:13:43 -07:00
Lucien Greathouse
9e956e593d Expand test project to have a partition targeting a script directly 2018-04-20 23:13:01 -07:00
Lucien Greathouse
c2cfcc7a2c Prevent syncing while a sync is already in progress.
I'm fairly confident that there will be zero cases where the plugin gets
into a bad state where you can't sync.

This change also prefixes most of Rojo's messages with `Rojo:` to make
them easier to identify.

Fixes #61.
2018-04-20 22:29:58 -07:00
Lucien Greathouse
8c482f75dd Improve error messages for 'serve' command.
Rojo now throws an error if no project file could be found.

Fixes #63.
2018-04-20 21:45:48 -07:00
Lucien Greathouse
29a83cb626 Update LICENSE 2018-04-12 00:18:45 -07:00
Lucien Greathouse
a563e4c381 Update LICENSE 2018-04-12 00:13:09 -07:00
Lucien Greathouse
9cee587f22 Remove documentation from README and point to snazzy new documentation website 2018-04-08 00:16:21 -07:00
Lucien Greathouse
b5cc243466 Flesh out documentation, normalize markdown indentation 2018-04-08 00:09:28 -07:00
Lucien Greathouse
73c6b5a08c 0.4.4 2018-04-07 22:58:58 -07:00
Lucien Greathouse
1f5a686570 Fix small regression that I missed for 0.4.3 2018-04-07 22:57:48 -07:00
Lucien Greathouse
6fc497f95e 0.4.3 2018-04-07 22:54:59 -07:00
Lucien Greathouse
52eea667a7 Make plugin connection much more robust, with better errors 2018-04-07 22:24:42 -07:00
Lucien Greathouse
c2f7e268ff Update changelog 2018-04-07 20:13:07 -07:00
Validark
31e5c558ab Open Http Properties upon HttpEnabled prompt (#58) 2018-04-07 20:10:55 -07:00
Lucien Greathouse
7a7ac9550d Update server dependencies 2018-04-04 23:09:02 -07:00
Lucien Greathouse
4d0fdf0dfd 0.4.2 2018-04-04 23:06:57 -07:00
Lucien Greathouse
b448e8007e Fix duplication 0.4.x duplication bug for good 2018-04-04 23:05:01 -07:00
Lucien Greathouse
bad0e67266 Remove extra spawn in server code 2018-04-04 23:02:46 -07:00
Lucien Greathouse
3dee3dd627 Fix README whitespace inconsistency 2018-04-04 00:14:23 -07:00
Lucien Greathouse
4772350968 Version 0.4.1 2018-04-01 23:39:19 -07:00
Lucien Greathouse
eabcc0bd1d Add root gitignore to ignore mkdocs generated site 2018-04-01 23:36:04 -07:00
Lucien Greathouse
3a3af6ab10 Introduce mkdocs documentation 2018-04-01 23:35:18 -07:00
Lucien Greathouse
9723622b66 Bump server to version 0.4.1, update dependencies 2018-04-01 23:30:33 -07:00
Lucien Greathouse
3b1d647acb Bump license year 2018-04-01 23:30:25 -07:00
Lucien Greathouse
6fa925a402 Merge plugin back into main repository (#49) 2018-04-01 23:22:04 -07:00
Lucien Greathouse
c8f837d726 Add dates to each release in CHANGELOG 2018-04-01 21:23:22 -07:00
Lucien Greathouse
4557396564 Improve README in slight ways
Closes #14.
2018-03-27 01:51:15 -07:00
Lucien Greathouse
d3d67d47e1 Add new plugin logo 2018-03-27 01:11:18 -07:00
Lucien Greathouse
42107e0715 Update changes again, one day we'll release 0.4.0 2018-03-27 00:57:20 -07:00
Lucien Greathouse
ed183e0805 Update CHANGES, 0.4.0 2018-03-27 00:55:52 -07:00
Lucien Greathouse
116be16392 Improve error message when a partition target doesn't exist.
Closes #46
2018-03-27 00:50:44 -07:00
Lucien Greathouse
2c188738e6 Document JSON syncing and fix README typos 2018-02-21 23:48:37 -08:00
Lucien Greathouse
ebffba9589 Add bi-directional syncing note from Quenty 2018-02-04 08:55:19 -08:00
Lucien Greathouse
ab644c3dfa Update model.json example 2018-02-04 07:31:33 -08:00
Lucien Greathouse
c6cdd8a815 Change test project to test another edge case 2018-02-04 07:26:30 -08:00
Lucien Greathouse
d99df59d9b 'Wildcard' type in DefaultPlugin, change to PascalCase in API 2018-02-04 07:10:59 -08:00
Lucien Greathouse
c5f8247543 Add support for Bool and Number primitive types. 2018-02-03 23:16:29 -08:00
Lucien Greathouse
72557c9d23 Hip logo, totally not riffing on Babel 2018-01-29 15:57:10 -08:00
Lucien Greathouse
1a1b6d923f Fix JsonModelPlugin setting the name of the resulting RbxInstance 2018-01-09 16:40:39 -08:00
Lucien Greathouse
27cf2c8740 Add error context to output for JsonModelPlugin 2018-01-09 11:31:48 -08:00
Lucien Greathouse
c08a598d3f Fix broken file watcher implementation
This one took a little bit of tracking down; the VfsWatcher used to spawn a new
thread and then stall/park forever. With one of the recent changes to get rid of
the extra thread, VfsWatcher started getting dropped, which in turn dropped the
watchers created by the notify crate.

Because the threads only tie back to the VfsWatcher was a cloned
Arc<Mutex<VfsSession>>, everything was fine, except that their mpsc::Receiver
objects were no longer receiving events.

This manifested itself as the file watcher magically not watching any files.
Oops.
2018-01-08 12:33:36 -08:00
Lucien Greathouse
1318842c36 Update dependencies 2018-01-08 12:33:33 -08:00
Lucien Greathouse
86d7d033d7 Add 'route' to each RbxInstance, which tags how the instance was generated 2018-01-05 13:07:09 -08:00
Lucien Greathouse
2df1dfa1cb Insulate VFS internals a little bit 2018-01-03 18:13:49 -08:00
Lucien Greathouse
78a1c658d8 Simplify and collapse some code from 'rojo serve' 2018-01-03 18:05:00 -08:00
Lucien Greathouse
f52f43fe90 Eliminate extra thread for VfsWatcher 2018-01-03 18:02:56 -08:00
Lucien Greathouse
58b244b7e9 Reorganize some of the unwieldly parts of the codebase
* Moved commands into their own folder to reduce `bin.rs`'s size
* Moved all of the VFS-related functionality into its own folder
* Documented a lot of functions, including a few very obscure ones
2018-01-03 16:45:46 -08:00
Lucien Greathouse
d8bcbee463 Rename RbxItem -> RbxInstance 2018-01-03 16:01:48 -08:00
Lucien Greathouse
f00152a9ac Add a bit of documentation, this code is lacking it 2018-01-03 16:00:27 -08:00
Lucien Greathouse
9720c56765 Change each VfsItem to keep a full route instead of just its name 2018-01-03 15:56:19 -08:00
Lucien Greathouse
13ce04abb2 Add 'Contributing' section to README 2018-01-03 11:46:07 -08:00
Lucien Greathouse
ab22b55b84 Add further logging in verbose mode 2018-01-02 18:17:44 -08:00
Lucien Greathouse
73117edbe7 Enable JsonModelPlugin by default as a test 2018-01-02 15:41:10 -08:00
Lucien Greathouse
d7e2a3542c Make notes about compatibility breakage and version 0.4.0 2018-01-02 14:52:51 -08:00
Lucien Greathouse
fe240ed577 Prototype JsonModelPlugin, untested
Also cleaned up all of the warnings in the other plugin code
2017-12-21 17:09:32 -08:00
Lucien Greathouse
5e98cbe68f More detail in DESIGN.md 2017-12-21 16:10:47 -08:00
Lucien Greathouse
7a372dc50c Add forgotten change about CPU usage 2017-12-21 14:21:03 -08:00
Lucien Greathouse
958b6660be Update README and DESIGN 2017-12-20 23:00:48 -08:00
Lucien Greathouse
e731811911 Add changes from serve-instances merge 2017-12-20 22:54:10 -08:00
Lucien Greathouse
66144cef2f Merge branch 'serve-instances' 2017-12-20 22:52:32 -08:00
Lucien Greathouse
13925f5879 Publish 0.3.2 2017-12-20 22:41:23 -08:00
Lucien Greathouse
68ba3fee6c Fix max body size typo 2017-12-20 22:36:12 -08:00
Lucien Greathouse
95581dbaa6 Pass common plugin chain into web handler 2017-12-20 22:35:26 -08:00
Lucien Greathouse
aaaf3ba0b9 Implement handle_rbx_change API for plugins as a pass 2017-12-20 22:11:46 -08:00
Lucien Greathouse
b885cae086 Rename TransformResult -> TransformFileResult in preparation for two-way syncing 2017-12-20 22:01:38 -08:00
Lucien Greathouse
0f78eb933a DESIGN doc, stub out /write endpoint 2017-12-20 22:00:01 -08:00
Lucien Greathouse
6ee9a48e20 Use plugin chain code in Vfs 2017-12-18 01:52:13 -08:00
Lucien Greathouse
f90c51e923 Move web server onto main thread 2017-12-18 01:20:04 -08:00
Lucien Greathouse
6472a2cbce Add handle_file_change to plugin API
This solves the problem I was running into with the ScriptPlugin implementation -- if foo/init.lua changes, foo needs to be requested, not 'foo/init.lua' (which would then erroneously create a ModuleScript before this commit)
2017-12-17 22:47:16 -08:00
Lucien Greathouse
c75cbebbf0 Merge branch 'master' into serve-instances 2017-12-17 22:12:04 -08:00
Lucien Greathouse
2e340ff78c Merge pull request #22 from Quenty/fix-21-high-cpu
Fix #21: High CPU usage in a small project
2017-12-17 21:42:21 -08:00
James Onnen
5a20646c57 Address code review, remove unnecessary import 2017-12-17 23:40:32 -06:00
James Onnen
199ebda689 Use ::park() instead of ::sleep() 2017-12-17 14:34:31 -06:00
James Onnen
ae6ca6fb23 Fix #21: High CPU usage in a small project 2017-12-17 14:20:24 -06:00
Lucien Greathouse
12bfcd7b66 Implement init.lua support in ScriptPlugin 2017-12-14 01:11:44 -08:00
Lucien Greathouse
d365bc076e Add VfsItem::name to make comparisons easier 2017-12-14 01:11:44 -08:00
Lucien Greathouse
67ac6b7cec First implementation of 'ScriptPlugin', which serves script files as scripts 2017-12-14 01:11:44 -08:00
Lucien Greathouse
01325c8c7e Implement PluginChain 2017-12-14 01:11:44 -08:00
Lucien Greathouse
21e9625c36 Prototype plugin architecture, switch instance-based stuff to that 2017-12-14 01:11:44 -08:00
Lucien Greathouse
5bf1f11190 Hacky first go at it -- keeping the existing VfsItem infrastructure
I think this is actually a pretty reasonable flow.
2017-12-14 01:11:44 -08:00
Lucien Greathouse
b4e31ea35d Fix serve path failing to be absolute when given as a relative path 2017-12-14 01:09:10 -08:00
Lucien Greathouse
7c6fe38346 CLI version 0.3.1 2017-12-14 00:24:01 -08:00
Lucien Greathouse
f89d491f29 Run rustfmt
I ignored some odd formatting it introduced relating to putting braces on newlines in if-let blocks. This might be a bug, but I didn't find any way to turn that off.
2017-12-13 12:05:11 -08:00
Lucien Greathouse
59b2401c2c Add more detailed error reporting around invalid projects 2017-12-13 11:56:06 -08:00
Lucien Greathouse
b74ba141d1 Update dependencies, server v0.3.0 2017-12-12 15:01:36 -08:00
Lucien Greathouse
b60f06aa88 Update changelog to represent refactoring of server/client 2017-12-11 15:50:22 -08:00
Lucien Greathouse
f00bcc6d7e Point to the rojo-plugin repository 2017-12-08 16:52:13 -08:00
Lucien Greathouse
d5b41e2bd4 Remove plugin source, moved to rojo-plugin 2017-12-08 16:50:30 -08:00
Lucien Greathouse
c9a53debc3 Add small config test 2017-12-08 16:32:32 -08:00
Lucien Greathouse
edd45ca02e Update to Lemur master, 'fixes' Promise tests 2017-12-08 15:53:25 -08:00
Lucien Greathouse
f88cb67210 Back to being custom, since the 'Rust' image has a really old Python version 2017-12-08 15:46:50 -08:00
Lucien Greathouse
302c6cf663 Hybrid build script between Travis and custom installation... 2017-12-08 15:42:56 -08:00
Lucien Greathouse
7995b6eca4 Try radically changing the Travis script 2017-12-08 15:39:17 -08:00
Lucien Greathouse
fd7e737c20 Put back the original Rust config, maybe this will work 2017-12-08 14:26:29 -08:00
Lucien Greathouse
68b3d56619 Remove extra stuff I accidentally added :D 2017-12-08 14:23:58 -08:00
Lucien Greathouse
059ff1777b Try some random fixes I saw on StackOverflow to work around Travis-CI bug 2017-12-08 14:23:37 -08:00
Lucien Greathouse
dd16cadb4c Fix indentation, yaml is mean 2017-12-08 14:01:09 -08:00
Lucien Greathouse
551f75f39c Implement Lua unit tests, this may fail 2017-12-08 13:59:36 -08:00
Lucien Greathouse
23ae0bc186 Wrap warning earlier in Promise 2017-12-08 11:34:22 -08:00
Lucien Greathouse
713a199419 Add spec.lua for testing -- Promise tests are currently broken 2017-12-07 18:08:03 -08:00
Lucien Greathouse
4dc705ee45 Update Rojo project paths to point to new dependencies 2017-12-07 17:36:47 -08:00
Lucien Greathouse
fe4678fdc5 Re-add dependencies with their new path 2017-12-07 17:36:06 -08:00
Lucien Greathouse
97682108aa Update git module paths, still fighting git submodules a bit 2017-12-07 17:29:00 -08:00
Lucien Greathouse
23d4f45ac9 Fix use of services as partition targets 2017-12-07 16:56:20 -08:00
Lucien Greathouse
9fd6799f93 Fix Travis-CI README link 2017-12-07 15:53:45 -08:00
Lucien Greathouse
5898780e8e Add note about testing to CHANGES 2017-12-07 15:52:24 -08:00
Lucien Greathouse
1ad20421e9 Move Windows-specific path test into its own file 2017-12-07 15:50:55 -08:00
Lucien Greathouse
4ff9033916 Update dependencies 2017-12-07 15:47:18 -08:00
Lucien Greathouse
37bb0d1aa9 Add Travis-CI configuration to start running tests 2017-12-07 14:48:02 -08:00
Lucien Greathouse
7042680a0a Fixed usage of a partition pointing to a file instead of a folder 2017-12-07 14:42:30 -08:00
138 changed files with 8209 additions and 2526 deletions

View File

@@ -3,19 +3,16 @@ root = true
[*]
end_of_line = lf
charset = utf-8
[*.lua]
indent_style = tab
insert_final_newline = false
trim_trailing_whitespace = true
insert_final_newline = true
[*.rs]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
[*.json]
[*.{json,js,css}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
[*.{md,rs}]
indent_style = space
indent_size = 4
[*.lua]
indent_style = tab

5
.gitignore vendored
View File

@@ -1,2 +1,5 @@
/target/
/site
/target
/server/scratch
**/*.rs.bk
/generate-docs.run

30
.gitmodules vendored
View File

@@ -1,12 +1,18 @@
[submodule "modules/Roact"]
path = modules/Roact
url = https://github.com/Roblox/Roact.git
[submodule "modules/Rodux"]
path = modules/Rodux
url = https://github.com/Roblox/Rodux.git
[submodule "modules/RoactRodux"]
path = modules/RoactRodux
url = https://github.com/Roblox/RoactRodux.git
[submodule "modules/TestEZ"]
path = modules/TestEZ
url = https://github.com/Roblox/TestEZ.git
[submodule "plugin/modules/roact"]
path = plugin/modules/roact
url = https://github.com/Roblox/roact.git
[submodule "plugin/modules/rodux"]
path = plugin/modules/rodux
url = https://github.com/Roblox/rodux.git
[submodule "plugin/modules/roact-rodux"]
path = plugin/modules/roact-rodux
url = https://github.com/Roblox/roact-rodux.git
[submodule "plugin/modules/testez"]
path = plugin/modules/testez
url = https://github.com/Roblox/testez.git
[submodule "plugin/modules/lemur"]
path = plugin/modules/lemur
url = https://github.com/LPGhatguy/lemur.git
[submodule "plugin/modules/promise"]
path = plugin/modules/promise
url = https://github.com/LPGhatguy/roblox-lua-promise.git

38
.travis.yml Normal file
View File

@@ -0,0 +1,38 @@
matrix:
include:
- language: python
env:
- LUA="lua=5.1"
before_install:
- pip install hererocks
- hererocks lua_install -r^ --$LUA
- export PATH=$PATH:$PWD/lua_install/bin
install:
- luarocks install luafilesystem
- luarocks install busted
- luarocks install luacov
- luarocks install luacov-coveralls
- luarocks install luacheck
script:
- cd plugin
- luacheck src
- lua -lluacov spec.lua
after_success:
- cd plugin
- luacov-coveralls -e $TRAVIS_BUILD_DIR/lua_install
- language: rust
rust: stable
script:
- cargo test --verbose
- language: rust
rust: beta
script:
- cargo test --verbose

139
CHANGELOG.md Normal file
View File

@@ -0,0 +1,139 @@
# Rojo Changelog
## [Unreleased]
## [0.5.0 Alpha 1](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.1) (January 14, 2019)
* Changed plugin UI to be way prettier
* Thanks to [Reselim](https://github.com/Reselim) for the design!
* Changed plugin error messages to be a little more useful
* Removed unused 'Config' button in plugin UI
* Fixed bug where bad server responses could cause the plugin to be in a bad state
* Upgraded to rbx\_tree, rbx\_xml, and rbx\_binary 0.2.0, which dramatically expands the kinds of properties that Rojo can handle, especially in XML.
## [0.5.0 Alpha 0](https://github.com/LPGhatguy/rojo/releases/tag/v0.5.0-alpha.0) (January 14, 2019)
* "Epiphany" rewrite, in progress since the beginning of time
* New live sync protocol
* Uses HTTP long polling to reduce request count and improve responsiveness
* New project format
* Hierarchical, preventing overlapping partitions
* Added `rojo build` command
* Generates `rbxm`, `rbxmx`, `rbxl`, or `rbxlx` files out of your project
* Usage: `rojo build <PROJECT> --output <OUTPUT>.rbxm`
* Added `rojo upload` command
* Generates and uploads a place or model to roblox.com out of your project
* Usage: `rojo upload <PROJECT> --cookie "<ROBLOSECURITY>" --asset_id <PLACE_ID>`
* New plugin
* Only one button now, "Connect"
* New UI to pick server address and port
* Better error reporting
* Added support for `.csv` files turning into `LocalizationTable` instances
* Added support for `.txt` files turning into `StringValue` instances
* Added debug visualization code to diagnose problems
* `/visualize/rbx` and `/visualize/imfs` show instance and file state respectively; they require GraphViz to be installed on your machine.
* Added optional place ID restrictions to project files
* This helps prevent syncing in content to the wrong place
* Multiple places can be specified, like when building a multi-place game
* Added support for specifying properties on services in project files
## [0.4.13](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.13) (November 12, 2018)
* When `rojo.json` points to a file or directory that does not exist, Rojo now issues a warning instead of throwing an error and exiting
## [0.4.12](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.12) (June 21, 2018)
* Fixed obscure assertion failure when renaming or deleting files ([#78](https://github.com/LPGhatguy/rojo/issues/78))
* Added a `PluginAction` for the sync in command, which should help with some automation scripts ([#80](https://github.com/LPGhatguy/rojo/pull/80))
## [0.4.11](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.11) (June 10, 2018)
* Defensively insert existing instances into RouteMap; should fix most duplication cases when syncing into existing trees.
* Fixed incorrect synchronization from `Plugin:_pull` that would cause polling to create issues
* Fixed incorrect file routes being assigned to `init.lua` and `init.model.json` files
* Untangled route handling-internals slightly
## [0.4.10](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.10) (June 2, 2018)
* Added support for `init.model.json` files, which enable versioning `Tool` instances (among other things) with Rojo. ([#66](https://github.com/LPGhatguy/rojo/issues/66))
* Fixed obscure error when syncing into an invalid service.
* Fixed multiple sync processes occurring when a server ID mismatch is detected.
## [0.4.9](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.9) (May 26, 2018)
* Fixed warning when renaming or removing files that would sometimes corrupt the instance cache ([#72](https://github.com/LPGhatguy/rojo/pull/72))
* JSON models are no longer as strict -- `Children` and `Properties` are now optional.
## [0.4.8](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.8) (May 26, 2018)
* Hotfix to prevent errors from being thrown when objects managed by Rojo are deleted
## [0.4.7](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.7) (May 25, 2018)
* Added icons to the Rojo plugin, made by [@Vorlias](https://github.com/Vorlias)! ([#70](https://github.com/LPGhatguy/rojo/pull/70))
* Server will now issue a warning if no partitions are specified in `rojo serve` ([#40](https://github.com/LPGhatguy/rojo/issues/40))
## [0.4.6](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.6) (May 21, 2018)
* Rojo handles being restarted by Roblox Studio more gracefully ([#67](https://github.com/LPGhatguy/rojo/issues/67))
* Folders should no longer get collapsed when syncing occurs.
* **Significant** robustness improvements with regards to caching.
* **This should catch all existing script duplication bugs.**
* If there are any bugs with script duplication or caching in the future, restarting the Rojo server process will fix them for that session.
* Fixed message in plugin not being prefixed with `Rojo: `.
## [0.4.5](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.5) (May 1, 2018)
* Rojo messages are now prefixed with `Rojo: ` to make them stand out in the output more.
* Fixed server to notice file changes *much* more quickly. (200ms vs 1000ms)
* Server now lists name of project when starting up.
* Rojo now throws an error if no project file is found. ([#63](https://github.com/LPGhatguy/rojo/issues/63))
* Fixed multiple sync operations occuring at the same time. ([#61](https://github.com/LPGhatguy/rojo/issues/61))
* Partitions targeting files directly now work as expected. ([#57](https://github.com/LPGhatguy/rojo/issues/57))
## [0.4.4](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.4) (April 7, 2018)
* Fix small regression introduced in 0.4.3
## [0.4.3](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.3) (April 7, 2018)
* Plugin now automatically selects `HttpService` if it determines that HTTP isn't enabled ([#58](https://github.com/LPGhatguy/rojo/pull/58))
* Plugin now has much more robust handling and will wipe all state when the server changes.
* This should fix issues that would otherwise be solved by restarting Roblox Studio.
## [0.4.2](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.2) (April 4, 2018)
* Fixed final case of duplicated instance insertion, caused by reconciled instances not being inserted into `RouteMap`.
* The reconciler is still not a perfect solution, especially if script instances get moved around without being destroyed. I don't think this can be fixed before a big refactor.
## [0.4.1](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.1) (April 1, 2018)
* Merged plugin repository into main Rojo repository for easier tracking.
* Improved `RouteMap` object tracking; this should fix some cases of duplicated instances being synced into the tree.
## [0.4.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.4.0) (March 27, 2018)
* Protocol version 1, which shifts more responsibility onto the server
* This is a **major breaking** change!
* The server now has a content of 'filter plugins', which transform data at various stages in the pipeline
* The server now exposes Roblox instance objects instead of file contents, which lines up with how `rojo pack` will work, and paves the way for more robust syncing.
* Added `*.model.json` files, which let you embed small Roblox objects into your Rojo tree.
* Improved error messages in some cases ([#46](https://github.com/LPGhatguy/rojo/issues/46))
## [0.3.2](https://github.com/LPGhatguy/rojo/releases/tag/v0.3.2) (December 20, 2017)
* Fixed `rojo serve` failing to correctly construct an absolute root path when passed as an argument
* Fixed intense CPU usage when running `rojo serve`
## [0.3.1](https://github.com/LPGhatguy/rojo/releases/tag/v0.3.1) (December 14, 2017)
* Improved error reporting when invalid JSON is found in a `rojo.json` project
* These messages are passed on from Serde
## [0.3.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.3.0) (December 12, 2017)
* Factored out the plugin into a separate repository
* Fixed server when using a file as a partition
* Previously, trailing slashes were put on the end of a partition even if the read request was an empty string. This broke file reading on Windows when a partition pointed to a file instead of a directory!
* Started running automatic tests on Travis CI (#9)
## [0.2.3](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.3) (December 4, 2017)
* Plugin only release
* Tightened `init` file rules to only match script files
* Previously, Rojo would sometimes pick up the wrong file when syncing
## [0.2.2](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.2) (December 1, 2017)
* Plugin only release
* Fixed broken reconciliation behavior with `init` files
## [0.2.1](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.1) (December 1, 2017)
* Plugin only release
* Changes default port to 8000
## [0.2.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.2.0) (December 1, 2017)
* Support for `init.lua` like rbxfs and rbxpacker
* More robust syncing with a new reconciler
## [0.1.0](https://github.com/LPGhatguy/rojo/releases/tag/v0.1.0) (November 29, 2017)
* Initial release, functionally very similar to [rbxfs](https://github.com/LPGhatguy/rbxfs)

View File

@@ -1,24 +0,0 @@
# Rojo Change Log
## Current Master
* *No changes*
## 0.2.3
* Plugin only release
* Tightened `init` file rules to only match script files
* Previously, Rojo would sometimes pick up the wrong file when syncing
## 0.2.2
* Plugin only release
* Fixed broken reconciliation behavior with `init` files
## 0.2.1
* Plugin only release
* Changes default port to 8000
## 0.2.0
* Support for `init.lua` like rbxfs and rbxpacker
* More robust syncing with a new reconciler
## 0.1.0
* Initial release, functionally very similar to [rbxfs](https://github.com/LPGhatguy/rbxfs)

2059
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,5 @@
[package]
name = "rojo"
version = "0.2.0"
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
description = "A tool to create robust Roblox projects"
license = "MIT"
repository = "https://github.com/LPGhatguy/rojo"
[[bin]]
name = "rojo"
path = "src/bin.rs"
[dependencies]
clap = "2.27.1"
rouille = "1.0"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
notify = "4.0.0"
rand = "0.3"
[workspace]
members = [
"server",
"rojo-e2e",
]

View File

@@ -1,9 +0,0 @@
The MIT License (MIT)
Copyright (c) 2017 Lucien Greathouse
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

373
LICENSE.txt Normal file
View File

@@ -0,0 +1,373 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

169
README.md
View File

@@ -1,141 +1,68 @@
<h1 align="center">Rojo</h1>
<div align="center">
<a href="https://travis-ci.org/LPGhatguy/Rojo">
<img src="https://api.travis-ci.org/LPGhatguy/Rojo.svg?branch=master" alt="Travis-CI Build Status" />
</a>
<img src="assets/rojo-logo.png" alt="Rojo" height="217" />
</div>
<div>&nbsp;</div>
Rojo is a flexible multi-tool designed for creating robust Roblox projects. It's in early development, but is still useful for many projects.
<div align="center">
<a href="https://travis-ci.org/LPGhatguy/rojo">
<img src="https://api.travis-ci.org/LPGhatguy/rojo.svg?branch=master" alt="Travis-CI Build Status" />
</a>
<a href="https://crates.io/crates/rojo">
<img src="https://img.shields.io/crates/v/rojo.svg?label=version" alt="Latest server version" />
</a>
<a href="https://lpghatguy.github.io/rojo/0.4.x">
<img src="https://img.shields.io/badge/docs-0.4.x-brightgreen.svg" alt="Rojo Documentation" />
</a>
<a href="https://lpghatguy.github.io/rojo/0.5.x">
<img src="https://img.shields.io/badge/docs-0.5.x-brightgreen.svg" alt="Rojo Documentation" />
</a>
</div>
It's designed for power users who want to use the **best tools available** for building games, libraries, and plugins.
<hr />
**Rojo** is a flexible multi-tool designed for creating robust Roblox projects.
It lets Roblox developers use industry-leading tools like Git and VS Code, and crucial utilities like Luacheck.
Rojo is designed for **power users** who want to use the **best tools available** for building games, libraries, and plugins.
## Features
Rojo has a number of desirable features *right now*:
Rojo lets you:
* Work on scripts from the filesystem, in your favorite editor
* Version your place, library, or plugin using Git or another VCS
* Version your place, model, or plugin using Git or another VCS
* Sync `rbxmx` and `rbxm` models into your game in real time
* Package and deploy your project to Roblox.com from the command line
Soon, Rojo will be able to:
* Sync Roblox objects (including models) bi-directionally between the filesystem and Roblox Studio
* Create installation scripts for libraries to be used in standalone places
* Similar to [rbxpacker](https://github.com/LPGhatguy/rbxpacker), another one of my projects
* Add strongly-versioned dependencies to your project
* Sync instances from Roblox Studio to the filesystem
* Compile MoonScript and other custom things for your project
## Installation
Rojo has two components:
* The command line tool, written in Rust
* The [Roblox Studio plugin](https://www.roblox.com/library/1211549683/Rojo-v0-0-0), written in Lua
## [Documentation](https://lpghatguy.github.io/rojo/0.4.x)
You can also view the documentation by browsing the [docs](https://github.com/LPGhatguy/rojo/tree/master/docs) folder of the repository, but because it uses a number of Markdown extensions, it may not be very readable.
To install the command line tool, there are two options:
* Cargo, if you have Rust installed
* Use `cargo install rojo` -- Rojo will be available with the `rojo` command
* Download a pre-built Windows binary from [the GitHub releases page](https://github.com/LPGhatguy/rojo/releases)
## Usage
For more help, use `rojo help`.
### New Project
Just create a new folder and tell Rojo to initialize it!
```sh
mkdir my-new-project
cd my-new-project
rojo init
```
Rojo will create an empty project in the directory.
The default project looks like this:
```json
{
"name": "my-new-project",
"servePort": 8000,
"partitions": {}
}
```
### Start Dev Server
To create a server that allows the Rojo Dev Plugin to access your project, use:
```sh
rojo serve
```
The tool will tell you whether it found an existing project. You should then be able to connect and use the project from within Roblox Studio!
### Migrating an Existing Roblox Project
**Coming soon!**
### Syncing into Roblox
In order to sync code into Roblox, you'll need to add one or more "partitions" to your configuration. A partition tells Rojo how to map directories to Roblox objects.
Each entry in the partitions table has a unique name, a filesystem path, and the full name of the Roblox object to sync into.
For example, if you want to map your `src` directory to an object named `My Cool Game` in `ReplicatedStorage`, you could use this configuration:
```json
{
"name": "rojo",
"servePort": 8000,
"partitions": {
"game": {
"path": "src",
"target": "ReplicatedStorage.My Cool Game"
}
}
}
```
The `path` parameter is relative to the project file.
The `target` starts at `game` and crawls down the tree. If any objects don't exist along the way, they'll be created as `Folder` instances.
Run `rojo serve` in the directory containing this project, then press the "Sync In" or "Toggle Polling" buttons in the Roblox Studio plugin to move code into your game.
### Sync Details
The structure of files and folders on the filesystem are preserved when syncing into game.
Creation of Roblox instances follows a simple set of rules. The first rule that matches the file name is chosen:
| File Name | Instance Type | Notes |
| -------------- | -------------- | ----------------------------------------- |
| `*.server.lua` | `Script` | `Source` will contain the file's contents |
| `*.client.lua` | `LocalScript` | `Source` will contain the file's contents |
| `*.lua` | `ModuleScript` | `Source` will contain the file's contents |
| `*` | `StringValue` | `Value` will contain the file's contents |
Any folders on the filesystem will turn into `Folder` objects unless they contain a file named `init.lua`, `init.server.lua`, or `init.client.lua`. Following the convention of Lua, those objects will instead be whatever the `init` file would turn into.
For example, this file tree:
* my-game
* init.client.lua
* foo.lua
Will turn into this tree in Roblox:
* `my-game` (`LocalScript` with source from `my-game/init.client.lua`)
* `foo` (`ModuleScript` with source from `my-game/foo.lua`)
## Inspiration
There are lots of other tools that sync scripts into Roblox, or otherwise work to improve the development flow outside of Roblox Studio.
## Inspiration and Alternatives
There are lots of other tools that sync scripts into Roblox or provide other tools for working with Roblox places.
Here are a few, if you're looking for alternatives or supplements to Rojo:
* [Studio Bridge by Vocksel](https://github.com/vocksel/studio-bridge)
* [RbxRefresh by Osyris](https://github.com/osyrisrblx/RbxRefresh)
* [RbxSync by evaera](https://github.com/evaera/RbxSync)
* [CodeSync](https://github.com/MemoryPenguin/CodeSync) and [rbx-exteditor](https://github.com/MemoryPenguin/rbx-exteditor) by [MemoryPenguin](https://github.com/MemoryPenguin)
* [rbxmk by Anaminus](https://github.com/anaminus/rbxmk)
I also have a couple tools that Rojo intends to replace:
* [rbxfs](https://github.com/LPGhatguy/rbxfs), which has been deprecated by Rojo
* [rbxpacker](https://github.com/LPGhatguy/rbxpacker), which is still useful
* [rbxmk by Anaminus](https://github.com/anaminus/rbxmk)
* [Rofresh by Osyris](https://github.com/osyrisrblx/rofresh)
* [RbxRefresh by Osyris](https://github.com/osyrisrblx/RbxRefresh)
* [Studio Bridge by Vocksel](https://github.com/vocksel/studio-bridge)
* [Elixir by Vocksel](https://github.com/vocksel/elixir)
* [RbxSync by evaera](https://github.com/evaera/RbxSync)
* [CodeSync by MemoryPenguin](https://github.com/MemoryPenguin/CodeSync)
* [rbx-exteditor by MemoryPenguin](https://github.com/MemoryPenguin/rbx-exteditor)
If you use a plugin that _isn't_ Rojo for syncing code, open an issue and let me know why! I'd like Rojo to be the end-all tool so that people stop reinventing solutions to this problem.
## Contributing
Pull requests are welcome!
All pull requests are run against a test suite on Travis CI. That test suite should always pass!
## License
Rojo is available under the terms of the MIT license. See [LICENSE.md](LICENSE.md) for details.
Rojo is available under the terms of the Mozilla Public License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for details.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,41 @@
<TextureAtlas imagePath="sheet.png">
<SubTexture name="grey_arrowDownGrey.png" x="78" y="498" width="15" height="10"/>
<SubTexture name="grey_arrowDownWhite.png" x="123" y="496" width="15" height="10"/>
<SubTexture name="grey_arrowUpGrey.png" x="108" y="498" width="15" height="10"/>
<SubTexture name="grey_arrowUpWhite.png" x="93" y="498" width="15" height="10"/>
<SubTexture name="grey_box.png" x="147" y="433" width="38" height="36"/>
<SubTexture name="grey_boxCheckmark.png" x="147" y="469" width="38" height="36"/>
<SubTexture name="grey_boxCross.png" x="185" y="433" width="38" height="36"/>
<SubTexture name="grey_boxTick.png" x="190" y="198" width="36" height="36"/>
<SubTexture name="grey_button00.png" x="0" y="143" width="190" height="45"/>
<SubTexture name="grey_button01.png" x="0" y="188" width="190" height="49"/>
<SubTexture name="grey_button02.png" x="0" y="98" width="190" height="45"/>
<SubTexture name="grey_button03.png" x="0" y="331" width="190" height="49"/>
<SubTexture name="grey_button04.png" x="0" y="286" width="190" height="45"/>
<SubTexture name="grey_button05.png" x="0" y="0" width="195" height="49"/>
<SubTexture name="grey_button06.png" x="0" y="49" width="191" height="49"/>
<SubTexture name="grey_button07.png" x="195" y="0" width="49" height="49"/>
<SubTexture name="grey_button08.png" x="240" y="49" width="49" height="49"/>
<SubTexture name="grey_button09.png" x="98" y="433" width="49" height="45"/>
<SubTexture name="grey_button10.png" x="191" y="49" width="49" height="49"/>
<SubTexture name="grey_button11.png" x="0" y="433" width="49" height="45"/>
<SubTexture name="grey_button12.png" x="244" y="0" width="49" height="49"/>
<SubTexture name="grey_button13.png" x="49" y="433" width="49" height="45"/>
<SubTexture name="grey_button14.png" x="0" y="384" width="190" height="49"/>
<SubTexture name="grey_button15.png" x="0" y="237" width="190" height="49"/>
<SubTexture name="grey_checkmarkGrey.png" x="99" y="478" width="21" height="20"/>
<SubTexture name="grey_checkmarkWhite.png" x="78" y="478" width="21" height="20"/>
<SubTexture name="grey_circle.png" x="185" y="469" width="36" height="36"/>
<SubTexture name="grey_crossGrey.png" x="120" y="478" width="18" height="18"/>
<SubTexture name="grey_crossWhite.png" x="190" y="318" width="18" height="18"/>
<SubTexture name="grey_panel.png" x="190" y="98" width="100" height="100"/>
<SubTexture name="grey_sliderDown.png" x="190" y="234" width="28" height="42"/>
<SubTexture name="grey_sliderEnd.png" x="138" y="478" width="8" height="10"/>
<SubTexture name="grey_sliderHorizontal.png" x="0" y="380" width="190" height="4"/>
<SubTexture name="grey_sliderLeft.png" x="0" y="478" width="39" height="31"/>
<SubTexture name="grey_sliderRight.png" x="39" y="478" width="39" height="31"/>
<SubTexture name="grey_sliderUp.png" x="190" y="276" width="28" height="42"/>
<SubTexture name="grey_sliderVertical.png" x="208" y="318" width="4" height="100"/>
<SubTexture name="grey_tickGrey.png" x="190" y="336" width="17" height="17"/>
<SubTexture name="grey_tickWhite.png" x="190" y="353" width="17" height="17"/>
</TextureAtlas>

BIN
assets/rojo-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
assets/rojo-plugin-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

BIN
assets/rojo-sync-in.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

BIN
assets/rojo-test-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

39
design.gv Normal file
View File

@@ -0,0 +1,39 @@
digraph G {
graph [
ranksep = "0.7",
nodesep = "1.0",
];
node [
fontname = "Hack",
shape = "record",
];
roblox_studio -> plugin [dir = "both"];
plugin -> web_server [style = "dashed", dir = "both"];
web_server -> session;
session -> rbx_session;
session -> fs_watcher;
session -> message_queue;
fs_watcher -> imfs [weight = "10"];
fs_watcher -> rbx_session [constraint = "false"];
imfs -> fs;
rbx_session -> imfs;
rbx_session -> middlewares [weight = "10"];
rbx_session -> message_queue [constraint = "false"];
plugin [label = "Studio Plugin"];
roblox_studio [label = "Roblox Studio"];
fs [label = "Filesystem"];
fs_watcher [label = "Filesystem Watcher"];
session [label = "Session"];
web_server [label = "Web API"];
imfs [label = "In-Memory Filesystem"];
rbx_session [label = "RbxSession"];
message_queue [label = "MessageQueue"];
middlewares [label = "Middlewares"];
}

View File

@@ -0,0 +1,64 @@
To use Rojo to build a place, you'll need to create a new project file, which tells Rojo how your project is structured on-disk and in Roblox.
Create a new folder, then run `rojo init` inside that folder to initialize an empty project.
```sh
mkdir my-new-project
cd my-new-project
rojo init
```
Rojo will make a small project file in your directory, named `roblox-project.json`. It'll make sure that any code in the directory `src` will get put into `ReplicatedStorage.Source`.
Speaking of, let's make sure we create a directory named `src`, and maybe a Lua file inside of it:
```sh
mkdir src
echo 'print("Hello, world!")' > src/hello.lua
```
## Building Your Place
Now that we have a project, one thing we can do is build a Roblox place file for our project. This is a great way to get started with a project quickly with no fuss.
All we have to do is call `rojo build`:
```sh
rojo build -o MyNewProject.rbxl
```
If you open `MyNewProject.rbxl` in Roblox Studio now, you should see a `Folder` containing a `ModuleScript` under `ReplicatedStorage`!
!!! info
To generate an XML place file instead, like if you're checking the place file into version control, just use `rbxlx` as the extension on the output file instead.
## Live-Syncing into Studio
Building a place file is great for the initial build, but for actively working on your place, you'll want something quicker.
In Roblox Studio, make sure the Rojo plugin is installed. If you need it, check out [the installation guide](installation) to learn how to install it.
To expose your project to the plugin, you'll need to _serve_ it from the command line:
```sh
rojo serve
```
This will start up a web server that tells Roblox Studio what instances are in your project and sends notifications if any of them change.
Note the port number, then switch into Roblox Studio and press the Rojo **Connect** button in the plugins tab. Type in the port number, if necessary, and press **Start**.
If everything went well, you should now be able to change files in the `src` directory and watch them sync into Roblox Studio in real time!
## Uploading Your Place
Aimed at teams that want serious levels of automation, Rojo can upload places to Roblox.com automatically.
You'll need an existing place on Roblox.com as well as the `.ROBLOSECURITY` cookie of an account that has write access to that place.
!!! warning
It's recommended that you set up a Roblox account dedicated to deploying your place instead of your personal account in case your security cookie is compromised.
Generating and uploading your place file is as simple as:
```sh
rojo upload --asset_id [PLACE ID] --cookie "[SECURITY COOKIE]"
```

View File

@@ -0,0 +1,25 @@
Rojo has two components:
* The server, a binary written in Rust
* The plugin, a Roblox Studio plugin written in Lua
It's important that the plugin and server are compatible. The plugin will show errors in the Roblox Studio Output window if there is a version mismatch.
## Installing the Server
To install the server, either:
* If you have Rust installed, use `cargo install rojo`
* Or, download a pre-built Windows binary from [the GitHub releases page](https://github.com/LPGhatguy/rojo/releases)
**The Rojo binary must be run from the command line, like Terminal on MacOS or `cmd.exe` on Windows. It's recommended that you put the Rojo binary on your `PATH` to make this easier.**
## Installing the Plugin
To install the plugin, either:
* Install the plugin from the [Roblox plugin page](https://www.roblox.com/library/1211549683/Rojo).
* This gives you less control over what version you install -- you will always have the latest version.
* Or, download the latest release from [the GitHub releases section](https://github.com/LPGhatguy/rojo/releases) and install it into your Roblox plugins folder
* You can open this folder by clicking the "Plugins Folder" button from the Plugins toolbar in Roblox Studio
## Visual Studio Code Extension
If you use Visual Studio Code on Windows, you can install [Evaera's unofficial Rojo extension](https://marketplace.visualstudio.com/items?itemName=evaera.vscode-rojo), which will install both halves of Rojo for you. It even has a nifty UI to add partitions and start/stop the Rojo server!

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

11
docs/index.md Normal file
View File

@@ -0,0 +1,11 @@
This is the documentation home for Rojo.
Available versions of these docs:
* [0.5.x](https://lpghatguy.github.io/rojo/0.5.x)
* [0.4.x](https://lpghatguy.github.io/rojo/0.4.x)
* [`master` branch](https://lpghatguy.github.io/rojo/master)
**Rojo** is a flexible multi-tool designed for creating robust Roblox projects.
This documentation is a continual work in progress. If you find any issues, please file an issue on [Rojo's issue tracker](https://github.com/LPGhatguy/rojo/issues)!

View File

@@ -0,0 +1,59 @@
Rojo underwent a large refactor during most of 2018 to enable a bunch of new features and lay groundwork for lots more in 2019. As such, Rojo **0.5.x** projects are not compatible with Rojo **0.4.x** projects.
## Supporting Both 0.4.x and 0.5.x
Rojo 0.5.x uses a different name for its project format. While 0.4.x used `rojo.json`, 0.5.x uses `roblox-project.json`, which allows them to coexist.
If you aren't sure about upgrading or want to upgrade gradually, it's possible to keep both files in the same project without causing problems.
## Upgrading Your Project File
Project files in 0.5.x are more explicit and flexible than they were in 0.4.x. Project files can now describe models and plugins in addition to places.
This new project file format also guards against two of the biggest pitfalls when writing a config file:
* Using a service as a partition target directly, which often wiped away extra instances
* Defining two partitions that overlapped, which made Rojo act unpredictably
The biggest change is that the `partitions` field has been replaced with a new field, `tree`, that describes the entire hierarchy of your project from the top-down.
A project for 0.4.x that syncs from the `src` directory into `ReplicatedStorage.Source` would look like this:
```json
{
"name": "Rojo 0.4.x Example",
"partitions": {
"path": "src",
"target": "ReplicatedStorage.Source"
}
}
```
In 0.5.x, the project format is more explicit:
```json
{
"name": "Rojo 0.5.x Example",
"tree": {
"$className": "DataModel",
"ReplicatedStorage": {
"$className": "ReplicatedStorage",
"Source": {
"$path": "src"
}
}
}
}
```
For each object in the tree, we define *metadata* and *children*.
Metadata begins with a dollar sign (`$`), like `$className`. This is so that children and metadata can coexist without creating too many nested layers.
All other values are considered children, where the key is the instance's name, and the value is an object, repeating the process.
## Migrating `.model.json` Files
No upgrade path yet, stay tuned.
## Migrating Unknown Files
If you used Rojo to sync in files as `StringValue` objects, you'll need to make sure those files end with the `txt` extension to preserve this in Rojo 0.5.x.
Unknown files are now ignored in Rojo instead of being converted to `StringValue` objects.

3
docs/requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
mkdocs
mkdocs-material
pymdown-extensions

35
docs/sync-details.md Normal file
View File

@@ -0,0 +1,35 @@
This page aims to describe how Rojo turns files on the filesystem into Roblox objects.
## Overview
| File Name | Instance Type |
| -------------- | ------------------- |
| any directory | `Folder` |
| `*.server.lua` | `Script` |
| `*.client.lua` | `LocalScript` |
| `*.lua` | `ModuleScript` |
| `*.csv` | `LocalizationTable` |
| `*.txt` | `StringValue` |
## Folders
Any directory on the filesystem will turn into a `Folder` instance unless it contains an 'init' script, described below.
## Scripts
The default script type in Rojo projects is `ModuleScript`, since most scripts in well-structued Roblox projects will be modules.
If a directory contains a file named `init.server.lua`, `init.client.lua`, or `init.lua`, that folder will be transformed into a `*Script` instance with the contents of the 'init' file. This can be used to create scripts inside of scripts.
For example, these files:
* my-game
* init.client.lua
* foo.lua
Will turn into these instances in Roblox:
![Example of Roblox instances](/images/sync-example.png)
## Localization Tables
Any CSV files are transformed into `LocalizationTable` instances. Rojo expects these files to follow the same format that Roblox does when importing and exporting localization information.
## Plain Text Files
Plain text files (`.txt`) files are transformed into `StringValue` instances. This is useful for bringing in text data that can be read by scripts at runtime.

20
docs/why-rojo.md Normal file
View File

@@ -0,0 +1,20 @@
There are a number of existing plugins for Roblox that move code from the filesystem into Roblox.
Besides Rojo, there is:
* [Studio Bridge](https://github.com/vocksel/studio-bridge) by [Vocksel](https://github.com/vocksel)
* [RbxRefresh](https://github.com/osyrisrblx/RbxRefresh) by [Osyris](https://github.com/osyrisrblx)
* [RbxSync](https://github.com/evaera/RbxSync) by [evaera](https://github.com/evaera)
* [CodeSync](https://github.com/MemoryPenguin/CodeSync) and [rbx-exteditor](https://github.com/MemoryPenguin/rbx-exteditor) by [MemoryPenguin](https://github.com/MemoryPenguin)
* [rbxmk](https://github.com/anaminus/rbxmk) by [Anaminus](https://github.com/anaminus)
So why did I build Rojo?
Each of these tools solves what is essentially the same problem from a few different angles. The goal of Rojo is to take all of the lessons and ideas learned from these projects and build a tool that can solve the problem for good.
Additionally:
* I think that this tool needs to be built in a compiled language without a runtime, for easy distribution and good performance.
* I think that the conventions promoted by other sync plugins (`.module.lua` for modules, as well a single sync point) are sub-optimal.
* I think that I have a good enough understanding of the problem to build something robust.
* I think that Rojo should be able to do more than just sync code.

25
generate-docs Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
# Kludged documentation generator to support multiple versions.
# Make sure the `site` folder is a checkout of this repository's `gh-pages`
# branch.
# To use, copy this file to `generate-docs.run` so that Git will leave it alone,
# then run `generate-docs.run` in the root of the repository.
set -e
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Building 0.4.x"
git checkout v0.4.x
git pull
mkdocs build --site-dir site/0.4.x
echo "Building master"
git checkout master
mkdocs build --site-dir site/master
echo "Building 0.5.x"
mkdocs build --site-dir site/0.5.x
git checkout "$CURRENT_BRANCH"

26
mkdocs.yml Normal file
View File

@@ -0,0 +1,26 @@
site_name: Rojo Documentation
repo_name: LPGhatguy/rojo
repo_url: https://github.com/LPGhatguy/rojo
theme:
name: material
palette:
primary: 'Red'
accent: 'Red'
nav:
- Home: index.md
- Why Rojo?: why-rojo.md
- Getting Started:
- Installation: getting-started/installation.md
- Creating a Place with Rojo: getting-started/creating-a-place.md
- Sync Details: sync-details.md
- Migrating from 0.4.x to 0.5.x: migrating-to-epiphany.md
markdown_extensions:
- attr_list
- admonition
- codehilite:
guess_lang: false
- toc:
permalink: true

Submodule modules/Roact deleted from 7cce62b130

Submodule modules/Rodux deleted from 6c573259ab

Submodule modules/TestEZ deleted from 9945f562e5

1
plugin/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/luacov.*

View File

@@ -9,7 +9,7 @@ stds.roblox = {
-- Extra functions
"tick", "warn", "spawn",
"wait", "settings",
"wait", "settings", "typeof",
-- Types
"Vector2", "Vector3",

8
plugin/.luacov Normal file
View File

@@ -0,0 +1,8 @@
return {
include = {
"^src",
},
exclude = {
"%.spec$",
},
}

5
plugin/README.md Normal file
View File

@@ -0,0 +1,5 @@
# Rojo Plugin
This is the source to the Rojo Roblox Studio plugin.
Documentation is WIP.

View File

@@ -0,0 +1,37 @@
--[[
Loads the Rojo plugin and all of its dependencies.
]]
local function loadEnvironment()
-- If you add any dependencies, add them to this table so they'll be loaded!
local LOAD_MODULES = {
{"src", "Rojo"},
{"modules/promise/lib", "Promise"},
{"modules/testez/lib", "TestEZ"},
}
-- This makes sure we can load Lemur and other libraries that depend on init.lua
package.path = package.path .. ";?/init.lua"
-- If this fails, make sure you've run `lua bin/install-dependencies.lua` first!
local lemur = require("modules.lemur")
-- Create a virtual Roblox tree
local habitat = lemur.Habitat.new()
-- We'll put all of our library code and dependencies here
local modules = lemur.Instance.new("Folder")
modules.Name = "Modules"
modules.Parent = habitat.game:GetService("ReplicatedStorage")
-- Load all of the modules specified above
for _, module in ipairs(LOAD_MODULES) do
local container = habitat:loadFromFs(module[1])
container.Name = module[2]
container.Parent = modules
end
return habitat, modules
end
return loadEnvironment

1
plugin/modules/lemur Submodule

Submodule plugin/modules/lemur added at 96d4166a2d

1
plugin/modules/roact Submodule

Submodule plugin/modules/roact added at 8da5b29805

1
plugin/modules/rodux Submodule

Submodule plugin/modules/rodux added at 862f1c769a

1
plugin/modules/testez Submodule

Submodule plugin/modules/testez added at 6e9157db3c

51
plugin/place-project.json Normal file
View File

@@ -0,0 +1,51 @@
{
"name": "rojo",
"tree": {
"$className": "DataModel",
"ReplicatedStorage": {
"$className": "ReplicatedStorage",
"Rojo": {
"$className": "Folder",
"Plugin": {
"$path": "src"
},
"Roact": {
"$path": "modules/roact/lib"
},
"Rodux": {
"$path": "modules/rodux/lib"
},
"RoactRodux": {
"$path": "modules/roact-rodux/lib"
},
"Promise": {
"$path": "modules/promise/lib"
}
},
"TestEZ": {
"$path": "modules/testez/lib"
}
},
"HttpService": {
"$className": "HttpService",
"$properties": {
"HttpEnabled": {
"Type": "Bool",
"Value": true
}
}
},
"TestService": {
"$className": "TestService",
"TestBootstrap": {
"$path": "testBootstrap.server.lua"
}
}
}
}

View File

@@ -0,0 +1,21 @@
{
"name": "Rojo",
"tree": {
"$className": "Folder",
"Plugin": {
"$path": "src"
},
"Roact": {
"$path": "modules/roact/lib"
},
"Rodux": {
"$path": "modules/rodux/lib"
},
"RoactRodux": {
"$path": "modules/roact-rodux/lib"
},
"Promise": {
"$path": "modules/promise/lib"
}
}
}

34
plugin/rojo.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "rojo",
"servePort": 8000,
"partitions": {
"plugin": {
"path": "src",
"target": "ReplicatedStorage.Rojo.Plugin"
},
"modules/roact": {
"path": "modules/roact/lib",
"target": "ReplicatedStorage.Rojo.Roact"
},
"modules/rodux": {
"path": "modules/rodux/lib",
"target": "ReplicatedStorage.Rojo.Rodux"
},
"modules/roact-rodux": {
"path": "modules/roact-rodux/lib",
"target": "ReplicatedStorage.Rojo.RoactRodux"
},
"modules/promise": {
"path": "modules/promise/lib",
"target": "ReplicatedStorage.Rojo.Promise"
},
"modules/testez": {
"path": "modules/testez/lib",
"target": "ReplicatedStorage.TestEZ"
},
"tests": {
"path": "testBootstrap.server.lua",
"target": "TestService.testBootstrap"
}
}
}

15
plugin/runTest.lua Normal file
View File

@@ -0,0 +1,15 @@
local loadEnvironment = require("loadEnvironment")
local testPath = assert((...), "Please specify a path to a test file.")
local habitat = loadEnvironment()
local testModule = habitat:loadFromFs(testPath)
if testModule == nil then
error("Couldn't find test file at " .. testPath)
end
print("Starting test module.")
habitat:require(testModule)

17
plugin/spec.lua Normal file
View File

@@ -0,0 +1,17 @@
--[[
Loads our library and all of its dependencies, then runs tests using TestEZ.
]]
local loadEnvironment = require("loadEnvironment")
local habitat, modules = loadEnvironment()
-- Load TestEZ and run our tests
local TestEZ = habitat:require(modules.TestEZ)
local results = TestEZ.TestBootstrap:run({modules.Rojo}, TestEZ.Reporters.TextReporter)
-- Did something go wrong?
if results.failureCount > 0 then
os.exit(1)
end

165
plugin/src/ApiContext.lua Normal file
View File

@@ -0,0 +1,165 @@
local Promise = require(script.Parent.Parent.Promise)
local Config = require(script.Parent.Config)
local Version = require(script.Parent.Version)
local Http = require(script.Parent.Http)
local HttpError = require(script.Parent.HttpError)
local ApiContext = {}
ApiContext.__index = ApiContext
-- TODO: Audit cases of errors and create enum values for each of them.
ApiContext.Error = {
ServerIdMismatch = "ServerIdMismatch",
-- The server gave an unexpected 400-category error, which may be the
-- client's fault.
ClientError = "ClientError",
-- The server gave an unexpected 500-category error, which may be the
-- server's fault.
ServerError = "ServerError",
}
setmetatable(ApiContext.Error, {
__index = function(_, key)
error("Invalid ApiContext.Error name " .. key, 2)
end
})
local function rejectFailedRequests(response)
if response.code >= 400 then
if response.code < 500 then
return Promise.reject(ApiContext.Error.ClientError)
else
return Promise.reject(ApiContext.Error.ServerError)
end
end
return response
end
function ApiContext.new(baseUrl)
assert(type(baseUrl) == "string")
local self = {
baseUrl = baseUrl,
serverId = nil,
rootInstanceId = nil,
messageCursor = -1,
partitionRoutes = nil,
}
setmetatable(self, ApiContext)
return self
end
function ApiContext:onMessage(callback)
self.onMessageCallback = callback
end
function ApiContext:connect()
local url = ("%s/api/rojo"):format(self.baseUrl)
return Http.get(url)
:andThen(rejectFailedRequests)
:andThen(function(response)
local body = response:json()
if body.protocolVersion ~= Config.protocolVersion then
local message = (
"Found a Rojo dev server, but it's using a different protocol version, and is incompatible." ..
"\nMake sure you have matching versions of both the Rojo plugin and server!" ..
"\n\nYour client is version %s, with protocol version %s. It expects server version %s." ..
"\nYour server is version %s, with protocol version %s." ..
"\n\nGo to https://github.com/LPGhatguy/rojo for more details."
):format(
Version.display(Config.version), Config.protocolVersion,
Config.expectedApiContextVersionString,
body.serverVersion, body.protocolVersion
)
return Promise.reject(message)
end
if body.expectedPlaceIds ~= nil then
local foundId = false
for _, id in ipairs(body.expectedPlaceIds) do
if id == game.PlaceId then
foundId = true
break
end
end
if not foundId then
local idList = {}
for _, id in ipairs(body.expectedPlaceIds) do
table.insert(idList, "- " .. tostring(id))
end
local message = (
"Found a Rojo server, but its project is set to only be used with a specific list of places." ..
"\nYour place ID is %s, but needs to be one of these:" ..
"\n%s" ..
"\n\nTo change this list, edit 'servePlaceIds' in roblox-project.json"
):format(
tostring(game.PlaceId),
table.concat(idList, "\n")
)
return Promise.reject(message)
end
end
self.serverId = body.serverId
self.partitionRoutes = body.partitions
self.rootInstanceId = body.rootInstanceId
end)
end
function ApiContext:read(ids)
local url = ("%s/api/read/%s"):format(self.baseUrl, table.concat(ids, ","))
return Http.get(url)
:andThen(rejectFailedRequests)
:andThen(function(response)
local body = response:json()
if body.serverId ~= self.serverId then
return Promise.reject("Server changed ID")
end
self.messageCursor = body.messageCursor
return body
end)
end
function ApiContext:retrieveMessages()
local url = ("%s/api/subscribe/%s"):format(self.baseUrl, self.messageCursor)
return Http.get(url)
:catch(function(err)
if err.type == HttpError.Error.Timeout then
return self:retrieveMessages()
end
return Promise.reject(err)
end)
:andThen(rejectFailedRequests)
:andThen(function(response)
local body = response:json()
if body.serverId ~= self.serverId then
return Promise.reject("Server changed ID")
end
self.messageCursor = body.messageCursor
return body.messages
end)
end
return ApiContext

43
plugin/src/Assets.lua Normal file
View File

@@ -0,0 +1,43 @@
local sheetAsset = "rbxassetid://2738712459"
local Assets = {
Sprites = {
WhiteCross = {
asset = sheetAsset,
offset = Vector2.new(190, 318),
size = Vector2.new(18, 18),
},
},
Slices = {
RoundBox = {
asset = "rbxassetid://2773204550",
offset = Vector2.new(0, 0),
size = Vector2.new(32, 32),
center = Rect.new(4, 4, 4, 4),
},
},
Images = {
Logo = "rbxassetid://2773210620",
},
StartSession = "",
SessionActive = "",
Configure = "",
}
local function guardForTypos(name, map)
setmetatable(map, {
__index = function(_, key)
error(("%q is not a valid member of %s"):format(tostring(key), name), 2)
end
})
for key, child in pairs(map) do
if type(child) == "table" then
guardForTypos(("%s.%s"):format(name, key), child)
end
end
end
guardForTypos("Assets", Assets)
return Assets

View File

@@ -0,0 +1,195 @@
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
local Plugin = script:FindFirstAncestor("Plugin")
local Assets = require(Plugin.Assets)
local Session = require(Plugin.Session)
local Config = require(Plugin.Config)
local Version = require(Plugin.Version)
local Logging = require(Plugin.Logging)
local DevSettings = require(Plugin.DevSettings)
local ConnectPanel = require(Plugin.Components.ConnectPanel)
local ConnectionActivePanel = require(Plugin.Components.ConnectionActivePanel)
local e = Roact.createElement
local function showUpgradeMessage(lastVersion)
local message = (
"Rojo detected an upgrade from version %s to version %s." ..
"\nMake sure you have also upgraded your server!" ..
"\n\nRojo plugin version %s is intended for use with server version %s."
):format(
Version.display(lastVersion), Version.display(Config.version),
Version.display(Config.version), Config.expectedServerVersionString
)
Logging.info(message)
end
--[[
Check if the user is using a newer version of Rojo than last time. If they
are, show them a reminder to make sure they check their server version.
]]
local function checkUpgrade(plugin)
-- When developing Rojo, there's no use in doing version checks
if DevSettings:isEnabled() then
return
end
local lastVersion = plugin:GetSetting("LastRojoVersion")
if lastVersion then
local wasUpgraded = Version.compare(Config.version, lastVersion) == 1
if wasUpgraded then
showUpgradeMessage(lastVersion)
end
end
plugin:SetSetting("LastRojoVersion", Config.version)
end
local SessionStatus = {
Disconnected = "Disconnected",
Connected = "Connected",
ConfiguringSession = "ConfiguringSession",
-- TODO: Error?
}
setmetatable(SessionStatus, {
__index = function(_, key)
error(("%q is not a valid member of SessionStatus"):format(tostring(key)), 2)
end,
})
local App = Roact.Component:extend("App")
function App:init()
self:setState({
sessionStatus = SessionStatus.Disconnected,
})
self.connectButton = nil
self.currentSession = nil
self.displayedVersion = DevSettings:isEnabled()
and Config.codename
or Version.display(Config.version)
end
function App:render()
local children
if self.state.sessionStatus == SessionStatus.Connected then
children = {
ConnectionActivePanel = e(ConnectionActivePanel, {
stopSession = function()
Logging.trace("Disconnecting session")
self.currentSession:disconnect()
self.currentSession = nil
self:setState({
sessionStatus = SessionStatus.Disconnected,
})
Logging.trace("Session terminated by user")
end,
}),
}
elseif self.state.sessionStatus == SessionStatus.ConfiguringSession then
children = {
ConnectPanel = e(ConnectPanel, {
startSession = function(address, port)
Logging.trace("Starting new session")
local success, session = Session.new({
address = address,
port = port,
onError = function(message)
Logging.warn("Rojo session terminated because of an error:\n%s", tostring(message))
self.currentSession = nil
self:setState({
sessionStatus = SessionStatus.Disconnected,
})
end
})
if success then
self.currentSession = session
self:setState({
sessionStatus = SessionStatus.Connected,
})
end
end,
cancel = function()
Logging.trace("Canceling session configuration")
self:setState({
sessionStatus = SessionStatus.Disconnected,
})
end,
}),
}
end
return e("ScreenGui", {
AutoLocalize = false,
ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
}, children)
end
function App:didMount()
Logging.trace("Rojo %s initializing", self.displayedVersion)
local toolbar = self.props.plugin:CreateToolbar("Rojo " .. self.displayedVersion)
self.connectButton = toolbar:CreateButton(
"Connect",
"Connect to a running Rojo session",
Assets.StartSession)
self.connectButton.ClickableWhenViewportHidden = false
self.connectButton.Click:Connect(function()
checkUpgrade(self.props.plugin)
if self.state.sessionStatus == SessionStatus.Connected then
Logging.trace("Disconnecting session")
self.currentSession:disconnect()
self.currentSession = nil
self:setState({
sessionStatus = SessionStatus.Disconnected,
})
Logging.trace("Session terminated by user")
elseif self.state.sessionStatus == SessionStatus.Disconnected then
Logging.trace("Starting session configuration")
self:setState({
sessionStatus = SessionStatus.ConfiguringSession,
})
elseif self.state.sessionStatus == SessionStatus.ConfiguringSession then
Logging.trace("Canceling session configuration")
self:setState({
sessionStatus = SessionStatus.Disconnected,
})
end
end)
end
function App:didUpdate()
local connectActive = self.state.sessionStatus == SessionStatus.ConfiguringSession
or self.state.sessionStatus == SessionStatus.Connected
self.connectButton:SetActive(connectActive)
if self.state.sessionStatus == SessionStatus.Connected then
self.connectButton.Icon = Assets.SessionActive
else
self.connectButton.Icon = Assets.StartSession
end
end
return App

View File

@@ -0,0 +1,261 @@
local Rojo = script:FindFirstAncestor("Rojo")
local Plugin = Rojo.Plugin
local Roact = require(Rojo.Roact)
local Config = require(Plugin.Config)
local Version = require(Plugin.Version)
local Assets = require(Plugin.Assets)
local Theme = require(Plugin.Theme)
local joinBindings = require(Plugin.joinBindings)
local FitList = require(Plugin.Components.FitList)
local FitText = require(Plugin.Components.FitText)
local FormButton = require(Plugin.Components.FormButton)
local FormTextInput = require(Plugin.Components.FormTextInput)
local RoundBox = Assets.Slices.RoundBox
local e = Roact.createElement
local ConnectPanel = Roact.Component:extend("ConnectPanel")
function ConnectPanel:init()
self.footerSize, self.setFooterSize = Roact.createBinding(Vector2.new())
self.footerVersionSize, self.setFooterVersionSize = Roact.createBinding(Vector2.new())
-- This is constructed in init because 'joinBindings' is a hack and we'd
-- leak memory constructing it every render. When this kind of feature lands
-- in Roact properly, we can do this inline in render without fear.
self.footerRestSize = joinBindings(
{
self.footerSize,
self.footerVersionSize,
},
function(container, other)
return UDim2.new(0, container.X - other.X - 16, 0, 32)
end
)
self:setState({
address = "",
port = "",
})
end
function ConnectPanel:render()
local startSession = self.props.startSession
local cancel = self.props.cancel
return e(FitList, {
containerKind = "ImageLabel",
containerProps = {
Image = RoundBox.asset,
ImageRectOffset = RoundBox.offset,
ImageRectSize = RoundBox.size,
SliceCenter = RoundBox.center,
ScaleType = Enum.ScaleType.Slice,
BackgroundTransparency = 1,
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
},
layoutProps = {
HorizontalAlignment = Enum.HorizontalAlignment.Center,
},
}, {
Inputs = e(FitList, {
containerProps = {
BackgroundTransparency = 1,
LayoutOrder = 1,
},
layoutProps = {
FillDirection = Enum.FillDirection.Horizontal,
Padding = UDim.new(0, 8),
},
paddingProps = {
PaddingTop = UDim.new(0, 20),
PaddingBottom = UDim.new(0, 10),
PaddingLeft = UDim.new(0, 24),
PaddingRight = UDim.new(0, 24),
},
}, {
Address = e(FitList, {
containerProps = {
LayoutOrder = 1,
BackgroundTransparency = 1,
},
layoutProps = {
Padding = UDim.new(0, 4),
},
}, {
Label = e(FitText, {
Kind = "TextLabel",
LayoutOrder = 1,
BackgroundTransparency = 1,
TextXAlignment = Enum.TextXAlignment.Left,
Font = Theme.TitleFont,
TextSize = 20,
Text = "Address",
TextColor3 = Theme.AccentColor,
}),
Input = e(FormTextInput, {
layoutOrder = 2,
width = UDim.new(0, 220),
value = self.state.address,
placeholderValue = Config.defaultHost,
onValueChange = function(newValue)
self:setState({
address = newValue,
})
end,
}),
}),
Port = e(FitList, {
containerProps = {
LayoutOrder = 2,
BackgroundTransparency = 1,
},
layoutProps = {
Padding = UDim.new(0, 4),
},
}, {
Label = e(FitText, {
Kind = "TextLabel",
LayoutOrder = 1,
BackgroundTransparency = 1,
TextXAlignment = Enum.TextXAlignment.Left,
Font = Theme.TitleFont,
TextSize = 20,
Text = "Port",
TextColor3 = Theme.AccentColor,
}),
Input = e(FormTextInput, {
layoutOrder = 2,
width = UDim.new(0, 80),
value = self.state.port,
placeholderValue = Config.defaultPort,
onValueChange = function(newValue)
self:setState({
port = newValue,
})
end,
}),
}),
}),
Buttons = e(FitList, {
fitAxes = "Y",
containerProps = {
BackgroundTransparency = 1,
LayoutOrder = 2,
Size = UDim2.new(1, 0, 0, 0),
},
layoutProps = {
FillDirection = Enum.FillDirection.Horizontal,
HorizontalAlignment = Enum.HorizontalAlignment.Right,
Padding = UDim.new(0, 8),
},
paddingProps = {
PaddingTop = UDim.new(0, 0),
PaddingBottom = UDim.new(0, 20),
PaddingLeft = UDim.new(0, 24),
PaddingRight = UDim.new(0, 24),
},
}, {
e(FormButton, {
layoutOrder = 1,
text = "Cancel",
onClick = function()
if cancel ~= nil then
cancel()
end
end,
secondary = true,
}),
e(FormButton, {
layoutOrder = 2,
text = "Connect",
onClick = function()
if startSession ~= nil then
local address = self.state.address
if address:len() == 0 then
address = Config.defaultHost
end
local port = self.state.port
if port:len() == 0 then
port = Config.defaultPort
end
startSession(address, port)
end
end,
}),
}),
Footer = e(FitList, {
fitAxes = "Y",
containerKind = "ImageLabel",
containerProps = {
Image = RoundBox.asset,
ImageRectOffset = RoundBox.offset + Vector2.new(0, RoundBox.size.Y / 2),
ImageRectSize = RoundBox.size * Vector2.new(1, 0.5),
SliceCenter = RoundBox.center,
ScaleType = Enum.ScaleType.Slice,
ImageColor3 = Theme.SecondaryColor,
Size = UDim2.new(1, 0, 0, 0),
LayoutOrder = 3,
BackgroundTransparency = 1,
[Roact.Change.AbsoluteSize] = function(rbx)
self.setFooterSize(rbx.AbsoluteSize)
end,
},
layoutProps = {
FillDirection = Enum.FillDirection.Horizontal,
HorizontalAlignment = Enum.HorizontalAlignment.Center,
VerticalAlignment = Enum.VerticalAlignment.Center,
},
paddingProps = {
PaddingTop = UDim.new(0, 4),
PaddingBottom = UDim.new(0, 4),
PaddingLeft = UDim.new(0, 8),
PaddingRight = UDim.new(0, 8),
},
}, {
LogoContainer = e("Frame", {
BackgroundTransparency = 1,
Size = self.footerRestSize,
}, {
Logo = e("ImageLabel", {
Image = Assets.Images.Logo,
Size = UDim2.new(0, 80, 0, 40),
ScaleType = Enum.ScaleType.Fit,
BackgroundTransparency = 1,
Position = UDim2.new(0, 0, 1, -10),
AnchorPoint = Vector2.new(0, 1),
}),
}),
Version = e(FitText, {
Font = Theme.TitleFont,
TextSize = 18,
Text = Version.display(Config.version),
TextXAlignment = Enum.TextXAlignment.Right,
TextColor3 = Theme.LightTextColor,
BackgroundTransparency = 1,
[Roact.Change.AbsoluteSize] = function(rbx)
self.setFooterVersionSize(rbx.AbsoluteSize)
end,
}),
}),
})
end
return ConnectPanel

View File

@@ -0,0 +1,67 @@
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
local Plugin = script:FindFirstAncestor("Plugin")
local Theme = require(Plugin.Theme)
local Assets = require(Plugin.Assets)
local FitList = require(Plugin.Components.FitList)
local FitText = require(Plugin.Components.FitText)
local e = Roact.createElement
local RoundBox = Assets.Slices.RoundBox
local WhiteCross = Assets.Sprites.WhiteCross
local function ConnectionActivePanel(props)
local stopSession = props.stopSession
return e(FitList, {
containerKind = "ImageLabel",
containerProps = {
Image = RoundBox.asset,
ImageRectOffset = RoundBox.offset + Vector2.new(0, RoundBox.size.Y / 2),
ImageRectSize = RoundBox.size * Vector2.new(1, 0.5),
SliceCenter = Rect.new(4, 4, 4, 4),
ScaleType = Enum.ScaleType.Slice,
BackgroundTransparency = 1,
Position = UDim2.new(0.5, 0, 0, 0),
AnchorPoint = Vector2.new(0.5, 0),
},
layoutProps = {
FillDirection = Enum.FillDirection.Horizontal,
VerticalAlignment = Enum.VerticalAlignment.Center,
},
}, {
Text = e(FitText, {
Padding = Vector2.new(12, 6),
Font = Theme.ButtonFont,
TextSize = 18,
Text = "Rojo Connected",
TextColor3 = Theme.PrimaryColor,
BackgroundTransparency = 1,
}),
CloseContainer = e("ImageButton", {
Size = UDim2.new(0, 30, 0, 30),
BackgroundTransparency = 1,
[Roact.Event.Activated] = function()
stopSession()
end,
}, {
CloseImage = e("ImageLabel", {
Size = UDim2.new(0, 16, 0, 16),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
Image = WhiteCross.asset,
ImageRectOffset = WhiteCross.offset,
ImageRectSize = WhiteCross.size,
ImageColor3 = Theme.PrimaryColor,
BackgroundTransparency = 1,
}),
}),
})
end
return ConnectionActivePanel

View File

@@ -0,0 +1,63 @@
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
local Dictionary = require(script.Parent.Parent.Dictionary)
local e = Roact.createElement
local FitList = Roact.Component:extend("FitList")
function FitList:init()
self.sizeBinding, self.setSize = Roact.createBinding(UDim2.new())
end
function FitList:render()
local containerKind = self.props.containerKind or "Frame"
local fitAxes = self.props.fitAxes or "XY"
local containerProps = self.props.containerProps
local layoutProps = self.props.layoutProps
local paddingProps = self.props.paddingProps
local padding
if paddingProps ~= nil then
padding = e("UIPadding", paddingProps)
end
local children = Dictionary.merge(self.props[Roact.Children], {
["$Layout"] = e("UIListLayout", Dictionary.merge({
SortOrder = Enum.SortOrder.LayoutOrder,
[Roact.Change.AbsoluteContentSize] = function(instance)
local contentSize = instance.AbsoluteContentSize
if paddingProps ~= nil then
contentSize = contentSize + Vector2.new(
paddingProps.PaddingLeft.Offset + paddingProps.PaddingRight.Offset,
paddingProps.PaddingTop.Offset + paddingProps.PaddingBottom.Offset)
end
local combinedSize
if fitAxes == "X" then
combinedSize = UDim2.new(0, contentSize.X, containerProps.Size.Y.Scale, containerProps.Size.Y.Offset)
elseif fitAxes == "Y" then
combinedSize = UDim2.new(containerProps.Size.X.Scale, containerProps.Size.X.Offset, 0, contentSize.Y)
elseif fitAxes == "XY" then
combinedSize = UDim2.new(0, contentSize.X, 0, contentSize.Y)
else
error("Invalid fitAxes value")
end
self.setSize(combinedSize)
end,
}, layoutProps)),
["$Padding"] = padding,
})
local fullContainerProps = Dictionary.merge(containerProps, {
Size = self.sizeBinding,
})
return e(containerKind, fullContainerProps, children)
end
return FitList

View File

@@ -0,0 +1,52 @@
local TextService = game:GetService("TextService")
local Roact = require(script:FindFirstAncestor("Rojo").Roact)
local Dictionary = require(script.Parent.Parent.Dictionary)
local e = Roact.createElement
local FitText = Roact.Component:extend("FitText")
function FitText:init()
self.sizeBinding, self.setSize = Roact.createBinding(UDim2.new())
end
function FitText:render()
local kind = self.props.Kind or "TextLabel"
local containerProps = Dictionary.merge(self.props, {
Kind = Dictionary.None,
Padding = Dictionary.None,
MinSize = Dictionary.None,
Size = self.sizeBinding
})
return e(kind, containerProps)
end
function FitText:didMount()
self:updateTextMeasurements()
end
function FitText:didUpdate()
self:updateTextMeasurements()
end
function FitText:updateTextMeasurements()
local minSize = self.props.MinSize or Vector2.new(0, 0)
local padding = self.props.Padding or Vector2.new(0, 0)
local text = self.props.Text or ""
local font = self.props.Font or Enum.Font.Legacy
local textSize = self.props.TextSize or 12
local measuredText = TextService:GetTextSize(text, textSize, font, Vector2.new(9e6, 9e6))
local totalSize = UDim2.new(
0, math.max(minSize.X, padding.X * 2 + measuredText.X),
0, math.max(minSize.Y, padding.Y * 2 + measuredText.Y))
self.setSize(totalSize)
end
return FitText

View File

@@ -0,0 +1,62 @@
local Rojo = script:FindFirstAncestor("Rojo")
local Plugin = Rojo.Plugin
local Roact = require(Rojo.Roact)
local Assets = require(Plugin.Assets)
local Theme = require(Plugin.Theme)
local FitList = require(Plugin.Components.FitList)
local FitText = require(Plugin.Components.FitText)
local e = Roact.createElement
local RoundBox = Assets.Slices.RoundBox
local function FormButton(props)
local text = props.text
local layoutOrder = props.layoutOrder
local onClick = props.onClick
local textColor
local backgroundColor
if props.secondary then
textColor = Theme.AccentColor
backgroundColor = Theme.SecondaryColor
else
textColor = Theme.SecondaryColor
backgroundColor = Theme.AccentColor
end
return e(FitList, {
containerKind = "ImageButton",
containerProps = {
LayoutOrder = layoutOrder,
BackgroundTransparency = 1,
Image = RoundBox.asset,
ImageRectOffset = RoundBox.offset,
ImageRectSize = RoundBox.size,
SliceCenter = RoundBox.center,
ScaleType = Enum.ScaleType.Slice,
ImageColor3 = backgroundColor,
[Roact.Event.Activated] = function()
if onClick ~= nil then
onClick()
end
end,
},
}, {
Text = e(FitText, {
Kind = "TextLabel",
Text = text,
TextSize = 18,
TextColor3 = textColor,
Font = Theme.ButtonFont,
Padding = Vector2.new(16, 8),
BackgroundTransparency = 1,
}),
})
end
return FormButton

View File

@@ -0,0 +1,80 @@
local Rojo = script:FindFirstAncestor("Rojo")
local Plugin = Rojo.Plugin
local Roact = require(Rojo.Roact)
local Assets = require(Plugin.Assets)
local Theme = require(Plugin.Theme)
local e = Roact.createElement
local RoundBox = Assets.Slices.RoundBox
local TEXT_SIZE = 22
local PADDING = 8
local FormTextInput = Roact.Component:extend("FormTextInput")
function FormTextInput:init()
self:setState({
focused = false,
})
end
function FormTextInput:render()
local value = self.props.value
local placeholderValue = self.props.placeholderValue
local onValueChange = self.props.onValueChange
local layoutOrder = self.props.layoutOrder
local width = self.props.width
local shownPlaceholder
if self.state.focused then
shownPlaceholder = ""
else
shownPlaceholder = placeholderValue
end
return e("ImageLabel", {
LayoutOrder = layoutOrder,
Image = RoundBox.asset,
ImageRectOffset = RoundBox.offset,
ImageRectSize = RoundBox.size,
ScaleType = Enum.ScaleType.Slice,
SliceCenter = RoundBox.center,
ImageColor3 = Theme.SecondaryColor,
Size = UDim2.new(width.Scale, width.Offset, 0, TEXT_SIZE + PADDING * 2),
BackgroundTransparency = 1,
}, {
InputInner = e("TextBox", {
BackgroundTransparency = 1,
Size = UDim2.new(1, -PADDING * 2, 1, -PADDING * 2),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
Font = Theme.InputFont,
ClearTextOnFocus = false,
TextXAlignment = Enum.TextXAlignment.Center,
TextSize = TEXT_SIZE,
Text = value,
PlaceholderText = shownPlaceholder,
PlaceholderColor3 = Theme.AccentLightColor,
TextColor3 = Theme.AccentColor,
[Roact.Change.Text] = function(rbx)
onValueChange(rbx.Text)
end,
[Roact.Event.Focused] = function()
self:setState({
focused = true,
})
end,
[Roact.Event.FocusLost] = function()
self:setState({
focused = false,
})
end,
}),
})
end
return FormTextInput

View File

@@ -1,5 +1,8 @@
return {
pollingRate = 0.3,
version = "v0.2.3",
dev = false,
}
codename = "Epiphany",
version = {0, 5, 0, "-alpha.1"},
expectedServerVersionString = "0.5.0 or newer",
protocolVersion = 2,
defaultHost = "localhost",
defaultPort = 34872,
}

View File

@@ -0,0 +1,71 @@
local Config = require(script.Parent.Config)
local VALUES = {
LogLevel = {
type = "IntValue",
defaultUserValue = 2,
defaultDevValue = 3,
},
}
local CONTAINER_NAME = "RojoDevSettings" .. Config.codename
local function getValueContainer()
return game:FindFirstChild(CONTAINER_NAME)
end
local valueContainer = getValueContainer()
local function getStoredValue(name)
if valueContainer == nil then
return nil
end
local valueObject = valueContainer:FindFirstChild(name)
if valueObject == nil then
return nil
end
return valueObject.Value
end
local function setStoredValue(name, kind, value)
local object = valueContainer:FindFirstChild(name)
if object == nil then
object = Instance.new(kind)
object.Name = name
object.Parent = valueContainer
end
object.Value = value
end
local function createAllValues()
valueContainer = getValueContainer()
if valueContainer == nil then
valueContainer = Instance.new("Folder")
valueContainer.Name = CONTAINER_NAME
valueContainer.Parent = game
end
for name, value in pairs(VALUES) do
setStoredValue(name, value.type, value.defaultDevValue)
end
end
_G[("ROJO_%s_DEV_CREATE"):format(Config.codename:upper())] = createAllValues
local DevSettings = {}
function DevSettings:isEnabled()
return valueContainer ~= nil
end
function DevSettings:getLogLevel()
return getStoredValue("LogLevel") or VALUES.LogLevel.defaultUserValue
end
return DevSettings

33
plugin/src/Dictionary.lua Normal file
View File

@@ -0,0 +1,33 @@
--[[
This is a placeholder module waiting for Cryo to become available.
]]
local None = newproxy(true)
getmetatable(None).__tostring = function()
return "None"
end
local function merge(...)
local output = {}
for i = 1, select("#", ...) do
local source = select(i, ...)
if source ~= nil then
for key, value in pairs(source) do
if value == None then
output[key] = nil
else
output[key] = value
end
end
end
end
return output
end
return {
None = None,
merge = merge,
}

View File

@@ -1,67 +1,75 @@
local HttpService = game:GetService("HttpService")
local HTTP_DEBUG = false
local Promise = require(script.Parent.Parent.Promise)
local Promise = require(script.Parent.Promise)
local Logging = require(script.Parent.Logging)
local HttpError = require(script.Parent.HttpError)
local HttpResponse = require(script.Parent.HttpResponse)
local function dprint(...)
if HTTP_DEBUG then
print(...)
end
end
local lastRequestId = 0
-- TODO: Factor out into separate library, especially error handling
local Http = {}
Http.__index = Http
function Http.new(baseUrl)
assert(type(baseUrl) == "string", "Http.new needs a baseUrl!")
function Http.get(url)
local requestId = lastRequestId + 1
lastRequestId = requestId
local http = {
baseUrl = baseUrl
}
Logging.trace("GET(%d) %s", requestId, url)
setmetatable(http, Http)
return http
end
function Http:get(endpoint)
dprint("\nGET", endpoint)
return Promise.new(function(resolve, reject)
spawn(function()
local ok, result = pcall(function()
return HttpService:GetAsync(self.baseUrl .. endpoint, true)
coroutine.wrap(function()
local success, response = pcall(function()
return HttpService:RequestAsync({
Url = url,
Method = "GET",
})
end)
if ok then
dprint("\t", result, "\n")
resolve(HttpResponse.new(result))
if success then
Logging.trace("Request %d success: status code %s", requestId, response.StatusCode)
resolve(HttpResponse.fromRobloxResponse(response))
else
reject(HttpError.fromErrorString(result))
Logging.trace("Request %d failure: %s", requestId, response)
reject(HttpError.fromErrorString(response))
end
end)
end)()
end)
end
function Http:post(endpoint, body)
dprint("\nPOST", endpoint)
dprint(body)
function Http.post(url, body)
local requestId = lastRequestId + 1
lastRequestId = requestId
Logging.trace("POST(%d) %s\n%s", requestId, url, body)
return Promise.new(function(resolve, reject)
spawn(function()
local ok, result = pcall(function()
return HttpService:PostAsync(self.baseUrl .. endpoint, body)
coroutine.wrap(function()
local success, response = pcall(function()
return HttpService:RequestAsync({
Url = url,
Method = "POST",
Body = body,
})
end)
if ok then
dprint("\t", result, "\n")
resolve(HttpResponse.new(result))
if success then
Logging.trace("Request %d success: status code %s", requestId, response.StatusCode)
resolve(HttpResponse.fromRobloxResponse(response))
else
reject(HttpError.fromErrorString(result))
Logging.trace("Request %d failure: %s", requestId, response)
reject(HttpError.fromErrorString(response))
end
end)
end)()
end)
end
return Http
function Http.jsonEncode(object)
return HttpService:JSONEncode(object)
end
function Http.jsonDecode(source)
return HttpService:JSONDecode(source)
end
return Http

View File

@@ -1,3 +1,5 @@
local Logging = require(script.Parent.Logging)
local HttpError = {}
HttpError.__index = HttpError
@@ -7,14 +9,23 @@ HttpError.Error = {
"Check your game settings, located in the 'Home' tab of Studio.",
},
ConnectFailed = {
message = "Rojo plugin couldn't connect to the Rojo server.\n" ..
"Make sure the server is running -- use 'Rojo serve' to run it!",
message = "Couldn't connect to the Rojo server.\n" ..
"Make sure the server is running -- use 'rojo serve' to run it!",
},
Timeout = {
message = "Request timed out.",
},
Unknown = {
message = "Rojo encountered an unknown error: {{message}}",
message = "Unknown error: {{message}}",
},
}
setmetatable(HttpError.Error, {
__index = function(_, key)
error(("%q is not a valid member of HttpError.Error"):format(tostring(key)), 2)
end,
})
function HttpError.new(type, extraMessage)
extraMessage = extraMessage or ""
local message = type.message:gsub("{{message}}", extraMessage)
@@ -36,22 +47,26 @@ end
--[[
This method shouldn't have to exist. Ugh.
]]
function HttpError.fromErrorString(err)
err = err:lower()
function HttpError.fromErrorString(message)
local lower = message:lower()
if err:find("^http requests are not enabled") then
if lower:find("^http requests are not enabled") then
return HttpError.new(HttpError.Error.HttpNotEnabled)
end
if err:find("^curl error") then
if lower:find("^httperror: timedout") then
return HttpError.new(HttpError.Error.Timeout)
end
if lower:find("^httperror: connectfail") then
return HttpError.new(HttpError.Error.ConnectFailed)
end
return HttpError.new(HttpError.Error.Unknown, err)
return HttpError.new(HttpError.Error.Unknown, message)
end
function HttpError:report()
warn(self.message)
Logging.warn(self.message)
end
return HttpError
return HttpError

View File

@@ -1,20 +1,34 @@
local HttpService = game:GetService("HttpService")
local stringTemplate = [[
HttpResponse {
code: %d
body: %s
}]]
local HttpResponse = {}
HttpResponse.__index = HttpResponse
function HttpResponse.new(body)
local response = {
body = body,
function HttpResponse:__tostring()
return stringTemplate:format(self.code, self.body)
end
function HttpResponse.fromRobloxResponse(response)
local self = {
body = response.Body,
code = response.StatusCode,
headers = response.Headers,
}
setmetatable(response, HttpResponse)
return setmetatable(self, HttpResponse)
end
return response
function HttpResponse:isSuccess()
return self.code >= 200 and self.code < 300
end
function HttpResponse:json()
return HttpService:JSONDecode(self.body)
end
return HttpResponse
return HttpResponse

50
plugin/src/Logging.lua Normal file
View File

@@ -0,0 +1,50 @@
local DevSettings = require(script.Parent.DevSettings)
local Level = {
Error = 0,
Warning = 1,
Info = 2,
Trace = 3,
}
local testLogLevel = nil
local function getLogLevel()
if testLogLevel ~= nil then
return testLogLevel
end
return DevSettings:getLogLevel()
end
local function addTags(tag, message)
return tag .. message:gsub("\n", "\n" .. tag)
end
local INFO_TAG = (" "):rep(15) .. "[Rojo-Info] "
local TRACE_TAG = (" "):rep(15) .. "[Rojo-Trace] "
local WARN_TAG = "[Rojo-Warn] "
local Log = {}
Log.Level = Level
function Log.trace(template, ...)
if getLogLevel() >= Level.Trace then
print(addTags(TRACE_TAG, string.format(template, ...)))
end
end
function Log.info(template, ...)
if getLogLevel() >= Level.Info then
print(addTags(INFO_TAG, string.format(template, ...)))
end
end
function Log.warn(template, ...)
if getLogLevel() >= Level.Warning then
warn(addTags(WARN_TAG, string.format(template, ...)))
end
end
return Log

View File

@@ -1,42 +0,0 @@
if not plugin then
return
end
local Plugin = require(script.Parent.Plugin)
local Config = require(script.Parent.Config)
local function main()
local pluginInstance = Plugin.new()
local displayedVersion = Config.dev and "DEV" or Config.version
local toolbar = plugin:CreateToolbar("Rojo Plugin " .. displayedVersion)
toolbar:CreateButton("Test Connection", "Connect to Rojo Server", "")
.Click:Connect(function()
pluginInstance:connect()
:catch(function(err)
warn(err)
end)
end)
toolbar:CreateButton("Sync In", "Sync into Roblox Studio", "")
.Click:Connect(function()
pluginInstance:syncIn()
:catch(function(err)
warn(err)
end)
end)
toolbar:CreateButton("Toggle Polling", "Poll server for changes", "")
.Click:Connect(function()
spawn(function()
pluginInstance:togglePolling()
:catch(function(err)
warn(err)
end)
end)
end)
end
main()

View File

@@ -1,178 +0,0 @@
local Config = require(script.Parent.Config)
local Http = require(script.Parent.Http)
local Server = require(script.Parent.Server)
local Promise = require(script.Parent.Promise)
local Reconciler = require(script.Parent.Reconciler)
local function collectMatch(source, pattern)
local result = {}
for match in source:gmatch(pattern) do
table.insert(result, match)
end
return result
end
local Plugin = {}
Plugin.__index = Plugin
function Plugin.new()
local address = "localhost"
local port = Config.dev and 8001 or 8000
local remote = ("http://%s:%d"):format(address, port)
local foop = {
_http = Http.new(remote),
_server = nil,
_polling = false,
}
setmetatable(foop, Plugin)
do
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "Rojo UI"
screenGui.Parent = game.CoreGui
screenGui.DisplayOrder = -1
screenGui.Enabled = false
local label = Instance.new("TextLabel")
label.Font = Enum.Font.SourceSans
label.TextSize = 20
label.Text = "Rojo polling..."
label.BackgroundColor3 = Color3.fromRGB(31, 31, 31)
label.BackgroundTransparency = 0.5
label.BorderSizePixel = 0
label.TextColor3 = Color3.new(1, 1, 1)
label.Size = UDim2.new(0, 120, 0, 28)
label.Position = UDim2.new(0, 0, 0, 0)
label.Parent = screenGui
foop._label = screenGui
end
return foop
end
function Plugin:server()
if not self._server then
self._server = Server.connect(self._http)
:catch(function(err)
self._server = nil
return Promise.reject(err)
end)
end
return self._server
end
function Plugin:connect()
print("Testing connection...")
return self:server()
:andThen(function(server)
return server:getInfo()
end)
:andThen(function(result)
print("Server found!")
print("Protocol version:", result.protocolVersion)
print("Server version:", result.serverVersion)
end)
end
function Plugin:togglePolling()
if self._polling then
self:stopPolling()
return Promise.resolve(nil)
else
return self:startPolling()
end
end
function Plugin:stopPolling()
if not self._polling then
return
end
print("Stopped polling.")
self._polling = false
self._label.Enabled = false
end
function Plugin:_pull(server, project, routes)
local items = server:read(routes):await()
for index = 1, #routes do
local route = routes[index]
local partitionName = route[1]
local partition = project.partitions[partitionName]
local item = items[index]
local fullRoute = collectMatch(partition.target, "[^.]+")
for i = 2, #route do
table.insert(fullRoute, routes[index][i])
end
Reconciler.reconcileRoute(fullRoute, item)
end
end
function Plugin:startPolling()
if self._polling then
return
end
print("Starting to poll...")
self._polling = true
self._label.Enabled = true
return self:server()
:andThen(function(server)
self:syncIn():await()
local project = server:getInfo():await().project
while self._polling do
local changes = server:getChanges():await()
local routes = {}
for _, change in ipairs(changes) do
table.insert(routes, change.route)
end
self:_pull(server, project, routes)
wait(Config.pollingRate)
end
end)
:catch(function()
self:stopPolling()
end)
end
function Plugin:syncIn()
print("Syncing from server...")
return self:server()
:andThen(function(server)
local project = server:getInfo():await().project
local routes = {}
for name in pairs(project.partitions) do
table.insert(routes, {name})
end
self:_pull(server, project, routes)
print("Sync successful!")
end)
end
return Plugin

View File

@@ -1,308 +0,0 @@
--[[
An implementation of Promises similar to Promise/A+.
]]
local PROMISE_DEBUG = false
-- If promise debugging is on, use a version of pcall that warns on failure.
-- This is useful for finding errors that happen within Promise itself.
local wpcall
if PROMISE_DEBUG then
wpcall = function(f, ...)
local result = { pcall(f, ...) }
if not result[1] then
warn(result[2])
end
return unpack(result)
end
else
wpcall = pcall
end
--[[
Creates a function that invokes a callback with correct error handling and
resolution mechanisms.
]]
local function createAdvancer(callback, resolve, reject)
return function(...)
local result = { wpcall(callback, ...) }
local ok = table.remove(result, 1)
if ok then
resolve(unpack(result))
else
reject(unpack(result))
end
end
end
local function isEmpty(t)
return next(t) == nil
end
local Promise = {}
Promise.__index = Promise
Promise.Status = {
Started = "Started",
Resolved = "Resolved",
Rejected = "Rejected",
}
--[[
Constructs a new Promise with the given initializing callback.
This is generally only called when directly wrapping a non-promise API into
a promise-based version.
The callback will receive 'resolve' and 'reject' methods, used to start
invoking the promise chain.
For example:
local function get(url)
return Promise.new(function(resolve, reject)
spawn(function()
resolve(HttpService:GetAsync(url))
end)
end)
end
get("https://google.com")
:andThen(function(stuff)
print("Got some stuff!", stuff)
end)
]]
function Promise.new(callback)
local promise = {
-- Used to locate where a promise was created
_source = debug.traceback(),
-- A tag to identify us as a promise
_type = "Promise",
_status = Promise.Status.Started,
-- A table containing a list of all results, whether success or failure.
-- Only valid if _status is set to something besides Started
_value = nil,
-- If an error occurs with no observers, this will be set.
_unhandledRejection = false,
-- Queues representing functions we should invoke when we update!
_queuedResolve = {},
_queuedReject = {},
}
setmetatable(promise, Promise)
local function resolve(...)
promise:_resolve(...)
end
local function reject(...)
promise:_reject(...)
end
local ok, err = wpcall(callback, resolve, reject)
if not ok and promise._status == Promise.Status.Started then
reject(err)
end
return promise
end
--[[
Create a promise that represents the immediately resolved value.
]]
function Promise.resolve(value)
return Promise.new(function(resolve)
resolve(value)
end)
end
--[[
Create a promise that represents the immediately rejected value.
]]
function Promise.reject(value)
return Promise.new(function(_, reject)
reject(value)
end)
end
--[[
Returns a new promise that:
* is resolved when all input promises resolve
* is rejected if ANY input promises reject
]]
function Promise.all(...)
error("unimplemented", 2)
end
--[[
Is the given object a Promise instance?
]]
function Promise.is(object)
if type(object) ~= "table" then
return false
end
return object._type == "Promise"
end
--[[
Creates a new promise that receives the result of this promise.
The given callbacks are invoked depending on that result.
]]
function Promise:andThen(successHandler, failureHandler)
self._unhandledRejection = false
-- Create a new promise to follow this part of the chain
return Promise.new(function(resolve, reject)
-- Our default callbacks just pass values onto the next promise.
-- This lets success and failure cascade correctly!
local successCallback = resolve
if successHandler then
successCallback = createAdvancer(successHandler, resolve, reject)
end
local failureCallback = reject
if failureHandler then
failureCallback = createAdvancer(failureHandler, resolve, reject)
end
if self._status == Promise.Status.Started then
-- If we haven't resolved yet, put ourselves into the queue
table.insert(self._queuedResolve, successCallback)
table.insert(self._queuedReject, failureCallback)
elseif self._status == Promise.Status.Resolved then
-- This promise has already resolved! Trigger success immediately.
successCallback(unpack(self._value))
elseif self._status == Promise.Status.Rejected then
-- This promise died a terrible death! Trigger failure immediately.
failureCallback(unpack(self._value))
end
end)
end
--[[
Used to catch any errors that may have occurred in the promise.
]]
function Promise:catch(failureCallback)
return self:andThen(nil, failureCallback)
end
--[[
Yield until the promise is completed.
This matches the execution model of normal Roblox functions.
]]
function Promise:await()
self._unhandledRejection = false
if self._status == Promise.Status.Started then
local result
local bindable = Instance.new("BindableEvent")
self:andThen(function(...)
result = {...}
bindable:Fire(true)
end, function(...)
result = {...}
bindable:Fire(false)
end)
local ok = bindable.Event:Wait()
bindable:Destroy()
if not ok then
error(tostring(result[1]), 2)
end
return unpack(result)
elseif self._status == Promise.Status.Resolved then
return unpack(self._value)
elseif self._status == Promise.Status.Rejected then
error(tostring(self._value[1]), 2)
end
end
function Promise:_resolve(...)
if self._status ~= Promise.Status.Started then
return
end
-- If the resolved value was a Promise, we chain onto it!
if Promise.is((...)) then
-- Without this warning, arguments sometimes mysteriously disappear
if select("#", ...) > 1 then
local message = ("When returning a Promise from andThen, extra arguments are discarded! See:\n\n%s"):format(
self._source
)
warn(message)
end
(...):andThen(function(...)
self:_resolve(...)
end, function(...)
self:_reject(...)
end)
return
end
self._status = Promise.Status.Resolved
self._value = {...}
-- We assume that these callbacks will not throw errors.
for _, callback in ipairs(self._queuedResolve) do
callback(...)
end
end
function Promise:_reject(...)
if self._status ~= Promise.Status.Started then
return
end
self._status = Promise.Status.Rejected
self._value = {...}
-- If there are any rejection handlers, call those!
if not isEmpty(self._queuedReject) then
-- We assume that these callbacks will not throw errors.
for _, callback in ipairs(self._queuedReject) do
callback(...)
end
else
-- At this point, no one was able to observe the error.
-- An error handler might still be attached if the error occurred
-- synchronously. We'll wait one tick, and if there are still no
-- observers, then we should put a message in the console.
self._unhandledRejection = true
local err = tostring((...))
spawn(function()
-- Someone observed the error, hooray!
if not self._unhandledRejection then
return
end
-- Build a reasonable message
local message = ("Unhandled promise rejection:\n\n%s\n\n%s"):format(
err,
self._source
)
warn(message)
end)
end
end
return Promise

View File

@@ -1,70 +0,0 @@
return function()
local Promise = require(script.Parent.Promise)
describe("Promise.new", function()
it("should instantiate with a callback", function()
local promise = Promise.new(function() end)
expect(promise).to.be.ok()
end)
it("should invoke the given callback with resolve and reject", function()
local callCount = 0
local resolveArg
local rejectArg
local promise = Promise.new(function(resolve, reject)
callCount = callCount + 1
resolveArg = resolve
rejectArg = reject
end)
expect(promise).to.be.ok()
expect(callCount).to.equal(1)
expect(resolveArg).to.be.a("function")
expect(rejectArg).to.be.a("function")
expect(promise._status).to.equal(Promise.Status.Started)
end)
it("should resolve promises on resolve()", function()
local callCount = 0
local promise = Promise.new(function(resolve)
callCount = callCount + 1
resolve()
end)
expect(promise).to.be.ok()
expect(callCount).to.equal(1)
expect(promise._status).to.equal(Promise.Status.Resolved)
end)
it("should reject promises on reject()", function()
local callCount = 0
local promise = Promise.new(function(resolve, reject)
callCount = callCount + 1
reject()
end)
expect(promise).to.be.ok()
expect(callCount).to.equal(1)
expect(promise._status).to.equal(Promise.Status.Rejected)
end)
it("should reject on error in callback", function()
local callCount = 0
local promise = Promise.new(function()
callCount = callCount + 1
error("hahah")
end)
expect(promise).to.be.ok()
expect(callCount).to.equal(1)
expect(promise._status).to.equal(Promise.Status.Rejected)
expect(promise._value[1]:find("hahah")).to.be.ok()
end)
end)
end

View File

@@ -1,264 +1,281 @@
local Reconciler = {}
local Logging = require(script.Parent.Logging)
--[[
The set of file names that should pass as init files
These files usurp their parents.
]]
local initNames = {
["init.lua"] = true,
["init.server.lua"] = true,
["init.client.lua"] = true,
}
local function makeInstanceMap()
local self = {
fromIds = {},
fromInstances = {},
}
local function isInit(item, itemFileName)
if item and item.type == "dir" then
function self:insert(id, instance)
self.fromIds[id] = instance
self.fromInstances[instance] = id
end
function self:removeId(id)
local instance = self.fromIds[id]
if instance ~= nil then
self.fromIds[id] = nil
self.fromInstances[instance] = nil
else
Logging.warn("Attempted to remove nonexistant ID %s", tostring(id))
end
end
function self:removeInstance(instance)
local id = self.fromInstances[instance]
if id ~= nil then
self.fromInstances[instance] = nil
self.fromIds[id] = nil
else
Logging.warn("Attempted to remove nonexistant instance %s", tostring(instance))
end
end
function self:destroyId(id)
local instance = self.fromIds[id]
self:removeId(id)
if instance ~= nil then
local descendantsToDestroy = {}
for otherInstance in pairs(self.fromInstances) do
if otherInstance:IsDescendantOf(instance) then
table.insert(descendantsToDestroy, otherInstance)
end
end
for _, otherInstance in ipairs(descendantsToDestroy) do
self:removeInstance(otherInstance)
end
instance:Destroy()
else
Logging.warn("Attempted to destroy nonexistant ID %s", tostring(id))
end
end
return self
end
local function setProperty(instance, key, value)
-- The 'Contents' property of LocalizationTable isn't directly exposed, but
-- has corresponding (deprecated) getters and setters.
if key == "Contents" and instance.ClassName == "LocalizationTable" then
instance:SetContents(value)
return
end
return initNames[itemFileName] or false
end
--[[
Determines if the given VFS item has an init file. Yields information about
the file.
]]
local function findInit(item)
if item.type ~= "dir" then
return nil, nil
end
for childFileName, childItem in pairs(item.children) do
if isInit(childItem, childFileName) then
return childItem, childFileName
end
end
return nil, nil
end
--[[
Given a VFS item, returns a Name and ClassName for a corresponding Roblox
instance.
Doesn't take into account init files.
]]
local function itemToName(item, fileName)
if item and item.type == "dir" then
return fileName, "Folder"
elseif item and item.type == "file" or not item then
if fileName:find("%.server%.lua$") then
return fileName:match("^(.-)%.server%.lua$"), "Script"
elseif fileName:find("%.client%.lua$") then
return fileName:match("^(.-)%.client%.lua$"), "LocalScript"
elseif fileName:find("%.lua") then
return fileName:match("^(.-)%.lua$"), "ModuleScript"
else
return fileName, "StringValue"
end
else
error("unknown item type " .. tostring(item.type))
end
end
--[[
Given a VFS item, assigns all relevant values (except Name!) to a Roblox
instance.
]]
local function setValues(rbx, item, fileName)
local _, className = itemToName(item, fileName)
if className:find("Script") then
rbx.Source = item.contents
else
rbx.Value = item.contents
end
end
function Reconciler._reifyShallow(item, fileName)
if item.type == "dir" then
local initItem, initFileName = findInit(item)
if initItem then
local rbx = Reconciler._reify(initItem, initFileName)
rbx.Name = fileName
return rbx
else
local rbx = Instance.new("Folder")
rbx.Name = fileName
return rbx
end
elseif item.type == "file" then
local objectName, className = itemToName(item, fileName)
local rbx = Instance.new(className)
rbx.Name = objectName
setValues(rbx, item, fileName)
return rbx
else
error("unknown item type " .. tostring(item.type))
end
end
--[[
Construct a new Roblox instance tree that corresponds to the given VFS item.
]]
function Reconciler._reify(item, fileName, parent)
local rbx = Reconciler._reifyShallow(item, fileName)
if item.type == "dir" then
for childFileName, childItem in pairs(item.children) do
if not isInit(childItem, childFileName) then
local childRbx = Reconciler._reify(childItem, childFileName)
childRbx.Parent = rbx
end
end
end
rbx.Parent = parent
return rbx
end
function Reconciler.reconcile(rbx, item, fileName, parent)
-- Item was deleted!
if not item then
if isInit(item, fileName) then
if not parent then
return
end
-- Un-usurp parent!
local newParent = Instance.new("Folder")
newParent.Name = parent.Name
for _, child in ipairs(parent:GetChildren()) do
child.Parent = newParent
end
newParent.Parent = parent.Parent
parent:Destroy()
-- If we don't have permissions to access this value at all, we can skip it.
local readSuccess, existingValue = pcall(function()
return instance[key]
end)
if not readSuccess then
-- An error will be thrown if there was a permission issue or if the
-- property doesn't exist. In the latter case, we should tell the user
-- because it's probably their fault.
if existingValue:find("lacking permission") then
Logging.trace("Permission error reading property %s on class %s", tostring(key), instance.ClassName)
return
else
if rbx then
rbx:Destroy()
end
return
error(("Invalid property %s on class %s: %s"):format(tostring(key), instance.ClassName, existingValue), 2)
end
end
if item.type == "dir" then
-- Folder was created!
if not rbx then
return Reconciler._reify(item, fileName, parent)
local writeSuccess, err = pcall(function()
if existingValue ~= value then
instance[key] = value
end
end)
local initItem, initFileName = findInit(item)
if not writeSuccess then
error(("Cannot set property %s on class %s: %s"):format(tostring(key), instance.ClassName, err), 2)
end
if initItem then
local _, initClassName = itemToName(initItem, initFileName)
return true
end
if rbx.ClassName == initClassName then
setValues(rbx, initItem, initFileName)
else
rbx:Destroy()
return Reconciler._reify(item, fileName, parent)
end
else
if rbx.ClassName ~= "Folder" then
rbx:Destroy()
return Reconciler._reify(item, fileName, parent)
end
end
local Reconciler = {}
Reconciler.__index = Reconciler
local visitedChildren = {}
function Reconciler.new()
local self = {
instanceMap = makeInstanceMap(),
}
for childFileName, childItem in pairs(item.children) do
if not isInit(childItem, childFileName) then
local childName = itemToName(childItem, childFileName)
return setmetatable(self, Reconciler)
end
visitedChildren[childName] = true
function Reconciler:applyUpdate(requestedIds, virtualInstancesById)
-- This function may eventually be asynchronous; it will require calls to
-- the server to resolve instances that don't exist yet.
local visitedIds = {}
Reconciler.reconcile(rbx:FindFirstChild(childName), childItem, childFileName, rbx)
end
end
for _, id in ipairs(requestedIds) do
self:__applyUpdatePiece(id, visitedIds, virtualInstancesById)
end
end
for _, childRbx in ipairs(rbx:GetChildren()) do
-- Child was deleted!
if not visitedChildren[childRbx.Name] then
childRbx:Destroy()
end
end
--[[
Update an existing instance, including its properties and children, to match
the given information.
]]
function Reconciler:reconcile(virtualInstancesById, id, instance)
local virtualInstance = virtualInstancesById[id]
return rbx
elseif item.type == "file" then
if isInit(item, fileName) then
-- Usurp our container!
local _, className = itemToName(item, fileName)
-- If an instance changes ClassName, we assume it's very different. That's
-- not always the case!
if virtualInstance.ClassName ~= instance.ClassName then
-- TODO: Preserve existing children instead?
local parent = instance.Parent
self.instanceMap:destroyId(id)
return self:__reify(virtualInstancesById, id, parent)
end
if parent.ClassName == className then
rbx = parent
else
rbx = Reconciler._reify(item, fileName, parent.Parent)
rbx.Name = parent.Name
self.instanceMap:insert(id, instance)
for _, child in ipairs(parent:GetChildren()) do
child.Parent = rbx
-- Some instances don't like being named, even if their name already matches
setProperty(instance, "Name", virtualInstance.Name)
for key, value in pairs(virtualInstance.Properties) do
setProperty(instance, key, value.Value)
end
local existingChildren = instance:GetChildren()
local unvisitedExistingChildren = {}
for _, child in ipairs(existingChildren) do
unvisitedExistingChildren[child] = true
end
for _, childId in ipairs(virtualInstance.Children) do
local childData = virtualInstancesById[childId]
local existingChildInstance
for instance in pairs(unvisitedExistingChildren) do
local ok, name, className = pcall(function()
return instance.Name, instance.ClassName
end)
if ok then
if name == childData.Name and className == childData.ClassName then
existingChildInstance = instance
break
end
parent:Destroy()
end
end
setValues(rbx, item, fileName)
return rbx
if existingChildInstance ~= nil then
unvisitedExistingChildren[existingChildInstance] = nil
self:reconcile(virtualInstancesById, childId, existingChildInstance)
else
if not rbx then
return Reconciler._reify(item, fileName, parent)
end
local _, className = itemToName(item, fileName)
if rbx.ClassName ~= className then
rbx:Destroy()
return Reconciler._reify(item, fileName, parent)
end
setValues(rbx, item, fileName)
return rbx
self:__reify(virtualInstancesById, childId, instance)
end
end
if self:__shouldClearUnknownInstances(virtualInstance) then
for existingChildInstance in pairs(unvisitedExistingChildren) do
self.instanceMap:removeInstance(existingChildInstance)
existingChildInstance:Destroy()
end
end
-- The root instance of a project won't have a parent, like the DataModel,
-- so we need to be careful here.
if virtualInstance.Parent ~= nil then
local parent = self.instanceMap.fromIds[virtualInstance.Parent]
if parent == nil then
Logging.info("Instance %s wanted parent of %s", tostring(id), tostring(virtualInstance.Parent))
error("Rojo bug: During reconciliation, an instance referred to an instance ID as parent that does not exist.")
end
-- Some instances, like services, don't like having their Parent
-- property poked, even if we're setting it to the same value.
setProperty(instance, "Parent", parent)
if instance.Parent ~= parent then
instance.Parent = parent
end
end
return instance
end
function Reconciler:__shouldClearUnknownInstances(virtualInstance)
if virtualInstance.Metadata ~= nil then
return not virtualInstance.Metadata.ignoreUnknownInstances
else
error("unknown item type " .. tostring(item.type))
return true
end
end
function Reconciler.reconcileRoute(route, item)
local location = game
function Reconciler:__reify(virtualInstancesById, id, parent)
local virtualInstance = virtualInstancesById[id]
for i = 1, #route - 1 do
local piece = route[i]
local newLocation = location:FindFirstChild(piece)
local instance = Instance.new(virtualInstance.ClassName)
if not newLocation then
newLocation = Instance.new("Folder")
newLocation.Name = piece
newLocation.Parent = location
for key, value in pairs(virtualInstance.Properties) do
-- TODO: Branch on value.Type
setProperty(instance, key, value.Value)
end
instance.Name = virtualInstance.Name
for _, childId in ipairs(virtualInstance.Children) do
self:__reify(virtualInstancesById, childId, instance)
end
setProperty(instance, "Parent", parent)
self.instanceMap:insert(id, instance)
return instance
end
function Reconciler:__applyUpdatePiece(id, visitedIds, virtualInstancesById)
if visitedIds[id] then
return
end
visitedIds[id] = true
local virtualInstance = virtualInstancesById[id]
local instance = self.instanceMap.fromIds[id]
-- The instance was deleted in this update
if virtualInstance == nil then
self.instanceMap:destroyId(id)
return
end
-- An instance we know about was updated
if instance ~= nil then
self:reconcile(virtualInstancesById, id, instance)
return instance
end
-- If the instance's parent already exists, we can stick it there
local parentInstance = self.instanceMap.fromIds[virtualInstance.Parent]
if parentInstance ~= nil then
self:__reify(virtualInstancesById, id, parentInstance)
return
end
-- Otherwise, we can check if this response payload contained the parent and
-- work from there instead.
local parentData = virtualInstancesById[virtualInstance.Parent]
if parentData ~= nil then
if visitedIds[virtualInstance.Parent] then
error("Rojo bug: An instance was present and marked as visited but its instance was missing")
end
location = newLocation
self:__applyUpdatePiece(virtualInstance.Parent, visitedIds, virtualInstancesById)
return
end
local fileName = route[#route]
local name = itemToName(item, fileName)
local rbx = location:FindFirstChild(name)
Reconciler.reconcile(rbx, item, fileName, location)
Logging.trace("Instance ID %s, parent ID %s", tostring(id), tostring(virtualInstance.Parent))
error("Rojo NYI: Instances with parents that weren't mentioned in an update payload")
end
return Reconciler
return Reconciler

View File

@@ -1,69 +0,0 @@
local HttpService = game:GetService("HttpService")
local Server = {}
Server.__index = Server
--[[
Create a new Server using the given HTTP implementation and replacer.
If the context becomes invalid, `replacer` will be invoked with a new
context that should be suitable to replace this one.
Attempting to invoke methods on an invalid conext will throw errors!
]]
function Server.connect(http)
local context = {
http = http,
serverId = nil,
currentTime = 0,
}
setmetatable(context, Server)
return context:_start()
end
function Server:_start()
return self:getInfo()
:andThen(function(response)
self.serverId = response.serverId
self.currentTime = response.currentTime
return self
end)
end
function Server:getInfo()
return self.http:get("/")
:andThen(function(response)
response = response:json()
return response
end)
end
function Server:read(paths)
local body = HttpService:JSONEncode(paths)
return self.http:post("/read", body)
:andThen(function(response)
response = response:json()
return response.items
end)
end
function Server:getChanges()
local url = ("/changes/%f"):format(self.currentTime)
return self.http:get(url)
:andThen(function(response)
response = response:json()
self.currentTime = response.currentTime
return response.changes
end)
end
return Server

97
plugin/src/Session.lua Normal file
View File

@@ -0,0 +1,97 @@
local Rojo = script:FindFirstAncestor("Rojo")
local Promise = require(Rojo.Promise)
local ApiContext = require(script.Parent.ApiContext)
local Reconciler = require(script.Parent.Reconciler)
local Session = {}
Session.__index = Session
function Session.new(config)
local remoteUrl = ("http://%s:%s"):format(config.address, config.port)
local api = ApiContext.new(remoteUrl)
local self = {
onError = config.onError,
disconnected = false,
reconciler = Reconciler.new(),
api = api,
}
api:connect()
:andThen(function()
if self.disconnected then
return
end
return api:read({api.rootInstanceId})
end)
:andThen(function(response)
if self.disconnected then
return
end
self.reconciler:reconcile(response.instances, api.rootInstanceId, game)
return self:__processMessages()
end)
:catch(function(message)
self.disconnected = true
self.onError(message)
end)
return not self.disconnected, setmetatable(self, Session)
end
function Session:__processMessages()
if self.disconnected then
return Promise.resolve()
end
return self.api:retrieveMessages()
:andThen(function(messages)
local promise = Promise.resolve(nil)
for _, message in ipairs(messages) do
promise = promise:andThen(function()
return self:__onMessage(message)
end)
end
return promise
end)
:andThen(function()
return self:__processMessages()
end)
end
function Session:__onMessage(message)
if self.disconnected then
return Promise.resolve()
end
local requestedIds = {}
for _, id in ipairs(message.added) do
table.insert(requestedIds, id)
end
for _, id in ipairs(message.updated) do
table.insert(requestedIds, id)
end
for _, id in ipairs(message.removed) do
table.insert(requestedIds, id)
end
return self.api:read(requestedIds)
:andThen(function(response)
return self.reconciler:applyUpdate(requestedIds, response.instances)
end)
end
function Session:disconnect()
self.disconnected = true
end
return Session

20
plugin/src/Theme.lua Normal file
View File

@@ -0,0 +1,20 @@
local Theme = {
ButtonFont = Enum.Font.GothamSemibold,
InputFont = Enum.Font.Code,
TitleFont = Enum.Font.GothamBold,
MainFont = Enum.Font.Gotham,
AccentColor = Color3.fromRGB(136, 0, 27),
AccentLightColor = Color3.fromRGB(210, 145, 157),
PrimaryColor = Color3.fromRGB(20, 20, 20),
SecondaryColor = Color3.fromRGB(235, 235, 235),
LightTextColor = Color3.fromRGB(140, 140, 140),
}
setmetatable(Theme, {
__index = function(_, key)
error(("%s is not a valid member of Theme"):format(key), 2)
end
})
return Theme

46
plugin/src/Version.lua Normal file
View File

@@ -0,0 +1,46 @@
local function compare(a, b)
if a > b then
return 1
elseif a < b then
return -1
end
return 0
end
local Version = {}
--[[
Compares two versions of the form {major, minor, revision}.
If a is newer than b, 1.
If a is older than b, -1.
If a and b are the same, 0.
]]
function Version.compare(a, b)
local major = compare(a[1], b[1])
local minor = compare(a[2] or 0, b[2] or 0)
local revision = compare(a[3] or 0, b[3] or 0)
if major ~= 0 then
return major
end
if minor ~= 0 then
return minor
end
return revision
end
function Version.display(version)
local output = ("%d.%d.%d"):format(version[1], version[2], version[3])
if version[4] ~= nil then
output = output .. version[4]
end
return output
end
return Version

View File

@@ -0,0 +1,28 @@
return function()
local Version = require(script.Parent.Version)
it("should compare equal versions", function()
expect(Version.compare({1, 2, 3}, {1, 2, 3})).to.equal(0)
expect(Version.compare({0, 4, 0}, {0, 4})).to.equal(0)
expect(Version.compare({0, 0, 123}, {0, 0, 123})).to.equal(0)
expect(Version.compare({26}, {26})).to.equal(0)
expect(Version.compare({26, 42}, {26, 42})).to.equal(0)
expect(Version.compare({1, 0, 0}, {1})).to.equal(0)
end)
it("should compare newer, older versions", function()
expect(Version.compare({1}, {0})).to.equal(1)
expect(Version.compare({1, 1}, {1, 0})).to.equal(1)
end)
it("should compare different major versions", function()
expect(Version.compare({1, 3, 2}, {2, 2, 1})).to.equal(-1)
expect(Version.compare({1, 2}, {2, 1})).to.equal(-1)
expect(Version.compare({1}, {2})).to.equal(-1)
end)
it("should compare different minor versions", function()
expect(Version.compare({1, 2, 3}, {1, 3, 2})).to.equal(-1)
expect(Version.compare({50, 1}, {50, 2})).to.equal(-1)
end)
end

View File

@@ -0,0 +1,19 @@
if not plugin then
return
end
local Roact = require(script.Parent.Roact)
Roact.setGlobalConfig({
elementTracing = true,
})
local App = require(script.Components.App)
local app = Roact.createElement(App, {
plugin = plugin,
})
Roact.mount(app, game:GetService("CoreGui"), "Rojo UI")
-- TODO: Detect another instance of Rojo coming online and shut down this one.

View File

@@ -0,0 +1,34 @@
--[[
joinBindings is a crazy hack that allows combining multiple Roact bindings
in the same spirit as `map`.
It's implemented in terms of Roact internals that will probably break at
some point; please don't do that or use this module in your own code!
]]
local Binding = require(script:FindFirstAncestor("Rojo").Roact.Binding)
local function evaluate(fun, bindings)
local input = {}
for index, binding in ipairs(bindings) do
input[index] = binding:getValue()
end
return fun(unpack(input, 1, #bindings))
end
local function joinBindings(bindings, joinFunction)
local initialValue = evaluate(joinFunction, bindings)
local binding, setValue = Binding.create(initialValue)
for _, binding in ipairs(bindings) do
Binding.subscribe(binding, function()
setValue(evaluate(joinFunction, bindings))
end)
end
return binding
end
return joinBindings

View File

@@ -0,0 +1,2 @@
local TestEZ = require(game.ReplicatedStorage.TestEZ)
TestEZ.TestBootstrap:run(game.ReplicatedStorage.Rojo.plugin)

5
plugin/tests/empty.lua Normal file
View File

@@ -0,0 +1,5 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Session = require(ReplicatedStorage.Modules.Rojo.Session)
Session.new()

6
rojo-e2e/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "rojo-e2e"
version = "0.1.0"
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
[dependencies]

2
rojo-e2e/README.md Normal file
View File

@@ -0,0 +1,2 @@
# Rojo End-to-End
This is a WIP test runner designed for Rojo. It will eventually start up the Rojo server and plugin and test functionality end-to-end.

32
rojo-e2e/src/lib.rs Normal file
View File

@@ -0,0 +1,32 @@
use std::{
path::Path,
process::Command,
thread,
time::Duration,
};
fn main() {
let plugin_path = Path::new("../plugin");
let server_path = Path::new("../server");
let tests_path = Path::new("../tests");
let server = Command::new("cargo")
.args(&["run", "--", "serve", "../test-projects/empty"])
.current_dir(server_path)
.spawn();
thread::sleep(Duration::from_millis(1000));
// TODO: Wait for server to start responding on the right port
let test_client = Command::new("lua")
.args(&["runTest.lua", "tests/empty.lua"])
.current_dir(plugin_path)
.spawn();
thread::sleep(Duration::from_millis(300));
// TODO: Collect output from the client for success/failure?
println!("Dying!");
}

View File

@@ -1,26 +0,0 @@
{
"name": "rojo",
"servePort": 8000,
"partitions": {
"plugin": {
"path": "plugin/src",
"target": "ReplicatedStorage.Rojo"
},
"modules/Roact": {
"path": "modules/Roact/lib",
"target": "ReplicatedStorage.Rojo.modules.Roact"
},
"modules/Rodux": {
"path": "modules/Rodux/lib",
"target": "ReplicatedStorage.Rojo.modules.Rodux"
},
"modules/RoactRodux": {
"path": "modules/RoactRodux/lib",
"target": "ReplicatedStorage.Rojo.modules.RoactRodux"
},
"modules/TestEZ": {
"path": "modules/TestEZ/lib",
"target": "ReplicatedStorage.TestEZ"
}
}
}

45
server/Cargo.toml Normal file
View File

@@ -0,0 +1,45 @@
[package]
name = "rojo"
version = "0.5.0-alpha.1"
authors = ["Lucien Greathouse <me@lpghatguy.com>"]
description = "A tool to create robust Roblox projects"
license = "MIT"
repository = "https://github.com/LPGhatguy/rojo"
edition = "2018"
[lib]
name = "librojo"
path = "src/lib.rs"
[[bin]]
name = "rojo"
path = "src/bin.rs"
[features]
default = []
bundle-plugin = []
[dependencies]
clap = "2.27"
csv = "1.0"
env_logger = "0.5"
failure = "0.1.3"
log = "0.4"
maplit = "1.0.1"
notify = "4.0"
rand = "0.4"
regex = "1.0"
reqwest = "0.9.5"
rouille = "2.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
uuid = { version = "0.7", features = ["v4", "serde"] }
rbx_tree = "0.2.0"
rbx_xml = "0.2.0"
rbx_binary = "0.2.0"
[dev-dependencies]
tempfile = "3.0"
walkdir = "2.1"
lazy_static = "1.2"

4
server/README.md Normal file
View File

@@ -0,0 +1,4 @@
# Rojo Server
This is the source to the Rojo server.
Documentation is WIP.

199
server/src/bin.rs Normal file
View File

@@ -0,0 +1,199 @@
use std::{
env,
panic,
path::{Path, PathBuf},
process,
};
use log::error;
use clap::{clap_app, ArgMatches};
use librojo::commands;
fn make_path_absolute(value: &Path) -> PathBuf {
if value.is_absolute() {
PathBuf::from(value)
} else {
let current_dir = env::current_dir().unwrap();
current_dir.join(value)
}
}
fn main() {
env_logger::Builder::from_default_env()
.default_format_timestamp(false)
.init();
let app = clap_app!(Rojo =>
(version: env!("CARGO_PKG_VERSION"))
(author: env!("CARGO_PKG_AUTHORS"))
(about: env!("CARGO_PKG_DESCRIPTION"))
(@subcommand init =>
(about: "Creates a new Rojo project")
(@arg PATH: "Path to the place to create the project. Defaults to the current directory.")
(@arg kind: --kind +takes_value "The kind of project to create, 'place' or 'model'. Defaults to place.")
)
(@subcommand serve =>
(about: "Serves the project's files for use with the Rojo Studio plugin.")
(@arg PROJECT: "Path to the project to serve. Defaults to the current directory.")
(@arg port: --port +takes_value "The port to listen on. Defaults to 8000.")
)
(@subcommand build =>
(about: "Generates an rbxmx model file from the project.")
(@arg PROJECT: "Path to the project to serve. Defaults to the current directory.")
(@arg output: --output -o +takes_value +required "Where to output the result.")
)
(@subcommand upload =>
(about: "Generates a place or model file out of the project and uploads it to Roblox.")
(@arg PROJECT: "Path to the project to upload. Defaults to the current directory.")
(@arg kind: --kind +takes_value "The kind of asset to generate, 'place', or 'model'. Defaults to place.")
(@arg cookie: --cookie +takes_value +required "Security cookie to authenticate with.")
(@arg asset_id: --asset_id +takes_value +required "Asset ID to upload to.")
)
);
let matches = app.get_matches();
let result = panic::catch_unwind(|| match matches.subcommand() {
("init", Some(sub_matches)) => start_init(sub_matches),
("serve", Some(sub_matches)) => start_serve(sub_matches),
("build", Some(sub_matches)) => start_build(sub_matches),
("upload", Some(sub_matches)) => start_upload(sub_matches),
_ => eprintln!("Usage: rojo <SUBCOMMAND>\nUse 'rojo help' for more help."),
});
if let Err(error) = result {
let message = match error.downcast_ref::<&str>() {
Some(message) => message.to_string(),
None => match error.downcast_ref::<String>() {
Some(message) => message.clone(),
None => "<no message>".to_string(),
},
};
show_crash_message(&message);
process::exit(1);
}
}
fn show_crash_message(message: &str) {
error!("Rojo crashed!");
error!("This is a bug in Rojo.");
error!("");
error!("Please consider filing a bug: https://github.com/LPGhatguy/rojo/issues");
error!("");
error!("Details: {}", message);
}
fn start_init(sub_matches: &ArgMatches) {
let fuzzy_project_path = make_path_absolute(Path::new(sub_matches.value_of("PATH").unwrap_or("")));
let kind = sub_matches.value_of("kind");
let options = commands::InitOptions {
fuzzy_project_path,
kind,
};
match commands::init(&options) {
Ok(_) => {},
Err(e) => {
error!("{}", e);
process::exit(1);
},
}
}
fn start_serve(sub_matches: &ArgMatches) {
let fuzzy_project_path = match sub_matches.value_of("PROJECT") {
Some(v) => make_path_absolute(Path::new(v)),
None => std::env::current_dir().unwrap(),
};
let port = match sub_matches.value_of("port") {
Some(v) => match v.parse::<u16>() {
Ok(port) => Some(port),
Err(_) => {
error!("Invalid port {}", v);
process::exit(1);
},
},
None => None,
};
let options = commands::ServeOptions {
fuzzy_project_path,
port,
};
match commands::serve(&options) {
Ok(_) => {},
Err(e) => {
error!("{}", e);
process::exit(1);
},
}
}
fn start_build(sub_matches: &ArgMatches) {
let fuzzy_project_path = match sub_matches.value_of("PROJECT") {
Some(v) => make_path_absolute(Path::new(v)),
None => std::env::current_dir().unwrap(),
};
let output_file = make_path_absolute(Path::new(sub_matches.value_of("output").unwrap()));
let options = commands::BuildOptions {
fuzzy_project_path,
output_file,
output_kind: None, // TODO: Accept from argument
};
match commands::build(&options) {
Ok(_) => {},
Err(e) => {
error!("{}", e);
process::exit(1);
},
}
}
fn start_upload(sub_matches: &ArgMatches) {
let fuzzy_project_path = match sub_matches.value_of("PROJECT") {
Some(v) => make_path_absolute(Path::new(v)),
None => std::env::current_dir().unwrap(),
};
let kind = sub_matches.value_of("kind");
let security_cookie = sub_matches.value_of("cookie").unwrap();
let asset_id: u64 = {
let arg = sub_matches.value_of("asset_id").unwrap();
match arg.parse() {
Ok(v) => v,
Err(_) => {
error!("Invalid place ID {}", arg);
process::exit(1);
},
}
};
let options = commands::UploadOptions {
fuzzy_project_path,
security_cookie: security_cookie.to_string(),
asset_id,
kind,
};
match commands::upload(&options) {
Ok(_) => {},
Err(e) => {
error!("{}", e);
process::exit(1);
},
}
}

View File

@@ -0,0 +1,115 @@
use std::{
path::PathBuf,
fs::File,
io,
};
use log::info;
use failure::Fail;
use crate::{
rbx_session::construct_oneoff_tree,
project::{Project, ProjectLoadFuzzyError},
imfs::Imfs,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OutputKind {
Rbxmx,
Rbxlx,
Rbxm,
Rbxl,
}
fn detect_output_kind(options: &BuildOptions) -> Option<OutputKind> {
let extension = options.output_file.extension()?.to_str()?;
match extension {
"rbxlx" => Some(OutputKind::Rbxlx),
"rbxmx" => Some(OutputKind::Rbxmx),
"rbxl" => Some(OutputKind::Rbxl),
"rbxm" => Some(OutputKind::Rbxm),
_ => None,
}
}
#[derive(Debug)]
pub struct BuildOptions {
pub fuzzy_project_path: PathBuf,
pub output_file: PathBuf,
pub output_kind: Option<OutputKind>,
}
#[derive(Debug, Fail)]
pub enum BuildError {
#[fail(display = "Could not detect what kind of file to create")]
UnknownOutputKind,
#[fail(display = "Project load error: {}", _0)]
ProjectLoadError(#[fail(cause)] ProjectLoadFuzzyError),
#[fail(display = "IO error: {}", _0)]
IoError(#[fail(cause)] io::Error),
#[fail(display = "XML model file error")]
XmlModelEncodeError(rbx_xml::EncodeError),
#[fail(display = "Binary model file error")]
BinaryModelEncodeError(rbx_binary::EncodeError)
}
impl_from!(BuildError {
ProjectLoadFuzzyError => ProjectLoadError,
io::Error => IoError,
rbx_xml::EncodeError => XmlModelEncodeError,
rbx_binary::EncodeError => BinaryModelEncodeError
});
pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
let output_kind = options.output_kind
.or_else(|| detect_output_kind(options))
.ok_or(BuildError::UnknownOutputKind)?;
info!("Hoping to generate file of type {:?}", output_kind);
info!("Looking for project at {}", options.fuzzy_project_path.display());
let project = Project::load_fuzzy(&options.fuzzy_project_path)?;
info!("Found project at {}", project.file_location.display());
info!("Using project {:#?}", project);
let mut imfs = Imfs::new();
imfs.add_roots_from_project(&project)?;
let tree = construct_oneoff_tree(&project, &imfs);
let mut file = File::create(&options.output_file)?;
match output_kind {
OutputKind::Rbxmx => {
// Model files include the root instance of the tree and all its
// descendants.
let root_id = tree.get_root_id();
rbx_xml::encode(&tree, &[root_id], &mut file)?;
},
OutputKind::Rbxlx => {
// Place files don't contain an entry for the DataModel, but our
// RbxTree representation does.
let root_id = tree.get_root_id();
let top_level_ids = tree.get_instance(root_id).unwrap().get_children_ids();
rbx_xml::encode(&tree, top_level_ids, &mut file)?;
},
OutputKind::Rbxm => {
let root_id = tree.get_root_id();
rbx_binary::encode(&tree, &[root_id], &mut file)?;
},
OutputKind::Rbxl => {
let root_id = tree.get_root_id();
let top_level_ids = tree.get_instance(root_id).unwrap().get_children_ids();
rbx_binary::encode(&tree, top_level_ids, &mut file)?;
},
}
Ok(())
}

View File

@@ -0,0 +1,44 @@
use std::{
path::PathBuf,
};
use failure::Fail;
use crate::project::{Project, ProjectInitError};
#[derive(Debug, Fail)]
pub enum InitError {
#[fail(display = "Invalid project kind '{}', valid kinds are 'place' and 'model'", _0)]
InvalidKind(String),
#[fail(display = "Project init error: {}", _0)]
ProjectInitError(#[fail(cause)] ProjectInitError)
}
impl_from!(InitError {
ProjectInitError => ProjectInitError,
});
#[derive(Debug)]
pub struct InitOptions<'a> {
pub fuzzy_project_path: PathBuf,
pub kind: Option<&'a str>,
}
pub fn init(options: &InitOptions) -> Result<(), InitError> {
let (project_path, project_kind) = match options.kind {
Some("place") | None => {
let path = Project::init_place(&options.fuzzy_project_path)?;
(path, "place")
},
Some("model") => {
let path = Project::init_model(&options.fuzzy_project_path)?;
(path, "model")
},
Some(invalid) => return Err(InitError::InvalidKind(invalid.to_string())),
};
println!("Created new {} project file at {}", project_kind, project_path.display());
Ok(())
}

View File

@@ -0,0 +1,9 @@
mod serve;
mod init;
mod build;
mod upload;
pub use self::serve::*;
pub use self::init::*;
pub use self::build::*;
pub use self::upload::*;

View File

@@ -0,0 +1,53 @@
use std::{
path::PathBuf,
sync::Arc,
};
use log::info;
use failure::Fail;
use crate::{
project::{Project, ProjectLoadFuzzyError},
web::Server,
live_session::LiveSession,
};
const DEFAULT_PORT: u16 = 34872;
#[derive(Debug)]
pub struct ServeOptions {
pub fuzzy_project_path: PathBuf,
pub port: Option<u16>,
}
#[derive(Debug, Fail)]
pub enum ServeError {
#[fail(display = "Project load error: {}", _0)]
ProjectLoadError(#[fail(cause)] ProjectLoadFuzzyError),
}
impl_from!(ServeError {
ProjectLoadFuzzyError => ProjectLoadError,
});
pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
info!("Looking for project at {}", options.fuzzy_project_path.display());
let project = Arc::new(Project::load_fuzzy(&options.fuzzy_project_path)?);
info!("Found project at {}", project.file_location.display());
info!("Using project {:#?}", project);
let live_session = Arc::new(LiveSession::new(Arc::clone(&project)).unwrap());
let server = Server::new(Arc::clone(&live_session));
let port = options.port
.or(project.serve_port)
.unwrap_or(DEFAULT_PORT);
println!("Rojo server listening on port {}", port);
server.listen(port);
Ok(())
}

View File

@@ -0,0 +1,98 @@
use std::{
path::PathBuf,
io,
};
use log::info;
use failure::Fail;
use reqwest::header::{ACCEPT, USER_AGENT, CONTENT_TYPE, COOKIE};
use crate::{
rbx_session::construct_oneoff_tree,
project::{Project, ProjectLoadFuzzyError},
imfs::Imfs,
};
#[derive(Debug, Fail)]
pub enum UploadError {
#[fail(display = "Roblox API Error: {}", _0)]
RobloxApiError(String),
#[fail(display = "Invalid asset kind: {}", _0)]
InvalidKind(String),
#[fail(display = "Project load error: {}", _0)]
ProjectLoadError(#[fail(cause)] ProjectLoadFuzzyError),
#[fail(display = "IO error: {}", _0)]
IoError(#[fail(cause)] io::Error),
#[fail(display = "HTTP error: {}", _0)]
HttpError(#[fail(cause)] reqwest::Error),
#[fail(display = "XML model file error")]
XmlModelEncodeError(rbx_xml::EncodeError),
}
impl_from!(UploadError {
ProjectLoadFuzzyError => ProjectLoadError,
io::Error => IoError,
reqwest::Error => HttpError,
rbx_xml::EncodeError => XmlModelEncodeError,
});
#[derive(Debug)]
pub struct UploadOptions<'a> {
pub fuzzy_project_path: PathBuf,
pub security_cookie: String,
pub asset_id: u64,
pub kind: Option<&'a str>,
}
pub fn upload(options: &UploadOptions) -> Result<(), UploadError> {
// TODO: Switch to uploading binary format?
info!("Looking for project at {}", options.fuzzy_project_path.display());
let project = Project::load_fuzzy(&options.fuzzy_project_path)?;
info!("Found project at {}", project.file_location.display());
info!("Using project {:#?}", project);
let mut imfs = Imfs::new();
imfs.add_roots_from_project(&project)?;
let tree = construct_oneoff_tree(&project, &imfs);
let root_id = tree.get_root_id();
let mut contents = Vec::new();
match options.kind {
Some("place") | None => {
let top_level_ids = tree.get_instance(root_id).unwrap().get_children_ids();
rbx_xml::encode(&tree, top_level_ids, &mut contents)?;
},
Some("model") => {
rbx_xml::encode(&tree, &[root_id], &mut contents)?;
},
Some(invalid) => return Err(UploadError::InvalidKind(invalid.to_owned())),
}
let url = format!("https://data.roblox.com/Data/Upload.ashx?assetid={}", options.asset_id);
let client = reqwest::Client::new();
let mut response = client.post(&url)
.header(COOKIE, format!(".ROBLOSECURITY={}", &options.security_cookie))
.header(USER_AGENT, "Roblox/WinInet")
.header("Requester", "Client")
.header(CONTENT_TYPE, "application/xml")
.header(ACCEPT, "application/json")
.body(contents)
.send()?;
if !response.status().is_success() {
return Err(UploadError::RobloxApiError(response.text()?));
}
Ok(())
}

116
server/src/fs_watcher.rs Normal file
View File

@@ -0,0 +1,116 @@
use std::{
sync::{mpsc, Arc, Mutex},
time::Duration,
thread,
};
use log::info;
use notify::{
self,
DebouncedEvent,
RecommendedWatcher,
RecursiveMode,
Watcher,
};
use crate::{
imfs::Imfs,
rbx_session::RbxSession,
};
const WATCH_TIMEOUT: Duration = Duration::from_millis(100);
fn handle_event(imfs: &Mutex<Imfs>, rbx_session: &Mutex<RbxSession>, event: DebouncedEvent) {
match event {
DebouncedEvent::Create(path) => {
{
let mut imfs = imfs.lock().unwrap();
imfs.path_created(&path).unwrap();
}
{
let mut rbx_session = rbx_session.lock().unwrap();
rbx_session.path_created(&path);
}
},
DebouncedEvent::Write(path) => {
{
let mut imfs = imfs.lock().unwrap();
imfs.path_updated(&path).unwrap();
}
{
let mut rbx_session = rbx_session.lock().unwrap();
rbx_session.path_updated(&path);
}
},
DebouncedEvent::Remove(path) => {
{
let mut imfs = imfs.lock().unwrap();
imfs.path_removed(&path).unwrap();
}
{
let mut rbx_session = rbx_session.lock().unwrap();
rbx_session.path_removed(&path);
}
},
DebouncedEvent::Rename(from_path, to_path) => {
{
let mut imfs = imfs.lock().unwrap();
imfs.path_moved(&from_path, &to_path).unwrap();
}
{
let mut rbx_session = rbx_session.lock().unwrap();
rbx_session.path_renamed(&from_path, &to_path);
}
},
_ => {},
}
}
/// Watches for changes on the filesystem and links together the in-memory
/// filesystem and in-memory Roblox tree.
pub struct FsWatcher {
#[allow(unused)]
watchers: Vec<RecommendedWatcher>,
}
impl FsWatcher {
pub fn start(imfs: Arc<Mutex<Imfs>>, rbx_session: Arc<Mutex<RbxSession>>) -> FsWatcher {
let mut watchers = Vec::new();
{
let imfs_temp = imfs.lock().unwrap();
for root_path in imfs_temp.get_roots() {
let (watch_tx, watch_rx) = mpsc::channel();
let mut watcher = notify::watcher(watch_tx, WATCH_TIMEOUT)
.expect("Could not create `notify` watcher");
watcher.watch(root_path, RecursiveMode::Recursive)
.expect("Could not watch directory");
watchers.push(watcher);
let imfs = Arc::clone(&imfs);
let rbx_session = Arc::clone(&rbx_session);
let root_path = root_path.clone();
thread::spawn(move || {
info!("Watcher thread ({}) started", root_path.display());
while let Ok(event) = watch_rx.recv() {
handle_event(&imfs, &rbx_session, event);
}
info!("Watcher thread ({}) stopped", root_path.display());
});
}
}
FsWatcher {
watchers,
}
}
}

225
server/src/imfs.rs Normal file
View File

@@ -0,0 +1,225 @@
use std::{
collections::{HashMap, HashSet},
path::{Path, PathBuf},
fs,
io,
};
use serde_derive::{Serialize, Deserialize};
use crate::project::{Project, ProjectNode};
fn add_sync_points(imfs: &mut Imfs, project_node: &ProjectNode) -> io::Result<()> {
match project_node {
ProjectNode::Instance(node) => {
for child in node.children.values() {
add_sync_points(imfs, child)?;
}
},
ProjectNode::SyncPoint(node) => {
imfs.add_root(&node.path)?;
},
}
Ok(())
}
/// The in-memory filesystem keeps a mirror of all files being watcher by Rojo
/// in order to deduplicate file changes in the case of bidirectional syncing
/// from Roblox Studio.
#[derive(Debug, Clone)]
pub struct Imfs {
items: HashMap<PathBuf, ImfsItem>,
roots: HashSet<PathBuf>,
}
impl Imfs {
pub fn new() -> Imfs {
Imfs {
items: HashMap::new(),
roots: HashSet::new(),
}
}
pub fn add_roots_from_project(&mut self, project: &Project) -> io::Result<()> {
add_sync_points(self, &project.tree)
}
pub fn get_roots(&self) -> &HashSet<PathBuf> {
&self.roots
}
pub fn get_items(&self) -> &HashMap<PathBuf, ImfsItem> {
&self.items
}
pub fn get(&self, path: &Path) -> Option<&ImfsItem> {
debug_assert!(path.is_absolute());
debug_assert!(self.is_within_roots(path));
self.items.get(path)
}
pub fn add_root(&mut self, path: &Path) -> io::Result<()> {
debug_assert!(path.is_absolute());
debug_assert!(!self.is_within_roots(path));
self.roots.insert(path.to_path_buf());
self.read_from_disk(path)
}
pub fn path_created(&mut self, path: &Path) -> io::Result<()> {
debug_assert!(path.is_absolute());
debug_assert!(self.is_within_roots(path));
self.read_from_disk(path)
}
pub fn path_updated(&mut self, path: &Path) -> io::Result<()> {
debug_assert!(path.is_absolute());
debug_assert!(self.is_within_roots(path));
self.read_from_disk(path)
}
pub fn path_removed(&mut self, path: &Path) -> io::Result<()> {
debug_assert!(path.is_absolute());
debug_assert!(self.is_within_roots(path));
self.remove_item(path);
if let Some(parent_path) = path.parent() {
self.unlink_child(parent_path, path);
}
Ok(())
}
pub fn path_moved(&mut self, from_path: &Path, to_path: &Path) -> io::Result<()> {
debug_assert!(from_path.is_absolute());
debug_assert!(self.is_within_roots(from_path));
debug_assert!(to_path.is_absolute());
debug_assert!(self.is_within_roots(to_path));
self.path_removed(from_path)?;
self.path_created(to_path)?;
Ok(())
}
pub fn get_root_for_path<'a>(&'a self, path: &Path) -> Option<&'a Path> {
for root_path in &self.roots {
if path.starts_with(root_path) {
return Some(root_path);
}
}
None
}
fn remove_item(&mut self, path: &Path) {
if let Some(ImfsItem::Directory(directory)) = self.items.remove(path) {
for child_path in &directory.children {
self.remove_item(child_path);
}
}
}
fn unlink_child(&mut self, parent: &Path, child: &Path) {
let parent_item = self.items.get_mut(parent);
match parent_item {
Some(ImfsItem::Directory(directory)) => {
directory.children.remove(child);
},
_ => {
panic!("Tried to unlink child of path that wasn't a directory!");
},
}
}
fn link_child(&mut self, parent: &Path, child: &Path) {
if self.is_within_roots(parent) {
let parent_item = self.items.get_mut(parent);
match parent_item {
Some(ImfsItem::Directory(directory)) => {
directory.children.insert(child.to_path_buf());
},
_ => {
panic!("Tried to link child of path that wasn't a directory!");
},
}
}
}
fn read_from_disk(&mut self, path: &Path) -> io::Result<()> {
let metadata = fs::metadata(path)?;
if metadata.is_file() {
let contents = fs::read(path)?;
let item = ImfsItem::File(ImfsFile {
path: path.to_path_buf(),
contents,
});
self.items.insert(path.to_path_buf(), item);
if let Some(parent_path) = path.parent() {
self.link_child(parent_path, path);
}
Ok(())
} else if metadata.is_dir() {
let item = ImfsItem::Directory(ImfsDirectory {
path: path.to_path_buf(),
children: HashSet::new(),
});
self.items.insert(path.to_path_buf(), item);
for entry in fs::read_dir(path)? {
let entry = entry?;
let child_path = entry.path();
self.read_from_disk(&child_path)?;
}
if let Some(parent_path) = path.parent() {
self.link_child(parent_path, path);
}
Ok(())
} else {
panic!("Unexpected non-file, non-directory item");
}
}
fn is_within_roots(&self, path: &Path) -> bool {
for root_path in &self.roots {
if path.starts_with(root_path) {
return true;
}
}
false
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ImfsFile {
pub path: PathBuf,
pub contents: Vec<u8>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ImfsDirectory {
pub path: PathBuf,
pub children: HashSet<PathBuf>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ImfsItem {
File(ImfsFile),
Directory(ImfsDirectory),
}

18
server/src/impl_from.rs Normal file
View File

@@ -0,0 +1,18 @@
/// Implements 'From' for a list of variants, intended for use with error enums
/// that are wrapping a number of errors from other methods.
#[macro_export]
macro_rules! impl_from {
(
$enum_name: ident {
$($error_type: ty => $variant_name: ident),* $(,)*
}
) => {
$(
impl From<$error_type> for $enum_name {
fn from(error: $error_type) -> $enum_name {
$enum_name::$variant_name(error)
}
}
)*
}
}

19
server/src/lib.rs Normal file
View File

@@ -0,0 +1,19 @@
// Macros
#[macro_use]
pub mod impl_from;
// Other modules
pub mod commands;
pub mod fs_watcher;
pub mod imfs;
pub mod message_queue;
pub mod path_map;
pub mod project;
pub mod rbx_session;
pub mod rbx_snapshot;
pub mod live_session;
pub mod session_id;
pub mod snapshot_reconciler;
pub mod visualize;
pub mod web;
pub mod web_util;

View File

@@ -0,0 +1,62 @@
use std::{
sync::{Arc, Mutex},
io,
};
use crate::{
message_queue::MessageQueue,
project::Project,
imfs::Imfs,
session_id::SessionId,
rbx_session::RbxSession,
snapshot_reconciler::InstanceChanges,
fs_watcher::FsWatcher,
};
/// Contains all of the state for a Rojo live-sync session.
pub struct LiveSession {
pub project: Arc<Project>,
pub session_id: SessionId,
pub message_queue: Arc<MessageQueue<InstanceChanges>>,
pub rbx_session: Arc<Mutex<RbxSession>>,
pub imfs: Arc<Mutex<Imfs>>,
_fs_watcher: FsWatcher,
}
impl LiveSession {
pub fn new(project: Arc<Project>) -> io::Result<LiveSession> {
let imfs = {
let mut imfs = Imfs::new();
imfs.add_roots_from_project(&project)?;
Arc::new(Mutex::new(imfs))
};
let message_queue = Arc::new(MessageQueue::new());
let rbx_session = Arc::new(Mutex::new(RbxSession::new(
Arc::clone(&project),
Arc::clone(&imfs),
Arc::clone(&message_queue),
)));
let fs_watcher = FsWatcher::start(
Arc::clone(&imfs),
Arc::clone(&rbx_session),
);
let session_id = SessionId::new();
Ok(LiveSession {
project,
session_id,
message_queue,
rbx_session,
imfs,
_fs_watcher: fs_watcher,
})
}
pub fn get_project(&self) -> &Project {
&self.project
}
}

Some files were not shown because too many files have changed in this diff Show More