Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Plugin System #124

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
eb17d05
fix: remove fleet config
mrxiaozhuox Mar 25, 2023
fb31b40
fix: deleted useless code
mrxiaozhuox Mar 25, 2023
2f39649
feat: commit code
mrxiaozhuox Mar 25, 2023
0eaddf0
feat: commit code
mrxiaozhuox Mar 26, 2023
828bcbe
fix: crate root path
mrxiaozhuox Mar 26, 2023
ec685f2
feat: add `move_file` api
mrxiaozhuox Mar 26, 2023
21ffda1
feat: add plugin installer
mrxiaozhuox Mar 26, 2023
565b78a
fix: directory exists
mrxiaozhuox Mar 26, 2023
f375675
fix: commit code
mrxiaozhuox Mar 26, 2023
fdb40b7
feat: plugin add support `branch`
mrxiaozhuox Mar 27, 2023
1624940
feat: diff plugin version re-init
mrxiaozhuox Mar 27, 2023
cda1ed7
fix: some problem
mrxiaozhuox Mar 28, 2023
311ee5d
fix: plugin log include plugin name
mrxiaozhuox Mar 30, 2023
6a73f17
feat: delete plugin `interval` api
mrxiaozhuox Mar 31, 2023
4615453
feat: update serve start args
mrxiaozhuox Apr 2, 2023
11c0a88
fix: plugin init
mrxiaozhuox Apr 6, 2023
1ff5ea3
feat: deleted auto-init plugin system
mrxiaozhuox Apr 7, 2023
afab9da
feat: add upgrade command
mrxiaozhuox Apr 8, 2023
daada50
feat: add core library version verify
mrxiaozhuox Apr 8, 2023
850af0b
fix: create dir
mrxiaozhuox Apr 8, 2023
1d22815
fix: rewrite download_file in plugin API
arqalite Apr 9, 2023
4b9d436
refactor: clean up download_file()
arqalite Apr 9, 2023
a955370
feat: commit code
mrxiaozhuox Apr 12, 2023
d6301b7
Merge pull request #1 from arqalite/master
mrxiaozhuox Apr 12, 2023
0ebe1fb
fix: properly load library_dir
arqalite Apr 12, 2023
309d36c
Merge pull request #3 from arqalite/master
mrxiaozhuox Apr 12, 2023
4e8c9dc
feat: commit code
mrxiaozhuox Apr 13, 2023
e6dbc46
feat: commit code
mrxiaozhuox Apr 13, 2023
2a7f631
Merge remote-tracking branch 'refs/remotes/origin/master'
mrxiaozhuox Apr 13, 2023
3f5f1de
fix: problem
mrxiaozhuox Apr 13, 2023
b6b13fe
feat: config api
mrxiaozhuox Apr 14, 2023
84dffae
feat: cargo update
mrxiaozhuox Apr 14, 2023
e671d72
fix: deleted log::info
mrxiaozhuox Apr 14, 2023
086175d
feat: add before_rebuild stage
arqalite Apr 14, 2023
d21fdf4
Merge pull request #4 from arqalite/add_before_rebuild_stage
mrxiaozhuox Apr 14, 2023
3c85647
refactor: rename rebuild events
arqalite Apr 14, 2023
27e37d1
Merge pull request #5 from arqalite/add_before_rebuild_stage
mrxiaozhuox Apr 14, 2023
16c3c01
fix: stop panicking if Plugin.lock is missing, and create it instead
arqalite Apr 18, 2023
369ecf0
Merge pull request #6 from arqalite/create_lock_if_missing
mrxiaozhuox Apr 18, 2023
26b059a
feat: add read_dir api
mrxiaozhuox Apr 19, 2023
71c9e5b
feat: add json api
mrxiaozhuox Apr 19, 2023
48f52c8
feat: add copy_file api
mrxiaozhuox Apr 19, 2023
a594658
feat: add copy_file api
mrxiaozhuox Apr 19, 2023
1261923
docs: update documents
mrxiaozhuox Apr 21, 2023
9f9cd90
docs: update documents
mrxiaozhuox Apr 21, 2023
d9bed49
feat: commit docs
mrxiaozhuox Apr 23, 2023
bbf4daa
feat: commit docs
mrxiaozhuox Apr 23, 2023
26349bc
Merge branch 'master' into master
mrxiaozhuox May 5, 2023
6916862
fix: update `Cargo.lock`
mrxiaozhuox May 7, 2023
e5b83bd
Merge branch 'master' into master
mrxiaozhuox May 23, 2023
afdeacd
fix: clone_repo branch
mrxiaozhuox May 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .fleet/settings.json
Empty file.
26 changes: 23 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ mlua = { version = "0.8.1", features = [
"async",
"send",
"macros",
"serialize",
] }
ctrlc = "3.2.3"
# dioxus-rsx = "0.0.1"
Expand Down
5 changes: 4 additions & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
- [Build](./cmd/build.md)
- [Serve](./cmd/serve.md)
- [Clean](./cmd/clean.md)
- [Plugin](./cmd/plugin.md)
- [Translate](./cmd/translate.md)
- [Format](./cmd/fmt.md)
- [Plugin Development](./plugin/README.md)
- [API.Log](./plugin/interface/log.md)
- [API.Command](./plugin/interface/command.md)
- [API.OS](./plugin/interface/os.md)
- [API.Directories](./plugin/interface/dirs.md)
- [API.Network](./plugin/interface/network.md)
- [API.Path](./plugin/interface/path.md)
- [API.Path](./plugin/interface/path.md)
- [API.FileSystem](./plugin/interface/fs.md)
11 changes: 10 additions & 1 deletion docs/src/cmd/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ You can use `--example {name}` to build a example code.
```
# build `example/test` code
dioxus build --exmaple test
```
```

## Enable Features

You can use `--features {features}` to enable different features.

```sh
dioxus build --feautres desktop
```

15 changes: 15 additions & 0 deletions docs/src/cmd/fmt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fmt

`dioxus fmt` can help you format your `rsx` code.

```
USAGE:
dioxus fmt [OPTIONS]

