Package Exports
- ns-flip
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ns-flip) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ns-flip
A tool for creating and using updatable code templates. Supports regeneration of code without losing custom changes. Framework agnostic.

Why
After you generate code with a template or tool, you make changes to the code. But then usually you can't regenerate it without losing your changes. So you can't apply an updated template or change to another similar template. Keeping your "legacy code" current becomes an expensive pain.
What
ns-flip is a CLI to support code templates that can be exchanged as easily as WordPress themes.
A template can generate three types of files:
- standard (appear in every generated code base, e.g.
App.jsx) - custom static (static, but must be custom specified for each code base, e.g. steps in an input stepper)
- custom dynamic (based on queries e.g. components showing query results).
You can create templates with locations designated for custom code. You can also name regions that can be replaced or removed in the generated code. Ns-flip stores the custom changes before regenerating and 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. To create one, you will need a basic working knowledge of Handlebars and not much more.

- Build a template from sample code by calling
ns newtemplate. - Generate or regenerate code from the template :
ns generate $CODE [-t $TEMPLATE. All safe changes to $CODE are preserved. There's also a meta 'ns' file that stores settings for the code base such as custom instances for data types used in the template. - Add custom code. But periodically run
ns check $CODEto be sure or doing it safely. (Otherwise, some of your changes will not be preserved whenns generateis run in the future.)
Help
- Read our documentation
- Post questions on our Community
- open issues
Usage
$ npm install -g ns-flip
$ ns COMMAND
running command...
$ ns (-v|--version|version)
ns-flip/2.3.4 linux-x64 node-v14.9.0
$ ns --help [COMMAND]
USAGE
$ ns COMMAND
...Commands
ns check CODEDIRns contact [MESSAGE]ns filediffs TEMPLATEDIRns generate CODEDIRns help [COMMAND]ns newtemplatens settings CODEDIR
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/myappSee 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 pauljones123@gmail.com
$ 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, --sampleDir=sampleDir sample directory. Will override the default
EXAMPLE
$ ns filediffs $TEMPLATE -c $CODE -s $SAMPLESee 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 $CODESee 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 CLISee code: @oclif/plugin-help
ns newtemplate
create new template.
USAGE
$ ns newtemplate
OPTIONS
-h, --help show CLI help
EXAMPLE
$ ns newtemplateSee 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 $CODESee code: lib/commands/settings.js
