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

murasame

v0.0.0

Published

Implementation of a command line interfaces decorators.

Downloads

1

Readme

murasame

package engine

Introduction

This project is an implementation of a command line interfaces decorators.

This project was originally created for personal use and had no intention of being open source, as its applicability was limited. However, with JavaScript soon to support decorators, it would be my greatest honor if my code can provide some level of assistance to you.

Chaining

const cli = require('other package');

cli
  .name('my-tools')
  .version('0.0.1')
  .description('Some of my cli tools.');

cli
  .command('test')
  .action(() => {
    // ...
  });

cli.parse();

Decorators

import { Murasame, Program, Command } from 'murasame';

@Program({
  name: 'my-tools',
  version: '0.0.1',
  description: 'Some of my cli tools.',
})
class Tools extends Murasame {
  @Command('test')
  test() {
    // ...
  }
}

const tools = new Tools();
tools.parse();

This is so cool, isn't it?

Install

The current decorator is in stage 3 state in JavaScript, and this project is currently a pure TypeScript package that you can use tools such as ts-node to work with.

npm i typescript ts-node murasame

Usage

You need to set your tsconfig.json compilation target to es2022 or below, and configure your lib setting to either include "esnext" or "esnext.decorators".

{
  "compilerOptions": {
    "target": "es2022",
    "lib": ["es2022", "esnext.decorators"]
  }
}

Example:

import { Murasame, Program, Command } from 'murasame';

@Program({
  name: 'my-tools',
  prefix: 'tool',
  version: '0.0.1',
  description: 'Some of my cli tools.',
})
class Tools extends Murasame {
  @Command('build')
  build(query: Record<string, unknown>) {
    console.log(query);
  }

  @Command('request')
  request(query: Record<string, unknown>) {
    console.log(query);
  }
}

const tools = new Tools();
tools.parse();
$ ts-node index.ts
my-tools

Usage:
  $ tool build
  $ tool request

Some of my cli tools.
$ ts-node index.ts tool build -d --outdir lib
{ d: true, outdir: 'lib' }

References

Murasame.debug(argv: string | string[])

debug() is a static method that can parse and print out the parameters of the current command.

Murasame(options?: minimist.Opts)

You can pass in the options of minimist to change the parameter parsing of the command.

class Tools extends Murasame {
  constructor() {
    super({
      boolean: true,
    });
  }
}

new Murasame().parse()

Parse the parameters of the current process.argv and execute the corresponding method.

FAQ

What does this project name mean?

Murasame is a word that originated from Japan (村雨, ムラサメ, literally "village rain", though often translated as "autumn rain"), refers to a type of rain that falls hard, then gently, in fits and starts. In Japanese poetic tradition, it is particularly associated with the cold rains of autumn.

Additionally, it is also the name of a character in the game "Senren * Banka", She assists her master in various things. I have a fondness for rain and also for 'ムラサメ' (murasame), so I chose it as the name for this project.

Why didn't you provide an option decorators?

This project was initially developed to meet my personal requirements. For parameter parsing, I utilized minimist to handle basic command processing in everyday situations. Consequently, I did not implement any validation for the options.

However, once decorators are supported in JavaScript, I will turn murasame into a truly meaningful package. (●'◡'●)

Thank

The package name "murasame" had already been in use initially, but it was not being actively maintained. After attempting to reach out to the author, they transferred the package to me. I am deeply grateful for this!