Skip to content

Commit

Permalink
feat: add Manifest type (#770)
Browse files Browse the repository at this point in the history
* 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 <mail@eduardoboucas.com>

* Update main.js

* chore: integrate into existing manifest test

* chore: remove .only

* chore: merge in schedule type

Co-authored-by: Netlify Team Account 1 <netlify-team-account-1@users.noreply.github.com>
Co-authored-by: Netlify Team Account 1 <90322326+netlify-team-account-1@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 26, 2021
1 parent ce5ee5e commit a78451c
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/manifest.ts
Expand Up @@ -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(),
Expand All @@ -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),
Expand All @@ -27,3 +45,4 @@ const formatFunctionForManifest = ({ config, mainFile, name, path, runtime }: Fu
})

export { createManifest }
export type { Manifest }

1 comment on commit a78451c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

largeDepsEsbuild: 8.9s

largeDepsNft: 1m 0.7s

largeDepsZisi: 1m 9.6s

Please sign in to comment.