Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed broken user-defined mocha config for cli testing #24

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ sample-project-typescript/build
*.map
*.js
tsconfig.tsbuildinfo
**/.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ The module provides access to high-level control of transaction flow.
This method allows you to wait until all transactions in the chain are finalized.

```typescript
const transaction = await locklift.transactions.waitFinalized(tokenRoot.methods.deployWallet({...))
const transaction = await locklift.transactions.waitFinalized(tokenRoot.methods.deployWallet({...}))
```

## Full contract state (`locklift.provider.getFullContractState`)
Expand Down
18 changes: 0 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
},
"homepage": "https://github.com/broxus/locklift#readme",
"dependencies": {
"@types/commander": "^2.12.2",
"@types/yargs": "^17.0.13",
"axios": "^0.27.2",
"bignumber.js": "^9.0.1",
Expand All @@ -103,7 +102,7 @@
"ejs": "^3.1.6",
"env-paths": "^2.2.1",
"everscale-crypto": "^0.1.1",
"everscale-inpage-provider": "^0.3.52",
"everscale-inpage-provider": "^0.3.58",
"everscale-standalone-client": "^2.1.16",
"find-node-modules": "^2.1.3",
"fs-extra": "^10.1.0",
Expand Down
19 changes: 6 additions & 13 deletions src/internal/cli/builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type Option = {
build: string;
disableIncludePath: boolean;
contracts: string;
mode?: string;
docs?: string;
include?: string;
};
export class Builder {
private options: Option;
Expand Down Expand Up @@ -166,7 +169,6 @@ export class Builder {
logger.printInfo(`Building ${path}`);

const output = execSyncWrapper(
//@ts-ignore
`cd ${this.options.build} && ${this.config.compilerPath} ./../${path} --${this.options.mode}`,
);

Expand Down Expand Up @@ -198,12 +200,7 @@ export class Builder {
rmWhitespace: true,
},
);
//@ts-ignore
fs.writeFileSync(
//@ts-ignore
resolve(process.cwd(), this.options.docs, "index.md"),
render,
);
fs.writeFileSync(resolve(process.cwd(), this.options.docs || "", "index.md"), render);

logger.printInfo("Docs generated successfully!");
} catch (e) {
Expand All @@ -223,18 +220,14 @@ export class Builder {
// Make them all absolute
.map(c => resolve(process.cwd(), this.options.build, c));
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const docs = [...output.matchAll(this.docRegex)].map(m =>
//@ts-ignore
JSON.parse(m.groups?.doc),
);
const docs = [...output.matchAll(this.docRegex)].map(m => JSON.parse(m.groups?.doc || ""));

return _.zip(contracts, docs).reduce((acc: ParsedDoc[], [contract, doc]: string[]) => {
const [path, name] = contract.split(":");

// Check name matches the "include" pattern and contract is located in the "contracts" dir
if (
//@ts-ignore
name.match(new RegExp(this.options.include)) !== null &&
name.match(new RegExp(this.options.include || "")) !== null &&
path.startsWith(`${process.cwd()}/${this.options.contracts}`)
) {
return [
Expand Down
5 changes: 0 additions & 5 deletions src/internal/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env node
import * as path from "path";

process.env.TS_NODE_PROJECT = path.join(__dirname, "../../tsconfig.json");
process.env.TS_CONFIG_PATHS = "true";

import { program } from "commander";
import init from "./commands/init";
import build from "./commands/build";
Expand Down
7 changes: 6 additions & 1 deletion src/internal/cli/commands/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Command, Option } from "commander";
import Mocha from "mocha";
import "ts-mocha";
import path from "path";
import dirTree from "directory-tree";

Expand All @@ -10,6 +9,11 @@ import * as utils from "../builder/utils";

import { buildStep } from "../steps/build";

require("ts-node").register({
project: path.join(__dirname, "../../../tsconfig.json"),
transpileOnly: !process.env.TS_TYPE_CHECK,
});

const program = new Command();

program
Expand Down Expand Up @@ -49,6 +53,7 @@ program
process.env.TS_NODE_PROJECT = config.mocha?.tsconfig;
process.env.TS_CONFIG_PATHS = "true";
}
require("ts-mocha");
const mocha = new Mocha({ ...config.mocha });

// Run all .js files in tests or only specified tests
Expand Down
2 changes: 1 addition & 1 deletion src/internal/compilerComponentsStore/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getLinkerUrl = ({ version }: { version: string }) =>
const getCompilerUrl = ({ version }: { version: string }) =>
`https://binaries.tonlabs.io/${getGzFileName(getCompilerFileName({ version }))}`;
const getLibUrl = ({ version }: { version: string }) =>
`http://sdkbinaries.tonlabs.io/${getGzFileName(getLibFileName({ version }))}`;
`https://sdkbinaries.tonlabs.io/${getGzFileName(getLibFileName({ version }))}`;

export const replaceDots = (arg: string): string => arg.replace(/\./g, "_");

Expand Down
3 changes: 1 addition & 2 deletions src/internal/tracing/viewTraceTree/viewTracingTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ export class ViewTracingTree {
contract,
name,
}: { contract: C } & { name: N }) => {
//@ts-ignore
if (name in contract._functions) {
if (name in contract.methodsAbi) {
return this.findByType<N, MethodParams<C, N>>({ name, type: TraceType.FUNCTION_CALL, contract });
}
return this.findByType<N, E>({ name, type: TraceType.EVENT, contract });
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export const initializeExtenders = (params: {
mergeMap(extender =>
from(extender.initializer(params)).pipe(
tap(extenderObject => {
//@ts-ignore
params.locklift[extender.pluginName] = extenderObject;
(params.locklift as any)[extender.pluginName] = extenderObject;
}),
),
),
Expand Down