How do I add a feature?
From the project's root:
nutin-add docker
nutin-add markdown
nutin-add all # both
| Feature | Adds | Docs |
|---|---|---|
docker |
A Dockerfile and nginx config, and the docker:build/docker:run scripts |
How do I use the Docker feature? |
markdown |
Markdown folders compiled into routed pages, and the markdown:check script |
How do I use the Markdown feature? |
A feature can only be removed by hand once it's added. See What is the difference between options and features?
What it does
- Adds the feature's files. A file that already exists at the same path is kept, and listed as skipped.
- Adds its scripts to
package.json. A script you already have under the same name is kept. - Adds its configuration to
nutin.config.js, under a// Nutin featurescomment:dockerPortsfor docker,markdownSourcesfor markdown. A key that's already there is kept. - Updates the Nutin files that change with the feature (e.g.
tools/builder/builder.jsgets the markdown build step). Your own edits to those files are kept. When a change can't be placed automatically, it's printed as a patch to apply by hand. - Records the feature in
.nutin-meta.json, sonutin-updateupdates its files too. Adding a feature that's already there does nothing.
Commit before adding a feature: the changes are easy to review, and to undo.
Dependencies
nutin-add doesn't install anything:
- docker needs no npm package. It needs Docker, to build and run the image.
- markdown needs
markedandgray-matter. The first dev build asks to install them; pass-- -yto install them without asking (npm run build -- -y), e.g. in CI. Production builds never install anything: they fail with the command to run.
Projects without .nutin-meta.json
Projects created before Nutin recorded it have no .nutin-meta.json. nutin-add then asks which Nutin version created the project and which features it has, and writes the file. That needs an interactive terminal.
Browser extensions
docker and markdown can't be added to a project created with --extension: an extension has no server, and Markdown pages need the router, which extension pages don't use.