CI additions and tests
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
name: Testing
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
pull_request:
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Setup repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: oven-sh/setup-bun@v2
|
||||||
|
|
||||||
|
- name: Run linter
|
||||||
|
run: bun ci
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: bun test
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
|
||||||
|
"vcs": {
|
||||||
|
"enabled": true,
|
||||||
|
"clientKind": "git",
|
||||||
|
"useIgnoreFile": true
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"ignoreUnknown": false
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"indentStyle": "tab"
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"javascript": {
|
||||||
|
"formatter": {
|
||||||
|
"quoteStyle": "double"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"assist": {
|
||||||
|
"enabled": true,
|
||||||
|
"actions": {
|
||||||
|
"source": {
|
||||||
|
"organizeImports": "on"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 0,
|
||||||
|
"workspaces": {
|
||||||
|
"": {
|
||||||
|
"name": "mcprofile",
|
||||||
|
"dependencies": {
|
||||||
|
"node-fetch": "^3.3.2",
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "2.3.11",
|
||||||
|
"bun": "^1.3.5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"@biomejs/biome": ["@biomejs/biome@2.3.11", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.3.11", "@biomejs/cli-darwin-x64": "2.3.11", "@biomejs/cli-linux-arm64": "2.3.11", "@biomejs/cli-linux-arm64-musl": "2.3.11", "@biomejs/cli-linux-x64": "2.3.11", "@biomejs/cli-linux-x64-musl": "2.3.11", "@biomejs/cli-win32-arm64": "2.3.11", "@biomejs/cli-win32-x64": "2.3.11" }, "bin": { "biome": "bin/biome" } }, "sha512-/zt+6qazBWguPG6+eWmiELqO+9jRsMZ/DBU3lfuU2ngtIQYzymocHhKiZRyrbra4aCOoyTg/BmY+6WH5mv9xmQ=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.3.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-/uXXkBcPKVQY7rc9Ys2CrlirBJYbpESEDme7RKiBD6MmqR2w3j0+ZZXRIL2xiaNPsIMMNhP1YnA+jRRxoOAFrA=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.3.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-fh7nnvbweDPm2xEmFjfmq7zSUiox88plgdHF9OIW4i99WnXrAC3o2P3ag9judoUMv8FCSUnlwJCM1B64nO5Fbg=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.3.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-l4xkGa9E7Uc0/05qU2lMYfN1H+fzzkHgaJoy98wO+b/7Gl78srbCRRgwYSW+BTLixTBrM6Ede5NSBwt7rd/i6g=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.3.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-XPSQ+XIPZMLaZ6zveQdwNjbX+QdROEd1zPgMwD47zvHV+tCGB88VH+aynyGxAHdzL+Tm/+DtKST5SECs4iwCLg=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.3.11", "", { "os": "linux", "cpu": "x64" }, "sha512-/1s9V/H3cSe0r0Mv/Z8JryF5x9ywRxywomqZVLHAoa/uN0eY7F8gEngWKNS5vbbN/BsfpCG5yeBT5ENh50Frxg=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.3.11", "", { "os": "linux", "cpu": "x64" }, "sha512-vU7a8wLs5C9yJ4CB8a44r12aXYb8yYgBn+WeyzbMjaCMklzCv1oXr8x+VEyWodgJt9bDmhiaW/I0RHbn7rsNmw=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.3.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-PZQ6ElCOnkYapSsysiTy0+fYX+agXPlWugh6+eQ6uPKI3vKAqNp6TnMhoM3oY2NltSB89hz59o8xIfOdyhi9Iw=="],
|
||||||
|
|
||||||
|
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.3.11", "", { "os": "win32", "cpu": "x64" }, "sha512-43VrG813EW+b5+YbDbz31uUsheX+qFKCpXeY9kfdAx+ww3naKxeVkTD9zLIWxUPfJquANMHrmW3wbe/037G0Qg=="],
|
||||||
|
|
||||||
|
"@oven/bun-darwin-aarch64": ["@oven/bun-darwin-aarch64@1.3.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-8GvNtMo0NINM7Emk9cNAviCG3teEgr3BUX9be0+GD029zIagx2Sf54jMui1Eu1IpFm7nWHODuLEefGOQNaJ0gQ=="],
|
||||||
|
|
||||||
|
"@oven/bun-darwin-x64": ["@oven/bun-darwin-x64@1.3.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-r33eHQOHAwkuiBJIwmkXIyqONQOQMnd1GMTpDzaxx9vf9+svby80LZO9Hcm1ns6KT/TBRFyODC/0loA7FAaffg=="],
|
||||||
|
|
||||||
|
"@oven/bun-darwin-x64-baseline": ["@oven/bun-darwin-x64-baseline@1.3.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-p5q3rJk48qhLuLBOFehVc+kqCE03YrswTc6NCxbwsxiwfySXwcAvpF2KWKF/ZZObvvR8hCCvqe1F81b2p5r2dg=="],
|
||||||
|
|
||||||
|
"@oven/bun-linux-aarch64": ["@oven/bun-linux-aarch64@1.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-zkcHPI23QxJ1TdqafhgkXt1NOEN8o5C460sVeNnrhfJ43LwZgtfcvcQE39x/pBedu67fatY8CU0iY00nOh46ZQ=="],
|
||||||
|
|
||||||
|
"@oven/bun-linux-aarch64-musl": ["@oven/bun-linux-aarch64-musl@1.3.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-HKBeUlJdNduRkzJKZ5DXM+pPqntfC50/Hu2X65jVX0Y7hu/6IC8RaUTqpr8FtCZqqmc9wDK0OTL+Mbi9UQIKYQ=="],
|
||||||
|
|
||||||
|
"@oven/bun-linux-x64": ["@oven/bun-linux-x64@1.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-n7zhKTSDZS0yOYg5Rq8easZu5Y/o47sv0c7yGr2ciFdcie9uYV55fZ7QMqhWMGK33ezCSikh5EDkUMCIvfWpjA=="],
|
||||||
|
|
||||||
|
"@oven/bun-linux-x64-baseline": ["@oven/bun-linux-x64-baseline@1.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-FeCQyBU62DMuB0nn01vPnf3McXrKOsrK9p7sHaBFYycw0mmoU8kCq/WkBkGMnLuvQljJSyen8QBTx+fXdNupWg=="],
|
||||||
|
|
||||||
|
"@oven/bun-linux-x64-musl": ["@oven/bun-linux-x64-musl@1.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-XkCCHkByYn8BIDvoxnny898znju4xnW2kvFE8FT5+0Y62cWdcBGMZ9RdsEUTeRz16k8hHtJpaSfLcEmNTFIwRQ=="],
|
||||||
|
|
||||||
|
"@oven/bun-linux-x64-musl-baseline": ["@oven/bun-linux-x64-musl-baseline@1.3.5", "", { "os": "linux", "cpu": "x64" }, "sha512-TJiYC7KCr0XxFTsxgwQOeE7dncrEL/RSyL0EzSL3xRkrxJMWBCvCSjQn7LV1i6T7hFst0+3KoN3VWvD5BinqHA=="],
|
||||||
|
|
||||||
|
"@oven/bun-windows-x64": ["@oven/bun-windows-x64@1.3.5", "", { "os": "win32", "cpu": "x64" }, "sha512-T3xkODItb/0ftQPFsZDc7EAX2D6A4TEazQ2YZyofZToO8Q7y8YT8ooWdhd0BQiTCd66uEvgE1DCZetynwg2IoA=="],
|
||||||
|
|
||||||
|
"@oven/bun-windows-x64-baseline": ["@oven/bun-windows-x64-baseline@1.3.5", "", { "os": "win32", "cpu": "x64" }, "sha512-rtVQB9/1XK8FWJgFtsOthbPifRMYypgJwxu+pK3NHx8WvFKmq7HcPDqNr8xLzGULjQEO7eAo2aOZfONOwYz+5g=="],
|
||||||
|
|
||||||
|
"bun": ["bun@1.3.5", "", { "optionalDependencies": { "@oven/bun-darwin-aarch64": "1.3.5", "@oven/bun-darwin-x64": "1.3.5", "@oven/bun-darwin-x64-baseline": "1.3.5", "@oven/bun-linux-aarch64": "1.3.5", "@oven/bun-linux-aarch64-musl": "1.3.5", "@oven/bun-linux-x64": "1.3.5", "@oven/bun-linux-x64-baseline": "1.3.5", "@oven/bun-linux-x64-musl": "1.3.5", "@oven/bun-linux-x64-musl-baseline": "1.3.5", "@oven/bun-windows-x64": "1.3.5", "@oven/bun-windows-x64-baseline": "1.3.5" }, "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ], "bin": { "bun": "bin/bun.exe", "bunx": "bin/bunx.exe" } }, "sha512-c1YHIGUfgvYPJmLug5QiLzNWlX2Dg7X/67JWu1Va+AmMXNXzC/KQn2lgQ7rD+n1u1UqDpJMowVGGxTNpbPydNw=="],
|
||||||
|
|
||||||
|
"data-uri-to-buffer": ["data-uri-to-buffer@4.0.1", "", {}, "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A=="],
|
||||||
|
|
||||||
|
"fetch-blob": ["fetch-blob@3.2.0", "", { "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" } }, "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ=="],
|
||||||
|
|
||||||
|
"formdata-polyfill": ["formdata-polyfill@4.0.10", "", { "dependencies": { "fetch-blob": "^3.1.2" } }, "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g=="],
|
||||||
|
|
||||||
|
"node-domexception": ["node-domexception@1.0.0", "", {}, "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="],
|
||||||
|
|
||||||
|
"node-fetch": ["node-fetch@3.3.2", "", { "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10" } }, "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA=="],
|
||||||
|
|
||||||
|
"web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="],
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+19
-19
@@ -1,26 +1,26 @@
|
|||||||
export interface JavaUser {
|
export interface JavaUser {
|
||||||
username: string,
|
username: string;
|
||||||
uuid: string,
|
uuid: string;
|
||||||
skin: string,
|
skin: string;
|
||||||
cape: string,
|
cape: string;
|
||||||
linked: boolean,
|
linked: boolean;
|
||||||
bedrock_gamertag?: string,
|
bedrock_gamertag?: string;
|
||||||
bedrock_xuid?: number,
|
bedrock_xuid?: number;
|
||||||
bedrock_fuid?: string
|
bedrock_fuid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BedrockUser {
|
export interface BedrockUser {
|
||||||
gamertag: string,
|
gamertag: string;
|
||||||
xuid: string,
|
xuid: string;
|
||||||
floodgateuid: string,
|
floodgateuid: string;
|
||||||
icon: string,
|
icon: string;
|
||||||
gamescore: string,
|
gamescore: string;
|
||||||
accounttier: string,
|
accounttier: string;
|
||||||
textureid: string,
|
textureid: string;
|
||||||
skin: string,
|
skin: string;
|
||||||
linked: boolean,
|
linked: boolean;
|
||||||
java_uuid?: string,
|
java_uuid?: string;
|
||||||
java_name?: string
|
java_name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const java: {
|
export const java: {
|
||||||
|
|||||||
@@ -1,35 +1,46 @@
|
|||||||
import fetch from 'node-fetch';
|
import fetch from "node-fetch";
|
||||||
const BASE = 'https://mcprofile.io/api/v1';
|
|
||||||
|
const BASE = "https://mcprofile.io/api/v1";
|
||||||
|
|
||||||
export const java = {
|
export const java = {
|
||||||
getPlayerByUsername: async function(username) {
|
getPlayerByUsername: async (username) => {
|
||||||
const response = await fetch(`${BASE}/java/username/${encodeURIComponent(username)}`);
|
const response = await fetch(
|
||||||
if (!response.ok) throw new Error('Failed to fetch profile');
|
`${BASE}/java/username/${encodeURIComponent(username)}`,
|
||||||
|
);
|
||||||
|
if (!response.ok) throw new Error("Failed to fetch profile");
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
getPlayerByUUID: async function(uuid) {
|
getPlayerByUUID: async (uuid) => {
|
||||||
const response = await fetch(`${BASE}/java/uuid/${encodeURIComponent(uuid)}`);
|
const response = await fetch(
|
||||||
if (!response.ok) throw new Error('Failed to fetch profile');
|
`${BASE}/java/uuid/${encodeURIComponent(uuid)}`,
|
||||||
|
);
|
||||||
|
if (!response.ok) throw new Error("Failed to fetch profile");
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
export const bedrock = {
|
export const bedrock = {
|
||||||
getPlayerByUsername: async function(gamertag) {
|
getPlayerByUsername: async (gamertag) => {
|
||||||
const response = await fetch(`${BASE}/bedrock/gamertag/${encodeURIComponent(gamertag)}`);
|
const response = await fetch(
|
||||||
if (!response.ok) throw new Error('Failed to fetch profile');
|
`${BASE}/bedrock/gamertag/${encodeURIComponent(gamertag)}`,
|
||||||
|
);
|
||||||
|
if (!response.ok) throw new Error("Failed to fetch profile");
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
getPlayerByXUID: async function(xuid) {
|
getPlayerByXUID: async (xuid) => {
|
||||||
const response = await fetch(`${BASE}/bedrock/xuid/${encodeURIComponent(xuid)}`);
|
const response = await fetch(
|
||||||
if (!response.ok) throw new Error('Failed to fetch profile');
|
`${BASE}/bedrock/xuid/${encodeURIComponent(xuid)}`,
|
||||||
|
);
|
||||||
|
if (!response.ok) throw new Error("Failed to fetch profile");
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
getPlayerByFUID: async function(xuid) {
|
getPlayerByFUID: async (fuid) => {
|
||||||
const response = await fetch(`${BASE}/bedrock/fuid/${encodeURIComponent(fuid)}`);
|
const response = await fetch(
|
||||||
if (!response.ok) throw new Error('Failed to fetch profile');
|
`${BASE}/bedrock/fuid/${encodeURIComponent(fuid)}`,
|
||||||
|
);
|
||||||
|
if (!response.ok) throw new Error("Failed to fetch profile");
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
export default {java, bedrock}
|
export default { java, bedrock };
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { expect, test } from "bun:test"
|
||||||
|
import MCProfile from "./index.js";
|
||||||
|
|
||||||
|
test("getPlayerByUsername - Java", async () => {
|
||||||
|
const profile = await MCProfile.java.getPlayerByUsername("Notch");
|
||||||
|
expect(profile.username).toBe("Notch");
|
||||||
|
expect(profile.uuid).toBe("069a79f4-44e9-4726-a5be-fca90e38aaf5");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getPlayerByUUID - Java", async () => {
|
||||||
|
const profile = await MCProfile.java.getPlayerByUUID("069a79f4-44e9-4726-a5be-fca90e38aaf5");
|
||||||
|
expect(profile.username).toBe("Notch");
|
||||||
|
expect(profile.uuid).toBe("069a79f4-44e9-4726-a5be-fca90e38aaf5");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getPlayerByGamertag - Bedrock", async () => {
|
||||||
|
const profile = await MCProfile.bedrock.getPlayerByUsername("Notch");
|
||||||
|
expect(profile.gamertag).toBe("Notch");
|
||||||
|
expect(profile.xuid).toBe("2535453759792258");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getPlayerByXUID - Bedrock", async () => {
|
||||||
|
const profile = await MCProfile.bedrock.getPlayerByXUID("2535453759792258");
|
||||||
|
expect(profile.gamertag).toBe("Notch");
|
||||||
|
expect(profile.xuid).toBe("2535453759792258");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getPlayerByFUID - Bedrock", async () => {
|
||||||
|
const profile = await MCProfile.bedrock.getPlayerByFUID("00000000-0000-0000-0009-01fb54b26482");
|
||||||
|
expect(profile.floodgateuid).toBe("00000000-0000-0000-0009-01fb54b26482");
|
||||||
|
expect(profile.gamertag).toBe("Notch");
|
||||||
|
});
|
||||||
+10
-3
@@ -4,14 +4,17 @@
|
|||||||
"description": "Connect to mcprofile.io",
|
"description": "Connect to mcprofile.io",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"ci": "biome ci",
|
||||||
|
"lint": "biome lint",
|
||||||
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/profilelag/mcprofile.git"
|
"url": "git+https://github.com/profilelag/mcprofile.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"minecraft"
|
"minecraft",
|
||||||
|
"mcprofile"
|
||||||
],
|
],
|
||||||
"author": "Nicholas Keller",
|
"author": "Nicholas Keller",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -23,5 +26,9 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-fetch": "^3.3.2"
|
"node-fetch": "^3.3.2"
|
||||||
},
|
},
|
||||||
"types": "index.d.ts"
|
"types": "index.d.ts",
|
||||||
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "2.3.11",
|
||||||
|
"bun": "^1.3.5"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user