Skip to content

Commit

Permalink
Merge pull request #84 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
update
  • Loading branch information
GuoXiCheng authored Jan 17, 2024
2 parents a3ea2aa + f71b79c commit d0dc6bb
Show file tree
Hide file tree
Showing 26 changed files with 115 additions and 82 deletions.
27 changes: 25 additions & 2 deletions package-lock.json

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

9 changes: 6 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 @@ -37,6 +39,7 @@
"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()],
},
];
2 changes: 1 addition & 1 deletion src/__tests__/authenticate-github.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GithubUser } from "./../repository-lib";
import { GithubUser } from "../index";
import { USE_API, githubRequest } from "./helper/helper";
import { mockGithubUser } from "./mock/mock-git-user";

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/book-repository.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from "dayjs";
import { PlainObject } from "./../repository-lib";
import { PlainObject } from "../index";
import { BookModel } from "./helper/book-model";
import { USE_API } from "./helper/helper";
import { Book } from "./helper/book-repository";
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/chat-repository.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlainObject } from "./../repository-lib";
import { PlainObject } from "../index";
import { ChatModel } from "./helper/chat-model";
import { Chat } from "./helper/chat-repository";
import { USE_API } from "./helper/helper";
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/helper/book-model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseModel } from '../../repository-lib/';
import { BaseModel} from '../../index'
export interface BookModel extends BaseModel {
book_name: string;
book_author: string;
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/helper/book-repository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { GithubRepository } from "../../repository-lib";
import { SingletonFactory } from "../../utils";
import { GithubRepository, SingletonFactory } from "../../index";
import { BookModel } from "./book-model";
import { githubRequest } from "./helper";

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/helper/chat-model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseModel } from "../../repository-lib";
import { BaseModel } from "../../index";

export interface ChatModel extends BaseModel {
participants: string[];
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/helper/chat-repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { GitlabRepository } from "../../repository-lib";
import { GitlabRepository, SingletonFactory } from "../../index";
import { ChatModel } from "./chat-model";
import { GITLAB_NUMBER, gitlabRequest } from "./helper";
import { SingletonFactory } from "../../utils";

class ChatRepository extends GitlabRepository<ChatModel> {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/helper/helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dotenv/config';
import axios from 'axios';
import CryptoJS from 'crypto-js';
import { createRequest } from '../../request-lib';
import { createRequest } from '../../index';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/helper/user-model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseModel } from "../../repository-lib";
import { BaseModel } from "../../index";
export interface UserModel extends BaseModel {
name: string;
age: number;
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/helper/user-repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

import { GiteeRepository } from '../../repository-lib';
import { SingletonFactory } from '../../utils';
import { GiteeRepository, SingletonFactory } from '../../index';
import { GITEE_NUMBER, giteeRequest } from './helper';
import { UserModel } from './user-model';

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/user-repository.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dayjs from "dayjs";
import { PlainObject } from "./../repository-lib";
import { PlainObject } from "../index";
import { UserModel } from "./helper/user-model";
import { User } from "./helper/user-repository";
import { setupGiteeMock } from "./mock/mock-gitee-api";
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/wx-request.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRequest } from './../request-lib';
import { createRequest } from '../index';

const wx = {
request: jest.fn()
Expand Down
28 changes: 21 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import { createRequest } from "./request-lib/create-request";
import { BaseModel, GiteeRepository, GitlabRepository, GithubRepository, PlainObject } from "./repository-lib";
import { SingletonFactory } from "./utils"
export {
createRequest, BaseModel, PlainObject,
GiteeRepository, GitlabRepository, GithubRepository, SingletonFactory
};
export { createRequest } from './request-lib/create-request';

export { SingletonFactory } from './utils/singleton-factory';

export { BaseRepository } from './repository-lib/base/base-repository';

export { BaseModel } from './repository-lib/base/base-model';

export { PlainObject } from './repository-lib/base/plain-object';

export { GiteeRepository } from './repository-lib/gitee/gitee-repository';

export { GithubRepository } from './repository-lib/github/github-repository';

export { GitlabRepository } from './repository-lib/gitlab/gitlab-repository';

export { GitlabUser } from './repository-lib/gitlab/gitlab-user';

export { GithubUser } from './repository-lib/github/github-user';

export { GiteeUser } from './repository-lib/gitee/gitee-user';

2 changes: 1 addition & 1 deletion src/repository-lib/base/base-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseRequest } from "../../request-lib";
import { BaseRequest } from "../../request-lib/base/base-request";
import { Author } from "./author";
import { BaseComment } from "./base-comment";
import { BaseModel } from "./base-model";
Expand Down
2 changes: 1 addition & 1 deletion src/repository-lib/gitee/gitee-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseRequest } from "../../request-lib";
import { BaseRequest } from "../../request-lib/base/base-request";
import { Author } from "../base/author";
import { BaseComment } from "../base/base-comment";
import { BaseModel } from "../base/base-model";
Expand Down
2 changes: 1 addition & 1 deletion src/repository-lib/github/github-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseRequest } from "../../request-lib";
import { BaseRequest } from "../../request-lib/base/base-request";
import { Author } from "../base/author";
import { BaseComment } from "../base/base-comment";
import { BaseModel } from "../base/base-model";
Expand Down
2 changes: 1 addition & 1 deletion src/repository-lib/gitlab/gitlab-repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseRequest } from "../../request-lib";
import { BaseRequest } from "../../request-lib/base/base-request";
import { BaseComment } from "../base/base-comment";
import { BaseModel } from "../base/base-model";
import { BaseRepository } from "../base/base-repository";
Expand Down
14 changes: 0 additions & 14 deletions src/repository-lib/index.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/request-lib/base/base-request.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { StoragePlatform } from "../../enums";
import { GiteeUser, GithubUser, GitlabUser } from "../../repository-lib";
import { GiteeUser } from '../../repository-lib/gitee/gitee-user';
import { GithubUser } from '../../repository-lib/github/github-user';
import { GitlabUser } from '../../repository-lib/gitlab/gitlab-user';
import { RequestMethods } from "./request-methods";
import { RequestOptions } from "./request-options";

Expand Down
4 changes: 3 additions & 1 deletion src/request-lib/base/request-options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GiteeOptions, GithubOptions, GitlabOptions } from "../../repository-lib";
import { GiteeOptions } from "../../repository-lib/gitee/gitee-options";
import { GithubOptions } from "../../repository-lib/github/github-options";
import { GitlabOptions } from "../../repository-lib/gitlab/gitlab-options";
import { AxiosOptions } from "../axios/axios-options";
import { WxOptions } from "../wx/wx-options";

Expand Down
3 changes: 0 additions & 3 deletions src/request-lib/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/utils/index.ts

This file was deleted.

5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"module": "ESNext" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "Node" /* Specify how TypeScript looks up a file from a given module specifier. */,
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "baseUrl": "./" /* Specify the base directory to resolve non-relative module names. */,
// "paths": {} /* Specify a set of entries that re-map imports to additional lookup locations. */,
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
Expand All @@ -50,6 +50,7 @@

/* Emit */
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
"declarationDir": "./dist/types",
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
Expand Down

0 comments on commit d0dc6bb

Please sign in to comment.