Skip to content

Commit

Permalink
CI
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed Mar 1, 2024
1 parent 7e39488 commit 0c563f0
Show file tree
Hide file tree
Showing 25 changed files with 6,645 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# zhin

## 3.0.0

### Major Changes

- Bump version
12 changes: 12 additions & 0 deletions packages/adapters/dingtalk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/dingtalk

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/adapters/discord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/discord

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/adapters/icqq/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/icqq

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
13 changes: 13 additions & 0 deletions packages/adapters/onebot-11/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @zhinjs/onebot-11

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- @zhinjs/plugin-http-server@1.0.0
- zhin@3.0.0
13 changes: 13 additions & 0 deletions packages/adapters/onebot-12/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @zhinjs/onebot-12

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- @zhinjs/plugin-http-server@1.0.0
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/adapters/qq/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/qq

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/adapters/wechat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/wechat

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
13 changes: 13 additions & 0 deletions packages/plugins/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @zhinjs/client

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- @zhinjs/plugin-http-server@1.0.0
- zhin@3.0.0
13 changes: 13 additions & 0 deletions packages/plugins/game/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @zhinjs/plugin-game

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- @zhinjs/plugin-drawer@1.0.0
- zhin@3.0.0
13 changes: 13 additions & 0 deletions packages/plugins/groupManage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @zhinjs/plugin-group-manage

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- @zhinjs/onebot-12@1.0.0
- zhin@3.0.0
13 changes: 13 additions & 0 deletions packages/plugins/guildManage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @zhinjs/plugin-guild-manage

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- @zhinjs/qq@1.0.0
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/plugins/qa/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/plugin-qa

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/plugins/schedule/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/plugin-schedule

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/services/drawer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/plugin-drawer

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
12 changes: 12 additions & 0 deletions packages/services/http-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# @zhinjs/plugin-http-server

## 1.0.0

### Major Changes

- Bump version

### Patch Changes

- Updated dependencies
- zhin@3.0.0
21 changes: 21 additions & 0 deletions packages/services/jsondb/lib/db.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export declare class JsonDB {
private readonly filePath;
private data;
constructor(filePath: string);
private init;
private write;
private read;
findIndex<T>(route: string, predicate: (value: T, index: number, obj: T[]) => unknown): number;
indexOf<T>(route: string, item: T): number;
get<T>(route: string, initialValue?: T): T | undefined;
set<T>(route: string, data: T): T;
delete(route: string): boolean;
private getArray;
unshift<T>(route: string, ...data: T[]): number;
shift<T>(route: string): T | undefined;
push<T>(route: string, ...data: T[]): number;
pop<T>(route: string): T | undefined;
splice<T>(route: string, index?: number, deleteCount?: number, ...data: T[]): T[];
find<T>(route: string, callback: (item: T) => boolean): T | undefined;
filter<T>(route: string, callback: (item: T) => boolean): T[];
}
149 changes: 149 additions & 0 deletions packages/services/jsondb/lib/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonDB = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const utils_1 = require("./utils");
class JsonDB {
constructor(filePath) {
this.filePath = filePath;
this.data = {};
const dir = path.dirname(this.filePath);
if (fs.existsSync(dir))
fs.mkdirSync(dir, { recursive: true });
if (!this.filePath.endsWith('.jsondb'))
this.filePath = this.filePath + '.jsondb';
if (!fs.existsSync(this.filePath))
this.write();
this.init();
}
init() {
this.read();
}
write() {
fs.writeFileSync(this.filePath, (0, utils_1.stringifyObj)(this.data), 'utf8');
}
read() {
this.data = (0, utils_1.parseObjFromStr)(fs.readFileSync(this.filePath, 'utf8'));
}
findIndex(route, predicate) {
const arr = this.getArray(route);
return arr.findIndex(predicate);
}
indexOf(route, item) {
return this.findIndex(route, value => value === item);
}
get(route, initialValue) {
this.read();
const parentPath = route.split('.').filter(p => p.length);
const key = parentPath.pop();
if (!key)
return this.data;
let temp = this.data;
while (parentPath.length) {
const currentKey = parentPath.shift();
if (!Reflect.has(temp, currentKey))
Reflect.set(temp, key, {});
temp = Reflect.get(temp, currentKey);
}
if (temp[key] !== undefined)
return temp[key];
temp[key] = initialValue;
this.write();
return initialValue;
}
set(route, data) {
const parentPath = route.split('.');
const key = parentPath.pop();
if (!key)
throw new SyntaxError(`route can't empty`);
const parentObj = this.get(parentPath.join('.'), {});
if (!parentObj)
throw new SyntaxError(`can't set property ${key} of undefined`);
parentObj[key] = data;
this.write();
return data;
}
delete(route) {
const parentPath = route.split('.');
const key = parentPath.pop();
if (!key)
throw new SyntaxError(`route can't empty`);
const parentObj = this.get(parentPath.join('.'), {});
if (!parentObj)
throw new SyntaxError(`property ${key} is not exist of undefined`);
const result = delete parentObj[key];
this.write();
return result;
}
getArray(route) {
if (!route)
throw new Error(`route can't empty`);
const arr = this.get(route, []);
if (!arr)
throw new SyntaxError(`route ${route} is not define`);
if (!Array.isArray(arr))
throw new TypeError(`data ${route} is not an Array`);
return arr;
}
unshift(route, ...data) {
const arr = this.getArray(route);
const result = arr.unshift(...data);
this.write();
return result;
}
shift(route) {
const arr = this.getArray(route);
const result = arr.shift();
this.write();
return result;
}
push(route, ...data) {
const arr = this.getArray(route);
const result = arr.push(...data);
this.write();
return result;
}
pop(route) {
const arr = this.getArray(route);
const result = arr.pop();
this.write();
return result;
}
splice(route, index = 0, deleteCount = 0, ...data) {
const arr = this.getArray(route);
const result = arr.splice(index, deleteCount, ...data);
this.write();
return result;
}
find(route, callback) {
return this.getArray(route).find(callback);
}
filter(route, callback) {
return this.getArray(route).filter(callback);
}
}
exports.JsonDB = JsonDB;
11 changes: 11 additions & 0 deletions packages/services/jsondb/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Plugin } from 'zhin';
import { JsonDB } from './db';
declare module 'zhin' {
namespace App {
interface Services {
jsondb: JsonDB;
}
}
}
declare const db: Plugin;
export default db;
Loading

0 comments on commit 0c563f0

Please sign in to comment.