add service module
This commit is contained in:
parent
8caac6f37a
commit
3c689c1cba
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,6 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
*storybook.log
|
*storybook.log
|
||||||
storybook-static
|
storybook-static
|
||||||
|
|
||||||
|
dist
|
@ -1,15 +1,12 @@
|
|||||||
type JSXElement = {
|
export function createDOMElement(jsxElement: JSX.Element) {
|
||||||
type: string | symbol;
|
|
||||||
props: Record<string, any>;
|
|
||||||
key?: string | number;
|
|
||||||
};
|
|
||||||
export function createDOMElement(jsxElement: JSXElement) {
|
|
||||||
// 如果 jsxElement 是 null, undefined 或者是布尔值,则直接跳过处理
|
// 如果 jsxElement 是 null, undefined 或者是布尔值,则直接跳过处理
|
||||||
if (jsxElement == null || typeof jsxElement === 'boolean') {
|
if (jsxElement == null || typeof jsxElement === 'boolean') {
|
||||||
console.warn('Invalid JSX element:', jsxElement);
|
console.warn('Invalid JSX element:', jsxElement);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { type, props } = jsxElement;
|
const { type, props } = jsxElement;
|
||||||
|
|
||||||
// React Fragment 的处理
|
// React Fragment 的处理
|
||||||
if (type === Symbol.for('react.fragment')) {
|
if (type === Symbol.for('react.fragment')) {
|
||||||
const fragment = document.createDocumentFragment();
|
const fragment = document.createDocumentFragment();
|
||||||
@ -31,8 +28,8 @@ export function createDOMElement(jsxElement: JSXElement) {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
const domElement = document.createElement(type as string);
|
const domElement = document.createElement(type);
|
||||||
|
if (!props) return domElement;
|
||||||
// 处理 props
|
// 处理 props
|
||||||
Object.keys(props).forEach((prop) => {
|
Object.keys(props).forEach((prop) => {
|
||||||
if (prop === 'children') {
|
if (prop === 'children') {
|
||||||
|
1855
pnpm-lock.yaml
generated
1855
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,4 @@
|
|||||||
packages:
|
packages:
|
||||||
- 'packages/*'
|
- 'packages/*'
|
||||||
- 'apps/*'
|
- 'apps/*'
|
||||||
|
- 'services/*'
|
46
services/apps-backend-store/package.json
Normal file
46
services/apps-backend-store/package.json
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"name": "apps-backend-store",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"watch": "rollup -c rollup.config.mjs -w",
|
||||||
|
"dev": "cross-env NODE_ENV=development nodemon --delay 2.5 -e js,cjs,mjs --exec node dist/app.mjs",
|
||||||
|
"test": "tsx test/**/*.ts",
|
||||||
|
"dev:watch": "concurrently -n \"Watch,Dev\" -c \"green,blue\" \"npm run watch\" \"sleep 1 && npm run dev\" ",
|
||||||
|
"build": "rimraf dist && rollup -c rollup.config.mjs",
|
||||||
|
"deploy": "envision switchOrg docs && envision publish . -k system-book",
|
||||||
|
"clean": "rm -rf dist"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "abearxiong <xiongxiao@xiongxiao.me>",
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "module",
|
||||||
|
"dependencies": {
|
||||||
|
"@abearxiong/auth": "1.0.2",
|
||||||
|
"@abearxiong/use-config": "^0.0.2",
|
||||||
|
"@kevisual/router": "0.0.4-alpha-8",
|
||||||
|
"nanoid": "^5.0.8",
|
||||||
|
"pg": "^8.13.1",
|
||||||
|
"sequelize": "^6.37.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
|
"@rollup/plugin-commonjs": "^28.0.1",
|
||||||
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
|
"@rollup/plugin-typescript": "^12.1.1",
|
||||||
|
"@types/node": "^22.9.0",
|
||||||
|
"concurrently": "^9.1.0",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
|
"glob": "^11.0.0",
|
||||||
|
"nodemon": "^3.1.7",
|
||||||
|
"rimraf": "^6.0.1",
|
||||||
|
"rollup": "^4.26.0",
|
||||||
|
"rollup-plugin-copy": "^3.5.0",
|
||||||
|
"rollup-plugin-dts": "^6.1.1",
|
||||||
|
"rollup-plugin-esbuild": "^6.1.1",
|
||||||
|
"rollup-plugin-inject": "^3.0.2",
|
||||||
|
"tslib": "^2.8.1"
|
||||||
|
}
|
||||||
|
}
|
66
services/apps-backend-store/rollup.config.mjs
Normal file
66
services/apps-backend-store/rollup.config.mjs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import typescript from '@rollup/plugin-typescript';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
// import copy from 'rollup-plugin-copy';
|
||||||
|
// import { dts } from 'rollup-plugin-dts';
|
||||||
|
import json from '@rollup/plugin-json';
|
||||||
|
import path from 'path';
|
||||||
|
import alias from '@rollup/plugin-alias';
|
||||||
|
import esbuild from 'rollup-plugin-esbuild'
|
||||||
|
// import replace from '@rollup/plugin-replace';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('rollup').RollupOptions}
|
||||||
|
*/
|
||||||
|
const config = {
|
||||||
|
input: './src/index.ts',
|
||||||
|
output: {
|
||||||
|
dir: './dist',
|
||||||
|
entryFileNames: 'app.mjs',
|
||||||
|
chunkFileNames: '[name]-[hash].mjs',
|
||||||
|
format: 'esm',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
alias({
|
||||||
|
// only esbuild needs to be configured
|
||||||
|
entries: [
|
||||||
|
{ find: '@', replacement: path.resolve('src') }, // 配置 @ 为 src 目录
|
||||||
|
{ find: 'http', replacement: 'node:http' },
|
||||||
|
{ find: 'https', replacement: 'node:https' },
|
||||||
|
{ find: 'fs', replacement: 'node:fs' },
|
||||||
|
{ find: 'path', replacement: 'node:path' },
|
||||||
|
{ find: 'crypto', replacement: 'node:crypto' },
|
||||||
|
{ find: 'zlib', replacement: 'node:zlib' },
|
||||||
|
{ find: 'stream', replacement: 'node:stream' },
|
||||||
|
{ find: 'net', replacement: 'node:net' },
|
||||||
|
{ find: 'tty', replacement: 'node:tty' },
|
||||||
|
{ find: 'tls', replacement: 'node:tls' },
|
||||||
|
{ find: 'buffer', replacement: 'node:buffer' },
|
||||||
|
{ find: 'timers', replacement: 'node:timers' },
|
||||||
|
// { find: 'string_decoder', replacement: 'node:string_decoder' },
|
||||||
|
{ find: 'dns', replacement: 'node:dns' },
|
||||||
|
{ find: 'domain', replacement: 'node:domain' },
|
||||||
|
{ find: 'os', replacement: 'node:os' },
|
||||||
|
{ find: 'events', replacement: 'node:events' },
|
||||||
|
{ find: 'url', replacement: 'node:url' },
|
||||||
|
{ find: 'assert', replacement: 'node:assert' },
|
||||||
|
{ find: 'util', replacement: 'node:util' },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
resolve({
|
||||||
|
preferBuiltins: true, // 强制优先使用内置模块
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
esbuild({
|
||||||
|
target: 'node22', // 目标为 Node.js 14
|
||||||
|
minify: false, // 启用代码压缩
|
||||||
|
tsconfig: 'tsconfig.json'
|
||||||
|
}),
|
||||||
|
// typescript({
|
||||||
|
// declaration: false,
|
||||||
|
// }),
|
||||||
|
json(),
|
||||||
|
],
|
||||||
|
external: ['sequelize', '@kevisual/router', 'ioredis', 'socket.io', 'minio', 'pm2'],
|
||||||
|
};
|
||||||
|
export default config;
|
16
services/apps-backend-store/src/index.ts
Normal file
16
services/apps-backend-store/src/index.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { App } from '@kevisual/router';
|
||||||
|
const app = new App();
|
||||||
|
|
||||||
|
app
|
||||||
|
.route({
|
||||||
|
path: 'apps-backend',
|
||||||
|
key: 'list',
|
||||||
|
})
|
||||||
|
.define(async (ctx) => {
|
||||||
|
ctx.body = ['apps-backend'];
|
||||||
|
})
|
||||||
|
.addTo(app);
|
||||||
|
|
||||||
|
app.listen(3007, () => {
|
||||||
|
console.log('pm2-manage is running on', `http://localhost:3007`);
|
||||||
|
});
|
36
services/apps-backend-store/tsconfig.json
Normal file
36
services/apps-backend-store/tsconfig.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "nodenext",
|
||||||
|
"target": "esnext",
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"sourceMap": false,
|
||||||
|
"allowJs": true,
|
||||||
|
"newLine": "LF",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types",
|
||||||
|
],
|
||||||
|
"declaration": true,
|
||||||
|
"noEmit": false,
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"emitDeclarationOnly": true,
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"src/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts",
|
||||||
|
"test/**/*.ts",
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
}
|
50
services/pm2-manage/package.json
Normal file
50
services/pm2-manage/package.json
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"name": "pm2-manage",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "pm2的服务",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"watch": "rollup -c rollup.config.mjs -w",
|
||||||
|
"dev": "cross-env NODE_ENV=development nodemon --delay 2.5 -e js,cjs,mjs --exec node dist/app.mjs",
|
||||||
|
"test": "tsx test/**/*.ts",
|
||||||
|
"dev:watch": "concurrently -n \"Watch,Dev\" -c \"green,blue\" \"npm run watch\" \"sleep 1 && npm run dev\" ",
|
||||||
|
"build": "rimraf dist && rollup -c rollup.config.mjs",
|
||||||
|
"deploy": "envision switchOrg docs && envision publish . -k system-book",
|
||||||
|
"clean": "rm -rf dist"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "abearxiong <xiongxiao@xiongxiao.me>",
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "module",
|
||||||
|
"app": {
|
||||||
|
"type": "service"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@abearxiong/auth": "1.0.2",
|
||||||
|
"@abearxiong/use-config": "^0.0.2",
|
||||||
|
"@kevisual/router": "0.0.4-alpha-8",
|
||||||
|
"nanoid": "^5.0.8",
|
||||||
|
"pg": "^8.13.1",
|
||||||
|
"sequelize": "^6.37.5",
|
||||||
|
"pm2": "^5.4.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-alias": "^5.1.1",
|
||||||
|
"@rollup/plugin-commonjs": "^28.0.1",
|
||||||
|
"@rollup/plugin-json": "^6.1.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||||
|
"@rollup/plugin-typescript": "^12.1.1",
|
||||||
|
"@types/node": "^22.9.0",
|
||||||
|
"concurrently": "^9.1.0",
|
||||||
|
"cross-env": "^7.0.3",
|
||||||
|
"glob": "^11.0.0",
|
||||||
|
"nodemon": "^3.1.7",
|
||||||
|
"rimraf": "^6.0.1",
|
||||||
|
"rollup": "^4.26.0",
|
||||||
|
"rollup-plugin-copy": "^3.5.0",
|
||||||
|
"rollup-plugin-dts": "^6.1.1",
|
||||||
|
"rollup-plugin-esbuild": "^6.1.1",
|
||||||
|
"rollup-plugin-inject": "^3.0.2",
|
||||||
|
"tslib": "^2.8.1"
|
||||||
|
}
|
||||||
|
}
|
66
services/pm2-manage/rollup.config.mjs
Normal file
66
services/pm2-manage/rollup.config.mjs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import typescript from '@rollup/plugin-typescript';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
// import copy from 'rollup-plugin-copy';
|
||||||
|
// import { dts } from 'rollup-plugin-dts';
|
||||||
|
import json from '@rollup/plugin-json';
|
||||||
|
import path from 'path';
|
||||||
|
import alias from '@rollup/plugin-alias';
|
||||||
|
import esbuild from 'rollup-plugin-esbuild'
|
||||||
|
// import replace from '@rollup/plugin-replace';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('rollup').RollupOptions}
|
||||||
|
*/
|
||||||
|
const config = {
|
||||||
|
input: './src/index.ts',
|
||||||
|
output: {
|
||||||
|
dir: './dist',
|
||||||
|
entryFileNames: 'app.mjs',
|
||||||
|
chunkFileNames: '[name]-[hash].mjs',
|
||||||
|
format: 'esm',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
alias({
|
||||||
|
// only esbuild needs to be configured
|
||||||
|
entries: [
|
||||||
|
{ find: '@', replacement: path.resolve('src') }, // 配置 @ 为 src 目录
|
||||||
|
{ find: 'http', replacement: 'node:http' },
|
||||||
|
{ find: 'https', replacement: 'node:https' },
|
||||||
|
{ find: 'fs', replacement: 'node:fs' },
|
||||||
|
{ find: 'path', replacement: 'node:path' },
|
||||||
|
{ find: 'crypto', replacement: 'node:crypto' },
|
||||||
|
{ find: 'zlib', replacement: 'node:zlib' },
|
||||||
|
{ find: 'stream', replacement: 'node:stream' },
|
||||||
|
{ find: 'net', replacement: 'node:net' },
|
||||||
|
{ find: 'tty', replacement: 'node:tty' },
|
||||||
|
{ find: 'tls', replacement: 'node:tls' },
|
||||||
|
{ find: 'buffer', replacement: 'node:buffer' },
|
||||||
|
{ find: 'timers', replacement: 'node:timers' },
|
||||||
|
// { find: 'string_decoder', replacement: 'node:string_decoder' },
|
||||||
|
{ find: 'dns', replacement: 'node:dns' },
|
||||||
|
{ find: 'domain', replacement: 'node:domain' },
|
||||||
|
{ find: 'os', replacement: 'node:os' },
|
||||||
|
{ find: 'events', replacement: 'node:events' },
|
||||||
|
{ find: 'url', replacement: 'node:url' },
|
||||||
|
{ find: 'assert', replacement: 'node:assert' },
|
||||||
|
{ find: 'util', replacement: 'node:util' },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
resolve({
|
||||||
|
preferBuiltins: true, // 强制优先使用内置模块
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
esbuild({
|
||||||
|
target: 'node22', // 目标为 Node.js 14
|
||||||
|
minify: false, // 启用代码压缩
|
||||||
|
tsconfig: 'tsconfig.json'
|
||||||
|
}),
|
||||||
|
// typescript({
|
||||||
|
// declaration: false,
|
||||||
|
// }),
|
||||||
|
json(),
|
||||||
|
],
|
||||||
|
external: ['sequelize', '@kevisual/router', 'ioredis', 'socket.io', 'minio', 'pm2'],
|
||||||
|
};
|
||||||
|
export default config;
|
33
services/pm2-manage/src/index.ts
Normal file
33
services/pm2-manage/src/index.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { App } from '@kevisual/router';
|
||||||
|
import pm2 from 'pm2';
|
||||||
|
const app = new App();
|
||||||
|
|
||||||
|
app
|
||||||
|
.route({
|
||||||
|
path: 'pm2',
|
||||||
|
key: 'list',
|
||||||
|
})
|
||||||
|
.define(async (ctx) => {
|
||||||
|
ctx.body = 'pm2 list';
|
||||||
|
const services = await new Promise((resolve, reject) => {
|
||||||
|
const connect = pm2.connect((err) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
pm2.list((err, list) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
resolve(list);
|
||||||
|
});
|
||||||
|
// resolve([{ name: 'test' }]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
console.log(services);
|
||||||
|
ctx.body = services;
|
||||||
|
})
|
||||||
|
.addTo(app);
|
||||||
|
|
||||||
|
app.listen(3006, () => {
|
||||||
|
console.log('pm2-manage is running on', `http://localhost:3006`);
|
||||||
|
});
|
36
services/pm2-manage/tsconfig.json
Normal file
36
services/pm2-manage/tsconfig.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "nodenext",
|
||||||
|
"target": "esnext",
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"sourceMap": false,
|
||||||
|
"allowJs": true,
|
||||||
|
"newLine": "LF",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types",
|
||||||
|
],
|
||||||
|
"declaration": true,
|
||||||
|
"noEmit": false,
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"emitDeclarationOnly": true,
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"src/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts",
|
||||||
|
"test/**/*.ts",
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user