Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
30e828c
⬆️ Upgrade prettier
pavelsvagr Aug 27, 2025
9653738
⬆️ Upgrade styleguide-config to 1.0.1
pavelsvagr Aug 27, 2025
039c1f6
🔨 Add jsonc prettier validation
pavelsvagr Aug 27, 2025
2ea4cbf
➕ Add inquirer ora and fast-glob
pavelsvagr Aug 27, 2025
349a651
🏗️ Rework starter to copy-paste pattern with inquirer CLI
pavelsvagr Aug 27, 2025
7847c04
✨ Add file mergers
pavelsvagr Aug 27, 2025
fe887e5
✨ Add base project structure starter
pavelsvagr Aug 27, 2025
f94a492
✨ Add REST API starter
pavelsvagr Aug 27, 2025
e4b88b4
✨ Add GraphQL starter
pavelsvagr Aug 27, 2025
28b7919
✨ Add PostgreSQL starter
pavelsvagr Aug 27, 2025
3b6fc21
✨ Add GitLab CloudRun pipeline starter
pavelsvagr Aug 27, 2025
d7b8d7f
📝 Add _base README
pavelsvagr Aug 27, 2025
5c95642
🚨 Run prettier
pavelsvagr Aug 27, 2025
7aef116
📝 Update spec to new options
pavelsvagr Aug 27, 2025
9d0caeb
✨ Add all starters to CLI options
pavelsvagr Aug 27, 2025
5fe4ce0
📝 Add CLI options
pavelsvagr Aug 27, 2025
4c62bc2
📝 Add pavel.svagr as an author
pavelsvagr Aug 27, 2025
e0402eb
👷 Separate PostgreSQL pipeline
pavelsvagr Aug 28, 2025
c9af7d5
✨ Allow absolute paths in dir option
pavelsvagr Aug 28, 2025
94956d5
🗃️ Add knex migration and seed templates
pavelsvagr Aug 28, 2025
2e04c09
🔈 Add debug logging in PackageJson
pavelsvagr Sep 19, 2025
0ca8dc6
♻️ Add readUtf8File util
pavelsvagr Sep 19, 2025
c9b8fd3
✨ Replace validation - only files in project dir
pavelsvagr Sep 19, 2025
774ca85
✨ Add parametr types in askMissingOptions
pavelsvagr Sep 19, 2025
7dd99e3
✏️ Fix typo in pipeine docs
pavelsvagr Sep 19, 2025
ff0eb9a
📝 Add docs for development
pavelsvagr Sep 19, 2025
be2daae
🔥 Remove lib folder
pavelsvagr Sep 19, 2025
c5e7fcf
✏️ INGORED typo
pavelsvagr Oct 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/actions/test-create-project/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: 'Create project'
description: 'Runs create-node-project and performs tests'
inputs:
options:
description: 'create-node-app options'
required: true
dbConnection:
description: 'DB_CONNECTION_STRING env var'
default: 'postgresql://postgres:postgres@localhost:5432/postgres'
runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Install dependencies
run: npm ci --ignore-scripts
shell: bash

- name: Build the project
run: npm run build
shell: bash

- name: Run npm link
run: npm link
shell: bash

- name: Create project
run: create-node-app ${{ inputs.options }}
shell: bash

- name: Build created project
working-directory: ./node-app
run: npm run build
shell: bash

- name: Run lint
working-directory: ./node-app
run: npm run ci-lint
shell: bash

- name: Run tests
working-directory: ./node-app
run: npm run ci-test
shell: bash
env:
DB_CONNECTION_STRING: ${{inputs.dbConnection}}

- name: Run start
if: ${{ !contains(inputs.options, '--api none') }}
working-directory: ./node-app
run: |
npm run start &
start_pid=$!
sleep 10
kill $start_pid
shell: bash
env:
DB_CONNECTION_STRING: ${{inputs.dbConnection}}

- name: Run start
if: ${{ contains(inputs.options, '--api none') }}
working-directory: ./node-app
shell: bash
run: npm run start
env:
DB_CONNECTION_STRING: ${{inputs.dbConnection}}
78 changes: 39 additions & 39 deletions .github/workflows/create-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,48 @@ jobs:
strategy:
fail-fast: false
matrix:
create-app-command: ["create-node-app cloudrun", "create-node-app cloudrun-graphql"]
create-app-options:
- "--api rest --database none --pipeline cloudrun-gitlab"
- "--api graphql --database none --pipeline cloudrun-gitlab"
- "--api rest --database none --pipeline none"
- "--api none --database none --pipeline cloudrun-gitlab"
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v3
- uses: actions/checkout@v4
- id: create-node-app
uses: ./.github/actions/test-create-project
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Build the project
run: npm run build

- name: Run npm link
run: npm link

- name: Create project
run: ${{ matrix.create-app-command }}

