npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stackrstaterollback-cli

v1.0.1

Published

A CLI Tool for Snapshotting and Rollbacking states of a Stackr Micro-rollup.

Downloads

6

Readme

Stackr State Rollback CLI

A CLI Tool for Snaphotting and Rollbacking states of a Stackr Micro-rollup.

Introduction

Micro-rollup are basically state machines that are responsible for preserving and updating state of a system. However, evaluating state transitions and ensuring a system operates as expected in specific states often lacks dedicated tools.

The Stackr State Rollback CLI addresses this gap by offering the ability to capture a snapshot of a state and subsequently roll back to it. It is a developer friendly CLI tool particularly made for enhancing the testing and debugging process a micro-rollup.

Features and Benefits

  • In case of server closure due to errors, developers can seamlessly resume testing by rolling back to a previously snapshotted state. This ensures continuity in the testing process

  • Provides a convenient mechanism for developers to document the state of their systems at specific points in time, aiding in comprehensive testing and debugging.

  • Enables quick and seamless transitions between different system states, facilitating efficient testing and debugging workflows.

  • Offers developers a detailed rollback history, enabling thorough analysis of state transitions, complete with action and block details.

Installation

Install stackrstaterollback-cli from CLI , in your project's root directory.

  npm install stackrstaterollback-cli

Usage

After installing the package :

  1. run the command from your project's root directory
  npx stackrstaterollback-cli

This will prompt for two questions:

a. Enter the micro-rollup is running on?

Type the port you are running the app on, you can find it in src/index.ts

b. Enter the current state variable:

Type the name of the variable you are using it to send the current state of the app. You can find it in src/index.ts.

For example if your function looks like this:

app.get("/", (req: Request, res: Response) => {
res.send({
  currentCount: state.get().state.getState(),
  });
}); 

type currentCount as your response fo the question. Also make sure your endpoint is "/" for both: getting current state and for performing action.

  1. Add the following code in src/state.ts:

a. import * as rollback from "../rollbackconfig.json";

b. Add a type in Action Input as "rollback"

for example :

interface CounterActionInput {
  type: "increment" | "decrement" | "rollback";
}

c. Add a else if statement for input type of "rollback" in the STF function.

for example:

else if (inputs.type === "rollback") {
  newState = Number(rollback.desiredState);
}

Note: Here, the StateVariable is a Number, the tool works on the presumption that rollback.desiredState is converted into the type of the StateVariable.

  1. Now run the micro-rollup server from the command: bun run src/index.ts

Run

Note: Make sure the server is running.

To run the Tool, run the command

npx stackrstaterollback-cli

you will get 5 options to select from :

  • Snapshot current state
  • List the snapshotted states
  • Rollback to a snapshotted state
  • List the Rollback History
  • update port and current state variable

Example Responses

Example response of selecting List the snapshotted states

| State | Timestamp | Comment | |-------|-------------------------|-------------------------------------| | 0 | 2024-02-05 14:27:06 | Initial state of DEX1 | | 1 | 2024-02-05 14:28:03 | State of DEX where server stopped |

Example response of selecting List the Rollback History

| Params | Values | |--------------------|----------------------------------------------------------------------------------------------------| | previousState | 1 | | newState | 0 | | actionHash | 0x35904d82998dc2a6f3c97b9948682424aca03486076204e37265cadccc3a3c98 | | currentHeight | 91 | | operatorSignature | 0x23bf00e3c31155afda014f1d7379675f669c023cbc9f0d55a04b9b52ba16c1ef280239427ac06... | | blockHash | 0x6a3d41e492a6cf3f3f151919485b9d19bd43f0e50d2c95347c9aaa551e136e43 | | parentHash | 0xaf936fd63ee69f605c321befec7bea3d4b5043a7f43720dee775a78c29cb01a5 | | acknowledgementRoot| 0x33451cff0eb1bd1f89f6e27172d7093f55a1d421dbc09b729ca21244ec58fad1 |

Appendix

This is like the v0 of the package, it needs some enhancement to make it modular.

Authors