Skip to content
Merged

v2.0 #232

Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 56 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,64 @@

If you wish to contribute to the NanoForge project, fork the repository and submit a pull request. Please mind following the pre-commit hooks to keep the codebase as clean as possible.

## Repository structure

This repository is a [pnpm workspace](https://pnpm.io/workspaces) monorepo orchestrated with [Turborepo](https://turborepo.com). It contains the following packages:

| Path | Package | Description |
| ----------------- | --------------------------- | ----------------------------------------------------- |
| `.` | `@nanoforge-dev/cli` | The `nf` command line interface |
| `libs/config` | `@nanoforge-dev/config` | Config types and helpers for `nanoforge.config.ts` |
| `libs/schematics` | `@nanoforge-dev/schematics` | Schematics used by the CLI to generate projects files |

The CLI depends on the libraries through `workspace:*`, so the libraries must be built before the CLI. The `repo:*` scripts take care of this for you.

## Setup

To get ready to work on the codebase, please do the following:

1. Fork & clone the repository, and make sure you're on the **main** branch
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
3. Make your changes
4. Run `pnpm format && pnpm build && pnpm test:unit` to run ESLint/Prettier, build and tests
5. [Submit a pull request](https://github.com/NanoForge-dev/CLI/compare) (Make sure you follow the [conventional commit format](https://github.com/NanoForge-dev/CLI/blob/main/.github/COMMIT_CONVENTION.md))
2. Use the Node.js version defined in [`.nvmrc`](../.nvmrc)
3. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
4. Run `pnpm repo:build` to build every package
5. Make your changes
6. Run `pnpm repo:format && pnpm repo:build && pnpm repo:test` to run ESLint/Prettier, build and tests on every package
7. [Submit a pull request](https://github.com/NanoForge-dev/CLI/compare) (Make sure you follow the [conventional commit format](https://github.com/NanoForge-dev/CLI/blob/main/.github/COMMIT_CONVENTION.md))

## Useful commands

Scripts prefixed with `repo:` run on every package of the workspace through Turborepo:

| Command | Description |
| --------------------- | --------------------------------------------- |
| `pnpm repo:build` | Build all packages |
| `pnpm repo:lint` | Check formatting and lint all packages |
| `pnpm repo:format` | Format and fix lint errors in all packages |
| `pnpm repo:test` | Run unit and end-to-end tests of all packages |
| `pnpm repo:test:unit` | Run unit tests of all packages |
| `pnpm repo:test:e2e` | Run end-to-end tests of all packages |

Scripts without prefix (`build`, `lint`, `test`, ...) only run on the CLI package. To run a script on a single library, use the pnpm `--filter` flag:

```sh
pnpm --filter @nanoforge-dev/config test:unit
pnpm --filter @nanoforge-dev/schematics build
```

## Commits

Commits and pull request titles must follow the [conventional commit format](https://github.com/NanoForge-dev/CLI/blob/main/.github/COMMIT_CONVENTION.md). Use the package as scope when your change targets a single one: `cli`, `config` or `schematics` (e.g. `feat(config): add server port validation`).

Git hooks are installed automatically by `pnpm install`:

- `commit-msg` checks the commit message with commitlint
- `pre-commit` formats staged files with lint-staged
- `pre-push` runs `repo:build`, `repo:lint` and `repo:test`

## Releases

All the packages of this repository share the same version and are released together. Releases are handled by maintainers through GitHub Actions:

1. The **Pre-Release** workflow opens a `releases/cli@<version>` pull request that bumps every package to `<version>` and updates their changelogs. The version must be higher than the latest published version of **every** package (e.g. `@nanoforge-dev/schematics` is already at `2.2.1` on npm)
2. Merging this pull request triggers the **Release** workflow, which publishes the packages to npm (libraries first), creates the `<version>` tag and GitHub release, and synchronizes the documentation
3. The **Alpha Release** workflow can be triggered manually to publish an `alpha` pre-release of a single package from any branch
14 changes: 12 additions & 2 deletions .github/ISSUE_TEMPLATE/01-command_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ body:
value: |
Thank you for filing an issue! If you are here to ask a question, don't hesitate to open a discussion instead: https://github.com/NanoForge-dev/CLI/discussions.

This issue form is for Nanoforge CLI.
This issue form is for the Nanoforge CLI and its libraries (`@nanoforge-dev/config`, `@nanoforge-dev/schematics`). If the issue is not related to a CLI command, pick `other` as the command.
- type: dropdown
id: package
attributes:
label: Which package is this bug report for?
options:
- "@nanoforge-dev/cli"
- "@nanoforge-dev/config"
- "@nanoforge-dev/schematics"
validations:
required: true
- type: dropdown
id: command
attributes:
Expand All @@ -16,7 +26,7 @@ body:
- build
- create
- dev
- generate
- editor
- help
- install
- login
Expand Down
12 changes: 11 additions & 1 deletion .github/ISSUE_TEMPLATE/02-feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ body:
attributes:
value: |
Thank you for submitting an idea !
- type: dropdown
id: package
attributes:
label: Which package is this feature request for?
options:
- "@nanoforge-dev/cli"
- "@nanoforge-dev/config"
- "@nanoforge-dev/schematics"
validations:
required: true
- type: dropdown
id: command
attributes:
Expand All @@ -14,7 +24,7 @@ body:
- build
- create
- dev
- generate
- editor
- help
- install
- login
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
description: Install pnpm depedencies
default: "true"
build:
description: Build packages
description: Build all workspace packages
default: "true"
runs:
using: composite
Expand All @@ -17,7 +17,7 @@ runs:
name: Install Node.js
uses: actions/setup-node@v6
with:
node-version: 25
node-version-file: .nvmrc
package-manager-cache: false
registry-url: https://registry.npmjs.org

Expand All @@ -28,4 +28,4 @@ runs:
- if: inputs.build == 'true'
name: Build packages
shell: bash
run: pnpm run build
run: pnpm run repo:build
12 changes: 10 additions & 2 deletions .github/issue-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ command:dev:
- "### Which command is this (bug
report|feature request) for\\?\\n\\ndev\\n"

command:generate:
command:editor:
- "### Which command is this (bug
report|feature request) for\\?\\n\\ngenerate\\n"
report|feature request) for\\?\\n\\neditor\\n"

command:help:
- "### Which command is this (bug
Expand Down Expand Up @@ -45,3 +45,11 @@ command:start:
command:unpublish:
- "### Which command is this (bug
report|feature request) for\\?\\n\\nunpublish\\n"

