跳到主要内容

版权标头管理

本项目通过自定义脚本,自动为所有 TypeScript/JavaScript 源文件添加版权标头。

版权标头

frontend/srcbackend/src 目录中的所有源文件(.ts.tsx.js.jsx)都会自动添加以下标头:

/*
* 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

此命令会:

  1. 运行标头添加脚本
  2. 使用 Prettier 格式化所有文件

手动添加标头

也可以在不格式化的情况下手动添加标头:

npm run add-headers

智能标头检测

脚本会:

  • ✅ 为没有标头的文件添加标头
  • ✅ 跳过已有版权标头的文件
  • ✅ 忽略配置文件、构建输出和依赖项
  • ✅ 仅处理 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 的格式化工作流中。