From cc2e81e6488ff51fadb712f77584fa1ed80152a8 Mon Sep 17 00:00:00 2001 From: dm1sh Date: Tue, 3 Aug 2021 10:06:21 +0300 Subject: [PATCH] Sut up dev environment --- .github/workflows/test.yaml | 14 ++++++++++++++ .gitignore | 4 ++++ README.md | 6 ++++++ jestconfig.json | 7 +++++++ package.json | 22 +++++++++++++++++++--- html-pagination.d.ts => src/index.ts | 4 ++-- tsconfig.json | 11 +++++++++++ 7 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test.yaml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 jestconfig.json rename html-pagination.d.ts => src/index.ts (88%) create mode 100644 tsconfig.json diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..f817bc1 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,14 @@ +name: Test CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: "14" + - run: npm install + - run: npm test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd4bc96 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +package-lock.json +pnpm-lock.yaml +/lib/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e7883d --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# HTML pagination + +![Test workflow](https://github.com/dm1sh/html-pagination/actions/workflows/test.yaml/badge.svg) + +It is a plugin for HTML document pagination to fit fixed-sized container. +This operation is rather time-consuming, so, please, use this module carefully. diff --git a/jestconfig.json b/jestconfig.json new file mode 100644 index 0000000..20c25c0 --- /dev/null +++ b/jestconfig.json @@ -0,0 +1,7 @@ +{ + "transform": { + "^.+\\.(t|j)sx?$": "ts-jest" + }, + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"] +} diff --git a/package.json b/package.json index 2200bf1..2d0cc33 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,19 @@ "name": "html-pagination", "version": "1.0.0", "description": "Package for html document pagination to fit container with fixed width", - "main": "index.js", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "files": [ + "./lib/**/*" + ], "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "tsc", + "test": "jest --config jestconfig.json --passWithNoTests", + "prepare": "npm run build", + "prepublishOnly": "npm test && npm run lint", + "preversion": "npm run lint", + "version": "npm run format && git add -A src", + "postversion": "git push && git push --tags" }, "repository": { "type": "git", @@ -19,5 +29,11 @@ "bugs": { "url": "https://github.com/dm1sh/html-pagination/issues" }, - "homepage": "https://github.com/dm1sh/html-pagination#readme" + "homepage": "https://github.com/dm1sh/html-pagination#readme", + "devDependencies": { + "@types/jest": "^26.0.24", + "jest": "^27.0.6", + "ts-jest": "^27.0.4", + "typescript": "^4.3.5" + } } diff --git a/html-pagination.d.ts b/src/index.ts similarity index 88% rename from html-pagination.d.ts rename to src/index.ts index d55c17b..fe2a725 100644 --- a/html-pagination.d.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export abstract class CacheInterface { +export declare abstract class CacheInterface { abstract g(key: string): string; abstract s(key: string, value: string): void; } @@ -15,7 +15,7 @@ declare function getPage(n: number): string; * @param container HTML element which will store content to display * @param cache Class implementing `g` and `s` methods for getting and setting elements of KV storage */ -export function setup( +export declare function setup( content: HTMLElement, container: HTMLElement, cache: CacheInterface diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ca4bf6a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "declaration": true, + "outDir": "./lib", + "strict": true + }, + "include": ["src"], + "exclude": ["node_modules", "**/__tests__/*"] +}