1
0
mirror of https://github.com/barthuijgen/factorio-sites.git synced 2025-02-01 13:27:43 +02:00

Merge branch 'master' into develop

This commit is contained in:
Bart Huijgen 2022-11-14 11:48:43 +01:00
commit 5f12a98601
9 changed files with 21 additions and 19 deletions

View File

@ -29,7 +29,7 @@ jobs:
env: env:
CF_WEB_ANALYTICS: 6c563c1e5db141129a5fc95d5c459722 CF_WEB_ANALYTICS: 6c563c1e5db141129a5fc95d5c459722
- name: Set up Cloud SDK - name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master uses: google-github-actions/setup-gcloud@v1
with: with:
project_id: ${{ secrets.GCP_PROJECT_ID }} project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }} service_account_key: ${{ secrets.GCP_SA_KEY }}

View File

@ -29,15 +29,15 @@ jobs:
env: env:
PUBLIC_URL: https://factorio-blueprints-assets.storage.googleapis.com/public PUBLIC_URL: https://factorio-blueprints-assets.storage.googleapis.com/public
CF_WEB_ANALYTICS: 4a7b06ea5bdb4d328a1baea602aea295 CF_WEB_ANALYTICS: 4a7b06ea5bdb4d328a1baea602aea295
- name: Set up Cloud SDK - name: Authenticate gcloud
uses: google-github-actions/setup-gcloud@master uses: google-github-actions/auth@v1
with: with:
project_id: ${{ secrets.GCP_PROJECT_ID }} credentials_json: "${{ secrets.GCP_SA_KEY }}"
service_account_key: ${{ secrets.GCP_SA_KEY }} - name: Set up Cloud SDK
export_default_credentials: true uses: google-github-actions/setup-gcloud@v1
- run: gcloud auth configure-docker --quiet - run: gcloud auth configure-docker --quiet
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v3
with: with:
context: . context: .
file: blueprints.github.Dockerfile file: blueprints.github.Dockerfile

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/* eslint-disable import/first */ /* eslint-disable @typescript-eslint/no-explicit-any, import/first */
jest.mock("next/config", () => () => ({ jest.mock("next/config", () => () => ({
publicRuntimeConfig: {}, publicRuntimeConfig: {},
})); }));
@ -6,16 +6,15 @@ jest.mock("next/config", () => () => ({
import { render } from "@testing-library/react"; import { render } from "@testing-library/react";
import Index from "../src/pages/index"; import Index from "../src/pages/index";
import * as nextRouter from "next/router"; import * as nextRouter from "next/router";
import { NextRouter } from "next/router";
const useRouter = jest.spyOn(nextRouter, "useRouter"); const useRouter = jest.spyOn(nextRouter, "useRouter");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(global as any).fetch = jest.fn(() => Promise.resolve()); (global as any).fetch = jest.fn(() => Promise.resolve());
console.error = jest.fn(); console.error = jest.fn();
describe("Index", () => { describe("Index", () => {
it("should render successfully", () => { it("should render successfully", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any useRouter.mockImplementation(() => ({ query: {} } as NextRouter));
useRouter.mockImplementationOnce(() => ({ query: {} } as any));
const { baseElement } = render( const { baseElement } = render(
<Index totalItems={0} currentPage={0} totalPages={0} blueprints={[]} /> <Index totalItems={0} currentPage={0} totalPages={0} blueprints={[]} />

View File

@ -90,6 +90,7 @@ export const ImageEditor: React.FC<ImageEditorProps> = ({ string, onError }) =>
// const picture = await editor.getPicture(); // const picture = await editor.getPicture();
// setImage(URL.createObjectURL(picture)); // setImage(URL.createObjectURL(picture));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (reason: any) { } catch (reason: any) {
setRenderError(true); setRenderError(true);
if (onError) onError(); if (onError) onError();

View File

@ -66,7 +66,9 @@ export const useFbeData = (): FactorioData | null => {
useEffect(() => { useEffect(() => {
(async () => { (async () => {
if (!fbeDataState.value) { if (!fbeDataState.value) {
const result = await fetch("/api/fbe-proxy/data.json") const result = await fetch(
"https://storage.googleapis.com/factorio-blueprints-fbe-assets/data.json"
)
.then((res) => res.json()) .then((res) => res.json())
.catch(() => { .catch(() => {
console.error("Failed to fetch data.json"); console.error("Failed to fetch data.json");

View File

@ -14,7 +14,7 @@ export const useFetch = <T>(
const data = dataState.nested(url).value; const data = dataState.nested(url).value;
const [loading, setLoading] = useState(() => !data && !skip); const [loading, setLoading] = useState(() => !data && !skip);
const [error, setError] = useState(null); const [error, setError] = useState<Error | null>(null);
useEffect(() => { useEffect(() => {
if (!url || data || skip) return; if (!url || data || skip) return;
@ -25,8 +25,8 @@ export const useFetch = <T>(
const response = await fetch(url); const response = await fetch(url);
const data = await response.json(); const data = await response.json();
dataState.nested(url).set(data); dataState.nested(url).set(data);
} catch (error: any) { } catch (error: unknown) {
setError(error); setError(error as Error);
} }
setLoading(false); setLoading(false);
}; };

View File

@ -47,8 +47,8 @@ export const fetchSteamProfile = async (steam_id: string, api_key: string) => {
} else { } else {
throw Error("No players found for the given SteamID."); throw Error("No players found for the given SteamID.");
} }
} catch (error: any) { } catch (error: unknown) {
throw Error("Steam server error: " + error.message); throw Error("Steam server error: " + (error as Error).message);
} }
}; };