lib:config:
- "### Which package is this (bug
report|feature request) for\\?\\n\\n@nanoforge-dev/config\\n"

lib:schematics:
- "### Which package is this (bug
report|feature request) for\\?\\n\\n@nanoforge-dev/schematics\\n"
18 changes: 15 additions & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ command:dev:
- src/command/commands/dev.command.ts
- src/action/actions/dev.action.ts

command:generate:
command:editor:
- changed-files:
- any-glob-to-any-file:
- src/command/commands/generate.command.ts
- src/action/actions/generate.action.ts
- src/command/commands/editor.command.ts
- src/action/actions/editor.action.ts

command:install:
- changed-files:
Expand Down Expand Up @@ -69,3 +69,15 @@ documentation:
- any-glob-to-any-file:
- docs/*
- docs/**/*

lib:config:
- changed-files:
- any-glob-to-any-file:
- libs/config/*
- libs/config/**/*

lib:schematics:
- changed-files:
- any-glob-to-any-file:
- libs/schematics/*
- libs/schematics/**/*
12 changes: 10 additions & 2 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
description: "Related to dev command"
color: "aaa3dc"

- name: "command:generate"
description: "Related to generate command"
- name: "command:editor"
description: "Related to editor command"
color: "aaa3dc"

- name: "command:help"
Expand Down Expand Up @@ -90,6 +90,14 @@
description: "Related to unpublish command"
color: "aaa3dc"

- name: "lib:config"
description: "Related to the @nanoforge-dev/config library"
color: "c5def5"

- name: "lib:schematics"
description: "Related to the @nanoforge-dev/schematics library"
color: "c5def5"

- name: "question"
description: "Further information is requested"
color: "d876e3"
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/alpha-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name: Alpha Release
on:
workflow_dispatch:
inputs:
package:
description: "The published name of a single package to release"
type: choice
required: true
options:
- "@nanoforge-dev/cli"
- "@nanoforge-dev/config"
- "@nanoforge-dev/schematics"
dry_run:
description: Perform a dry run?
type: boolean
Expand All @@ -16,7 +24,7 @@ jobs:
alpha-release:
name: Alpha release
runs-on: ubuntu-latest
if: github.repository_owner == 'NanoForge-dev' && github.ref_name != 'main' && github.ref_name != 'master'
if: github.repository_owner == 'NanoForge-dev'
steps:
- name: Checkout repository
uses: actions/checkout@v7
Expand All @@ -27,7 +35,7 @@ jobs:
- name: Release alpha
uses: ./node_modules/@nanoforge-dev/actions/actions/release-dev
with:
package: "@nanoforge-dev/cli"
package: ${{ inputs.package }}
tag: alpha
dry: ${{ inputs.dry_run }}
env:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ jobs:
- name: Create release PR
uses: ./node_modules/@nanoforge-dev/actions/actions/create-packages-release-pr
with:
packages: "@nanoforge-dev/cli"
packages: "@nanoforge-dev/config,@nanoforge-dev/schematics,@nanoforge-dev/cli"
version: ${{ inputs.version }}
branch-format: "releases/cli@{version}"
commit-format: "chore: release @nanoforge-dev/cli@{version}"
dry: ${{ inputs.dry_run }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 2 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
if: github.repository_owner == 'NanoForge-dev' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/')
if: github.repository_owner == 'NanoForge-dev' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/cli@')
steps:
- name: Checkout repository
uses: actions/checkout@v7
Expand All @@ -26,33 +26,13 @@ jobs:
- name: Release packages
uses: ./node_modules/@nanoforge-dev/actions/actions/release-packages
with:
packages: "@nanoforge-dev/cli"
packages: "@nanoforge-dev/config,@nanoforge-dev/schematics,@nanoforge-dev/cli"
tag-format: "{version}"
latest: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

beta-release:
name: Beta release
runs-on: ubuntu-latest
if: github.repository_owner == 'NanoForge-dev' && github.event.pull_request.merged == true && !startsWith(github.head_ref, 'releases/')
steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Prepare
uses: ./.github/actions/prepare

- name: Release beta
uses: ./node_modules/@nanoforge-dev/actions/actions/release-dev
with:
package: "@nanoforge-dev/cli"
tag: beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-docs:
name: Publish docs
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: ./.github/actions/prepare

- name: Run linter
run: pnpm run lint
run: pnpm run repo:lint

- name: Run tests
run: pnpm run test
run: pnpm run repo:test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,6 @@ src/**/*.d.ts

.tmp-e2e-*/

.direnv
.direnv

.turbo/
6 changes: 3 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pnpm run build
pnpm run lint
pnpm run test
pnpm run repo:build
pnpm run repo:lint
pnpm run repo:test
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
25
v26
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ CHANGELOG.md
coverage/

.tmp-e2e-*/

libs/
Loading
Loading