33f5ad68bf
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 7m19s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 7m26s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 7m32s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 7m34s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m57s
Project CI / AI game creator shell Rust crates (push) Successful in 3m18s
Project CI / Native shell tests (push) Successful in 10m54s
Project CI / Backend tests (push) Successful in 12m42s
Project CI / Frontend tests (push) Successful in 13m4s
Project CI / AI game creator shell web tests (push) Successful in 5m1s
Project CI / Repository checks (push) Successful in 12m48s
AGC 原有插件系统无法直接操作已打开的 Unity Editor。本变更增加内置 `agc-unity-editor`,在 Windows x64 / Unity Mono 上支持当前项目探测、连接与 C# 执行,不向 Unity 工程安装 UPM 桥接包。 ## 主要变更 - 固定复用 DotCraft.Unity 0.4.3 的 Attach 核心,提供自包含 .NET helper,保留上游许可证、来源及修改记录。 - GUI、Runtime、DirectProject 共用 Runner 执行服务;补齐项目身份、并发、总期限、回执确认与持久不确定状态阻断。 - 现有打开项目入口支持 Unity,按项目类型及开关暴露插件和 Agent 工具。 - Windows 构建准备 helper 并随包分发;插件 JS/Rust 测试接入现有 CI 组,Jenkins 增加 .NET 10 工具链预检。 ## 验证 - .NET helper 27 项测试、自包含发布及最小环境协议 smoke 通过。 - Unity 6000.3.7f1 实机验证通过:连接、C# 执行、编译错误修复、断连重连、Domain Reload 后重新握手;真实 Runner 的 ACK、并发拒绝和跨重启阻断通过。 - 宿主 Unity、PluginHost、Cocos、MCP、工具目录与引擎识别定向回归通过;前端类型检查、插件 JS/Rust、CI 配置、格式、编码和文档门禁通过。 Linux CI 不代替 Windows helper/实机验证;发行安装包 UI smoke、其它 Unity 版本和 Unity CoreCLR 未验证。Unity 演示工程中的场景和组件已撤销,不在此 PR 范围内。 --------- Co-authored-by: kdletters <61648117+kdletters@users.noreply.github.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/423
176 lines
6.1 KiB
JavaScript
176 lines
6.1 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { afterEach, test } from 'node:test';
|
|
|
|
import {
|
|
collectNpmWorkspaceErrors,
|
|
REQUIRED_PACKAGE_MANAGER,
|
|
REQUIRED_WORKSPACES,
|
|
} from './check-npm-workspaces.mjs';
|
|
|
|
const fixtureDirectories = [];
|
|
|
|
const workspaceNames = {
|
|
'apps/admin-web': '@genarrative/admin-web',
|
|
'apps/ai-game-creator-shell': '@genarrative/ai-game-creator-shell',
|
|
'apps/desktop-shell': '@genarrative/desktop-shell',
|
|
'apps/mobile-shell': '@genarrative/mobile-shell',
|
|
'apps/preview-deployer-web': '@genarrative/preview-deployer-web',
|
|
'packages/image-canvas-core': '@genarrative/image-canvas-core',
|
|
'packages/image-canvas-react': '@genarrative/image-canvas-react',
|
|
'packages/agc-plugin-sdk': '@genarrative/agc-plugin-sdk',
|
|
'packages/shared': '@genarrative/shared',
|
|
'plugins/agc-cocos-editor': '@genarrative/agc-plugin-cocos-editor',
|
|
'plugins/agc-unity-editor': '@genarrative/agc-plugin-unity-editor',
|
|
'tools/spine-json-export-validator':
|
|
'@genarrative/spine-json-export-validator',
|
|
};
|
|
|
|
const localDependencies = {
|
|
'apps/admin-web': { '@genarrative/shared': '0.1.0' },
|
|
'apps/ai-game-creator-shell': {
|
|
'@genarrative/image-canvas-core': '0.1.0',
|
|
'@genarrative/image-canvas-react': '0.1.0',
|
|
'@genarrative/shared': '0.1.0',
|
|
},
|
|
'apps/mobile-shell': { '@genarrative/shared': '0.1.0' },
|
|
'packages/image-canvas-react': { '@genarrative/image-canvas-core': '0.1.0' },
|
|
'plugins/agc-cocos-editor': { '@genarrative/agc-plugin-sdk': '0.1.0' },
|
|
'plugins/agc-unity-editor': { '@genarrative/agc-plugin-sdk': '0.1.0' },
|
|
};
|
|
|
|
afterEach(() => {
|
|
for (const fixtureDirectory of fixtureDirectories.splice(0)) {
|
|
fs.rmSync(fixtureDirectory, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
function writeJson(rootDir, relativePath, value) {
|
|
const absolutePath = path.join(rootDir, relativePath);
|
|
fs.mkdirSync(path.dirname(absolutePath), { recursive: true });
|
|
fs.writeFileSync(absolutePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
}
|
|
|
|
function createValidFixture() {
|
|
const rootDir = fs.mkdtempSync(
|
|
path.join(os.tmpdir(), 'genarrative-npm-workspaces-'),
|
|
);
|
|
fixtureDirectories.push(rootDir);
|
|
|
|
writeJson(rootDir, 'package.json', {
|
|
name: 'fixture-root',
|
|
private: true,
|
|
version: '0.0.0',
|
|
packageManager: REQUIRED_PACKAGE_MANAGER,
|
|
workspaces: REQUIRED_WORKSPACES,
|
|
dependencies: {
|
|
'@genarrative/image-canvas-core': '0.1.0',
|
|
'@genarrative/image-canvas-react': '0.1.0',
|
|
'@genarrative/shared': '0.1.0',
|
|
},
|
|
});
|
|
|
|
const packages = {
|
|
'': {
|
|
name: 'fixture-root',
|
|
version: '0.0.0',
|
|
workspaces: REQUIRED_WORKSPACES,
|
|
},
|
|
};
|
|
for (const workspacePath of REQUIRED_WORKSPACES) {
|
|
const manifest = {
|
|
name: workspaceNames[workspacePath],
|
|
private: true,
|
|
version:
|
|
workspacePath === 'apps/ai-game-creator-shell' ? '0.1.12' : '0.1.0',
|
|
dependencies: localDependencies[workspacePath],
|
|
};
|
|
writeJson(rootDir, `${workspacePath}/package.json`, manifest);
|
|
packages[workspacePath] = manifest;
|
|
packages[`node_modules/${manifest.name}`] = {
|
|
resolved: workspacePath,
|
|
link: true,
|
|
};
|
|
}
|
|
writeJson(rootDir, 'package-lock.json', {
|
|
name: 'fixture-root',
|
|
version: '0.0.0',
|
|
lockfileVersion: 3,
|
|
requires: true,
|
|
packages,
|
|
});
|
|
|
|
return rootDir;
|
|
}
|
|
|
|
function readJson(rootDir, relativePath) {
|
|
return JSON.parse(fs.readFileSync(path.join(rootDir, relativePath), 'utf8'));
|
|
}
|
|
|
|
test('accepts the fixed npm workspace topology and root lock links', () => {
|
|
const rootDir = createValidFixture();
|
|
assert.deepEqual(collectNpmWorkspaceErrors(rootDir), []);
|
|
});
|
|
|
|
test('rejects workspace protocol and non-exact local package versions', () => {
|
|
const rootDir = createValidFixture();
|
|
const manifestPath = 'apps/admin-web/package.json';
|
|
const manifest = readJson(rootDir, manifestPath);
|
|
manifest.dependencies['@genarrative/shared'] = 'workspace:*';
|
|
writeJson(rootDir, manifestPath, manifest);
|
|
|
|
const errors = collectNpmWorkspaceErrors(rootDir).join('\n');
|
|
assert.match(errors, /must not use the unsupported workspace: protocol/u);
|
|
assert.match(errors, /must use exact version 0\.1\.0/u);
|
|
});
|
|
|
|
test('rejects missing workspace entries and links in the root lock', () => {
|
|
const rootDir = createValidFixture();
|
|
const lockfile = readJson(rootDir, 'package-lock.json');
|
|
delete lockfile.packages['apps/mobile-shell'];
|
|
delete lockfile.packages['node_modules/@genarrative/mobile-shell'];
|
|
writeJson(rootDir, 'package-lock.json', lockfile);
|
|
|
|
const errors = collectNpmWorkspaceErrors(rootDir).join('\n');
|
|
assert.match(errors, /packages\["apps\/mobile-shell"\]/u);
|
|
assert.match(errors, /node_modules\/@genarrative\/mobile-shell/u);
|
|
});
|
|
|
|
test('rejects nested package locks and shrinkwrap files', () => {
|
|
const rootDir = createValidFixture();
|
|
writeJson(rootDir, 'apps/admin-web/package-lock.json', {});
|
|
writeJson(rootDir, 'packages/shared/fixtures/npm-shrinkwrap.json', {});
|
|
|
|
const errors = collectNpmWorkspaceErrors(rootDir).join('\n');
|
|
assert.match(errors, /apps\/admin-web\/package-lock\.json/u);
|
|
assert.match(errors, /packages\/shared\/fixtures\/npm-shrinkwrap\.json/u);
|
|
});
|
|
|
|
test('rejects package manager and explicit workspace list drift', () => {
|
|
const rootDir = createValidFixture();
|
|
const rootPackage = readJson(rootDir, 'package.json');
|
|
rootPackage.packageManager = 'npm@11.0.0';
|
|
rootPackage.workspaces = ['apps/*', 'packages/*'];
|
|
writeJson(rootDir, 'package.json', rootPackage);
|
|
|
|
const errors = collectNpmWorkspaceErrors(rootDir).join('\n');
|
|
assert.match(errors, /packageManager must be npm@10\.9\.7/u);
|
|
assert.match(errors, /workspaces must be the explicit ordered list/u);
|
|
});
|
|
|
|
test('rejects test and build aliases tied to a nested workspace install', () => {
|
|
const rootDir = createValidFixture();
|
|
fs.writeFileSync(
|
|
path.join(rootDir, 'vitest.config.ts'),
|
|
"const cubone = 'apps/ai-game-creator-shell/node_modules/@cubone/react-file-manager';\n",
|
|
);
|
|
|
|
const errors = collectNpmWorkspaceErrors(rootDir).join('\n');
|
|
assert.match(
|
|
errors,
|
|
/vitest\.config\.ts: resolve dependencies from the workspace manifest/u,
|
|
);
|
|
});
|