mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-04 14:41:14 +00:00
Update napcat-types usage and config in plugin
Changed napcat-plugin-builtin to use workspace reference for napcat-types instead of a fixed version. Updated tsconfig to use bundler module resolution and improved Vite config plugin resolution. Enhanced napcat-types package.json exports for better type support.
This commit is contained in:
parent
28c9761e3d
commit
a60d8d109c
@ -6,7 +6,7 @@
|
||||
"description": "NapCat 内置插件",
|
||||
"author": "NapNeko",
|
||||
"dependencies": {
|
||||
"napcat-types": "0.0.2"
|
||||
"napcat-types": "0.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.1"
|
||||
|
||||
@ -68,14 +68,7 @@ export default defineConfig({
|
||||
entry: 'index.ts',
|
||||
formats: ['es'],
|
||||
fileName: () => 'index.mjs',
|
||||
},
|
||||
rollupOptions: {
|
||||
external: (id) => {
|
||||
if (nodeModules.includes(id)) return true;
|
||||
if (id.startsWith('napcat-')) return true;
|
||||
return false;
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
plugins: [nodeResolve(), copyToShellPlugin()],
|
||||
});
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
"dist/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.json && tsc-alias --project tsconfig.json --outDir dist && node ./scripts/copy-dist.mjs",
|
||||
"build": "tsc --project tsconfig.json && tsc-alias --project tsconfig.json --outDir dist && node ./scripts/post-build.mjs && node ./scripts/copy-dist.mjs",
|
||||
"test": "pnpm -s exec tsc --project tsconfig.json --noEmit",
|
||||
"publish": "cd dist && npm publish"
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "napcat-types",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"types": "./napcat-types/index.d.ts",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// 复制 cp README.md dist/ && cp package.public.json dist/package.json
|
||||
// 复制 cp README.md dist/ && cp package.public.json dist/package.json && cp external-shims.d.ts dist/
|
||||
import { copyFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
@ -10,4 +10,8 @@ await copyFile(
|
||||
await copyFile(
|
||||
join(__dirname, 'README.md'),
|
||||
join(__dirname, 'dist', 'README.md')
|
||||
);
|
||||
await copyFile(
|
||||
join(__dirname, 'external-shims.d.ts'),
|
||||
join(__dirname, 'dist', 'external-shims.d.ts')
|
||||
);
|
||||
41
packages/napcat-types/scripts/post-build.mjs
Normal file
41
packages/napcat-types/scripts/post-build.mjs
Normal file
@ -0,0 +1,41 @@
|
||||
import { readdir, readFile, writeFile, rename } from 'node:fs/promises';
|
||||
import { join, extname, basename } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = fileURLToPath(new URL('../', import.meta.url));
|
||||
const distDir = join(__dirname, 'dist');
|
||||
|
||||
async function traverseDirectory (dir) {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = join(dir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await traverseDirectory(fullPath);
|
||||
} else if (entry.isFile() && entry.name.endsWith('.d.ts')) {
|
||||
await processFile(fullPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function processFile (filePath) {
|
||||
// Read file content
|
||||
let content = await readFile(filePath, 'utf-8');
|
||||
|
||||
// Replace "export declare enum" with "export enum"
|
||||
content = content.replace(/export declare enum/g, 'export enum');
|
||||
|
||||
// Write back the modified content
|
||||
await writeFile(filePath, content, 'utf-8');
|
||||
|
||||
// Rename .d.ts to .ts
|
||||
const newPath = filePath.replace(/\.d\.ts$/, '.ts');
|
||||
await rename(filePath, newPath);
|
||||
|
||||
console.log(`Processed: ${basename(filePath)} -> ${basename(newPath)}`);
|
||||
}
|
||||
|
||||
console.log('Starting post-build processing...');
|
||||
await traverseDirectory(distDir);
|
||||
console.log('Post-build processing completed!');
|
||||
@ -223,8 +223,8 @@ importers:
|
||||
packages/napcat-plugin-builtin:
|
||||
dependencies:
|
||||
napcat-types:
|
||||
specifier: 0.0.2
|
||||
version: 0.0.2
|
||||
specifier: 0.0.3
|
||||
version: 0.0.3
|
||||
devDependencies:
|
||||
'@types/node':
|
||||
specifier: ^22.0.1
|
||||
@ -5445,8 +5445,8 @@ packages:
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
napcat-types@0.0.2:
|
||||
resolution: {integrity: sha512-CXcuUbK8/iGTf9qeG8juCOQjVzgmudjdQi6stlxTMLv7TzYIpeAg7TAOtAdlpvL+tnFieZ2H1AYrecdlB9l68A==}
|
||||
napcat-types@0.0.3:
|
||||
resolution: {integrity: sha512-YZVBvtIw7N2TRck+JcVAoZJRqcoKf9PbKhHggZ/EcQzTkqGLgu8iIgMfQnCYscgXRglYBPexpb78piaEwlVcjQ==}
|
||||
|
||||
napcat.protobuf@1.1.4:
|
||||
resolution: {integrity: sha512-z7XtLSBJ/PxmYb0VD/w+eYr/X3LyGz+SZ2QejFTOczwt6zWNxy2yV1mTMTvJoc3BWkI3ESVFRxkuT6+pj1tb1Q==}
|
||||
@ -12816,7 +12816,7 @@ snapshots:
|
||||
|
||||
nanoid@3.3.11: {}
|
||||
|
||||
napcat-types@0.0.2:
|
||||
napcat-types@0.0.3:
|
||||
dependencies:
|
||||
'@types/cors': 2.8.19
|
||||
'@types/express': 4.17.25
|
||||
|
||||
Loading…
Reference in New Issue
Block a user