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'; import { toUnixPath } from './utils';
/** /**
* npm
* @example * @example
* 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 app/client plugins/acl core/* => ['app/client', 'plugins/acl', ...all core dir's packages]
* yarn build => all packages * yarn build => all packages
*/ */
function getPackagesPath(pkgs: string[]) { function getPackagesPath(pkgs: string[]) {
if (pkgs.length === 0) { const allPackageJson = fg
return fg
.sync(['*/*/package.json', '*/*/*/package.json'], { .sync(['*/*/package.json', '*/*/*/package.json'], {
cwd: PACKAGES_PATH, cwd: PACKAGES_PATH,
absolute: true, absolute: true,
onlyFiles: true, onlyFiles: true,
}) });
.map(toUnixPath).map(item => path.dirname(item))
if (pkgs.length === 0) {
return allPackageJson
.map(toUnixPath).map(item => path.dirname(item));
} }
return fg
.sync(pkgs, { const allPackageInfo = allPackageJson
cwd: PACKAGES_PATH, .map(packageJsonPath => ({ name: require(packageJsonPath).name, path: path.dirname(toUnixPath(packageJsonPath)) }))
absolute: true, .reduce((acc, cur) => {
onlyDirectories: true, acc[cur.name] = cur.path;
}) return acc;
.map(toUnixPath); }, {});
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[]) { export function getPackages(pkgs: string[]) {

View File

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

View File

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

View File

@ -570,7 +570,7 @@ export class PluginManager {
if (model) { if (model) {
opts['name'] = model.name; opts['name'] = model.name;
} }
if (!opts['name']) { if (!opts['packageName']) {
opts['packageName'] = urlOrName; opts['packageName'] = urlOrName;
} }
await this.add(opts['name'] || urlOrName, opts, true); await this.add(opts['name'] || urlOrName, opts, true);