fix: some bugs
This commit is contained in:
parent
47b857d80a
commit
50286e2c3c
@ -37,7 +37,7 @@ class PluginGenerator extends Generator {
|
|||||||
const packageVersion = await getProjectVersion();
|
const packageVersion = await getProjectVersion();
|
||||||
return {
|
return {
|
||||||
...this.context,
|
...this.context,
|
||||||
packageName: `@${packageName}/${name}`,
|
packageName: `@${packageName}/plugin-${name}`,
|
||||||
packageVersion: packageVersion,
|
packageVersion: packageVersion,
|
||||||
pascalCaseName: capitalize(camelize(name)),
|
pascalCaseName: capitalize(camelize(name)),
|
||||||
};
|
};
|
||||||
|
@ -1 +0,0 @@
|
|||||||
// TODO
|
|
5
packages/core/cli/templates/plugin/src/client/index.tsx
Normal file
5
packages/core/cli/templates/plugin/src/client/index.tsx
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export default React.memo((props) => {
|
||||||
|
return <>{props.children}</>;
|
||||||
|
});
|
@ -70,7 +70,7 @@ function resolveNocobasePackagesAlias(config) {
|
|||||||
const packageSrc = resolve(process.cwd(), './packages/samples/', package, 'src');
|
const packageSrc = resolve(process.cwd(), './packages/samples/', package, 'src');
|
||||||
if (existsSync(packageSrc)) {
|
if (existsSync(packageSrc)) {
|
||||||
config.module.rules.get('ts-in-node_modules').include.add(packageSrc);
|
config.module.rules.get('ts-in-node_modules').include.add(packageSrc);
|
||||||
config.resolve.alias.set(`@nocobase/plugin-${package}-sample`, packageSrc);
|
config.resolve.alias.set(`@nocobase/plugin-sample-${package}`, packageSrc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ export default (app: Application) => {
|
|||||||
const pm = {
|
const pm = {
|
||||||
async create() {
|
async create() {
|
||||||
const name = plugins[0];
|
const name = plugins[0];
|
||||||
|
const { run } = require('@nocobase/cli/src/util');
|
||||||
const { PluginGenerator } = require('@nocobase/cli/src/plugin-generator');
|
const { PluginGenerator } = require('@nocobase/cli/src/plugin-generator');
|
||||||
const generator = new PluginGenerator({
|
const generator = new PluginGenerator({
|
||||||
cwd: resolve(process.cwd(), name),
|
cwd: resolve(process.cwd(), name),
|
||||||
@ -28,14 +29,33 @@ export default (app: Application) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
await generator.run();
|
await generator.run();
|
||||||
|
await run('yarn', ['install']);
|
||||||
},
|
},
|
||||||
async add() {
|
async add() {
|
||||||
|
try {
|
||||||
if (started) {
|
if (started) {
|
||||||
const res = await axios.get(`${baseURL}pm:add/${plugins.join(',')}`);
|
const res = await axios.get(`${baseURL}pm:add/${plugins.join(',')}`);
|
||||||
console.log(res.data);
|
console.log(res.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await app.pm.add(plugins);
|
await app.pm.add(plugins);
|
||||||
|
} catch (error) {}
|
||||||
|
const fs = require('fs/promises');
|
||||||
|
await Promise.all(
|
||||||
|
plugins.map((plugin) => {
|
||||||
|
const file = resolve(
|
||||||
|
process.cwd(),
|
||||||
|
'packages',
|
||||||
|
process.env.APP_PACKAGE_ROOT || 'app',
|
||||||
|
'client/src/plugins',
|
||||||
|
`${plugin}.ts`,
|
||||||
|
);
|
||||||
|
console.log(file);
|
||||||
|
return fs.writeFile(file, `export { default } from '@nocobase/plugin-${plugin}/client';`);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const { run } = require('@nocobase/cli/src/util');
|
||||||
|
await run('yarn', ['nocobase', 'postinstall']);
|
||||||
},
|
},
|
||||||
async enable() {
|
async enable() {
|
||||||
if (started) {
|
if (started) {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
"@nocobase/app-*": [
|
"@nocobase/app-*": [
|
||||||
"packages/app/*/src"
|
"packages/app/*/src"
|
||||||
],
|
],
|
||||||
"@nocobase/plugin-*-sample": [
|
"@nocobase/plugin-sample-*": [
|
||||||
"packages/samples/*/src"
|
"packages/samples/*/src"
|
||||||
],
|
],
|
||||||
"@nocobase/plugin-*": [
|
"@nocobase/plugin-*": [
|
||||||
|
Loading…
Reference in New Issue
Block a user