Skip to content

Commit

Permalink
Add the fundamental setups for npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
baku89 committed Nov 27, 2023
0 parents commit d537aad
Show file tree
Hide file tree
Showing 14 changed files with 3,431 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
env: {
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2022,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
'simple-import-sort',
'unused-imports',
'jest',
],
rules: {
'no-console': 'off',
'no-debugger': 'warn',
eqeqeq: 'error',
'prefer-const': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'simple-import-sort/imports': 'error',
'unused-imports/no-unused-imports-ts': 'error',
},
}
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Unit Test / Linting
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install modules
run: yarn
- name: Run tests
run: yarn test
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the pwa branch, when a new tag is created
push:
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build:doc
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload dist repository
path: './docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.DS_Store
node_modules

/lib
/docs

# local env files
.env.local
.env.*.local

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"useTabs": true,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"printWidth": 80,
"trailingComma": "es5",
"arrowParens": "avoid"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Baku Hashimoto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Pathed

[![NPM Version](https://img.shields.io/npm/v/pathed.svg)](https://www.npmjs.com/package/pathed)
![CI Test Result](https://github.com/baku89/pathed/actions/workflows/ci.yml/badge.svg)
![MIT License](https://img.shields.io/npm/l/pathed.svg)

## Development

```
git clone https://github.com/baku89/pathed
cd pathed
yarn install
yarn test --watch
```

## License

This repository is published under an MIT License. See the included [LICENSE file](./LICENSE).
25 changes: 25 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type {Config} from '@jest/types'

const config: Config.InitialOptions = {
silent: false,
preset: 'ts-jest',
passWithNoTests: true,
maxWorkers: 1,
projects: [
{
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
},
{
displayName: 'lint',
runner: 'jest-runner-eslint',
testMatch: ['<rootDir>/src/**/*.ts'],
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
},
],
}

export default config
57 changes: 57 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "pathed",
"version": "0.0.0",
"description": "A low level toolkit for SVG paths.",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/esm/index.d.ts",
"sideEffects": false,
"scripts": {
"build": "tsc && tsc -p tsconfig.cjs.json",
"build:doc": "typedoc",
"lint": "eslint",
"test": "jest",
"prepare": "npm run build",
"preversion": "npm run test",
"postversion": "git push && git push --tags && npm publish"
},
"repository": {
"type": "git",
"url": "git+https://github.com/baku89/pathed.git"
},
"keywords": [
"svg",
"path",
"transform",
"graphics",
"vector",
"matrix"
],
"author": "Baku Hashimoto <[email protected]>",
"files": [
"lib"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/baku89/pathed/issues"
},
"homepage": "https://baku89.github.io/pathed",
"devDependencies": {
"@types/jest": "^29.5.4",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"jest": "^29.7.0",
"jest-runner-eslint": "^2.1.1",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.1",
"typedoc-plugin-markdown": "^3.16.0",
"typescript": "^5.2.2"
}
}
Empty file added src/index.ts
Empty file.
8 changes: 8 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "Node",
"outDir": "./lib/cjs"
}
}
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "es2022",
"module": "ES2022",
"strict": true,
"moduleResolution": "Bundler",
"esModuleInterop": true,
"experimentalDecorators": true,
"inlineSourceMap": true,
"baseUrl": ".",
"outDir": "./lib/esm",
"isolatedModules": true,
"declaration": true,
"declarationMap": true,
"lib": ["esnext", "DOM"],
"skipLibCheck": true,
"skipDefaultLibCheck": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "src/**/*.test.ts"]
}
8 changes: 8 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://typedoc.org/schema.json",
"entryPoints": ["./src/index.ts"],
"readme": "README.md",
"sort": ["alphabetical"],
"defaultCategory": "Functions",
"categoryOrder": ["Types", "Constants", "Generators", "Functions", "Aliases"]
}
Loading

0 comments on commit d537aad

Please sign in to comment.