Skip to content

Commit d1dbd50

Browse files
authored
Add support for uploading and syncing plugins (#4)
Co-authored-by: Marin Minnerly <[email protected]>
1 parent 277ab6c commit d1dbd50

File tree

12 files changed

+94
-19
lines changed

12 files changed

+94
-19
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "plugin",
3+
"emitLegacyScripts": false,
4+
"tree": {
5+
"$path": "src"
6+
}
7+
}

examples/plugin/deploy.luau

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
local rbxasset = require("@root/")
2+
3+
local process = require("@lune/process")
4+
5+
local apiKey = process.args[1]
6+
assert(apiKey, "argument #1 must be a valid Open Cloud API key")
7+
8+
assert(process.cwd:match("examples/plugin"), "you must be in the `examples/plugin` folder when running this script")
9+
10+
process.exec("rojo", { "build", "-o", "plugin.rbxm" })
11+
12+
rbxasset.publishPackageAsync(process.cwd, "plugin.rbxm", apiKey)

examples/plugin/icon.png

68.9 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
assetId = "104757825775127"
2+
3+
[images."icon.png"]
4+
assetId = "124561703176693"
5+
hash = "fac185770cf5e824d4c0a9b59e547df42dc10011c5ad139bfc2c7e1507eef631"

examples/plugin/rbxasset.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[asset]
2+
name = "Example Plugin"
3+
description = "Longform description"
4+
icon = "icon.png"
5+
type = "Plugin"
6+
distribute = true
7+
8+
[deployment]
9+
creatorId = 35175308
10+
creatorType = "Group"
11+
universeId = 7854970752
12+
placeId = 119490202754966
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("This is a plugin!")

foreman.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tools]
22
lune = { source = "lune-org/lune", version = "=0.9.3" }
3-
rojo = { source = "rojo-rbx/rojo", version = "=7.3.0" }
3+
rojo = { source = "rojo-rbx/rojo", version = "=7.5.0" }
44
selene = { source = "kampfkarren/selene", version = "=0.28.0" }
55
stylua = { source = "johnnymorganz/stylua", version = "=2.1.0" }

src/requests/publishAssetAsync.luau

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ local function publishAssetAsync(
2525
local variables = runLuauTask(publishAssetTask, {
2626
CREATOR_ID = assetConfig.deployment.creatorId,
2727
CREATOR_TYPE = assetConfig.deployment.creatorType,
28+
ASSET_TYPE = assetConfig.asset.type or "Package",
2829

2930
-- Only provide the assetId from the manifest if there's a matching
3031
-- asset on the Creator Store. We need this check in case the manifest

src/requests/setAssetDetailsAsync.luau

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ local serde = require("@lune/serde")
22

33
local createFormData = require("@root/requests/forms/createFormData")
44
local fetch = require("@root/requests/fetch")
5+
local types = require("@root/types")
56
local waitForAssetOperationAsync = require("@root/requests/waitForAssetOperationAsync")
67

8+
type OperationResponse = types.OperationResponse
9+
710
type AssetDetails = {
811
displayName: string,
912
description: string?,
@@ -30,9 +33,13 @@ local function setAssetDetailsAsync(assetId: string, apiKey: string, details: As
3033
body = formData.body,
3134
})
3235

33-
local body = serde.decode("json", res.body)
36+
local body: OperationResponse = serde.decode("json", res.body)
3437

35-
waitForAssetOperationAsync(body.operationId, apiKey)
38+
if body.message then
39+
error(body.message)
40+
else
41+
waitForAssetOperationAsync(body.operationId, apiKey)
42+
end
3643
end
3744

3845
return setAssetDetailsAsync

src/requests/waitForAssetOperationAsync.luau

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@ local serde = require("@lune/serde")
22
local task = require("@lune/task")
33

44
local fetch = require("@root/requests/fetch")
5+
local types = require("@root/types")
56

67
local MAX_RETRIES = 5
78
local RETRY_MULTIPLIER = 2
89

9-
type OperationResponse = {
10-
done: boolean,
11-
operationId: string,
12-
path: string,
13-
response: { [string]: any },
14-
} | {
15-
code: string,
16-
message: string,
17-
}
10+
type OperationResponse = types.OperationResponse
1811

1912
local function waitForAssetOperationAsync(operationId: string, apiKey: string): OperationResponse
2013
local currentRetries = 0

0 commit comments

Comments
 (0)