Add RunContext support for script outputs (#765)

Resolves #667

This PR:

- Introduces a new field in the project file: `scriptType` which has the
default value of `Class` (in parity with previous versions), but can
also be `RunContext`.
- This is then passed to `InstanceContext` from the `Project` struct.
- This then changes the RunContext in the lua `snapshot_middleware`

---------

Co-authored-by: Micah <dekkonot@rocketmail.com>
This commit is contained in:
Sasial
2023-09-24 06:28:09 +10:00
committed by GitHub
parent 539cd0d418
commit bb8dd1402d
56 changed files with 602 additions and 95 deletions

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.csv
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: LocalizationTable
properties:

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.csv
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: LocalizationTable
properties:

View File

@@ -17,7 +17,8 @@ metadata:
- /foo/init.client.lua
- /foo/init.client.luau
- /foo/init.csv
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: Folder
properties: {}

View File

@@ -17,7 +17,8 @@ metadata:
- /foo/init.client.lua
- /foo/init.client.luau
- /foo/init.csv
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: Folder
properties: {}
@@ -37,7 +38,8 @@ children:
- /foo/Child/init.client.lua
- /foo/Child/init.client.luau
- /foo/Child/init.csv
context: {}
context:
emit_legacy_scripts: true
name: Child
class_name: Folder
properties: {}

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.json
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: ModuleScript
properties:

View File

@@ -9,7 +9,8 @@ metadata:
Path: /foo.model.json
relevant_paths:
- /foo.model.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: IntValue
properties:
@@ -20,7 +21,8 @@ children:
metadata:
ignore_unknown_instances: false
relevant_paths: []
context: {}
context:
emit_legacy_scripts: true
name: The Child
class_name: StringValue
properties: {}

View File

@@ -9,7 +9,8 @@ metadata:
Path: /foo.model.json
relevant_paths:
- /foo.model.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: IntValue
properties:
@@ -20,7 +21,8 @@ children:
metadata:
ignore_unknown_instances: false
relevant_paths: []
context: {}
context:
emit_legacy_scripts: true
name: The Child
class_name: StringValue
properties: {}

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.client.lua
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: LocalScript
properties:

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.lua
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: ModuleScript
properties:

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.lua
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: ModuleScript
properties:

View File

@@ -10,12 +10,15 @@ metadata:
relevant_paths:
- /bar.server.lua
- /bar.meta.json
context: {}
context:
emit_legacy_scripts: true
name: bar
class_name: Script
properties:
Disabled:
Bool: true
RunContext:
Enum: 0
Source:
String: Hello there!
children: []

View File

@@ -10,10 +10,13 @@ metadata:
relevant_paths:
- /foo.server.lua
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: Script
properties:
RunContext:
Enum: 0
Source:
String: Hello there!
children: []

View File

@@ -10,10 +10,13 @@ metadata:
relevant_paths:
- /foo.server.lua
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: Script
properties:
RunContext:
Enum: 0
Source:
String: Hello there!
children: []

View File

@@ -13,7 +13,8 @@ metadata:
- /root/init.lua
- /root/init.server.lua
- /root/init.client.lua
context: {}
context:
script_type: Class
name: root
class_name: ModuleScript
properties:

View File

@@ -0,0 +1,23 @@
---
source: src/snapshot_middleware/lua.rs
expression: instance_snapshot
---
snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /foo.client.lua
relevant_paths:
- /foo.client.lua
- /foo.meta.json
context:
emit_legacy_scripts: false
name: foo
class_name: Script
properties:
RunContext:
Enum: 2
Source:
String: Hello there!
children: []

View File

@@ -0,0 +1,21 @@
---
source: src/snapshot_middleware/lua.rs
expression: instance_snapshot
---
snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /foo.lua
relevant_paths:
- /foo.lua
- /foo.meta.json
context:
emit_legacy_scripts: false
name: foo
class_name: ModuleScript
properties:
Source:
String: Hello there!
children: []

View File

@@ -0,0 +1,21 @@
---
source: src/snapshot_middleware/lua.rs
expression: instance_snapshot
---
snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: true
instigating_source:
Path: /foo.lua
relevant_paths:
- /foo.lua
- /foo.meta.json
context:
emit_legacy_scripts: false
name: foo
class_name: ModuleScript
properties:
Source:
String: Hello there!
children: []

View File

@@ -0,0 +1,25 @@
---
source: src/snapshot_middleware/lua.rs
expression: instance_snapshot
---
snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /bar.server.lua
relevant_paths:
- /bar.server.lua
- /bar.meta.json
context:
emit_legacy_scripts: false
name: bar
class_name: Script
properties:
Disabled:
Bool: true
RunContext:
Enum: 1
Source:
String: Hello there!
children: []

View File

@@ -0,0 +1,23 @@
---
source: src/snapshot_middleware/lua.rs
expression: instance_snapshot
---
snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: true
instigating_source:
Path: /foo.server.lua
relevant_paths:
- /foo.server.lua
- /foo.meta.json
context:
emit_legacy_scripts: false
name: foo
class_name: Script
properties:
RunContext:
Enum: 1
Source:
String: Hello there!
children: []

View File

@@ -0,0 +1,23 @@
---
source: src/snapshot_middleware/lua.rs
expression: instance_snapshot
---
snapshot_id: "00000000000000000000000000000000"
metadata:
ignore_unknown_instances: false
instigating_source:
Path: /foo.server.lua
relevant_paths:
- /foo.server.lua
- /foo.meta.json
context:
emit_legacy_scripts: false
name: foo
class_name: Script
properties:
RunContext:
Enum: 1
Source:
String: Hello there!
children: []

View File

@@ -9,7 +9,8 @@ metadata:
Path: /foo/hello.project.json
relevant_paths:
- /foo/hello.project.json
context: {}
context:
emit_legacy_scripts: true
name: direct-project
class_name: Model
properties: {}

View File

@@ -9,7 +9,8 @@ metadata:
Path: /foo/default.project.json
relevant_paths:
- /foo/default.project.json
context: {}
context:
script_type: Class
name: indirect-project
class_name: Folder
properties: {}

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo/other.project.json
- /foo/default.project.json
context: {}
context:
emit_legacy_scripts: true
name: path-property-override
class_name: StringValue
properties:

View File

@@ -9,7 +9,8 @@ metadata:
Path: /foo.project.json
relevant_paths:
- /foo.project.json
context: {}
context:
emit_legacy_scripts: true
name: children
class_name: Folder
properties: {}
@@ -24,7 +25,8 @@ children:
- $className: Model
- Folder
relevant_paths: []
context: {}
context:
emit_legacy_scripts: true
name: Child
class_name: Model
properties: {}

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo/other.project.json
- /foo/default.project.json
context: {}
context:
emit_legacy_scripts: true
name: path-project
class_name: Model
properties: {}

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo/other.project.json
- /foo/default.project.json
context: {}
context:
emit_legacy_scripts: true
name: path-child-project
class_name: Folder
properties: {}
@@ -25,7 +26,8 @@ children:
- $className: Model
- Folder
relevant_paths: []
context: {}
context:
emit_legacy_scripts: true
name: SomeChild
class_name: Model
properties: {}

View File

@@ -11,7 +11,8 @@ metadata:
- /foo/other.txt
- /foo/other.meta.json
- /foo/default.project.json
context: {}
context:
emit_legacy_scripts: true
name: path-project
class_name: StringValue
properties:

View File

@@ -9,7 +9,8 @@ metadata:
Path: /foo.project.json
relevant_paths:
- /foo.project.json
context: {}
context:
emit_legacy_scripts: true
name: resolved-properties
class_name: StringValue
properties:

View File

@@ -9,7 +9,8 @@ metadata:
Path: /foo.project.json
relevant_paths:
- /foo.project.json
context: {}
context:
emit_legacy_scripts: true
name: unresolved-properties
class_name: StringValue
properties:

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.toml
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: ModuleScript
properties:

View File

@@ -10,7 +10,8 @@ metadata:
relevant_paths:
- /foo.txt
- /foo.meta.json
context: {}
context:
emit_legacy_scripts: true
name: foo
class_name: StringValue
properties: