A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(tools): a host that cannot read the engine version says so instead of asking the mirror for v0.0.0
yhhd005421a0e1a
diff --git a/pipeline/src/tools/externalTools.ts b/pipeline/src/tools/externalTools.tsindex 25f88737b..d8f60a492 100644--- a/pipeline/src/tools/externalTools.ts+++ b/pipeline/src/tools/externalTools.ts@@ -143,17 +143,26 @@ export interface InstallPlan {sources: string[];}-export function toolSources(env: NodeJS.ProcessEnv = process.env, engineVersion = defaultEngineVersion()): string[] {+export function toolSources(env: NodeJS.ProcessEnv = process.env, engineVersion?: string): string[] {const override = env[TOOLS_BASE_ENV];- return override ? [override.replace(/[\\/]+$/, '')] : (releaseAssetBases(engineVersion, env) as string[]);+ // A base given outright needs no release to be named.+ return override ? [override.replace(/[\\/]+$/, '')] : (releaseAssetBases(engineVersion ?? defaultEngineVersion(env), env) as string[]);}-function defaultEngineVersion(): string {+/** The environment variable a host sets to say which engine release it is, when it is not running from the source tree. */+export const ENGINE_VERSION_ENV = 'ESTELLA_ENGINE_VERSION';++/**+ * Which release's files to ask the mirror for. A packaged editor has no source tree to read it from, so it says so+ * (an `engineVersion` option, or {@link ENGINE_VERSION_ENV}); and when nothing can say, this throws. It once fell back to+ * `0.0.0`, which asks the mirror for a release that does not exist and reports a download failure nobody can act on.+ */+function defaultEngineVersion(env: NodeJS.ProcessEnv = process.env): string {+ if (env[ENGINE_VERSION_ENV]) return env[ENGINE_VERSION_ENV];try {- // The repo root's package.json when running from source; the editor passes its own version.return (JSON.parse(readFileSync(new URL('../../../package.json', import.meta.url), 'utf8')) as { version: string }).version;} catch {- return '0.0.0';+ throw new Error(`cannot tell which engine release this is: pass engineVersion, or set ${ENGINE_VERSION_ENV}`);}}diff --git a/pipeline/src/tools/lubanRun.ts b/pipeline/src/tools/lubanRun.tsindex 620b1dbbd..5fa724d23 100644--- a/pipeline/src/tools/lubanRun.ts+++ b/pipeline/src/tools/lubanRun.ts@@ -25,6 +25,8 @@ export interface LubanRunOptions {check?: boolean;store?: string;platform?: ToolPlatform | null;+ /** What to tell a person to do when the tool is missing, in the words of the place they are (a command line, the editor). */+ installHint?: string;/** For tests: how a process is run. */run?: (command: string, args: string[], options: { cwd: string; env: NodeJS.ProcessEnv }) => Promise<{ code: number | null; output: string }>;}@@ -95,7 +97,7 @@ export async function runLuban(options: LubanRunOptions): Promise<LubanRunResultconst plan = installPlan('luban', where);const what = plan.items.map((i) => `${i.name} ${i.version}`).join(' and ');return { ok: false, reason: 'missing-tool', changed: [], log: '', errors: [what- ? `Luban is switched on for this project but ${what} ${plan.items.length > 1 ? 'are' : 'is'} not installed. Run: estella tools install luban`+ ? `Luban is switched on for this project but ${what} ${plan.items.length > 1 ? 'are' : 'is'} not installed. ${options.installHint ?? 'Run: estella tools install luban'}`: `Luban cannot run here: ${status.problem ?? status.needs.find((n) => !toolReady(n))?.problem ?? 'unavailable'}`] };}const manifest = toolsManifest();diff --git a/pipeline/src/tools/toolsCli.ts b/pipeline/src/tools/toolsCli.tsindex 80b7cb883..bfe7c45b3 100644--- a/pipeline/src/tools/toolsCli.ts+++ b/pipeline/src/tools/toolsCli.ts@@ -130,10 +130,10 @@ export async function lubanCommand(sub: 'gen' | 'check', projectDir: string, opt* packaged from stale JSON. A project that has it off is not touched, and nothing is looked for.* Returns the message to stop with, or null to go on.*/-export async function prepareProjectTools(projectDir: string, options: { store?: string } = {}): Promise<string | null> {+export async function prepareProjectTools(projectDir: string, options: { store?: string; installHint?: string } = {}): Promise<string | null> {const setting = readProjectManifest(projectDir).tools?.luban;if (!setting?.enabled) return null;- const result = await runLuban({ projectDir, setting, store: options.store });+ const result = await runLuban({ projectDir, setting, store: options.store, installHint: options.installHint });if (result.ok) return null;return `Luban: ${result.errors.join('\n')}`;}diff --git a/pipeline/tests/external-tools.test.ts b/pipeline/tests/external-tools.test.tsindex e375fb965..4fdbd21cc 100644--- a/pipeline/tests/external-tools.test.ts+++ b/pipeline/tests/external-tools.test.ts@@ -267,3 +267,15 @@ describe('the index', () => {expect(parseToolsIndex({ ...f.index, files: [] })).toBeNull();});});++describe('which engine release to ask for', () => {+ it('is the one the host names, and never a made-up one', () => {+ expect(toolSources({ ESTELLA_ENGINE_VERSION: '1.2.3' } as NodeJS.ProcessEnv).every((s) => /\/v1\.2\.3$/.test(s))).toBe(true);+ // An explicit version wins over the environment.+ expect(toolSources({ ESTELLA_ENGINE_VERSION: '1.2.3' } as NodeJS.ProcessEnv, '4.5.6').every((s) => /\/v4\.5\.6$/.test(s))).toBe(true);+ // From the source tree it reads the repo's own version, and that is a real one.+ expect(toolSources({}).some((s) => /\/v\d+\.\d+\.\d+$/.test(s) && !s.endsWith('/v0.0.0'))).toBe(true);+ // A base named outright needs no release.+ expect(toolSources({ ESTELLA_TOOLS_BASE: '/x' } as NodeJS.ProcessEnv)).toEqual(['/x']);+ });+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex dbb5c8ab5..0eef2f2eb 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -3024,6 +3024,8 @@ export const NOTED = {{"note":"A text field can accept only digits."},'feat(tools): optional third-party tools, pinned and fetched from the release mirror':{"note":"Optional tools a project switches on, fetched and checked by the engine."},+ 'fix(tools): a host that cannot read the engine version says so instead of asking the mirror for v0.0.0':+ {"internal":"A fix inside the optional tools feature, which has not shipped yet."},"perf(sdk): a blank mini-game package no longer carries terrain and water":{"note":"A blank mini-game package no longer carries terrain and water."},"perf(ecs): one stable sort for every component type, 239KB off the engine wasm":