feat(insight): enhance template loading logic and add insight templates copying

This commit is contained in:
DragonnZhang 2026-02-02 11:01:51 +08:00
parent 338387f93a
commit 7e21ba4983
3 changed files with 62 additions and 43 deletions

View file

@ -17,11 +17,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { copyFileSync, existsSync, mkdirSync, statSync } from 'node:fs';
import {
copyFileSync,
existsSync,
mkdirSync,
statSync,
readdirSync,
chmodSync,
} from 'node:fs';
import { dirname, join, basename } from 'node:path';
import { fileURLToPath } from 'node:url';
import { glob } from 'glob';
import fs from 'node:fs';
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = join(__dirname, '..');
@ -56,7 +62,7 @@ console.log('\n✅ All bundle assets copied to dist/');
/**
* Recursively copy directory
*/
function copyRecursiveSync(src, dest) {
export function copyRecursiveSync(src, dest) {
if (!existsSync(src)) {
return;
}
@ -68,7 +74,7 @@ function copyRecursiveSync(src, dest) {
mkdirSync(dest, { recursive: true });
}
const entries = fs.readdirSync(src);
const entries = readdirSync(src);
for (const entry of entries) {
// Skip .DS_Store files
if (entry === '.DS_Store') {
@ -84,7 +90,7 @@ function copyRecursiveSync(src, dest) {
// Preserve execute permissions for binaries
const srcStats = statSync(src);
if (srcStats.mode & 0o111) {
fs.chmodSync(dest, srcStats.mode);
chmodSync(dest, srcStats.mode);
}
}
}