Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin into antdv-next

This commit is contained in:
dap
2026-03-16 21:38:01 +08:00
73 changed files with 800 additions and 649 deletions

View File

@@ -1,7 +0,0 @@
import { defineBuildConfig } from 'unbuild';
export default defineBuildConfig({
clean: true,
declaration: true,
entries: ['src/index'],
});

View File

@@ -12,7 +12,7 @@
"license": "MIT",
"type": "module",
"scripts": {
"stub": "pnpm unbuild --stub"
"stub": "node ./scripts/build.mjs"
},
"files": [
"dist"
@@ -22,7 +22,7 @@
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./src/index.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
}

View File

@@ -0,0 +1,37 @@
import { spawnSync } from 'node:child_process';
const pnpmCommand =
process.env.npm_execpath &&
process.env.npm_execpath.endsWith('.cjs')
? [process.execPath, process.env.npm_execpath]
: ['pnpm'];
const steps = [
['exec', 'tsdown', '--no-dts'],
[
'exec',
'tsc',
'-p',
'tsconfig.build.json',
'--emitDeclarationOnly',
'--declaration',
'--outDir',
'dist',
],
];
for (const args of steps) {
const [command, ...commandArgs] = pnpmCommand;
const result = spawnSync(command, [...commandArgs, ...args], {
shell: true,
stdio: 'inherit',
});
if (result.error) {
throw result.error;
}
if (result.status !== 0) {
process.exit(result.status ?? 1);
}
}

View File

@@ -1,6 +1,6 @@
import dayjs from 'dayjs';
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone.js';
import utc from 'dayjs/plugin/utc.js';
dayjs.extend(utc);
dayjs.extend(timezone);

View File

@@ -1,21 +1,31 @@
import { dirname } from 'node:path';
import type { Package } from '@manypkg/get-packages';
import {
getPackages as getPackagesFunc,
getPackagesSync as getPackagesSyncFunc,
} from '@manypkg/get-packages';
import { findUpSync } from 'find-up';
import { existsSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import * as manypkg from '@manypkg/get-packages';
const { getPackages: getPackagesFunc, getPackagesSync: getPackagesSyncFunc } =
manypkg;
/**
* 查找大仓的根目录
* @param cwd
*/
function findMonorepoRoot(cwd: string = process.cwd()) {
const lockFile = findUpSync('pnpm-lock.yaml', {
cwd,
type: 'file',
});
return dirname(lockFile || '');
let currentDir = resolve(cwd);
while (true) {
if (existsSync(join(currentDir, 'pnpm-lock.yaml'))) {
return currentDir;
}
const parentDir = dirname(currentDir);
if (parentDir === currentDir) {
return '';
}
currentDir = parentDir;
}
}
/**
@@ -40,7 +50,7 @@ async function getPackages() {
*/
async function getPackage(pkgName: string) {
const { packages } = await getPackages();
return packages.find((pkg) => pkg.packageJson.name === pkgName);
return packages.find((pkg: Package) => pkg.packageJson.name === pkgName);
}
export { findMonorepoRoot, getPackage, getPackages, getPackagesSync };

View File

@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false
},
"exclude": ["node_modules", "src/__tests__"]
}

View File

@@ -0,0 +1,10 @@
import { defineConfig } from 'tsdown';
export default defineConfig({
clean: false,
deps: {
skipNodeModulesBundle: true,
},
entry: ['src/index.ts'],
format: ['esm'],
});