diff --git a/.changeset/breezy-ducks-knock.md b/.changeset/breezy-ducks-knock.md new file mode 100644 index 000000000..dd65e83cd --- /dev/null +++ b/.changeset/breezy-ducks-knock.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': patch +--- + +fix --info showing [object Promise] for relevant packages instead of their versions diff --git a/.changeset/pink-actors-learn.md b/.changeset/pink-actors-learn.md new file mode 100644 index 000000000..230e3e7fc --- /dev/null +++ b/.changeset/pink-actors-learn.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': patch +--- + +fix vercel command not found issue diff --git a/internal-packages/eslint-config-next-on-pages/index.js b/internal-packages/eslint-config-next-on-pages/index.js index e12a335b8..f04d5f1fa 100644 --- a/internal-packages/eslint-config-next-on-pages/index.js +++ b/internal-packages/eslint-config-next-on-pages/index.js @@ -1,26 +1,33 @@ module.exports = { - "env": { - "es2021": true, - "node": true + env: { + es2021: true, + node: true }, - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - "overrides": [], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "sourceType": "module", - "project": true + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], + overrides: [], + parser: "@typescript-eslint/parser", + parserOptions: { + sourceType: "module", + project: true }, - "plugins": ["@typescript-eslint"], - "rules": { + plugins: ["@typescript-eslint"], + rules: { "no-case-declarations": "error", "no-console": "error", "prefer-const": "error", "no-mixed-spaces-and-tabs": "off", // off because it conflicts with prettier "eqeqeq": "error", - "@typescript-eslint/no-explicit-any": "error", "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/consistent-type-imports": "error" + "@typescript-eslint/consistent-type-imports": "error", + + // Promises & async/await + "no-async-promise-executor": "error", + "no-promise-executor-return": "error", + "no-return-await": "error", + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/no-floating-promises": "error", + "@typescript-eslint/promise-function-async": "error", }, - "ignorePatterns": ["vitest.config.ts"] + ignorePatterns: ["vitest.config.ts"] }; diff --git a/packages/next-on-pages/src/buildApplication/buildVercelOutput.ts b/packages/next-on-pages/src/buildApplication/buildVercelOutput.ts index 8b243d786..686a1eb05 100644 --- a/packages/next-on-pages/src/buildApplication/buildVercelOutput.ts +++ b/packages/next-on-pages/src/buildApplication/buildVercelOutput.ts @@ -124,7 +124,7 @@ async function getVercelBuildChildProcess( async function isVercelPackageInstalled( pkgMng: PackageManager ): Promise { - const packageVersion = getPackageVersion('vercel', pkgMng); + const packageVersion = await getPackageVersion('vercel', pkgMng); return !!packageVersion; } diff --git a/packages/next-on-pages/src/cli.ts b/packages/next-on-pages/src/cli.ts index c3ea536a1..191a8e7af 100644 --- a/packages/next-on-pages/src/cli.ts +++ b/packages/next-on-pages/src/cli.ts @@ -225,8 +225,8 @@ export async function printEnvInfo(): Promise { Package Manager Used: ${await getCurrentPackageManager()} Relevant Packages: @cloudflare/next-on-pages: ${nextOnPagesVersion} - vercel: ${getPackageVersion('vercel', packageManager) ?? 'N/A'} - next: ${getPackageVersion('next', packageManager) ?? 'N/A'} + vercel: ${(await getPackageVersion('vercel', packageManager)) ?? 'N/A'} + next: ${(await getPackageVersion('next', packageManager)) ?? 'N/A'} `); // eslint-disable-next-line no-console diff --git a/packages/next-on-pages/src/index.ts b/packages/next-on-pages/src/index.ts index e67b68c40..9139d50e2 100644 --- a/packages/next-on-pages/src/index.ts +++ b/packages/next-on-pages/src/index.ts @@ -1,16 +1,16 @@ import { watch } from 'chokidar'; import pLimit from 'p-limit'; import type { CliOptions } from './cli'; -import { cliWarn } from './cli'; +import { cliWarn, cliError } from './cli'; import { cliLog, parseCliArgs, printCliHelpMessage, printEnvInfo } from './cli'; import { buildApplication } from './buildApplication'; import { nextOnPagesVersion } from './utils'; const limit = pLimit(1); -runNextOnPages(); +void runNextOnPages(); -function runNextOnPages(): void { +async function runNextOnPages(): Promise { const args = parseCliArgs(); if (args.version) { @@ -19,7 +19,7 @@ function runNextOnPages(): void { return; } if (args.info) { - printEnvInfo(); + await printEnvInfo(); return; } @@ -62,7 +62,7 @@ function runBuild(options: CliOptions) { `); } } - }); + }).catch(error => cliError(`Watch mode unexpected error: ${error}`)); } function setWatchMode(fn: () => void): void { diff --git a/packages/next-on-pages/src/utils/fs.ts b/packages/next-on-pages/src/utils/fs.ts index e0891c842..d59825a12 100644 --- a/packages/next-on-pages/src/utils/fs.ts +++ b/packages/next-on-pages/src/utils/fs.ts @@ -76,7 +76,7 @@ async function validatePathType(path: string, type: 'file' | 'directory') { * @param path Path to check. * @returns Whether a file exists at the given path. */ -export function validateFile(path: string) { +export async function validateFile(path: string) { return validatePathType(path, 'file'); } @@ -86,7 +86,7 @@ export function validateFile(path: string) { * @param path Path to check. * @returns Whether a directory exists at the given path. */ -export function validateDir(path: string) { +export async function validateDir(path: string) { return validatePathType(path, 'directory'); } @@ -104,9 +104,7 @@ export async function readPathsRecursively(dir: string): Promise { files.map(async file => { const path = resolve(dir, file); - return (await validateDir(path)) - ? await readPathsRecursively(path) - : [path]; + return (await validateDir(path)) ? readPathsRecursively(path) : [path]; }) );