actions_toolkit_sys/
tool_cache.rs

1use js_sys::{Array, Error, JsString, Number, Promise};
2use wasm_bindgen::prelude::*;
3
4#[wasm_bindgen(module = "@actions/tool-cache")]
5extern {
6    #[wasm_bindgen(extends = Error)]
7    pub type HTTPError;
8
9    #[wasm_bindgen(method, getter, js_name = "httpStatusCode")]
10    pub fn http_status_code(this: &HTTPError) -> Option<Number>;
11
12    #[wasm_bindgen(constructor)]
13    pub fn new(http_status_code: Option<&Number>) -> HTTPError;
14}
15
16#[wasm_bindgen(module = "@actions/tool-cache")]
17extern {
18    /// Download a tool from an url and stream it into a file.
19    #[wasm_bindgen(js_name = "downloadTool")]
20    #[must_use] // Promise<string>
21    pub fn download_tool(url: &JsString) -> Promise;
22
23    /// Extract a .7z file.
24    #[wasm_bindgen(js_name = "extract7z")]
25    #[must_use] // Promise<string>
26    pub fn extract_7z(file: &JsString, dest: Option<&JsString>, _7z_path: Option<&JsString>) -> Promise;
27
28    /// Extract a tar.
29    #[wasm_bindgen(js_name = "extractTar")]
30    #[must_use] // Promise<string>
31    pub fn extract_tar(file: &JsString, dest: Option<&JsString>, flags: Option<&JsString>) -> Promise;
32
33    /// Extract a zip.
34    #[wasm_bindgen(js_name = "extractZip")]
35    #[must_use] // Promise<string>
36    pub fn extract_zip(file: &JsString, dest: Option<&JsString>) -> Promise;
37
38    /// Caches a directory and installs it into the tool cacheDir.
39    #[wasm_bindgen(js_name = "cacheDir")]
40    #[must_use] // Promise<string>
41    pub fn cache_dir(source: &JsString, tool: &JsString, version: &JsString, arch: Option<&JsString>) -> Promise;
42
43    /// Caches a downloaded file (GUID) and installs it into the tool cache with a given targetName.
44    #[wasm_bindgen(js_name = "cacheFile")]
45    #[must_use] // Promise<string>
46    pub fn cache_file(
47        source: &JsString,
48        target: &JsString,
49        tool: &JsString,
50        version: &JsString,
51        arch: Option<&JsString>,
52    ) -> Promise;
53
54    /// Finds the path to a tool version in the local installed tool cache.
55    #[wasm_bindgen]
56    pub fn find(tool: &JsString, version: &JsString, arch: Option<&JsString>) -> String;
57
58    /// Finds the paths to all versions of a tool that are installed in the local tool cache.
59    #[wasm_bindgen(js_name = "findAllVersions")]
60    pub fn find_all_versions(tool: &JsString, arch: Option<&JsString>) -> Array;
61}