Skip to content

Commit d28ade8

Browse files
committed
Windows対応処置
WindowsでDockerによるLinuxビルドが通らない問題の修正
1 parent de20f49 commit d28ade8

8 files changed

Lines changed: 834 additions & 742 deletions

frontend/tsconfig.app.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
44
"exclude": ["src/**/__tests__/*"],
55
"compilerOptions": {
6-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
6+
// Extra safety for array and object lookups, but may have false positives.
7+
"noUncheckedIndexedAccess": true,
78

9+
// Path mapping for cleaner imports.
810
"paths": {
911
"@/*": ["./src/*"]
10-
}
12+
},
13+
14+
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
15+
// Specified here to keep it out of the root directory.
16+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo"
1117
}
1218
}

frontend/tsconfig.node.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1+
// TSConfig for modules that run in Node.js environment via either transpilation or type-stripping.
12
{
23
"extends": "@tsconfig/node-lts/tsconfig.json",
34
"include": [
45
"vite.config.*",
56
"vitest.config.*",
67
"cypress.config.*",
7-
"nightwatch.conf.*",
88
"playwright.config.*",
99
"eslint.config.*"
1010
],
1111
"compilerOptions": {
12+
// Most tools use transpilation instead of Node.js's native type-stripping.
13+
// Bundler mode provides a smoother developer experience.
14+
"module": "preserve",
15+
"moduleResolution": "bundler",
16+
17+
// Include Node.js types and avoid accidentally including other `@types/*` packages.
18+
"types": ["node"],
19+
20+
// Disable emitting output during `vue-tsc --build`, which is used for type-checking only.
1221
"noEmit": true,
13-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
1422

15-
"module": "ESNext",
16-
"moduleResolution": "Bundler",
17-
"types": ["node"]
23+
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
24+
// Specified here to keep it out of the root directory.
25+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
1826
}
1927
}

pnpm-lock.yaml

Lines changed: 710 additions & 710 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build-linux-docker.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,21 @@ $PlatformSafe = $Platform -replace '/', '-'
130130
$CargoVolume = "tauri-vue3-cargo-cache-$PlatformSafe"
131131
$PnpmVolume = "tauri-vue3-pnpm-cache-$PlatformSafe"
132132
$TargetVolume = "tauri-vue3-target-cache-$PlatformSafe"
133+
$WorkspaceNodeModulesVolume = "tauri-vue3-workspace-node-modules-$PlatformSafe"
133134
$NodeModulesVolume = "tauri-vue3-node-modules-$PlatformSafe"
134135

135136
# ボリュームが存在しない場合は作成
136137
docker volume create $CargoVolume 2>&1 | Out-Null
137138
docker volume create $PnpmVolume 2>&1 | Out-Null
138139
docker volume create $TargetVolume 2>&1 | Out-Null
140+
docker volume create $WorkspaceNodeModulesVolume 2>&1 | Out-Null
139141
docker volume create $NodeModulesVolume 2>&1 | Out-Null
140142

141143
Write-Host "キャッシュボリューム:" -ForegroundColor Green
142144
Write-Host " - Cargo: $CargoVolume"
143145
Write-Host " - pnpm: $PnpmVolume"
144146
Write-Host " - Target: $TargetVolume"
147+
Write-Host " - Workspace node_modules: $WorkspaceNodeModulesVolume"
145148
Write-Host " - Node modules: $NodeModulesVolume (ホスト環境から完全に分離)"
146149
Write-Host ""
147150

