Skip to content
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

[do not merge] fix(deps): upgrade glob from v8 to v10 #6143

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
112 changes: 69 additions & 43 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions packages/zip-it-and-ship-it/package.json
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@
"fast-glob": "^3.3.2",
"filter-obj": "^5.0.0",
"find-up": "^6.0.0",
"glob": "^8.0.3",
"glob": "^10.4.5",
"is-builtin-module": "^3.1.0",
"is-path-inside": "^4.0.0",
"junk": "^4.0.0",
@@ -78,7 +78,6 @@
},
"devDependencies": {
"@types/archiver": "6.0.3",
"@types/glob": "8.1.0",
"@types/is-ci": "3.0.4",
"@types/node": "20.12.11",
"@types/normalize-path": "3.0.2",
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ const includedFilesToEsbuildExternals = async (includedFiles: string[], baseDir:
const resolved = await glob(pattern, {
noglobstar: true,
cwd: baseDir,
dotRelative: true,
})

result.push(...resolved)
30 changes: 16 additions & 14 deletions packages/zip-it-and-ship-it/src/utils/matching.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import { promisify } from 'util'

import globFunction from 'glob'
import { minimatch as minimatchFunction, MinimatchOptions } from 'minimatch'
import { glob as originalGlob, type GlobOptions } from 'glob'
import { minimatch as minimatchFunction, type MinimatchOptions } from 'minimatch'
import normalizePath from 'normalize-path'

const pGlob = promisify(globFunction)
// We don't use this. Specifying that we don't makes typing easier, since otherwise `glob` returns
// either `string[]` or `Path[]` depending on this passed option.
type Options = Omit<GlobOptions, 'withFileTypes'>

/**
* Both glob and minimatch only support unix style slashes in patterns
* For this reason we wrap them and ensure all patters are always unixified
* For this reason we wrap them and ensure all patterns are always unixified
* We use `normalize-path` here instead of `unixify` because we do not want to remove drive letters
*/

export const glob = function (pattern: string, options: globFunction.IOptions): Promise<string[]> {
let normalizedIgnore
export const glob = function (pattern: string, options: Options): Promise<string[]> {
let normalizedIgnore: string | undefined

if (options.ignore) {
normalizedIgnore =
typeof options.ignore === 'string'
? normalizePath(options.ignore)
: options.ignore.map((expression) => normalizePath(expression))
if (typeof options.ignore === 'string') {
normalizedIgnore = normalizePath(options.ignore)
} else if (Array.isArray(options.ignore)) {
options.ignore.map((expression) => normalizePath(expression))
} else {
throw new Error('Custom glob ignore is not supported')
}
}

return pGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore })
return originalGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore })
}

export const minimatch = function (target: string, pattern: string, options?: MinimatchOptions): boolean {
7 changes: 2 additions & 5 deletions packages/zip-it-and-ship-it/tests/v2api.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { readFile } from 'fs/promises'
import { join, resolve } from 'path'
import { platform, version as nodeVersion } from 'process'
import { promisify } from 'util'

import { getPath as getBootstrapPath } from '@netlify/serverless-functions-api'
import merge from 'deepmerge'
import glob from 'glob'
import glob from 'fast-glob'
import { pathExists } from 'path-exists'
import semver from 'semver'
import { dir as getTmpDir } from 'tmp-promise'
@@ -18,8 +17,6 @@ import { invokeLambda, readAsBuffer } from './helpers/lambda.js'
import { zipFixture, unzipFiles, importFunctionFile, FIXTURES_ESM_DIR, FIXTURES_DIR } from './helpers/main.js'
import { testMany } from './helpers/test_many.js'

const pGlob = promisify(glob)

vi.mock('../src/utils/shell.js', () => ({ shellUtils: { runCommand: vi.fn() } }))

describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => {
@@ -132,7 +129,7 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => {

const [{ name: archive, entryFilename, path }] = files

const untranspiledFiles = await pGlob(`${path}/**/*.ts`)
const untranspiledFiles = await glob(`${path}/**/*.ts`)
expect(untranspiledFiles).toEqual([])

const func = await importFunctionFile(`${tmpDir}/${archive}/${entryFilename}`)