This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
{
"label": "{{name}}",
"name": "{{id}}",
"url": "/plugins/{{id}}/index.js",
"version": "0.0.0",
"author": "{{author}}",
"description": "{{desc}}",
"requireRestart": true
}

View File

@@ -0,0 +1,16 @@
{
"name": "@plugins/{{id}}",
"main": "src/index.tsx",
"version": "0.0.0",
"description": "{{desc}}",
"private": true,
"scripts": {
"sync:declaration": "tailchat declaration github"
},
"dependencies": {},
"devDependencies": {
"@types/styled-components": "^5.1.26",
"react": "18.2.0",
"styled-components": "^5.3.6"
}
}

View File

@@ -0,0 +1,4 @@
const PLUGIN_ID = '{{id}}';
const PLUGIN_NAME = '{{name}}';
console.log(`Plugin ${PLUGIN_NAME}(${PLUGIN_ID}) is loaded`);

View File

@@ -0,0 +1,8 @@
import { localTrans } from '@capital/common';
export const Translate = {
name: localTrans({
'zh-CN': '{{name}}',
'en-US': '{{name}}',
}),
};

View File

@@ -0,0 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"importsNotUsedAsValues": "error"
}
}

View File

@@ -0,0 +1,2 @@
declare module '@capital/common';
declare module '@capital/component';

View File

@@ -0,0 +1,132 @@
const path = require('path');
const _ = require('lodash')
function pickPluginName(text) {
const [_1, _2, ...others] = text.split('.');
return others.join('-');
}
function upperFirst(text) {
return _.upperFirst(_.camelCase(text));
}
module.exports = function (
/** @type {import('plop').NodePlopAPI} */
plop
) {
plop.setHelper('pickPluginName', pickPluginName);
plop.setHelper('pickPluginNameUp', (text) => {
return upperFirst(pickPluginName(text));
});
const namePrompts = [
{
type: 'input',
name: 'name',
require: true,
message: 'Plugin Name',
}
]
const serverPrompts = [
{
type: 'input',
name: 'id',
require: true,
default: 'com.msgbyte.example',
message: 'Plugin unique id, a unique string in reverse domain name format',
},
{
type: 'input',
name: 'author',
message: 'Plugin Author',
default: 'anonymous',
},
{
type: 'input',
name: 'desc',
message: 'Plugin description',
default: '',
},
];
// 服务端插件的前端模板代码
plop.setGenerator('client-plugin', {
description: 'Pure frontend plugin template',
prompts: [
...namePrompts,
...serverPrompts,
],
actions: [
{
type: 'addMany',
destination: path.resolve(process.cwd(), './plugins'),
base: './client-plugin',
templateFiles: [
'./client-plugin/**/*',
],
skipIfExists: true,
globOptions: {},
},
],
});
// 服务端插件的前端模板代码
plop.setGenerator('server-plugin', {
description: 'Pure backtend plugin template',
prompts: serverPrompts,
actions: [
{
type: 'addMany',
destination: path.resolve(process.cwd(), './plugins'),
base: './server-plugin',
templateFiles: ['./server-plugin/**/*'],
skipIfExists: true,
globOptions: {},
},
],
});
// 服务端插件的前端模板代码
plop.setGenerator('server-plugin-web', {
description: 'web plugin in backtend plugin template',
prompts: [
...namePrompts,
...serverPrompts,
],
actions: [
{
type: 'addMany',
destination: path.resolve(process.cwd(), './plugins'),
base: './server-plugin-web',
templateFiles: [
'./server-plugin-web/**/*',
'./server-plugin-web/*/.ministarrc.js',
],
skipIfExists: true,
globOptions: {},
},
],
});
// 服务端插件的前端模板代码
plop.setGenerator('server-plugin-full', {
description: 'Full backend plugin template',
prompts: [
...namePrompts,
...serverPrompts,
],
actions: [
{
type: 'addMany',
destination: path.resolve(process.cwd(), './plugins'),
base: './server-plugin-full',
templateFiles: [
'./server-plugin-full/**/*',
'./server-plugin-full/*/.ministarrc.js',
],
skipIfExists: true,
globOptions: {},
},
],
});
};

View File

@@ -0,0 +1,17 @@
const path = require('path');
const pluginRoot = path.resolve(__dirname, './web');
const outDir = path.resolve(__dirname, '../../public');
module.exports = {
externalDeps: [
'react',
'react-router',
'axios',
'styled-components',
'zustand',
'zustand/middleware/immer'
],
pluginRoot,
outDir,
};

View File

@@ -0,0 +1,20 @@
import { db } from 'tailchat-server-sdk';
const { getModelForClass, prop, modelOptions, TimeStamps } = db;
@modelOptions({
options: {
customName: 'p_{{pickPluginName id}}',
},
})
export class {{pickPluginNameUp id}} extends TimeStamps implements db.Base {
_id: db.Types.ObjectId;
id: string;
}
export type {{pickPluginNameUp id}}Document = db.DocumentType<{{pickPluginNameUp id}}>;
const model = getModelForClass({{pickPluginNameUp id}});
export type {{pickPluginNameUp id}}Model = typeof model;
export default model;

View File

@@ -0,0 +1,20 @@
{
"name": "tailchat-plugin-{{pickPluginName id}}",
"version": "1.0.0",
"main": "index.js",
"author": "{{author}}",
"description": "{{desc}}",
"license": "MIT",
"private": true,
"scripts": {
"build:web": "ministar buildPlugin all",
"build:web:watch": "ministar watchPlugin all"
},
"devDependencies": {
"@types/react": "18.0.20",
"mini-star": "*"
},
"dependencies": {
"tailchat-server-sdk": "*"
}
}

