Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

develop 동기화 #123

Merged
merged 14 commits into from
Sep 28, 2024
72 changes: 51 additions & 21 deletions addLicense.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/**
* @license
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* All contributors who participated in development before September 26, 2024, retain full copyright over their contributions.
* These contributors are granted the right, under a Contributor License Agreement (CLA), to use, modify, and distribute their contributions
* under additional or alternative licensing terms of their choosing, while the project as a whole remains licensed under the MPL 2.0.
*
* Any contributions made after September 26, 2024, are subject to the terms of the MPL 2.0 and are licensed accordingly.
*/

const fs = require("fs");
const path = require("path");

const licenseText = `/**
const LICENSE_TEXT = `/**
* @license
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
Expand All @@ -14,34 +26,52 @@ const licenseText = `/**
*/
`;

const directoryPath = path.join(__dirname, "src");
const UNIQUE_LICENSE_STRING = "This Source Code Form";
const TARGET_EXTENSIONS = [".ts", ".tsx"];
const MAX_FILE_CONTENT_PREVIEW = 100;

function hasLicense(fileContent) {
return fileContent.slice(0, MAX_FILE_CONTENT_PREVIEW).includes(UNIQUE_LICENSE_STRING);
}

function prependLicense(filePath) {
try {
const fileContent = fs.readFileSync(filePath, "utf8").trim();

function addLicenseToFile(filePath) {
const fileContent = fs.readFileSync(filePath, "utf8");
if (!fileContent.startsWith("/* This Source Code Form")) {
const newContent = licenseText + "\n" + fileContent;
fs.writeFileSync(filePath, newContent, "utf8");
console.log(`License added to: ${filePath}`);
} else {
console.log(`License already present in: ${filePath}`);
if (!hasLicense(fileContent)) {
const updatedContent = LICENSE_TEXT + "\n" + fileContent;
fs.writeFileSync(filePath, updatedContent, "utf8");
console.log(`License added to: ${filePath}`);
} else {
console.log(`License already present in: ${filePath}`);
}
} catch (err) {
console.error(`Error processing file: ${filePath} - ${err.message}`);
}
}

function processDirectory(directory) {
fs.readdir(directory, (err, files) => {
if (err) return;
try {
const items = fs.readdirSync(directory);

files.forEach((file) => {
const filePath = path.join(directory, file);
const stat = fs.statSync(filePath);
items.forEach((item) => {
const itemPath = path.join(directory, item);
const stat = fs.statSync(itemPath);

if (stat.isDirectory() && file !== "node_modules") {
processDirectory(filePath);
} else if (file.endsWith(".ts") || file.endsWith(".tsx")) {
addLicenseToFile(filePath);
if (stat.isDirectory() && item !== "node_modules") {
processDirectory(itemPath);
} else if (TARGET_EXTENSIONS.some((ext) => item.endsWith(ext))) {
prependLicense(itemPath);
}
});
});
} catch (err) {
console.error(`Error processing directory: ${directory} - ${err.message}`);
}
}

function main() {
const srcDirectory = path.join(__dirname, "src");
processDirectory(srcDirectory);
}

processDirectory(directoryPath);
main();
142 changes: 71 additions & 71 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ export function Footer() {
<Link to={"/makers"}>
<FooterLogo className={styles.footerLogo} />
</Link>
<a
href="https://docs.google.com/forms/d/1faPr7Csw59XleXz56_oYiU4raGi44BV-2aT7OLhrVJw/"
target="_blank"
rel="noopener noreferrer"
className={styles.inquiryLink}
>
사이트 문의
</a>
<Link to={"/site_info"} className={styles.inquiryLink}>
사이트 정보
</Link>
</div>
<p className={styles.footerText}>
COPYRIGHT Ⓒ 2024 LIKELION KANGWON NATIONAL UNIV. ALL RIGHTS RESERVED.
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Header from "../Header";
import { Footer } from "../Footer";
import ScrollToTop from "./scrollContol";

// TODO: 모든 페이지에 공통으로 들어가는 레이아웃을 작성합니다. 필요 없으면 삭제해주세요
// 모든 페이지에 공통으로 들어가는 레이아웃을 작성합니다.
export default function Layout() {
return (
<div>
Expand Down
Loading