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.

To generate code from a template:
- Create a starter directory by calling
ns newstarter -t <template> -s <starter>. - Create a code base using the starter:
ns newcode -c <code path> -s <starter>. - The code base will have a
metadirectory with a sample ns filemeta/ns.yml. You can modify the ns file to change data types for dynamic files and any static information needed. After any modifications, regenerate the code using [ns regenerate -c <code>](#ns regenerate) - Anyone can add custom code. But periodically run
ns test -c <code>to be certain you did it right. (Otherwise, some of your changes will not be preserved whenns regenerateis run in the future.)
Whenever you want to run an updated version of the template, create a new starter (as in step 1) and then run ns regenerate -c <code> again.
Here's a sample template.
Help
- Read our documentation
- Post questions on our Community
- open issues
In short: don't be shy!
Usage
$ npm install -g ns-flip
$ ns COMMAND
running command...
$ ns (-v|--version|version)
ns-flip/1.6.6 linux-x64 node-v14.9.0
$ ns --help [COMMAND]
USAGE
$ ns COMMAND
...Commands
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 newcode
new code base, based on a starter. You can use generate to update based on the ns.yml file.
USAGE
$ ns newcode
OPTIONS
-c, --codeDir=codeDir code base directory
-h, --help show CLI help
-s, --starterDir=starterDir starter directory.
EXAMPLE
$ ns newcode -c ~/projects/myapp -s ~/ns/starters/currentSee code: lib/commands/newcode.js
ns newstarter
create new starter from a template. You can then generate a new code base from it using newCode.
USAGE
$ ns newstarter
OPTIONS
-c, --sampleDir=sampleDir optional sample generated code directory
-f, --force when force is used, the starter is overwritten without warning.
-h, --help show CLI help
-s, --starterDir=starterDir starter directory
-t, --templateDir=templateDir template directory
EXAMPLES
$ ns newstarter -t ~/ns/templates/basicTemplate -s ~/ns/starters/mystarter
$ ns newstarter -t $TEMPLATE -s $STARTER -c ~/ns/samples/out
$ ns newstarter -t $TEMPLATE -s $STARTER -c $CODE -fSee code: lib/commands/newstarter.js
ns newtemplate
create new template.
USAGE
$ ns newtemplate
OPTIONS
-h, --help show CLI help
EXAMPLE
$ ns newtemplateSee code: lib/commands/newtemplate.js
ns regenerate
regenerates code based on a meta file ns.yml, custom changes, and a starter. The code directory must have been created for the first time using newcode.
USAGE
$ ns regenerate
OPTIONS
-c, --codeDir=codeDir code directory
-h, --help show CLI help
EXAMPLE
$ nd regenerate -c ~/projects/myappSee code: lib/commands/regenerate.js
ns test
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. For documentation about the rules for custom code placement, please see https://github.com/NoStackApp/ns-flip/wiki/Safe-Custom-Code.
USAGE
$ ns test
OPTIONS
-c, --codeDir=codeDir code base directory
-h, --help show CLI help
DESCRIPTION
Essentially, the test 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.
EXAMPLE
$ ns test -c ~/projects/myappSee code: lib/commands/test.js