Skip to content

Commit 7cc4302

Browse files
committed
📝 Add docs for development
1 parent 8de0d62 commit 7cc4302

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

docs/development.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Development 👷
2+
3+
## Starters
4+
5+
Starters are folders containing files and structure that can be optionally added to the final created repository by `create-node-app` (cna). The base folder structure and tooling that should be available in every application created by cna is located in the [\_base](../starter/_base) folder.
6+
7+
Each additional starter is an addition to this base. When a user selects a specific starter, all contents are copied into the final directory **except for specific files that require content merging**. Every file that is merged uses its own merger defined in the [Mergers](../src/Mergers/) directory.
8+
9+
Each starter directory must contain a `node-app.jsonc` configuration file that defines the starter's metadata for the cna.
10+
11+
### Grouping and sorting
12+
13+
Starters are grouped into categories called "modules". These indicate that only one starter should be selected from each group. For example, under the API module there can be GraphQL and RESTful API starters, but the created application can have only one of those.
14+
15+
The order for injection into the final repository is alphabetical based on the module fields. The logic for grouping and sorting is as follows:
16+
17+
1. **Base Starter**: The `_base` starter is always built first
18+
2. **Selected Starters**: Each selected starter is built in the order of user selection
19+
3. **npm install**: Dependencies are installed
20+
4. **Prebuild Scripts**: All `prebuild` scripts from selected starters are executed
21+
5. **Final Build**: `npm run build` is executed
22+
23+
### Configuration
24+
25+
The `node-app.jsonc` file is a JSON with Comments file that configures how a starter behaves during the build process. The structure is as follows (fields with \* are required):
26+
27+
- `id`\* (`string`): Unique identifier
28+
- `name`\* (`string`): Displayed in the CLI in the form of `<name> <module>` e.g. `RESTful API`
29+
- `module`\* (`string`): The category this starter belongs to (e.g., "API", "database")
30+
- `prebuild` (`string[]`): Array of npm script names to run before the main build
31+
- `replace` (`string[]`): Array of file paths (relative to project root) where string replacements should be applied
32+
33+
#### Example RESTful API `node-app.jsonc`
34+
35+
```jsonc
36+
{
37+
"module": "API",
38+
"id": "rest",
39+
"name": "RESTful",
40+
"prebuild": ["generate:api"],
41+
}
42+
```

0 commit comments

Comments
 (0)