fix: some bugs
This commit is contained in:
parent
47b857d80a
commit
50286e2c3c
@ -37,7 +37,7 @@ class PluginGenerator extends Generator {
|
||||
const packageVersion = await getProjectVersion();
|
||||
return {
|
||||
...this.context,
|
||||
packageName: `@${packageName}/${name}`,
|
||||
packageName: `@${packageName}/plugin-${name}`,
|
||||
packageVersion: packageVersion,
|
||||
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');
|
||||
if (existsSync(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 = {
|
||||
async create() {
|
||||
const name = plugins[0];
|
||||
const { run } = require('@nocobase/cli/src/util');
|
||||
const { PluginGenerator } = require('@nocobase/cli/src/plugin-generator');
|
||||
const generator = new PluginGenerator({
|
||||
cwd: resolve(process.cwd(), name),
|
||||
@ -28,14 +29,33 @@ export default (app: Application) => {
|
||||
},
|
||||
});
|
||||
await generator.run();
|
||||
await run('yarn', ['install']);
|
||||
},
|
||||
async add() {
|
||||
if (started) {
|
||||
const res = await axios.get(`${baseURL}pm:add/${plugins.join(',')}`);
|
||||
console.log(res.data);
|
||||
return;
|
||||
}
|
||||
await app.pm.add(plugins);
|
||||
try {
|
||||
if (started) {
|
||||
const res = await axios.get(`${baseURL}pm:add/${plugins.join(',')}`);
|
||||
console.log(res.data);
|
||||
return;
|
||||
}
|
||||
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() {
|
||||
if (started) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
"@nocobase/app-*": [
|
||||
"packages/app/*/src"
|
||||
],
|
||||
"@nocobase/plugin-*-sample": [
|
||||
"@nocobase/plugin-sample-*": [
|
||||
"packages/samples/*/src"
|
||||
],
|
||||
"@nocobase/plugin-*": [
|
||||
|
Loading…
Reference in New Issue
Block a user