From eddf8c4ef56683129732449be91d1be1ec0d9cf0 Mon Sep 17 00:00:00 2001
From: elasticLove1
Date: Thu, 25 Feb 2021 23:17:02 +0300
Subject: [PATCH 13/24] update
---
README.md | 18 ++++++++++++------
assets/tondev-FT.svg | 4 ----
assets/tondev-TB.png | Bin 1083 -> 0 bytes
assets/tondev-blue.png | Bin 873 -> 0 bytes
assets/{tondev-ZT.png => tondev.png} | Bin
5 files changed, 12 insertions(+), 10 deletions(-)
delete mode 100644 assets/tondev-FT.svg
delete mode 100644 assets/tondev-TB.png
delete mode 100644 assets/tondev-blue.png
rename assets/{tondev-ZT.png => tondev.png} (100%)
diff --git a/README.md b/README.md
index 91c4104..d9fba4b 100644
--- a/README.md
+++ b/README.md
@@ -40,22 +40,28 @@
## What is TONDEV?
-TONDEV an Node.js package with CLI interface that allows to easily download and install all the core TON.DEV components in background and use them from a single interface.
-Also, this project serves as a backend for [TONDEV VS Code plugin](https://github.com/tonlabs/tondev-vscode).
+TONDEV is a Node.js package with CLI interface that allows to easily download and install all the core TON.DEV components in background and use them from a single interface.
+Also, this project serves as a backend for [TONDEV VS Code extension](https://github.com/tonlabs/tondev-vscode).
### What components does it support?
These components are supported or will be supported soon.
Each component is downloaded and installed automatically for the target platform upon the first request.
+- [Debot](https://docs.ton.dev/86757ecb2/p/72f1b7-debot-specifications) - SOON
+ Support of debot test chat(browser for debot testing), debot publishing, etc.
- [Solidity Compiler](https://github.com/tonlabs/TON-Solidity-Compiler)
-- [TON-SDK](https://github.com/tonlabs/TON-SDK)
- [C/C++ Compiler](https://github.com/tonlabs/TON-Compiler) - SOON
-- [TON OS Startup Edition](https://github.com/tonlabs/tonos-se) – SOON
-- [TestSuite4](https://github.com/tonlabs/TestSuite4) – SOON
+- [TON OS Startup Edition](https://github.com/tonlabs/tonos-se) –
+ Local blockchain for development and testing
+- [TestSuite4](https://github.com/tonlabs/TestSuite4) –
+Python lightweight framework for Solidity testing
- [tonos-cli](https://github.com/tonlabs/tonos-cli) (installation only) – SOON
+ TONOS Client Application with CLI interface
+- [TON-SDK](https://github.com/tonlabs/TON-SDK)
+ Core SDK Library. We plan to add some useful functionality like keys generation, address conversion, support of deploy, get methods, etc. from CLI and IDE
-It can be extended with other tools following the [instructions of integration](#tondev-extensibility).
+TONDEV can be extended with other tools following the [instructions of integration](#tondev-extensibility).
## Installation
diff --git a/assets/tondev-FT.svg b/assets/tondev-FT.svg
deleted file mode 100644
index 5c1b0bc..0000000
--- a/assets/tondev-FT.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/assets/tondev-TB.png b/assets/tondev-TB.png
deleted file mode 100644
index fc7c0ee861f488443a35353e529f933a70148725..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1083
zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q4M;wBd$a>caTa()7Bes?T7WR4>omgzpde#$
zkh>GZx^prwfgF}}M_)$E)e-c?47?>}3x;TbZFuuLJKfgCnrs3n|Ro=Ib^-Bi|
z3MCpPh?)sDOU#(~gPG@0(v*k@A08bxL(d}$Y-c=XbZiKj6|!Win{?*Vm;6`XPd%oz
z_xU|{>F;~atG~Q*`I*}HmzDQ_?|W|h)+@YSY|@ow?^GDsRE{*XNK6o57D{q(;_>KU
z$%C;{Z`o(>R!6MzV*jH5&HBvE@Qo>0oN$!w%jRp>OMJecNm;Zjefg}u
zla;!2SKVp2_Kd}3YL%LM@b0X~^QHDLp1E^hkvyxG*@BtB=B+8*dsrVRai4ATF-zvs
z1$XvW30+vW{rl!)XLHVV?-Ul5zVKyRZRF!?{rkM7?QFc(zLKxmR`KKXZuV)vqpSjV
zGV;DTFDGs6nQQaDK%{D!TkzkrbKiViyJwnT@R#KqUN-L8|Hne`-nTEG9s&mi-LqgnClf@<6y}B_eQ0`+HEr`z2?_CslIFNmEE;v)&JMF
ze6hm6PlJS*y8IoLkFQ(rG*;;8i^?r)6p3Jem8}2;}ziBV*
z?fU3Z!qmf&K|j@ll^cF^MGFfC$GG&QN^SJZ$Smvnyv)MnsL;e2g-JChx2s1zG~4eK
iBdklKj36;#Lj0V*dv2mox#)9&t;ucLK6TXaK%yp
diff --git a/assets/tondev-blue.png b/assets/tondev-blue.png
deleted file mode 100644
index 8efcbf5b409e4f5e74ce45c407cdb4c770b51109..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 873
zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q4M;wBd$a>caTa()7Bes?T7WR4>omgzpde#$
zkh>GZx^prwfgF}}M_)$E)e-c?47?}Qfx;TbZFuuJTn~7w`T$XUz<^dTOZpWsMmMcDg9KFujoL}2t
zKc&*NxF*f04`>Sp`0>YUOIF>@qyJCdoUHc$+T;cn#)(P_K`bs^4IY95noLTr4olv+
zZ{8JpCweBI^!C%)+gIM5`Xcs>{=K`hfxXY)yc9p!<}3kG$I&5zsTsH6r4ReRzImeM
zwZ_hJ(d?REg$xf23;K_=Ka%VG;19MJMQfpvY3=^QM!ka4l@9+8{pDl78@@4?FL4Qq
zBA|=kvRyg)dpG;k<`b{j_8x0E|H)#jbim8DoGr~3|4OBHSM9Xu5prgVa$Ou{*AmMs
zWg2PU9lQ2BAA8>x_NtP+NBxeEy=r84YdyWXq4Dnfiz~{QXO*08R8B7}s+9R&`sv%x
z2gM1gn>yUKN?)kjD`T_m$m)tp%P$2YAMYkbeYdmcldJ#xaC%0_ZpOWKRq=--_+)AW
z_$#|-#Mc!+Kk@T+dg0#xw{7KG%z>*+{M!6rOxNs`rb8LtQWLhFTBEhw(X6w
z!}9vCl7F{v+&=U3nMZZ!7AL;_pZ4nH(cM)$W*+m~CO-S^k3Z||{I)(L
zr1aETyCT+1dB3>uEqlqglF02(&VT%H?(v(G{ug%?&f$)(uh?ig$7agEz1QmJ9pmUx
zUQlOLQ(XH+LGbJQi~Fy?UL4xv@O$!$+kLNpolU9V_Ro&9+%Cum1Y6@x6v^&%`(HQvSEi&EU_P
zn(J3X-xZlYE7-=e4E~_ixXdX
Date: Thu, 25 Feb 2021 23:19:00 +0300
Subject: [PATCH 14/24] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 2d1a0dd..a2636c5 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
**Get quick help in our telegram channel:**
[![Channel on Telegram](https://img.shields.io/badge/chat-on%20telegram-9cf.svg)](https://t.me/ton_sdk)
-# TONDEV - Free TON Developer Environment
+# TONDEV - Free TON Development Environment
+Download and install all the core TON.DEV components in one click and access them from a single interface.
## Content Table
-- [TONDEV - Free TON Developer Environment](#tondev---free-ton-developer-environment)
+- [TONDEV - Free TON Development Environment](#tondev---free-ton-development-environment)
- [Content Table](#content-table)
- [What is TONDEV?](#what-is-tondev)
- [What components does it support?](#what-components-does-it-support)
From c884d6f460e63fd3f22de3c293ebd009c4d38638 Mon Sep 17 00:00:00 2001
From: Ekaterina Pantaz <52739957+elasticLove1@users.noreply.github.com>
Date: Thu, 25 Feb 2021 23:49:23 +0300
Subject: [PATCH 16/24] Update README.md
---
README.md | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index aab0bdf..11fb4ad 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
TONDEV
Free TON Development Environment
+
**Get quick help in our telegram channel:**
@@ -8,7 +9,7 @@
[![Channel on Telegram](https://img.shields.io/badge/chat-on%20telegram-9cf.svg)](https://t.me/ton_sdk)
# TONDEV - Free TON Development Environment
-Download and install all the core TON.DEV components in one click and access them from a single interface.
+Download and install all the core [TON.DEV](https://docs.ton.dev/86757ecb2/p/04a4ba-) components in one click and access them from a single interface.
## Content Table
@@ -32,6 +33,7 @@ Download and install all the core TON.DEV components in one click and access the
- [Create Demo Project](#create-demo-project)
- [TONDEV Extensibility](#tondev-extensibility)
- [Backlog](#backlog)
+ - [Debot](#debot)
- [Solidity](#solidity-1)
- [C/C++](#cc)
- [TS4](#ts4)
@@ -49,18 +51,17 @@ Also, this project serves as a backend for [TONDEV VS Code extension](https://gi
These components are supported or will be supported soon.
Each component is downloaded and installed automatically for the target platform upon the first request.
-- [Debot](https://docs.ton.dev/86757ecb2/p/72f1b7-debot-specifications) - SOON
- Support of debot test chat(browser for debot testing), debot publishing, etc.
+- [Debot](https://docs.ton.dev/86757ecb2/p/72f1b7-debot-specifications) - **SOON**
- [Solidity Compiler](https://github.com/tonlabs/TON-Solidity-Compiler)
-- [C/C++ Compiler](https://github.com/tonlabs/TON-Compiler) - SOON
+- [C/C++ Compiler](https://github.com/tonlabs/TON-Compiler) - **SOON**
- [TON OS Startup Edition](https://github.com/tonlabs/tonos-se) –
Local blockchain for development and testing
-- [TestSuite4](https://github.com/tonlabs/TestSuite4) –
-Python lightweight framework for Solidity testing
-- [tonos-cli](https://github.com/tonlabs/tonos-cli) (installation only) – SOON
- TONOS Client Application with CLI interface
-- [TON-SDK](https://github.com/tonlabs/TON-SDK)
- Core SDK Library. We plan to add some useful functionality like keys generation, address conversion, support of deploy, get methods, etc. from CLI and IDE
+- [TestSuite4](https://github.com/tonlabs/TestSuite4) – **SOON**
+ Python lightweight framework for Solidity testing
+- [tonos-cli](https://github.com/tonlabs/tonos-cli) – **SOON** (installation only)
+ Command line tool for TON OS
+- [TON-SDK](https://github.com/tonlabs/TON-SDK) - **SOON**
+ Core SDK Library features.
TONDEV can be extended with other tools following the [instructions of integration](#tondev-extensibility).
@@ -175,10 +176,13 @@ Learn more about creating your own controller: [Creating Controller](docs/creati
## Backlog
+### Debot
+- Support of debot test chat(browser for debot testing),
+- Debot publishing, etc.
+
### Solidity
-- syntax highlighting - Q1 2021
-- support other compilation and linking options
+- Support other compilation and linking options
### C/C++
@@ -186,11 +190,18 @@ Learn more about creating your own controller: [Creating Controller](docs/creati
### TS4
-- debug contracts with TS framework and tools
+- Debug contracts with TS framework and tools
### SDK
- Create and run Web Demo DApp with one command
+- Generate keys
+- Calculate addresses
+- Estimate deploy fees
+- Deploy contracts,
+- Run on-chain methods
+- Run get-methods
+- Convert addresses, etc.
### Network support
@@ -199,6 +210,3 @@ Q1 2021:
- Connect to networks: main.ton.dev, net.ton.dev, local network
- Add a custom network
- Setup network giver
-- Deploy to network
-
-### etc
From 0aed107e811610a7fb1036c4a75d6430b55b88cd Mon Sep 17 00:00:00 2001
From: Michael Vlasov
Date: Fri, 26 Feb 2021 11:55:38 +0500
Subject: [PATCH 17/24] NEW: print usage format NEW: se info format FIX: se
commands failed when tondev home folder is missing.
---
src/cli/index.ts | 46 ++++++++++++++-------------------
src/controllers/js/index.ts | 2 +-
src/controllers/se/commands.ts | 46 +++++++++++++++++++--------------
src/controllers/se/index.ts | 2 +-
src/controllers/se/installer.ts | 4 +++
src/core/utils.ts | 24 +++++++++++++++++
6 files changed, 77 insertions(+), 47 deletions(-)
diff --git a/src/cli/index.ts b/src/cli/index.ts
index 0670754..5a4375e 100644
--- a/src/cli/index.ts
+++ b/src/cli/index.ts
@@ -1,6 +1,6 @@
import { Command, CommandArg, ToolController } from "../core";
import { controllers } from "../controllers";
-import { consoleTerminal } from "../core/utils";
+import { consoleTerminal, formatTable } from "../core/utils";
import * as fs from "fs";
import * as path from "path";
@@ -70,45 +70,39 @@ export function printCommandUsage(controller: ToolController, command: Command)
console.log(`Use: tondev ${controller.name} ${command.name}${usageArgs}`);
if (args.length > 0) {
console.log("Args:");
- let colWidth = options.reduce((w, x) => Math.max(w, x.name.length), 0);
- args.forEach(x => {
- console.log(` ${x.name.padEnd(colWidth)} ${x.title ?? ""}`);
- });
+ console.log(formatTable(args.map(x => [" ", x.name, x.title])));
}
console.log("Options:");
console.log(` --help, -h Show command usage`);
- let colWidth = options.reduce((w, x) => Math.max(w, x.name.length), 0);
- options.forEach(x => {
- console.log(` --${x.name.padEnd(colWidth)} ${x.title ?? ""}`);
- });
+ console.log(formatTable(options.map(x => [" ", `--${x.name}`, x.title])));
return;
}
-export function printUsage(useController?: ToolController, useCommand?: Command) {
+export function printControllerUsage(controller: ToolController) {
+ const commands: [string, Command][] = controller.commands
+ .map(x => [`${controller.name} ${x.name}`, x]);
+ console.log(formatTable(commands.map(x => [" ", x[0], x[1].title])));
+}
+
+export function printUsage(controller?: ToolController, command?: Command) {
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "..", "..", "package.json"), "utf8"));
console.log(`TONDev Version: ${pkg.version}`);
- if (useController && useCommand) {
- printCommandUsage(useController, useCommand);
+ if (controller && command) {
+ printCommandUsage(controller, command);
return;
}
- console.log(`Use: tondev ${useController?.name ?? "tool"} ${useCommand?.name ?? "command"} args [options]`);
+ console.log(`Use: tondev ${controller?.name ?? "tool"} ${command?.name ?? "command"} args [options]`);
console.log(`Options:`);
console.log(` --help, -h Show command usage`);
- console.log("Commands:");
- const commands: [string, Command][] = [];
+ if (controller) {
+ console.log("Commands:");
+ printControllerUsage(controller);
+ return;
+ }
for (const controller of controllers) {
- for (const command of controller.commands) {
- if ((useController === undefined || useController === controller)
- && (useCommand === undefined || useCommand === command)) {
- commands.push([`${controller.name} ${command.name}`, command])
- }
- }
+ console.log(`\n${controller.title ?? controller.name} Commands:\n`);
+ printControllerUsage(controller);
}
- let colWidth = commands.reduce((w, x) => Math.max(w, x[0].length), 0);
- commands.forEach(x => {
- console.log(` ${x[0].padEnd(colWidth)} ${x[1].title ?? ""}`);
- });
- return;
}
function missingArgError(arg: CommandArg): Error {
diff --git a/src/controllers/js/index.ts b/src/controllers/js/index.ts
index c1efa8c..6e53a0e 100644
--- a/src/controllers/js/index.ts
+++ b/src/controllers/js/index.ts
@@ -3,6 +3,6 @@ import {ToolController} from "../../core";
export const JsApps: ToolController = {
name: "js",
- title: "JS TON Applications",
+ title: "JS Apps",
commands: [jsCreateCommand],
};
diff --git a/src/controllers/se/commands.ts b/src/controllers/se/commands.ts
index d455740..1c5feff 100644
--- a/src/controllers/se/commands.ts
+++ b/src/controllers/se/commands.ts
@@ -10,6 +10,7 @@ import {
} from "./installer";
import { Command, CommandArg, Terminal } from "../../core";
import { ContainerDef, ContainerStatus, DevDocker } from "./docker";
+import { formatTable } from "../../core/utils";
export const instanceArg: CommandArg = {
name: "instance",
@@ -26,38 +27,45 @@ async function controlInstances(
await control(new DevDocker(), defs);
}
-
export const seInfoCommand: Command = {
name: "info",
- title: "Show TON SE Info",
+ title: "Show SE Info",
args: [instanceArg],
async run(terminal: Terminal, args: { instance: string }): Promise {
const docker = new DevDocker();
+ const table: any[][] = [[
+ "Instance",
+ "State",
+ "Version",
+ "GraphQL Port",
+ "ArangoDB Port",
+ "Docker Container",
+ "Docker Image",
+ ]]
for (const instance of await filterInstances(args.instance)) {
const info = await getInstanceInfo(docker, instance);
- terminal.log(`${instance.name}: ${info.state}`);
- terminal.log(` Config: --version ${instance.version} --port ${instance.port} --db-port ${instance.dbPort ?? "none"}`);
- terminal.log(` Docker: ${info.docker.container} (${info.docker.image})`);
+ table.push([
+ instance.name,
+ info.state,
+ instance.version,
+ instance.port,
+ instance.dbPort,
+ info.docker.container,
+ info.docker.image,
+ ]);
}
+ terminal.log(formatTable(table, { headerSeparator: true }))
},
};
export const seVersionCommand: Command = {
name: "version",
- title: "Show Node SE Version",
- args: [{
- name: "available",
- type: "string",
- defaultValue: "false",
- title: "Show available versions",
- }],
- async run(terminal: Terminal, args: { available: string }): Promise {
+ title: "Show SE Versions",
+ async run(terminal: Terminal, _args: {}): Promise {
for (const instance of (await getConfig()).instances) {
terminal.log(`${instance.name}: ${instance.version}`);
}
- if (args.available === "true") {
- terminal.log(`Available: ${(await getVersions()).join(", ")}`);
- }
+ terminal.log(`Available Versions: ${(await getVersions()).join(", ")}`);
},
};
@@ -148,7 +156,7 @@ export const seSetCommand: Command = {
}): Promise {
const config = await getConfig();
const docker = new DevDocker();
-
+
let version: string | undefined = undefined;
if (args.version !== "") {
if (args.version.toLowerCase() === "latest") {
@@ -160,7 +168,7 @@ export const seSetCommand: Command = {
version = args.version;
}
}
-
+
let port: number | undefined = undefined;
if (args.port !== "") {
port = Number.parseInt(args.port);
@@ -168,7 +176,7 @@ export const seSetCommand: Command = {
throw new Error(`Invalid port: ${args.port}`);
}
}
-
+
let dbPort: number | "none" | undefined = undefined;
if (args["db-port"] !== "") {
if (args["db-port"].toLowerCase() === "none") {
diff --git a/src/controllers/se/index.ts b/src/controllers/se/index.ts
index 4e428a4..81dd110 100644
--- a/src/controllers/se/index.ts
+++ b/src/controllers/se/index.ts
@@ -11,7 +11,7 @@ import {
export const SE: ToolController = {
name: "se",
- title: "Node SE",
+ title: "SE",
commands: [
seInfoCommand,
seVersionCommand,
diff --git a/src/controllers/se/installer.ts b/src/controllers/se/installer.ts
index 5e2db96..c5a9f81 100644
--- a/src/controllers/se/installer.ts
+++ b/src/controllers/se/installer.ts
@@ -93,6 +93,10 @@ export async function getConfig(): Promise {
}
export async function setConfig(config: SEConfig) {
+ const configDir = path.dirname(configPath());
+ if (!fs.existsSync(configDir)) {
+ fs.mkdirSync(configDir, { recursive: true });
+ }
fs.writeFileSync(configPath(), JSON.stringify(config, undefined, " "), "utf8");
}
diff --git a/src/core/utils.ts b/src/core/utils.ts
index 6b43511..fc85d0a 100644
--- a/src/core/utils.ts
+++ b/src/core/utils.ts
@@ -263,3 +263,27 @@ function toIdentifier(s: string): string {
export function userIdentifier(): string {
return toIdentifier(os.userInfo().username).toLowerCase();
}
+
+function toString(value: any): string {
+ return value === null || value === undefined ? "" : value.toString();
+}
+
+export function formatTable(rows: any[][], options?: { headerSeparator?: boolean }): string {
+ const widths: number[] = [];
+ const updateWidth = (value: any, i: number) => {
+ const width = toString(value).length;
+ while (widths.length <= i) {
+ widths.push(0);
+ }
+ widths[i] = Math.max(widths[i], width);
+ };
+ rows.forEach(x => x.forEach(updateWidth));
+ const formatValue = (value: any, i: number) => toString(value).padEnd(widths[i]);
+ const formatRow = (row: any[]) => row.map(formatValue).join(" ").trimEnd();
+ const lines = rows.map(formatRow);
+ if (options?.headerSeparator) {
+ const separator = formatRow(widths.map(x => "-".repeat(x)));
+ lines.splice(1, 0, separator);
+ }
+ return lines.join("\n");
+}
From 5259faa1a83a3a527ba40ceb48795bf79c263e39 Mon Sep 17 00:00:00 2001
From: elasticLove1
Date: Fri, 26 Feb 2021 12:34:31 +0300
Subject: [PATCH 18/24] tonos se docs
---
.gitignore | 1 +
README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 3315bbc..7033300 100644
--- a/.gitignore
+++ b/.gitignore
@@ -108,3 +108,4 @@ dist
examples/sol/package-lock.json
examples/sol/Hello.abi.json
examples/sol/Hello.tvc
+README.html
diff --git a/README.md b/README.md
index 11fb4ad..a150ad2 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,14 @@ Download and install all the core [TON.DEV](https://docs.ton.dev/86757ecb2/p/04a
- [Compile](#compile)
- [Version](#version)
- [Update](#update-1)
+ - [TON OS Startup Edition(SE)](#ton-os-startup-editionse)
+ - [Start](#start)
+ - [Version](#version-1)
+ - [Set](#set)
+ - [Reset](#reset)
+ - [Update](#update-2)
+ - [Stop](#stop)
+ - [Info](#info)
- [SDK](#sdk)
- [Create Demo Project](#create-demo-project)
- [TONDEV Extensibility](#tondev-extensibility)
@@ -39,7 +47,6 @@ Download and install all the core [TON.DEV](https://docs.ton.dev/86757ecb2/p/04a
- [TS4](#ts4)
- [SDK](#sdk-1)
- [Network support](#network-support)
- - [etc](#etc)
## What is TONDEV?
@@ -153,6 +160,64 @@ This command updates the compiler to the latest version.
tondev sol update
```
+### TON OS Startup Edition(SE)
+
+#### Start
+This command starts the TON OS SE container (Docker must be launched). When executed for the first time downloads the latest SE image
+from dockerhub.
+
+```shell
+tondev se start
+```
+
+#### Version
+This command shows the default TON OS SE version and list of other available versions.
+
+```shell
+tondev se version
+
+default: 0.24.12
+Available Versions: 0, 0.24, 0.24.5, 0.24.6, 0.24.8, 0.24.9, 0.24.10, 0.24.11, 0.24.12, latest
+```
+
+#### Set
+This command switches tonon se to the specified version and downloads it, it is missing.
+
+```shell
+tondev se set 0.24.11
+```
+
+#### Reset
+This command resets the TON OS SE container (Docker must be launched) - restarts it from scratch with a clean database.
+
+```shell
+tondev se reset
+```
+#### Update
+This command downloads the latest TON OS SE image (Docker must be launched) and starts it.
+
+```shell
+tondev se update
+```
+
+#### Stop
+This command stops TON OS SE container.
+
+```shell
+tondev se stop
+```
+
+#### Info
+This command shows info about the downloaded versions.
+
+```shell
+tondev se info
+
+Instance State Version GraphQL Port ArangoDB Port Docker Container Docker Image
+-------- ------- ------- ------------ ------------- -------------------------- --------------------------
+default running 0.24.12 2020 tonlabs-tonos-se-ekaterina tonlabs/local-node:0.24.12
+```
+
### SDK
#### Create Demo Project
From a8c2701c420eccf2d02976f0ee5735bab2991ac9 Mon Sep 17 00:00:00 2001
From: Michael Vlasov
Date: Fri, 26 Feb 2021 14:55:39 +0500
Subject: [PATCH 19/24] FIX: default graphql port has changed to 80 FIX:
instance filter validates specified names FIX: set command suggests if user
has not specified any parameter
---
src/cli/index.ts | 3 ++
src/controllers/se/commands.ts | 55 +++++++++++++++++----------------
src/controllers/se/installer.ts | 28 ++++++++++-------
3 files changed, 49 insertions(+), 37 deletions(-)
diff --git a/src/cli/index.ts b/src/cli/index.ts
index 5a4375e..a5fb1eb 100644
--- a/src/cli/index.ts
+++ b/src/cli/index.ts
@@ -115,6 +115,9 @@ function getArgValue(arg: CommandArg, commandLine: CommandLine): string | undefi
if (value !== undefined) {
return value;
}
+ if (arg.defaultValue !== undefined) {
+ return arg.defaultValue;
+ }
throw missingArgError(arg);
}
let value = commandLine.options[arg.name];
diff --git a/src/controllers/se/commands.ts b/src/controllers/se/commands.ts
index 1c5feff..6ebded8 100644
--- a/src/controllers/se/commands.ts
+++ b/src/controllers/se/commands.ts
@@ -1,11 +1,11 @@
import {
+ filterConfigInstances,
filterInstances,
getConfig,
getInstanceInfo,
getLatestVersion,
getVersions,
instanceContainerDef,
- isInstanceMatched,
setConfig
} from "./installer";
import { Command, CommandArg, Terminal } from "../../core";
@@ -13,6 +13,7 @@ import { ContainerDef, ContainerStatus, DevDocker } from "./docker";
import { formatTable } from "../../core/utils";
export const instanceArg: CommandArg = {
+ isArg: true,
name: "instance",
type: "string",
defaultValue: "*",
@@ -23,7 +24,7 @@ async function controlInstances(
instanceFilter: string,
control: (docker: DevDocker, defs: ContainerDef[]) => Promise
): Promise {
- const defs: ContainerDef[] = (await filterInstances(instanceFilter)).map(instanceContainerDef);
+ const defs: ContainerDef[] = (await filterConfigInstances(instanceFilter)).map(instanceContainerDef);
await control(new DevDocker(), defs);
}
@@ -42,7 +43,7 @@ export const seInfoCommand: Command = {
"Docker Container",
"Docker Image",
]]
- for (const instance of await filterInstances(args.instance)) {
+ for (const instance of await filterConfigInstances(args.instance)) {
const info = await getInstanceInfo(docker, instance);
table.push([
instance.name,
@@ -111,13 +112,11 @@ export const seUpdateCommand: Command = {
const config = await getConfig();
const latestVersion = await getLatestVersion();
const docker = new DevDocker();
- for (const instance of config.instances) {
- if (isInstanceMatched(instance, args.instance)) {
- instance.version = latestVersion;
- const def = instanceContainerDef(instance);
- await docker.shutdownContainer(terminal, def, ContainerStatus.missing);
- await docker.startupContainer(terminal, def, ContainerStatus.created);
- }
+ for (const instance of filterInstances(config.instances, args.instance)) {
+ instance.version = latestVersion;
+ const def = instanceContainerDef(instance);
+ await docker.shutdownContainer(terminal, def, ContainerStatus.missing);
+ await docker.startupContainer(terminal, def, ContainerStatus.created);
}
setConfig(config);
},
@@ -189,23 +188,27 @@ export const seSetCommand: Command = {
}
}
- for (const instance of config.instances) {
- if (isInstanceMatched(instance, args.instance)) {
- if (version !== undefined) {
- instance.version = version;
- }
- if (port !== undefined) {
- instance.port = port;
- }
- if (dbPort === "none") {
- delete instance.dbPort;
- } else if (dbPort !== undefined) {
- instance.dbPort = dbPort;
- }
- const def = instanceContainerDef(instance);
- await docker.shutdownContainer(terminal, def, ContainerStatus.missing);
- await docker.startupContainer(terminal, def, ContainerStatus.created);
+ const instances = filterInstances(config.instances, args.instance);
+
+ if (version === undefined && port === undefined && dbPort === undefined) {
+ throw new Error("There is nothing to set. You have to specify at least one config parameter. See command help.");
+ }
+
+ for (const instance of instances) {
+ if (version !== undefined) {
+ instance.version = version;
+ }
+ if (port !== undefined) {
+ instance.port = port;
+ }
+ if (dbPort === "none") {
+ delete instance.dbPort;
+ } else if (dbPort !== undefined) {
+ instance.dbPort = dbPort;
}
+ const def = instanceContainerDef(instance);
+ await docker.shutdownContainer(terminal, def, ContainerStatus.missing);
+ await docker.startupContainer(terminal, def, ContainerStatus.created);
}
setConfig(config);
},
diff --git a/src/controllers/se/installer.ts b/src/controllers/se/installer.ts
index c5a9f81..439bf2d 100644
--- a/src/controllers/se/installer.ts
+++ b/src/controllers/se/installer.ts
@@ -7,7 +7,7 @@ import { ContainerDef, DevDocker } from "./docker";
import Dockerode from "dockerode";
const DEFAULT_INSTANCE_NAME = "default";
-const DEFAULT_INSTANCE_PORT = 2020;
+const DEFAULT_INSTANCE_PORT = 80;
const DOCKER_IMAGE_NAME = "tonlabs/local-node";
const DOCKER_CONTAINER_NAME_PREFIX = "tonlabs-tonos-se";
@@ -27,7 +27,7 @@ type SEInstanceConfig = {
* Port on localhost used to expose GraphQL API
* GraphQL API is accessible through http://localhost:port/graphql
* Node Requests API is accessible through http://localhost:port/topics/requests
- * Default value: 2020
+ * Default value: 80
*/
port: number,
/**
@@ -100,20 +100,26 @@ export async function setConfig(config: SEConfig) {
fs.writeFileSync(configPath(), JSON.stringify(config, undefined, " "), "utf8");
}
-export function isInstanceMatched(instance: SEInstanceConfig, instanceFilter: string): boolean {
- return instanceFilter === "*" || instanceFilter.toLowerCase() === instance.name.toLowerCase();
-}
-
-export async function filterInstances(instanceFilter: string): Promise {
+export function filterInstances(instances: SEInstanceConfig[], filter: string): SEInstanceConfig[] {
+ const names = filter.toLowerCase().split(",").map(x => x.trim()).filter(x => x !== "");
+ if (names.includes("*")) {
+ return instances;
+ }
const filtered: SEInstanceConfig[] = [];
- for (const instance of (await getConfig()).instances) {
- if (isInstanceMatched(instance, instanceFilter)) {
- filtered.push(instance);
+ names.forEach(name => {
+ const instance = instances.find(x => x.name.toLowerCase() === name);
+ if (instance === undefined) {
+ throw new Error(`Instance \"${name}\" is not found`);
}
- }
+ filtered.push(instance);
+ });
return filtered;
}
+export async function filterConfigInstances(filter: string): Promise {
+ return filterInstances(await (await getConfig()).instances, filter);
+}
+
export function instanceContainerDef(instance: SEInstanceConfig): ContainerDef {
const requiredImage = `${DOCKER_IMAGE_NAME}:${instance.version}`;
const suffix = instance.name !== DEFAULT_INSTANCE_NAME ? `-${instance.name}` : '';
From 713dd212ae2288427e2f6f8a9025a40f83964da7 Mon Sep 17 00:00:00 2001
From: Michael Vlasov
Date: Fri, 26 Feb 2021 17:34:43 +0500
Subject: [PATCH 20/24] NEW: preserve se instance state after config has
updated
---
src/controllers/se/commands.ts | 64 ++++++++-------------------------
src/controllers/se/installer.ts | 43 +++++++++++++++++++---
2 files changed, 54 insertions(+), 53 deletions(-)
diff --git a/src/controllers/se/commands.ts b/src/controllers/se/commands.ts
index 6ebded8..e315f76 100644
--- a/src/controllers/se/commands.ts
+++ b/src/controllers/se/commands.ts
@@ -1,12 +1,13 @@
import {
filterConfigInstances,
- filterInstances,
getConfig,
getInstanceInfo,
getLatestVersion,
getVersions,
instanceContainerDef,
- setConfig
+ PORT_NONE,
+ SEInstanceConfig,
+ updateConfig
} from "./installer";
import { Command, CommandArg, Terminal } from "../../core";
import { ContainerDef, ContainerStatus, DevDocker } from "./docker";
@@ -109,16 +110,9 @@ export const seUpdateCommand: Command = {
title: "Update SE Instance Version",
args: [instanceArg],
async run(terminal: Terminal, args: { instance: string }): Promise {
- const config = await getConfig();
- const latestVersion = await getLatestVersion();
- const docker = new DevDocker();
- for (const instance of filterInstances(config.instances, args.instance)) {
- instance.version = latestVersion;
- const def = instanceContainerDef(instance);
- await docker.shutdownContainer(terminal, def, ContainerStatus.missing);
- await docker.startupContainer(terminal, def, ContainerStatus.created);
- }
- setConfig(config);
+ await updateConfig(terminal, args.instance, {
+ version: await getLatestVersion(),
+ });
},
};
@@ -153,63 +147,35 @@ export const seSetCommand: Command = {
"db-port": string,
instance: string
}): Promise {
- const config = await getConfig();
- const docker = new DevDocker();
-
- let version: string | undefined = undefined;
+ const updates: Partial = {};
if (args.version !== "") {
if (args.version.toLowerCase() === "latest") {
- version = await getLatestVersion();
+ updates.version = await getLatestVersion();
} else {
if (!(await getVersions()).includes(args.version)) {
throw new Error(`Invalid version: ${args.version}`);
}
- version = args.version;
+ updates.version = args.version;
}
}
- let port: number | undefined = undefined;
if (args.port !== "") {
- port = Number.parseInt(args.port);
- if (port === undefined) {
+ updates.port = Number.parseInt(args.port);
+ if (updates.port === undefined) {
throw new Error(`Invalid port: ${args.port}`);
}
}
- let dbPort: number | "none" | undefined = undefined;
if (args["db-port"] !== "") {
if (args["db-port"].toLowerCase() === "none") {
- dbPort = "none";
+ updates.dbPort = PORT_NONE;
} else {
- dbPort = Number.parseInt(args["db-port"]);
- if (port === undefined) {
+ updates.dbPort = Number.parseInt(args["db-port"]);
+ if (updates.port === undefined) {
throw new Error(`Invalid db-port: ${args["db-port"]}`);
}
}
}
-
- const instances = filterInstances(config.instances, args.instance);
-
- if (version === undefined && port === undefined && dbPort === undefined) {
- throw new Error("There is nothing to set. You have to specify at least one config parameter. See command help.");
- }
-
- for (const instance of instances) {
- if (version !== undefined) {
- instance.version = version;
- }
- if (port !== undefined) {
- instance.port = port;
- }
- if (dbPort === "none") {
- delete instance.dbPort;
- } else if (dbPort !== undefined) {
- instance.dbPort = dbPort;
- }
- const def = instanceContainerDef(instance);
- await docker.shutdownContainer(terminal, def, ContainerStatus.missing);
- await docker.startupContainer(terminal, def, ContainerStatus.created);
- }
- setConfig(config);
+ await updateConfig(terminal, args.instance, updates);
},
};
\ No newline at end of file
diff --git a/src/controllers/se/installer.ts b/src/controllers/se/installer.ts
index 439bf2d..d3a9dfa 100644
--- a/src/controllers/se/installer.ts
+++ b/src/controllers/se/installer.ts
@@ -1,20 +1,21 @@
import * as path from "path";
import * as fs from "fs";
-import { tondevHome } from "../../core";
+import { Terminal, tondevHome } from "../../core";
import { httpsGetJson, userIdentifier, versionToNumber } from "../../core/utils";
-import { ContainerDef, DevDocker } from "./docker";
+import { ContainerDef, ContainerStatus, DevDocker } from "./docker";
import Dockerode from "dockerode";
const DEFAULT_INSTANCE_NAME = "default";
const DEFAULT_INSTANCE_PORT = 80;
const DOCKER_IMAGE_NAME = "tonlabs/local-node";
const DOCKER_CONTAINER_NAME_PREFIX = "tonlabs-tonos-se";
+export const PORT_NONE = -1;
/**
* SE instance config
*/
-type SEInstanceConfig = {
+export type SEInstanceConfig = {
/**
* Instance name
*/
@@ -92,7 +93,7 @@ export async function getConfig(): Promise {
return config;
}
-export async function setConfig(config: SEConfig) {
+export function setConfig(config: SEConfig) {
const configDir = path.dirname(configPath());
if (!fs.existsSync(configDir)) {
fs.mkdirSync(configDir, { recursive: true });
@@ -181,3 +182,37 @@ export async function getInstanceInfo(docker: DevDocker, instance: SEInstanceCon
};
}
+
+export async function updateConfig(terminal: Terminal, filter: string, updates: Partial): Promise {
+ const config = await getConfig();
+ const docker = new DevDocker();
+
+ const instances = filterInstances(config.instances, filter);
+
+ if (updates.version === undefined && updates.port === undefined && updates.dbPort === undefined) {
+ throw new Error("There is nothing to set. You have to specify at least one config parameter. See command help.");
+ }
+
+ for (const instance of instances) {
+ if (updates.version !== undefined) {
+ instance.version = updates.version;
+ }
+ if (updates.port !== undefined) {
+ instance.port = updates.port;
+ }
+ if (updates.dbPort === PORT_NONE) {
+ delete instance.dbPort;
+ } else if (updates.dbPort !== undefined) {
+ instance.dbPort = updates.dbPort;
+ }
+ const def = instanceContainerDef(instance);
+ const info = await getInstanceInfo(docker, instance);
+ await docker.shutdownContainer(terminal, def, ContainerStatus.missing);
+ await docker.startupContainer(
+ terminal,
+ def,
+ info.state === "running" ? ContainerStatus.running : ContainerStatus.created,
+ );
+ }
+ setConfig(config);
+}
From 123291ab42ad51687cf44788ad90d7f9680f0c6e Mon Sep 17 00:00:00 2001
From: elasticLove1
Date: Fri, 26 Feb 2021 17:08:19 +0300
Subject: [PATCH 21/24] Update README.md
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index a150ad2..70d7d83 100644
--- a/README.md
+++ b/README.md
@@ -181,10 +181,11 @@ Available Versions: 0, 0.24, 0.24.5, 0.24.6, 0.24.8, 0.24.9, 0.24.10, 0.24.11, 0
```
#### Set
-This command switches tonon se to the specified version and downloads it, it is missing.
+This command switches tonon se to the specified version and port and downloads it, it is missing.
+Attention! This command does not start TON OS SE, you need to run `start` command separately.
```shell
-tondev se set 0.24.11
+tondev se set --version 0.24.11 --port 2020
```
#### Reset
From 3e1cfbd647390747c1cabdc5afd81fec4e5cfb85 Mon Sep 17 00:00:00 2001
From: Ekaterina Pantaz <52739957+elasticLove1@users.noreply.github.com>
Date: Fri, 26 Feb 2021 17:09:37 +0300
Subject: [PATCH 22/24] Update README.md
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 70d7d83..09e647b 100644
--- a/README.md
+++ b/README.md
@@ -181,8 +181,8 @@ Available Versions: 0, 0.24, 0.24.5, 0.24.6, 0.24.8, 0.24.9, 0.24.10, 0.24.11, 0
```
#### Set
-This command switches tonon se to the specified version and port and downloads it, it is missing.
-Attention! This command does not start TON OS SE, you need to run `start` command separately.
+This command switches TON OS SE to the specified version and port and downloads it, if it is missing.
+**Attention! This command does not start TON OS SE, you need to run `start` command separately.**
```shell
tondev se set --version 0.24.11 --port 2020
From 73275a5567fa46bce1a22738ef63e67b0d1d66e6 Mon Sep 17 00:00:00 2001
From: Ekaterina Pantaz <52739957+elasticLove1@users.noreply.github.com>
Date: Fri, 26 Feb 2021 17:10:12 +0300
Subject: [PATCH 23/24] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 09e647b..42b4fea 100644
--- a/README.md
+++ b/README.md
@@ -181,7 +181,7 @@ Available Versions: 0, 0.24, 0.24.5, 0.24.6, 0.24.8, 0.24.9, 0.24.10, 0.24.11, 0
```
#### Set
-This command switches TON OS SE to the specified version and port and downloads it, if it is missing.
+This command switches TON OS SE to the specified version and port and downloads it, if it is missing.
**Attention! This command does not start TON OS SE, you need to run `start` command separately.**
```shell
From 0b26b4c2e7b9bb6fd63a8d4ae08ac056acaaaf51 Mon Sep 17 00:00:00 2001
From: Sergei Voronezhskii
Date: Fri, 26 Feb 2021 19:23:51 +0300
Subject: [PATCH 24/24] Github Action npm publish
---
.github/workflows/npmpublish.yml | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 .github/workflows/npmpublish.yml
diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml
new file mode 100644
index 0000000..fe79f55
--- /dev/null
+++ b/.github/workflows/npmpublish.yml
@@ -0,0 +1,18 @@
+name: npm publish
+
+on:
+ release:
+ types: [published]
+
+jobs:
+ publish-npm:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v1
+ with:
+ node-version: 12
+ registry-url: https://registry.npmjs.org/
+ - run: npm publish
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}