chore: remove unneeded deps
This commit is contained in:
parent
d485611692
commit
61d32b727e
6 changed files with 44 additions and 41 deletions
5
.github/workflows/deploy.yml
vendored
5
.github/workflows/deploy.yml
vendored
|
|
@ -21,6 +21,9 @@ jobs:
|
|||
- name: Install deps
|
||||
run: pnpm m i
|
||||
|
||||
- name: Run ESLint
|
||||
run: pnpm lint
|
||||
|
||||
- name: Build plugin(s)
|
||||
run: node ./build.mjs
|
||||
|
||||
|
|
@ -44,4 +47,4 @@ jobs:
|
|||
# Makes it so the md files in the previous step get processed by GitHub Pages
|
||||
enable_jekyll: true
|
||||
# This creates the CNAME file required to host GitHub Pages on a custom domain
|
||||
# cname: example.com
|
||||
# cname: example.com
|
||||
|
|
|
|||
30
build.mjs
30
build.mjs
|
|
@ -24,17 +24,17 @@ for (const plugin of toBuild) {
|
|||
try {
|
||||
await buildPlugin(plugin);
|
||||
} catch (e) {
|
||||
console.error(e.stack || e);
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
console.log("\n" + (
|
||||
failed
|
||||
? "\x1b[31m" + `Failed to build ${failed} plugin(s)"}` + "\x1b[0m"
|
||||
? "\x1b[31m" + `Failed to build ${failed} plugin(s)` + "\x1b[0m"
|
||||
: "\x1b[32m" + "All plugin(s) built successfully!" + "\x1b[0m"
|
||||
));
|
||||
|
||||
|
||||
isWatch && console.log("\nWatching for changes...");
|
||||
|
||||
async function buildPlugin(plugin) {
|
||||
|
|
@ -42,6 +42,7 @@ async function buildPlugin(plugin) {
|
|||
const entry = "index.js";
|
||||
const outPath = `./dist/${plugin}/${entry}`;
|
||||
|
||||
/** @type {import("rollup").RollupOptions} */
|
||||
const options = {
|
||||
input: `./plugins/${plugin}/${manifest.main}`,
|
||||
output: {
|
||||
|
|
@ -49,7 +50,7 @@ async function buildPlugin(plugin) {
|
|||
globals(id) {
|
||||
if (id.startsWith("@vendetta")) return id.substring(1).replace(/\//g, ".");
|
||||
const map = {
|
||||
react: "window.React",
|
||||
react: "window.React"
|
||||
};
|
||||
|
||||
return map[id] || null;
|
||||
|
|
@ -70,18 +71,23 @@ async function buildPlugin(plugin) {
|
|||
commonjs(),
|
||||
esbuild({
|
||||
target: "esnext",
|
||||
supported: {
|
||||
"arrow": false, // arrows are supported but not with async await
|
||||
"class": false,
|
||||
"bigint": false,
|
||||
},
|
||||
minify: true,
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
if (!isWatch) {
|
||||
return await rollup(options).then(async (bundle) => {
|
||||
await bundle.write(options.output);
|
||||
await bundle.close();
|
||||
const bundle = await rollup(options);
|
||||
await bundle.write(options.output);
|
||||
await bundle.close();
|
||||
|
||||
console.log(`${plugin}: ` + "\x1b[32m" + "Build succeed!" + "\x1b[0m");
|
||||
});
|
||||
console.log(`${plugin}: ` + "\x1b[32m" + "Build succeed!" + "\x1b[0m");
|
||||
return;
|
||||
}
|
||||
|
||||
const watcher = watch(options);
|
||||
|
|
@ -89,8 +95,6 @@ async function buildPlugin(plugin) {
|
|||
return await new Promise((resolve, reject) => {
|
||||
watcher.on("event", (event) => {
|
||||
switch (event.code) {
|
||||
case "START":
|
||||
break;
|
||||
case "BUNDLE_END": {
|
||||
event.result.close();
|
||||
|
||||
|
|
@ -105,13 +109,11 @@ async function buildPlugin(plugin) {
|
|||
}
|
||||
case "ERROR":
|
||||
console.error(`${plugin}: ` + "\x1b[31m", "Failed! :(", "\x1b[0m");
|
||||
console.error(event.error.stack);
|
||||
reject(event.error.stack);
|
||||
reject(event.error);
|
||||
break;
|
||||
case "FATAL":
|
||||
console.error(`${plugin}: ` + "\x1b[31m", "Failed! :(", "\x1b[0m");
|
||||
console.error(event.error.stack);
|
||||
reject(event.error.stack);
|
||||
reject(event.error);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
10
package.json
10
package.json
|
|
@ -5,17 +5,13 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^24.0.1",
|
||||
"@rollup/plugin-eslint": "^9.0.3",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@rollup/plugin-typescript": "^11.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
||||
"@typescript-eslint/parser": "^5.51.0",
|
||||
"@types/react": "^18.0.28",
|
||||
"@types/react-native": "^0.70.11",
|
||||
"esbuild": "^0.16.17",
|
||||
"eslint": "^8.34.0",
|
||||
"eslint-plugin-react": "^7.32.2",
|
||||
"rollup": "^3.15.0",
|
||||
"rollup-plugin-esbuild": "^5.0.0",
|
||||
"typescript": "^4.9.5",
|
||||
"vendetta-types": "^2.3.4"
|
||||
"vendetta-types": "^2.3.6"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { showToast } from "@vendetta/ui/toasts";
|
|||
|
||||
import { currentSettings } from ".";
|
||||
import Constants from "./constants";
|
||||
import { flush, initialize } from "./utils";
|
||||
import { initialize } from "./utils";
|
||||
|
||||
const { ScrollView, TouchableOpacity, Text } = ReactNative;
|
||||
const { FormInput, FormDivider, FormSwitchRow, FormText, FormIcon } = Forms;
|
||||
|
|
@ -21,7 +21,6 @@ function UpdateButton() {
|
|||
}
|
||||
|
||||
console.log("Applying settings...");
|
||||
await flush();
|
||||
await initialize();
|
||||
showToast("Settings updated!", getAssetIDByName("Check"));
|
||||
}
|
||||
|
|
@ -31,6 +30,7 @@ function UpdateButton() {
|
|||
</TouchableOpacity>;
|
||||
|
||||
}
|
||||
|
||||
export default function Settings() {
|
||||
const settings = useProxy(storage) as PluginSettings;
|
||||
const navigation = NavigationNative.useNavigation();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import Settings from "./Settings";
|
|||
import { flush, initialize, patchActivityType } from "./utils";
|
||||
|
||||
export const global = {} as {
|
||||
stopped?: boolean,
|
||||
pluginStopped?: boolean,
|
||||
lastActivity?: Activity,
|
||||
updateInterval?: NodeJS.Timer,
|
||||
lastTrackUrl?: string,
|
||||
|
|
@ -26,7 +26,7 @@ export default {
|
|||
onLoad: () => {
|
||||
console.log("Starting last.fm plugin..");
|
||||
global.activityTypeUnpatch = patchActivityType();
|
||||
global.stopped = false;
|
||||
global.pluginStopped = false;
|
||||
|
||||
if (UserStore.getCurrentUser()) {
|
||||
console.log("User is already logged in, initializing...");
|
||||
|
|
@ -40,7 +40,7 @@ export default {
|
|||
onUnload: () => {
|
||||
console.log("Stopping last.fm...");
|
||||
|
||||
global.stopped = true;
|
||||
global.pluginStopped = true;
|
||||
|
||||
flush();
|
||||
global.activityTypeUnpatch?.();
|
||||
|
|
|
|||
|
|
@ -16,11 +16,15 @@ async function fetchLatestScrobble(): Promise<Track> {
|
|||
"extended": "1"
|
||||
}).toString();
|
||||
|
||||
const info = await fetch(`https://ws.audioscrobbler.com/2.0/?${params}`).then(x => {
|
||||
if (!x.ok) throw new Error(`Failed to fetch latest scrobble: ${x.status} ${x.statusText}`);
|
||||
return x.json();
|
||||
});
|
||||
const lastTrack = info.recenttracks?.track?.[0] || Promise.reject(info);
|
||||
const result = await fetch(`https://ws.audioscrobbler.com/2.0/?${params}`);
|
||||
if (!result.ok) throw new Error(`Failed to fetch the latest scrobble: ${result.statusText}`);
|
||||
|
||||
const info = await result.json();
|
||||
|
||||
const lastTrack = info?.recenttracks?.track?.[0];
|
||||
|
||||
if (!lastTrack) throw info;
|
||||
|
||||
return {
|
||||
name: lastTrack.name,
|
||||
artist: lastTrack.artist.name,
|
||||
|
|
@ -47,7 +51,7 @@ async function handleAlbumCover(cover: string): Promise<string> {
|
|||
|
||||
/** Sends the activity details to Discord */
|
||||
async function sendRequest(activity: Activity): Promise<ResultActivity> {
|
||||
if (global.stopped) {
|
||||
if (global.pluginStopped) {
|
||||
console.log("--> Plugin is unloaded, aborting...");
|
||||
global.updateInterval && clearInterval(global.updateInterval);
|
||||
activity = null;
|
||||
|
|
@ -91,7 +95,7 @@ export async function update() {
|
|||
throw new Error("Username is not set");
|
||||
}
|
||||
|
||||
const lastTrack = await fetchLatestScrobble().catch(async function (err) {
|
||||
const lastTrack = await fetchLatestScrobble().catch(async (err) => {
|
||||
verboseLog("--> An error occurred while fetching the last track, aborting...");
|
||||
await clearActivity().catch();
|
||||
throw err;
|
||||
|
|
@ -132,7 +136,7 @@ export async function update() {
|
|||
};
|
||||
}
|
||||
|
||||
const response = await sendRequest(activity).catch(async function (err) {
|
||||
const response = await sendRequest(activity).catch(async (err) => {
|
||||
verboseLog("--> An error occurred while setting the activity");
|
||||
await clearActivity().catch();
|
||||
throw err;
|
||||
|
|
@ -147,6 +151,8 @@ export async function update() {
|
|||
export function flush(): Promise<ResultActivity> {
|
||||
console.log("--> Flushing...");
|
||||
global.lastActivity = null;
|
||||
global.lastTrackUrl = null;
|
||||
|
||||
global.updateInterval && clearInterval(global.updateInterval);
|
||||
|
||||
return clearActivity();
|
||||
|
|
@ -156,14 +162,11 @@ export function flush(): Promise<ResultActivity> {
|
|||
export async function initialize() {
|
||||
console.log("--> Initializing...");
|
||||
|
||||
if (global.stopped) {
|
||||
if (global.pluginStopped) {
|
||||
throw new Error("Plugin is already stopped!");
|
||||
}
|
||||
|
||||
global.lastTrackUrl = null;
|
||||
|
||||
global.updateInterval && clearInterval(global.updateInterval);
|
||||
global.lastActivity && await clearActivity();
|
||||
await flush();
|
||||
|
||||
let tries = 0;
|
||||
|
||||
|
|
@ -182,7 +185,6 @@ export async function initialize() {
|
|||
if (++tries > 3) {
|
||||
console.error("Failed to fetch/set activity 3 times, aborting...");
|
||||
clearInterval(global.updateInterval);
|
||||
global.stopped = true;
|
||||
}
|
||||
}),
|
||||
(currentSettings.timeInterval || Constants.DEFAULT_TIME_INTERVAL) * 1000
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue