Skip to content

Commit

Permalink
Version 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
d3p authored Apr 29, 2021
2 parents 2f94754 + e80792e commit 5501c4f
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 44 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

All notable changes to this project will be documented in this file.

## [0.5.0] - 2021-04-08
## [0.6.0] - 2021-04-28

### New
- `clang` controller for C++ compiler:
- `ts4` [TestSuite4](README.md#testsuite4) framework for contract testing is supported: install, manage versions, create test template, run tests.

## [0.5.0] - 2021-04-23

### New
- `clang` controller for [C++ compiler](https://github.com/tonlabs/TON-Compiler):
install, compile with 1 command, manage versions, etc.
- `signer` controller for signer registry management:
generate keys, import keys and mnemonics, specify default signer, etc.
Expand Down
105 changes: 65 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

**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)
[![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](https://docs.ton.dev/86757ecb2/p/04a4ba-) components in one click and access them from a single interface.
Expand Down Expand Up @@ -35,7 +35,7 @@ Download and install all the core [TON.DEV](https://docs.ton.dev/86757ecb2/p/04a
- [Compile](#compile-1)
- [Version](#version-1)
- [Update](#update-2)
- [Set](#set-1)
- [Set](#set-1)
- [TON OS Startup Edition(SE)](#ton-os-startup-editionse)
- [Start](#start)
- [Version](#version-2)
Expand All @@ -54,6 +54,12 @@ Download and install all the core [TON.DEV](https://docs.ton.dev/86757ecb2/p/04a
- [Version](#version-3)
- [Set](#set-3)
- [Update](#update-4)
- [TestSuite4](#testsuite4)
- [Version](#version-4)
- [Install](#install-2)
- [Update](#update-5)
- [Create](#create)
- [Run](#run)
- [Signer Tool](#signer-tool)
- [Add a signer with randomly generated keys](#add-a-signer-with-randomly-generated-keys)
- [Add a signer with specific keys](#add-a-signer-with-specific-keys)
Expand All @@ -79,10 +85,6 @@ Download and install all the core [TON.DEV](https://docs.ton.dev/86757ecb2/p/04a
- [Backlog](#backlog)
- [Debot](#debot)
- [Solidity](#solidity-1)
- [C/C++](#cc)
- [TS4](#ts4)
- [SDK](#sdk-1)
- [Network support](#network-support)

## What is TONDEV?

Expand All @@ -99,7 +101,7 @@ Each component is downloaded and installed automatically for the target platform
- [C/C++ Compiler](https://github.com/tonlabs/TON-Compiler)
- [TON OS Startup Edition](https://github.com/tonlabs/tonos-se)
Local blockchain for development and testing
- [TestSuite4](https://github.com/tonlabs/TestSuite4)**soon as part of tondev**
- [TestSuite4](https://github.com/tonlabs/TestSuite4)
Python lightweight framework for contract testing
- [tonos-cli](https://github.com/tonlabs/tonos-cli)
Command line tool for TON OS. TONDEV helps with installation and version management.
Expand All @@ -115,18 +117,14 @@ TONDEV can be extended with other tools following the [instructions of integrati
- [`Node.js`](https://nodejs.org/) >= 10.x installed
- (optional) [`Docker`](https://www.docker.com/) >= 19.x installed
- Solidity compiler requires VC++ Runtime on Windows. You can install it from [the latest supported Visual C++ downloads](https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0).
- You need to be root (or use sudo) to be able to install globally on macOS and Linux.

### Install

```shell
npm i -g tondev
```
or
```shell
sudo npm i -g tondev
```

If you see an EACCES error when you try to install a package globally on Mac or Linux, [please see this instruction](https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally)

### Update

Expand Down Expand Up @@ -433,6 +431,60 @@ This command updates tonos-cli version to the latest
tondev tonos-cli update
```


### TestSuite4

TestSuite4 is a framework designed to simplify development and testing of TON Contracts. It contains lightweight blockchain emulator making it easy to develop contracts in a TDD-friendly style.

For more information, visit [TestSuite4's documentation](https://tonlabs.github.io/TestSuite4/).

:information_source: `Python 3.6 - 3.9` and `pip` required.

#### Version

This command shows the currently installed and available TestSuite4 framework versions.

```
tondev ts4 version
```

#### Install

This command installs (using `pip`) TestSuite4's latest or selected version and downloads them if needed.

```bash
tondev ts4 install # install latest version

tondev ts4 install 0.2.0 # install version 0.2.0
```

#### Update

This command updates TestSuite4 to the latest version.

```
tondev ts4 update
```

#### Create

This command creates a TestSuite4's template of the test (`TestName.py`).

```bash
tondev ts4 create TestName

tondev ts4 create TestName --folder tests # creates tests/TestName.py (folder must exist)
```

#### Run

This command runs selected test (`TestName.py`).

```
tondev ts4 run TestName
```


### Signer Tool

Signer registry is a centralized place where you can store your development keys.
Expand Down Expand Up @@ -1105,35 +1157,8 @@ 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.
- Debot deployment
### Solidity
- Support other compilation and linking options
### C/C++
- Integrate C/C++ compiler - easily install and compile C/C++ contracts
### TS4
- Debug contracts with TS framework and tools
### SDK
- Generate keys
- Calculate addresses
- Estimate deploy fees
- Deploy contracts,
- Run on-chain methods
- Run get-methods
- Convert addresses, etc.
### Network support
Q1 2021:
- Connect to networks: main.ton.dev, net.ton.dev, local network
- Add a custom network
- Setup network giver
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tondev",
"version": "0.5.0",
"version": "0.6.0",
"description": "TON Dev Environment",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Solidity} from "./solidity";
import {JsApps} from "./js";
import {SE} from "./se";
import {TONOS} from "./tonos-cli";
import {TestSuite4} from "./ts4";
import {
Command,
matchName,
Expand All @@ -23,6 +24,7 @@ export const controllers = [
Contract,
JsApps,
TONOS,
TestSuite4,
];

export function findControllerAndCommandByAlias(
Expand Down
78 changes: 78 additions & 0 deletions src/controllers/ts4/components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import os from 'os'
import { Component, Terminal } from '../../core'
import { compareVersions, httpsGetJson, nullTerminal, run } from '../../core/utils'

const TS4_PKG = 'tonos-ts4'
const PYPI = `https://pypi.org/pypi/${TS4_PKG}/json`
const currentOS = os.type()
const [PYTHON, PIP] = ['Linux', 'Darwin'].includes(currentOS)
? ['python3', 'pip3']
: ['python', 'pip']

export const components = {
ts4: new class extends Component {
async getCurrentVersion(): Promise<string> {
let version

try {
const output = await run(PIP, ['show', TS4_PKG], {}, nullTerminal)
version = output.split(os.EOL).find(line => (/^Version:/).exec(line))
} catch {
// TODO handle the lack of 'pip'
console.debug(`Package ${TS4_PKG} not found`)
}
return version ? version.split(/:\s*/)[1] : ''
}

async ensureVersion(
terminal: Terminal,
force: boolean,
requiredVersion?: string,
): Promise<boolean> {
const current = await this.getCurrentVersion();
if (!force && current !== "" && !requiredVersion) {
return false;
}
let version = (requiredVersion ?? "latest").toLowerCase();
if (!force && version === current) {
return false;
}
const available = await this.loadAvailableVersions();
if (version === "latest") {
version = available[0];
} else {
if (!available.includes(version)) {
throw new Error(`Invalid ${this.name} version ${version}`);
}
}
if (!force && version === current) {
return false;
}
const pkg = TS4_PKG + (version ? `==${version}` : '')
const output = await run(PIP, ['install', '-U', pkg], {}, nullTerminal)
const successPattern = `Successfully installed ${TS4_PKG}-${version}`
const isOk = output.split(os.EOL).find(line => line === successPattern)

if (!isOk) {
terminal.writeError(output)
return false
} else {
terminal.log(successPattern)
}

return true
}

async loadAvailableVersions(): Promise<string[]> {
const info = await httpsGetJson(PYPI)
const versions = Object.keys(info.releases)
.filter(v => (/^(\d+\.){2}\d+$/).test(v))
.sort(compareVersions)
.reverse()
return versions.length < 10 ? versions : [...versions.slice(0, 10), "..."]
}
}('', PYTHON, {
executable: true,
globally: true,
}),
}
99 changes: 99 additions & 0 deletions src/controllers/ts4/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import path from 'path'
import fs from 'fs'
import { Command, Component, Terminal, ToolController } from '../../core'
import { uniqueFilePath } from '../../core/utils'
import { components } from './components'
import { BasicTest } from './snippets'

export const ts4VersionCommand: Command = {
name: "version",
title: "Show installed and available versions",
async run(terminal: Terminal, _args: {}): Promise<void> {
terminal.log(await Component.getInfoAll(components));
},
}

export const ts4InstallCommand: Command = {
name: "install",
title: "Install latest release of TestSuite4",
args: [{
isArg: true,
name: 'version',
type: 'string',
title: 'TestSuite4 version (semver compatible)',
}],
async run(terminal: Terminal, args: { version: string }) {
const versions: {
ts4?: string;
} = {
...(args.version !== "" ? { ts4: args.version } : {}),
}
await Component.setVersions(terminal, false, components, versions)
},
}

export const ts4UpdateCommand: Command = {
name: "update",
title: "Update to the latest version",
async run(terminal: Terminal, _args: {}): Promise<void> {
await Component.updateAll(terminal, true, components)
},
}

export const ts4CreateCommand: Command = {
name: "create",
title: "Create TestSuite4 test",
args: [{
isArg: true,
name: "name",
title: "Test script name",
type: "string",
defaultValue: "Test",
}, {
name: "folder",
type: "folder",
title: "Target folder (current is default)",
}],
async run(terminal: Terminal, args: { name: string, folder: string }) {
const filePath = uniqueFilePath(args.folder, `${args.name}{}.py`)
const text = BasicTest.split("{name}").join(args.name)
fs.writeFileSync(filePath, text)
terminal.log(`TestSuite4 test script ${path.basename(filePath)} created.`)
},
}

export const ts4RunCommand: Command = {
name: 'run',
title: 'Run TestSuite4\'s test',
args: [{
isArg: true,
name: 'file',
type: 'file',
title: 'Test',
nameRegExp: /\.py$/i,
}],
async run(terminal: Terminal, args: { file: string }): Promise<void> {
const ext = path.extname(args.file)
if (ext !== ".py") {
terminal.log(`Choose file *.py`)
return
}
await Component.ensureInstalledAll(terminal, components)
const fileDir = path.dirname(args.file)
const fileName = path.basename(args.file)

await components.ts4.run(terminal, fileDir, [fileName])
},
}

export const TestSuite4: ToolController = {
name: "ts4",
title: "TestSuite4 framework",
commands: [
ts4VersionCommand,
ts4InstallCommand,
ts4UpdateCommand,
ts4CreateCommand,
ts4RunCommand,
],
}
Loading

0 comments on commit 5501c4f

Please sign in to comment.