Migrate project to pnpm monorepo
Restructure the repository into a pnpm workspace under packages/ (core, webui, runtime). Move source files for core and webui into packages/*, add package manifests for @snowluma/core and @snowluma/runtime, and remove the old launcher package.json. Update root package.json to be a monorepo controller (scripts delegate to pnpm filters, set packageManager and Node engine). Configure build outputs to emit into the repo-root dist/ (vite config changes) so the existing release pipeline continues to work. Add .npmrc with mirrors, expand .gitignore for monorepo layout, add tsconfig base and package-level tsconfigs, and add vitest config for the core package. Adjust injector native search paths and update tests import paths to the new package layout. Small CI/workflow comment added to clarify build behavior and README updated with monorepo structure and common commands.
No files matched your search
@@ -40,6 +40,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Root scripts delegate to `moon run`; produces dist/ at repo root.
|
||||||
- name: Build project
|
- name: Build project
|
||||||
run: pnpm run ${{ matrix.script }}
|
run: pnpm run ${{ matrix.script }}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ _deps/
|
|||||||
|
|
||||||
# Runtime generated
|
# Runtime generated
|
||||||
config.json
|
config.json
|
||||||
/node_modules
|
|
||||||
/dist
|
# Node / pnpm / monorepo
|
||||||
/.vscode
|
node_modules/
|
||||||
|
**/node_modules/
|
||||||
|
dist/
|
||||||
|
**/dist/
|
||||||
|
.vscode/
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
registry=https://registry.npmmirror.com/
|
||||||
|
@moonrepo:registry=https://registry.npmmirror.com/
|
||||||
|
|
||||||
|
# Mirrors for binary downloads (sharp, esbuild, swc, electron etc.)
|
||||||
|
disturl=https://npmmirror.com/dist
|
||||||
|
electron_mirror=https://npmmirror.com/mirrors/electron/
|
||||||
|
sass_binary_site=https://npmmirror.com/mirrors/node-sass/
|
||||||
|
sharp_binary_host=https://npmmirror.com/mirrors/sharp
|
||||||
|
sharp_libvips_binary_host=https://npmmirror.com/mirrors/sharp-libvips
|
||||||
|
puppeteer_download_host=https://npmmirror.com/mirrors
|
||||||
|
|
||||||
|
auto-install-peers=true
|
||||||
|
strict-peer-dependencies=false
|
||||||
@@ -5,6 +5,59 @@
|
|||||||
## 关于项目
|
## 关于项目
|
||||||
项目处于开发初期,仅支持部分功能,持续高速迭代中,仅支持有头。
|
项目处于开发初期,仅支持部分功能,持续高速迭代中,仅支持有头。
|
||||||
|
|
||||||
|
## 仓库结构
|
||||||
|
|
||||||
|
本仓库使用 **pnpm workspace** 进行多包管理。
|
||||||
|
|
||||||
|
```
|
||||||
|
SnowLuma/
|
||||||
|
├─ packages/
|
||||||
|
│ ├─ core/ @snowluma/core - Node.js 运行时(NTQQ packet sniffer + Hook + OneBot)
|
||||||
|
│ ├─ webui/ webui - React + Vite 前端
|
||||||
|
│ └─ runtime/ @snowluma/runtime - 发行包资源
|
||||||
|
│ ├─ launcher.bat
|
||||||
|
│ ├─ package.json (随 dist 一起发布的运行时依赖清单)
|
||||||
|
│ └─ native/ 平台预编译产物 (snowluma-win32-x64.{dll,node})
|
||||||
|
├─ tools/ 辅助脚本(如 Python OneBot WS 测试)
|
||||||
|
├─ tsconfig.base.json
|
||||||
|
├─ tsconfig.json monorepo 根 TS 项目(仅含 references)
|
||||||
|
├─ pnpm-workspace.yaml
|
||||||
|
└─ package.json monorepo 根(脚本委托给 pnpm filter)
|
||||||
|
```
|
||||||
|
|
||||||
|
构建产物统一输出到仓库根 `dist/`,与发行流水线保持兼容。
|
||||||
|
|
||||||
|
## 常用命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 安装依赖
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# 开发 — 核心运行时(tsx)
|
||||||
|
pnpm dev
|
||||||
|
|
||||||
|
# 开发 — WebUI 前端(vite dev server)
|
||||||
|
pnpm dev:web
|
||||||
|
|
||||||
|
# 仅构建核心
|
||||||
|
pnpm build
|
||||||
|
|
||||||
|
# 仅构建 WebUI
|
||||||
|
pnpm build:webui
|
||||||
|
|
||||||
|
# 一次构建核心 + WebUI 完整发行版(顺序固定 core → webui)
|
||||||
|
pnpm build:all
|
||||||
|
|
||||||
|
# 单元测试 / 类型检查 / Lint
|
||||||
|
pnpm test
|
||||||
|
pnpm typecheck
|
||||||
|
pnpm lint
|
||||||
|
|
||||||
|
# 直接对单个包操作
|
||||||
|
pnpm --filter @snowluma/core dev
|
||||||
|
pnpm --filter webui build
|
||||||
|
```
|
||||||
|
|
||||||
## 鸣谢
|
## 鸣谢
|
||||||
[LagrangeV2](https://github.com/LagrangeDev/LagrangeV2) - Proto
|
[LagrangeV2](https://github.com/LagrangeDev/LagrangeV2) - Proto
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "snowluma",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"type": "module",
|
|
||||||
"main": "index.mjs",
|
|
||||||
"dependencies": {
|
|
||||||
"ws": "^8.20.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "snowluma",
|
"name": "snowluma-monorepo",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "SnowLuma - NTQQ packet sniffer with Node.js native addon",
|
"description": "SnowLuma monorepo workspace (pnpm)",
|
||||||
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.mjs",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"testtypes": "tsc --noEmit",
|
"build": "pnpm --filter @snowluma/core build",
|
||||||
"test": "vitest run",
|
|
||||||
"test:watch": "vitest",
|
|
||||||
"build": "vite build",
|
|
||||||
"build:webui": "pnpm --filter webui build",
|
"build:webui": "pnpm --filter webui build",
|
||||||
"build:all": "cross-env BUILD_WEBUI=true vite build && pnpm --filter webui build",
|
"build:all": "pnpm --filter @snowluma/core build:all && pnpm --filter webui build",
|
||||||
"dev": "pnpm --parallel run dev",
|
"dev": "pnpm --filter @snowluma/core dev",
|
||||||
"dev:core": "tsx src/index.ts",
|
|
||||||
"dev:web": "pnpm --filter webui dev",
|
"dev:web": "pnpm --filter webui dev",
|
||||||
|
"test": "pnpm --filter @snowluma/core test",
|
||||||
|
"test:watch": "pnpm --filter @snowluma/core test:watch",
|
||||||
|
"typecheck": "pnpm -r --if-present typecheck",
|
||||||
|
"lint": "pnpm -r --if-present lint",
|
||||||
"start": "node dist/index.mjs"
|
"start": "node dist/index.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"ws": "^8.20.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@hono/node-server": "^1.19.14",
|
"typescript": "catalog:"
|
||||||
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
||||||
"@types/node": "^24.12.2",
|
|
||||||
"@types/ws": "^8.18.1",
|
|
||||||
"cross-env": "^10.1.0",
|
|
||||||
"hono": "^4.12.14",
|
|
||||||
"tsx": "^4.21.0",
|
|
||||||
"typescript": "^6.0.2",
|
|
||||||
"vite": "catalog:",
|
|
||||||
"vite-plugin-cp": "^6.0.3",
|
|
||||||
"vitest": "^4.1.4"
|
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"peerDependencyRules": {
|
"peerDependencyRules": {
|
||||||
@@ -38,5 +25,9 @@
|
|||||||
"eslint-plugin-react-hooks>eslint": "10"
|
"eslint-plugin-react-hooks>eslint": "10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"packageManager": "[email protected]",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "@snowluma/core",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "SnowLuma core - NTQQ packet sniffer with Node.js native addon",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"main": "../../dist/index.mjs",
|
||||||
|
"scripts": {
|
||||||
|
"build": "vite build",
|
||||||
|
"build:all": "cross-env BUILD_WEBUI=true vite build",
|
||||||
|
"dev": "tsx src/index.ts",
|
||||||
|
"test": "vitest run",
|
||||||
|
"test:watch": "vitest",
|
||||||
|
"typecheck": "tsc --noEmit"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ws": "^8.20.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@hono/node-server": "^1.19.14",
|
||||||
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
||||||
|
"@types/node": "^24.12.2",
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
|
"cross-env": "^10.1.0",
|
||||||
|
"hono": "^4.12.14",
|
||||||
|
"tsx": "^4.21.0",
|
||||||
|
"typescript": "catalog:",
|
||||||
|
"vite": "catalog:",
|
||||||
|
"vite-plugin-cp": "^6.0.3",
|
||||||
|
"vitest": "^4.1.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,11 +43,16 @@ function platformBinaryName(ext: 'node' | 'dll'): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nativeSearchDirs(): string[] {
|
function nativeSearchDirs(): string[] {
|
||||||
|
// Several layouts must be supported:
|
||||||
|
// 1. Released zip (flattened dist/): __dirname=<extracted>/, native at <extracted>/native
|
||||||
|
// 2. Repo bundled build (dist/index.mjs): __dirname=<root>/dist, native at <root>/dist/native
|
||||||
|
// 3. Dev via tsx (packages/core/src/hook/injector.ts): __dirname=<root>/packages/core/src/hook
|
||||||
|
// → walk up to <root>/packages and append runtime/native
|
||||||
return [
|
return [
|
||||||
path.resolve(__dirname, '..', '..', 'native'),
|
path.resolve(__dirname, 'native'),
|
||||||
path.resolve(__dirname, '..', 'native'),
|
path.resolve(__dirname, '..', '..', '..', 'runtime', 'native'),
|
||||||
path.resolve(process.cwd(), 'dist', 'native'),
|
path.resolve(process.cwd(), 'dist', 'native'),
|
||||||
path.resolve(process.cwd(), 'native'),
|
path.resolve(process.cwd(), 'packages', 'runtime', 'native'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { loadOneBotConfig, makeDefaultOneBotConfig } from '../onebot/config';
|
import { loadOneBotConfig, makeDefaultOneBotConfig } from '../src/onebot/config';
|
||||||
|
|
||||||
describe('makeDefaultOneBotConfig', () => {
|
describe('makeDefaultOneBotConfig', () => {
|
||||||
it('returns default config structure', () => {
|
it('returns default config structure', () => {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { protoDecode, protoEncode, type ProtoSchema } from '../protobuf/decode';
|
import { protoDecode, protoEncode, type ProtoSchema } from '../src/protobuf/decode';
|
||||||
import { WireMessage, encodeKey, encodeVarint, WireType } from '../protobuf/wire';
|
import { WireMessage, encodeKey, encodeVarint, WireType } from '../src/protobuf/wire';
|
||||||
|
|
||||||
describe('protoDecode', () => {
|
describe('protoDecode', () => {
|
||||||
const SimpleSchema = {
|
const SimpleSchema = {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { toHex, fromHex, hexPreview } from '../utils/hex';
|
import { toHex, fromHex, hexPreview } from '../src/utils/hex';
|
||||||
|
|
||||||
describe('toHex', () => {
|
describe('toHex', () => {
|
||||||
it('converts empty buffer', () => {
|
it('converts empty buffer', () => {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { hashMessageIdInt32, GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT } from '../onebot/message-id';
|
import { hashMessageIdInt32, GROUP_MESSAGE_EVENT, PRIVATE_MESSAGE_EVENT } from '../src/onebot/message-id';
|
||||||
|
|
||||||
describe('hashMessageIdInt32', () => {
|
describe('hashMessageIdInt32', () => {
|
||||||
it('returns consistent hash for same inputs', () => {
|
it('returns consistent hash for same inputs', () => {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { parseMessage } from '../onebot/message-parser';
|
import { parseMessage } from '../src/onebot/message-parser';
|
||||||
|
|
||||||
describe('parseMessage', () => {
|
describe('parseMessage', () => {
|
||||||
describe('plain text', () => {
|
describe('plain text', () => {
|
||||||
@@ -151,7 +151,8 @@ describe('parseMessage', () => {
|
|||||||
);
|
);
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
expect(result[0].type).toBe('json');
|
expect(result[0].type).toBe('json');
|
||||||
const parsed = JSON.parse(result[0].text);
|
expect(result[0].text).toBeDefined();
|
||||||
|
const parsed = JSON.parse(result[0].text!);
|
||||||
expect(parsed.app).toBe('com.tencent.structmsg');
|
expect(parsed.app).toBe('com.tencent.structmsg');
|
||||||
expect(parsed.meta.news.title).toBe('Test');
|
expect(parsed.meta.news.title).toBe('Test');
|
||||||
});
|
});
|
||||||
@@ -204,7 +205,8 @@ describe('parseMessage', () => {
|
|||||||
);
|
);
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
expect(result[0].type).toBe('json');
|
expect(result[0].type).toBe('json');
|
||||||
const parsed = JSON.parse(result[0].text);
|
expect(result[0].text).toBeDefined();
|
||||||
|
const parsed = JSON.parse(result[0].text!);
|
||||||
expect(parsed.app).toBe('com.tencent.map');
|
expect(parsed.app).toBe('com.tencent.map');
|
||||||
expect(parsed.meta.Location.lat).toBe('39.9');
|
expect(parsed.meta.Location.lat).toBe('39.9');
|
||||||
});
|
});
|
||||||
@@ -216,7 +218,8 @@ describe('parseMessage', () => {
|
|||||||
);
|
);
|
||||||
expect(result).toHaveLength(1);
|
expect(result).toHaveLength(1);
|
||||||
expect(result[0].type).toBe('json');
|
expect(result[0].type).toBe('json');
|
||||||
const parsed = JSON.parse(result[0].text);
|
expect(result[0].text).toBeDefined();
|
||||||
|
const parsed = JSON.parse(result[0].text!);
|
||||||
expect(parsed.meta.contact.type).toBe('group');
|
expect(parsed.meta.contact.type).toBe('group');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
fieldAsUint32,
|
fieldAsUint32,
|
||||||
fieldAsString,
|
fieldAsString,
|
||||||
fieldAsBool,
|
fieldAsBool,
|
||||||
} from '../protobuf/wire';
|
} from '../src/protobuf/wire';
|
||||||
|
|
||||||
// Helper to build bytes from number array
|
// Helper to build bytes from number array
|
||||||
function bytes(...vals: number[]): Uint8Array {
|
function bytes(...vals: number[]): Uint8Array {
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist",
|
||||||
|
// Tests live outside src/ so we don't pin rootDir; tsc --noEmit doesn't write output anyway.
|
||||||
|
"types": ["node", "vitest/globals"],
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src/**/*", "tests/**/*"],
|
||||||
|
"exclude": ["node_modules", "dist"]
|
||||||
|
}
|
||||||
@@ -5,6 +5,13 @@ import { builtinModules } from 'module';
|
|||||||
import cp from 'vite-plugin-cp';
|
import cp from 'vite-plugin-cp';
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const repoRoot = path.resolve(__dirname, '..', '..');
|
||||||
|
const distDir = path.resolve(repoRoot, 'dist');
|
||||||
|
const runtimeDir = path.resolve(repoRoot, 'packages', 'runtime');
|
||||||
|
const nativeDir = path.resolve(runtimeDir, 'native');
|
||||||
|
|
||||||
|
// vite-plugin-cp consumes globs through globby; on Windows we must use POSIX-style separators.
|
||||||
|
const toPosix = (p: string) => p.replace(/\\/g, '/');
|
||||||
|
|
||||||
const external = [
|
const external = [
|
||||||
'ws'
|
'ws'
|
||||||
@@ -12,11 +19,22 @@ const external = [
|
|||||||
|
|
||||||
const nodeModules = [...builtinModules, ...builtinModules.map((m) => `node:${m}`), 'node:sqlite'].flat();
|
const nodeModules = [...builtinModules, ...builtinModules.map((m) => `node:${m}`), 'node:sqlite'].flat();
|
||||||
|
|
||||||
|
const runtimeSrc = toPosix(runtimeDir);
|
||||||
|
const nativeSrc = toPosix(nativeDir);
|
||||||
|
|
||||||
|
// Only the runtime distribution assets land in dist/.
|
||||||
|
// (.gitignore and other dev artifacts must NOT be shipped.)
|
||||||
|
const runtimeDistFiles = ['launcher.bat', 'package.json'];
|
||||||
|
|
||||||
const BaseConfigPlugin: PluginOption[] = [
|
const BaseConfigPlugin: PluginOption[] = [
|
||||||
cp({
|
cp({
|
||||||
targets: [
|
targets: [
|
||||||
{ src: './launcher/*', dest: 'dist', flatten: true },
|
...runtimeDistFiles.map((file) => ({
|
||||||
{ src: './native/*', dest: 'dist/native/', flatten: true },
|
src: `${runtimeSrc}/${file}`,
|
||||||
|
dest: distDir,
|
||||||
|
flatten: true,
|
||||||
|
})),
|
||||||
|
{ src: `${nativeSrc}/*`, dest: path.join(distDir, 'native'), flatten: true },
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
@@ -42,7 +60,9 @@ const BaseConfig = (source_map: boolean = false) => defineConfig({
|
|||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: [...nodeModules, ...external]
|
external: [...nodeModules, ...external]
|
||||||
},
|
},
|
||||||
outDir: 'dist',
|
// Emit to monorepo root dist/ so the existing release pipeline keeps working.
|
||||||
|
outDir: distDir,
|
||||||
|
// Required since outDir is outside the vite project root.
|
||||||
emptyOutDir: true
|
emptyOutDir: true
|
||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': path.resolve(__dirname, 'src')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
include: ['tests/**/*.test.ts'],
|
||||||
|
environment: 'node'
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "@snowluma/runtime",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.mjs",
|
||||||
|
"description": "SnowLuma runtime distribution manifest: ships into dist/ (launcher.bat, package.json, native/*.dll, native/*.node)",
|
||||||
|
"dependencies": {
|
||||||
|
"ws": "^8.20.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
|
"typecheck": "tsc -b",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 8.5 KiB |