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

chore: Bump versions #211

Merged
merged 4 commits into from
Mar 12, 2024
Merged
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
104 changes: 52 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,71 +20,71 @@
],
"dependencies": {
"@iarna/toml": "^2.2.5",
"@oclif/core": "2.10.0",
"@oclif/plugin-help": "5.2.14",
"@oclif/plugin-plugins": "3.1.8",
"@oclif/plugin-version": "1.3.7",
"@polkadot/api": "10.9.1",
"@polkadot/api-augment": "10.9.1",
"@polkadot/api-contract": "10.9.1",
"@polkadot/keyring": "12.3.2",
"@polkadot/types": "10.9.1",
"@polkadot/util": "12.3.2",
"@polkadot/util-crypto": "12.3.2",
"@oclif/core": "3.24.0",
"@oclif/plugin-help": "6.0.18",
"@oclif/plugin-plugins": "4.3.5",
"@oclif/plugin-version": "2.0.14",
"@polkadot/api": "10.12.2",
"@polkadot/api-augment": "10.12.2",
"@polkadot/api-contract": "10.12.2",
"@polkadot/keyring": "12.6.2",
"@polkadot/types": "10.12.2",
"@polkadot/types-codec": "10.12.2",
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"bn.js": "5.2.1",
"chalk": "5.3.0",
"change-case": "4.1.2",
"change-case": "5.4.3",
"decompress": "4.2.1",
"enquirer": "^2.3.6",
"execa": "7.2.0",
"fs-extra": "11.1.1",
"globby": "^13.1.4",
"handlebars": "4.7.7",
"inquirer": "9.2.8",
"enquirer": "^2.4.1",
"execa": "8.0.1",
"fs-extra": "11.2.0",
"globby": "^14.0.1",
"handlebars": "4.7.8",
"inquirer": "9.2.15",
"inquirer-fuzzy-path": "^2.3.0",
"listr2": "6.6.0",
"listr2": "8.0.2",
"lodash-es": "^4.17.21",
"mocha": "10.2.0",
"mocha-suppress-logs": "0.3.1",
"mocha": "10.3.0",
"mocha-suppress-logs": "0.5.1",
"mochawesome": "7.1.3",
"modern-errors": "^6.0.0",
"modern-errors-bugs": "^4.0.0",
"modern-errors-clean": "^5.0.0",
"modern-errors-winston": "^4.0.0",
"modern-errors": "^7.0.0",
"modern-errors-bugs": "^5.0.0",
"modern-errors-clean": "^6.0.0",
"modern-errors-winston": "^5.0.0",
"node-downloader-helper": "2.1.9",
"ora": "6.3.1",
"semver": "7.5.4",
"shelljs": "0.8.5",
"ora": "8.0.1",
"semver": "7.6.0",
"toml": "^3.0.0",
"ts-mocha": "^10.0.0",
"winston": "^3.10.0"
"winston": "^3.12.0"
},
"devDependencies": {
"@oclif/test": "2.4.0",
"@oclif/test": "3.2.5",
"@types/bn.js": "^5.1.5",
"@types/chai": "4",
"@types/decompress": "4.2.4",
"@types/fs-extra": "11.0.1",
"@types/iarna__toml": "^2.0.2",
"@types/inquirer": "9.0.3",
"@types/inquirer-fuzzy-path": "^2.3.6",
"@types/lodash-es": "^4.17.8",
"@types/mocha": "10.0.1",
"@types/node": "^20.4.5",
"@types/semver": "7.5.0",
"@types/shelljs": "0.8.12",
"@typescript-eslint/eslint-plugin": "6.2.0",
"@typescript-eslint/parser": "6.2.0",
"chai": "4",
"eslint": "8.45.0",
"eslint-config-prettier": "8.9.0",
"eslint-plugin-prettier": "5.0.0",
"nodemon": "^3.0.1",
"oclif": "3.10.0",
"prettier": "3.0.0",
"@types/decompress": "4.2.7",
"@types/fs-extra": "11.0.4",
"@types/iarna__toml": "^2.0.5",
"@types/inquirer": "9.0.7",
"@types/inquirer-fuzzy-path": "^2.3.9",
"@types/lodash-es": "^4.17.12",
"@types/mocha": "10.0.6",
"@types/node": "^20.11.26",
"@types/semver": "7.5.8",
"@typescript-eslint/eslint-plugin": "7.2.0",
"@typescript-eslint/parser": "7.2.0",
"chai": "5",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"nodemon": "^3.1.0",
"oclif": "4.5.4",
"prettier": "3.2.5",
"shx": "0.3.4",
"ts-node": "10.9.1",
"tslib": "2.6.1",
"typescript": "5.1.6"
"ts-node": "10.9.2",
"tslib": "2.6.2",
"typescript": "5.4.2"
},
"oclif": {
"bin": "swanky",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/contract/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getSwankyConfig,
} from "../../lib/index.js";
import { email, name, pickTemplate } from "../../lib/prompts.js";
import { paramCase, pascalCase, snakeCase } from "change-case";
import { kebabCase, pascalCase, snakeCase } from "change-case";
import { execaCommandSync } from "execa";
import inquirer from "inquirer";
import { SwankyCommand } from "../../lib/swankyCommand.js";
Expand Down Expand Up @@ -96,7 +96,7 @@ export class NewContract extends SwankyCommand<typeof NewContract> {
await this.spinner.runCommand(
() =>
processTemplates(projectPath, {
project_name: paramCase(this.config.pjson.name),
project_name: kebabCase(this.config.pjson.name),
author_name: answers.authorName,
author_email: answers.email,
swanky_version: this.config.pjson.version,
Expand Down
100 changes: 47 additions & 53 deletions src/commands/contract/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import path from "node:path";
import { globby } from "globby";
import Mocha from "mocha";
import { emptyDir, pathExistsSync } from "fs-extra/esm";
import shell from "shelljs";
import { Contract } from "../../lib/contract.js";
import { SwankyCommand } from "../../lib/swankyCommand.js";
import { ConfigError, FileError, InputError, ProcessError, TestError } from "../../lib/errors.js";
Expand All @@ -25,8 +24,8 @@ export class TestContract extends SwankyCommand<typeof TestContract> {
description: "Run tests for all contracts",
}),
mocha: Flags.boolean({
default: false,
description: "Run tests with mocha",
default: false,
description: "Run tests with mocha",
}),
};

Expand Down Expand Up @@ -69,7 +68,9 @@ export class TestContract extends SwankyCommand<typeof TestContract> {

console.log(`Testing contract: ${contractName}`);

if (!flags.mocha) {
if (flags.mocha) {
await this.runMochaTests(contract);
} else {
await spinner.runCommand(
async () => {
return new Promise<string>((resolve, reject) => {
Expand All @@ -79,7 +80,7 @@ export class TestContract extends SwankyCommand<typeof TestContract> {
"e2e-tests",
"--manifest-path",
`contracts/${contractName}/Cargo.toml`,
"--release"
"--release",
];

const compile = spawn("cargo", compileArgs);
Expand Down Expand Up @@ -114,24 +115,26 @@ export class TestContract extends SwankyCommand<typeof TestContract> {
`Testing ${contractName} contract`,
`${contractName} testing finished successfully`
);
} else {

const testDir = path.resolve("tests");
}
}
}

if (!pathExistsSync(testDir)) {
throw new FileError(`Tests folder does not exist: ${testDir}`);
}
async runMochaTests(contract: Contract): Promise<void> {
const testDir = path.resolve("tests", contract.name);
if (!pathExistsSync(testDir)) {
throw new FileError(`Test directory does not exist: ${testDir}`);
}

const artifactsCheck = await contract.artifactsExist();
const artifactsCheck = await contract.artifactsExist();

if (!artifactsCheck.result) {
throw new FileError(
`No artifact file found at path: ${artifactsCheck.missingPaths.toString()}`
);
}

const artifactPath = path.resolve("typedContracts", `${contractName}`);
const typedContractCheck = await contract.typedContractExists(contractName);
const artifactPath = path.resolve("typedContracts", `${contract.name}`);
const typedContractCheck = await contract.typedContractExists(contract.name);

this.log(`artifactPath: ${artifactPath}`);

Expand All @@ -141,46 +144,37 @@ export class TestContract extends SwankyCommand<typeof TestContract> {
);
}

const reportDir = path.resolve(testDir, contract.name, "testReports");

await emptyDir(reportDir);

const mocha = new Mocha({
timeout: 200000,
reporter: "mochawesome",
reporterOptions: {
reportDir,
charts: true,
reportTitle: `${contractName} test report`,
quiet: true,
json: false,
},
});

const tests = await globby(`${path.resolve(testDir, contractName)}/*.test.ts`);

tests.forEach((test) => {
mocha.addFile(test);
const reportDir = path.resolve(testDir, "testReports");
await emptyDir(reportDir);

const mocha = new Mocha({
timeout: 200000,
reporter: "mochawesome",
reporterOptions: {
reportDir,
quiet: true,
},
});

const testFiles = await globby(`${testDir}/*.test.ts`);
testFiles.forEach((file) => mocha.addFile(file));

global.contractTypesPath = path.resolve(testDir, "typedContract");


try {
await new Promise<void>((resolve, reject) => {
mocha.run((failures) => {
if (failures) {
reject(new Error(`Tests failed. See report: ${reportDir}`));
} else {
console.log(`All tests passed. See report: ${reportDir}`);
resolve();
}
});

global.contractTypesPath = path.resolve(testDir, contractName, "typedContract");

shell.cd(`${testDir}/${contractName}`);
try {
await new Promise<void>((resolve, reject) => {
mocha.run((failures) => {
if (failures) {
reject(`At least one of the tests failed. Check report for details: ${reportDir}`);
} else {
this.log(`All tests passing. Check the report for details: ${reportDir}`);
resolve();
}
});
});
} catch (cause) {
throw new TestError("Error in test", { cause });
}
}
});
} catch (error) {
throw new TestError("Mocha tests failed", { cause: error });
}
}
}
7 changes: 3 additions & 4 deletions src/commands/env/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ import { ConfigBuilder } from "../../lib/config-builder.js";
export class Install extends SwankyCommand<typeof Install> {
static flags = {
deps: Flags.string({
required: false,
description: `Install the specified dev dependency name and version in the format <dependency@version>. The following options are supported: ${Object.keys(
SUPPORTED_DEPS
).join(", ")}. For installing rust nightly version run: env install --deps rust@nightly`,
multiple: true,
default: [],
char: "d",
}),
};

async run(): Promise<void> {
const { flags } = await this.parse(Install);
const depsArray = flags.deps ?? [];

const localConfig = getSwankyConfig('local') as SwankyConfig;
const depsToInstall = flags.deps.length > 0 ? this.parseDeps(flags.deps) : localConfig.env;
const depsToInstall = depsArray.length > 0 ? this.parseDeps(depsArray) : localConfig.env;

if (Object.keys(depsToInstall).length === 0) {
this.log("No dependencies to install.");
Expand All @@ -32,7 +31,7 @@ export class Install extends SwankyCommand<typeof Install> {

await this.installDeps(depsToInstall);

if (flags.deps.length > 0) {
if (depsArray.length > 0) {
await this.updateLocalConfig(depsToInstall);
}

Expand Down
5 changes: 2 additions & 3 deletions src/commands/generate/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ConfigError, FileError, InputError } from "../../lib/errors.js";
import path from "node:path";
import { existsSync } from "node:fs";
import inquirer from "inquirer";
import { paramCase, pascalCase } from "change-case";
import { kebabCase, pascalCase } from "change-case";
import { TestType } from "../../index.js";

export class GenerateTests extends SwankyCommand<typeof GenerateTests> {
Expand All @@ -15,7 +15,6 @@ export class GenerateTests extends SwankyCommand<typeof GenerateTests> {
static args = {
contractName: Args.string({
name: "contractName",
required: false,
description: "Name of the contract",
}),
};
Expand Down Expand Up @@ -151,7 +150,7 @@ export class GenerateTests extends SwankyCommand<typeof GenerateTests> {
await this.spinner.runCommand(
() =>
processTemplates(projectPath, {
project_name: paramCase(this.config.pjson.name),
project_name: kebabCase(this.config.pjson.name),
swanky_version: this.config.pjson.version,
contract_name: contractName ?? "",
contract_name_pascal: contractName ? pascalCase(contractName) : "",
Expand Down
6 changes: 3 additions & 3 deletions src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from "node:path";
import { copy, ensureDir, outputFile, pathExists, readJSON, remove, writeJSON } from "fs-extra/esm";
import { readdir, readFile, stat } from "fs/promises";
import { execaCommand, execaCommandSync } from "execa";
import { paramCase, pascalCase, snakeCase } from "change-case";
import { kebabCase, pascalCase, snakeCase } from "change-case";
import inquirer from "inquirer";
import TOML from "@iarna/toml";
import { choice, email, name, pickNodeVersion, pickTemplate } from "../../lib/prompts.js";
Expand Down Expand Up @@ -259,7 +259,7 @@ export class Init extends SwankyCommand<typeof Init> {
args: [
this.projectPath,
{
project_name: paramCase(projectName),
project_name: kebabCase(projectName),
author_name: authorName,
author_email: authorEmail,
swanky_version: this.config.pjson.version,
Expand Down Expand Up @@ -328,7 +328,7 @@ export class Init extends SwankyCommand<typeof Init> {
args: [
this.projectPath,
{
project_name: paramCase(projectName),
project_name: kebabCase(projectName),
swanky_version: this.config.pjson.version,
},
],
Expand Down
Loading
Loading