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

anno-cli

v1.0.5

Published

This is anno-cli

Downloads

9

Readme

Anno-cli

What is Anno-cli

Anno-cli is a cli tool which can be used with Anno.js together.

Getting Started

Installation

Run $ npm i -g anno-cli or $ npm i -save-dev anno-cli to install the latest version of anno-cli.

Generate template

Run anno-cli t to generate template.

Step 1 Choose a template

$ anno-cli t
? What template would you like to generate? (Use arrow keys)
❯ foo-bar(local)
  foo-bar

Step 2 Input path

$ anno-cli t
? What template would you like to generate? foo-bar(local)
? What path would you like to generate to? path: foo-bar

Step 3 Input class name, and press enter. You will generate files according to your own defined template. NOTE: The class name can be defined in your own way.

$ anno-cli t
? What template would you like to generate? foo-bar(local)
? What path would you like to generate to? path: foo-bar
? What class name do you prefer? className: FooBar
$ anno-cli t
? What template would you like to generate? foo-bar(local)
? What path would you like to generate to? path: foo-bar
? What class name do you prefer? className: FooBar
/anno.js/tests/e2e/foo-bar/test.spec.js
/anno.js/src/foo-bar/bar/index.module.scss
/anno.js/src/foo-bar/bar/index.tsx
/anno.js/src/foo-bar/index.module.scss
/anno.js/src/foo-bar/index.page.tsx
/anno.js/tests/unit/foo-bar/test.spec.js

Define Your Own Template

You can define your own local template in your local folder ./templates.

Step 1 Template folder structure

templates
├── foo-bar
    ├── e2e
    │   └── test.spec.js 
    ├── src
    │   └── bar 
    │   │   ├── index.module.scss
    │   │   └── index.tsx
    │   ├── index.module.scss
    │   └── index.page.tsx
    ├── unit
    │   └── test.spec.js 
    └── config.json

Step 2 Config template

  1. config.map is used for matching the template path to the destination path.
  2. config.prompts is used for defining variables which can be input in questions, which might be used in template later. For more detail, refer to inquirer.

config.js

const config = {
  map: {
    src: 'src', 
    e2e: 'tests/e2e', 
    unit: 'tests/unit', 
  },
  prompts: [
    {
      name: 'className',
      type: 'input',
      message: 'What class name do you prefer? className:',
      validate: function (input) {
        if (/^([A-Za-z\-\_\d])+$/.test(input)) return true
        else return 'Class name may only include letters, numbers, underscores and hashes.'
      },
    },
  ]
}

module.exports = config

Step 3 Edit template file

  1. We use ejs to render remplate. For more detail, refer to ejs.
  2. All variables are under root, like root.className, which should be same as it in config.js. We can get path from root.$PATH and get template which we selected from root.$TEMPLATE.

templates/foo-bar/src/index.page.tsx

import { Component, Vue } from 'vue-property-decorator'
import Bar from './bar'
import style from './index.module.scss'

@Component
export default class <%=root.className%> extends Vue {

  private render(h: CreateElement, context: any) {
    return (
      <div class={style.container} id="<%=root.className%>">
        Welcome to <%=root.className%>
        {h(Bar, {})}
      </div>
    )
  }
}

Step 3 The generated files likes below.

NOTE:If you don't wanna generate test files, we cannot decide except you don't define it in template folder. About this, We will improve it later, like prompting a question to let you to decide whether you generate test files.

src/foo-bar/index.page.tsx

import { Component, Vue } from 'vue-property-decorator'
import Bar from './bar'
import style from './index.module.scss'

@Component
export default class FooBar extends Vue {

  private render(h: CreateElement, context: any) {
    return (
      <div class={style.container} id="FooBar">
        Welcome to FooBar
        {h(Bar, {})}
      </div>
    )
  }
}

Dependencies