OPTIONS:
-c, --check Run in 'check' mode.
-f, --file <FILE> Input file
-h, --help Print help information
-r, --raw <RAW> Input rsx (selection)
```

33 changes: 33 additions & 0 deletions docs/src/cmd/plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Plugin

`dioxus plugin` can help developer manage & develop their own cli plugin.

### Init plugin system

This command will download a plugin core library in your project, and enable plugin system.

```shell
dioxus plugin init
```



### Install & add new plugin

This command can help you install a new plugin from git.

> currently it just support install from git repository.

```shell
dioxus plugin add --git {GIT_URL}
```



### Upgrade core library

Beacause of the core library must be sync with cli version, so you need use upgrade core library after updated cli version.

```shell
dioxus plugin upgrade
```
31 changes: 8 additions & 23 deletions docs/src/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,7 @@ We use `toml` to define some info for `dioxus` project.
asset_dir = "public"
```

### Application.Tools

You can combine different tools with `dioxus`.

1. ***binaryen*** - Use the `binaryen` tooling suite.
```
# current support: wasm-opt
# default: web
binaryen = { wasm_opt = true }
```
Use the `wasm_opt = true` key/pair value to activate optimization with wasm-opt.
When building on `release` profile, Dioxus will run `wasm_opt` with `-Oz` option.
2. ***tailwindcss*** - Use the `tailwindcss` standalone binary to generate a Tailwind CSS bundle file.
```
tailwindcss = { input = "main.css", config = "tailwind.config.js" }
```
You can set two optional keys :
- input: path of the input CSS file (default value is "public/tailwind.css")
- config: path to the config file for Tailwind (default value is "src/tailwind.config.js")

When building on `release` profile, Dioxus will run `tailwindcss` with the `--minify` option.

Note : Dioxus will automatically include the generated tailwind file in the `index.html`
5. **sub_package** - build & work on a sub-package.

### Web.App

Expand All @@ -59,6 +37,13 @@ Web platform application config:
title = "dioxus app | ⛺"
```

2. **base_path** - custom web service root path.

```
base = "my-site"
# url will be: http://localhost:8080/my-site
```

### Web.Watcher

Web platform `dev-server` watcher config:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

📦✨ **Dioxus-Cli** is a tool to help get dioxus projects off the ground.

![dioxus-logo](https://dioxuslabs.com/guide/images/dioxuslogo_full.png)
![dioxus-logo](https://github.com/DioxusLabs/dioxus/raw/master/notes/header.svg)

It includes `dev server`, `hot reload` and some `quick command` to help you use dioxus.

Expand Down
13 changes: 9 additions & 4 deletions docs/src/plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ The plugin library have pre-define some important event you can control:
- `build.on_start`
- `build.on_finished`
- `serve.on_start`
- `serve.on_rebuild`
- `serve.on_rebuild_start`
- `serve.on_rebuild_end`
- `serve.on_shutdown`

### Plugin Template
Expand Down Expand Up @@ -63,7 +64,13 @@ manager.serve.on_start = function (info)
end

---@param info ServeRebuildInfo
manager.serve.on_rebuild = function (info)
manager.serve.on_rebuild_start = function (info)
-- this function will execute before the CLI rebuilds
log.info("[plugin] Before rebuild: " .. info.name)
end

---@param info ServeRebuildInfo
manager.serve.on_rebuild_end = function (info)
-- this function will after clean & print to run, so you can print some thing.
local files = plugin.tool.dump(info.changed_files)
log.info("[plugin] Serve rebuild: '" .. files .. "'")
Expand All @@ -73,7 +80,5 @@ manager.serve.on_shutdown = function ()
log.info("[plugin] Serve shutdown")
end

manager.serve.interval = 1000

return manager
```
30 changes: 4 additions & 26 deletions docs/src/plugin/interface/dirs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,11 @@
> you can use Dirs functions to get some directory path


