Change how resource type works, allow proper app and library installation (#956)

* Change how app store types work, allow proper app and library installation

* Add node for resources in dependencies and docs

* Fix NPE without `type`

* Fix docs trying to change location of app type resource

* Separate libraries and apps and add trash for them

* Update docs

* Create trash directory if it doesn't exist
This commit is contained in:
altrisi authored and GitHub committed 2021-06-30 12:42:24 -03:00
1 parent d92b412c0a
commit 97e69d347e
5 files changed
+153 -65

No files matched your search

+29 -13
View File
@@ -110,30 +110,46 @@ in a list and contain of map-like resources descriptors, looking like
'resources' -> [
{
'source' -> 'https://raw.githubusercontent.com/gnembon/fabric-carpet/master/src/main/resources/assets/carpet/icon.png',
'type' -> 'url',
'target' -> 'foo/photos.zip/foo/cm.png',
},
{
'source' -> 'survival/README.md',
'type' -> 'store',
'source' -> '/survival/README.md',
'target' -> 'survival_readme.md',
'shared' -> true,
},
{
'source' -> 'carpets.sc',
'type' -> 'app',
'target' -> 'apps/flying_carpets.sc',
'shared' -> true,
'source' -> 'circle.sc', // Relative path
'target' -> 'apps/circle.sc', // This won't install the app, use 'libraries' for that
},
]
```
`source` and `type` indicate resource location: either an arbitrary url (type `'url'`),
absolute location of a file in the app store (type `'store'`),
or a relative location in the same folder as the app in question (type `'app'`).
`'target'` points to the path in app data, or shared app data folder
`source` indicates resource location: either an arbitrary url (starting with `http://` or `https://`),
absolute location of a file in the app store (starting with a slash `/`),
or a relative location in the same folder as the app in question (the relative location directly).
`'target'` points to the path in app data, or shared app data folder. If not specified it will place the app into the main data folder with the name it has.
if `'shared'` is specified and `true`. When re-downloading the app, all resources will be re-downloaded as well.
Currently, app resources
are only downloaded when using `/carpet download` command.
Currently, app resources are only downloaded when using `/carpet download` command.
* `libraries` - list of libraries or apps to be downloaded when installing the app from the app store. It needs to be a list of map-like resource
descriptors, like the above `resources` field.
```
'libraries' -> [
{
'source' -> '/tutorial/carpets.sc'
},
{
'source' -> '/fundamentals/heap.sc',
'target' -> 'heap-lib.sc'
}
]
```
`source` indicates resource location and must point to a scarpet app or library. It can be either an arbitrary url (starting with `http://`
or `https://`), absolute location of a file in the app store (starting with a slash `/`), or a relative location in the same folder as the app
in question (the relative location directly).
`target` is an optional field indicating the new name of the app. If not specified it will place the app into the main data folder with the name it has.
If the app has relative resources dependencies, Carpet will use the app's path for relatives if the app was loaded from the same app store, or none if the
app was loaded from an external url.
If you need to `import()` from dependencies indicated in this block, make sure to have the `__config()` map before any import that references your
remote dependencies, in order to allow them to be downloaded and initialized before the import is executed.
* `'arguments'` - defines custom argument types for legacy commands with `'legacy_command_type_support'` as well
as for the custom commands defined with `'commands'`, see below.
* `'commands'` - defines custom commands for the app to be executed with `/<app>` command, see below.
@@ -141,6 +141,10 @@ but if symbols are used directly in the module body rather than functions, it ma
Returns full list of available symbols that could be imported from this module, which can be used to debug import
issues, and list contents of libraries.
You can load and import functions from dependencies in a remote app store's source specified in your config's `libraries` block, but make sure
to place your config _before_ the import in order to allow the remote dependency to be downloaded (currently, app resources are only downloaded
when using the `/carpet download` command).
### `call(function, ? args ...)`
calls a user defined function with specified arguments. It is equivalent to calling `function(args...)` directly