generator-code-makeup v0.0.6
Code makeup tool
DISCLAIMER
This project is currently at early stages of development and is expected to become more robust over time. But for now, it aims to demonstrate the new approach to "continuous scaffolding". It might miss features and might be less flexible than you want it to be. Consider opening an issue in this repository if you find it suitable.
Installation
More info can be found in Yeoman documentation.
npm install -g yo
npm install -g generator-code-makeup
Usage
Run yo code-makeup:<GENERATOR_NAME>
in the folder you generate to.
Example: yo code-makeup:makeup-node-app
.
Approach
This tool is a Yeoman generator that helps initiate Node.js projects and maintain the standards in them continuously.
This continuity is achieved through applying these requirements to every code change operation:
- Every change happens only if strictly necessary (if the project value aligns with the intended one, no change happen).
- Every change considers side-effects of the change itself and takes care of it - either through a cleanup or communicating the change to the user.
Also, this generator stores every answer to previously asked questions in one of a few storages:
- Project itself (
package.json
,tsconfig.json
and so on). - Yeoman project configuration storage.
- Global configuration storage (It's an in-generator global JSON in
os.homedir
. The values are shared between all generator runs in all projects, such asauthor.name
).
What storage to use depends on the configuration value entirely. User input is always asked only once.
Available independent and grouped generators
There are two types of generators available in this project:
- "Feature" generator. Executes a set of operations aiming to makeup a particular aspect of the project.
- "Makeup" generator. Executes multiple feature generators in a particular order.
All of them can be ran separately in any project.
"Makeup" generators
makeup-node-app
feature-initiate-npm-package
feature-initiate-typescript
feature-initiate-jest
feature-prettify-configuration-files
"Feature" generators
NOTE: For every action read it as needed if not said otherwise.
feature-initiate-npm-package
- Create
package.json
. - Set project name.
- Update license information and add a license file (
UNLICENSED
for proprietary andLGPL-3.0
for open source). - Set author info (name, email, URL).
feature-initiate-typescript
- Add
typescript
as a dev dependency. - Create
tsconfig.json
. - Create
src
directory for source files. - Add support of absolute paths (
@
meanssrc
). - Set
module
andmoduleResolution
suitable for bundling the TS app. - Enable
esModuleInterop
.
feature-initiate-jest
- Add
jest
as a dev dependency. - Create
jest.config.json
. - Remove
ts-jest
from dependencies. - Add
@swc/jest
as a dev dependency. - Initiate Jest configuration.
- Setup TS absolute paths support in
@swc/jest
. - Create
__tests__
folder for storing spec files. - Set test script in
package.json
.
feature-prettify-configuration-files
- Sort
package.json
with sort-package-json. - Sort
tsconfig.json
with sort-json. - Sort
jest.config.json
with sort-json.
Making it work from source code
It requires the package to be available globally. That can be done with npm link
in the root of this package. That will make it globally available to other npm scripts (including yo
).