Skip to content

Commit

Permalink
mention that running under windows is not advised (cloudflare#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
dario-piotrowicz authored Jul 31, 2023
1 parent e08f4c5 commit 191d796
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
4 changes: 4 additions & 0 deletions docs/supported.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Supported Versions and Features

## Operating Systems

`@cloudflare/next-on-pages` can be run on Linux, Mac OS and Windows but its usage under the latter is discouraged as we've noticed that one of the CLI's dependencies, the [Vercel CLI](https://vercel.com/docs/cli) (used to build the Next.js application) seems not to work reliably on Windows. If you need to run `@cloudflare/next-on-pages` on Windows we advise you to run it under the [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/).

## Supported Next.js versions

Based on manual testing, it seems like the latest Next.js version (`13.4.2` at the time of writing) is supported.
Expand Down
11 changes: 1 addition & 10 deletions src/buildApplication/packageManagerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execFileSync, spawn } from 'child_process';
import { readFile } from 'fs/promises';
import YAML from 'js-yaml';
import { cliError, cliWarn } from '../cli';
import { validateFile } from '../utils';
import { isWindows, validateFile } from '../utils';

/**
* Gets the current package manager for the project.
Expand Down Expand Up @@ -250,15 +250,6 @@ export async function getExecStr(
return `${execCmd ?? baseCmd} ${args.join(' ') ?? ''}`.trim();
}

/**
* Checks whether the current platform is Windows.
*
* @returns Whether the current platform is Windows.
*/
function isWindows(): boolean {
return process.platform === 'win32';
}

export type PackageManager =
| 'bun'
| 'pnpm'
Expand Down
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { CliOptions } from './cli';
import { cliWarn, cliError } from './cli';
import { cliLog, parseCliArgs, printCliHelpMessage, printEnvInfo } from './cli';
import { buildApplication } from './buildApplication';
import { nextOnPagesVersion } from './utils';
import { isWindows, nextOnPagesVersion } from './utils';

const limit = pLimit(1);

Expand All @@ -30,6 +30,16 @@ async function runNextOnPages(): Promise<void> {
return;
}

if (isWindows()) {
cliWarn(
`Warning: It seems like you're on a Windows system, the Vercel CLI (run by @cloudflare/next-on-pages
to build your application) seems not to work reliably on Windows so if you experience issues during
the build process please try switching to a different operating system or running
@cloudflare/next-on-pages under the Windows Subsystem for Linux`,
{ spaced: true },
);
}

if (args.experimentalMinify) {
cliWarn(
`
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './fs';
export * from './version';
export * from './routing';
export * from './str';
export * from './os';
8 changes: 8 additions & 0 deletions src/utils/os.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Checks whether the current platform is Windows.
*
* @returns Whether the current platform is Windows.
*/
export function isWindows(): boolean {
return process.platform === 'win32';
}

0 comments on commit 191d796

Please sign in to comment.