From a78451ca5f8d7901dbad3982c201134cbaf6498f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Tue, 26 Oct 2021 10:49:45 +0100 Subject: [PATCH] feat: add Manifest type (#770) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: add for schedule property * feat: output `schedule` property into functions manifest * feat: add Manifest type * Update src/manifest.ts Co-authored-by: Eduardo Bouças * Update main.js * chore: integrate into existing manifest test * chore: remove .only * chore: merge in schedule type Co-authored-by: Netlify Team Account 1 Co-authored-by: Netlify Team Account 1 <90322326+netlify-team-account-1@users.noreply.github.com> --- src/manifest.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/manifest.ts b/src/manifest.ts index d7601cdba..a05543031 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -4,11 +4,29 @@ import { arch, platform } from 'process' import { FunctionResult } from './utils/format_result' import { writeFile } from './utils/fs' +interface ManifestFunction { + mainFile: string + name: string + path: string + runtime: string + schedule?: string +} + +interface Manifest { + functions: ManifestFunction[] + system: { + arch: string + platform: string + } + timestamp: number + version: number +} + const MANIFEST_VERSION = 1 const createManifest = async ({ functions, path }: { functions: FunctionResult[]; path: string }) => { const formattedFunctions = functions.map(formatFunctionForManifest) - const payload = { + const payload: Manifest = { functions: formattedFunctions, system: { arch, platform }, timestamp: Date.now(), @@ -18,7 +36,7 @@ const createManifest = async ({ functions, path }: { functions: FunctionResult[] await writeFile(path, JSON.stringify(payload)) } -const formatFunctionForManifest = ({ config, mainFile, name, path, runtime }: FunctionResult) => ({ +const formatFunctionForManifest = ({ config, mainFile, name, path, runtime }: FunctionResult): ManifestFunction => ({ mainFile, name, path: resolve(path), @@ -27,3 +45,4 @@ const formatFunctionForManifest = ({ config, mainFile, name, path, runtime }: Fu }) export { createManifest } +export type { Manifest }