mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 00:37:22 +00:00
Remove some unused files from the repo (#5205)
- .devcontainer: we don't update it, we could keep it if we wanted - .gitpod.yml: we don't need the .gitpod file, if someone uses gitpod they can install deps themself - .helix: the config is out of date as it still uses prettier - scripts/checkCpuModel.js: this script was used for benchmarks but we removed those - scripts/generateMessage.js: this script was used for benchmarks but we removed those - scripts/openApiSchema.js: this is a WIP script that was never finished and the discord open-api spec is preview - .vscode/settings.json: the old tsdk config is deprecated, we now use the new js/ts.tsdk.path config instead
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=20-bullseye
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
|
||||
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||
# ARG EXTRA_NODE_VERSION=10
|
||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||
|
||||
# [Optional] Uncomment if you want to install more global node packages
|
||||
# RUN su node -c "npm install -g <your-package-list -here>"
|
||||
@@ -1,32 +0,0 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/typescript-node
|
||||
{
|
||||
"name": "Node.js & TypeScript",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
// Update 'VARIANT' to pick a Node version: 18, 16, 14.
|
||||
// Append -bullseye or -buster to pin to an OS version.
|
||||
// Use -bullseye variants on local on arm64/Apple Silicon.
|
||||
"args": {
|
||||
"VARIANT": "20-bullseye"
|
||||
}
|
||||
},
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": ["biomejs.biome"]
|
||||
}
|
||||
},
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "yarn install",
|
||||
|
||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "node"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
# This configuration file was automatically generated by Gitpod.
|
||||
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
|
||||
# and commit this file to your remote git repository to share the goodness with others.
|
||||
|
||||
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
|
||||
|
||||
tasks:
|
||||
- init: yarn install && yarn run build && yarn run lint && yarn run build:doc
|
||||
command: yarn run dev
|
||||
@@ -1,24 +0,0 @@
|
||||
[[language]]
|
||||
name = "javascript"
|
||||
formatter = { command = "npx", args = ["prettier", "--parser", "javascript"] }
|
||||
auto-format = true
|
||||
|
||||
[[language]]
|
||||
name = "json"
|
||||
formatter = { command = "npx", args = ["prettier", "--parser", "json"] }
|
||||
auto-format = true
|
||||
|
||||
[[language]]
|
||||
name = "markdown"
|
||||
formatter = { command = "npx", args = ["prettier", "--parser", "markdown"] }
|
||||
auto-format = true
|
||||
|
||||
[[language]]
|
||||
name = "typescript"
|
||||
formatter = { command = "npx", args = ["prettier", "--parser", "typescript"] }
|
||||
auto-format = true
|
||||
|
||||
[[language]]
|
||||
name = "yaml"
|
||||
formatter = { command = "npx", args = ["prettier", "--parser", "yaml"] }
|
||||
auto-format = true
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@
|
||||
"*.ts": "typescript",
|
||||
"*.js": "javascript"
|
||||
},
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"js/ts.tsdk.path": "node_modules/typescript/lib",
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
"editor.quickSuggestions": {
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
|
||||
const hostCpu = os.cpus()[0].model.trim();
|
||||
const targetCpu = await fetch('https://raw.githubusercontent.com/discordeno/discordeno/benchies/cpu')
|
||||
.then(async (res) => await res.text())
|
||||
.then((text) => text.slice(0, -1));
|
||||
console.dir(`host cpu: ${hostCpu} target cpu: ${targetCpu}`);
|
||||
|
||||
let outputFile = fs.readFileSync(process.env.GITHUB_OUTPUT, 'utf8');
|
||||
outputFile += `\nmatch=${hostCpu === targetCpu}`;
|
||||
fs.writeFileSync(process.env.GITHUB_OUTPUT, outputFile, 'utf8');
|
||||
@@ -1,56 +0,0 @@
|
||||
import fs from 'node:fs/promises';
|
||||
|
||||
const benchmarkData = await fetch(`https://raw.githubusercontent.com/discordeno/discordeno/benchies/benchmarksResult/data.js`)
|
||||
.then(async (res) => await res.text())
|
||||
.then((text) => JSON.parse(text.slice(24)));
|
||||
// const commitSha = await fs.readFile('./sha', 'utf-8')
|
||||
const results = JSON.parse(await fs.readFile('./data.json', 'utf-8'));
|
||||
const benchmarks = results.entries.Benchmark;
|
||||
benchmarks.reverse();
|
||||
const compareWithHead = {};
|
||||
const latestBaseBenchmarks = benchmarkData.entries.Benchmark.slice(-1)[0];
|
||||
for (const benchmark of latestBaseBenchmarks.benches) {
|
||||
compareWithHead[benchmark.name] = {
|
||||
[latestBaseBenchmarks.commit.id]: benchmark,
|
||||
};
|
||||
}
|
||||
for (let i = benchmarks.length - 1; i >= 0; i--) {
|
||||
for (const bench of benchmarks[i].benches) {
|
||||
if (compareWithHead[bench.name]) {
|
||||
compareWithHead[bench.name][benchmarks[i].commit.id] = bench;
|
||||
} else {
|
||||
compareWithHead[bench.name] = {
|
||||
[benchmarks[i].commit.id]: bench,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
let message = '<!-- benchmark comment by ci -->\n';
|
||||
message += `## Benchmark\n\n`;
|
||||
message += '<details><summary>Detail results of benchmarks</summary>\n\n';
|
||||
let header1 = `| Benchmark suite | Base (${latestBaseBenchmarks.commit.id}) |`;
|
||||
let header2 = `|-|-|`;
|
||||
const commitIds = benchmarks.map((benchmark) => benchmark.commit.id);
|
||||
const uniqueCommitIds = commitIds.filter((benchmarkCommitId, index) => commitIds.indexOf(benchmarkCommitId) === index);
|
||||
for (const [index, commitId] of uniqueCommitIds.entries()) {
|
||||
header1 += index === 0 ? ` Latest Head (${commitId}) |` : ` ${commitId} |`;
|
||||
header2 += '-|';
|
||||
}
|
||||
message += `${header1}\n`;
|
||||
message += `${header2}\n`;
|
||||
for (const benchName of Object.keys(compareWithHead)) {
|
||||
let benchData = `| ${benchName} |`;
|
||||
benchData += compareWithHead[benchName][latestBaseBenchmarks.commit.id]
|
||||
? ` ${`\`${compareWithHead[benchName][latestBaseBenchmarks.commit.id].value}\` ${
|
||||
compareWithHead[benchName][latestBaseBenchmarks.commit.id].unit
|
||||
} \`${compareWithHead[benchName][latestBaseBenchmarks.commit.id].range}\``} |`
|
||||
: '|';
|
||||
for (const commitId of uniqueCommitIds) {
|
||||
benchData += compareWithHead[benchName][commitId]
|
||||
? ` \`${compareWithHead[benchName][commitId].value}\` ${compareWithHead[benchName][commitId].unit} \`${compareWithHead[benchName][commitId].range}\`|`
|
||||
: '|';
|
||||
}
|
||||
message += `${benchData}\n`;
|
||||
}
|
||||
message += '</details>\n\n';
|
||||
console.log(message.replaceAll('`', '\\`'));
|
||||
@@ -1,126 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
// TODO: replace with fetch of live spec
|
||||
const DISCORD_SPEC = {};
|
||||
|
||||
function schemaRefToName(ref) {
|
||||
if (!ref) return '';
|
||||
return `Discord${ref?.substring(ref.lastIndexOf('/') + 1)}`;
|
||||
}
|
||||
|
||||
function snakeToPascalCase(str) {
|
||||
if (!str.includes('_')) return str;
|
||||
|
||||
let result = '';
|
||||
for (let i = 0, len = str.length; i < len; ++i) {
|
||||
if (str[i] === '_') {
|
||||
result += str[++i].toUpperCase();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
result += str[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function generateFromSpec() {
|
||||
const finalTypings = [];
|
||||
|
||||
for (const [key, schema] of Object.entries(DISCORD_SPEC.components.schemas)) {
|
||||
const interfacey = [`export interface Discord${key} {`];
|
||||
|
||||
if (schema.properties) {
|
||||
for (const [name, property] of Object.entries(schema.properties)) {
|
||||
const type = Array.isArray(property.type) ? property.type : property.type ? [property.type] : undefined;
|
||||
let ref = property.$ref && schemaRefToName(property.$ref);
|
||||
let allOf = property.allOf?.find((a) => a.$ref);
|
||||
if (allOf) {
|
||||
allOf = schemaRefToName(allOf.$ref);
|
||||
}
|
||||
|
||||
const isArray = property.type === 'array';
|
||||
if (isArray) {
|
||||
if (property.items.$ref) ref = schemaRefToName(property.items.$ref);
|
||||
else if (Array.isArray(property.oneOf)) {
|
||||
ref = property.oneOf.map((o) => schemaRefToName(o.$ref)).join(' | ');
|
||||
}
|
||||
}
|
||||
|
||||
if (property.description) {
|
||||
interfacey.push(` /** ${property.description} */`);
|
||||
}
|
||||
|
||||
let cleanType =
|
||||
ref ??
|
||||
allOf ??
|
||||
type
|
||||
?.map((type) =>
|
||||
type === 'integer'
|
||||
? 'number'
|
||||
: type === 'array'
|
||||
? property.items.$ref
|
||||
? `${schemaRefToName(property.items.$ref)}[]`
|
||||
: Array.isArray(property.items.oneOf)
|
||||
? `${property.items.oneOf.map((o) => `${schemaRefToName(o.$ref)}[]`).join(' | ')}`
|
||||
: `unknown[]`
|
||||
: type,
|
||||
)
|
||||
.join(' | ') ??
|
||||
property.oneOf
|
||||
?.map(
|
||||
(o) =>
|
||||
(o.type
|
||||
? o.type === 'integer'
|
||||
? o.enum
|
||||
? o.allOf.map((a) => schemaRefToName(a.$ref)).join(' | ')
|
||||
: 'number'
|
||||
: o.type
|
||||
: undefined) ?? schemaRefToName(o.$ref),
|
||||
)
|
||||
.join(' | ') ??
|
||||
'unknown';
|
||||
|
||||
if (cleanType.startsWith('null | ')) cleanType = cleanType.substring(cleanType.indexOf('|') + 2) + ' | null';
|
||||
interfacey.push(` ${name}${schema.required?.includes(name) ? ':' : '?:'} ${cleanType}`);
|
||||
}
|
||||
} else {
|
||||
// No properties so is enum
|
||||
if (['integer', 'string'].includes(schema.type) && Array.isArray(schema.oneOf)) {
|
||||
const enumm = [`export enum Discord${key} {`];
|
||||
for (const possible of schema.oneOf) {
|
||||
if (possible.description) enumm.push(` /** ${possible.description} */`);
|
||||
// TODO: camel case the title
|
||||
enumm.push(
|
||||
` ${possible.title.includes('-') ? '"' : ''}${snakeToPascalCase(
|
||||
`${possible.title[0].toUpperCase()}${possible.title.substring(1).toLowerCase()}`,
|
||||
)}${possible.title.includes('-') ? '"' : ''} = ${schema.type === 'string' ? '"' : ''}${possible.const}${
|
||||
schema.type === 'string' ? '"' : ''
|
||||
},`,
|
||||
);
|
||||
}
|
||||
enumm.push('}');
|
||||
|
||||
finalTypings.push(enumm.join('\n'));
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log('NO PROPERTIES', key, schema);
|
||||
continue;
|
||||
}
|
||||
|
||||
interfacey.push('}');
|
||||
|
||||
finalTypings.push(interfacey.join('\n'));
|
||||
}
|
||||
|
||||
fs.writeFileSync('./packages/types/src/discord.ts', finalTypings.join('\n\n'), function (err, _result) {
|
||||
if (err) throw err;
|
||||
});
|
||||
}
|
||||
|
||||
generateFromSpec();
|
||||
Reference in New Issue
Block a user