feat: add puzzle clear template runtime

This commit is contained in:
2026-06-03 22:11:46 +08:00
parent 6e74cf5add
commit 1b5e098225
148 changed files with 19588 additions and 241 deletions

View File

@@ -5,6 +5,7 @@ import {
existsSync,
readdirSync,
readFileSync,
realpathSync,
statSync,
watch,
writeFileSync,
@@ -1684,6 +1685,26 @@ function normalizePath(path) {
return path.replace(/\\/gu, '/');
}
function safeRealpath(pathValue) {
try {
return realpathSync(pathValue);
} catch {
return resolve(pathValue);
}
}
function isDirectModuleExecution(argv1, moduleUrl, resolvePath = safeRealpath) {
if (!argv1) {
return false;
}
try {
return resolvePath(argv1) === resolvePath(fileURLToPath(moduleUrl));
} catch {
return resolve(argv1) === fileURLToPath(moduleUrl);
}
}
function buildSpacetimePublishArgs({database, server, preserveDatabase}) {
const args = [
'publish',
@@ -1735,6 +1756,7 @@ export {
createDevServerSpawnOptions,
createWatchConfigs,
isSpacetimePublishPermissionError,
isDirectModuleExecution,
parseSpacetimeToolVersion,
parseArgs,
shouldAcceptWatchEvent,
@@ -1765,6 +1787,6 @@ async function main() {
}
}
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
if (isDirectModuleExecution(process.argv[1], import.meta.url)) {
void main();
}