Skip to content

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.

fix(release): the publish gate asks the platform list instead of keeping one

esengine17c18a2de005
diff --git a/build-tools/tasks/verifyTemplate.d.ts b/build-tools/tasks/verifyTemplate.d.ts
new file mode 100644
index 000000000..210f6e954
--- /dev/null
+++ b/build-tools/tasks/verifyTemplate.d.ts
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import type { NativePlatform } from '../utils/nativeTemplate.js';
+
+export interface TemplateVerdict {
+ ok: boolean;
+ problems: string[];
+ platform: NativePlatform | null;
+ engineVersion: string | null;
+}
+
+export function verifyTemplateZip(zipPath: string): TemplateVerdict;
+export function verifyTemplates(zipPaths: string[]): void;
diff --git a/build-tools/tasks/verifyTemplate.js b/build-tools/tasks/verifyTemplate.js
index d98687599..27944f160 100644
--- a/build-tools/tasks/verifyTemplate.js
+++ b/build-tools/tasks/verifyTemplate.js
@@ -18,7 +18,8 @@ import { readFileSync } from 'fs';
import * as logger from '../utils/logger.js';
import { readZip } from '../utils/zip.js';
import {
- missingTemplateEntries, readTemplateManifest, TEMPLATE_MANIFEST, TEMPLATE_FORMAT,
+ missingTemplateEntries, readTemplateManifest, isTemplatePlatform,
+ TEMPLATE_MANIFEST, TEMPLATE_FORMAT,
} from '../utils/nativeTemplate.js';
/** The manifest inside the archive, without unpacking it. */
@@ -62,7 +63,7 @@ export function verifyTemplateZip(zipPath) {
}
const platform = manifest.platform ?? null;
- if (platform !== 'android' && platform !== 'ios') {
+ if (!isTemplatePlatform(platform)) {
problems.push(`platform "${platform}" is not one this build knows`);
return { ok: false, problems, platform, engineVersion: manifest.engineVersion ?? null };
}
diff --git a/build-tools/utils/nativeTemplate.d.ts b/build-tools/utils/nativeTemplate.d.ts
index c613e593c..4645e5ddf 100644
--- a/build-tools/utils/nativeTemplate.d.ts
+++ b/build-tools/utils/nativeTemplate.d.ts
@@ -44,6 +44,11 @@ export const BYTECODE_FILE: string;
export const ANDROID_ABIS: readonly string[];
export function templateId(platform: NativePlatform): string;
+
+/** Every platform a template is built and published for — the one list the
+ * layouts and the release verifier both ask. */
+export const TEMPLATE_PLATFORMS: readonly NativePlatform[];
+export function isTemplatePlatform(platform: unknown): platform is NativePlatform;
export function templateAbis(dir: string): string[];
export interface TemplateEntry {
/** Path inside the template. */
@@ -57,7 +62,7 @@ export interface TemplateEntry {
}
export function templateLayout(platform: NativePlatform, options?: { abis?: readonly string[] }): TemplateEntry[];
-export function requiredTemplateFiles(platform: NativePlatform, options?: { abis?: readonly string[] }): string[];
+export function requiredTemplateFiles(platform: NativePlatform, options?: { abis?: readonly string[]; release?: boolean }): string[];
export function missingTemplateFiles(dir: string, platform: NativePlatform, options?: { abis?: readonly string[] }): string[];
/** The same question asked of a NAME LIST rather than a directory — what a zip
* is missing, checked before it is unpacked. */
diff --git a/build-tools/utils/nativeTemplate.js b/build-tools/utils/nativeTemplate.js
index eb94a401a..54b3881b0 100644
--- a/build-tools/utils/nativeTemplate.js
+++ b/build-tools/utils/nativeTemplate.js
@@ -86,6 +86,19 @@ export function templateId(platform) {
return platform;
}
+/**
+ * Every platform a template is built and published for. One list, because the
+ * alternative already failed: the release gate kept its own pair of names while
+ * three desktop platforms landed in {@link templateLayout}, and the publish step
+ * then rejected three archives it had just built correctly.
+ */
+export const TEMPLATE_PLATFORMS = ['android', 'ios', 'macos', 'windows', 'linux'];
+
+/** Whether {@link templateLayout} can describe this platform. */
+export function isTemplatePlatform(platform) {
+ return TEMPLATE_PLATFORMS.includes(platform);
+}
+
/**
* The Android ABIs a template can carry, in the order a package lists them.
* `arm64-v8a` is every real device; `x86_64` is the emulator, which is how anyone
@@ -222,9 +235,7 @@ export function templateLayout(platform, options = {}) {
{ rel: DEFAULT_ICON, from: (ctx) => path.join(ctx.root, 'native', 'icon.png') },
];
}
- // windows and linux are named ids with no layout yet (S3c): a template for one
- // cannot be installed, so this is only reached if something invents one.
- throw new Error(`No template layout for "${platform}" — android, ios and macos have one.`);
+ throw new Error(`No template layout for "${platform}" — ${TEMPLATE_PLATFORMS.join(', ')} have one.`);
}
/**
diff --git a/desktop/tests/native-template.test.ts b/desktop/tests/native-template.test.ts
index 0e25bb2f1..baabe8c2b 100644
--- a/desktop/tests/native-template.test.ts
+++ b/desktop/tests/native-template.test.ts
@@ -21,8 +21,11 @@ import {
import { listPlatforms } from '../electron/platformCatalog';
import {
requiredTemplateFiles, templateLayout, installedTemplateDir, parseTemplateIndex,
- missingTemplateEntries, TEMPLATE_FORMAT, TEMPLATE_MANIFEST, TEMPLATE_INDEX,
+ missingTemplateEntries, isTemplatePlatform,
+ TEMPLATE_FORMAT, TEMPLATE_MANIFEST, TEMPLATE_INDEX, TEMPLATE_PLATFORMS,
+ type NativePlatform,
} from '../../build-tools/utils/nativeTemplate.js';
+import { verifyTemplateZip } from '../../build-tools/tasks/verifyTemplate.js';
import { makeZip } from '../../build-tools/utils/zip.js';
const VERSION = '9.9.9';
@@ -335,3 +338,48 @@ describe('what a PUBLISHED template must carry', () => {
expect(missingTemplateEntries(win, 'android', { release: true })).toEqual([]);
});
});
+
+describe('the platforms templates are published for', () => {
+ /** A release-complete archive for any platform, built from that platform's own
+ * layout so the fixture follows the contract instead of restating it. */
+ function releaseZip(platform: NativePlatform): Buffer {
+ const entries = requiredTemplateFiles(platform, { release: true })
+ .map((rel: string) => ({ name: rel, data: Buffer.from(`stand-in for ${rel}`) }));
+ entries.push({
+ name: TEMPLATE_MANIFEST,
+ data: Buffer.from(JSON.stringify({
+ kind: 'estella-native-template',
+ formatVersion: TEMPLATE_FORMAT,
+ id: platform,
+ platform,
+ engineVersion: VERSION,
+ })),
+ });
+ return makeZip(entries);
+ }
+
+ it('all have a layout, and the list is what asks', () => {
+ // The release gate kept its own pair of names while three desktop platforms
+ // landed in templateLayout, so v0.47.0 built five templates correctly and
+ // then refused to publish three. One list, and the layouts cannot part from it.
+ for (const p of TEMPLATE_PLATFORMS) {
+ expect(isTemplatePlatform(p)).toBe(true);
+ expect(templateLayout(p).length).toBeGreaterThan(0);
+ }
+ expect(isTemplatePlatform('playstation')).toBe(false);
+ expect(() => templateLayout('playstation' as NativePlatform)).toThrow();
+ });
+
+ it('are each accepted by the release verifier', () => {
+ // Through the verifier's own entry point, not a copy of its rule — having a
+ // copy was the defect.
+ for (const p of TEMPLATE_PLATFORMS) {
+ const zip = path.join(scratch, `t-${p}.zip`);
+ writeFileSync(zip, releaseZip(p));
+ const res = verifyTemplateZip(zip);
+ expect(res.platform).toBe(p);
+ expect(res.problems).toEqual([]);
+ expect(res.ok).toBe(true);
+ }
+ });
+});