Skip to content

Commit

Permalink
chore(init): init project
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Mar 31, 2024
1 parent a72b63c commit fddb8a9
Show file tree
Hide file tree
Showing 16 changed files with 5,790 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# EditorConfig is awesome: https://EditorConfig.org
# install EditorConfig for VS Code extension
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules
67 changes: 67 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"env": {
"browser": true,
"es6": true,
"node": true,
"jest": true
},
"extends": [
"airbnb",
"prettier",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"plugins": [
"prettier",
"@typescript-eslint"
],
"rules": {
"no-useless-constructor": 0,
"class-methods-use-this": 0,
"no-underscore-dangle": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"max-classes-per-file": 0,
"no-await-in-loop": "off",
"no-restricted-syntax": "off",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
],
"import/prefer-default-export": "off",
"prettier/prettier": [
"error"
],
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"ts": "never"
}
]
},
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".ts"
]
}
}
}
}
26 changes: 26 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, build, and test
run: |
yarn install
yarn build
yarn test
env:
CI: true
24 changes: 24 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish Package to npmjs
on:
release:
types: [created]
jobs:
publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn build
- run: yarn test
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
CI: true

1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# use-transport
A React hook with simple and responsible universal transports

![Node CI](https://github.com/unadlib/use-transport/workflows/Node%20CI/badge.svg)
[![npm](https://img.shields.io/npm/v/use-transport.svg)](https://www.npmjs.com/package/use-transport)
![license](https://img.shields.io/npm/l/use-transport)

A React hook with simple and responsible universal transports.

### Motivation

### Installation

```bash
npm install use-transport data-transport
# or
yarn add use-transport data-transport
```

### Features

### Example

### API

### Options

### Return

## License

`use-transport` is [MIT licensed](https://github.com/unadlib/use-transport/blob/main/LICENSE).
1 change: 1 addition & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var __DEV__: boolean
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src';
88 changes: 88 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"name": "use-transport",
"version": "0.0.1",
"description": "A React hook with simple and responsible universal transports",
"main": "dist/index.cjs.js",
"unpkg": "dist/index.umd.js",
"types": "dist/index.d.ts",
"umd:main": "dist/index.umd.js",
"module": "dist/index.esm.js",
"jsnext:main": "dist/index.esm.js",
"react-native": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"source": "src/index.ts",
"sideEffects": false,
"files": [
"dist"
],
"scripts": {
"test": "jest",
"test:coverage": "jest --coverage && coveralls < coverage/lcov.info",
"clean": "rimraf dist",
"build": "yarn clean && tsc --skipLibCheck && yarn build:prod",
"build:prod": "NODE_ENV=production rollup --config --bundleConfigAsCjs",
"commit": "yarn git-cz"
},
"repository": {
"type": "git",
"url": "git+https://github.com/unadlib/use-transport.git"
},
"author": "unadlib",
"license": "MIT",
"bugs": {
"url": "https://github.com/unadlib/use-transport/issues"
},
"homepage": "https://github.com/unadlib/use-transport#readme",
"keywords": [],
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.2",
"@testing-library/react": "^14.2.1",
"@types/jest": "^29.5.0",
"@types/node": "^18.15.5",
"@types/react": "^18.2.66",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"commitizen": "^4.3.0",
"coveralls": "^3.1.1",
"data-transport": "^4.3.5",
"eslint": "^8.36.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"prettier": "^2.8.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^4.4.0",
"rollup": "^3.20.0",
"rollup-plugin-terser": "^7.0.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typedoc": "^0.23.28",
"typedoc-plugin-markdown": "^3.14.0",
"typescript": "^5.4.3",
"yargs": "^17.7.1"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "jsdom",
"globals": {
"__DEV__": false
}
},
"peerDependencies": {
"@types/react": "^18.0 || ^17.0",
"data-transport": "^4.3.5",
"react": "^18.0 || ^17.0"
}
}
48 changes: 48 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';

const input = './dist/index.js';

export default {
input,
output: [
{
format: 'cjs',
exports: 'auto',
file: 'dist/index.cjs.js',
sourcemap: true,
},
{
format: 'es',
file: 'dist/index.esm.js',
sourcemap: true,
},
{
format: 'umd',
name: pkg.name
.split('-')
.map(([s, ...rest]) => [s.toUpperCase(), ...rest].join(''))
.join(''),
file: pkg.unpkg,
sourcemap: true,
globals: {
'data-transport': 'DataTransport',
react: 'React',
},
exports: 'named',
},
],
plugins: [
resolve(),
commonjs(),
replace({
__DEV__: 'false',
preventAssignment: true,
}),
terser(),
],
external: ['data-transport', 'react'],
};
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const add = (a: number, b: number) => a + b;
3 changes: 3 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test('', () => {
//
});
Loading

0 comments on commit fddb8a9

Please sign in to comment.