mirror of
https://github.com/SrIzan10/util-utils.git
synced 2026-06-06 01:06:59 +00:00
Initial commit
This commit is contained in:
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
/lib
|
||||
/coverage
|
||||
17
.eslintrc
Normal file
17
.eslintrc
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"no-console": 1,
|
||||
"semi-style": ["error", "last"],
|
||||
"semi": [2, "always"]
|
||||
}
|
||||
}
|
||||
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [el3um4s]
|
||||
patreon: el3um4s
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: ["https://www.paypal.me/el3um4s"]
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
/lib
|
||||
/coverage
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Samuele de Tomasi
|
||||
|
||||
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.
|
||||
106
README.md
Normal file
106
README.md
Normal file
@@ -0,0 +1,106 @@
|
||||
# Typescript NPM Package Starter
|
||||
My template for creating npm packages using typescript.
|
||||
|
||||
- TS to JS
|
||||
- Testing via Jest, includes coverage
|
||||
- ESLint
|
||||
- Ignore files to ensure minimal code is stored/shipped
|
||||
|
||||
NPM link: [@el3um4s/typescript-npm-package-starter](https://www.npmjs.com/package/@el3um4s/typescript-npm-package-starter)
|
||||
|
||||
### Getting Started
|
||||
|
||||
To create a new project based on this template using degit:
|
||||
|
||||
```bash
|
||||
npx degit el3um4s/typescript-npm-package-starter
|
||||
```
|
||||
|
||||
Then install the dependencies with
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
Now update the name field in package.json with your desired package name. Then update the homepage field in package.json. And finally add your code.
|
||||
|
||||
### Build the package
|
||||
|
||||
Run
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Test the package
|
||||
|
||||
You can test the code with [Jest](https://jestjs.io/)
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
You can find the test coverage in `coverage/lcov-report/index.html`.
|
||||
|
||||
### Check dependencies
|
||||
|
||||
You can check and upgrade dependencies to the latest versions, ignoring specified versions. with [npm-check-updates](https://www.npmjs.com/package/npm-check-updates):
|
||||
|
||||
```bash
|
||||
npm run check-updates
|
||||
```
|
||||
|
||||
You can also use `npm run check-updates:minor` to update only patch and minor.
|
||||
|
||||
Instead `npm run check-updates:patch` only updates patch.
|
||||
|
||||
### Publish
|
||||
|
||||
First commit the changes to GitHub. Then login to your [NPM](https://www.npmjs.com) account (If you don’t have an account you can do so on [https://www.npmjs.com/signup](https://www.npmjs.com/signup))
|
||||
|
||||
```bash
|
||||
npm login
|
||||
```
|
||||
|
||||
Then run publish:
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
If you're using a scoped name use:
|
||||
|
||||
```bash
|
||||
npm publish --access public
|
||||
```
|
||||
|
||||
### Bumping a new version
|
||||
|
||||
To update the package use:
|
||||
|
||||
```bash
|
||||
npm version patch
|
||||
```
|
||||
|
||||
and then
|
||||
|
||||
```bash
|
||||
npm publish
|
||||
```
|
||||
|
||||
### Install and use the package
|
||||
|
||||
To use the package in a project:
|
||||
|
||||
```bash
|
||||
npm i @el3um4s/typescript-npm-package-starter
|
||||
```
|
||||
|
||||
and then in a file:
|
||||
|
||||
```ts
|
||||
import { ciao } from "@el3um4s/typescript-npm-package-starter";
|
||||
|
||||
const b = ciao("mondo");
|
||||
console.log(b); // Ciao Mondo
|
||||
```
|
||||
9
jestconfig.json
Normal file
9
jestconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"transform": {
|
||||
"^.+\\.(t|j)sx?$": "ts-jest"
|
||||
},
|
||||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
||||
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
|
||||
"collectCoverageFrom": ["src/**/*.{ts,tsx}"],
|
||||
"collectCoverage":true
|
||||
}
|
||||
10037
package-lock.json
generated
Normal file
10037
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
65
package.json
Normal file
65
package.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "@el3um4s/typescript-npm-package-starter",
|
||||
"version": "1.0.5",
|
||||
"description": "Typescript NPM Package Starter",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"test": "jest --config jestconfig.json",
|
||||
"prepare": "npm run build",
|
||||
"prepublishOnly": "npm test && npm run lint",
|
||||
"preversion": "npm run lint",
|
||||
"version": "git add -A src",
|
||||
"postversion": "git push && git push --tags",
|
||||
"check-updates": "npx npm-check-updates",
|
||||
"check-updates:minor": "npx npm-check-updates --target minor",
|
||||
"check-updates:patch": "npx npm-check-updates --target patch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/el3um4s/typescript-npm-package-starter.git"
|
||||
},
|
||||
"files": [
|
||||
"lib/**/*"
|
||||
],
|
||||
"keywords": [
|
||||
"typescript",
|
||||
"npm",
|
||||
"template",
|
||||
"ts"
|
||||
],
|
||||
"author": "Samuele C. De Tomasi",
|
||||
"license": "MIT",
|
||||
"funding": [
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/el3um4s"
|
||||
},
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://www.paypal.me/el3um4s"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/el3um4s/typescript-npm-package-starter/issues"
|
||||
},
|
||||
"homepage": "https://github.com/el3um4s/typescript-npm-package-starter#readme",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.4.0",
|
||||
"@types/node": "^18.13.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
||||
"@typescript-eslint/parser": "^5.51.0",
|
||||
"ansi-regex": ">=6.0.1",
|
||||
"eslint": "^8.33.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"jest": "^29.4.1",
|
||||
"ts-jest": "^29.0.5",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
8
src/__tests__/Ciao.test.ts
Normal file
8
src/__tests__/Ciao.test.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { myCustomFunction, ciao } from '../index';
|
||||
test('ciao', () => {
|
||||
expect(ciao('Mondo')).toBe('Ciao Mondo');
|
||||
});
|
||||
|
||||
test("myCustomFunction", () => {
|
||||
expect(myCustomFunction('Mario')).toBe('Hello Mario');
|
||||
});
|
||||
6
src/index.ts
Normal file
6
src/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
const myCustomFunction = (name: string):string => `Hello ${name}`;
|
||||
function ciao(name: string): string {
|
||||
return `Ciao ${name}`;
|
||||
}
|
||||
|
||||
export { myCustomFunction, ciao};
|
||||
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib",
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"declaration": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/*"]
|
||||
}
|
||||
5
tsconfig.spec.json
Normal file
5
tsconfig.spec.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"types": ["jest", "node"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user