Skip to content

fix a few windows path issues #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/olive-lemons-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

Fix multiple Windows path issues.
27 changes: 27 additions & 0 deletions .github/actions/setup-playwright/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Setup Playwright"
description: "Setup Playwright with caching"

runs:
using: "composite"
steps:
- name: Put $HOME in env
if: runner.os == 'windows'
shell: pwsh
run: echo "HOME=$HOME" | Out-File -FilePath $env:GITHUB_ENV -Append

- name: Cache Playwright
id: playwright-cache
uses: actions/cache@v4
with:
path: ${{ runner.os == 'Windows' && format('{0}{1}', env.HOME, '\AppData\Local\ms-playwright') || runner.os == 'Linux' && '~/.cache/ms-playwright' || '~/Library/Caches/ms-playwright' }}
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}

- name: Install Playwright with dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: pnpm playwright install --with-deps

- name: Install Playwright's dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
shell: bash
run: pnpm playwright install-deps
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: ./.github/actions/install-dependencies

- name: Install Playwright
run: pnpm run install-playwright
uses: ./.github/actions/setup-playwright

- name: Build the tool
run: pnpm build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.
import { patchCode } from "@opennextjs/aws/build/patch/astCodePatcher.js";
import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-updater.js";

import { normalizePath } from "../../utils/normalize-path.js";

export function patchInstrumentation(updater: ContentUpdater, buildOpts: BuildOptions): Plugin {
const builtInstrumentationPath = getBuiltInstrumentationPath(buildOpts);

Expand Down Expand Up @@ -84,7 +86,7 @@ function getBuiltInstrumentationPath(buildOpts: BuildOptions): string | null {
getPackagePath(buildOpts),
`.next/server/${INSTRUMENTATION_HOOK_FILENAME}.js`
);
return existsSync(maybeBuiltInstrumentationPath) ? maybeBuiltInstrumentationPath : null;
return existsSync(maybeBuiltInstrumentationPath) ? normalizePath(maybeBuiltInstrumentationPath) : null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { dirname, resolve } from "node:path";

import type { PluginBuild } from "esbuild";

import { normalizePath } from "../../utils/normalize-path.js";

export function setWranglerExternal() {
return {
name: "wrangler-externals",
Expand All @@ -27,7 +29,7 @@ export function setWranglerExternal() {

build.onResolve({ filter: /(\.bin|\.wasm\?module)$/ }, ({ path, importer }) => {
return {
path: resolve(dirname(importer), path),
path: normalizePath(resolve(dirname(importer), path)),
namespace,
external: true,
};
Expand Down
11 changes: 8 additions & 3 deletions packages/cloudflare/src/cli/commands/populate-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
BINDING_NAME as D1_TAG_BINDING_NAME,
NAME as D1_TAG_NAME,
} from "../../api/overrides/tag-cache/d1-next-tag-cache.js";
import { normalizePath } from "../build/utils/normalize-path.js";
import type { WranglerTarget } from "../utils/run-wrangler.js";
import { runWrangler } from "../utils/run-wrangler.js";

Expand All @@ -57,8 +58,8 @@ export function getCacheAssets(opts: BuildOptions): CacheAsset[] {
const assets: CacheAsset[] = [];

for (const file of allFiles) {
const fullPath = file.fullpathPosix();
const relativePath = path.relative(path.join(opts.outputDir, "cache"), fullPath);
const fullPath = file.fullpath();
const relativePath = normalizePath(path.relative(path.join(opts.outputDir, "cache"), fullPath));

if (relativePath.startsWith("__fetch")) {
const [__fetch, buildId, ...keyParts] = relativePath.split("/");
Expand Down Expand Up @@ -121,7 +122,11 @@ function populateR2IncrementalCache(

runWrangler(
options,
["r2 object put", JSON.stringify(path.join(bucket, cacheKey)), `--file ${JSON.stringify(fullPath)}`],
[
"r2 object put",
JSON.stringify(normalizePath(path.join(bucket, cacheKey))),
`--file ${JSON.stringify(fullPath)}`,
],
// NOTE: R2 does not support the environment flag and results in the following error:
// Incorrect type for the 'cacheExpiry' field on 'HttpMetadata': the provided value is not of type 'date'.
{ target: populateCacheOptions.target, excludeRemoteFlag: true, logging: "error" }
Expand Down