build: add precompiled CLI distribution

This commit is contained in:
2026-08-29 19:00:14 +08:00
parent d074681928
commit 4d1dc76e31
77 changed files with 3461 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
if (typeof path === "string" && /^\.\.?\//.test(path)) {
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
});
}
return path;
};
import { access, readFile } from 'node:fs/promises';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
const defaults = {
title: 'easy-slides',
description: 'Markdown presentations powered by easy-slides',
slidesDir: 'slides',
outDir: 'dist',
exportDir: 'exports',
};
export async function loadProjectConfig(cwd = process.cwd()) {
const candidates = [
'easy-slides.config.mjs',
'easy-slides.config.js',
'easy-slides.config.json',
];
for (const candidate of candidates) {
const filename = path.join(cwd, candidate);
if (!(await exists(filename)))
continue;
const loaded = candidate.endsWith('.json')
? JSON.parse(await readFile(filename, 'utf8'))
: (await import(__rewriteRelativeImportExtension(`${pathToFileURL(filename).href}?t=${Date.now()}`))).default;
return normalizeConfig(loaded);
}
return { ...defaults };
}
export function normalizeConfig(value) {
return {
...defaults,
...value,
slidesDir: normalizeRelativePath(value?.slidesDir ?? defaults.slidesDir, 'slidesDir'),
outDir: normalizeRelativePath(value?.outDir ?? defaults.outDir, 'outDir'),
exportDir: normalizeRelativePath(value?.exportDir ?? defaults.exportDir, 'exportDir'),
};
}
function normalizeRelativePath(value, field) {
const normalized = value.trim().replace(/[\\/]+$/, '');
const portable = normalized.replaceAll('\\', '/');
if (!normalized || path.isAbsolute(normalized) || portable === '..' || portable.startsWith('../'))
throw new Error(`${field} 必须是项目内的相对路径`);
return normalized;
}
async function exists(filename) {
try {
await access(filename);
return true;
}
catch {
return false;
}
}
//# sourceMappingURL=config.js.map