Skip to content
Merged

V2 #45

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d339dbc
chore: improve package.json lint and format scripts
Kit-p Jul 17, 2023
7b13f34
chore(style): lint and format all code files
Kit-p Jul 17, 2023
bba21a6
chore: prefer use type over interface with eslint
Kit-p Jul 17, 2023
33dd7ba
chore(types): use generic TypeGuardFunction type
Kit-p Jul 17, 2023
6542bf6
feat(serialize): add generic type and typeGuard parameter to serializ…
Kit-p Jul 17, 2023
759eaa7
fix(types): use namespace export for better consumption
Kit-p Jul 17, 2023
95ef4b8
feat(signature): provide overloads for stringify and parse
Kit-p Jul 17, 2023
fb58f12
chore(types): remove = any as the default value of generic types
Kit-p Jul 17, 2023
20cc610
chore(types): remove redundant generic type
Kit-p Jul 17, 2023
2e23192
chore: remove lint-staged
Kit-p Jul 17, 2023
46ec396
chore(types): use const type parameter for function generic type
Kit-p Jul 17, 2023
04577d3
fix(serialize): add missing return type
Kit-p Jul 17, 2023
2b7eaaa
chore(test): add test for export members
Kit-p Jul 17, 2023
f068d54
chore(test): update parse.test.ts
Kit-p Jul 17, 2023
dd818e0
chore: remove empty code block in README.md
Kit-p Jul 17, 2023
5879dae
chore(docs): add TSDoc with TypeDoc for documentation site
Kit-p Jul 17, 2023
1700d53
chore(release): fix outdated path for CHANGELOG.md
Kit-p Jul 17, 2023
c705c97
chore: add steps to publish documentations in the CI/CD pipeline
Kit-p Jul 17, 2023
87ec043
chore(style): turn off eslint rules conflicting with prettier with es…
Kit-p Jul 22, 2023
40e998d
chore(format): ignore site and wiki directories
Kit-p Jul 30, 2023
ac02a54
chore(renovate): use default semantic commit types
Kit-p Jul 30, 2023
109caec
chore(test): configure jest threshold
Kit-p Jul 30, 2023
3b398cc
chore(docs): update README.md
Kit-p Jul 30, 2023
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
9 changes: 8 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand All @@ -18,6 +23,8 @@
"node_modules",
"dist",
"docs",
"site",
"wiki",
"coverage",
"test/dataset",
"*.cjs"
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Publish

on:
release:
types: ["released"]

workflow_dispatch:
inputs:
version:
description: "Version"
type: string
required: true

jobs:
build_and_publish_wiki:
name: Build and Publish GitHub Wiki
runs-on: ubuntu-latest
environment: Publish
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build documentations
run: pnpm exec concurrently "pnpm:build:docs:site" "pnpm:build:docs:wiki"
- name: Publish GitHub Wiki
uses: Andrew-Chen-Wang/github-wiki-action@v4
with:
commit-message: "chore(publish): GitHub Wiki for ${{ inputs.version || github.ref_name || github.sha }} [skip ci]"
- name: Upload GitHub Pages Artifacts
uses: actions/upload-pages-artifact@v2
with:
path: "site/"
publish_pages:
name: Publish GitHub Pages
needs: build_and_publish_wiki
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Setup GitHub Pages
uses: actions/configure-pages@v3
- name: Publish GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
12 changes: 0 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,3 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: rm -rf dist && pnpm run pre-release && pnpm run semantic-release
- name: Bump package version
uses: peter-evans/create-pull-request@v5
with:
add-paths: |
CHANGELOG.md
package.json
commit-message: "chore(release): bump version and update CHANGELOG.md [skip ci]"
committer: "release-bot <noreply@github.com>"
branch: release
delete-branch: true
title: "chore(release): bump version and update CHANGELOG.md [skip ci]"
body: "This PR bumps the version in `package.json` and updates `docs/CHANGELOG.md`."
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ dist

# TernJS port file
.tern-port