- name: Build created project
working-directory: ./node-app
run: npm run build
options: ${{ matrix.create-app-options }}

- name: Run lint
working-directory: ./node-app
run: npm run ci-lint
create-projects-with-postgres:
needs: "build"
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
strategy:
fail-fast: false
matrix:
create-app-options:
- "--api none --database postgres-knex --pipeline none"
- "--api rest --database postgres-knex --pipeline cloudrun-gitlab"
- "--api graphql --database postgres-knex --pipeline cloudrun-gitlab"
runs-on: ubuntu-latest

- name: Run tests
working-directory: ./node-app
run: npm run ci-test

- name: Run start
working-directory: ./node-app
run: |
npm run start &
start_pid=$!
sleep 10
kill $start_pid
steps:
- uses: actions/checkout@v4
- id: create-node-app
uses: ./.github/actions/test-create-project
with:
options: ${{ matrix.create-app-options }}
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Jiri Smolik <jiri.smolik@ackee.cz>
Patrik Hoffmann <patrik.hoffmann@ackee.cz>
Roman Filatov <roman.filatov@ackee.cz>
Roman Filatov <roman.filatov@ackee.cz>
Pavel Švagr <pavel.svagr@ackee.cz>
44 changes: 26 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,42 @@

# Create Node App

CLI to help you set up Node.js TypeScript project. Set up project includes
CLI to help you set up a Node.js TypeScript project. The setup includes:

- code style tools (prettier, lint)
- testing (using jest)
- infrastructure files of your choice (Docker, etc.)
- GitLab CI and npm ci-\* scripts (for Ackee CI/CD pipelines)
- testing (using mocha)
- infrastructure files of your choice (PostgreSQL etc.)
- CI pipeline templates (based on Ackee GitLab CI/CD pipelines)

## Usage

Run directly from GitHub repo via npx:

```
Usage: npm exec --ignore-scripts -- github:AckeeCZ/create-node-app STARTER [OPTIONS] [DIRECTORY]

STARTER Which template to setup (required)
Usage: npm exec --ignore-scripts -- github:AckeeCZ/create-node-app [OPTIONS]

Options:
--dir, -d DIR Destination directory (default: ./node-app)
--project-name, -n NAME Google Cloud project name (default: directory basename)
--force, -f Overwrite existing destination directory if it's not empty
--help, -h Show this help message

Starters available:
cloudrun Cloud Run + express
cloudrun-graphql Cloud Run + graphql
-d, --dir Destination directory [string] [default: "./node-app"]
-D, --debug Enables debug logs [boolean] [default: false]
-n, --project-name Google Cloud project name [string] [default: "node-app"]
-f, --force Overwrite existing destination if it's not empty
[boolean] [default: false]
--api Selects API
[string] [choices: "graphql", "rest"]
--database Selects database as database
[string] [choices: "postgres-knex"]
--pipeline Selects pipeline
[string] [choices: "cloudrun-gitlab"]
--version Show version number [boolean]
--help Show help [boolean]
```

Supported starter templates:
## Setup options

- [Cloud Run](./starter/cloudrun/README.md)
- [GraphQL Cloud Run](./starter/cloudrun-graphql/README.md)
- API layer
- [RESTful](starter/api/rest/)
- [GraphQL](starter/api/graphql/)
- Database
- [PostgreSQL](starter/infra/postgresql-knex/) using [Knex](https://github.com/knex/knex)
- Pipelines
- [GitLab CloudRun](starter/pipeline/cloudrun-gitlab/)
42 changes: 42 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Development 👷

## Starters

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.

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.

Each starter directory must contain a `node-app.jsonc` configuration file that defines the starter's metadata for the cna.

### Grouping and sorting

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.

The order for injection into the final repository is alphabetical based on the module fields. The logic for grouping and sorting is as follows:

1. **Base Starter**: The `_base` starter is always built first
2. **Selected Starters**: Each selected starter is built in the order of user selection
3. **npm install**: Dependencies are installed
4. **Prebuild Scripts**: All `prebuild` scripts from selected starters are executed
5. **Final Build**: `npm run build` is executed

### Configuration

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):

- `id`\* (`string`): Unique identifier
- `name`\* (`string`): Displayed in the CLI in the form of `<name> <module>` e.g. `RESTful API`
- `module`\* (`string`): The category this starter belongs to (e.g., "API", "database")
- `prebuild` (`string[]`): Array of npm script names to run before the main build
- `replace` (`string[]`): Array of file paths (relative to project root) where string replacements should be applied

#### Example RESTful API `node-app.jsonc`

```jsonc
{
"module": "API",
"id": "rest",
"name": "RESTful",
"prebuild": ["generate:api"],
}
```
91 changes: 0 additions & 91 deletions lib/Bootstrap.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/Bootstrap.js.map

This file was deleted.

12 changes: 0 additions & 12 deletions lib/Logger.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/Logger.js.map

This file was deleted.

Loading