diff --git a/e2e/install.e2e.js b/e2e/install.e2e.js index e5204eac41b..168967425c6 100644 --- a/e2e/install.e2e.js +++ b/e2e/install.e2e.js @@ -1,11 +1,11 @@ -import { readFileSync, existsSync } from 'fs' +import { existsSync, readFileSync } from 'fs' import { mkdir } from 'fs/promises' import { platform } from 'os' import { join, resolve } from 'path' import { env } from 'process' import { fileURLToPath } from 'url' -import execa from 'execa' +import { execa } from 'execa' import { expect, test } from 'vitest' import { packageManagerConfig, packageManagerExists } from './utils.js' diff --git a/scripts/prepare-for-publish.js b/scripts/prepare-for-publish.js index 1145db3bc5b..a1e2cda0b14 100644 --- a/scripts/prepare-for-publish.js +++ b/scripts/prepare-for-publish.js @@ -2,7 +2,7 @@ import { readFile, writeFile } from 'fs/promises' import { dirname, join } from 'path' import { fileURLToPath } from 'url' -import execa from 'execa' +import { execa } from 'execa' import ora from 'ora' // These scripts from package.json need to be preserved on publish diff --git a/src/commands/dev/dev-exec.ts b/src/commands/dev/dev-exec.ts index 038ab860b0a..39632049846 100644 --- a/src/commands/dev/dev-exec.ts +++ b/src/commands/dev/dev-exec.ts @@ -1,5 +1,5 @@ import { OptionValues } from 'commander' -import execa from 'execa' +import { execa } from 'execa' import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.js' import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.js' diff --git a/src/lib/exec-fetcher.ts b/src/lib/exec-fetcher.ts index 7461173c07b..754267be86a 100644 --- a/src/lib/exec-fetcher.ts +++ b/src/lib/exec-fetcher.ts @@ -63,6 +63,7 @@ export const shouldFetchLatestVersion = async ({ return false } + // @ts-expect-error TS(2339) Property 'match' does not exist on type 'never' const match = stdout.match(new RegExp(pattern)) if (!match) { return false diff --git a/src/recipes/vscode/index.ts b/src/recipes/vscode/index.ts index 3fd7be1a96b..c2c5087f435 100644 --- a/src/recipes/vscode/index.ts +++ b/src/recipes/vscode/index.ts @@ -1,7 +1,7 @@ import { join } from 'path' import { DenoBridge } from '@netlify/edge-bundler' -import execa from 'execa' +import { execa } from 'execa' import inquirer from 'inquirer' import { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.js' diff --git a/src/utils/execa.ts b/src/utils/execa.ts index 4c901559698..f840da02d13 100644 --- a/src/utils/execa.ts +++ b/src/utils/execa.ts @@ -1,6 +1,6 @@ import { env } from 'process' -import execaLib from 'execa' +import { execa as execaLib } from 'execa' // This is a thin layer on top of `execa` that allows consumers to provide an // alternative path to the module location, making it easier to mock its logic diff --git a/src/utils/lm/install.ts b/src/utils/lm/install.ts index b8e300a3379..d280d717af2 100644 --- a/src/utils/lm/install.ts +++ b/src/utils/lm/install.ts @@ -4,7 +4,7 @@ import path, { join, sep } from 'path' import process from 'process' import { fileURLToPath } from 'url' -import execa from 'execa' +import { execa } from 'execa' // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'hasb... Remove this comment to see the full error message import hasbin from 'hasbin' import { Listr } from 'listr2' diff --git a/src/utils/shell.ts b/src/utils/shell.ts index fbaf2b0869e..ae5fd75e210 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -1,6 +1,6 @@ import process from 'process' -import execa from 'execa' +import { execaCommand } from 'execa' // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'stri... Remove this comment to see the full error message import stripAnsiCc from 'strip-ansi-control-characters' @@ -54,7 +54,7 @@ const cleanupBeforeExit = async ({ exitCode }) => { export const runCommand = (command, options = {}) => { // @ts-expect-error TS(2339) FIXME: Property 'cwd' does not exist on type '{}'. const { cwd, env = {}, spinner = null } = options - const commandProcess = execa.command(command, { + const commandProcess = execaCommand(command, { preferLocal: true, // we use reject=false to avoid rejecting synchronously when the command doesn't exist reject: false, @@ -84,11 +84,8 @@ export const runCommand = (command, options = {}) => { }) } - // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. commandProcess.stdout.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stdout)) - // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. commandProcess.stderr.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stderr)) - // @ts-expect-error TS(2345) FIXME: Argument of type 'Writable | null' is not assignab... Remove this comment to see the full error message process.stdin.pipe(commandProcess.stdin) // we can't try->await->catch since we don't want to block on the framework server which @@ -107,8 +104,7 @@ export const runCommand = (command, options = {}) => { ) } else { const errorMessage = result.failed - ? // @ts-expect-error TS(2339) FIXME: Property 'shortMessage' does not exist on type 'Ex... Remove this comment to see the full error message - `${NETLIFYDEVERR} ${result.shortMessage}` + ? `${NETLIFYDEVERR} ${result.shortMessage}` : `${NETLIFYDEVWARN} "${command}" exited with code ${result.exitCode}` log(`${errorMessage}. Shutting down Netlify Dev server`) diff --git a/tests/integration/commands/build/build.test.js b/tests/integration/commands/build/build.test.js index ebc9c2fb707..f33955d72ae 100644 --- a/tests/integration/commands/build/build.test.js +++ b/tests/integration/commands/build/build.test.js @@ -1,7 +1,7 @@ import path from 'path' import process from 'process' -import execa from 'execa' +import { execa } from 'execa' import { describe, test } from 'vitest' import { cliPath } from '../../utils/cli-path.js' diff --git a/tests/integration/commands/deploy/deploy.test.js b/tests/integration/commands/deploy/deploy.test.js index fd1258ee0b1..7e218495a26 100644 --- a/tests/integration/commands/deploy/deploy.test.js +++ b/tests/integration/commands/deploy/deploy.test.js @@ -2,7 +2,7 @@ import path from 'path' import process from 'process' import { fileURLToPath } from 'url' -import execa from 'execa' +import { execaCommand } from 'execa' import fetch from 'node-fetch' import { afterAll, beforeAll, describe, test } from 'vitest' @@ -886,7 +886,7 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co }) .build() - await execa.command('npm install', { cwd: builder.directory }) + await execaCommand('npm install', { cwd: builder.directory }) const { deploy_url: deployUrl } = await callCli( ['deploy', '--json'], { diff --git a/tests/integration/commands/dev/dev-miscellaneous.test.js b/tests/integration/commands/dev/dev-miscellaneous.test.js index 21d8e24d62e..7872e179b7c 100644 --- a/tests/integration/commands/dev/dev-miscellaneous.test.js +++ b/tests/integration/commands/dev/dev-miscellaneous.test.js @@ -4,7 +4,7 @@ import { platform } from 'process' import { fileURLToPath } from 'url' import { setProperty } from 'dot-prop' -import execa from 'execa' +import { execa } from 'execa' import getAvailablePort from 'get-port' import jwt from 'jsonwebtoken' import fetch from 'node-fetch' diff --git a/tests/integration/commands/dev/v2-api.test.ts b/tests/integration/commands/dev/v2-api.test.ts index 450ed634ff1..3de019243ab 100644 --- a/tests/integration/commands/dev/v2-api.test.ts +++ b/tests/integration/commands/dev/v2-api.test.ts @@ -1,6 +1,6 @@ import { version } from 'process' -import execa from 'execa' +import { execa } from 'execa' import { gte } from 'semver' import { describe, expect, test } from 'vitest' diff --git a/tests/integration/commands/env/env.test.js b/tests/integration/commands/env/env.test.js index c1eba42850e..1b61aefe0f1 100644 --- a/tests/integration/commands/env/env.test.js +++ b/tests/integration/commands/env/env.test.js @@ -1,6 +1,6 @@ import process from 'process' -import execa from 'execa' +import { execa } from 'execa' import { describe, test } from 'vitest' import { callCli } from '../../utils/call-cli.js' diff --git a/tests/integration/commands/functions-create/functions-create.test.ts b/tests/integration/commands/functions-create/functions-create.test.ts index a032551ff1c..575d9dd16f5 100644 --- a/tests/integration/commands/functions-create/functions-create.test.ts +++ b/tests/integration/commands/functions-create/functions-create.test.ts @@ -2,7 +2,7 @@ import { existsSync } from 'fs' import { readFile } from 'fs/promises' import { join } from 'path' -import execa from 'execa' +import { execa } from 'execa' import { describe, expect, test } from 'vitest' import { fileExistsAsync } from '../../../../src/lib/fs.js' diff --git a/tests/integration/commands/functions-serve/functions-serve.test.js b/tests/integration/commands/functions-serve/functions-serve.test.js index ca8d5aad4ab..b63a28d12bd 100644 --- a/tests/integration/commands/functions-serve/functions-serve.test.js +++ b/tests/integration/commands/functions-serve/functions-serve.test.js @@ -1,4 +1,4 @@ -import execa from 'execa' +import { execa } from 'execa' import getPort from 'get-port' import fetch from 'node-fetch' import { describe, test } from 'vitest' diff --git a/tests/integration/commands/init/init.test.js b/tests/integration/commands/init/init.test.js index 4e7f76b9d23..9e2678876af 100644 --- a/tests/integration/commands/init/init.test.js +++ b/tests/integration/commands/init/init.test.js @@ -1,7 +1,7 @@ import { readFile } from 'fs/promises' import cleanDeep from 'clean-deep' -import execa from 'execa' +import { execa } from 'execa' import toml from 'toml' import { describe, test } from 'vitest' diff --git a/tests/integration/commands/lm/lm.test.ts b/tests/integration/commands/lm/lm.test.ts index bc67bc88dff..4702247f5e8 100644 --- a/tests/integration/commands/lm/lm.test.ts +++ b/tests/integration/commands/lm/lm.test.ts @@ -2,7 +2,7 @@ import { readFile } from 'fs/promises' import os from 'os' import process from 'process' -import execa from 'execa' +import { execaCommand } from 'execa' import ini from 'ini' import { describe, expect, test } from 'vitest' @@ -81,7 +81,7 @@ describe('lm command', () => { const match = cliResponse.match(/source[\s\S]+?(\/.+inc)/) if (!match) expect.fail('could not match path') const [, sourcePath] = match - const { stdout } = await execa.command(`source ${sourcePath} && git-credential-netlify version`, { + const { stdout } = await execaCommand(`source ${sourcePath} && git-credential-netlify version`, { shell: execOptions.env.SHELL, }) diff --git a/tests/integration/commands/recipes/recipes.test.js b/tests/integration/commands/recipes/recipes.test.js index a6034a06d08..735f68ab001 100644 --- a/tests/integration/commands/recipes/recipes.test.js +++ b/tests/integration/commands/recipes/recipes.test.js @@ -2,7 +2,7 @@ import { readFile } from 'fs/promises' import { resolve } from 'path' import { parse } from 'comment-json' -import execa from 'execa' +import { execa } from 'execa' import { describe, test } from 'vitest' import { callCli } from '../../utils/call-cli.js' diff --git a/tests/integration/framework-detection.test.js b/tests/integration/framework-detection.test.js index 41018cbfac7..923b4087b99 100644 --- a/tests/integration/framework-detection.test.js +++ b/tests/integration/framework-detection.test.js @@ -1,4 +1,4 @@ -import execa from 'execa' +import { execa } from 'execa' import fetch from 'node-fetch' import { describe, test } from 'vitest' diff --git a/tests/integration/telemetry.test.ts b/tests/integration/telemetry.test.ts index 7e511ab998d..0db4045d513 100644 --- a/tests/integration/telemetry.test.ts +++ b/tests/integration/telemetry.test.ts @@ -1,7 +1,7 @@ import { env as _env, version as nodejsVersion } from 'process' import type { Options } from 'execa' -import execa from 'execa' +import { execa } from 'execa' import { version as uuidVersion } from 'uuid' import { expect, test } from 'vitest' diff --git a/tests/integration/utils/call-cli.js b/tests/integration/utils/call-cli.js index 3e8f509f7a2..1fbd41ef898 100644 --- a/tests/integration/utils/call-cli.js +++ b/tests/integration/utils/call-cli.js @@ -1,4 +1,4 @@ -import execa from 'execa' +import { execaNode } from 'execa' import { cliPath } from './cli-path.js' @@ -13,7 +13,7 @@ const CLI_TIMEOUT = 3e5 * @returns {Promise} */ export const callCli = async function (args, execOptions = {}, parseJson = false) { - const { stdout } = await execa.node(cliPath, args, { + const { stdout } = await execaNode(cliPath, args, { timeout: CLI_TIMEOUT, nodeOptions: [], ...execOptions, diff --git a/tests/integration/utils/curl.js b/tests/integration/utils/curl.js index 892f54bbc3b..52368637f40 100644 --- a/tests/integration/utils/curl.js +++ b/tests/integration/utils/curl.js @@ -1,4 +1,4 @@ -import execa from 'execa' +import { execa } from 'execa' const CURL_TIMEOUT = 1e5 diff --git a/tests/integration/utils/dev-server.ts b/tests/integration/utils/dev-server.ts index 81eb02e139b..9a0f5c7a1c0 100644 --- a/tests/integration/utils/dev-server.ts +++ b/tests/integration/utils/dev-server.ts @@ -1,7 +1,7 @@ import path from 'path' import process from 'process' -import execa from 'execa' +import { execa } from 'execa' import getPort from 'get-port' import pTimeout from 'p-timeout' diff --git a/tests/integration/utils/site-builder.ts b/tests/integration/utils/site-builder.ts index 56a6bc73362..e503f2855ea 100644 --- a/tests/integration/utils/site-builder.ts +++ b/tests/integration/utils/site-builder.ts @@ -4,7 +4,7 @@ import path from 'path' import process from 'process' import slugify from '@sindresorhus/slugify' -import execa from 'execa' +import { execa } from 'execa' import serializeJS from 'serialize-javascript' import tempDirectory from 'temp-dir' import tomlify from 'tomlify-j0.4' diff --git a/tools/affected-test.js b/tools/affected-test.js index a0cd5902c97..cfcbc96cdea 100755 --- a/tools/affected-test.js +++ b/tools/affected-test.js @@ -6,7 +6,7 @@ import process from 'process' import { fileURLToPath } from 'url' import chalk from 'chalk' -import execa from 'execa' +import { execa } from 'execa' import glob from 'fast-glob' import { DependencyGraph, fileVisitor, visitorPlugins } from './project-graph/index.js' diff --git a/tools/e2e/run.js b/tools/e2e/run.js index 5f5c9540f59..160fc2c6953 100644 --- a/tools/e2e/run.js +++ b/tools/e2e/run.js @@ -3,7 +3,7 @@ import { dirname, join } from 'path' import { exit } from 'process' import { fileURLToPath } from 'url' -import execa from 'execa' +import { execa } from 'execa' import { setup } from './setup.js' diff --git a/tools/e2e/setup.js b/tools/e2e/setup.js index 8ccc6ee3d39..a1a6f78a8a1 100644 --- a/tools/e2e/setup.js +++ b/tools/e2e/setup.js @@ -4,7 +4,7 @@ import { dirname, join, normalize, sep } from 'path' import { env } from 'process' import { fileURLToPath } from 'url' -import execa from 'execa' +import { execa } from 'execa' import getPort from 'get-port' import pTimeout from 'p-timeout' import { runServer } from 'verdaccio'