การจัดการส่วนหัวลิขสิทธิ์
โปรเจกต์นี้เพิ่มส่วนหัวลิขสิทธิ์ให้ไฟล์ต้นฉบับ TypeScript/JavaScript ทั้งหมดโดยอัตโนมัติด้วยสคริปต์เฉพาะ
ส่วนหัวลิขสิทธิ์
ไฟล์ต้นฉบับทั้งหมด (.ts, .tsx, .js, .jsx) ในไดเรกทอรี frontend/src และ backend/src จะได้รับส่วนหัวลิขสิทธิ์ต่อไปนี้โดยอัตโนมัติ:
/*
* Libre WebUI
* Copyright (C) 2025 Kroonen AI, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
การใช้งาน
เพิ่มส่วนหัวอัตโนมัติ
ส่วนหัวลิขสิทธิ์จะถูกเพิ่มโดยอัตโนมัติเมื่อรัน:
npm run format
คำสั่งนี้จะ:
- รันสคริปต์เพิ่มส่วนหัว
- จัดรูปแบบไฟล์ทั้งหมดด้วย Prettier
เพิ่มส่วนหัวด้วยตนเอง
คุณสามารถเพิ่มส่วนหัวด้วยตนเองโดยไม่จัดรูปแบบได้เช่นกัน:
npm run add-headers
ตรวจหาส่วนหัวอย่างชาญฉลาด
สคริปต์จะ:
- ✅ เพิ่มส่วนหัวให้ไฟล์ที่ยังไม่มี
- ✅ ข้ามไฟล์ที่มีส่วนหัวลิขสิทธิ์แล้ว
- ✅ ไม่สนใจไฟล์กำหนดค่า ผลลัพธ์ build และ dependency
- ✅ ประมวลผลเฉพาะไฟล์ต้นฉบับ TypeScript/JavaScript
ไฟล์/ไดเรกทอรีที่ไม่ประมวลผล
รายการต่อไปนี้จะถูกข้ามโดยอัตโนมัติ:
node_modules/dist/build/coverage/public/- ไฟล์กำหนดค่า (
*.config.js,*.config.ts) - ไฟล์นิยามชนิด (
vite-env.d.ts) - การกำหนดค่า ESLint (
eslint.config.js)
การนำไปใช้
การจัดการส่วนหัวอยู่ใน /scripts/add-headers.js และผสานกับขั้นตอนจัดรูปแบบใน package.json