# TypeDoc generated documentations
site/
wiki/
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run lint && pnpm exec lint-staged
pnpm run lint
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
node_modules/
dist/
docs/
site/
wiki/
coverage/
test/dataset/
.editorconfig
Expand Down
16 changes: 12 additions & 4 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,25 @@
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
},
"writerOpts": {
"commitsSort": ["subject", "scope"]
"commitsSort": ["scope", "type", "subject"]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/changelog",
"@semantic-release/exec",
{
"changelogFile": "CHANGELOG.md"
"prepareCmd": "pnpm run build:docs:md"
}
],
[
"@semantic-release/git",
{
"assets": ["package.json", "CHANGELOG.md", "docs/"],
"message": "chore(release): release v${nextRelease.version} [skip ci]"
}
],
"@semantic-release/npm",
[
"@semantic-release/github",
{
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<h1 align="center">json-kit</h1>

<div align="center">
<a href="https://www.npmjs.com/package/@kit-p/json-kit">
<img
src="https://img.shields.io/npm/v/%40kit-p/json-kit"
alt="npm: @kit-p/json-kit"
/>
</a>
<a>
<img
src="https://img.shields.io/github/languages/top/Kit-p/json-kit"
alt="languages: github.com/Kit-p/json-kit"
/>
</a>
<a href="https://github.com/semantic-release/semantic-release">
<img
src="https://img.shields.io/badge/semantic--release-conventionalcommits-e10079?logo=semantic-release"
Expand All @@ -21,7 +33,7 @@

## Project State

> This project is in **early development** phase. The APIs are subject to change. Please do **NOT** use in production environments.
> This project is in **maintenance** state. The APIs are stable.

## Installation

Expand Down Expand Up @@ -73,10 +85,10 @@ import { JsonKit } from "@kit-p/json-kit";
</script>
```

## License
## Usage

MIT
See [the documentation site](https://kit-p.github.io/json-kit/modules.html) or [the repository Wiki page](https://github.com/Kit-p/json-kit/wiki/Exports) or `docs/modules.md`.

```
## License

```
[MIT](https://github.com/Kit-p/json-kit/blob/main/LICENSE)
Empty file added docs/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ const config = {
transform: {
"^.+\\.(c|m)?(t|j)sx?$": ["@swc/jest"],
},
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
};

export default config;
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@
"test": "jest --coverage --filter \"./jest.filter.cjs\"",
"test:perf": "jest --filter \"./jest.perf.filter.cjs\"",
"lint": "concurrently \"pnpm:lint:*\"",
"lint:code": "eslint .",
"lint:style": "prettier --check .",
"lint:types": "tsc --noEmit",
"lint:js": "eslint src",
"build": "concurrently \"pnpm:build:*\"",
"format": "eslint --fix --ext .ts . && prettier --write .",
"build": "concurrently \"pnpm:build:*(!docs)\"",
"build:types": "tsc -d --emitDeclarationOnly -p ./tsconfig.build.json",
"build:docs": "concurrently \"pnpm:build:docs:*\"",
"build:docs:site": "typedoc",
"build:docs:md": "typedoc --out docs --plugin typedoc-plugin-markdown",
"build:docs:wiki": "typedoc --out wiki --plugin typedoc-plugin-markdown --plugin typedoc-github-wiki-theme",
"build:js": "rollup -c rollup.config.mjs && pnpm run minify",
"minify": "concurrently \"pnpm:minify:*\"",
"minify:umd": "terser dist/index.umd.cjs --compress --mangle > dist/index.umd.min.cjs",
Expand Down Expand Up @@ -73,6 +79,8 @@
"@rollup/plugin-node-resolve": "15.1.0",
"@rollup/plugin-typescript": "11.1.2",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/exec": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/npm": "10.0.4",
"@swc/core": "1.3.69",
"@swc/jest": "0.2.26",
Expand All @@ -84,16 +92,19 @@
"@typescript-eslint/parser": "6.0.0",
"concurrently": "8.2.0",
"eslint": "8.45.0",
"eslint-config-prettier": "8.8.0",
"husky": "8.0.3",
"jest": "29.6.1",
"lint-staged": "13.2.3",
"prettier": "3.0.0",
"renovate": "36.8.11",
"rollup": "3.26.2",
"semantic-release": "21.0.7",
"terser": "5.19.0",
"ts-jest": "29.1.1",
"tslib": "2.6.0",
"typedoc": "0.24.8",
"typedoc-github-wiki-theme": "1.1.0",
"typedoc-plugin-markdown": "3.15.3",
"typescript": "5.1.6"
},
"pnpm": {
Expand All @@ -102,8 +113,5 @@
"marked-terminal@5>marked": "5"
}
}
},
"lint-staged": {
"*": "prettier --write"
}
}
Loading