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

ns-flip

v2.5.0

Published

build and use updatable templates: can be reapplied to code without losing custom changes to files.

Downloads

46

Readme

ns-flip

Make and use updatable project templates. Regenerate code without losing custom changes. Framework agnostic.

oclif Version Downloads/week License

Why

After you generate code with a template or tool, you make changes. But then usually you can't regenerate the code without losing your changes. So you can't apply an updated template or change to another one supporting the same inputs. Keeping your "legacy code" current becomes an expensive pain.

What

ns-flip is a CLI to support creating and using project generators that can be exchanged as easily as WordPress themes. Here is a sample with 1 minute video.

A "template" can generate any combination of three types of files:

  1. standard (appear in every generated code base, e.g. App.jsx)
  2. custom static (static, but must be custom specified for each code base, e.g. steps in an input stepper)
  3. custom dynamic (based on queries e.g. components showing query results).

You can create templates with locations designated for custom code within the generated files. You can also name regions that can be replaced or removed in the generated code. Ns-flip stores the custom changes before regenerating and then restores them.

See some standard use cases.

How

A template is a directory with requirements explained in the documentation. You can use it privately or distribute it.
You will need a basic working knowledge of Handlebars and not much more.

ns-flip-commands

  1. Build a template from sample code by calling ns newtemplate with a sample code base.
  2. Generate or regenerate code from the template : ns generate $CODE [-t $TEMPLATE. All safe changes to $CODE are preserved. There's a settings file for the code base that determines what is generated.
  3. Modify your requirements by running ns settings $CODE. Just answer the prompts.
  4. Add custom code. But periodically run ns check $CODE to be sure you are doing it safely. (Otherwise, some of your changes will not be preserved when ns generate is run in the future.)

Help

Getting Started with ns-flip 1.6 Templating

Usage

$ npm install -g ns-flip
$ ns COMMAND
running command...
$ ns (-v|--version|version)
ns-flip/2.5.0 linux-x64 node-v14.9.0
$ ns --help [COMMAND]
USAGE
  $ ns COMMAND
...

Commands

ns check CODEDIR

Confirms that your custom changes have been entered safely, allowing you to generate with an updated or replaced template, or with a changed 'ns.yml' file. Essentially, generates a new version of the code and then simply compares it against your current version. If there are differences, then there is a problem with your code. For documentation about safe custom code changes, please see https://ns-flip.nostack.net//Safe-Custom-Code.

USAGE
  $ ns check CODEDIR

ARGUMENTS
  CODEDIR  directory containing the code to check

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ ns check ~/projects/myapp

See code: lib/commands/check.js

ns contact [MESSAGE]

send feedback or request to ns-flip. Optionally provide email and other fields.

USAGE
  $ ns contact [MESSAGE]

ARGUMENTS
  MESSAGE  the message to send

OPTIONS
  -e, --email=email  email of sender
  -h, --help         show CLI help

EXAMPLES
  $ ns contact "how do I set up comment delimiters with escape chars?" -e [email protected]
  $ ns contact "generate is breaking when I add handlers."

See code: lib/commands/contact.js

ns filediffs TEMPLATEDIR

compare the files in your sample target code and in the code being generated. In some cases makes suggestions.

USAGE
  $ ns filediffs TEMPLATEDIR

ARGUMENTS
  TEMPLATEDIR  directory containing the template

OPTIONS
  -c, --codeDir=codeDir    code directory.  Will override the default
  -h, --help               show CLI help
  -s, --modelDir=modelDir  model directory.  Will override the default

EXAMPLES
  $ ns filediffs $TEMPLATE
  $ ns filediffs $TEMPLATE -c $CODE -m $MODEL

See code: lib/commands/filediffs.js

ns generate CODEDIR

generates code based on a template and an 'ns file'. To set the template, you need the template flag.

USAGE
  $ ns generate CODEDIR

ARGUMENTS
  CODEDIR  directory containing the code to check

OPTIONS
  -h, --help                     show CLI help

  -n, --noSetup                  Do not update the startup routine (this is only relevant when the templateDir flag is
                                 also used). Saves a lot of time for a template developer.

  -t, --templateDir=templateDir  Template directory. Will generate from the template, and will override any prior
                                 template or template version used.

EXAMPLES
  $ ns generate ~/ns/samples/out -t ~/ns/templates/basicTemplate
  $ ns generate $CODE -t $TEMPLATE --noSetup
  $ ns generate $CODE

See code: lib/commands/generate.js

ns help [COMMAND]

display help for ns

USAGE
  $ ns help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

ns newtemplate

create new template.

USAGE
  $ ns newtemplate

OPTIONS
  -h, --help                     show CLI help
  -m, --model=model              directory containing the model code base from which you want to template
  -t, --templateDir=templateDir  directory for the template

EXAMPLE
  $ ns newtemplate -m $MODEL -t $TEMPLATE

See code: lib/commands/newtemplate.js

ns settings CODEDIR

create new template.

USAGE
  $ ns settings CODEDIR

ARGUMENTS
  CODEDIR  directory containing the code

OPTIONS
  -h, --help  show CLI help

EXAMPLE
  $ ns settings $CODE

See code: lib/commands/settings.js