From 0e7f127ece7c12d0266131605ebdfd6d0998cdb2 Mon Sep 17 00:00:00 2001
From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com>
Date: Wed, 18 Jan 2023 13:05:49 +1100
Subject: Script to add license preamble to each file. Also, does that. (#935)
* Add script to automatically add license to each file
* Add license preamble to each file.
* Fix existing preamble detection breaking due to line endings. Git :(
* Prevent license from being added to code with other licenses
---
scripts/benchmark/connections.js | 18 +++++++
scripts/benchmark/index.js | 18 +++++++
scripts/benchmark/users.js | 18 +++++++
scripts/changelog.js | 18 +++++++
scripts/client.js | 18 +++++++
scripts/license.js | 60 ++++++++++++++++++++++
scripts/openapi.js | 18 +++++++
scripts/rights.js | 18 +++++++
scripts/schema.js | 36 +++++++------
scripts/stagingMigration/index.js | 18 +++++++
.../maria/1672833135670-staging.js | 18 +++++++
.../mysql/1672833135670-staging.js | 18 +++++++
.../postgres/1672815835837-staging.js | 36 ++++++++-----
scripts/stresstest/index.js | 18 +++++++
scripts/stresstest/src/login/index.js | 18 +++++++
scripts/stresstest/src/message/send.js | 18 +++++++
scripts/stresstest/src/register/index.js | 18 +++++++
scripts/syncronise.js | 18 +++++++
scripts/util/getRouteDescriptions.js | 18 +++++++
scripts/util/licensePreamble.txt | 15 ++++++
scripts/util/walk.js | 37 +++++++++++++
21 files changed, 442 insertions(+), 30 deletions(-)
create mode 100644 scripts/license.js
create mode 100644 scripts/util/licensePreamble.txt
create mode 100644 scripts/util/walk.js
(limited to 'scripts')
diff --git a/scripts/benchmark/connections.js b/scripts/benchmark/connections.js
index 1a30d49f..6e65b8c7 100644
--- a/scripts/benchmark/connections.js
+++ b/scripts/benchmark/connections.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
require("dotenv").config();
const cluster = require("cluster");
const WebSocket = require("ws");
diff --git a/scripts/benchmark/index.js b/scripts/benchmark/index.js
index 37ac5633..e56d6f06 100644
--- a/scripts/benchmark/index.js
+++ b/scripts/benchmark/index.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
require("dotenv").config();
require("./connections");
diff --git a/scripts/benchmark/users.js b/scripts/benchmark/users.js
index bce67bf4..ac927aab 100644
--- a/scripts/benchmark/users.js
+++ b/scripts/benchmark/users.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
require("dotenv").config();
const fetch = require("node-fetch");
const count = Number(process.env.COUNT) || 50;
diff --git a/scripts/changelog.js b/scripts/changelog.js
index bb1799c6..9f564bcd 100644
--- a/scripts/changelog.js
+++ b/scripts/changelog.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
/*
Changelogs are baked inside the discord.com web client.
To change them, we simply need to update the changelog in a specific file of the client.
diff --git a/scripts/client.js b/scripts/client.js
index 606430be..1ec110b3 100644
--- a/scripts/client.js
+++ b/scripts/client.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
/*
This file downloads a ( mostly ) complete discord.com web client for testing,
and performs some basic patching:
diff --git a/scripts/license.js b/scripts/license.js
new file mode 100644
index 00000000..31321cd1
--- /dev/null
+++ b/scripts/license.js
@@ -0,0 +1,60 @@
+/*
+ Automatically appends our license preamble to each source file.
+ Does not prepend if preamble already exists.
+ Does not replace if change in util/licensePreamble.txt was made.
+ Does not prepend is file contains @fc-license-skip
+*/
+
+const Path = require("path");
+const fs = require("fs");
+const walk = require("./util/walk");
+
+const FOSSCORD_SOURCE_DIR = Path.join(__dirname, "..", "src");
+const FOSSCORD_SCRIPTS_DIR = Path.join(__dirname);
+const FOSSCORD_LICENSE_PREAMBLE = fs
+ .readFileSync(Path.join(__dirname, "util", "licensePreamble.txt"))
+ .toString()
+ .split("\r") // remove windows bs
+ .join("") // ^
+ .split("\n")
+ .map((x) => `\t${x}`)
+ .join("\n");
+
+const languageCommentStrings = {
+ js: ["/*", "*/"],
+ ts: ["/*", "*/"],
+};
+
+const addToDir = (dir) => {
+ const files = walk(dir, Object.keys(languageCommentStrings));
+
+ for (let path of files) {
+ const file = fs.readFileSync(path).toString().split("\r").join("");
+ const fileType = path.slice(path.lastIndexOf(".") + 1);
+ const commentStrings = languageCommentStrings[fileType];
+ if (!commentStrings) continue;
+
+ const preamble =
+ commentStrings[0] +
+ "\n" +
+ FOSSCORD_LICENSE_PREAMBLE +
+ "\n" +
+ commentStrings[1];
+
+ if (file.startsWith(preamble)) {
+ continue;
+ }
+
+ // This is kind of lame.
+ if (file.includes("@fc-license-skip") && path != __filename) {
+ console.log(`skipping ${path} as it has a different license.`);
+ continue;
+ }
+
+ console.log(`writing to ${path}`);
+ fs.writeFileSync(path, preamble + "\n\n" + file);
+ }
+};
+
+addToDir(FOSSCORD_SOURCE_DIR);
+addToDir(FOSSCORD_SCRIPTS_DIR);
diff --git a/scripts/openapi.js b/scripts/openapi.js
index 6f066e94..f280eba4 100644
--- a/scripts/openapi.js
+++ b/scripts/openapi.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
require("module-alias/register");
const getRouteDescriptions = require("./util/getRouteDescriptions");
const path = require("path");
diff --git a/scripts/rights.js b/scripts/rights.js
index 86c8db16..0fbdf128 100644
--- a/scripts/rights.js
+++ b/scripts/rights.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
/*
Calculates a discord.com-like rights value.
*/
diff --git a/scripts/schema.js b/scripts/schema.js
index fedbf25f..be1a7a3f 100644
--- a/scripts/schema.js
+++ b/scripts/schema.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
/*
Regenerates the `fosscord-server/assets/schemas.json` file, used for API/Gateway input validation.
*/
@@ -5,6 +23,7 @@
const path = require("path");
const fs = require("fs");
const TJS = require("typescript-json-schema");
+const walk = require("./util/walk");
const schemaPath = path.join(__dirname, "..", "assets", "schemas.json");
const settings = {
@@ -98,20 +117,3 @@ function main() {
}
main();
-
-function walk(dir) {
- var results = [];
- var list = fs.readdirSync(dir);
- list.forEach(function (file) {
- file = dir + "/" + file;
- var stat = fs.statSync(file);
- if (stat && stat.isDirectory()) {
- /* Recurse into a subdirectory */
- results = results.concat(walk(file));
- } else {
- if (!file.endsWith(".ts")) return;
- results.push(file);
- }
- });
- return results;
-}
diff --git a/scripts/stagingMigration/index.js b/scripts/stagingMigration/index.js
index a1acaabb..505405c8 100644
--- a/scripts/stagingMigration/index.js
+++ b/scripts/stagingMigration/index.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const { DataSourceOptions, DatabaseType, initDatabase } = require("../..");
const path = require("path");
diff --git a/scripts/stagingMigration/maria/1672833135670-staging.js b/scripts/stagingMigration/maria/1672833135670-staging.js
index ce0c1ed8..fc04ba58 100644
--- a/scripts/stagingMigration/maria/1672833135670-staging.js
+++ b/scripts/stagingMigration/maria/1672833135670-staging.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const { MigrationInterface, QueryRunner } = require("typeorm");
module.exports = class staging1672833135670 {
diff --git a/scripts/stagingMigration/mysql/1672833135670-staging.js b/scripts/stagingMigration/mysql/1672833135670-staging.js
index ce0c1ed8..fc04ba58 100644
--- a/scripts/stagingMigration/mysql/1672833135670-staging.js
+++ b/scripts/stagingMigration/mysql/1672833135670-staging.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const { MigrationInterface, QueryRunner } = require("typeorm");
module.exports = class staging1672833135670 {
diff --git a/scripts/stagingMigration/postgres/1672815835837-staging.js b/scripts/stagingMigration/postgres/1672815835837-staging.js
index 675f84ca..64031e5f 100644
--- a/scripts/stagingMigration/postgres/1672815835837-staging.js
+++ b/scripts/stagingMigration/postgres/1672815835837-staging.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const { MigrationInterface, QueryRunner } = require("typeorm");
module.exports = class staging1672815835837 {
@@ -130,22 +148,14 @@ module.exports = class staging1672815835837 {
await queryRunner.query(
`ALTER TABLE "members" ADD "premium_since" bigint`,
);
- await queryRunner.query(
- `ALTER TABLE members ADD theme_colors text`
- );
- await queryRunner.query(
- `ALTER TABLE members ADD pronouns varchar`
- );
+ await queryRunner.query(`ALTER TABLE members ADD theme_colors text`);
+ await queryRunner.query(`ALTER TABLE members ADD pronouns varchar`);
await queryRunner.query(`UPDATE users SET bio = '' WHERE bio IS NULL`);
await queryRunner.query(
`ALTER TABLE users ALTER COLUMN bio SET NOT NULL`,
);
- await queryRunner.query(
- `ALTER TABLE users ADD theme_colors text`
- );
- await queryRunner.query(
- `ALTER TABLE users ADD pronouns varchar`
- );
+ await queryRunner.query(`ALTER TABLE users ADD theme_colors text`);
+ await queryRunner.query(`ALTER TABLE users ADD pronouns varchar`);
await queryRunner.query(
`UPDATE users SET mfa_enabled = false WHERE mfa_enabled IS NULL`,
);
@@ -157,5 +167,5 @@ module.exports = class staging1672815835837 {
);
}
- async down(queryRunner) { }
+ async down(queryRunner) {}
};
diff --git a/scripts/stresstest/index.js b/scripts/stresstest/index.js
index a9a65097..07e17de7 100644
--- a/scripts/stresstest/index.js
+++ b/scripts/stresstest/index.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const register = require("./src/register");
const login = require("./src/login/index");
const config = require("./config.json");
diff --git a/scripts/stresstest/src/login/index.js b/scripts/stresstest/src/login/index.js
index 291e2b8b..fb68c8b2 100644
--- a/scripts/stresstest/src/login/index.js
+++ b/scripts/stresstest/src/login/index.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const fetch = require("node-fetch");
const fs = require("fs");
var config = require("../../config.json");
diff --git a/scripts/stresstest/src/message/send.js b/scripts/stresstest/src/message/send.js
index 1e5ea062..622fc1fb 100644
--- a/scripts/stresstest/src/message/send.js
+++ b/scripts/stresstest/src/message/send.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const fetch = require("node-fetch");
const fs = require("fs");
var config = require("../../config.json");
diff --git a/scripts/stresstest/src/register/index.js b/scripts/stresstest/src/register/index.js
index 38089dc7..4097d854 100644
--- a/scripts/stresstest/src/register/index.js
+++ b/scripts/stresstest/src/register/index.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const fetch = require("node-fetch");
const fs = require("fs");
var config = require("../../config.json");
diff --git a/scripts/syncronise.js b/scripts/syncronise.js
index 38895662..b1658deb 100644
--- a/scripts/syncronise.js
+++ b/scripts/syncronise.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
/*
"Why?" I hear you say! "Why don't you just use `typeorm schema:sync`?"!
Because we have a lot ( like, 30? ) cyclic imports in the entities folder,
diff --git a/scripts/util/getRouteDescriptions.js b/scripts/util/getRouteDescriptions.js
index 21c36ca7..274c0d14 100644
--- a/scripts/util/getRouteDescriptions.js
+++ b/scripts/util/getRouteDescriptions.js
@@ -1,3 +1,21 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
const { traverseDirectory } = require("lambert-server");
const path = require("path");
const express = require("express");
diff --git a/scripts/util/licensePreamble.txt b/scripts/util/licensePreamble.txt
new file mode 100644
index 00000000..f6c70e00
--- /dev/null
+++ b/scripts/util/licensePreamble.txt
@@ -0,0 +1,15 @@
+Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
\ No newline at end of file
diff --git a/scripts/util/walk.js b/scripts/util/walk.js
new file mode 100644
index 00000000..66e98447
--- /dev/null
+++ b/scripts/util/walk.js
@@ -0,0 +1,37 @@
+/*
+ Fosscord: A FOSS re-implementation and extension of the Discord.com backend.
+ Copyright (C) 2023 Fosscord and Fosscord Contributors
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+const fs = require("fs");
+
+/** dir: string. types: string[] ( file types ) */
+module.exports = function walk(dir, types = ["ts"]) {
+ var results = [];
+ var list = fs.readdirSync(dir);
+ list.forEach(function (file) {
+ file = dir + "/" + file;
+ var stat = fs.statSync(file);
+ if (stat && stat.isDirectory()) {
+ /* Recurse into a subdirectory */
+ results = results.concat(walk(file, types));
+ } else {
+ if (!types.find((x) => file.endsWith(x))) return;
+ results.push(file);
+ }
+ });
+ return results;
+};
--
cgit 1.4.1