### plugin_dir() -> string
### crate_dir() -> string

You can get current plugin **root** directory path
You can get current crate **root** directory path

```lua
local path = plugin.dirs.plugin_dir()
-- example: ~/Development/DioxusCli/plugin/test-plugin/
local path = plugin.dirs.crate_dir()
-- path = "~/MyProject/dioxus-starter/"
```

### bin_dir() -> string

You can get plugin **bin** direcotry path

Sometime you need install some binary file like `tailwind-cli` & `sass-cli` to help your plugin work, then you should put binary file in this directory.

```lua
local path = plugin.dirs.bin_dir()
-- example: ~/Development/DioxusCli/plugin/test-plugin/bin/
```

### temp_dir() -> string

You can get plugin **temp** direcotry path

Just put some temporary file in this directory.

```lua
local path = plugin.dirs.bin_dir()
-- example: ~/Development/DioxusCli/plugin/test-plugin/temp/
```
116 changes: 116 additions & 0 deletions docs/src/plugin/interface/fs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# FileSystem Functions

> you can use FileSystem functions to handle file.

### create_dir(path: string, recursive: boolean): boolean

This function can help you create a directory, if `recursive` is `true`, API will auto-create missing directory.

```lua
local path = "~/MyProject/temp/hello"

-- before
-- - MyProject

plugin.fs.create_dir(path, true)
-- after (recursive)
-- - MyProject
-- - - temp
-- - - - hello
```

### remove_dir(path: string): boolean

This function will remove a single directory.

```lua
local path = "~/MyProject/temp/hello"

-- before
-- - MyProject
-- - - temp
-- - - - hello

plugin.fs.create_dir(path, true)
-- after
-- - MyProject
-- - - temp
```

### file_get_content(path: string): string

This function can read a file's content.

```lua
local path = "~/MyProject/hello.txt"
local content = plugin.fs.file_get_content(path)
-- content = "hello world"
```

### file_set_content(path: string, content: string): boolean

This function can write file's content.

```lua
local path = "~/MyProject/hello.txt"
-- before: "Hello World"
plugin.fs.file_set_content(path, "Hello Dioxus")
-- after: "Hello Dioxus"
```

### remove_file(path: string): boolean

This function can remove a file from path.

```lua
local file = "~/MyProject/hello.txt"
plugin.fs.remove_file(file)
```

### move_file(path: string, target: string): boolean

This function can move a file from a path to another path.

```lua
local file = "~/MyProject/hello.txt"
plugin.fs.move_file(file, "~/MyProject/temp/hello.txt")
```

### copy_file(path: string, target: string): boolean

This function can move a file from a path to another path.

> The different and `move_file` is `copy_file` will keep origin file.

```lua
local file = "~/MyProject/hello.txt"
plugin.fs.copy_file(file, "~/MyProject/temp/hello.txt")
```

### unzip_file(path: string, target: string): boolean

This function can let you **unzip** a `.zip` file.

```lua
local file = "~/MyProject/package.zip"
plugin.fs.unzip(file, "~/MyProject/unpackaged")
```

### untar_gz_file(path: string, target: string): boolean

This function can let you **unpackage** a `.tar.gz` file.

```lua
local file = "~/MyProject/package.tar.gz"
plugin.fs.untar_gz_file(file, "~/MyProject/unpackaged")
```

### read_dir(path: string): string []

This function can read a directory and get a list.

```lua
local path = "~/MyProject/"
local list = plugin.fs.read_dir(path)
-- list = ["temp", "package.zip", "package.tar.gz"]
```
Loading