From da8c418de30a47bc29285f52cc6154eb414e4a6d Mon Sep 17 00:00:00 2001 From: timbrinded <79199034+timbrinded@users.noreply.github.com> Date: Fri, 8 Sep 2023 17:35:02 +0100 Subject: [PATCH] added env descriptions --- .changeset/moody-fans-juggle.md | 4 +- packages/cli/src/cmds/main.ts | 88 ++++++++++++++++--------------- packages/types/config_schema.json | 9 +++- packages/types/src/config.ts | 49 ++++++++++++++++- test/moonwall.config.json | 3 ++ 5 files changed, 107 insertions(+), 46 deletions(-) diff --git a/.changeset/moody-fans-juggle.md b/.changeset/moody-fans-juggle.md index d6ffff0a..f2a0773a 100644 --- a/.changeset/moody-fans-juggle.md +++ b/.changeset/moody-fans-juggle.md @@ -8,4 +8,6 @@ # September Update - [#258](https://github.com/Moonsong-Labs/moonwall/issues/258) -- [#254](https://github.com/Moonsong-Labs/moonwall/issues/254) \ No newline at end of file +- [#254](https://github.com/Moonsong-Labs/moonwall/issues/254) +- [#251](https://github.com/Moonsong-Labs/moonwall/issues/251) +- [#224](https://github.com/Moonsong-Labs/moonwall/issues/224) \ No newline at end of file diff --git a/packages/cli/src/cmds/main.ts b/packages/cli/src/cmds/main.ts index 05461b1e..b2f676e7 100644 --- a/packages/cli/src/cmds/main.ts +++ b/packages/cli/src/cmds/main.ts @@ -45,46 +45,46 @@ async function mainMenu(config: MoonwallConfig) { message: `Main Menu - Please select one of the following:`, default: 0, pageSize: 12, - choices: [ - { - name: !configPresent - ? "1) Initialise: Generate a new Moonwall Config File." - : chalk.dim("1) Initialise: ✅ CONFIG ALREADY GENERATED"), - value: "init", - disabled: configPresent, - }, - { - name: configPresent - ? `2) Network Launcher & Toolbox: Launch network, access tools: tail logs, interactive tests etc.` - : chalk.dim("2) Network Launcher & Toolbox NO CONFIG FOUND"), - value: "run", - disabled: !configPresent, - }, - { - name: configPresent - ? "3) Test Suite Execution: Run automated tests, start network if needed." - : chalk.dim("3) Test Suite Execution: NO CONFIG FOUND"), - value: "test", + choices: !configPresent + ? [ + { + name: !configPresent + ? "1) Initialise: Generate a new Moonwall Config File." + : chalk.dim("1) Initialise: ✅ CONFIG ALREADY GENERATED"), + value: "init", + }, + { + name: "2) Artifact Downloader: Fetch artifacts (x86) from GitHub repos.", + value: "download", + }, + { + name: `3) Quit Application`, + value: "quit", + }, + ] + : [ + { + name: configPresent + ? `1) Network Launcher & Toolbox: Launch network, access tools: tail logs, interactive tests etc.` + : chalk.dim("2) Network Launcher & Toolbox NO CONFIG FOUND"), + value: "run", + }, + { + name: configPresent + ? "2) Test Suite Execution: Run automated tests, start network if needed." + : chalk.dim("3) Test Suite Execution: NO CONFIG FOUND"), + value: "test", + }, - disabled: !configPresent, - }, - { - name: chalk.dim("4) Batch-Run Tests: 🏗️ NOT YET IMPLEMENTED "), - value: "batch", - - disabled: true, - }, - { - name: "5) Artifact Downloader: Fetch artifacts (x86) from GitHub repos.", - value: "download", - - disabled: false, - }, - { - name: `6) Quit Application`, - value: "quit", - }, - ], + { + name: "3) Artifact Downloader: Fetch artifacts (x86) from GitHub repos.", + value: "download", + }, + { + name: `4) Quit Application`, + value: "quit", + }, + ], filter(val) { return val; }, @@ -134,6 +134,8 @@ async function resolveDownloadChoice() { const binList = ghRepos().reduce((acc, curr) => { acc.push(...curr.binaries.map((bin) => bin.name).flat()); acc.push(new inquirer.Separator()); + acc.push("Back"); + acc.push(new inquirer.Separator()); return acc; }, [] as string[]); @@ -204,7 +206,7 @@ async function resolveDownloadChoice() { const chooseTestEnv = async (config: MoonwallConfig) => { const envs = config.environments .map((a) => ({ - name: `Env: ${a.name} (${a.foundation.type})`, + name: `[${a.foundation.type}] ${a.name}${a.description ? ": \t\t" + a.description : ""}`, value: a.name, disabled: false, })) @@ -235,9 +237,11 @@ const chooseRunEnv = async (config: MoonwallConfig) => { a.foundation.type === "chopsticks" || a.foundation.type === "zombie" ) { - result.name = `Env: ${a.name} (${a.foundation.type})`; + result.name = `[${a.foundation.type}] ${a.name}${ + a.description ? ": \t\t" + a.description : "" + }`; } else { - result.name = chalk.dim(`Env: ${a.name} (${a.foundation.type}) NO NETWORK TO RUN`); + result.name = chalk.dim(`[${a.foundation.type}] ${a.name} NO NETWORK TO RUN`); result.disabled = true; } return result; diff --git a/packages/types/config_schema.json b/packages/types/config_schema.json index ac08a621..05d6765a 100644 --- a/packages/types/config_schema.json +++ b/packages/types/config_schema.json @@ -499,9 +499,11 @@ "additionalRepos": { "description": "Use this to specify additional repos to download binaries from.\nPolkadot, Tanssi and Moonbeam are available by default.", "items": { + "description": "`RepoSpec` type represents the configuration required to download binaries\nfrom a project's GitHub repository.", "properties": { "binaries": { "items": { + "description": "`Bin` type defines the binary configurations within a `RepoSpec`.", "properties": { "defaultArgs": { "items": { @@ -515,8 +517,7 @@ "type": { "enum": [ "binary", - "tar", - "zip" + "tar" ], "type": "string" } @@ -586,6 +587,10 @@ }, "type": "object" }, + "description": { + "description": "Description of the environment to display in menus.", + "type": "string" + }, "envVars": { "description": "An optional array of environment variable names.", "items": { diff --git a/packages/types/src/config.ts b/packages/types/src/config.ts index 4806c868..837d2bc3 100644 --- a/packages/types/src/config.ts +++ b/packages/types/src/config.ts @@ -51,6 +51,11 @@ export type Environment = { */ name: string; + /** + * Description of the environment to display in menus. + */ + description?: string; + /** * An array of directories with test files. */ @@ -440,6 +445,29 @@ export interface OrcOptionsInterface { setGlobalNetwork?: (network: object) => void; } +/** + * `RepoSpec` type represents the configuration required to download binaries + * from a project's GitHub repository. + * + * @property {string} name - A unique identifier or name for the repo configuration. + * @property {string} ghAuthor - The GitHub username or organization under which the repository resides. + * @property {string} ghRepo - The GitHub repository name. + * @property {Bin[]} binaries - An array of binary configurations to be downloaded. + * + * @example + * { + * "name": "astar", + * "ghAuthor": "AstarNetwork", + * "ghRepo": "Astar", + * "binaries": [ + * { + * "name": "astar-collator*ubuntu-x86*", + * "type": "tar", + * "defaultArgs": ["--dev", "--sealing=manual", "--no-hardware-benchmarks", "--no-telemetry"] + * } + * ] + * } + */ export type RepoSpec = { name: string; ghAuthor: string; @@ -447,8 +475,27 @@ export type RepoSpec = { binaries: Bin[]; }; +/** + * `Bin` type defines the binary configurations within a `RepoSpec`. + * + * @property {string} name - The name or pattern to identify the binary. + * @property {("binary"|"tar")?} type - The type of the binary. It's optional and can be one of "binary" or "tar". + * @property {string[]?} defaultArgs - An optional array of default arguments to be used with the binary. + * + * @example + * { + * "name": "hydradx" + * } + * + * @example + * { + * "name": "astar-collator*ubuntu-x86*", + * "type": "tar", + * "defaultArgs": ["--dev", "--sealing=manual", "--no-hardware-benchmarks", "--no-telemetry"] + * } + */ export type Bin = { name: string; - type?: "binary" | "tar" | "zip"; + type?: "binary" | "tar" ; defaultArgs?: string[]; }; diff --git a/test/moonwall.config.json b/test/moonwall.config.json index 844af7e7..d9e21cfc 100644 --- a/test/moonwall.config.json +++ b/test/moonwall.config.json @@ -46,6 +46,7 @@ { "name": "dev_tanssi", "testFileDir": ["suites/tanssi"], + "description": "Basic Tanssi dev test", "foundation": { "type": "dev", "launchSpec": [ @@ -75,6 +76,7 @@ }, { "name": "zombie_wasm", + "description": "For upgrade testing using zombienet", "testFileDir": ["suites/zombie"], "foundation": { "type": "zombie", @@ -142,6 +144,7 @@ }, { "name": "basic", + "description": "Suite of tests that doesnt involve any blockchain stuff", "testFileDir": ["suites/basic/"], "foundation": { "type": "read_only"