diff --git a/src/commands/fetch-versions.ts b/src/commands/fetch-versions.ts deleted file mode 100644 index aaec8d6..0000000 --- a/src/commands/fetch-versions.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* eslint-disable camelcase */ -import * as fs from "node:fs"; -import * as path from "node:path"; - -import axios from "axios"; -import { Command } from "@oclif/core"; - -import { WORK_DIR, githubTag } from "../config"; - -export interface Tag { - name: string; - zipball_url: string; - tarball_url: string; - commit: Commit; - node_id: string; -} - -export interface Commit { - sha: string; - url: string; -} - -export default class FetchVersion extends Command { - static description = "Fetch available casper node version from GitHub tags."; - - static args = {}; - - async run(): Promise { - const workDir = path.resolve(__dirname, "../..", WORK_DIR); - - const { data } = await axios.get(githubTag); - - const result = { - fetchedAt: Date.now(), - versions: data.map((tag) => tag.name), - }; - - fs.writeFileSync( - path.resolve(workDir, "versions.json"), - `${JSON.stringify(result)}` - ); - } -} diff --git a/src/commands/node.ts b/src/commands/node.ts index 2d6591b..5b49576 100644 --- a/src/commands/node.ts +++ b/src/commands/node.ts @@ -115,6 +115,7 @@ export default class Node extends Command { }); let rpcStarted = false; + let speculativeStarted = false; let restStarted = false; let eventStreamStarted = false; @@ -152,6 +153,18 @@ export default class Node extends Command { kleur.green(`Started event stream server at http://127.0.0.1:9999`) ); } + + if ( + data.includes("started speculative execution server") && + !speculativeStarted + ) { + speculativeStarted = true; + console.info( + kleur.green( + `Started speculative execution server at http://127.0.0.1:7778` + ) + ); + } }); // log pid for further stop diff --git a/src/utils/check-version.ts b/src/utils/check-version.ts index 141f194..508e75e 100644 --- a/src/utils/check-version.ts +++ b/src/utils/check-version.ts @@ -1,42 +1,42 @@ +/* eslint-disable camelcase */ import * as fs from "node:fs"; import * as path from "node:path"; +import axios from "axios"; -import FetchVersion from "../commands/fetch-versions"; +import { WORK_DIR, githubTag } from "../config"; -import { WORK_DIR } from "../config"; - -interface Props { - forceDownloadTags?: boolean; +export interface Tag { + name: string; + zipball_url: string; + tarball_url: string; + commit: Commit; + node_id: string; } -export const getVersions = async (props?: Props): Promise => { - const { forceDownloadTags = false } = props || {}; - const workDir = path.resolve(__dirname, "../..", WORK_DIR); - const versionFilePath = path.resolve(workDir, "versions.json"); +export interface Commit { + sha: string; + url: string; +} - // Save file tags if version file doesn't exist - if (!fs.existsSync(versionFilePath) || forceDownloadTags) { - await FetchVersion.run(); - } +export const getVersions = async (): Promise => { + const { data } = await axios.get(githubTag); + const versions = data.map((tag) => tag.name); - // load version file - const { versions }: { fetchedAt: number; versions: string[] } = JSON.parse( - fs.readFileSync(versionFilePath, { encoding: "utf-8" }) - ); return versions; }; -export const checkVersion = async ( - version: string, - props?: Props -): Promise => { +export const checkVersion = async (version: string): Promise => { if (version === "dev") return true; + const workDir = path.resolve(__dirname, "../..", WORK_DIR); + + // Return true for downloaded version + if (fs.existsSync(path.resolve(workDir, version))) return true; - const versions = await getVersions(props); + const versions = await getVersions(); return versions.includes(version); }; -export const fetchLatestVersion = async (props?: Props): Promise => { - const versions = await getVersions(props); +export const fetchLatestVersion = async (): Promise => { + const versions = await getVersions(); return versions[0]; }; diff --git a/src/utils/download.ts b/src/utils/download.ts index 497dc92..77e9561 100644 --- a/src/utils/download.ts +++ b/src/utils/download.ts @@ -14,7 +14,7 @@ export default async function download( const response = await fetch(url); if (!response.ok) { - throw new Error("Unable to access"); + throw new Error(`Unable to access to ${url}`); } return new Promise((resolve) => {