Skip to content

Commit

Permalink
Merge branch 'loadEnvEngineInfosに切り出し' into 指定されているVVPPがなかったら確認後にインスト…
Browse files Browse the repository at this point in the history
…ールし、使えるようにするようにする
  • Loading branch information
Hiroshiba committed Oct 29, 2024
2 parents 187cc8a + 6e637ad commit 1627f00
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/backend/browser/contract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadEnvEngineInfos } from "../common/envEngineInfoSchema";
import { loadEnvEngineInfos } from "@/domain/defaultEngine/envEngineInfo";
import { type EngineInfo } from "@/type/preload";

const baseEngineInfo = loadEnvEngineInfos()[0];
Expand Down
1 change: 1 addition & 0 deletions src/backend/common/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
PresetKey,
} from "@/type/preload";
import { ensureNotNullish } from "@/helpers/errorHelper";
import { loadEnvEngineInfos } from "@/domain/defaultEngine/envEngineInfo";

Check failure on line 17 in src/backend/common/ConfigManager.ts

View workflow job for this annotation

GitHub Actions / build-test

Duplicate identifier 'loadEnvEngineInfos'.

Check failure on line 17 in src/backend/common/ConfigManager.ts

View workflow job for this annotation

GitHub Actions / lint

Duplicate identifier 'loadEnvEngineInfos'.

const lockKey = "save";

Expand Down
6 changes: 2 additions & 4 deletions src/backend/electron/manager/engineInfoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import {
} from "@/type/preload";
import { AltPortInfos } from "@/store/type";
import { BaseConfigManager } from "@/backend/common/ConfigManager";
import {
EnvEngineInfo,
loadEnvEngineInfos,
} from "@/backend/common/envEngineInfoSchema";
import { EnvEngineInfo } from "@/backend/common/envEngineInfoSchema";
import { UnreachableError } from "@/type/utility";
import { loadEnvEngineInfos } from "@/domain/defaultEngine/envEngineInfo";

/**
* デフォルトエンジンの情報を取得する
Expand Down
28 changes: 28 additions & 0 deletions src/domain/defaultEngine/envEngineInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* デフォルトエンジンの環境変数関連のモジュール
*/

import { z } from "zod";

import { engineIdSchema } from "@/type/preload";

/** .envに書くデフォルトエンジン情報のスキーマ */
export const envEngineInfoSchema = z.object({
uuid: engineIdSchema,
host: z.string(),
name: z.string(),
executionEnabled: z.boolean(),
executionFilePath: z.string(),
executionArgs: z.array(z.string()),
path: z.string().optional(),
});
export type EnvEngineInfoType = z.infer<typeof envEngineInfoSchema>;

/** 環境変数を経由して.envを読み込む */
export function loadEnvEngineInfos(): EnvEngineInfoType[] {
const defaultEngineInfosEnv =
import.meta.env.VITE_DEFAULT_ENGINE_INFOS ?? "[]";

const envSchema = envEngineInfoSchema.array();
return envSchema.parse(JSON.parse(defaultEngineInfosEnv));
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* デフォルトエンジン関連のモジュール
* デフォルトエンジンの最新情報関連のモジュール
*/

import { z } from "zod";
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/domain/defaultEngine/defaultEngine.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import path from "path";
import fs from "fs";
import { fetchDefaultEngineUpdateInfo } from "@/domain/defaultEngine";
import { fetchDefaultEngineInfos } from "@/domain/defaultEngine/latetDefaultEngine";

Check failure on line 5 in tests/unit/domain/defaultEngine/defaultEngine.node.spec.ts

View workflow job for this annotation

GitHub Actions / build-test

'"@/domain/defaultEngine/latetDefaultEngine"' has no exported member named 'fetchDefaultEngineInfos'. Did you mean 'fetchDefaultEngineUpdateInfo'?

Check failure on line 5 in tests/unit/domain/defaultEngine/defaultEngine.node.spec.ts

View workflow job for this annotation

GitHub Actions / lint

'"@/domain/defaultEngine/latetDefaultEngine"' has no exported member named 'fetchDefaultEngineInfos'. Did you mean 'fetchDefaultEngineUpdateInfo'?

const currentDir = "tests/unit/domain/defaultEngine";

Expand Down

0 comments on commit 1627f00

Please sign in to comment.