Skip to content

fix(deps): replace find-up with empathic #7121

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

Closed
wants to merge 2 commits into from
Closed
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
57 changes: 15 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"decache": "4.6.2",
"dot-prop": "9.0.0",
"dotenv": "16.4.7",
"empathic": "^1.0.0",
"env-paths": "3.0.0",
"envinfo": "7.14.0",
"etag": "1.8.1",
Expand All @@ -100,7 +101,6 @@
"extract-zip": "2.0.1",
"fastest-levenshtein": "1.0.16",
"fastify": "4.29.0",
"find-up": "7.0.0",
"flush-write-stream": "2.0.0",
"folder-walker": "3.2.0",
"from2-array": "0.0.4",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { isCI } from 'ci-info'
import { Command, Help, Option } from 'commander'
import debug from 'debug'
import { findUp } from 'find-up'
import { up } from 'empathic/find'
import inquirer from 'inquirer'
import inquirerAutocompletePrompt from 'inquirer-autocomplete-prompt'
import merge from 'lodash/merge.js'
Expand Down Expand Up @@ -140,8 +140,8 @@
return selected.path
}

async function getRepositoryRoot(cwd?: string): Promise<string | undefined> {

Check failure on line 143 in src/commands/base-command.ts

View workflow job for this annotation

GitHub Actions / Lint

Async function 'getRepositoryRoot' has no 'await' expression
const res = await findUp('.git', { cwd, type: 'directory' })
const res = up('.git', { cwd })
if (res) {
return join(res, '..')
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/functions/functions-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import process from 'process'
import { fileURLToPath, pathToFileURL } from 'url'

import { OptionValues } from 'commander'
import { findUp } from 'find-up'
import { up } from 'empathic/find'
import fuzzy from 'fuzzy'
import inquirer from 'inquirer'
import fetch from 'node-fetch'
Expand Down Expand Up @@ -432,7 +432,7 @@ const getNpmInstallPackages = (existingPackages = {}, neededPackages = {}) =>
// @ts-expect-error TS(7031) FIXME: Binding element 'functionPackageJson' implicitly h... Remove this comment to see the full error message
const installDeps = async ({ functionPackageJson, functionPath, functionsDir }) => {
const { dependencies: functionDependencies, devDependencies: functionDevDependencies } = require(functionPackageJson)
const sitePackageJson = await findUp('package.json', { cwd: functionsDir })
const sitePackageJson = up('package.json', { cwd: functionsDir })
const npmInstallFlags = ['--no-audit', '--no-fund']

// If there is no site-level `package.json`, we fall back to the old behavior
Expand Down
8 changes: 3 additions & 5 deletions src/lib/functions/runtimes/rust/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { dirname, extname, join, resolve } from 'path'
import { platform } from 'process'

import { findUp } from 'find-up'
import { up } from 'empathic/find'
import toml from 'toml'

import execa from '../../../../utils/execa.js'
Expand Down Expand Up @@ -41,10 +41,8 @@
() =>
build({ func })

// @ts-expect-error TS(7006) FIXME: Parameter 'cwd' implicitly has an 'any' type.
const getCrateName = async (cwd) => {
const manifestPath = await findUp('Cargo.toml', { cwd, type: 'file' })
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
const getCrateName = async (cwd: string) => {
const manifestPath = up('Cargo.toml', { cwd })!

Check failure on line 45 in src/lib/functions/runtimes/rust/index.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion
const manifest = await readFile(manifestPath, 'utf-8')
const { package: CargoPackage } = toml.parse(manifest)

Expand Down
4 changes: 2 additions & 2 deletions src/utils/get-repo-data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dirname } from 'path'
import util from 'util'

import { findUp } from 'find-up'
import { up } from 'empathic/find'
import gitRepoInfo from 'git-repo-info'
import gitconfiglocal from 'gitconfiglocal'
import parseGithubUrl from 'parse-github-url'
Expand All @@ -20,7 +20,7 @@ const getRepoData = async function ({ remoteName, workingDir }: { remoteName?: s
try {
const [gitConfig, gitDirectory] = await Promise.all([
util.promisify(gitconfiglocal)(workingDir),
findUp('.git', { cwd: workingDir, type: 'directory' }),
Promise.resolve(up('.git', { cwd: workingDir })),
])

if (!gitDirectory || !gitConfig || !gitConfig.remote || Object.keys(gitConfig.remote).length === 0) {
Expand Down
10 changes: 4 additions & 6 deletions src/utils/state-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path'
import process from 'process'

import { deleteProperty, getProperty, hasProperty, setProperty } from 'dot-prop'
import { findUpSync } from 'find-up'
import { up } from 'empathic/find'
import writeFileAtomic from 'write-file-atomic'

import { getPathInProject } from '../lib/settings.js'
Expand All @@ -13,12 +13,10 @@ const permissionError = "You don't have access to this file."

/**
* Finds location of `.netlify/state.json`
* @param {string} cwd
* @returns {string}
* @param cwd
*/
// @ts-expect-error TS(7006) FIXME: Parameter 'cwd' implicitly has an 'any' type.
const findStatePath = (cwd) => {
const statePath = findUpSync([STATE_PATH], { cwd })
const findStatePath = (cwd: string): string => {
const statePath = up(STATE_PATH, { cwd })

if (!statePath) {
return path.join(cwd, STATE_PATH)
Expand Down
Loading