Skip to content

Commit

Permalink
Merge pull request #90 from tonlabs/1.1.1-rc
Browse files Browse the repository at this point in the history
1.1.1 rc
  • Loading branch information
d3p authored Feb 14, 2022
2 parents c000550 + 1417d3f commit 38c3570
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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

## [1.1.1] - 2022-02-11
### Fixed
- An error "TON Client binary bridge is not set" that occurred when using `js wrap` command as a module

### Improved
- Command parameter parsing when using tondev as a module.
Now, when some unrecognized option is found, an error occurs.
Previously unrecognized option was silently skipped.

## [1.1.0] - 2022-02-09
### New
- If a new version of everdev is available, then the user who executes any `everdev` command will be
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "everdev",
"version": "1.1.0",
"version": "1.1.1",
"description": "Everscale Dev Environment",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
40 changes: 40 additions & 0 deletions src/__tests__/checkArgs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fs from 'fs'
import path from 'path'

import { doneTests, initTests, deleteFolderRecursive } from './init'
import { StringTerminal, runCommand } from '..'

const outPath = path.resolve(__dirname, '..', '..', `${Date.now()}-tmp`)

beforeAll(initTests)
afterAll(doneTests)
beforeEach(() => deleteFolderRecursive(outPath))
afterEach(() => deleteFolderRecursive(outPath))

test('Should create HelloWallet.tvc in user defined output directory', async () => {
const solPath = path.resolve(__dirname, '..', '..', 'contracts', 'HelloWallet.sol')

const terminal = new StringTerminal()
await runCommand(terminal, 'sol compile', {
file: solPath,
outputDir: outPath,
})
expect(terminal.stderr.trim()).toEqual('')

const tvcFile = path.resolve(outPath, 'HelloWallet.tvc')
expect(fs.existsSync(tvcFile)).toBeTruthy()
})

test('Should warn user to use options in camelCase', async () => {
const solPath = path.resolve(__dirname, '..', '..', 'contracts', 'HelloWallet.sol')
const terminal = new StringTerminal()
try {
await runCommand(terminal, 'sol compile', {
file: solPath,
'hello-world': 'hi!',
})
throw Error("This function didn't throw")
} catch (err: any) {
expect(err.message).toMatch(/Unknow option: hello-world/)
}
})
4 changes: 2 additions & 2 deletions src/__tests__/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function writeTempJson(name: string, json: unknown): string {
return writeTempText(name, JSON.stringify(json, undefined, " "));
}

function deleteFiles(files: string[]) {
export function deleteFiles(files: string[]) {
files.forEach((file) => {
if (fs.existsSync(file)) {
fs.unlinkSync(file);
Expand All @@ -64,7 +64,7 @@ export function doneTests() {
everdevDone();
}

function deleteFolderRecursive(directoryPath: string) {
export function deleteFolderRecursive(directoryPath: string) {
if (fs.existsSync(directoryPath)) {
fs.readdirSync(directoryPath).forEach((file) => {
const curPath = path.join(directoryPath, file);
Expand Down
32 changes: 32 additions & 0 deletions src/__tests__/wrap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import path from 'path'

import { doneTests, initTests, deleteFiles } from './init'
import { StringTerminal, runCommand } from '..'

beforeAll(initTests)
afterAll(doneTests)

test('Shoud create HelloWallet.abi.json file', async () => {
const solPath = path.resolve(__dirname, '..', '..', 'contracts', 'HelloWallet.sol')
const terminal = new StringTerminal()
await runCommand(terminal, 'sol compile', {
file: solPath,
})
expect(terminal.stderr.trim()).toEqual('')
})

test('Shoud create HelloWalletContract.js file', async () => {
const wrappedJs = path.resolve(__dirname, '..', '..', 'HelloWalletContract.js')
deleteFiles([wrappedJs])

const terminal = new StringTerminal()
await runCommand(terminal, 'js wrap', {
file: path.resolve(__dirname, '..', '..', 'HelloWallet.abi.json'),
})
expect(terminal.stderr.trim()).toEqual('')

const { HelloWalletContract } = await import(wrappedJs)
expect(typeof HelloWalletContract).toEqual('object')

deleteFiles([wrappedJs])
})
5 changes: 3 additions & 2 deletions src/controllers/contract/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function inputTuple(terminal: Terminal, param: AbiParam): Promise<any> {
while (true) {
const value = await inputLine(terminal, `${param.name} (${param.type})`)
try {
return JSON.parse(value)
return JSON.parse(value)
} catch (err: any) {
terminal.log(err.toString())
}
Expand Down Expand Up @@ -192,5 +192,6 @@ export async function logRunResult(
out_messages: outMessages.filter(x => x?.body_type !== MessageBodyType.Output),
};
terminal.log();
terminal.log(`Execution has finished with result: ${JSON.stringify(details, undefined, " ")}`);
terminal.log('Execution has finished with result:');
terminal.log(JSON.stringify(details, undefined, " "));
}
14 changes: 14 additions & 0 deletions src/controllers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export async function runCommand(terminal: Terminal, name: string, args: any): P
}

const resolvedArgs: any = Object.assign({}, args);
let checkedArgs = Object.keys(resolvedArgs);

for (const arg of command.args ?? []) {
const name = arg.name
.split("-")
Expand All @@ -78,8 +80,20 @@ export async function runCommand(terminal: Terminal, name: string, args: any): P
} else {
throw await missingArgError(arg);
}
} else {
// remove matched element from array
checkedArgs = checkedArgs.filter(k => k !== name);
}
}

if (checkedArgs.length > 0) {
const msg = [`Unknow option: ${checkedArgs[0]}`]
if (checkedArgs[0].includes('-')) {
msg.push(
`You must convert parameters to camelcase, for example "output-dir" to "outputDir"`,
)
}
throw Error(msg.join('\n'))
}
await command.run(terminal, resolvedArgs);
}
3 changes: 3 additions & 0 deletions src/controllers/js/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
import path from "path";
import {TonClient} from "@tonclient/core";
import {resolveContract, writeTextFile} from "../../core/utils";
const {libNode} = require("@tonclient/lib-node");

TonClient.useBinaryLibrary(libNode);

enum ExportFormat {
CommonJs = "commonjs",
Expand Down

0 comments on commit 38c3570

Please sign in to comment.