@plaoc/cli
This is the plaoc command line tool, responsible for the development, packaging, and publishing of Dwebapp. After packaging with this tool, the app can be installed in the Dweb Browser on any platform.
This cli tool also serves as a publishing tool and verifies the app's functionality, and can use plaoc run in conjunction with the server for quick packaging and publishing of applications.
Installation
First, you need to install the plaoc command line tool.
npm i -g @plaoc/cliyarn global add @plaoc/clipnpm add -g @plaoc/cliYou can also use npx plaoc to execute commands
Assume the project directory is as follows:
dweb-app
├── dist // Compiled source code directory
├── ......Other project files
├── manifest.json
└── plaoc.jsonDevelopment Mode
Monitoring Source Code Changes
plaoc live ./distThis command will start an http service in the specified folder and generate the installation address for Dwebapp based on the generated http address. Since it binds to the http service address, the app installation only provides forwarding and does not install the source code into dweb_browser.
In simple terms, when the source code files are updated, there is no need to reinstall the Dwebapp source code as it will also be updated.
Options
--portor-p: Used to specify the service port to start. Default is port 8096.--config-diror-c: Dynamically specify the configuration file directory, i.e., specify the root directory where you createdmanifest.json. Default uses the current directory.--web-serveror-s: Used to specify the Dwebapp backend address.--static-portor-p2: Specify the static service address.
Example
Note, the source code folder must be specified.
plaoc live ./distThe output is similar to the following:
0: dweb://install?url=http://127.0.0.1:8096/metadata.json
1: dweb://install?url=http://172.30.95.105:8096/metadata.json
? Enter the corresponding number to generate a QR code. (0) › 1
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▄▄▄ █▀▀ ███▄█▀█▀▄ ██ █ ▄▄▄▄▄ █
█ █ █ █▄▀██▀▀▄▄█▄▄█▀██ █ █ █ █
█ █▄▄▄█ █ ▄ █ ██▀█ ▀ █▄▄ █ █▄▄▄█ █
█▄▄▄▄▄▄▄█ █ ▀▄▀▄█▄▀ █▄▀ █ █▄▄▄▄▄▄▄█
█ ▀ ▀█▄▄▀▀█ ▀▄▄ ███▄▄▄█▄█ ▄▄▀ ▄▀█
█ ▄███▄▄█▄▀▀ ▄█ █▀ ▄▀▀█ ▄ ██ ▄█
█▀█▀▄▄ ▄▀▀▀▄ █▀ ▄▄ █ █ ▄▄▄ ▀█▀█ █
█▀ ▄█▀█▄█ ▄▄ █▄▄██ ▀██ ▄▄▀▀█ ▀█▄██
█▄ ▀▄█ ▄▄██▀█ ▀█ ▄▀█▀ ▀ █▀▄█▄▀▀▀▄█
█▄▀▄█▀▀▄ ▄ ▀▄ █ █ ▀██▀▀ ▀▄▄██▄▄█ █
█▄ ▀▄ █▄▀▄█▀▀██▀▄ ▀██▄▄▄▄▀█▀██ ▀▄▀█
█▄ ▀█ ▄▄ █ ███▀█▀█ ▄█ █▀ █ ▄▀ █
█▄████▄▄█▀▀█▀ ██▄ █▀█▄▄█ ▄▄▄ █▀▄ █
█ ▄▄▄▄▄ █▄▄▀█ ▀▀▀█ █▀▄▀ █ █▄█ ▄█ ▀█
█ █ █ █▀▀█▄█▄▄█▀▄█▄▀ ▀█▄▄ ▄█▄██
█ █▄▄▄█ █▀ █▀█ █▀▄▀ ▀ ▀█▄ █▀ ▄██▄█
█▄▄▄▄▄▄▄█▄▄█▄▄█▄████▄█▄▄█▄██▄▄██▄██The generated QR code can be used in the Dweb Browser mobile app with the scanning module for installation.
Monitoring Service
plaoc serve provides two modes, you can create a static service from static source code. You can also specify a dynamically started http address to create an installation service.
Specify Dynamic Address
For example, using vite --host to create a dynamic service, the advantage of this method is that you don't need to reinstall the app every time you modify the code. However, you need to ensure that devices can access each other, so if it's not local, try to use a private address.
plaoc serve http://172.30.95.105:5173/The output is the same as above.
Specify Static Source Code
Specifying static source code installation is equivalent to having installed it into Dweb Browser, and the installation service does not need to be kept running, but if the code is modified, it needs to be reinstalled.
plaoc serve ./distThe output is the same as above.
Options
--portor-p: Used to specify the service port to start. Default is port 8096.--config-diror-c: Dynamically specify the configuration file directory, i.e., specify the root directory where you createdmanifest.json. Default uses the current directory.--web-serveror-s: Used to specify the Dwebapp backend address.
Packaging Dwebapp
plaoc bundle is used when publishing Dwebapp, it will package into the following folder structure, and output a compressed file .zip and a metadata.json.
|- bundle
|- appId.version.zip
|- metadata.json
Here, the source code folder is still specified.
plaoc bundle ./dist./dist directory is your packaged source code directory. And you need to ensure that the folder where you run the plaoc command is at the same level as your manifest.json folder.
If not in the same directory, you can refer to the -c directory below for specification.
Specify manifest.json Directory
If your manifest.json is not in the same folder as the packaged directory, you can use -c to specify to the manifest.json folder.
Assume the project directory is as follows:
plaoc-main
├── ......Other project files
├── plaoc-app1
├── ./dist //Project packaged source code files
├── manifest.json
├── plaoc-app2
├── ./dist //Project packaged source code files
└── manifest.jsonIf you have multiple projects under your directory, you can specify the directory to package as follows.
plaoc bundle ./plaoc-app1/dist -c ./plaoc-app1ps: You can also use
plaoc bundle --helpto view.
Specify the Output Package File Location
You can use --out to specify the output directory name, default is bundle.
plaoc bundle ./dist --out ./bundleDirSpecify the Output appId
You can use --id to specify the app's id.
plaoc bundle ./dist --id new.plaoc.org.dwebNote that the specified id needs to end with .dweb, and be the same domain as the configured home.
Specify the Output App Version
You can use --version to specify the app's version.
plaoc bundle ./dist --version 0.2.3Options
-oor--out: Specify the directory name after packaging, default name isbundle.-vor--version: Specify the app's version, can override the configuration inmanifest.json.--id: Specify the app's id, can override the configuration inmanifest.json.-cor--config-dir: Used to specify the development directory, i.e., specify the root directory where you createdmanifest.json.--clear: Whether to clear the compiled folder, default is to clear.
Example
plaoc bundle ./dist --dir ./plaoc/demo --version 0.0.2After packaging, it can be deployed to any accessible location, and then in the Dweb Browser on any platform, access the metadata.json file to install.