Skip to content

feat: add defineConfig function #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2024
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ jobs:
- name: Install Dependencies
run: pnpm i

- name: Build
run: pnpm build

- name: Create Release
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
# NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: pnpm release
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test
on:
workflow_run:
workflows:
- ESLint
- CodeQL
types:
- completed
pull_request:
Expand Down
323 changes: 0 additions & 323 deletions CHANGELOG.md

Large diffs are not rendered by default.

284 changes: 33 additions & 251 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,271 +1,53 @@
# Archoleat Repo Template

![CodeQL](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/codeql.yaml?label=CodeQL)
![Test](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/test.yaml?label=Test)
![Commitlint](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/commitlint.yaml?label=Commitlint)
![Editorconfig](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/editorconfig.yaml?label=Editorconfig)
![Prettier](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/prettier.yaml?label=Prettier)
![ESLint](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/eslint.yaml?label=ESLint)
![Markdown](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/markdown.yaml?label=Markdown)
# Commitlint Define Config

![NPM Version](https://img.shields.io/npm/v/%40archoleat%2Fcommitlint-define-config)
![NPM Downloads](https://img.shields.io/npm/dm/%40archoleat%2Fcommitlint-define-config)
![CodeQL](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/codeql.yaml?label=CodeQL)
![Test](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/test.yaml?label=Test)
![Commitlint](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/commitlint.yaml?label=Commitlint)
![Editorconfig](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/editorconfig.yaml?label=Editorconfig)
![Prettier](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/prettier.yaml?label=Prettier)
![ESLint](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/eslint.yaml?label=ESLint)
![Markdown](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/markdown.yaml?label=Markdown)
![ESM Only](https://img.shields.io/badge/ESM-only-gray?labelColor=fe0)

## Table of Contents

- [Getting Started](#getting-started)
- [Features](#features)
- [Scripts](#scripts)
- [Workflows](#workflows)
- [Prettier](#prettier)
- [Commitlint, ESM and TypeScript](#commitlint-esm-and-typescript)
- [Change of Maintainer](#change-of-maintainer)
- [Installation](#installation)
- [Usage](#usage)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)

**Archoleat Repo Template** is a template repository designed for quickly
starting new projects with pre-configured tools and best development practices.
This template includes ready-made solutions for integration with:

- **Git**.
- **GitHub**.
- **Commitizen**.
- **Commitlint**.
- **Conventional Commits**.
- **Husky & Lint Staged**.
- **GitHub Actions**.
- **Semantic Release**.
- **PNPM**.
- **CodeQL**.
- **EditorConfig**.
- **ESLint**.
- **Remark**.
- **Prettier**.
- **Vitest**.
- **TypeScript**.
- **Dependabot**.

> \[!TIP]
> **A good solution for your business!**
>
> Now you don't have to worry about unnecessary costs.
> Everything is already set up and prepared for you!
>
> And also the template is very good for teams,
> because you can easily standardize projects with this template.

## Getting Started

1. **Create a Repository**: Use this template
to create a new repository on GitHub.

> Since this is a **Public Template** you can click the button
> **Use this template** for a faster and more convenient cloning.

1. **Clone the Repository**: Clone your new repository to your local machine.

1. **Start Development**: Develop your project,
making changes according to your project's needs.

1. **Configure GitHub Actions**: Modify GitHub Actions
settings to fit your requirements.

> **For those unfamiliar with GitHub Actions**,
> our workflows use
> [**chain**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run),
> if you want to add more workflows to this chain,
> workflows, it won't work, because the chain only supports
> only three levels, example: `workflow A` > `workflow B` >
> `workflow C` > `workflow D`, if you add `workflow E`
> to the chain. it won't work!

## Features

- **Flexibility**: Easily customizable template to adapt
to different project types.

- **Git and GitHub Integration**: Pre-configured `.gitignore`, `.gitmodules`
and `.gitattributes` for efficient work with Git and GitHub.

- **Conventional Commits, Commitlint & Commitizen**: If you don't want
to think about how to write a commit every time,
these plugins will help you.

> It will be especially useful for teams that
> have an ongoing debate about writing commits.

- **Husky & Lint Staged**: Won't let you submit
bad code to the repository!

- **Continuous Integration (CI)**: Built-in CI support using GitHub Actions
for automatic linting, testing and building of your code with each change.

> Also suitable for private repositories! GitHub Actions use
> **cache**, **timeout-minutes**, **path filters** and **workflow run**
> to reduce the execution time, which means it will significantly
> reduce your costs!

- **Security**: Included **CodeQL** workflow for detecting
and preventing potential vulnerabilities in your code.

- **Linters**: Help you maintain a consistent code writing style
and find errors.

> By default **ESLint**, **Prettier**, **Editorconfig Checker** and
> **Remark** check all files in the project, if you want to change this
> behavior then go to [`package.json`](package.json)
> and [`lint-staged.config.js`](lint-staged.config.js)
> files.

- **Tests**: Automated testing will help you focus on
writing better code!

- **Semantic Release**: For those who are tired of writing changelogs
and thinking about what the next version number will be.

- **TypeScript**: Pre-configured **TypeScript** setup
for improved reliability and development convenience.

- **Bots**:

- **Dependabot**: No more wasting time updating dependencies!

## Scripts

- `init`: Installs dependencies, **Husky** and update submodules.

- `test`: Runs **Vitest** and the tests in the **specs/** folder.

- `test:coverage`: Runs **Vitest** with **Coverage-V8**.

- `release`: Runs **Semantic Release**.

> Also runs using the [`test.yaml`](.github/workflows/test.yaml)
> workflow.

- `lint:editorconfig`: Runs **Editorconfig Checker** and
checks all files in the project.

> Also runs with the [`editorconfig.yaml`](.github/workflows/editorconfig.yaml)
> workflow.
## Installation

- `lint:formatting`: Runs **Prettier** with the `--check` flag
for all files.

> In the [`prettier.yaml`](.github/workflows/prettier.yaml)
>
> Also run with a `pre-commit` hook.

- `lint:md`: Runs **Remark** with the `--quiet` flag and
checks all **Markdown** files.

> Also runs with the [`markdown.yaml`](.github/workflows/markdown.yaml)
> workflow.

- `lint:ts`: Runs **ESLint** with the flag `--fix`
for all **TypeScript** files.

> Runs with the [`eslint.yaml`](.github/workflows/eslint.yaml)
> workflow.
>
> Also run with a `pre-commit` hook.

- `prettify`: Runs **Prettier** with the `--write` flag
for all files.

- `commit`: Runs **Commitlint** to create commits according to
**Conventional Commits** standards.

## Workflows

- [`codeql.yaml`](.github/workflows/codeql.yaml):
Checks **TypeScript** for vulnerabilities.

- [`commitlint.yaml`](.github/workflows/commitlint.yaml):
Checks the commit message according
to the **Conventional Commits** standard.

- [`create-pull-request.yaml`](.github/workflows/create-pull-request.yaml):
Automatically creates a **Pull Request**
when pushing a branch to the repository.

- [`dependabot-auto-merge-pull-request.yaml`](.github/workflows/dependabot-auto-merge-pull-request.yaml):
Automatically merges dependabot **Pull Requests** to the **main** branch.

- [`editorconfig.yaml`](.github/workflows/editorconfig.yaml):
Checks all files with **editorconfig-checker**.

- [`eslint.yaml`](.github/workflows/eslint.yaml):
Checks all **TypeScript** files with **ESLint**.

- [`markdown.yaml`](.github/workflows/markdown.yaml):
Checks all Markdown files with **remark**.

- [`test.yaml`](.github/workflows/test.yaml):
Tests all TypeScript files with **Vitest**.

- [`pre-commit.yaml`](.github/workflows/pre-commit.yaml):
Runs a check on the contents of the **Pull Request** before merging.

- [`prettier.yaml`](.github/workflows/prettier.yaml):
Checks all files with **Prettier**.

- [`release.yaml`](.github/workflows/release.yaml): Creates release.

- [`semantic-pull-request.yaml`](.github/workflows/semantic-pull-request-title.yaml):
Validates the **Pull Request** title
against the **conventional commits** standard.

- [`stale.yaml`](.github/workflows/stale.yaml):
Removes issues that have not been active for more than 60 days.

## Prettier

> \[!WARNING]
> You need to install the **Prettier** extension for it to work.
>
> You can see all necessary extensions for **Visual Studio Code** in
> [**.vscode**](https://github.com/archoleat/.vscode/extensions.json).

> \[!TIP]
> If you want to change the rules in `prettier.config.js` you can do it
> in `.editorconfig`, prettier will automatically pick up the rules
> from editorconfig.

> \[!NOTE]
> All **Markdown** and **.\*ignore** files [**ignored**](.prettierignore).

## Commitlint, ESM and TypeScript

In order for `commitlint.config.ts` to work correctly together
with the **CI/CD** pipeline, the following code has been added:

```json
// package.json
"exports": {
"./*": "./commitlint.config.ts"
},
```shell
# pnpm
pnpm i -D @archoleat/commitlint-define-config
```

```json
// tsconfig.json
{
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
```shell
# npm
npm i -D @archoleat/commitlint-define-config
```

## Change of Maintainer
```shell
# yarn
yarn add -D @archoleat/commitlint-define-config
```

The following files use the names **Archoleat** and **nikkeyl** by default:
## Usage

- [`CODEOWNERS`](.github/CODEOWNERS).
- [`package.json`](package.json).
See [Commitlint Configuration](https://commitlint.js.org/reference/configuration.html).

Before using this template, replace this name with your
name, name of your team or the name of your organization.
```js
// commitlint.config.js or commitlint.config.ts
import { defineConfig } from '@archoleat/commitlint-define-config';

> \[!CAUTION]
> Don't forget to change your license!
export default defineConfig({
// Your options
})
```

## Troubleshooting

Expand Down
27 changes: 22 additions & 5 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import type { UserConfig } from '@commitlint/types';
import { defineConfig } from '.';

const commitLintConfig: UserConfig = {
export default defineConfig({
extends: ['@commitlint/config-conventional'],
};

export default commitLintConfig;
rules: {
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'spec',
'style',
],
],
},
});
12 changes: 12 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { UserConfig } from '@commitlint/types';

/**
* Define an Commitlint config.
*
* @param {object} config Commitlint config.
*
* @returns Commitlint config.
*/
declare const defineConfig: (config: UserConfig) => UserConfig;

export { defineConfig };
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const n=e=>e;export{n as defineConfig};
15 changes: 13 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export default async (string: string) => {
return string;
import type { UserConfig } from '@commitlint/types';

/**
* Define an Commitlint config.
*
* @param {object} config Commitlint config.
*
* @returns Commitlint config.
*/
const defineConfig = (config: UserConfig): UserConfig => {
return config;
};

export { defineConfig };
Loading