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.

internal: the optional-tools manifest sits where the pipeline may read it, and the tool code uses the shared sandbox and retrying deletes

yhhb8d9f9bcf85c
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index bdbef2bf1..333cc8a92 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -358,7 +358,7 @@ jobs:
run: gh release upload "$GITHUB_REF_NAME" artifacts/* --repo "$GITHUB_REPOSITORY" --clobber
# The third-party tools a project can switch on (Luban and the .NET runtime it runs on), pinned in
- # external-tools.manifest.json. Each vendor file is checked against its pin, repackaged as a .zip and
+ # tools/external-tools.manifest.json. Each vendor file is checked against its pin, repackaged as a .zip and
# attached to the release with an index, so a release carries exactly the tool versions it was built
# against and mirror-release.yml copies them to dl.estella.games with everything else. The editor
# refuses a file that does not match the index, and an index built from another vendor file than the
@@ -373,6 +373,8 @@ jobs:
steps:
- uses: actions/checkout@v7
+ - uses: ./.github/actions/setup
+
- name: Build the tool archives and their index
run: |
command -v 7z >/dev/null || sudo apt-get install -y p7zip-full
diff --git a/pipeline/src/tools/externalTools.ts b/pipeline/src/tools/externalTools.ts
index d8f60a492..554f954d2 100644
--- a/pipeline/src/tools/externalTools.ts
+++ b/pipeline/src/tools/externalTools.ts
@@ -3,7 +3,7 @@
/**
* @file externalTools.ts — the third-party tools a project can switch on, found, fetched and checked.
*
- * `external-tools.manifest.json` (repo root) pins each tool to one exact vendor file. A project that
+ * `tools/external-tools.manifest.json` pins each tool to one exact vendor file. A project that
* turns a tool on gets exactly that: it is looked for in the user's tool store, and when it is missing
* the caller is handed a PLAN (what would be fetched, and from where) to put in front of the person
* before anything is downloaded. Nothing here downloads on its own.
@@ -21,7 +21,7 @@ import { once } from 'node:events';
import path from 'node:path';
import { estellaDataDir, releaseAssetBases } from '../../../build-tools/utils/nativeTemplate.js';
import { extractZip } from '../../../build-tools/utils/zip.js';
-import manifestJson from '../../../external-tools.manifest.json';
+import manifestJson from '../../../tools/external-tools.manifest.json';
export type ToolPlatform = 'win-x64' | 'linux-x64' | 'linux-arm64' | 'osx-x64' | 'osx-arm64' | 'any';
diff --git a/pipeline/src/tools/lubanRun.ts b/pipeline/src/tools/lubanRun.ts
index 269c12d58..f0d11e2f1 100644
--- a/pipeline/src/tools/lubanRun.ts
+++ b/pipeline/src/tools/lubanRun.ts
@@ -12,6 +12,7 @@ import { spawn } from 'node:child_process';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
+import { resolveInside } from '../fs/pathSandbox';
import { hostPlatform, installPlan, toolReady, toolStatus, toolsManifest, type ToolPlatform } from './externalTools';
import type { LubanSetting } from './projectTools';
@@ -83,9 +84,7 @@ export function sameBytes(a: string, b: string): boolean {
/** Within the project, whatever the setting says. */
export function inside(root: string, rel: string): string {
- const abs = path.resolve(root, rel);
- if (abs !== root && !abs.startsWith(root + path.sep)) throw new Error(`"${rel}" is outside the project`);
- return abs;
+ return resolveInside(root, rel, 'project');
}
export async function runLuban(options: LubanRunOptions): Promise<LubanRunResult> {
diff --git a/pipeline/tests/external-tools.test.ts b/pipeline/tests/external-tools.test.ts
index 4fdbd21cc..43d980514 100644
--- a/pipeline/tests/external-tools.test.ts
+++ b/pipeline/tests/external-tools.test.ts
@@ -59,7 +59,7 @@ beforeEach(() => {
store = path.join(temp, 'store');
mkdirSync(base);
});
-afterEach(() => rmSync(temp, { recursive: true, force: true }));
+afterEach(() => rmSync(temp, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }));
function publish(f: ReturnType<typeof fixture>, index = f.index) {
writeFileSync(path.join(base, 'rt-1.2.3-win-x64.zip'), f.rtZip);
@@ -149,7 +149,7 @@ describe('installing', () => {
publish(f);
await installTool('gen', { manifest: f.manifest, platform: 'win-x64', store, env: env() });
expect(removeTool('rt', store)).toBe(false); // not in this manifest's store layout under the real manifest
- rmSync(path.join(store, 'rt'), { recursive: true });
+ rmSync(path.join(store, 'rt'), { recursive: true, maxRetries: 10, retryDelay: 50 });
const status = toolStatus('gen', { manifest: f.manifest, platform: 'win-x64', store });
expect(status.installed).toBe(true);
expect(toolReady(status)).toBe(false);
diff --git a/pipeline/tests/luban-run.test.ts b/pipeline/tests/luban-run.test.ts
index b7a639c3d..cdb17d91a 100644
--- a/pipeline/tests/luban-run.test.ts
+++ b/pipeline/tests/luban-run.test.ts
@@ -56,8 +56,8 @@ describe('Luban missing', () => {
expect(result).toMatchObject({ ok: false, reason: 'missing-tool' });
expect(result.errors[0]).toMatch(/\.NET runtime 8\.0\.33 and Luban 5\.1\.0 are not installed.*estella tools install luban/);
} finally {
- rmSync(root, { recursive: true, force: true });
- rmSync(store, { recursive: true, force: true });
+ rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
+ rmSync(store, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
}
});
});
@@ -93,8 +93,8 @@ describe.skipIf(!base || !existsSync(path.join(base, 'external-tools.json')))('L
writeFileSync(path.join(conf, 'Datas/sites.csv'), '##var,id,item,stock\n##type,string,string,int\n##,id,产出,次数\n,workshop,parts,4\n');
}, 120_000);
afterAll(() => {
- rmSync(store, { recursive: true, force: true });
- rmSync(root, { recursive: true, force: true });
+ rmSync(store, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
+ rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
});
const run = (extra: Partial<Parameters<typeof runLuban>[0]> = {}) => runLuban({ projectDir: root, setting, store, ...extra });
@@ -189,7 +189,7 @@ describe('is the generated output behind the tables?', () => {
writeFileSync(path.join(root, '.esengine/luban-generated.json'), 'not json');
expect(lubanStaleness(root, setting)).toBe('never');
} finally {
- rmSync(root, { recursive: true, force: true });
+ rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
}
});
});
diff --git a/pipeline/tests/protobuf-run.test.ts b/pipeline/tests/protobuf-run.test.ts
index f7a180d61..3997d98be 100644
--- a/pipeline/tests/protobuf-run.test.ts
+++ b/pipeline/tests/protobuf-run.test.ts
@@ -34,8 +34,8 @@ describe('protoc missing', () => {
expect(result).toMatchObject({ ok: false, reason: 'missing-tool' });
expect(result.errors[0]).toMatch(/Protocol Buffers compiler 36\.2 is not installed.*estella tools install protoc/);
} finally {
- rmSync(root, { recursive: true, force: true });
- rmSync(store, { recursive: true, force: true });
+ rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
+ rmSync(store, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
}
});
@@ -85,8 +85,8 @@ message Order {
`);
}, 120_000);
afterAll(() => {
- rmSync(store, { recursive: true, force: true });
- rmSync(root, { recursive: true, force: true });
+ rmSync(store, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
+ rmSync(root, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
});
const run = (extra: Partial<Parameters<typeof runProtobuf>[0]> = {}) => runProtobuf({ projectDir: root, setting, store, ...extra });
diff --git a/external-tools.manifest.json b/tools/external-tools.manifest.json
similarity index 100%
rename from external-tools.manifest.json
rename to tools/external-tools.manifest.json
diff --git a/tools/sync-external-tools.mjs b/tools/sync-external-tools.mjs
index 01e0a9f17..ed6d16a78 100644
--- a/tools/sync-external-tools.mjs
+++ b/tools/sync-external-tools.mjs
@@ -4,7 +4,7 @@
/**
* @file sync-external-tools.mjs — put the pinned third-party tools on the release mirror's terms.
*
- * `external-tools.manifest.json` pins each tool to the exact file its vendor publishes. This script
+ * `tools/external-tools.manifest.json` pins each tool to the exact file its vendor publishes. This script
* turns those into what an engine release serves: one .zip per tool and platform (the single archive
* format the engine reads, so it needs no extractor for .7z or .tar.gz) and an index that says what
* each file must hash to. The files are attached to the release; `mirror-release.yml` copies them to
@@ -27,7 +27,7 @@ import { fileURLToPath } from 'node:url';
import { makeZip, readZip, zipTree } from '../build-tools/utils/zip.js';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
-const MANIFEST = path.join(ROOT, 'external-tools.manifest.json');
+const MANIFEST = path.join(ROOT, 'tools', 'external-tools.manifest.json');
export const PLATFORMS = ['win-x64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64', 'any'];
const SHA = /^[0-9a-f]{64}$/;
@@ -135,7 +135,7 @@ function read7z(buf) {
if (run.status !== 0) throw new Error(`7z failed: ${run.stderr || run.stdout}`);
return zipTree(out);
} finally {
- rmSync(temp, { recursive: true, force: true });
+ rmSync(temp, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
}
}
@@ -173,14 +173,14 @@ async function main() {
if (args.mode === 'check') {
const problems = manifestProblems(manifest);
- if (problems.length) { console.error(`external-tools.manifest.json:\n - ${problems.join('\n - ')}`); process.exit(1); }
+ if (problems.length) { console.error(`tools/external-tools.manifest.json:\n - ${problems.join('\n - ')}`); process.exit(1); }
const n = Object.values(manifest.tools).reduce((sum, t) => sum + Object.keys(t.files).length, 0);
console.log(`external-tools: ${Object.keys(manifest.tools).length} tools, ${n} pinned files — ok`);
return;
}
const structural = manifestProblems(manifest, { requirePins: false });
- if (structural.length) { console.error(`external-tools.manifest.json:\n - ${structural.join('\n - ')}`); process.exit(1); }
+ if (structural.length) { console.error(`tools/external-tools.manifest.json:\n - ${structural.join('\n - ')}`); process.exit(1); }
if (args.mode === 'record') {
let changed = 0;
@@ -201,7 +201,7 @@ async function main() {
}
const problems = manifestProblems(manifest);
- if (problems.length) { console.error(`external-tools.manifest.json:\n - ${problems.join('\n - ')}`); process.exit(1); }
+ if (problems.length) { console.error(`tools/external-tools.manifest.json:\n - ${problems.join('\n - ')}`); process.exit(1); }
const engineVersion = JSON.parse(readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version;
mkdirSync(args.out, { recursive: true });
const index = { kind: 'estella-external-tools', formatVersion: 1, engineVersion, files: [] };