mirror of
https://github.com/status-im/status-dev-cli.git
synced 2026-08-30 21:11:13 +00:00
Pre-release README update
This commit is contained in:
@@ -4,10 +4,9 @@ Additional tools for DApps developers. These tools allows to speed up the proces
|
||||
|
||||
## Requirements
|
||||
|
||||
1. adb (from Android SDK);
|
||||
2. Node.js;
|
||||
3. NPM;
|
||||
4. Watchman (https://facebook.github.io/watchman/docs/install.html).
|
||||
1. Node.js;
|
||||
2. NPM;
|
||||
3. Watchman (https://facebook.github.io/watchman/docs/install.html).
|
||||
|
||||
## Installing
|
||||
|
||||
@@ -19,32 +18,38 @@ npm i -g status-dev-cli
|
||||
|
||||
**Common additional parameters:**
|
||||
|
||||
* `--ip <device-ip>` to specify your device's IP address.
|
||||
* `--ip <device-ip>` to specify your device's IP address. If you don't know your device's IP address, just run `status-dev-cli scan`.
|
||||
|
||||
#### 1. Adding a contact (DApp or bot)
|
||||
#### 1. Scanning the network
|
||||
|
||||
***status-dev-cli 3.2.0+, Status 0.9.8+***
|
||||
|
||||
Scans for available Status debug servers and returns IP addresses of them.
|
||||
|
||||
`status-dev-cli scan`
|
||||
|
||||
#### 2. Adding a contact (DApp or bot)
|
||||
|
||||
`status-dev-cli add [contact]`
|
||||
|
||||
* `contact` — JSON containing contact information. It is not required if you develop a DApp and this DApp contains `package.json` file. Otherwise, this map should contain `whisper-identity`, `name` and `dapp-url` or `bot-url` fields (see the example in **Scenario** section)
|
||||
|
||||
You can additionally specify `--dapp-port <port>` if your DApp uses port other than 8080 and you don't specify a `dapp`JSON.
|
||||
|
||||
#### 2. Removing a contact (DApp or bot)
|
||||
#### 3. Removing a contact (DApp or bot)
|
||||
|
||||
`status-dev-cli remove [contact]`
|
||||
|
||||
* `dapp` — JSON containing `whisper-identity` field. It is not required if you develop a DApp and this DApp contains `package.json` file.
|
||||
* `contact` — JSON containing `whisper-identity` field. It is not required if you develop a DApp and this DApp contains `package.json` file.
|
||||
|
||||
#### 3. Refreshing a DApp automatically
|
||||
#### 4. Refreshing a DApp automatically
|
||||
|
||||
`status-dev-cli watch [dir] [contact]`
|
||||
|
||||
* `dir` — dir that should be observed. Not required;
|
||||
* `contact` — JSON containing `whisper-identity` field. It is not required if you develop a DApp and this DApp contains `package.json` file.
|
||||
|
||||
#### 4. Refreshing a DApp manually
|
||||
#### 5. Refreshing a DApp manually
|
||||
|
||||
***Requires status-dev-cli 2.2.1+!***
|
||||
***status-dev-cli 2.2.1+***
|
||||
|
||||
This command simply reloads the DApp
|
||||
|
||||
@@ -52,9 +57,9 @@ This command simply reloads the DApp
|
||||
|
||||
* `dapp` — JSON containing `whisper-identity` field. It is not required if your DApp contains `package.json` file.
|
||||
|
||||
#### 5. Switching network
|
||||
#### 6. Switching network
|
||||
|
||||
***Requires Status 0.9.4+ & status-dev-cli 2.2.0+!***
|
||||
***status-dev-cli 2.2.0+, Status 0.9.4+***
|
||||
|
||||
Typically when developing DApps, a developer uses his own private chain or a simulator.
|
||||
Status inserts its own web3 object into the DApp, however, this web3 object is connected to a different network than the development one.
|
||||
@@ -64,45 +69,47 @@ This command allows to switch a network. Next time you login the network will be
|
||||
|
||||
* `url` (required) — the network that will be used instead of `http://localhost:8545`
|
||||
|
||||
## Library
|
||||
#### 7. Listing all debuggable DApps and bots
|
||||
|
||||
***status-dev-cli 3.2.0+, Status 0.9.8+***
|
||||
|
||||
Displays all debuggable DApps and bots. Can be useful if you don't remember identities of your applications.
|
||||
|
||||
`status-dev-cli list`
|
||||
|
||||
#### 8. Extracting logs
|
||||
|
||||
***status-dev-cli 3.2.0+, Status 0.9.8+***
|
||||
|
||||
Displays the last 100 log messages for the specified bot or DApp.
|
||||
|
||||
`status-dev-cli log <whisper-identity>`
|
||||
|
||||
* `whisper-identity` — identity of your DApp or bot.
|
||||
|
||||
## Using status-dev-cli as a library
|
||||
|
||||
```
|
||||
var StatusDev = require('status-dev-cli');
|
||||
var statusDev = new StatusDev({ip: 'you-device-ip'});
|
||||
```
|
||||
|
||||
#### dappData
|
||||
|
||||
```
|
||||
dataData = {
|
||||
"whisper-identity": "dapp-MyAppName",
|
||||
"dapp-url": "http://your-server-ip:port",
|
||||
"name": "My App Name"
|
||||
}
|
||||
```
|
||||
|
||||
#### 1. Adding a DApp
|
||||
statusDev.addContact(dappData, function(error, result) {});
|
||||
|
||||
```
|
||||
statusDev.addDapp(dappData, function(error, result) {});
|
||||
```
|
||||
statusDev.refreshContact(dappData, function(error, result) {});
|
||||
|
||||
#### 2. Refreshing a DApp
|
||||
statusDev.removeContact(dappData, function(error, result) {});
|
||||
|
||||
```
|
||||
statusDev.refreshDapp(dappData, function(error, result) {});
|
||||
```
|
||||
|
||||
#### 3. Removing a DApp
|
||||
|
||||
```
|
||||
statusDev.removeDapp(dappData, function(error, result) {});
|
||||
```
|
||||
|
||||
#### 4. Switching network
|
||||
|
||||
```
|
||||
statusDev.switchNode(rpcUrl, function(error, result) {});
|
||||
|
||||
statusDev.listDApps(function(error, result) {});
|
||||
|
||||
statusDev.getLog(identity, function(error, result) {});
|
||||
```
|
||||
|
||||
## DApp development
|
||||
@@ -111,10 +118,8 @@ To make debugging work we run a web server on your device. It runs on port 5561
|
||||
|
||||
To start a server you need to:
|
||||
1. Connect your device to computer;
|
||||
2. In the case you're developing for Android, you need to use a port forwarding.
|
||||
Execute `adb forward tcp:5561 tcp:5561`;
|
||||
3. Open Status application and log in;
|
||||
4. Open `Console` chat and execute `/debug` command providing "On" as the argument.
|
||||
2. Open Status application and log in;
|
||||
3. Open `Console` chat and execute `/debug` command providing "On" as the argument.
|
||||
|
||||
You can also easily turn the server off from here.
|
||||
|
||||
@@ -126,6 +131,7 @@ Imagine you are developing a DApp on your computer. You have a directory where a
|
||||
and there is a server running on your computer. Let's say it is running on port 8080, so you can access
|
||||
your DApp by typing http://localhost:8080 in your browser.
|
||||
|
||||
1. Add a DApp to Status by executing `status-dev-cli add '{"whisper-identity": "dapp-test", "dapp-url": "http://localhost:8080/", "name": "My Dapp"}'`;
|
||||
2. Open the "My Dapp" on your device;
|
||||
3. Optional: Execute `status-dev-cli watch-dapp . '{"whisper-identity": "dapp-test"}'` to start automatically refreshing your DApp in Status browser when you change the DApp's code.
|
||||
1. Find the IP address of your device by running `status-dev-cli scan`;
|
||||
2. Add a DApp to Status by executing `status-dev-cli add '{"whisper-identity": "dapp-test", "dapp-url": "http://localhost:8080/", "name": "My Dapp"}' --ip <DEVICE IP>`;
|
||||
3. Open the "My Dapp" on your device;
|
||||
4. Optional: Execute `status-dev-cli watch-dapp . '{"whisper-identity": "dapp-test"}' --ip <DEVICE IP>` to start automatically refreshing your DApp in Status browser when you change the DApp's code.
|
||||
|
||||
@@ -12,7 +12,6 @@ const pkgJson = require(__dirname + '/package.json');
|
||||
|
||||
const client = new watchman.Client();
|
||||
const defaultIp = "localhost";
|
||||
const defaultDAppPort = 8080;
|
||||
const statusDebugServerPort = 5561;
|
||||
const StatusDev = require('./index.js');
|
||||
|
||||
@@ -75,15 +74,23 @@ function getCurrentPackageData() {
|
||||
var json = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
|
||||
obj["name"] = json.name;
|
||||
obj["whisper-identity"] = "dapp-" + fromAscii(json.name);
|
||||
obj["dapp-url"] = "http://localhost:" + (cli.dappPort || defaultDAppPort);
|
||||
|
||||
obj["dapp-url"] = json["dapp-url"] || json["bot-url"];
|
||||
if (!obj["dapp-url"]) {
|
||||
console.error(chalk.red("Neither 'dapp-url' nor 'bot-url' have been found in your package.json file."));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function getPackageData(contact) {
|
||||
var contactData;
|
||||
var contactData = null;
|
||||
if (!contact) {
|
||||
contactData = JSON.stringify(getCurrentPackageData());
|
||||
var data = getCurrentPackageData();
|
||||
if (data != null) {
|
||||
contactData = JSON.stringify(data);
|
||||
}
|
||||
} else {
|
||||
contactData = contact;
|
||||
}
|
||||
@@ -297,5 +304,4 @@ cli.on("*", function(command) {
|
||||
|
||||
cli.version(pkgJson.version)
|
||||
.option("--ip [ip]", "IP address of your device")
|
||||
.option("--dapp-port [dappPort]", "Port of your local DApp server")
|
||||
.parse(process.argv);
|
||||
|
||||
Reference in New Issue
Block a user