@plaoc/cli
This is the plaoc command-line tool, tasked with developing, packaging, and distributing dweb apps. After using this CLI to package your app, it can be installed on any platform's Dweb Browser.
The cli tool also includes publishing tools and functionalities for validating apps, allowing you to use plaoc run alongside the server-side to quickly package and publish applications.
Installation
First, you need to install the plaoc command-line tool.
pnpm add -g @plaoc/cli yarn global add @plaoc/cli npm i -g @plaoc/cliAlternative: You can also execute commands using
npx plaoc.
Assume your project directory looks like this:
dweb-app
├── dist // The compiled source code directory for engineering
├── ... Other project files
├── manifest.json
└── plaoc.jsonDevelopment Mode
Listening to Source Code Changes
plaoc live ./distThis command starts an HTTP service in the specified folder and generates a dweb app installation address based on the generated HTTP address. Since it's bound to the HTTP service URL, the app is installed by providing redirection only, without actually installing the source code into the Dweb Browser.
In essence, when your code files are updated, you don't need to reinstall the dweb app as its source changes.
Options
--portor-p: Specifies the service port for startup. Defaults to 8096.--config-diror-c: Dynamically specifies the configuration file directory, that is, the root directory where you createdmanifest.json. The default uses the current directory.--web-serveror-s: Specifies the backend address fordweb app.--static-portor-p2: Specifies the static service address.
Example
Ensure to specify the source code folder:
plaoc live ./distOutput typically appears as:
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 scanned and installed using the scanning module in the Dweb Browser on mobile devices.
Monitoring Service
The plaoc serve command offers two modes for creating static services from static source code. It also allows specifying a dynamic starting HTTP address to create an installation service.
Specifying Dynamic Address
For instance, using vite --host creates a dynamic service. The advantage of this method is that you don't need to reinstall the app every time your code changes. However, it requires ensuring that devices can access each other, so if not local, try using private addresses.
plaoc serve http://172.30.95.105:5173/The output will be as above.
Specifying Static Source Code
When specifying static source code for installation, it's equivalent to installing into the Dweb Browser, and you don't need a service running continuously. However, if your code changes, you'll need to reinstall.
plaoc serve ./distThe output will be as above.
Options:
--portor-p: Used to specify the port for starting the service. The default is 8096.--config-diror-c: Dynamically specifies the configuration file directory, which means specifying the root directory where you created themanifest.json. By default, it uses the current directory.--web-serveror-s: Used to specify the backend address fordweb app.
Packaging dweb app
plaoc bundle is used when publishing a dweb app, 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 ./distThe ./dist directory is the source code directory you want to package. Also, make sure that the folder where you run the plaoc command is at the same level as your manifest.json file.
If not in the same directory, you can refer to the -c directory for specification.
Specifying the manifest.json directory
If your manifest.json is not in the same folder as the packaging directory, you can use the -c option to specify the folder where manifest.json is located.
Assuming the project directory is as follows:
plaoc-main
├── other-engine-files
└── plaoc-app1
├── ./dist # location of packaged project code files
└── manifest.json
└── plaoc-app2
├── ./dist # location of packaged project code files
└── manifest.jsonWith multiple projects in your folder, you can bundle them by specifying the directory like this:
plaoc bundle ./plaoc-app1/dist -c ./plaoc-app1Note: You can also get more details using plaoc bundle --help.
Specifying the Output Directory for Bundled Files
You have an option to use --out to designate the output directory, with the default being bundle.
plaoc bundle ./dist --out ./bundleDirNaming Your App ID
You can also specify your app's id using --id. Remember that for it to work correctly:
- The id should end in
.dweb. - It must match the domain specified in your
homeconfiguration.
Setting an App Version
Use the --version flag to define your app version. This overrides any version information from your manifest.json.
plaoc bundle ./dist --version 0.2.3Command Options Explained
-oor--out: Specifies the target folder for packaged files, with a default ofbundle.-vor--version: Sets the app version, which takes precedence over the one inmanifest.json.--id: Assigns your app's id, overriding themanifest.jsonconfiguration.-c(or--config-dir): Points to your development directory, where you created themanifest.json.--clear: Determines if the compiled folder should be cleared (trueby default).
Example Usage
plaoc bundle ./dist --dir ./plaoc/demo --version 0.0.2After bundling is complete and your files are ready, you can deploy them to any accessible location. To install these on the Dweb Browser, simply navigate to metadata.json from any platform.