Skip to content

Commit

Permalink
chore: init the project
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadGh committed May 20, 2024
1 parent 2c38e25 commit 5c8c25d
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 113 deletions.
14 changes: 0 additions & 14 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,5 @@
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml"
]
}
97 changes: 2 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,2 @@
# my-typescript-library-starter

A boilerplate (template starter) for starting a TypeScript library with ease; equipped with:

- **ESLint**: auto fix for formatting (no Prettier needed)
- **Commitizen**: conventional commit interactive-cli helper
- **Husky**: enforce eslint rules, conventional commit message before each commit
- **Release-it**: semantic versioning, release management and publishing to npm or github/gitlab with interactive-cli helper
- **Changelogen**: auto-generated beautiful change-log based on conventional commits

## Usage
**1) clone:** first clone the repo (our used the github green button `Use this template` on the top-right of this window and change project-related fields in package json.
> [!IMPORTANT]
> After cloning the repo, replace `name`, `version`, `description`, `author`, `homepage` and `repository related links` fields in `package.json` to use this template.
** ** Now enter repo's directory and **install dependency** using 'npm' or 'pnpm':

``` shell
pnpm i
```

**2)** to **build** project:
``` shell
pnpm build
```

**3)** to **commit** using commitizen-cli, after adding modified files to stage, enter `pnpm commit` instead of `git commit`:
``` shell
git add .
pnpm commit
```

**4)** to **release** using release-it cli:
``` sell
pnpm release
```
after releasing the `change-log doc` automatically generated to `CHANGELOG.md` file at the root of the project.

## ESLint & ESLint Configuration
We use @antfu amazing eslint configuration. Js file `eslint.config.js` configures the `eslint`. It extends antfu's configuration but you can customize it. for example if you prefer to use double-quotations for string, change this file as:

``` javascript
import antfu from '@antfu/eslint-config'

export default antfu({
stylistic: {
quotes: 'double'
},
})
```
## Conventional Commits & Husky Hooks
we use `Commitizen` for conventional commits. `husky` is used to enforce conventional commit messages with `commitlint`.

## Test & Test Coverage
`Vitest` is used for running tests and measure test coverage.

`coverage-v8` is used to obtain coverage metrics.

The test and coverage config file is `vitest.config.ts`. for example to exclude config files in the root of project from coverage analysis, we config `vitest.config.ts` like follow:

```js
import { configDefaults, defineConfig } from 'vitest/config'

export default defineConfig({
test: {
coverage: {
exclude: [
...configDefaults.exclude,
'*.config.js',
'*.config.ts',
],
},
},
})
```

## Release-it for Releasing
We use `release-it` for version management and publish to anywhere (npm or github). We also use its hooks to execute any command we need to test, build, and publish our project.

## Auto Changelog based on Conventional Commits
We use `changelogen` to generate beautiful changelogs using Conventional Commits.

## CSpell
`CSpell` used to automatically check for spelling errors when committing files and writing commit messages.

If there are spelling errors in the staged files for commit, `husky` will prevent you from committing.
Also, if the commit message text has spelling errors, `husky` will still prevent the commit.

Additional Notes:

- You can configure CSpell in `cspell.json` file in your project directory.
- You can list words that you want `CSpell` to ignore in `/project-words.txt` file.

## License
[MIT](./LICENSE) License
# filenet
serve and send file's data through network
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "my-typescript-library-starter",
"type": "module",
"version": "1.1.1",
"version": "0.0.0",
"packageManager": "pnpm@8.15.3",
"description": "A boilerplate for starting a TypeScript library, equipped with Vitest + ESLint + Commitizen + Husky + Release-it and generating beautiful change-log with Changelogen",
"author": "mgh <m.ghoreshi@gmail.com>",
Expand Down Expand Up @@ -58,6 +58,10 @@
"commit": "cz",
"release": "release-it"
},
"dependencies": {
"citty": "^0.1.6",
"consola": "^3.2.3"
},
"devDependencies": {
"@antfu/eslint-config": "^2.15.0",
"@antfu/ni": "^0.21.12",
Expand Down
9 changes: 7 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion project-words.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
antfu
changelogen
citty
commitlint
typecheck
filenet
typecheck
consola
21 changes: 21 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable no-console */
import { defineCommand, runMain } from 'citty'

const main = defineCommand({
meta: {
name: 'filenet',
version: '1.0.0',
description: 'Filenet CLI',
},
setup() {
console.log('Setup')
},
cleanup() {
console.log('Cleanup')
},
subCommands: {
serve: () => import('./commands/serve').then(r => r.default),
},
})

runMain(main)
24 changes: 24 additions & 0 deletions src/commands/serve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import consola from 'consola'
import { defineCommand } from 'citty'

export default defineCommand({
meta: {
name: 'serve',
description: 'serve the file on a ip:port',
},
args: {
verbose: {
type: 'boolean',
description: 'Output more detailed debugging information',
},
feature: {
type: 'string',
default: 'database-query',
description: 'Only debug a specific function',
},
},
run({ args }) {
consola.log('Debug')
consola.log('Parsed args:', args)
},
})

0 comments on commit 5c8c25d

Please sign in to comment.