优化
This commit is contained in:
17
apps/cli/templates/server-plugin-full/{{id}}/.ministarrc.js
Normal file
17
apps/cli/templates/server-plugin-full/{{id}}/.ministarrc.js
Normal 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,
|
||||
};
|
||||
@@ -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;
|
||||
20
apps/cli/templates/server-plugin-full/{{id}}/package.json
Normal file
20
apps/cli/templates/server-plugin-full/{{id}}/package.json
Normal 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": "*"
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"label": "{{name}}",
|
||||
"name": "{{id}}",
|
||||
"url": "{BACKEND}/plugins/{{id}}/index.js",
|
||||
"version": "0.0.0",
|
||||
"author": "{{author}}",
|
||||
"description": "{{desc}}",
|
||||
"requireRestart": true
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
const PLUGIN_ID = '{{id}}';
|
||||
const PLUGIN_NAME = '{{name}}';
|
||||
|
||||
console.log(`Plugin ${PLUGIN_NAME}(${PLUGIN_ID}) is loaded`);
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"jsx": "react",
|
||||
"importsNotUsedAsValues": "error"
|
||||
}
|
||||
}
|
||||
2
apps/cli/templates/server-plugin-full/{{id}}/web/plugins/{{id}}/types/tailchat.d.ts
vendored
Normal file
2
apps/cli/templates/server-plugin-full/{{id}}/web/plugins/{{id}}/types/tailchat.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare module '@capital/common';
|
||||
declare module '@capital/component';
|
||||
Reference in New Issue
Block a user