@@ -156,6 +159,7 @@ $runArgs = @(
156159
"-v", "${CargoVolume}:/root/.cargo/registry",
157160
"-v", "${PnpmVolume}:/pnpm/store",
158161
"-v", "${TargetVolume}:/workspace/backend/target",
162+
"-v", "${WorkspaceNodeModulesVolume}:/workspace/node_modules",
159163
"-v", "${NodeModulesVolume}:/workspace/frontend/node_modules",
160164
"-e", "BUILD_TARGET=$BuildTarget",
161165
"-e", "APPIMAGE_EXTRACT_AND_RUN=1",

scripts/build-linux-docker.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,21 @@ echo -e "${BLUE}🔨 Linux向けアプリケーションをビルド中...${NC}"
146146
CARGO_CACHE_VOLUME="tauri-vue3-cargo-cache-${PLATFORM//\//-}"
147147
PNPM_CACHE_VOLUME="tauri-vue3-pnpm-cache-${PLATFORM//\//-}"
148148
TARGET_CACHE_VOLUME="tauri-vue3-target-cache-${PLATFORM//\//-}"
149+
WORKSPACE_NODE_MODULES_VOLUME="tauri-vue3-workspace-node-modules-${PLATFORM//\//-}"
149150
NODE_MODULES_VOLUME="tauri-vue3-node-modules-${PLATFORM//\//-}"
150151

151152
# ボリュームが存在しない場合は作成
152153
docker volume create "$CARGO_CACHE_VOLUME" >/dev/null 2>&1 || true
153154
docker volume create "$PNPM_CACHE_VOLUME" >/dev/null 2>&1 || true
154155
docker volume create "$TARGET_CACHE_VOLUME" >/dev/null 2>&1 || true
156+
docker volume create "$WORKSPACE_NODE_MODULES_VOLUME" >/dev/null 2>&1 || true
155157
docker volume create "$NODE_MODULES_VOLUME" >/dev/null 2>&1 || true
156158

157159
echo -e "${GREEN}キャッシュボリューム:${NC}"
158160
echo " - Cargo: $CARGO_CACHE_VOLUME"
159161
echo " - pnpm: $PNPM_CACHE_VOLUME"
160162
echo " - Target: $TARGET_CACHE_VOLUME"
163+
echo " - Workspace node_modules: $WORKSPACE_NODE_MODULES_VOLUME"
161164
echo " - Node modules: $NODE_MODULES_VOLUME (ホスト環境から完全に分離)"
162165
echo ""
163166

@@ -174,6 +177,7 @@ docker run --rm \
174177
-v "$CARGO_CACHE_VOLUME:/root/.cargo/registry" \
175178
-v "$PNPM_CACHE_VOLUME:/pnpm/store" \
176179
-v "$TARGET_CACHE_VOLUME:/workspace/backend/target" \
180+
-v "$WORKSPACE_NODE_MODULES_VOLUME:/workspace/node_modules" \
177181
-v "$NODE_MODULES_VOLUME:/workspace/frontend/node_modules" \
178182
-e BUILD_TARGET="$TARGET" \
179183
-e TAURI_BUNDLER_TARGETS="$BUNDLE_TARGETS" \

scripts/ensure-frontend-dev.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { spawn } from "node:child_process";
2+
3+
const devUrl = process.env.TAURI_DEV_URL ?? "http://localhost:1420/";
4+
5+
async function isDevServerUp(url) {
6+
const controller = new AbortController();
7+
const timeoutId = setTimeout(() => controller.abort(), 1500);
8+
9+
try {
10+
const response = await fetch(url, {
11+
method: "GET",
12+
signal: controller.signal,
13+
});
14+
return response.ok;
15+
} catch {
16+
return false;
17+
} finally {
18+
clearTimeout(timeoutId);
19+
}
20+
}
21+
22+
if (await isDevServerUp(devUrl)) {
23+
console.log(`Frontend dev server is already running: ${devUrl}`);
24+
process.exit(0);
25+
}
26+
27+
console.log(`Starting frontend dev server: ${devUrl}`);
28+
const command =
29+
process.platform === "win32"
30+
? ["cmd.exe", ["/d", "/s", "/c", "pnpm --filter frontend dev"]]
31+
: ["pnpm", ["--filter", "frontend", "dev"]];
32+
33+
const child = spawn(command[0], command[1], {
34+
stdio: "inherit",
35+
shell: false,
36+
});
37+
38+
function shutdown(signal) {
39+
if (child.exitCode === null) {
40+
child.kill(signal);
41+
}
42+
}
43+
44+
process.on("SIGINT", () => shutdown("SIGINT"));
45+
process.on("SIGTERM", () => shutdown("SIGTERM"));
46+
47+
child.on("exit", (code) => {
48+
process.exit(code ?? 0);
49+
});

scripts/run-tauri-build.mjs

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
1-
import { spawnSync } from "node:child_process";
1+
import { execSync } from "node:child_process";
22
import { dirname, resolve } from "node:path";
33
import { fileURLToPath } from "node:url";
4-
import { syncTauriConfigFromEnv } from "./sync-tauri-config-from-env.mjs";
54

65
const scriptDir = dirname(fileURLToPath(import.meta.url));
76
const repoRoot = resolve(scriptDir, "..");
8-
const extraArgs = process.argv.slice(2);
9-
10-
const syncResult = syncTauriConfigFromEnv(repoRoot);
11-
console.log("Synced Tauri config from .env");
12-
console.log(` version=${syncResult.version}`);
13-
console.log(` identifier=${syncResult.identifier}`);
7+
const tauriConfigPath = resolve(repoRoot, "backend", "tauri.conf.json");
8+
const tauriBin = resolve(
9+
repoRoot,
10+
"frontend",
11+
"node_modules",
12+
".bin",
13+
process.platform === "win32" ? "tauri.cmd" : "tauri",
14+
);
15+
const extraArgs = process.argv.slice(2).join(" ");
1416

15-
const tauriBinary =
16-
process.platform === "win32"
17-
? resolve(repoRoot, "frontend/node_modules/.bin/tauri.cmd")
18-
: resolve(repoRoot, "frontend/node_modules/.bin/tauri");
17+
process.chdir(repoRoot);
1918

20-
const result = spawnSync(
21-
tauriBinary,
22-
["build", "--config", "backend/tauri.conf.json", ...extraArgs],
23-
{
24-
cwd: repoRoot,
19+
try {
20+
execSync(`"${tauriBin}" build --config "${tauriConfigPath}" ${extraArgs}`, {
2521
stdio: "inherit",
2622
env: process.env,
27-
shell: false,
28-
},
29-
);
30-
31-
if (result.error) {
32-
console.error(result.error.message);
23+
shell: true,
24+
});
25+
process.exit(0);
26+
} catch {
3327
process.exit(1);
3428
}
35-
36-
process.exit(result.status ?? 1);

scripts/run-tauri-dev-mode.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { execSync } from "node:child_process";
2+
import { dirname, resolve } from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
5+
const scriptDir = dirname(fileURLToPath(import.meta.url));
6+
const repoRoot = resolve(scriptDir, "..");
7+
const bootMode = process.argv[2] ?? "full";
8+
const mainContentMode = process.argv[3] ?? "";
9+
const safeBoot = process.argv[4] ?? "";
10+
11+
const env = {
12+
...process.env,
13+
VITE_BOOT_MODE: bootMode,
14+
};
15+
16+
if (mainContentMode) {
17+
env.VITE_MAIN_CONTENT_MODE = mainContentMode;
18+
}
19+
20+
if (safeBoot) {
21+
env.VITE_SAFE_BOOT = safeBoot;
22+
}
23+
24+
process.chdir(resolve(repoRoot, "frontend"));
25+
execSync("pnpm run dev:tauri", {
26+
stdio: "inherit",
27+
env,
28+
shell: true,
29+
});

0 commit comments

Comments
 (0)