fix(pm): create plugin bug (#3117)
* fix: build bug * fix: app template package.json add workspaces * fix: plugin manager packageName * fix: remove template tsconfig paths
This commit is contained in:
parent
cb22d0f2ed
commit
d973ed8dba
@ -7,28 +7,37 @@ import { Package } from '@lerna/package';
|
||||
import { toUnixPath } from './utils';
|
||||
|
||||
/**
|
||||
* 获取构建包的绝对路径,支持项目路径和 npm 两种形式
|
||||
* @example
|
||||
* yarn build app/client,plugins/acl,core/* => ['app/client', 'plugins/acl', ...all core dir's packages]
|
||||
* yarn build app/client plugins/acl core/* => ['app/client', 'plugins/acl', ...all core dir's packages]
|
||||
* yarn build packages/core/client @nocobase/acl => ['/home/xx/packages/core/client', '/home/xx/packages/core/acl']
|
||||
* yarn build => all packages
|
||||
*/
|
||||
function getPackagesPath(pkgs: string[]) {
|
||||
if (pkgs.length === 0) {
|
||||
return fg
|
||||
.sync(['*/*/package.json', '*/*/*/package.json'], {
|
||||
cwd: PACKAGES_PATH,
|
||||
absolute: true,
|
||||
onlyFiles: true,
|
||||
})
|
||||
.map(toUnixPath).map(item => path.dirname(item))
|
||||
}
|
||||
return fg
|
||||
.sync(pkgs, {
|
||||
const allPackageJson = fg
|
||||
.sync(['*/*/package.json', '*/*/*/package.json'], {
|
||||
cwd: PACKAGES_PATH,
|
||||
absolute: true,
|
||||
onlyDirectories: true,
|
||||
})
|
||||
.map(toUnixPath);
|
||||
onlyFiles: true,
|
||||
});
|
||||
|
||||
if (pkgs.length === 0) {
|
||||
return allPackageJson
|
||||
.map(toUnixPath).map(item => path.dirname(item));
|
||||
}
|
||||
|
||||
const allPackageInfo = allPackageJson
|
||||
.map(packageJsonPath => ({ name: require(packageJsonPath).name, path: path.dirname(toUnixPath(packageJsonPath)) }))
|
||||
.reduce((acc, cur) => {
|
||||
acc[cur.name] = cur.path;
|
||||
return acc;
|
||||
}, {});
|
||||
const allPackagePaths: string[] = Object.values(allPackageInfo);
|
||||
|
||||
const pkgNames = pkgs.filter(item => allPackageInfo[item]);
|
||||
const relativePaths = pkgNames.length ? pkgs.filter(item => !pkgNames.includes(item)) : pkgs;
|
||||
const pkgPaths = pkgs.map(item => allPackageInfo[item])
|
||||
const absPaths = allPackagePaths.filter(absPath => relativePaths.some((relativePath) => absPath.endsWith(relativePath)));
|
||||
return [...pkgPaths, ...absPaths];
|
||||
}
|
||||
|
||||
export function getPackages(pkgs: string[]) {
|
||||
|
@ -2,7 +2,8 @@
|
||||
"name": "{{{name}}}",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"packages/*/*"
|
||||
"packages/*/*",
|
||||
"packages/*/*/*"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
|
@ -16,14 +16,6 @@
|
||||
"declaration": true,
|
||||
"experimentalDecorators": true,
|
||||
"downlevelIteration": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@{{{name}}}/app-*": [
|
||||
"packages/app/*/src"
|
||||
],
|
||||
"@{{{name}}}/plugin-*": [
|
||||
"packages/plugins/plugin-*/src"
|
||||
]
|
||||
}
|
||||
"baseUrl": "."
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ export class PluginManager {
|
||||
if (model) {
|
||||
opts['name'] = model.name;
|
||||
}
|
||||
if (!opts['name']) {
|
||||
if (!opts['packageName']) {
|
||||
opts['packageName'] = urlOrName;
|
||||
}
|
||||
await this.add(opts['name'] || urlOrName, opts, true);
|
||||
|
Loading…
Reference in New Issue
Block a user