Skip to content

Commit

Permalink
Feat/upgrade vitest (#425)
Browse files Browse the repository at this point in the history
* update pkgs

* new menu

* fmt

* add api key

* changeset

* newest vitest
  • Loading branch information
timbrinded authored Jul 8, 2024
1 parent dca2509 commit 1b3256a
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 240 deletions.
11 changes: 11 additions & 0 deletions .changeset/shaggy-dingos-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@moonwall/types": patch
"@moonwall/util": patch
"@moonwall/cli": patch
"@moonwall/tests": patch
---

Update Vitest
- Use Vitest 2.0.0
- New menu graphics!
- GITHUB_TOKEN support on downloader feature
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- "**"
env:
WSS_URL: ws://127.0.0.1:9955
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
Expand Down
12 changes: 7 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@
"@polkadot/types-codec": "12.1.1",
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"@vitest/ui": "1.6.0",
"@vitest/ui": "2.0.1",
"@zombienet/orchestrator": "0.0.87",
"@zombienet/utils": "0.0.25",
"bottleneck": "2.19.5",
"cfonts": "^3.3.0",
"chalk": "5.3.0",
"clear": "0.1.0",
"cli-progress": "3.12.0",
Expand All @@ -87,8 +88,9 @@
"jsonc-parser": "3.3.1",
"minimatch": "9.0.5",
"semver": "7.6.2",
"viem": "2.17.0",
"vitest": "1.6.0",
"viem": "2.17.3",
"vitest": "2.0.1",
"vue": "^3.4.31",
"web3": "4.10.0",
"web3-providers-ws": "^4.0.7",
"ws": "8.18.0",
Expand All @@ -104,10 +106,10 @@
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/clear": "^0.1.4",
"@types/cli-progress": "3.11.5",
"@types/cli-progress": "3.11.6",
"@types/debug": "4.1.12",
"@types/inquirer": "^9.0.7",
"@types/node": "20.14.9",
"@types/node": "20.14.10",
"@types/semver": "^7.5.8",
"@types/ws": "^8.5.10",
"@types/yargs": "17.0.32",
Expand Down
64 changes: 17 additions & 47 deletions packages/cli/src/cmds/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import chalk from "chalk";
import clear from "clear";
import colors from "colors";
import fs from "node:fs";
import cfonts from "cfonts";
import inquirer from "inquirer";
import PressToContinuePrompt from "inquirer-press-to-continue";
import path from "node:path";
Expand Down Expand Up @@ -445,55 +446,24 @@ const printIntro = async () => {
console.error(`Fetch Error: ${error}`);
}

const logo =
chalk.cyan(`\n
####################
############################
###################################
########################################
###########################################
##############################################
################################################
.#################################################
##################################################
##################################################
`) +
chalk.red(`
🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱
🧱🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱
🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱
🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱
🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱
🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱
🧱🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱🧱
\n`);
process.stdout.write(logo);
process.stdout.write(
colors.rainbow(
"================================================================================\n"
)
);
cfonts.say("Moonwall", {
gradient: ["#FF66FF", "#9966FF", "#99CCFF", "#99FFFF", "#33FFFF", "#3366FF"],
transitionGradient: true,
lineHeight: 4,
});

if (remoteVersion !== "unknown" && lt(currentVersion, new SemVer(remoteVersion))) {
process.stdout.write(
chalk.bgCyan.white(
` MOONWALL V${currentVersion.version} (New version ${remoteVersion} available!) \n`
)
);
} else {
process.stdout.write(
chalk.bgCyan.white(
` MOONWALL V${currentVersion.version} \n`
)
);
}
const versionText =
remoteVersion !== "unknown" && lt(currentVersion, new SemVer(remoteVersion))
? `V${currentVersion.version} (New version ${remoteVersion} available!) ${currentVersion.version}`
: `V${currentVersion.version}`;

process.stdout.write(
colors.rainbow(
"================================================================================\n"
)
);
const dividerLength = 90;
const leftPadding = Math.floor((dividerLength - versionText.length) / 2);
const rightPadding = dividerLength - versionText.length - leftPadding;

const formattedDivider = `${colors.rainbow("=".repeat(leftPadding))}${chalk.bgCyan.grey(versionText)}${colors.rainbow("=".repeat(rightPadding))}\n`;

console.log(formattedDivider);
};

const getExtString = (file: string) => {
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/cmds/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export async function executeTests(env: Environment, testRunArgs?: testRunArgs)
const options = new VitestOptionsBuilder()
.setReporters(env.reporters || ["default"])
.setOutputFile(env.reportFile)
.setName(env.name)
.setTimeout(env.timeout || globalConfig.defaultTestTimeout)
.setInclude(env.include || ["**/*{test,spec,test_,test-}*{ts,mts,cts}"])
.addThreadConfig(env.multiThreads)
Expand Down Expand Up @@ -150,6 +151,7 @@ class VitestOptionsBuilder {
optimizer: { ssr: { enabled: false }, web: { enabled: false } },
},
include: ["**/*{test,spec,test_,test-}*{ts,mts,cts}"],

onConsoleLog(log) {
if (filterList.includes(log.trim())) return false;
if (log.includes("has multiple versions, ensure that there is only one installed.")) {
Expand All @@ -158,6 +160,11 @@ class VitestOptionsBuilder {
},
};

setName(name: string): this {
this.options.name = name;
return this;
}

setReporters(reporters: string[]): this {
this.options.reporters = reporters;
return this;
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/internal/cmdFunctions/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export async function downloader(url: string, outputPath: string): Promise<void>
console.log("You've passed a WebSocket URL to fetch. Is this intended?");
}

const response = await fetch(url);
const headers: any = {};
if (process.env.GITHUB_TOKEN) {
headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
}
const response = await fetch(url, { headers });

if (!response.body) {
throw new Error("No response body");
Expand Down
4 changes: 2 additions & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
"@polkadot/types": "12.1.1",
"@polkadot/util": "12.6.2",
"@polkadot/util-crypto": "12.6.2",
"@types/node": "20.14.9",
"@types/node": "20.14.10",
"@zombienet/utils": "0.0.25",
"bottleneck": "2.19.5",
"debug": "4.3.5",
"ethers": "6.13.1",
"viem": "2.17.0",
"viem": "2.17.3",
"web3": "4.10.0"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
"inquirer-press-to-continue": "1.2.0",
"rlp": "3.0.0",
"semver": "7.6.2",
"viem": "2.17.0",
"vitest": "1.6.0",
"viem": "2.17.3",
"vitest": "2.0.1",
"web3": "4.10.0",
"ws": "8.18.0",
"yaml": "2.4.5",
Expand All @@ -89,7 +89,7 @@
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/debug": "4.1.12",
"@types/node": "20.14.9",
"@types/node": "20.14.10",
"@types/ws": "^8.5.10",
"@types/yargs": "17.0.32",
"tsup": "8.1.0",
Expand Down
Loading

0 comments on commit 1b3256a

Please sign in to comment.