mirror of
https://github.com/cool-team-official/cool-admin-midway-packages.git
synced 2025-12-10 21:32:48 +00:00
v8
This commit is contained in:
parent
48aa401553
commit
ffe8c9f199
33
LICENSE
Normal file
33
LICENSE
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) [2025] [厦门闪酷科技开发有限公司]
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
MIT 许可证
|
||||||
|
|
||||||
|
版权所有 (c) [2025] [厦门闪酷科技开发有限公司]
|
||||||
|
|
||||||
|
特此免费授予获得本软件及相关文档文件(“软件”)副本的任何人无限制地处理本软件的权限,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,并允许软件提供给其的人员这样做,但须符合以下条件:
|
||||||
|
|
||||||
|
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
|
||||||
|
|
||||||
|
本软件按“原样”提供,不提供任何明示或暗示的担保,包括但不限于对适销性、特定用途适用性和非侵权的担保。在任何情况下,作者或版权持有人均不对因软件或软件使用或其他交易而产生的任何索赔、损害或其他责任负责,无论是在合同诉讼、侵权诉讼或其他诉讼中。
|
||||||
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# 介绍
|
||||||
|
|
||||||
|
这是`cool-admin-midway`项目的核心包,用于提供`cool-admin-midway`项目的核心功能。
|
||||||
|
|
||||||
|
官网:https://cool-js.com
|
||||||
|
|
||||||
|
文档地址:https://node.cool-admin.com
|
||||||
11
core/.editorconfig
Normal file
11
core/.editorconfig
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# 🎨 editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
7
core/.eslintrc.json
Normal file
7
core/.eslintrc.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"extends": "./node_modules/mwts/",
|
||||||
|
"ignorePatterns": ["node_modules", "dist", "test", "jest.config.js", "typings"],
|
||||||
|
"env": {
|
||||||
|
"jest": true
|
||||||
|
}
|
||||||
|
}
|
||||||
13
core/.gitignore
vendored
Normal file
13
core/.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
logs/
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
dist/
|
||||||
|
.idea/
|
||||||
|
run/
|
||||||
|
.DS_Store
|
||||||
|
*.sw*
|
||||||
|
*.un~
|
||||||
|
.tsbuildinfo
|
||||||
|
.tsbuildinfo.*
|
||||||
3
core/.prettierrc.js
Normal file
3
core/.prettierrc.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
...require('mwts/.prettierrc.json')
|
||||||
|
}
|
||||||
10
core/index.d.ts
vendored
Normal file
10
core/index.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export * from './dist/index';
|
||||||
|
|
||||||
|
declare module '@midwayjs/core/dist/interface' {
|
||||||
|
interface MidwayConfig {
|
||||||
|
book?: PowerPartial<{
|
||||||
|
a: number;
|
||||||
|
b: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
}
|
||||||
7
core/jest.config.js
Normal file
7
core/jest.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: 'ts-jest',
|
||||||
|
testEnvironment: 'node',
|
||||||
|
testPathIgnorePatterns: ['<rootDir>/test/fixtures'],
|
||||||
|
coveragePathIgnorePatterns: ['<rootDir>/test/'],
|
||||||
|
setupFilesAfterEnv: ['./jest.setup.js']
|
||||||
|
};
|
||||||
1
core/jest.setup.js
Normal file
1
core/jest.setup.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
jest.setTimeout(30000);
|
||||||
42
core/package.json
Normal file
42
core/package.json
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/package",
|
||||||
|
"name": "@cool-midway/core",
|
||||||
|
"version": "8.0.0",
|
||||||
|
"description": "cool-admin-midway core",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"typings": "index.d.ts",
|
||||||
|
"bin": {
|
||||||
|
"cool": "./dist/bin/index.js"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "mwtsc --cleanOutDir",
|
||||||
|
"test": "cross-env NODE_ENV=unittest jest",
|
||||||
|
"cov": "jest --coverage",
|
||||||
|
"lint": "mwts check",
|
||||||
|
"lint:fix": "mwts fix"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"files": [
|
||||||
|
"dist/**/*.js",
|
||||||
|
"dist/**/*.d.ts",
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@midwayjs/core": "^3.19.0",
|
||||||
|
"@midwayjs/logger": "^3.4.2",
|
||||||
|
"@midwayjs/mock": "^3.19.2",
|
||||||
|
"@types/jest": "^29.5.14",
|
||||||
|
"@types/node": "^22.10.5",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
|
"jest": "^29.7.0",
|
||||||
|
"mwts": "^1.3.0",
|
||||||
|
"mwtsc": "^1.15.1",
|
||||||
|
"ts-jest": "^29.2.5",
|
||||||
|
"typescript": "~5.7.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"commander": "^11.1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
5239
core/pnpm-lock.yaml
generated
Normal file
5239
core/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
core/src/bin/check.ts
Normal file
9
core/src/bin/check.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export async function check() {
|
||||||
|
try {
|
||||||
|
console.log('Running check command...');
|
||||||
|
// 在这里实现检查逻辑
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Check failed:', error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
core/src/bin/index.ts
Normal file
25
core/src/bin/index.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { Command } from 'commander';
|
||||||
|
import { check } from './check';
|
||||||
|
|
||||||
|
const program = new Command();
|
||||||
|
|
||||||
|
// 设置版本号(从 package.json 中获取)
|
||||||
|
program.version(require('../../package.json').version);
|
||||||
|
|
||||||
|
// 添加 check 命令
|
||||||
|
program
|
||||||
|
.command('check')
|
||||||
|
.description('Run check command')
|
||||||
|
.action(async () => {
|
||||||
|
await check();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 解析命令行参数
|
||||||
|
program.parse(process.argv);
|
||||||
|
|
||||||
|
// 如果没有任何命令,显示帮助信息
|
||||||
|
if (!process.argv.slice(2).length) {
|
||||||
|
program.outputHelp();
|
||||||
|
}
|
||||||
4
core/src/config/config.default.ts
Normal file
4
core/src/config/config.default.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export const customKey = {
|
||||||
|
a: 1,
|
||||||
|
b: 'hello',
|
||||||
|
};
|
||||||
16
core/src/configuration.ts
Normal file
16
core/src/configuration.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Configuration } from '@midwayjs/core';
|
||||||
|
import * as DefaultConfig from './config/config.default';
|
||||||
|
|
||||||
|
@Configuration({
|
||||||
|
namespace: 'cool',
|
||||||
|
importConfigs: [
|
||||||
|
{
|
||||||
|
default: DefaultConfig,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class BookConfiguration {
|
||||||
|
async onReady() {
|
||||||
|
// TODO something
|
||||||
|
}
|
||||||
|
}
|
||||||
2
core/src/index.ts
Normal file
2
core/src/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export { BookConfiguration as Configuration } from './configuration';
|
||||||
|
export * from './service/book.service';
|
||||||
8
core/src/service/book.service.ts
Normal file
8
core/src/service/book.service.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Provide } from '@midwayjs/core';
|
||||||
|
|
||||||
|
@Provide()
|
||||||
|
export class BookService {
|
||||||
|
async getBookById() {
|
||||||
|
return 'hello world';
|
||||||
|
}
|
||||||
|
}
|
||||||
14
core/test/index.test.ts
Normal file
14
core/test/index.test.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { createLightApp } from '@midwayjs/mock';
|
||||||
|
import * as custom from '../src';
|
||||||
|
|
||||||
|
describe('/test/index.test.ts', () => {
|
||||||
|
it('test component', async () => {
|
||||||
|
const app = await createLightApp('', {
|
||||||
|
imports: [
|
||||||
|
custom
|
||||||
|
]
|
||||||
|
});
|
||||||
|
const bookService = await app.getApplicationContext().getAsync(custom.BookService);
|
||||||
|
expect(await bookService.getBookById()).toEqual('hello world');
|
||||||
|
});
|
||||||
|
});
|
||||||
28
core/tsconfig.json
Normal file
28
core/tsconfig.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"compileOnSave": true,
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2018",
|
||||||
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"inlineSourceMap":false,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"stripInternal": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noImplicitReturns": false,
|
||||||
|
"pretty": true,
|
||||||
|
"declaration": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": "src"
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"*.js",
|
||||||
|
"*.ts",
|
||||||
|
"dist",
|
||||||
|
"node_modules",
|
||||||
|
"test"
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user