mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
* init map view * switching off 3d buildings when sattelite view is on * rename menu items * upgrading dependencies, adding provider to popups * adding screenshot for map view * fixing readme * next release version
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
/*
|
|
* Copyright (c) 2026 by Christian Kellner.
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
*/
|
|
|
|
import fs from 'fs/promises';
|
|
import path from 'path';
|
|
|
|
const COPYRIGHT = `/*
|
|
* Copyright (c) ${new Date().getFullYear()} by Christian Kellner.
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
*/
|
|
|
|
`;
|
|
|
|
async function getAllFiles(dir = '.') {
|
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
let files = [];
|
|
for (let entry of entries) {
|
|
const fullPath = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue;
|
|
files = files.concat(await getAllFiles(fullPath));
|
|
} else if (fullPath.endsWith('.js') || fullPath.endsWith('.jsx')) {
|
|
files.push(fullPath);
|
|
}
|
|
}
|
|
return files;
|
|
}
|
|
|
|
/* eslint-disable no-console */
|
|
async function addCopyright(files) {
|
|
const oldCopyrightRegex =
|
|
/^(\/\*\n \* Copyright \(c\) \d{4} by Christian Kellner\.\n \* Licensed under Apache-2.0 with Commons Clause and Attribution\/Naming Clause\n \*\/\n\n)+/;
|
|
for (let file of files) {
|
|
try {
|
|
let content = await fs.readFile(file, 'utf8');
|
|
const strippedContent = content.replace(oldCopyrightRegex, '');
|
|
const newContent = COPYRIGHT + strippedContent;
|
|
if (content !== newContent) {
|
|
await fs.writeFile(file, newContent);
|
|
console.log(`Added/Updated copyright in ${file}`);
|
|
}
|
|
} catch (err) {
|
|
console.error(`Error processing ${file}: ${err}`);
|
|
}
|
|
}
|
|
}
|
|
/* eslint-enable no-console */
|
|
|
|
const filesToProcess = process.argv.length > 2 ? process.argv.slice(2) : await getAllFiles();
|
|
await addCopyright(filesToProcess);
|