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:
jack zhang 2023-11-30 12:41:15 +08:00 committed by GitHub
parent cb22d0f2ed
commit d973ed8dba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 27 deletions

View File

@ -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[]) {

View File

@ -2,7 +2,8 @@
"name": "{{{name}}}",
"private": true,
"workspaces": [
"packages/*/*"
"packages/*/*",
"packages/*/*/*"
],
"engines": {
"node": ">=18"

View File

@ -16,14 +16,6 @@
"declaration": true,
"experimentalDecorators": true,
"downlevelIteration": true,
"baseUrl": ".",
"paths": {
"@{{{name}}}/app-*": [
"packages/app/*/src"
],
"@{{{name}}}/plugin-*": [
"packages/plugins/plugin-*/src"
]
}
"baseUrl": "."
}
}

View File

@ -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);