Skip to content

Commit

Permalink
Merge pull request #85 from GuoXiCheng/main
Browse files Browse the repository at this point in the history
publish 1.0.23
  • Loading branch information
GuoXiCheng authored Jan 17, 2024
2 parents 5f90391 + d0dc6bb commit 8d75daa
Show file tree
Hide file tree
Showing 42 changed files with 1,222 additions and 229 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ dist
.pnp.*

lib
src/__tests__/mock/json/*.json
!src/__tests__/mock/json/mock*.json
23 changes: 12 additions & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module.exports = {
testTimeout: 120000,
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverageFrom: [
"src/**/*.ts", // 包括 src 目录下所有的 TypeScript 文件
"!src/**/*.d.ts", // 排除 TypeScript 声明文件
"!src/__tests__/**/*.ts"
],
testMatch: ["<rootDir>/src/__tests__/**/*.test.ts"]
};
module.exports = {
testTimeout: 30000,
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverageFrom: [
"src/**/*.ts", // 包括 src 目录下所有的 TypeScript 文件
"!src/**/*.d.ts", // 排除 TypeScript 声明文件
"!src/__tests__/**/*.ts"
],
testMatch: ["<rootDir>/src/__tests__/*.test.ts"],
testPathIgnorePatterns: []
};
102 changes: 100 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tiny-crud",
"version": "1.0.22",
"description": "",
"version": "1.0.23",
"description": "A tiny CRUD library based on Git Issue API",
"main": "dist/bundle.cjs.js",
"module": "dist/bundle.esm.js",
"types": "dist/index.d.ts",
Expand All @@ -13,7 +13,9 @@
"author": "Xicheng_Guo",
"license": "MIT",
"files": [
"dist"
"dist/bundle.cjs.js",
"dist/bundle.esm.js",
"dist/index.d.ts"
],
"devDependencies": {
"@babel/preset-env": "^7.23.3",
Expand All @@ -25,15 +27,19 @@
"@rollup/plugin-typescript": "^11.1.5",
"@types/crypto-js": "^4.2.1",
"@types/jest": "^29.5.9",
"@types/jsonfile": "^6.1.4",
"@types/wechat-miniprogram": "^3.4.7",
"axios": "^1.6.2",
"axios-mock-adapter": "^1.22.0",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.10",
"dotenv": "^16.3.1",
"jest": "^29.7.0",
"jsonfile": "^6.1.0",
"nyc": "^15.1.0",
"rimraf": "^5.0.5",
"rollup": "^4.3.0",
"rollup-plugin-dts": "^6.1.0",
"ts-jest": "^29.1.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
Expand Down
67 changes: 38 additions & 29 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";

export default {
input: 'src/index.ts',
output: [
{
file: 'dist/bundle.cjs.js', // CommonJS 输出文件
format: 'cjs',
},
{
file: 'dist/bundle.esm.js', // ES Module 输出文件
format: 'esm',
},
],
plugins: [
typescript({ include: ['./src/**/*.ts'] }),
babel({
babelHelpers: 'bundled',
extensions: ['.ts', '.tsx'],
presets: ['@babel/preset-env', '@babel/preset-typescript'],
}),
nodeResolve(),
commonjs(),
json()
]
};
export default [
{
input: "src/index.ts",
output: [
{
file: "dist/bundle.cjs.js", // CommonJS 输出文件
format: "cjs",
},
{
file: "dist/bundle.esm.js", // ES Module 输出文件
format: "esm",
},
],
plugins: [
typescript({ include: ["./src/**/*.ts"] }),
babel({
babelHelpers: "bundled",
extensions: [".ts", ".tsx"],
presets: ["@babel/preset-env", "@babel/preset-typescript"],
}),
nodeResolve(),
commonjs(),
json(),
],
},
/* 单独生成声明文件 */
{
input: "dist/types/index.d.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [dts()],
},
];
48 changes: 27 additions & 21 deletions src/__tests__/authenticate-gitee.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import { giteeRequest } from "./helper/helper";
import { USE_API, giteeRequest } from './helper/helper';
import { mockGiteeUser } from './mock/mock-git-user';

describe('Test Authenticate Gitee', () => {
test('Test Authenticate Gitee', async () => {
const res = await giteeRequest.authenticate();
expect(Object.keys(res)).toEqual([
'id', 'login',
'name', 'avatar_url',
'url', 'html_url',
'remark', 'followers_url',
'following_url', 'gists_url',
'starred_url', 'subscriptions_url',
'organizations_url', 'repos_url',
'events_url', 'received_events_url',
'type', 'blog',
'weibo', 'bio',
'public_repos', 'public_gists',
'followers', 'following',
'stared', 'watched',
'created_at', 'updated_at',
'email'
])
});
beforeAll(()=>{
if (USE_API) return;
mockGiteeUser();
});

test('Test Authenticate Gitee', async () => {
const res = await giteeRequest.authenticate();
expect(Object.keys(res)).toEqual([
'id', 'login',
'name', 'avatar_url',
'url', 'html_url',
'remark', 'followers_url',
'following_url', 'gists_url',
'starred_url', 'subscriptions_url',
'organizations_url', 'repos_url',
'events_url', 'received_events_url',
'type', 'blog',
'weibo', 'bio',
'public_repos', 'public_gists',
'followers', 'following',
'stared', 'watched',
'created_at', 'updated_at',
'email'
]);
});
});
12 changes: 10 additions & 2 deletions src/__tests__/authenticate-github.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { githubRequest } from "./helper/helper";
import { GithubUser } from "../index";
import { USE_API, githubRequest } from "./helper/helper";
import { mockGithubUser } from "./mock/mock-git-user";

describe('Test Authenticate Github', () => {
beforeAll(() => {
if (USE_API) return;
mockGithubUser();
});

test('Test Authenticate Github', async () => {
const res = await githubRequest.authenticate();
const res = await githubRequest.authenticate() as GithubUser;
console.log(res.blog);
expect(Object.keys(res)).toEqual([
'login', 'id',
'node_id', 'avatar_url',
Expand Down
Loading

0 comments on commit 8d75daa

Please sign in to comment.