Skip to content

Commit

Permalink
refactor: use exported types
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Oct 9, 2024
1 parent 0886925 commit 49fcc66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/build/src/plugins_core/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve } from 'path'

import { NodeBundlerName, RUNTIME, zipFunctions } from '@netlify/zip-it-and-ship-it'
import { NodeBundlerName, RUNTIME, zipFunctions, ZippedFunctions } from '@netlify/zip-it-and-ship-it'
import { pathExists } from 'path-exists'

import { addErrorInfo } from '../../error/info.js'
Expand All @@ -13,7 +13,7 @@ import { getUserAndInternalFunctions, validateFunctionsSrc } from './utils.js'
import { getZisiParameters } from './zisi.js'

// Get a list of all unique bundlers in this run
const getBundlers = (results: Awaited<ReturnType<typeof zipFunctions>> = []) =>
const getBundlers = (results: ZippedFunctions = []) =>
// using a Set to filter duplicates
new Set(
results
Expand All @@ -38,7 +38,7 @@ const eventTriggeredFunctions = new Set([
'identity-login',
])

const validateCustomRoutes = function (functions: Awaited<ReturnType<typeof zipFunctions>>) {
const validateCustomRoutes = function (functions: ZippedFunctions) {
for (const { routes, name, schedule } of functions) {
if (!routes || routes.length === 0) continue

Expand Down
9 changes: 8 additions & 1 deletion packages/zip-it-and-ship-it/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ import { RuntimeCache } from './utils/cache.js'
import { listFunctionsDirectories, resolveFunctionsDirectories } from './utils/fs.js'

export { Config, FunctionConfig } from './config.js'
export { zipFunction, zipFunctions, ZipFunctionOptions, ZipFunctionsOptions } from './zip.js'
export {
zipFunction,
zipFunctions,
ZipFunctionOptions,
ZipFunctionsOptions,
ZippedFunction,
ZippedFunctions,
} from './zip.js'

export { ArchiveFormat, ARCHIVE_FORMAT } from './archive.js'
export type { TrafficRules } from './rate_limit.js'
Expand Down
4 changes: 4 additions & 0 deletions packages/zip-it-and-ship-it/src/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export const zipFunctions = async function (
return formattedResults
}

export type ZippedFunctions = Awaited<ReturnType<typeof zipFunctions>>

export const zipFunction = async function (
relativeSrcPath: string,
destFolder: string,
Expand Down Expand Up @@ -204,3 +206,5 @@ export const zipFunction = async function (

return formatZipResult({ ...zipResult, mainFile, name, runtime })
}

export type ZippedFunction = Awaited<ReturnType<typeof zipFunction>>

0 comments on commit 49fcc66

Please sign in to comment.