From 0fde90cd64381a04776d88ace10a62616dd1cea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20Pul?= <4625220+codespool@users.noreply.github.com> Date: Wed, 17 May 2023 16:20:47 +0300 Subject: [PATCH] Feature/init convert (#136) Main feature is introducing a `--convert` flag to `init` command. (#111 ) Also handled are #113 and #83 . Some changes to how `init` works are introduced: - all "tasks" now get pushed into the task queue and only executed after all the options are confirmed - config is also gathered in the global configBuilder, and written as the last step To test: - have an existing project cloned to your filesystem (for example dex, or nft from https://github.com/swanky-dapps) - run `swanky init proj_name --convert path_to_existing_project` - it will check for Cargo.toml with `workspace` `members` and `exclude` fields - it assumes `members` are contracts, and `exclude` are extra crates - you can also specify manually - when done, you still need to manually adjust import paths in the contracts' Cargo.toml Note: the converted project is not expected to work out-of-the-box when converted, but should require minimum adjustments. --- lerna.json | 2 +- packages/cli/README.md | 17 +- packages/cli/package.json | 15 +- packages/cli/src/commands/check/index.ts | 4 +- packages/cli/src/commands/contract/compile.ts | 140 +-- packages/cli/src/commands/contract/deploy.ts | 39 +- packages/cli/src/commands/contract/explain.ts | 4 +- packages/cli/src/commands/contract/new.ts | 18 +- packages/cli/src/commands/contract/test.ts | 52 +- packages/cli/src/commands/contract/typegen.ts | 34 +- packages/cli/src/commands/init/index.ts | 625 +++++++++++-- packages/cli/src/commands/node/install.ts | 33 +- packages/cli/src/lib/baseCommand.ts | 17 +- packages/cli/src/lib/contract.ts | 66 ++ packages/cli/src/lib/contractCall.ts | 4 +- packages/core/package.json | 2 +- packages/core/src/lib/command-utils.ts | 144 ++- packages/core/src/lib/consts.ts | 9 +- packages/core/src/lib/tasks.ts | 19 +- packages/core/src/types/index.ts | 1 + packages/templates/README.md | 2 +- packages/templates/package.json | 2 +- .../ink/flipper/test/index.test.ts.hbs | 4 +- .../ink/psp22/test/index.test.ts.hbs | 4 +- .../templates/src/templates/package.json.hbs | 9 - yarn.lock | 877 ++++++++++++------ 26 files changed, 1416 insertions(+), 727 deletions(-) create mode 100644 packages/cli/src/lib/contract.ts diff --git a/lerna.json b/lerna.json index e1c29a47..40478e31 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", "useWorkspaces": true, - "version": "2.1.2", + "version": "2.2.2-alpha.0", "npmClient": "yarn" } diff --git a/packages/cli/README.md b/packages/cli/README.md index 3e644843..c590befd 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -17,7 +17,7 @@ $ npm install -g @astar-network/swanky-cli $ swanky COMMAND running command... $ swanky (--version|-V|-v) -@astar-network/swanky-cli/2.1.2 darwin-arm64 node-v18.10.0 +@astar-network/swanky-cli/2.2.2-alpha.0 darwin-x64 node-v18.2.0 $ swanky --help [COMMAND] USAGE $ swanky COMMAND @@ -114,7 +114,7 @@ DESCRIPTION Check installed package versions and compatibility ``` -_See code: [dist/commands/check/index.js](https://github.com/AstarNetwork/swanky-cli/blob/v2.1.2/dist/commands/check/index.js)_ +_See code: [dist/commands/check/index.js](https://github.com/AstarNetwork/swanky-cli/blob/v2.2.2-alpha.0/dist/commands/check/index.js)_ ## `swanky contract compile [CONTRACTNAME]` @@ -160,7 +160,7 @@ DESCRIPTION ## `swanky contract explain CONTRACTNAME` -Explain contract messages based on thier metadata +Explain contract messages based on the contracts' metadata ``` USAGE @@ -173,7 +173,7 @@ FLAGS -v, --verbose Display more info in the result logs DESCRIPTION - Explain contract messages based on thier metadata + Explain contract messages based on the contracts' metadata ``` ## `swanky contract new CONTRACTNAME` @@ -300,23 +300,24 @@ Generate a new smart contract environment ``` USAGE - $ swanky init PROJECTNAME [--swanky-node] [-t blank|erc20token|flipper|blank|flipper|psp22] [-l ask|ink] - [-v] + $ swanky init PROJECTNAME [-v] [--swanky-node] [-t blank|erc20token|flipper|blank|flipper|psp22] [-l + ask|ink] [-c ] ARGUMENTS PROJECTNAME directory name of new project FLAGS + -c, --convert= Converts an existing smart contract into a Swanky project -l, --language=