fix: support pro plugins
This commit is contained in:
parent
8e182a6add
commit
def0f642d7
@ -12,6 +12,7 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"@nocobase/plugin-sample-*/client": ["../../samples/*/src/client"],
|
"@nocobase/plugin-sample-*/client": ["../../samples/*/src/client"],
|
||||||
|
"@nocobase/plugin-pro-*/client": ["../../pro-plugins/*/src/client"],
|
||||||
"@nocobase/plugin-*/client": ["../../plugins/*/src/client"],
|
"@nocobase/plugin-*/client": ["../../plugins/*/src/client"],
|
||||||
"@nocobase/utils/client": ["../../core/utils/src/client"],
|
"@nocobase/utils/client": ["../../core/utils/src/client"],
|
||||||
"@nocobase/*": ["../../core/*/src/"],
|
"@nocobase/*": ["../../core/*/src/"],
|
||||||
|
@ -73,6 +73,14 @@ function resolveNocobasePackagesAlias(config) {
|
|||||||
config.resolve.alias.set(`@nocobase/plugin-sample-${package}`, packageSrc);
|
config.resolve.alias.set(`@nocobase/plugin-sample-${package}`, packageSrc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const pros = fs.readdirSync(resolve(process.cwd(), './packages/pro-plugins'));
|
||||||
|
for (const package of pros) {
|
||||||
|
const packageSrc = resolve(process.cwd(), './packages/pro-plugins/', package, 'src');
|
||||||
|
if (existsSync(packageSrc)) {
|
||||||
|
config.module.rules.get('ts-in-node_modules').include.add(packageSrc);
|
||||||
|
config.resolve.alias.set(`@nocobase/plugin-pro-${package}`, packageSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getUmiConfig = getUmiConfig;
|
exports.getUmiConfig = getUmiConfig;
|
||||||
|
@ -194,8 +194,9 @@ export class PluginManager {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log(`adding ${plugin} plugin`);
|
console.log(`adding ${plugin} plugin`);
|
||||||
const packageName = await PluginManager.findPackage(plugin);
|
const packageName = await PluginManager.findPackage(plugin);
|
||||||
|
console.log(`adding ${packageName}`);
|
||||||
const packageJson = require(`${packageName}/package.json`);
|
const packageJson = require(`${packageName}/package.json`);
|
||||||
const instance = this.addStatic(plugin, {
|
const instance = this.addStatic(plugin, {
|
||||||
...options,
|
...options,
|
||||||
@ -317,7 +318,7 @@ export class PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getPackageName(name: string) {
|
static getPackageName(name: string) {
|
||||||
const prefixes = (process.env.PLUGIN_PACKAGE_PREFIX || '@nocobase/plugin-,@nocobase/preset-').split(',');
|
const prefixes = (process.env.PLUGIN_PACKAGE_PREFIX || '@nocobase/plugin-,@nocobase/preset-,@nocobase/plugin-pro-').split(',');
|
||||||
for (const prefix of prefixes) {
|
for (const prefix of prefixes) {
|
||||||
try {
|
try {
|
||||||
require.resolve(`${prefix}${name}`);
|
require.resolve(`${prefix}${name}`);
|
||||||
@ -334,7 +335,7 @@ export class PluginManager {
|
|||||||
const packageName = this.getPackageName(name);
|
const packageName = this.getPackageName(name);
|
||||||
return packageName;
|
return packageName;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const prefixes = (process.env.PLUGIN_PACKAGE_PREFIX || '@nocobase/plugin-,@nocobase/preset-').split(',');
|
const prefixes = (process.env.PLUGIN_PACKAGE_PREFIX || '@nocobase/plugin-,@nocobase/preset-,@nocobase/plugin-pro-').split(',');
|
||||||
for (const prefix of prefixes) {
|
for (const prefix of prefixes) {
|
||||||
try {
|
try {
|
||||||
const packageName = `${prefix}${name}`;
|
const packageName = `${prefix}${name}`;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Plugin } from '@nocobase/server';
|
import { Plugin, PluginManager } from '@nocobase/server';
|
||||||
import send from 'koa-send';
|
import send from 'koa-send';
|
||||||
import serve from 'koa-static';
|
import serve from 'koa-static';
|
||||||
import { isAbsolute, resolve } from 'path';
|
import { isAbsolute, resolve } from 'path';
|
||||||
@ -64,7 +64,8 @@ export class ClientPlugin extends Plugin {
|
|||||||
ctx.body = items
|
ctx.body = items
|
||||||
.filter((item) => {
|
.filter((item) => {
|
||||||
try {
|
try {
|
||||||
require.resolve(`@nocobase/plugin-${item.name}/client`);
|
const packageName = PluginManager.getPackageName(item.name);
|
||||||
|
require.resolve(`${packageName}/client`);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
return false;
|
return false;
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
"@nocobase/plugin-sample-*": [
|
"@nocobase/plugin-sample-*": [
|
||||||
"packages/samples/*/src"
|
"packages/samples/*/src"
|
||||||
],
|
],
|
||||||
|
"@nocobase/plugin-pro-*": [
|
||||||
|
"packages/pro-plugins/*/src"
|
||||||
|
],
|
||||||
"@nocobase/plugin-*": [
|
"@nocobase/plugin-*": [
|
||||||
"packages/plugins/*/src"
|
"packages/plugins/*/src"
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user