mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
build: reduce build log noise
This commit is contained in:
@@ -223,9 +223,9 @@
|
|||||||
"android:run": "cd apps/android && ./gradlew :app:installDebug && adb shell am start -n ai.openclaw.app/.MainActivity",
|
"android:run": "cd apps/android && ./gradlew :app:installDebug && adb shell am start -n ai.openclaw.app/.MainActivity",
|
||||||
"android:test": "cd apps/android && ./gradlew :app:testDebugUnitTest",
|
"android:test": "cd apps/android && ./gradlew :app:testDebugUnitTest",
|
||||||
"android:test:integration": "OPENCLAW_LIVE_TEST=1 OPENCLAW_LIVE_ANDROID_NODE=1 vitest run --config vitest.live.config.ts src/gateway/android-node.capabilities.live.test.ts",
|
"android:test:integration": "OPENCLAW_LIVE_TEST=1 OPENCLAW_LIVE_ANDROID_NODE=1 vitest run --config vitest.live.config.ts src/gateway/android-node.capabilities.live.test.ts",
|
||||||
"build": "pnpm canvas:a2ui:bundle && tsdown && node scripts/copy-plugin-sdk-root-alias.mjs && pnpm build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --import tsx scripts/write-cli-startup-metadata.ts && node --import tsx scripts/write-cli-compat.ts",
|
"build": "pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/copy-plugin-sdk-root-alias.mjs && pnpm build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --import tsx scripts/write-cli-startup-metadata.ts && node --import tsx scripts/write-cli-compat.ts",
|
||||||
"build:plugin-sdk:dts": "tsc -p tsconfig.plugin-sdk.dts.json",
|
"build:plugin-sdk:dts": "tsc -p tsconfig.plugin-sdk.dts.json",
|
||||||
"build:strict-smoke": "pnpm canvas:a2ui:bundle && tsdown && node scripts/copy-plugin-sdk-root-alias.mjs && pnpm build:plugin-sdk:dts",
|
"build:strict-smoke": "pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/copy-plugin-sdk-root-alias.mjs && pnpm build:plugin-sdk:dts",
|
||||||
"canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh",
|
"canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh",
|
||||||
"check": "pnpm format:check && pnpm tsgo && pnpm lint && pnpm lint:tmp:no-random-messaging && pnpm lint:tmp:channel-agnostic-boundaries && pnpm lint:tmp:no-raw-channel-fetch && pnpm lint:agent:ingress-owner && pnpm lint:plugins:no-register-http-handler && pnpm lint:plugins:no-monolithic-plugin-sdk-entry-imports && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope && pnpm check:host-env-policy:swift",
|
"check": "pnpm format:check && pnpm tsgo && pnpm lint && pnpm lint:tmp:no-random-messaging && pnpm lint:tmp:channel-agnostic-boundaries && pnpm lint:tmp:no-raw-channel-fetch && pnpm lint:agent:ingress-owner && pnpm lint:plugins:no-register-http-handler && pnpm lint:plugins:no-monolithic-plugin-sdk-entry-imports && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope && pnpm check:host-env-policy:swift",
|
||||||
"check:docs": "pnpm format:docs:check && pnpm lint:docs && pnpm docs:check-links",
|
"check:docs": "pnpm format:docs:check && pnpm lint:docs && pnpm docs:check-links",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { fileURLToPath } from "node:url";
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const projectRoot = path.resolve(__dirname, "..");
|
const projectRoot = path.resolve(__dirname, "..");
|
||||||
|
const verbose = process.env.OPENCLAW_BUILD_VERBOSE === "1";
|
||||||
|
|
||||||
const srcDir = path.join(projectRoot, "src", "auto-reply", "reply", "export-html");
|
const srcDir = path.join(projectRoot, "src", "auto-reply", "reply", "export-html");
|
||||||
const distDir = path.join(projectRoot, "dist", "export-html");
|
const distDir = path.join(projectRoot, "dist", "export-html");
|
||||||
@@ -26,14 +27,18 @@ function copyExportHtmlTemplates() {
|
|||||||
|
|
||||||
// Copy main template files
|
// Copy main template files
|
||||||
const templateFiles = ["template.html", "template.css", "template.js"];
|
const templateFiles = ["template.html", "template.css", "template.js"];
|
||||||
|
let copiedCount = 0;
|
||||||
for (const file of templateFiles) {
|
for (const file of templateFiles) {
|
||||||
const srcFile = path.join(srcDir, file);
|
const srcFile = path.join(srcDir, file);
|
||||||
const distFile = path.join(distDir, file);
|
const distFile = path.join(distDir, file);
|
||||||
if (fs.existsSync(srcFile)) {
|
if (fs.existsSync(srcFile)) {
|
||||||
fs.copyFileSync(srcFile, distFile);
|
fs.copyFileSync(srcFile, distFile);
|
||||||
|
copiedCount += 1;
|
||||||
|
if (verbose) {
|
||||||
console.log(`[copy-export-html-templates] Copied ${file}`);
|
console.log(`[copy-export-html-templates] Copied ${file}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Copy vendor files
|
// Copy vendor files
|
||||||
const srcVendor = path.join(srcDir, "vendor");
|
const srcVendor = path.join(srcDir, "vendor");
|
||||||
@@ -48,12 +53,15 @@ function copyExportHtmlTemplates() {
|
|||||||
const distFile = path.join(distVendor, file);
|
const distFile = path.join(distVendor, file);
|
||||||
if (fs.statSync(srcFile).isFile()) {
|
if (fs.statSync(srcFile).isFile()) {
|
||||||
fs.copyFileSync(srcFile, distFile);
|
fs.copyFileSync(srcFile, distFile);
|
||||||
|
copiedCount += 1;
|
||||||
|
if (verbose) {
|
||||||
console.log(`[copy-export-html-templates] Copied vendor/${file}`);
|
console.log(`[copy-export-html-templates] Copied vendor/${file}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("[copy-export-html-templates] Done");
|
console.log(`[copy-export-html-templates] Copied ${copiedCount} export-html assets.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyExportHtmlTemplates();
|
copyExportHtmlTemplates();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { fileURLToPath } from "node:url";
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
const projectRoot = path.resolve(__dirname, "..");
|
const projectRoot = path.resolve(__dirname, "..");
|
||||||
|
const verbose = process.env.OPENCLAW_BUILD_VERBOSE === "1";
|
||||||
|
|
||||||
const srcBundled = path.join(projectRoot, "src", "hooks", "bundled");
|
const srcBundled = path.join(projectRoot, "src", "hooks", "bundled");
|
||||||
const distBundled = path.join(projectRoot, "dist", "bundled");
|
const distBundled = path.join(projectRoot, "dist", "bundled");
|
||||||
@@ -24,6 +25,7 @@ function copyHookMetadata() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const entries = fs.readdirSync(srcBundled, { withFileTypes: true });
|
const entries = fs.readdirSync(srcBundled, { withFileTypes: true });
|
||||||
|
let copiedCount = 0;
|
||||||
|
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (!entry.isDirectory()) {
|
if (!entry.isDirectory()) {
|
||||||
@@ -46,10 +48,13 @@ function copyHookMetadata() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs.copyFileSync(srcHookMd, distHookMd);
|
fs.copyFileSync(srcHookMd, distHookMd);
|
||||||
|
copiedCount += 1;
|
||||||
|
if (verbose) {
|
||||||
console.log(`[copy-hook-metadata] Copied ${hookName}/HOOK.md`);
|
console.log(`[copy-hook-metadata] Copied ${hookName}/HOOK.md`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("[copy-hook-metadata] Done");
|
console.log(`[copy-hook-metadata] Copied ${copiedCount} hook metadata files.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyHookMetadata();
|
copyHookMetadata();
|
||||||
|
|||||||
19
scripts/tsdown-build.mjs
Normal file
19
scripts/tsdown-build.mjs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { spawnSync } from "node:child_process";
|
||||||
|
|
||||||
|
const logLevel = process.env.OPENCLAW_BUILD_VERBOSE ? "info" : "warn";
|
||||||
|
const result = spawnSync(
|
||||||
|
"pnpm",
|
||||||
|
["exec", "tsdown", "--config-loader", "unrun", "--logLevel", logLevel],
|
||||||
|
{
|
||||||
|
stdio: "inherit",
|
||||||
|
shell: process.platform === "win32",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (typeof result.status === "number") {
|
||||||
|
process.exit(result.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
@@ -4,6 +4,42 @@ const env = {
|
|||||||
NODE_ENV: "production",
|
NODE_ENV: "production",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function buildInputOptions(options: { onLog?: unknown; [key: string]: unknown }) {
|
||||||
|
if (process.env.OPENCLAW_BUILD_VERBOSE === "1") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const previousOnLog = typeof options.onLog === "function" ? options.onLog : undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...options,
|
||||||
|
onLog(
|
||||||
|
level: string,
|
||||||
|
log: { code?: string },
|
||||||
|
defaultHandler: (level: string, log: { code?: string }) => void,
|
||||||
|
) {
|
||||||
|
if (log.code === "PLUGIN_TIMINGS") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof previousOnLog === "function") {
|
||||||
|
previousOnLog(level, log, defaultHandler);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
defaultHandler(level, log);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function nodeBuildConfig(config: Record<string, unknown>) {
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
env,
|
||||||
|
fixedExtension: false,
|
||||||
|
platform: "node",
|
||||||
|
inputOptions: buildInputOptions,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const pluginSdkEntrypoints = [
|
const pluginSdkEntrypoints = [
|
||||||
"index",
|
"index",
|
||||||
"core",
|
"core",
|
||||||
@@ -52,32 +88,20 @@ const pluginSdkEntrypoints = [
|
|||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export default defineConfig([
|
export default defineConfig([
|
||||||
{
|
nodeBuildConfig({
|
||||||
entry: "src/index.ts",
|
entry: "src/index.ts",
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
nodeBuildConfig({
|
||||||
platform: "node",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entry: "src/entry.ts",
|
entry: "src/entry.ts",
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
nodeBuildConfig({
|
||||||
platform: "node",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Ensure this module is bundled as an entry so legacy CLI shims can resolve its exports.
|
// Ensure this module is bundled as an entry so legacy CLI shims can resolve its exports.
|
||||||
entry: "src/cli/daemon-cli.ts",
|
entry: "src/cli/daemon-cli.ts",
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
nodeBuildConfig({
|
||||||
platform: "node",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entry: "src/infra/warning-filter.ts",
|
entry: "src/infra/warning-filter.ts",
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
nodeBuildConfig({
|
||||||
platform: "node",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Keep sync lazy-runtime channel modules as concrete dist files.
|
// Keep sync lazy-runtime channel modules as concrete dist files.
|
||||||
entry: {
|
entry: {
|
||||||
"channels/plugins/agent-tools/whatsapp-login":
|
"channels/plugins/agent-tools/whatsapp-login":
|
||||||
@@ -91,27 +115,17 @@ export default defineConfig([
|
|||||||
"line/send": "src/line/send.ts",
|
"line/send": "src/line/send.ts",
|
||||||
"line/template-messages": "src/line/template-messages.ts",
|
"line/template-messages": "src/line/template-messages.ts",
|
||||||
},
|
},
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
...pluginSdkEntrypoints.map((entry) =>
|
||||||
platform: "node",
|
nodeBuildConfig({
|
||||||
},
|
|
||||||
...pluginSdkEntrypoints.map((entry) => ({
|
|
||||||
entry: `src/plugin-sdk/${entry}.ts`,
|
entry: `src/plugin-sdk/${entry}.ts`,
|
||||||
outDir: "dist/plugin-sdk",
|
outDir: "dist/plugin-sdk",
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
),
|
||||||
platform: "node" as const,
|
nodeBuildConfig({
|
||||||
})),
|
|
||||||
{
|
|
||||||
entry: "src/extensionAPI.ts",
|
entry: "src/extensionAPI.ts",
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
nodeBuildConfig({
|
||||||
platform: "node",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entry: ["src/hooks/bundled/*/handler.ts", "src/hooks/llm-slug-generator.ts"],
|
entry: ["src/hooks/bundled/*/handler.ts", "src/hooks/llm-slug-generator.ts"],
|
||||||
env,
|
}),
|
||||||
fixedExtension: false,
|
|
||||||
platform: "node",
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user