Skip to content

Commit

Permalink
chore: prettier fmt and script command added to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ipapandinas committed Mar 25, 2024
1 parent 64e6be0 commit f52c5ce
Show file tree
Hide file tree
Showing 38 changed files with 609 additions and 467 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
node-version: ${{ env.NODE_VER }}

- name: yarn test
- name: Check test
run: yarn && yarn test

lint-check:
Expand All @@ -60,7 +60,7 @@ jobs:
with:
node-version: ${{ env.NODE_VER }}

- name: yarn lint
- name: Check lint
run: yarn && yarn lint

build-check:
Expand All @@ -75,5 +75,20 @@ jobs:
with:
node-version: ${{ env.NODE_VER }}

- name: yarn build
run: yarn && yarn build
- name: Check build
run: yarn && yarn build

format-check:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout the source code
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}

- name: Check formatting
run: yarn && yarn format
117 changes: 62 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
</p>

<!-- toc -->
* [Docs and guide](#docs-and-guide)
* [Quick start](#quick-start)
* [Base image and dev container](#base-image-and-dev-container)
* [Config](#config)
* [Network Management](#network-management)
* [Development and contributing](#development-and-contributing)
* [Reporting issues](#reporting-issues)
* [Command help](#command-help)

- [Docs and guide](#docs-and-guide)
- [Quick start](#quick-start)
- [Base image and dev container](#base-image-and-dev-container)
- [Config](#config)
- [Network Management](#network-management)
- [Development and contributing](#development-and-contributing)
- [Reporting issues](#reporting-issues)
- [Command help](#command-help)
<!-- tocstop -->

# Docs and guide
Expand Down Expand Up @@ -127,6 +128,7 @@ A newly generated project will have a `swanky.config.json` file that will get po
```

Also, global config will be created in your home directory, in `~/swanky` folder.

## Example:

```json
Expand Down Expand Up @@ -167,6 +169,7 @@ Also, global config will be created in your home directory, in `~/swanky` folder
}
}
```

You can use accounts and networks from the global config in any swanky project.

# Network Management
Expand Down Expand Up @@ -225,6 +228,7 @@ Please report any issue or bug you encounter, as well as any feature and improve
# Command help

<!-- usage -->

```sh-session
$ npm install -g @astar-network/swanky-cli
$ swanky COMMAND
Expand All @@ -236,48 +240,50 @@ USAGE
$ swanky COMMAND
...
```

<!-- usagestop -->

<!-- commands -->
* [`swanky account create`](#swanky-account-create)
* [`swanky account list`](#swanky-account-list)
* [`swanky account ls`](#swanky-account-ls)
* [`swanky account balance`](#swanky-account-balance)
* [`swanky account faucet`](#swanky-account-faucet)
* [`swanky account default`](#swanky-account-default)
* [`swanky clear CONTRACTNAME`](#swanky-clear-contractname)
* [`swanky contract compile [CONTRACTNAME]`](#swanky-contract-compile-contractname)
* [`swanky contract deploy CONTRACTNAME`](#swanky-contract-deploy-contractname)
* [`swanky contract explain CONTRACTNAME`](#swanky-contract-explain-contractname)
* [`swanky contract new CONTRACTNAME`](#swanky-contract-new-contractname)
* [`swanky contract query CONTRACTNAME MESSAGENAME`](#swanky-contract-query-contractname-messagename)
* [`swanky contract test [CONTRACTNAME]`](#swanky-contract-test-contractname)
* [`swanky contract tx CONTRACTNAME MESSAGENAME`](#swanky-contract-tx-contractname-messagename)
* [`swanky contract verify CONTRACTNAME`](#swanky-contract-verify-contractname)
* [`swanky env check`](#swanky-env-check)
* [`swanky env install`](#swanky-env-install)
* [`swanky generate tests`](#swanky-generate-tests)
* [`swanky generate types`](#swanky-generate-types)
* [`swanky help [COMMANDS]`](#swanky-help-commands)
* [`swanky init PROJECTNAME`](#swanky-init-projectname)
* [`swanky node install`](#swanky-node-install)
* [`swanky node purge`](#swanky-node-purge)
* [`swanky node start`](#swanky-node-start)
* [`swanky node version`](#swanky-node-version)
* [`swanky node chopsticks init`](#swanky-node-chopsticks-init)
* [`swanky node chopsticks start`](#swanky-node-chopsticks-start)
* [`swanky zombienet init`](#swanky-zombienet-init)
* [`swanky zombienet start`](#swanky-zombienet-start)
* [`swanky plugins`](#swanky-plugins)
* [`swanky plugins:install PLUGIN...`](#swanky-pluginsinstall-plugin)
* [`swanky plugins:inspect PLUGIN...`](#swanky-pluginsinspect-plugin)
* [`swanky plugins:install PLUGIN...`](#swanky-pluginsinstall-plugin-1)
* [`swanky plugins:link PLUGIN`](#swanky-pluginslink-plugin)
* [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin)
* [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin-1)
* [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin-2)
* [`swanky plugins update`](#swanky-plugins-update)
* [`swanky version`](#swanky-version)

- [`swanky account create`](#swanky-account-create)
- [`swanky account list`](#swanky-account-list)
- [`swanky account ls`](#swanky-account-ls)
- [`swanky account balance`](#swanky-account-balance)
- [`swanky account faucet`](#swanky-account-faucet)
- [`swanky account default`](#swanky-account-default)
- [`swanky clear CONTRACTNAME`](#swanky-clear-contractname)
- [`swanky contract compile [CONTRACTNAME]`](#swanky-contract-compile-contractname)
- [`swanky contract deploy CONTRACTNAME`](#swanky-contract-deploy-contractname)
- [`swanky contract explain CONTRACTNAME`](#swanky-contract-explain-contractname)
- [`swanky contract new CONTRACTNAME`](#swanky-contract-new-contractname)
- [`swanky contract query CONTRACTNAME MESSAGENAME`](#swanky-contract-query-contractname-messagename)
- [`swanky contract test [CONTRACTNAME]`](#swanky-contract-test-contractname)
- [`swanky contract tx CONTRACTNAME MESSAGENAME`](#swanky-contract-tx-contractname-messagename)
- [`swanky contract verify CONTRACTNAME`](#swanky-contract-verify-contractname)
- [`swanky env check`](#swanky-env-check)
- [`swanky env install`](#swanky-env-install)
- [`swanky generate tests`](#swanky-generate-tests)
- [`swanky generate types`](#swanky-generate-types)
- [`swanky help [COMMANDS]`](#swanky-help-commands)
- [`swanky init PROJECTNAME`](#swanky-init-projectname)
- [`swanky node install`](#swanky-node-install)
- [`swanky node purge`](#swanky-node-purge)
- [`swanky node start`](#swanky-node-start)
- [`swanky node version`](#swanky-node-version)
- [`swanky node chopsticks init`](#swanky-node-chopsticks-init)
- [`swanky node chopsticks start`](#swanky-node-chopsticks-start)
- [`swanky zombienet init`](#swanky-zombienet-init)
- [`swanky zombienet start`](#swanky-zombienet-start)
- [`swanky plugins`](#swanky-plugins)
- [`swanky plugins:install PLUGIN...`](#swanky-pluginsinstall-plugin)
- [`swanky plugins:inspect PLUGIN...`](#swanky-pluginsinspect-plugin)
- [`swanky plugins:install PLUGIN...`](#swanky-pluginsinstall-plugin-1)
- [`swanky plugins:link PLUGIN`](#swanky-pluginslink-plugin)
- [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin)
- [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin-1)
- [`swanky plugins:uninstall PLUGIN...`](#swanky-pluginsuninstall-plugin-2)
- [`swanky plugins update`](#swanky-plugins-update)
- [`swanky version`](#swanky-version)

## `swanky account create`

Expand All @@ -296,7 +302,9 @@ FLAGS
DESCRIPTION
Create a new dev account in config
```

_See code: [src/commands/account/create.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/create.ts)_

## `swanky account list`

List dev accounts stored in config
Expand All @@ -314,8 +322,8 @@ DESCRIPTION
ALIASES
$ swanky account ls
```
_See code: [src/commands/account/list.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/list.ts)_

_See code: [src/commands/account/list.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/list.ts)_

## `swanky account ls`

Expand Down Expand Up @@ -394,7 +402,7 @@ FLAGS
DESCRIPTION
Set default account to use
```
```

_See code: [src/commands/account/default.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/account/default.ts)_

Expand Down Expand Up @@ -463,7 +471,6 @@ DESCRIPTION
Deploy contract to a running node
```


_See code: [src/commands/contract/deploy.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/contract/deploy.ts)_

## `swanky contract explain CONTRACTNAME`
Expand Down Expand Up @@ -507,7 +514,6 @@ DESCRIPTION

_See code: [src/commands/contract/new.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/contract/new.ts)_


## `swanky contract query CONTRACTNAME MESSAGENAME`

Call a query message on smart contract
Expand Down Expand Up @@ -659,7 +665,7 @@ FLAGS
DESCRIPTION
Generate test files for the specified contract
```
```

_See code: [src/commands/generate/tests.ts](https://github.com/inkdevhub/swanky-cli/blob/master/src/commands/generate/tests.ts)_

Expand Down Expand Up @@ -849,7 +855,7 @@ _See code: [src/commands/node/chopsticks/start.ts](https://github.com/inkdevhub/

Initialize Zombienet

```
```
USAGE
$ swanky zombienet init [-v] [-b polkadot|polkadot-parachain|astar-collator]
Expand Down Expand Up @@ -936,7 +942,7 @@ ALIASES
$ swanky plugins add
EXAMPLES
$ swanky plugins:install myplugin
$ swanky plugins:install myplugin
$ swanky plugins:install https://github.com/someuser/someplugin
Expand Down Expand Up @@ -999,7 +1005,7 @@ ALIASES
$ swanky plugins add
EXAMPLES
$ swanky plugins:install myplugin
$ swanky plugins:install myplugin
$ swanky plugins:install https://github.com/someuser/someplugin
Expand Down Expand Up @@ -1137,4 +1143,5 @@ FLAG DESCRIPTIONS
```

_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v1.3.7/src/commands/version.ts)_

<!-- commandsstop -->
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
}
},
"scripts": {
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css,md}\"",
"lint": "eslint . --ext .ts --quiet --config .eslintrc",
"postpack": "shx rm -f oclif.manifest.json",
"prepack": "yarn build && oclif manifest && oclif readme",
Expand Down
9 changes: 7 additions & 2 deletions src/commands/account/create.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Flags } from "@oclif/core";
import chalk from "chalk";
import { ChainAccount, encrypt, getSwankyConfig, isLocalConfigCheck, SwankyAccountCommand } from "../../lib/index.js";
import {
ChainAccount,
encrypt,
getSwankyConfig,
isLocalConfigCheck,
SwankyAccountCommand,
} from "../../lib/index.js";
import { AccountData } from "../../types/index.js";
import inquirer from "inquirer";
import { SwankyCommand } from "../../lib/swankyCommand.js";
Expand All @@ -14,7 +20,6 @@ export class CreateAccount extends SwankyAccountCommand<typeof CreateAccount> {
global: Flags.boolean({
char: "g",
description: "Create account globally stored in Swanky system config.",

}),
new: Flags.boolean({
char: "n",
Expand Down
8 changes: 4 additions & 4 deletions src/commands/account/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export class ListAccounts extends SwankyCommand<typeof ListAccounts> {
async run(): Promise<void> {
const countOfDevAccounts = this.swankyConfig.accounts.filter((account) => account.isDev).length;

if(countOfDevAccounts !== 0) {
if (countOfDevAccounts !== 0) {
this.log(`${chalk.greenBright("✔")} Stored dev accounts:`);

for (const account of this.swankyConfig.accounts) {
if(account.isDev){
if (account.isDev) {
this.log(`\t${chalk.yellowBright("Alias: ")} ${account.alias} \
${chalk.yellowBright("Address: ")} ${account.address} ${this.swankyConfig.defaultAccount === account.alias ? chalk.greenBright("<- Default") : ""}`);
}
Expand All @@ -26,11 +26,11 @@ ${chalk.yellowBright("Address: ")} ${account.address} ${this.swankyConfig.defaul

const countOfProdAccounts = this.swankyConfig.accounts.length - countOfDevAccounts;

if(countOfProdAccounts !== 0) {
if (countOfProdAccounts !== 0) {
this.log(`${chalk.greenBright("✔")} Stored prod accounts:`);

for (const account of this.swankyConfig.accounts) {
if(!account.isDev){
if (!account.isDev) {
this.log(`\t${chalk.yellowBright("Alias: ")} ${account.alias} \
${chalk.yellowBright("Address: ")} ${account.address} ${this.swankyConfig.defaultAccount === account.alias ? chalk.greenBright("<- Default") : ""}`);
}
Expand Down
41 changes: 24 additions & 17 deletions src/commands/clear/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import { Args, Flags } from "@oclif/core";
import { ensureContractNameOrAllFlagIsSet } from "../../lib/checks.js";

interface Folder {
name: string,
contractName?: string,
path: string
name: string;
contractName?: string;
path: string;
}

export default class Clear extends SwankyCommand<typeof Clear> {

static flags = {
all: Flags.boolean({
char: "a",
Expand Down Expand Up @@ -42,29 +41,37 @@ export default class Clear extends SwankyCommand<typeof Clear> {
}

public async run(): Promise<any> {

const { flags, args } = await this.parse(Clear);

ensureContractNameOrAllFlagIsSet(args, flags);

const workDirectory = process.cwd();
const foldersToDelete: Folder[] = flags.all ?
[
{ name: "Artifacts", path: path.join(workDirectory, "./artifacts") },
{ name: "Target", path: path.join(workDirectory, "./target") }
]
: args.contractName ?
[
{ name: "Artifacts", contractName: args.contractName, path: path.join(workDirectory, "./artifacts/", args.contractName) },
const foldersToDelete: Folder[] = flags.all
? [
{ name: "Artifacts", path: path.join(workDirectory, "./artifacts") },
{ name: "Target", path: path.join(workDirectory, "./target") },
{ name: "TestArtifacts", contractName: args.contractName, path: path.join(workDirectory, "./tests/", args.contractName, "/artifacts") }
]
: [];
: args.contractName
? [
{
name: "Artifacts",
contractName: args.contractName,
path: path.join(workDirectory, "./artifacts/", args.contractName),
},
{ name: "Target", path: path.join(workDirectory, "./target") },
{
name: "TestArtifacts",
contractName: args.contractName,
path: path.join(workDirectory, "./tests/", args.contractName, "/artifacts"),
},
]
: [];
for (const folder of foldersToDelete) {
await this.spinner.runCommand(async () => this.deleteFolder(folder.path),
await this.spinner.runCommand(
async () => this.deleteFolder(folder.path),
`Deleting the ${folder.name} folder ${folder.contractName ? `for ${folder.contractName} contract` : ""}`,
`Successfully deleted the ${folder.name} folder ${folder.contractName ? `for ${folder.contractName} contract` : ""}\n at ${folder.path}`
);
}
}
}
}
Loading

0 comments on commit f52c5ce

Please sign in to comment.