moonwall 1.0.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +681 -0
- package/README.md +54 -0
- package/config_schema.json +811 -0
- package/dist/api/constants/accounts.d.ts +36 -0
- package/dist/api/constants/accounts.d.ts.map +1 -0
- package/dist/api/constants/accounts.js +67 -0
- package/dist/api/constants/chain.d.ts +134 -0
- package/dist/api/constants/chain.d.ts.map +1 -0
- package/dist/api/constants/chain.js +149 -0
- package/dist/api/constants/index.d.ts +4 -0
- package/dist/api/constants/index.d.ts.map +1 -0
- package/dist/api/constants/index.js +3 -0
- package/dist/api/constants/smartContract.d.ts +29 -0
- package/dist/api/constants/smartContract.d.ts.map +1 -0
- package/dist/api/constants/smartContract.js +118 -0
- package/dist/api/testing/blocks.d.ts +59 -0
- package/dist/api/testing/blocks.d.ts.map +1 -0
- package/dist/api/testing/blocks.js +147 -0
- package/dist/api/testing/contracts.d.ts +5 -0
- package/dist/api/testing/contracts.d.ts.map +1 -0
- package/dist/api/testing/contracts.js +32 -0
- package/dist/api/testing/ethers.d.ts +3 -0
- package/dist/api/testing/ethers.d.ts.map +1 -0
- package/dist/api/testing/ethers.js +38 -0
- package/dist/api/testing/events.d.ts +12 -0
- package/dist/api/testing/events.d.ts.map +1 -0
- package/dist/api/testing/events.js +23 -0
- package/dist/api/testing/extrinsics.d.ts +5 -0
- package/dist/api/testing/extrinsics.d.ts.map +1 -0
- package/dist/api/testing/extrinsics.js +10 -0
- package/dist/api/testing/index.d.ts +9 -0
- package/dist/api/testing/index.d.ts.map +1 -0
- package/dist/api/testing/index.js +8 -0
- package/dist/api/testing/jumping.d.ts +8 -0
- package/dist/api/testing/jumping.d.ts.map +1 -0
- package/dist/api/testing/jumping.js +78 -0
- package/dist/api/testing/providers.d.ts +18 -0
- package/dist/api/testing/providers.d.ts.map +1 -0
- package/dist/api/testing/providers.js +34 -0
- package/dist/api/testing/viem.d.ts +139 -0
- package/dist/api/testing/viem.d.ts.map +1 -0
- package/dist/api/testing/viem.js +247 -0
- package/dist/api/types/config.d.ts +609 -0
- package/dist/api/types/config.d.ts.map +1 -0
- package/dist/api/types/config.js +1 -0
- package/dist/api/types/context.d.ts +125 -0
- package/dist/api/types/context.d.ts.map +1 -0
- package/dist/api/types/context.js +1 -0
- package/dist/api/types/contracts.d.ts +66 -0
- package/dist/api/types/contracts.d.ts.map +1 -0
- package/dist/api/types/contracts.js +1 -0
- package/dist/api/types/eth.d.ts +3 -0
- package/dist/api/types/eth.d.ts.map +1 -0
- package/dist/api/types/eth.js +1 -0
- package/dist/api/types/foundations.d.ts +11 -0
- package/dist/api/types/foundations.d.ts.map +1 -0
- package/dist/api/types/foundations.js +1 -0
- package/dist/api/types/helpers.d.ts +7 -0
- package/dist/api/types/helpers.d.ts.map +1 -0
- package/dist/api/types/helpers.js +1 -0
- package/dist/api/types/index.d.ts +8 -0
- package/dist/api/types/index.d.ts.map +1 -0
- package/dist/api/types/index.js +7 -0
- package/dist/api/types/runner.d.ts +490 -0
- package/dist/api/types/runner.d.ts.map +1 -0
- package/dist/api/types/runner.js +1 -0
- package/dist/cli/cmds/components/LogViewer.d.ts +17 -0
- package/dist/cli/cmds/components/LogViewer.d.ts.map +1 -0
- package/dist/cli/cmds/components/LogViewer.js +171 -0
- package/dist/cli/cmds/entrypoint.d.ts +6 -0
- package/dist/cli/cmds/entrypoint.d.ts.map +1 -0
- package/dist/cli/cmds/entrypoint.js +192 -0
- package/dist/cli/cmds/interactiveCmds/chopsticksIntCmds.d.ts +2 -0
- package/dist/cli/cmds/interactiveCmds/chopsticksIntCmds.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/chopsticksIntCmds.js +117 -0
- package/dist/cli/cmds/interactiveCmds/devIntCmds.d.ts +2 -0
- package/dist/cli/cmds/interactiveCmds/devIntCmds.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/devIntCmds.js +103 -0
- package/dist/cli/cmds/interactiveCmds/index.d.ts +4 -0
- package/dist/cli/cmds/interactiveCmds/index.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/index.js +3 -0
- package/dist/cli/cmds/interactiveCmds/zombieIntCmds.d.ts +2 -0
- package/dist/cli/cmds/interactiveCmds/zombieIntCmds.d.ts.map +1 -0
- package/dist/cli/cmds/interactiveCmds/zombieIntCmds.js +32 -0
- package/dist/cli/cmds/main.d.ts +2 -0
- package/dist/cli/cmds/main.d.ts.map +1 -0
- package/dist/cli/cmds/main.js +336 -0
- package/dist/cli/cmds/runNetwork.d.ts +3 -0
- package/dist/cli/cmds/runNetwork.d.ts.map +1 -0
- package/dist/cli/cmds/runNetwork.js +292 -0
- package/dist/cli/cmds/runTests.d.ts +12 -0
- package/dist/cli/cmds/runTests.d.ts.map +1 -0
- package/dist/cli/cmds/runTests.js +257 -0
- package/dist/cli/internal/cmdFunctions/downloader.d.ts +4 -0
- package/dist/cli/internal/cmdFunctions/downloader.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/downloader.js +49 -0
- package/dist/cli/internal/cmdFunctions/fetchArtifact.d.ts +10 -0
- package/dist/cli/internal/cmdFunctions/fetchArtifact.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/fetchArtifact.js +145 -0
- package/dist/cli/internal/cmdFunctions/index.d.ts +5 -0
- package/dist/cli/internal/cmdFunctions/index.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/index.js +4 -0
- package/dist/cli/internal/cmdFunctions/initialisation.d.ts +20 -0
- package/dist/cli/internal/cmdFunctions/initialisation.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/initialisation.js +150 -0
- package/dist/cli/internal/cmdFunctions/tempLogs.d.ts +3 -0
- package/dist/cli/internal/cmdFunctions/tempLogs.d.ts.map +1 -0
- package/dist/cli/internal/cmdFunctions/tempLogs.js +37 -0
- package/dist/cli/internal/commandParsers.d.ts +59 -0
- package/dist/cli/internal/commandParsers.d.ts.map +1 -0
- package/dist/cli/internal/commandParsers.js +305 -0
- package/dist/cli/internal/deriveTestIds.d.ts +8 -0
- package/dist/cli/internal/deriveTestIds.d.ts.map +1 -0
- package/dist/cli/internal/deriveTestIds.js +123 -0
- package/dist/cli/internal/effect/index.d.ts +6 -0
- package/dist/cli/internal/effect/index.d.ts.map +1 -0
- package/dist/cli/internal/effect/index.js +5 -0
- package/dist/cli/internal/fileCheckers.d.ts +11 -0
- package/dist/cli/internal/fileCheckers.d.ts.map +1 -0
- package/dist/cli/internal/fileCheckers.js +165 -0
- package/dist/cli/internal/foundations/index.d.ts +4 -0
- package/dist/cli/internal/foundations/index.d.ts.map +1 -0
- package/dist/cli/internal/foundations/index.js +4 -0
- package/dist/cli/internal/index.d.ts +12 -0
- package/dist/cli/internal/index.d.ts.map +1 -0
- package/dist/cli/internal/index.js +11 -0
- package/dist/cli/internal/launcherCommon.d.ts +4 -0
- package/dist/cli/internal/launcherCommon.d.ts.map +1 -0
- package/dist/cli/internal/launcherCommon.js +130 -0
- package/dist/cli/internal/localNode.d.ts +16 -0
- package/dist/cli/internal/localNode.d.ts.map +1 -0
- package/dist/cli/internal/localNode.js +362 -0
- package/dist/cli/internal/logging.d.ts +2 -0
- package/dist/cli/internal/logging.d.ts.map +1 -0
- package/dist/cli/internal/logging.js +26 -0
- package/dist/cli/internal/node.d.ts +33 -0
- package/dist/cli/internal/node.d.ts.map +1 -0
- package/dist/cli/internal/node.js +228 -0
- package/dist/cli/internal/processHelpers.d.ts +17 -0
- package/dist/cli/internal/processHelpers.d.ts.map +1 -0
- package/dist/cli/internal/processHelpers.js +56 -0
- package/dist/cli/internal/providerFactories.d.ts +48 -0
- package/dist/cli/internal/providerFactories.d.ts.map +1 -0
- package/dist/cli/internal/providerFactories.js +442 -0
- package/dist/cli/internal/testIdParser.d.ts +34 -0
- package/dist/cli/internal/testIdParser.d.ts.map +1 -0
- package/dist/cli/internal/testIdParser.js +167 -0
- package/dist/cli/lib/binariesHelpers.d.ts +15 -0
- package/dist/cli/lib/binariesHelpers.d.ts.map +1 -0
- package/dist/cli/lib/binariesHelpers.js +99 -0
- package/dist/cli/lib/configReader.d.ts +8 -0
- package/dist/cli/lib/configReader.d.ts.map +1 -0
- package/dist/cli/lib/configReader.js +115 -0
- package/dist/cli/lib/contractFunctions.d.ts +2 -0
- package/dist/cli/lib/contractFunctions.d.ts.map +1 -0
- package/dist/cli/lib/contractFunctions.js +2 -0
- package/dist/cli/lib/globalContext.d.ts +46 -0
- package/dist/cli/lib/globalContext.d.ts.map +1 -0
- package/dist/cli/lib/globalContext.js +710 -0
- package/dist/cli/lib/governanceProcedures.d.ts +27 -0
- package/dist/cli/lib/governanceProcedures.d.ts.map +1 -0
- package/dist/cli/lib/governanceProcedures.js +458 -0
- package/dist/cli/lib/handlers/index.d.ts +5 -0
- package/dist/cli/lib/handlers/index.d.ts.map +1 -0
- package/dist/cli/lib/handlers/index.js +5 -0
- package/dist/cli/lib/repoDefinitions/index.d.ts +6 -0
- package/dist/cli/lib/repoDefinitions/index.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/index.js +21 -0
- package/dist/cli/lib/repoDefinitions/moonbeam.d.ts +4 -0
- package/dist/cli/lib/repoDefinitions/moonbeam.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/moonbeam.js +30 -0
- package/dist/cli/lib/repoDefinitions/polkadot.d.ts +4 -0
- package/dist/cli/lib/repoDefinitions/polkadot.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/polkadot.js +11 -0
- package/dist/cli/lib/repoDefinitions/tanssi.d.ts +4 -0
- package/dist/cli/lib/repoDefinitions/tanssi.d.ts.map +1 -0
- package/dist/cli/lib/repoDefinitions/tanssi.js +14 -0
- package/dist/cli/lib/rpcFunctions.d.ts +2 -0
- package/dist/cli/lib/rpcFunctions.d.ts.map +1 -0
- package/dist/cli/lib/rpcFunctions.js +26 -0
- package/dist/cli/lib/runnerContext.d.ts +32 -0
- package/dist/cli/lib/runnerContext.d.ts.map +1 -0
- package/dist/cli/lib/runnerContext.js +156 -0
- package/dist/cli/lib/shardManager.d.ts +40 -0
- package/dist/cli/lib/shardManager.d.ts.map +1 -0
- package/dist/cli/lib/shardManager.js +80 -0
- package/dist/cli/lib/upgradeProcedures.d.ts +5 -0
- package/dist/cli/lib/upgradeProcedures.d.ts.map +1 -0
- package/dist/cli/lib/upgradeProcedures.js +221 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +3 -0
- package/dist/contracts/contractInteraction.d.ts +17 -0
- package/dist/contracts/contractInteraction.d.ts.map +1 -0
- package/dist/contracts/contractInteraction.js +170 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/foundations/chopsticks/handler.d.ts +3 -0
- package/dist/foundations/chopsticks/handler.d.ts.map +1 -0
- package/dist/foundations/chopsticks/handler.js +93 -0
- package/dist/foundations/chopsticks/helpers.d.ts +27 -0
- package/dist/foundations/chopsticks/helpers.d.ts.map +1 -0
- package/dist/foundations/chopsticks/helpers.js +133 -0
- package/dist/foundations/dev/handler.d.ts +3 -0
- package/dist/foundations/dev/handler.d.ts.map +1 -0
- package/dist/foundations/dev/handler.js +136 -0
- package/dist/foundations/dev/helpers.d.ts +27 -0
- package/dist/foundations/dev/helpers.d.ts.map +1 -0
- package/dist/foundations/dev/helpers.js +161 -0
- package/dist/foundations/read-only/handler.d.ts +3 -0
- package/dist/foundations/read-only/handler.d.ts.map +1 -0
- package/dist/foundations/read-only/handler.js +32 -0
- package/dist/foundations/zombie/handler.d.ts +3 -0
- package/dist/foundations/zombie/handler.d.ts.map +1 -0
- package/dist/foundations/zombie/handler.js +92 -0
- package/dist/foundations/zombie/helpers.d.ts +16 -0
- package/dist/foundations/zombie/helpers.d.ts.map +1 -0
- package/dist/foundations/zombie/helpers.js +97 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/internal/common.d.ts +3 -0
- package/dist/internal/common.d.ts.map +1 -0
- package/dist/internal/common.js +41 -0
- package/dist/internal/index.d.ts +4 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +3 -0
- package/dist/internal/logger.d.ts +24 -0
- package/dist/internal/logger.d.ts.map +1 -0
- package/dist/internal/logger.js +66 -0
- package/dist/internal/logging.d.ts +7 -0
- package/dist/internal/logging.d.ts.map +1 -0
- package/dist/internal/logging.js +36 -0
- package/dist/moondebug.d.ts +3 -0
- package/dist/moondebug.d.ts.map +1 -0
- package/dist/moondebug.js +2 -0
- package/dist/services/cache/FileLock.d.ts +11 -0
- package/dist/services/cache/FileLock.d.ts.map +1 -0
- package/dist/services/cache/FileLock.js +68 -0
- package/dist/services/cache/StartupCacheService.d.ts +23 -0
- package/dist/services/cache/StartupCacheService.d.ts.map +1 -0
- package/dist/services/cache/StartupCacheService.js +159 -0
- package/dist/services/cache/index.d.ts +3 -0
- package/dist/services/cache/index.d.ts.map +1 -0
- package/dist/services/cache/index.js +2 -0
- package/dist/services/chopsticks/ChopsticksMultiChain.d.ts +158 -0
- package/dist/services/chopsticks/ChopsticksMultiChain.d.ts.map +1 -0
- package/dist/services/chopsticks/ChopsticksMultiChain.js +282 -0
- package/dist/services/chopsticks/ChopsticksService.d.ts +313 -0
- package/dist/services/chopsticks/ChopsticksService.d.ts.map +1 -0
- package/dist/services/chopsticks/ChopsticksService.js +77 -0
- package/dist/services/chopsticks/chopsticksConfigParser.d.ts +40 -0
- package/dist/services/chopsticks/chopsticksConfigParser.d.ts.map +1 -0
- package/dist/services/chopsticks/chopsticksConfigParser.js +201 -0
- package/dist/services/chopsticks/index.d.ts +5 -0
- package/dist/services/chopsticks/index.d.ts.map +1 -0
- package/dist/services/chopsticks/index.js +4 -0
- package/dist/services/chopsticks/launchChopsticksEffect.d.ts +225 -0
- package/dist/services/chopsticks/launchChopsticksEffect.d.ts.map +1 -0
- package/dist/services/chopsticks/launchChopsticksEffect.js +623 -0
- package/dist/services/config/configAccessors.d.ts +41 -0
- package/dist/services/config/configAccessors.d.ts.map +1 -0
- package/dist/services/config/configAccessors.js +149 -0
- package/dist/services/config/index.d.ts +2 -0
- package/dist/services/config/index.d.ts.map +1 -0
- package/dist/services/config/index.js +1 -0
- package/dist/services/errors.d.ts +72 -0
- package/dist/services/errors.d.ts.map +1 -0
- package/dist/services/errors.js +31 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +6 -0
- package/dist/services/network/NodeReadinessService.d.ts +35 -0
- package/dist/services/network/NodeReadinessService.d.ts.map +1 -0
- package/dist/services/network/NodeReadinessService.js +120 -0
- package/dist/services/network/PortDiscoveryService.d.ts +22 -0
- package/dist/services/network/PortDiscoveryService.d.ts.map +1 -0
- package/dist/services/network/PortDiscoveryService.js +77 -0
- package/dist/services/network/RpcPortDiscoveryService.d.ts +25 -0
- package/dist/services/network/RpcPortDiscoveryService.d.ts.map +1 -0
- package/dist/services/network/RpcPortDiscoveryService.js +136 -0
- package/dist/services/network/index.d.ts +4 -0
- package/dist/services/network/index.d.ts.map +1 -0
- package/dist/services/network/index.js +3 -0
- package/dist/services/process/ProcessManagerService.d.ts +49 -0
- package/dist/services/process/ProcessManagerService.d.ts.map +1 -0
- package/dist/services/process/ProcessManagerService.js +162 -0
- package/dist/services/process/index.d.ts +3 -0
- package/dist/services/process/index.d.ts.map +1 -0
- package/dist/services/process/index.js +2 -0
- package/dist/services/process/launchNodeEffect.d.ts +40 -0
- package/dist/services/process/launchNodeEffect.d.ts.map +1 -0
- package/dist/services/process/launchNodeEffect.js +86 -0
- package/dist/util/functions/index.d.ts +3 -0
- package/dist/util/functions/index.d.ts.map +1 -0
- package/dist/util/functions/index.js +4 -0
- package/dist/util/index.d.ts +4 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +2 -0
- package/package.json +157 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import clear from "clear";
|
|
3
|
+
import colors from "colors";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import cfonts from "cfonts";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { SemVer, lt } from "semver";
|
|
8
|
+
import pkg from "../../../package.json" with { type: "json" };
|
|
9
|
+
import { createFolders, deriveTestIds, executeScript, fetchArtifact, generateConfig, getVersions, } from "../internal/index.js";
|
|
10
|
+
import { configExists, importAsyncConfig } from "../lib/configReader.js";
|
|
11
|
+
import { allReposAsync, standardRepos } from "../lib/repoDefinitions/index.js";
|
|
12
|
+
import { runNetworkCmd } from "./runNetwork.js";
|
|
13
|
+
import { testCmd } from "./runTests.js";
|
|
14
|
+
import { Octokit } from "@octokit/rest";
|
|
15
|
+
import { checkbox, confirm, input, select, Separator } from "@inquirer/prompts";
|
|
16
|
+
const octokit = new Octokit({
|
|
17
|
+
baseUrl: "https://api.github.com",
|
|
18
|
+
log: {
|
|
19
|
+
debug: () => { },
|
|
20
|
+
info: () => { },
|
|
21
|
+
warn: console.warn,
|
|
22
|
+
error: console.error,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
export async function main() {
|
|
26
|
+
for (;;) {
|
|
27
|
+
const globalConfig = (await configExists()) ? await importAsyncConfig() : undefined;
|
|
28
|
+
clear();
|
|
29
|
+
await printIntro();
|
|
30
|
+
if (await mainMenu(globalConfig)) {
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
process.stdout.write("Goodbye! 👋\n");
|
|
35
|
+
}
|
|
36
|
+
async function mainMenu(config) {
|
|
37
|
+
const configPresent = config !== undefined;
|
|
38
|
+
const menuChoice = await select({
|
|
39
|
+
message: "Main Menu - Please select one of the following:",
|
|
40
|
+
default: "init",
|
|
41
|
+
pageSize: 12,
|
|
42
|
+
choices: !configPresent
|
|
43
|
+
? [
|
|
44
|
+
{
|
|
45
|
+
name: !configPresent
|
|
46
|
+
? "1) Initialise: Generate a new Moonwall Config File"
|
|
47
|
+
: chalk.dim("1) Initialise: ✅ CONFIG ALREADY GENERATED"),
|
|
48
|
+
value: "init",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "2) Artifact Downloader: Fetch artifacts (x86) from GitHub repos",
|
|
52
|
+
value: "download",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "3) Quit Application",
|
|
56
|
+
value: "quit",
|
|
57
|
+
},
|
|
58
|
+
]
|
|
59
|
+
: [
|
|
60
|
+
{
|
|
61
|
+
name: "1) Execute Script: Run scripts placed in your config defined script directory",
|
|
62
|
+
value: "exec",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "2) Network Launcher & Toolbox: Launch network, access tools: tail logs, interactive tests etc",
|
|
66
|
+
value: "run",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "3) Test Suite Execution: Run automated tests, start network if needed",
|
|
70
|
+
value: "test",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "4) Artifact Downloader: Fetch artifacts (x86) from GitHub repos",
|
|
74
|
+
value: "download",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "5) Rename TestIDs: Rename test id prefixes based on position in the directory tree",
|
|
78
|
+
value: "derive",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "6) Quit Application",
|
|
82
|
+
value: "quit",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
switch (menuChoice) {
|
|
87
|
+
case "init":
|
|
88
|
+
await generateConfig({});
|
|
89
|
+
await createFolders();
|
|
90
|
+
return false;
|
|
91
|
+
case "run": {
|
|
92
|
+
if (!config) {
|
|
93
|
+
throw new Error("Config not defined, this is a defect please raise it.");
|
|
94
|
+
}
|
|
95
|
+
const chosenRunEnv = await chooseRunEnv(config);
|
|
96
|
+
process.env.MOON_RUN_SCRIPTS = "true";
|
|
97
|
+
if (chosenRunEnv.envName !== "back") {
|
|
98
|
+
await runNetworkCmd(chosenRunEnv);
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
case "test": {
|
|
103
|
+
if (!config) {
|
|
104
|
+
throw new Error("Config not defined, this is a defect please raise it.");
|
|
105
|
+
}
|
|
106
|
+
const chosenTestEnv = await chooseTestEnv(config);
|
|
107
|
+
if (chosenTestEnv.envName !== "back") {
|
|
108
|
+
process.env.MOON_RUN_SCRIPTS = "true";
|
|
109
|
+
await testCmd(chosenTestEnv.envName);
|
|
110
|
+
await input({
|
|
111
|
+
message: `ℹ️ Test run for ${chalk.bgWhiteBright.black(chosenTestEnv.envName)} has been completed. Press any key to continue...\n`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
case "download":
|
|
117
|
+
await resolveDownloadChoice();
|
|
118
|
+
return false;
|
|
119
|
+
case "quit":
|
|
120
|
+
return await resolveQuitChoice();
|
|
121
|
+
case "exec": {
|
|
122
|
+
if (!config) {
|
|
123
|
+
throw new Error("Config not defined, this is a defect please raise it.");
|
|
124
|
+
}
|
|
125
|
+
return await resolveExecChoice(config);
|
|
126
|
+
}
|
|
127
|
+
case "derive": {
|
|
128
|
+
clear();
|
|
129
|
+
const rootDir = await input({
|
|
130
|
+
message: "Enter the root testSuites directory to process:",
|
|
131
|
+
default: "suites",
|
|
132
|
+
});
|
|
133
|
+
await deriveTestIds({ rootDir });
|
|
134
|
+
await input({
|
|
135
|
+
message: `ℹ️ Renaming task for ${chalk.bold(`/${rootDir}`)} has been completed. Press any key to continue...\n`,
|
|
136
|
+
});
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
default:
|
|
140
|
+
throw new Error("Invalid choice");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function resolveExecChoice(config) {
|
|
144
|
+
const scriptDir = config.scriptsDir;
|
|
145
|
+
if (!scriptDir) {
|
|
146
|
+
await input({
|
|
147
|
+
message: `ℹ️ No scriptDir property defined at ${chalk.bgWhiteBright.black("moonwall.config.json")}\n Press any key to continue...\n`,
|
|
148
|
+
});
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (!fs.existsSync(scriptDir)) {
|
|
152
|
+
await input({
|
|
153
|
+
message: `ℹ️ No scriptDir found at at ${chalk.bgWhiteBright.black(path.join(process.cwd(), scriptDir))}\n Press any key to continue...\n`,
|
|
154
|
+
});
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const files = await fs.promises.readdir(scriptDir);
|
|
158
|
+
if (!files) {
|
|
159
|
+
await input({
|
|
160
|
+
message: `ℹ️ No scripts found at ${chalk.bgWhiteBright.black(path.join(process.cwd(), config.scriptsDir || ""))}\n Press any key to continue...\n`,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const choices = files.map((file) => {
|
|
164
|
+
const ext = getExtString(file);
|
|
165
|
+
return { name: `${ext}: ${path.basename(file, "")}`, value: file };
|
|
166
|
+
});
|
|
167
|
+
for (;;) {
|
|
168
|
+
const selections = await checkbox({
|
|
169
|
+
message: "Select which scripts you'd like to run (press ↩️ with none selected to go 🔙)\n",
|
|
170
|
+
choices,
|
|
171
|
+
});
|
|
172
|
+
if (selections.length === 0) {
|
|
173
|
+
const noneSelected = await confirm({
|
|
174
|
+
message: "No scripts have been selected to run, do you wish to exit?",
|
|
175
|
+
default: true,
|
|
176
|
+
});
|
|
177
|
+
if (noneSelected) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
for (const script of selections) {
|
|
183
|
+
const args = await input({
|
|
184
|
+
message: `Enter any arguments for ${chalk.bgWhiteBright.black(script)} (press enter for none)`,
|
|
185
|
+
});
|
|
186
|
+
await executeScript(script, args);
|
|
187
|
+
}
|
|
188
|
+
await input({
|
|
189
|
+
message: "Press any key to continue...\n",
|
|
190
|
+
});
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function resolveDownloadChoice() {
|
|
195
|
+
const repos = (await configExists()) ? await allReposAsync() : standardRepos();
|
|
196
|
+
const binList = repos.reduce((acc, curr) => {
|
|
197
|
+
acc.push(...curr.binaries.flatMap((bin) => bin.name));
|
|
198
|
+
acc.push(new Separator());
|
|
199
|
+
acc.push("Back");
|
|
200
|
+
acc.push(new Separator());
|
|
201
|
+
return acc;
|
|
202
|
+
}, []);
|
|
203
|
+
for (;;) {
|
|
204
|
+
const firstChoice = await select({
|
|
205
|
+
message: "Download - which artifact?",
|
|
206
|
+
choices: binList,
|
|
207
|
+
});
|
|
208
|
+
if (firstChoice === "Back") {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const versions = await getVersions(firstChoice, firstChoice.includes("runtime"));
|
|
212
|
+
const chooseversion = await select({
|
|
213
|
+
default: "latest",
|
|
214
|
+
message: "Download - which version?",
|
|
215
|
+
choices: [...versions, new Separator(), "Back", new Separator()],
|
|
216
|
+
});
|
|
217
|
+
if (chooseversion === "Back") {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const chooseLocation = await input({
|
|
221
|
+
message: "Download - where would you like it placed?",
|
|
222
|
+
default: "./tmp",
|
|
223
|
+
});
|
|
224
|
+
const result = await confirm({
|
|
225
|
+
message: `You are about to download ${chalk.bgWhite.blackBright(firstChoice)} v-${chalk.bgWhite.blackBright(chooseversion)} to: ${chalk.bgWhite.blackBright(chooseLocation)}.\n Would you like to continue? `,
|
|
226
|
+
default: true,
|
|
227
|
+
});
|
|
228
|
+
if (result === false) {
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
await fetchArtifact({
|
|
232
|
+
bin: firstChoice,
|
|
233
|
+
ver: chooseversion,
|
|
234
|
+
path: chooseLocation,
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const chooseTestEnv = async (config) => {
|
|
240
|
+
const envs = config.environments
|
|
241
|
+
.map((a) => ({
|
|
242
|
+
name: `[${a.foundation.type}] ${a.name}${a.description ? `: \t\t${a.description}` : ""}`,
|
|
243
|
+
value: a.name,
|
|
244
|
+
disabled: false,
|
|
245
|
+
}))
|
|
246
|
+
.sort((a, b) => (a.name > b.name ? -1 : +1));
|
|
247
|
+
envs.push(...[new Separator(), { name: "Back", value: "back" }, new Separator()]);
|
|
248
|
+
const envName = (await select({
|
|
249
|
+
message: "Select a environment to run",
|
|
250
|
+
pageSize: 12,
|
|
251
|
+
choices: envs,
|
|
252
|
+
}));
|
|
253
|
+
return { envName };
|
|
254
|
+
};
|
|
255
|
+
const chooseRunEnv = async (config) => {
|
|
256
|
+
const envs = config.environments.map((a) => {
|
|
257
|
+
const result = { name: "", value: a.name, disabled: false };
|
|
258
|
+
if (a.foundation.type === "dev" ||
|
|
259
|
+
a.foundation.type === "chopsticks" ||
|
|
260
|
+
a.foundation.type === "zombie") {
|
|
261
|
+
result.name = `[${a.foundation.type}] ${a.name}${a.description ? `: \t\t${a.description}` : ""}`;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
result.name = chalk.dim(`[${a.foundation.type}] ${a.name} NO NETWORK TO RUN`);
|
|
265
|
+
result.disabled = true;
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
});
|
|
269
|
+
const choices = [
|
|
270
|
+
...envs.filter(({ disabled }) => disabled === false).sort((a, b) => (a.name > b.name ? 1 : -1)),
|
|
271
|
+
new Separator(),
|
|
272
|
+
...envs.filter(({ disabled }) => disabled === true).sort((a, b) => (a.name > b.name ? 1 : -1)),
|
|
273
|
+
new Separator(),
|
|
274
|
+
{ name: "Back", value: "back" },
|
|
275
|
+
new Separator(),
|
|
276
|
+
];
|
|
277
|
+
const envName = (await select({
|
|
278
|
+
message: "Select a environment to run",
|
|
279
|
+
pageSize: 12,
|
|
280
|
+
choices,
|
|
281
|
+
}));
|
|
282
|
+
return { envName };
|
|
283
|
+
};
|
|
284
|
+
const resolveQuitChoice = async () => {
|
|
285
|
+
const result = await confirm({
|
|
286
|
+
message: "Are you sure you want to Quit?",
|
|
287
|
+
default: false,
|
|
288
|
+
});
|
|
289
|
+
return result;
|
|
290
|
+
};
|
|
291
|
+
const printIntro = async () => {
|
|
292
|
+
const currentVersion = new SemVer(pkg.version);
|
|
293
|
+
let remoteVersion = "";
|
|
294
|
+
try {
|
|
295
|
+
const releases = await octokit.rest.repos.listReleases({
|
|
296
|
+
owner: "moonsong-labs",
|
|
297
|
+
repo: "moonwall",
|
|
298
|
+
});
|
|
299
|
+
if (releases.status !== 200 || releases.data.length === 0) {
|
|
300
|
+
throw new Error("No releases found for moonsong-labs.moonwall, try again later.");
|
|
301
|
+
}
|
|
302
|
+
const json = releases.data;
|
|
303
|
+
remoteVersion =
|
|
304
|
+
json.find((a) => a.tag_name.includes("moonwall@"))?.tag_name.split("@")[2] || "unknown";
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
remoteVersion = "unknown";
|
|
308
|
+
console.error(`Fetch Error: ${error}`);
|
|
309
|
+
}
|
|
310
|
+
cfonts.say("Moonwall", {
|
|
311
|
+
gradient: ["#FF66FF", "#9966FF", "#99CCFF", "#99FFFF", "#33FFFF", "#3366FF"],
|
|
312
|
+
transitionGradient: true,
|
|
313
|
+
lineHeight: 4,
|
|
314
|
+
});
|
|
315
|
+
const versionText = remoteVersion !== "unknown" && lt(currentVersion, new SemVer(remoteVersion))
|
|
316
|
+
? `V${currentVersion.version} (New version ${remoteVersion} available!) ${currentVersion.version}`
|
|
317
|
+
: `V${currentVersion.version}`;
|
|
318
|
+
const dividerLength = 90;
|
|
319
|
+
const leftPadding = Math.floor((dividerLength - versionText.length) / 2);
|
|
320
|
+
const rightPadding = dividerLength - versionText.length - leftPadding;
|
|
321
|
+
const formattedDivider = `${colors.rainbow("=".repeat(leftPadding))}${chalk.bgCyan.grey(versionText)}${colors.rainbow("=".repeat(rightPadding))}\n`;
|
|
322
|
+
console.log(formattedDivider);
|
|
323
|
+
};
|
|
324
|
+
const getExtString = (file) => {
|
|
325
|
+
const ext = path.extname(file);
|
|
326
|
+
switch (ext) {
|
|
327
|
+
case ".js":
|
|
328
|
+
return chalk.bgYellow.black(ext);
|
|
329
|
+
case ".ts":
|
|
330
|
+
return chalk.bgBlue.black(ext);
|
|
331
|
+
case ".sh":
|
|
332
|
+
return chalk.bgGreen.black(ext);
|
|
333
|
+
default:
|
|
334
|
+
return chalk.bgRed.black(ext);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runNetwork.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/runNetwork.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB;AAKtD,wBAAsB,aAAa,CAAC,IAAI,EAAE,cAAc,iBAsKvD"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import clear from "clear";
|
|
4
|
+
import { promises as fsPromises } from "node:fs";
|
|
5
|
+
import { render } from "ink";
|
|
6
|
+
import { LogViewer as LogStreamer } from "./components/LogViewer.js";
|
|
7
|
+
import { parse } from "yaml";
|
|
8
|
+
import { clearNodeLogs, reportLogLocation } from "../internal/cmdFunctions/tempLogs.js";
|
|
9
|
+
import { commonChecks } from "../internal/launcherCommon.js";
|
|
10
|
+
import { cacheConfig, getEnvironmentFromConfig, importAsyncConfig, loadEnvVars, } from "../lib/configReader.js";
|
|
11
|
+
import { MoonwallContext, runNetworkOnly } from "../lib/globalContext.js";
|
|
12
|
+
import { shardManager } from "../lib/shardManager.js";
|
|
13
|
+
import { resolveChopsticksInteractiveCmdChoice, resolveDevInteractiveCmdChoice, resolveZombieInteractiveCmdChoice, } from "./interactiveCmds/index.js";
|
|
14
|
+
import { executeTests } from "./runTests.js";
|
|
15
|
+
import { confirm, input, select, Separator } from "@inquirer/prompts";
|
|
16
|
+
let lastSelected = 0;
|
|
17
|
+
export async function runNetworkCmd(args) {
|
|
18
|
+
await cacheConfig();
|
|
19
|
+
process.env.MOON_TEST_ENV = args.envName;
|
|
20
|
+
if (args.subDirectory) {
|
|
21
|
+
process.env.MOON_SUBDIR = args.subDirectory;
|
|
22
|
+
}
|
|
23
|
+
// Initialize shard configuration (defaults to no sharding for run command)
|
|
24
|
+
shardManager.initializeSharding();
|
|
25
|
+
const globalConfig = await importAsyncConfig();
|
|
26
|
+
const env = globalConfig.environments.find(({ name }) => name === args.envName);
|
|
27
|
+
if (!env) {
|
|
28
|
+
const envList = globalConfig.environments
|
|
29
|
+
.map((env) => env.name)
|
|
30
|
+
.sort()
|
|
31
|
+
.join(", ");
|
|
32
|
+
throw new Error(`No environment found in config for: ${chalk.bgWhiteBright.blackBright(args.envName)}\n Environments defined in config are: ${envList}\n`);
|
|
33
|
+
}
|
|
34
|
+
loadEnvVars();
|
|
35
|
+
await commonChecks(env);
|
|
36
|
+
const testFileDirs = env.testFileDir;
|
|
37
|
+
const foundation = env.foundation.type;
|
|
38
|
+
if ((env.foundation.type === "dev" && !env.foundation.launchSpec[0].retainAllLogs) ||
|
|
39
|
+
(env.foundation.type === "chopsticks" && !env.foundation.launchSpec[0].retainAllLogs)) {
|
|
40
|
+
clearNodeLogs();
|
|
41
|
+
}
|
|
42
|
+
await runNetworkOnly();
|
|
43
|
+
clear();
|
|
44
|
+
const portsList = await reportServicePorts();
|
|
45
|
+
reportLogLocation();
|
|
46
|
+
for (const { port } of portsList) {
|
|
47
|
+
console.log(` 🖥️ https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A${port}`);
|
|
48
|
+
}
|
|
49
|
+
if (process.env.MOON_SUBDIR) {
|
|
50
|
+
console.log(chalk.bgWhite.blackBright(`📍 Subdirectory Filter: ${process.env.MOON_SUBDIR}`));
|
|
51
|
+
}
|
|
52
|
+
if (!args.GrepTest) {
|
|
53
|
+
await input({ message: "✅ Press any key to continue...\n" });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
process.env.MOON_RECYCLE = "true";
|
|
57
|
+
process.env.MOON_GREP = args.GrepTest;
|
|
58
|
+
await executeTests(env, { testNamePattern: args.GrepTest, subDirectory: args.subDirectory });
|
|
59
|
+
}
|
|
60
|
+
mainloop: for (;;) {
|
|
61
|
+
const menuChoice = await select({
|
|
62
|
+
message: `Environment : ${chalk.bgGray.cyanBright(args.envName)}\nPlease select a choice: `,
|
|
63
|
+
default: lastSelected,
|
|
64
|
+
pageSize: 10,
|
|
65
|
+
choices: [
|
|
66
|
+
{
|
|
67
|
+
name: "Tail: Print the logs of the current running node to this console",
|
|
68
|
+
value: 1,
|
|
69
|
+
short: "tail",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: `Info: Display Information about this environment ${args.envName}`,
|
|
73
|
+
value: 2,
|
|
74
|
+
short: "info",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: foundation === "dev" || foundation === "chopsticks" || foundation === "zombie"
|
|
78
|
+
? `Command: Run command on network (${chalk.bgGrey.cyanBright(foundation)})`
|
|
79
|
+
: chalk.dim(`Not applicable for foundation type (${chalk.bgGrey.cyanBright(foundation)})`),
|
|
80
|
+
value: 3,
|
|
81
|
+
short: "cmd",
|
|
82
|
+
disabled: foundation !== "dev" && foundation !== "chopsticks" && foundation !== "zombie",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: testFileDirs.length > 0
|
|
86
|
+
? `Test: Execute tests registered for this environment (${chalk.bgGrey.cyanBright(testFileDirs)})`
|
|
87
|
+
: chalk.dim("Test: NO TESTS SPECIFIED"),
|
|
88
|
+
value: 4,
|
|
89
|
+
disabled: !(testFileDirs.length > 0),
|
|
90
|
+
short: "test",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: testFileDirs.length > 0
|
|
94
|
+
? `GrepTest: Execute individual test(s) based on grepping the name / ID (${chalk.bgGrey.cyanBright(testFileDirs)})`
|
|
95
|
+
: chalk.dim("Test: NO TESTS SPECIFIED"),
|
|
96
|
+
value: 5,
|
|
97
|
+
disabled: !(testFileDirs.length > 0),
|
|
98
|
+
short: "grep",
|
|
99
|
+
},
|
|
100
|
+
new Separator(),
|
|
101
|
+
{
|
|
102
|
+
name: "Quit: Close network and quit the application",
|
|
103
|
+
value: 6,
|
|
104
|
+
short: "quit",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
const env = globalConfig.environments.find(({ name }) => name === args.envName);
|
|
109
|
+
if (!env) {
|
|
110
|
+
throw new Error("Environment not found in config. This is an error, please raise.");
|
|
111
|
+
}
|
|
112
|
+
switch (menuChoice) {
|
|
113
|
+
case 1:
|
|
114
|
+
clear();
|
|
115
|
+
await resolveTailChoice(env);
|
|
116
|
+
lastSelected = 0;
|
|
117
|
+
clear();
|
|
118
|
+
break;
|
|
119
|
+
case 2:
|
|
120
|
+
await resolveInfoChoice(env);
|
|
121
|
+
lastSelected = 1;
|
|
122
|
+
break;
|
|
123
|
+
case 3:
|
|
124
|
+
await resolveCommandChoice();
|
|
125
|
+
lastSelected = 2;
|
|
126
|
+
break;
|
|
127
|
+
case 4:
|
|
128
|
+
await resolveTestChoice(env);
|
|
129
|
+
lastSelected = 3;
|
|
130
|
+
break;
|
|
131
|
+
case 5:
|
|
132
|
+
await resolveGrepChoice(env);
|
|
133
|
+
lastSelected = 4;
|
|
134
|
+
break;
|
|
135
|
+
case 6: {
|
|
136
|
+
const quit = await confirm({
|
|
137
|
+
message: "ℹ️ Are you sure you'd like to close network and quit? \n",
|
|
138
|
+
default: false,
|
|
139
|
+
});
|
|
140
|
+
if (quit === true) {
|
|
141
|
+
break mainloop;
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
default:
|
|
146
|
+
throw new Error("invalid value");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
await MoonwallContext.destroy();
|
|
150
|
+
}
|
|
151
|
+
const reportServicePorts = async () => {
|
|
152
|
+
const ctx = await MoonwallContext.getContext();
|
|
153
|
+
const portsList = [];
|
|
154
|
+
const config = getEnvironmentFromConfig();
|
|
155
|
+
switch (config.foundation.type) {
|
|
156
|
+
case "dev": {
|
|
157
|
+
const args = ctx.environment.nodes[0].args;
|
|
158
|
+
const explicitPortArg = args.find((a) => a.includes("ws-port") || a.includes("rpc-port"));
|
|
159
|
+
const port = explicitPortArg ? explicitPortArg.split("=")[1] : "9944";
|
|
160
|
+
portsList.push({ port, name: "dev" });
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case "chopsticks": {
|
|
164
|
+
portsList.push(...(await Promise.all(config.foundation.launchSpec.map(async ({ configPath, name }) => {
|
|
165
|
+
const yaml = parse((await fsPromises.readFile(configPath)).toString());
|
|
166
|
+
return { name, port: yaml.port || "8000" };
|
|
167
|
+
}))));
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case "zombie": {
|
|
171
|
+
const zombieNetwork = ctx.zombieNetwork;
|
|
172
|
+
if (!zombieNetwork) {
|
|
173
|
+
throw new Error("Zombie network not found. This is a bug, please raise an issue.");
|
|
174
|
+
}
|
|
175
|
+
for (const { wsUri, name } of zombieNetwork.relay) {
|
|
176
|
+
portsList.push({ name, port: wsUri.split("ws://127.0.0.1:")[1] });
|
|
177
|
+
}
|
|
178
|
+
for (const paraId of Object.keys(zombieNetwork.paras)) {
|
|
179
|
+
for (const { wsUri, name } of zombieNetwork.paras[paraId].nodes) {
|
|
180
|
+
portsList.push({ name, port: wsUri.split("ws://127.0.0.1:")[1] });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
for (const { port, name } of portsList) {
|
|
186
|
+
console.log(` 🌐 Node ${name} has started, listening on ports - Websocket: ${port}`);
|
|
187
|
+
}
|
|
188
|
+
return portsList;
|
|
189
|
+
};
|
|
190
|
+
const resolveCommandChoice = async () => {
|
|
191
|
+
const ctx = await (await MoonwallContext.getContext()).connectEnvironment();
|
|
192
|
+
switch (ctx.foundation) {
|
|
193
|
+
case "dev":
|
|
194
|
+
await resolveDevInteractiveCmdChoice();
|
|
195
|
+
break;
|
|
196
|
+
case "chopsticks":
|
|
197
|
+
await resolveChopsticksInteractiveCmdChoice();
|
|
198
|
+
break;
|
|
199
|
+
case "zombie":
|
|
200
|
+
await resolveZombieInteractiveCmdChoice();
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const resolveInfoChoice = async (env) => {
|
|
205
|
+
console.log(chalk.bgWhite.blackBright("Node Launch args:"));
|
|
206
|
+
console.dir((await MoonwallContext.getContext()).environment, {
|
|
207
|
+
depth: null,
|
|
208
|
+
});
|
|
209
|
+
console.log(chalk.bgWhite.blackBright("Launch Spec in Config File:"));
|
|
210
|
+
console.dir(env, { depth: null });
|
|
211
|
+
const portsList = await reportServicePorts();
|
|
212
|
+
reportLogLocation();
|
|
213
|
+
for (const { port } of portsList) {
|
|
214
|
+
console.log(` 🖥️ https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A${port}`);
|
|
215
|
+
}
|
|
216
|
+
if (process.env.MOON_SUBDIR) {
|
|
217
|
+
console.log(chalk.bgWhite.blackBright(`📍 Subdirectory Filter: ${process.env.MOON_SUBDIR}`));
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const resolveGrepChoice = async (env, silent = false) => {
|
|
221
|
+
const grep = await input({
|
|
222
|
+
message: "What pattern would you like to filter for (ID/Title): ",
|
|
223
|
+
default: process.env.MOON_GREP || "D01T01",
|
|
224
|
+
});
|
|
225
|
+
process.env.MOON_RECYCLE = "true";
|
|
226
|
+
process.env.MOON_GREP = grep;
|
|
227
|
+
const opts = {
|
|
228
|
+
testNamePattern: grep,
|
|
229
|
+
silent,
|
|
230
|
+
subDirectory: process.env.MOON_SUBDIR,
|
|
231
|
+
};
|
|
232
|
+
if (silent) {
|
|
233
|
+
opts.reporters = ["dot"];
|
|
234
|
+
}
|
|
235
|
+
return await executeTests(env, opts);
|
|
236
|
+
};
|
|
237
|
+
const resolveTestChoice = async (env, silent = false) => {
|
|
238
|
+
process.env.MOON_RECYCLE = "true";
|
|
239
|
+
const opts = { silent, subDirectory: process.env.MOON_SUBDIR };
|
|
240
|
+
if (silent) {
|
|
241
|
+
opts.reporters = ["dot"];
|
|
242
|
+
}
|
|
243
|
+
return await executeTests(env, opts);
|
|
244
|
+
};
|
|
245
|
+
const resolveTailChoice = async (env) => {
|
|
246
|
+
let zombieNodePointer = 0;
|
|
247
|
+
let switchNode;
|
|
248
|
+
let zombieNodes;
|
|
249
|
+
if (process.env.MOON_ZOMBIE_NODES) {
|
|
250
|
+
zombieNodes = process.env.MOON_ZOMBIE_NODES.split("|");
|
|
251
|
+
}
|
|
252
|
+
for (;;) {
|
|
253
|
+
switchNode = false;
|
|
254
|
+
await new Promise(async (resolve) => {
|
|
255
|
+
const logFilePath = process.env.MOON_ZOMBIE_NODES
|
|
256
|
+
? `${process.env.MOON_ZOMBIE_DIR}/${zombieNodes?.[zombieNodePointer]}.log`
|
|
257
|
+
: process.env.MOON_LOG_LOCATION;
|
|
258
|
+
if (!logFilePath) {
|
|
259
|
+
throw new Error("No log file path resolved, this should not happen. Please raise defect");
|
|
260
|
+
}
|
|
261
|
+
// Resume stdin before rendering with ink - @inquirer/prompts pauses stdin
|
|
262
|
+
// after completing, which prevents ink's useInput from receiving keyboard events
|
|
263
|
+
if (process.stdin.isPaused()) {
|
|
264
|
+
process.stdin.resume();
|
|
265
|
+
}
|
|
266
|
+
const { waitUntilExit } = render(_jsx(LogStreamer, { env: env, logFilePath: logFilePath, onExit: () => resolve(), onNextLog: zombieNodes
|
|
267
|
+
? () => {
|
|
268
|
+
switchNode = true;
|
|
269
|
+
zombieNodePointer = (zombieNodePointer + 1) % zombieNodes.length;
|
|
270
|
+
resolve();
|
|
271
|
+
}
|
|
272
|
+
: undefined, onPrevLog: zombieNodes
|
|
273
|
+
? () => {
|
|
274
|
+
switchNode = true;
|
|
275
|
+
zombieNodePointer =
|
|
276
|
+
(zombieNodePointer - 1 + zombieNodes.length) % zombieNodes.length;
|
|
277
|
+
resolve();
|
|
278
|
+
}
|
|
279
|
+
: undefined, zombieInfo: zombieNodes
|
|
280
|
+
? {
|
|
281
|
+
currentNode: zombieNodes[zombieNodePointer],
|
|
282
|
+
position: zombieNodePointer + 1,
|
|
283
|
+
total: zombieNodes.length,
|
|
284
|
+
}
|
|
285
|
+
: undefined }));
|
|
286
|
+
await waitUntilExit();
|
|
287
|
+
});
|
|
288
|
+
if (!switchNode) {
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Environment } from "../../api/types/index.js";
|
|
2
|
+
import type { TestUserConfig, Vitest } from "vitest/node";
|
|
3
|
+
export declare function testCmd(envName: string, additionalArgs?: testRunArgs): Promise<boolean>;
|
|
4
|
+
export type testRunArgs = {
|
|
5
|
+
testNamePattern?: string;
|
|
6
|
+
subDirectory?: string;
|
|
7
|
+
shard?: string;
|
|
8
|
+
update?: boolean;
|
|
9
|
+
vitestPassthroughArgs?: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare function executeTests(env: Environment, testRunArgs?: testRunArgs & TestUserConfig): Promise<Vitest>;
|
|
12
|
+
//# sourceMappingURL=runTests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTests.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/runTests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iCAAiC;AAG5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmC1D,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAgD7F;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF,wBAAsB,YAAY,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,cAAc,mBA2G9F"}
|