lemmy-js-client/putTypesInIndex.js
Nutomic 646b95907b
Rework image api (#425)
* Adding list reports.

* 0.20.0-reports-combined.0

* Fix comment.

* Use internal tagging.

* 0.20.0-reports-combined.1

* 0.20.0-reports-combined.2

* 0.20.0-reports-combined.3

* Rework image api

* fix

* 0.20.0-image-api-rework.0

* rename

* 0.20.0-image-api-rework.2

* rename params

* 0.20.0-image-api-rework.3

* fix null

* fix upload urls

* 0.20.0-image-api-rework.4

* build full url

* 0.20.0-image-api-rework.5

* remaining upload endpoints

* 0.20.0-image-api-rework.6

* 0.20.0-image-api-rework.7

* Update dependency @types/node to v22.10.5 (#438)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update typescript-eslint monorepo to v8.19.0 (#439)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* add missing endpoints including delete

* 0.20.0-image-api-rework.8

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-01-13 23:29:23 -05:00

39 lines
1,020 B
JavaScript

const fs = require("fs/promises");
const path = require("path");
const exportRegex = /export\s+(?:enum|interface|type)\s+([A-Za-z0-9_]+)/g;
const baseExports = [
'export * from "./http";',
'export {UploadImage} from "./other_types";',
];
async function putTypesInIndex() {
const typeFiles = await fs.readdir(path.resolve("./src/types"));
const exports = [...baseExports];
for (const filename of typeFiles) {
const localExports = [];
const fileText = await fs.readFile(path.resolve(`./src/types/${filename}`));
for (
let match = exportRegex.exec(fileText);
match;
match = exportRegex.exec(fileText)
) {
localExports.push(match[1]);
}
const spacer = localExports.length > 1 ? "\n" : " ";
exports.push(
`export {${spacer}${localExports.join(
",\n",
)}${spacer}} from "./types/${filename.replace(/\..+/, "")}";`,
);
}
fs.writeFile(path.resolve("./src/index.ts"), exports.join("\n"), {
flag: "w",
});
}
putTypesInIndex();