Skip to content

Commit

Permalink
Merge pull request #122 from jjh4450/feat/time-table-demo
Browse files Browse the repository at this point in the history
Feat/time table demo
  • Loading branch information
jjh4450 authored Sep 28, 2024
2 parents 48ca206 + 86aaffe commit 32f8e64
Show file tree
Hide file tree
Showing 14 changed files with 618 additions and 119 deletions.
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

1 comment on commit 32f8e64

@vercel
Copy link

@vercel vercel bot commented on 32f8e64 Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.