View File

@@ -0,0 +1,22 @@
import { TcService, TcDbService } from 'tailchat-server-sdk';
import type { {{pickPluginNameUp id}}Document, {{pickPluginNameUp id}}Model } from '../models/{{pickPluginName id}}';
/**
* {{name}}
*
* {{desc}}
*/
interface {{pickPluginNameUp id}}Service
extends TcService,
TcDbService<{{pickPluginNameUp id}}Document, {{pickPluginNameUp id}}Model> {}
class {{pickPluginNameUp id}}Service extends TcService {
get serviceName() {
return 'plugin:{{id}}';
}
onInit() {
this.registerLocalDb(require('../models/{{pickPluginName id}}').default);
}
}
export default {{pickPluginNameUp id}}Service;

View File

@@ -0,0 +1,9 @@
{
"label": "{{name}}",
"name": "{{id}}",
"url": "{BACKEND}/plugins/{{id}}/index.js",
"version": "0.0.0",
"author": "{{author}}",
"description": "{{desc}}",
"requireRestart": true
}

View File

@@ -0,0 +1,16 @@
{
"name": "@plugins/{{id}}",
"main": "src/index.tsx",
"version": "0.0.0",
"description": "{{desc}}",
"private": true,
"scripts": {
"sync:declaration": "tailchat declaration github"
},
"dependencies": {},
"devDependencies": {
"@types/styled-components": "^5.1.26",
"react": "18.2.0",
"styled-components": "^5.3.6"
}
}

View File

@@ -0,0 +1,4 @@
const PLUGIN_ID = '{{id}}';
const PLUGIN_NAME = '{{name}}';
console.log(`Plugin ${PLUGIN_NAME}(${PLUGIN_ID}) is loaded`);

View File

@@ -0,0 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"importsNotUsedAsValues": "error"
}
}

View File

@@ -0,0 +1,2 @@
declare module '@capital/common';
declare module '@capital/component';

View File

@@ -0,0 +1,17 @@
const path = require('path');
const pluginRoot = path.resolve(__dirname, './web');
const outDir = path.resolve(__dirname, '../../public');
module.exports = {
externalDeps: [
'react',
'react-router',
'axios',
'styled-components',
'zustand',
'zustand/middleware/immer'
],
pluginRoot,
outDir,
};

View File

@@ -0,0 +1,9 @@
{
"label": "{{name}}",
"name": "{{id}}",
"url": "{BACKEND}/plugins/{{id}}/index.js",
"version": "0.0.0",
"author": "{{author}}",
"description": "{{desc}}",
"requireRestart": true
}

View File

@@ -0,0 +1,16 @@
{
"name": "@plugins/{{id}}",
"main": "src/index.tsx",
"version": "0.0.0",
"description": "{{desc}}",
"private": true,
"scripts": {
"sync:declaration": "tailchat declaration github"
},
"dependencies": {},
"devDependencies": {
"@types/styled-components": "^5.1.26",
"react": "18.2.0",
"styled-components": "^5.3.6"
}
}

View File

@@ -0,0 +1,4 @@
const PLUGIN_ID = '{{id}}';
const PLUGIN_NAME = '{{name}}';
console.log(`Plugin ${PLUGIN_NAME}(${PLUGIN_ID}) is loaded`);

View File

@@ -0,0 +1,8 @@
import { localTrans } from '@capital/common';
export const Translate = {
name: localTrans({
'zh-CN': '{{name}}',
'en-US': '{{name}}',
}),
};

View File

@@ -0,0 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"importsNotUsedAsValues": "error"
}
}

View File

@@ -0,0 +1,2 @@
declare module '@capital/common';
declare module '@capital/component';

View File

@@ -0,0 +1,20 @@
import { db } from 'tailchat-server-sdk';
const { getModelForClass, prop, modelOptions, TimeStamps } = db;
@modelOptions({
options: {
customName: 'p_{{pickPluginName id}}',
},
})
export class {{pickPluginNameUp id}} extends TimeStamps implements db.Base {
_id: db.Types.ObjectId;
id: string;
}
export type {{pickPluginNameUp id}}Document = db.DocumentType<{{pickPluginNameUp id}}>;
const model = getModelForClass({{pickPluginNameUp id}});
export type {{pickPluginNameUp id}}Model = typeof model;
export default model;

View File

@@ -0,0 +1,14 @@
{
"name": "tailchat-plugin-{{pickPluginName id}}",
"version": "1.0.0",
"main": "index.js",
"author": "{{author}}",
"description": "{{desc}}",
"license": "MIT",
"private": true,
"scripts": {},
"devDependencies": {},
"dependencies": {
"tailchat-server-sdk": "*"
}
}

View File

@@ -0,0 +1,20 @@
import { TcService, TcDbService } from 'tailchat-server-sdk';
import type { {{pickPluginNameUp id}}Document, {{pickPluginNameUp id}}Model } from '../models/{{pickPluginName id}}';
/**
* {{desc}}
*/
interface {{pickPluginNameUp id}}Service
extends TcService,
TcDbService<{{pickPluginNameUp id}}Document, {{pickPluginNameUp id}}Model> {}
class {{pickPluginNameUp id}}Service extends TcService {
get serviceName() {
return 'plugin:{{id}}';
}
onInit() {
this.registerLocalDb(require('../models/{{pickPluginName id}}').default);
}
}
export default {{pickPluginNameUp id}}Service;