diff --git a/package.json b/package.json index e56a22347..c208b3772 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,6 @@ "package": "svelte-kit package", "preview": "svelte-kit preview", "prepare": "svelte-kit sync", - "generate": "node scripts/generate.cjs", - "generate:watch": "nodemon --watch app --watch libs app/server.js", "check": "svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", "lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", diff --git a/src/package/plugins/generator/index.js b/src/package/plugins/generator/index.js index 08e655055..e34c1986e 100644 --- a/src/package/plugins/generator/index.js +++ b/src/package/plugins/generator/index.js @@ -4,10 +4,10 @@ import { projectColors } from './outputs/projectColors.js'; import { gameVersions } from './outputs/gameVersions.js'; import { tags } from './outputs/tags.js'; -const API_URL = 'https://api.modrinth.com/v2/'; //TODO Remove -process.env.VITE_API_URL || process.env?.NODE_ENV === 'development' - ? 'https://staging-api.modrinth.com/v2/' - : 'https://api.modrinth.com/v2/'; +const API_URL = + process.env.VITE_API_URL || process.env?.NODE_ENV === 'development' + ? 'https://staging-api.modrinth.com/v2/' + : 'https://api.modrinth.com/v2/'; // Time to live: 7 days const TTL = 7 * 24 * 60 * 60 * 1000; @@ -33,6 +33,7 @@ export default function Generator(options) { ) ); } + // Don't generate if the last generation was less than TTL and the options are the same if ( state?.lastGenerated && diff --git a/src/package/plugins/generator/outputs/tags.js b/src/package/plugins/generator/outputs/tags.js index 40616042d..fe84a83c0 100644 --- a/src/package/plugins/generator/outputs/tags.js +++ b/src/package/plugins/generator/outputs/tags.js @@ -19,11 +19,6 @@ export async function tags(API_URL) { ]); progressBar.update(4); - // Delete icons from original arrays - categories = categories.map(({ icon, ...rest }) => rest); - loaders = loaders.map(({ icon, ...rest }) => rest); - progressBar.increment(); - // Create single object with icons const tagIcons = { ...categories.reduce((a, v) => ({ ...a, [v.name]: v.icon }), {}), @@ -31,6 +26,11 @@ export async function tags(API_URL) { }; progressBar.increment(); + // Delete icons from original arrays + categories = categories.map(({ icon, ...rest }) => rest); + loaders = loaders.map(({ icon, ...rest }) => rest); + progressBar.increment(); + // Set project types const projectTypes = ['mod', 'modpack'];