Skip to content

Commit 5e58f10

Browse files
feat: add defineConfig function (#2)
Co-authored-by: Almanov Nikita <[email protected]>
1 parent efe4a43 commit 5e58f10

16 files changed

+560
-678
lines changed

.github/workflows/release.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ jobs:
4747
- name: Install Dependencies
4848
run: pnpm i
4949

50+
- name: Build
51+
run: pnpm build
52+
5053
- name: Create Release
5154
env:
5255
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
53-
# NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
56+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
5457
run: pnpm release

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Test
33
on:
44
workflow_run:
55
workflows:
6-
- ESLint
6+
- CodeQL
77
types:
88
- completed
99
pull_request:

CHANGELOG.md

Lines changed: 0 additions & 323 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 33 additions & 251 deletions
Original file line numberDiff line numberDiff line change
@@ -1,271 +1,53 @@
1-
# Archoleat Repo Template
2-
3-
![CodeQL](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/codeql.yaml?label=CodeQL)
4-
![Test](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/test.yaml?label=Test)
5-
![Commitlint](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/commitlint.yaml?label=Commitlint)
6-
![Editorconfig](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/editorconfig.yaml?label=Editorconfig)
7-
![Prettier](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/prettier.yaml?label=Prettier)
8-
![ESLint](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/eslint.yaml?label=ESLint)
9-
![Markdown](https://img.shields.io/github/actions/workflow/status/archoleat/repo-template/markdown.yaml?label=Markdown)
1+
# Commitlint Define Config
2+
3+
![NPM Version](https://img.shields.io/npm/v/%40archoleat%2Fcommitlint-define-config)
4+
![NPM Downloads](https://img.shields.io/npm/dm/%40archoleat%2Fcommitlint-define-config)
5+
![CodeQL](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/codeql.yaml?label=CodeQL)
6+
![Test](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/test.yaml?label=Test)
7+
![Commitlint](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/commitlint.yaml?label=Commitlint)
8+
![Editorconfig](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/editorconfig.yaml?label=Editorconfig)
9+
![Prettier](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/prettier.yaml?label=Prettier)
10+
![ESLint](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/eslint.yaml?label=ESLint)
11+
![Markdown](https://img.shields.io/github/actions/workflow/status/archoleat/commitlint-define-config/markdown.yaml?label=Markdown)
1012
![ESM Only](https://img.shields.io/badge/ESM-only-gray?labelColor=fe0)
1113

1214
## Table of Contents
1315

14-
- [Getting Started](#getting-started)
15-
- [Features](#features)
16-
- [Scripts](#scripts)
17-
- [Workflows](#workflows)
18-
- [Prettier](#prettier)
19-
- [Commitlint, ESM and TypeScript](#commitlint-esm-and-typescript)
20-
- [Change of Maintainer](#change-of-maintainer)
16+
- [Installation](#installation)
17+
- [Usage](#usage)
2118
- [Troubleshooting](#troubleshooting)
2219
- [Contributing](#contributing)
2320
- [License](#license)
2421

25-
**Archoleat Repo Template** is a template repository designed for quickly
26-
starting new projects with pre-configured tools and best development practices.
27-
This template includes ready-made solutions for integration with:
28-
29-
- **Git**.
30-
- **GitHub**.
31-
- **Commitizen**.
32-
- **Commitlint**.
33-
- **Conventional Commits**.
34-
- **Husky & Lint Staged**.
35-
- **GitHub Actions**.
36-
- **Semantic Release**.
37-
- **PNPM**.
38-
- **CodeQL**.
39-
- **EditorConfig**.
40-
- **ESLint**.
41-
- **Remark**.
42-
- **Prettier**.
43-
- **Vitest**.
44-
- **TypeScript**.
45-
- **Dependabot**.
46-
47-
> \[!TIP]
48-
> **A good solution for your business!**
49-
>
50-
> Now you don't have to worry about unnecessary costs.
51-
> Everything is already set up and prepared for you!
52-
>
53-
> And also the template is very good for teams,
54-
> because you can easily standardize projects with this template.
55-
56-
## Getting Started
57-
58-
1. **Create a Repository**: Use this template
59-
to create a new repository on GitHub.
60-
61-
> Since this is a **Public Template** you can click the button
62-
> **Use this template** for a faster and more convenient cloning.
63-
64-
1. **Clone the Repository**: Clone your new repository to your local machine.
65-
66-
1. **Start Development**: Develop your project,
67-
making changes according to your project's needs.
68-
69-
1. **Configure GitHub Actions**: Modify GitHub Actions
70-
settings to fit your requirements.
71-
72-
> **For those unfamiliar with GitHub Actions**,
73-
> our workflows use
74-
> [**chain**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run),
75-
> if you want to add more workflows to this chain,
76-
> workflows, it won't work, because the chain only supports
77-
> only three levels, example: `workflow A` > `workflow B` >
78-
> `workflow C` > `workflow D`, if you add `workflow E`
79-
> to the chain. it won't work!
80-
81-
## Features
82-
83-
- **Flexibility**: Easily customizable template to adapt
84-
to different project types.
85-
86-
- **Git and GitHub Integration**: Pre-configured `.gitignore`, `.gitmodules`
87-
and `.gitattributes` for efficient work with Git and GitHub.
88-
89-
- **Conventional Commits, Commitlint & Commitizen**: If you don't want
90-
to think about how to write a commit every time,
91-
these plugins will help you.
92-
93-
> It will be especially useful for teams that
94-
> have an ongoing debate about writing commits.
95-
96-
- **Husky & Lint Staged**: Won't let you submit
97-
bad code to the repository!
98-
99-
- **Continuous Integration (CI)**: Built-in CI support using GitHub Actions
100-
for automatic linting, testing and building of your code with each change.
101-
102-
> Also suitable for private repositories! GitHub Actions use
103-
> **cache**, **timeout-minutes**, **path filters** and **workflow run**
104-
> to reduce the execution time, which means it will significantly
105-
> reduce your costs!
106-
107-
- **Security**: Included **CodeQL** workflow for detecting
108-
and preventing potential vulnerabilities in your code.
109-
110-
- **Linters**: Help you maintain a consistent code writing style
111-
and find errors.
112-
113-
> By default **ESLint**, **Prettier**, **Editorconfig Checker** and
114-
> **Remark** check all files in the project, if you want to change this
115-
> behavior then go to [`package.json`](package.json)
116-
> and [`lint-staged.config.js`](lint-staged.config.js)
117-
> files.
118-
119-
- **Tests**: Automated testing will help you focus on
120-
writing better code!
121-
122-
- **Semantic Release**: For those who are tired of writing changelogs
123-
and thinking about what the next version number will be.
124-
125-
- **TypeScript**: Pre-configured **TypeScript** setup
126-
for improved reliability and development convenience.
127-
128-
- **Bots**:
129-
130-
- **Dependabot**: No more wasting time updating dependencies!
131-
132-
## Scripts
133-
134-
- `init`: Installs dependencies, **Husky** and update submodules.
135-
136-
- `test`: Runs **Vitest** and the tests in the **specs/** folder.
137-
138-
- `test:coverage`: Runs **Vitest** with **Coverage-V8**.
139-
140-
- `release`: Runs **Semantic Release**.
141-
142-
> Also runs using the [`test.yaml`](.github/workflows/test.yaml)
143-
> workflow.
144-
145-
- `lint:editorconfig`: Runs **Editorconfig Checker** and
146-
checks all files in the project.
147-
148-
> Also runs with the [`editorconfig.yaml`](.github/workflows/editorconfig.yaml)
149-
> workflow.
22+
## Installation
15023

151-
- `lint:formatting`: Runs **Prettier** with the `--check` flag
152-
for all files.
153-
154-
> In the [`prettier.yaml`](.github/workflows/prettier.yaml)
155-
>
156-
> Also run with a `pre-commit` hook.
157-
158-
- `lint:md`: Runs **Remark** with the `--quiet` flag and
159-
checks all **Markdown** files.
160-
161-
> Also runs with the [`markdown.yaml`](.github/workflows/markdown.yaml)
162-
> workflow.
163-
164-
- `lint:ts`: Runs **ESLint** with the flag `--fix`
165-
for all **TypeScript** files.
166-
167-
> Runs with the [`eslint.yaml`](.github/workflows/eslint.yaml)
168-
> workflow.
169-
>
170-
> Also run with a `pre-commit` hook.
171-
172-
- `prettify`: Runs **Prettier** with the `--write` flag
173-
for all files.
174-
175-
- `commit`: Runs **Commitlint** to create commits according to
176-
**Conventional Commits** standards.
177-
178-
## Workflows
179-
180-
- [`codeql.yaml`](.github/workflows/codeql.yaml):
181-
Checks **TypeScript** for vulnerabilities.
182-
183-
- [`commitlint.yaml`](.github/workflows/commitlint.yaml):
184-
Checks the commit message according
185-
to the **Conventional Commits** standard.
186-
187-
- [`create-pull-request.yaml`](.github/workflows/create-pull-request.yaml):
188-
Automatically creates a **Pull Request**
189-
when pushing a branch to the repository.
190-
191-
- [`dependabot-auto-merge-pull-request.yaml`](.github/workflows/dependabot-auto-merge-pull-request.yaml):
192-
Automatically merges dependabot **Pull Requests** to the **main** branch.
193-
194-
- [`editorconfig.yaml`](.github/workflows/editorconfig.yaml):
195-
Checks all files with **editorconfig-checker**.
196-
197-
- [`eslint.yaml`](.github/workflows/eslint.yaml):
198-
Checks all **TypeScript** files with **ESLint**.
199-
200-
- [`markdown.yaml`](.github/workflows/markdown.yaml):
201-
Checks all Markdown files with **remark**.
202-
203-
- [`test.yaml`](.github/workflows/test.yaml):
204-
Tests all TypeScript files with **Vitest**.
205-
206-
- [`pre-commit.yaml`](.github/workflows/pre-commit.yaml):
207-
Runs a check on the contents of the **Pull Request** before merging.
208-
209-
- [`prettier.yaml`](.github/workflows/prettier.yaml):
210-
Checks all files with **Prettier**.
211-
212-
- [`release.yaml`](.github/workflows/release.yaml): Creates release.
213-
214-
- [`semantic-pull-request.yaml`](.github/workflows/semantic-pull-request-title.yaml):
215-
Validates the **Pull Request** title
216-
against the **conventional commits** standard.
217-
218-
- [`stale.yaml`](.github/workflows/stale.yaml):
219-
Removes issues that have not been active for more than 60 days.
220-
221-
## Prettier
222-
223-
> \[!WARNING]
224-
> You need to install the **Prettier** extension for it to work.
225-
>
226-
> You can see all necessary extensions for **Visual Studio Code** in
227-
> [**.vscode**](https://github.com/archoleat/.vscode/extensions.json).
228-
229-
> \[!TIP]
230-
> If you want to change the rules in `prettier.config.js` you can do it
231-
> in `.editorconfig`, prettier will automatically pick up the rules
232-
> from editorconfig.
233-
234-
> \[!NOTE]
235-
> All **Markdown** and **.\*ignore** files [**ignored**](.prettierignore).
236-
237-
## Commitlint, ESM and TypeScript
238-
239-
In order for `commitlint.config.ts` to work correctly together
240-
with the **CI/CD** pipeline, the following code has been added:
241-
242-
```json
243-
// package.json
244-
"exports": {
245-
"./*": "./commitlint.config.ts"
246-
},
24+
```shell
25+
# pnpm
26+
pnpm i -D @archoleat/commitlint-define-config
24727
```
24828

249-
```json
250-
// tsconfig.json
251-
{
252-
"module": "NodeNext",
253-
"moduleResolution": "NodeNext"
254-
}
29+
```shell
30+
# npm
31+
npm i -D @archoleat/commitlint-define-config
25532
```
25633

257-
## Change of Maintainer
34+
```shell
35+
# yarn
36+
yarn add -D @archoleat/commitlint-define-config
37+
```
25838

259-
The following files use the names **Archoleat** and **nikkeyl** by default:
39+
## Usage
26040

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

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

267-
> \[!CAUTION]
268-
> Don't forget to change your license!
47+
export default defineConfig({
48+
// Your options
49+
})
50+
```
26951

27052
## Troubleshooting
27153

commitlint.config.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1-
import type { UserConfig } from '@commitlint/types';
1+
import { defineConfig } from '.';
22

3-
const commitLintConfig: UserConfig = {
3+
export default defineConfig({
44
extends: ['@commitlint/config-conventional'],
5-
};
6-
7-
export default commitLintConfig;
5+
rules: {
6+
'type-enum': [
7+
2,
8+
'always',
9+
[
10+
'build',
11+
'chore',
12+
'ci',
13+
'docs',
14+
'feat',
15+
'fix',
16+
'perf',
17+
'refactor',
18+
'revert',
19+
'spec',
20+
'style',
21+
],
22+
],
23+
},
24+
});

index.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { UserConfig } from '@commitlint/types';
2+
3+
/**
4+
* Define an Commitlint config.
5+
*
6+
* @param {object} config Commitlint config.
7+
*
8+
* @returns Commitlint config.
9+
*/
10+
declare const defineConfig: (config: UserConfig) => UserConfig;
11+
12+
export { defineConfig };

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const n=e=>e;export{n as defineConfig};

index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
export default async (string: string) => {
2-
return string;
1+
import type { UserConfig } from '@commitlint/types';
2+
3+
/**
4+
* Define an Commitlint config.
5+
*
6+
* @param {object} config Commitlint config.
7+
*
8+
* @returns Commitlint config.
9+
*/
10+
const defineConfig = (config: UserConfig): UserConfig => {
11+
return config;
312
};
13+
14+
export { defineConfig };

0 commit comments

Comments
 (0)