Skip to content

Commit

Permalink
feat: emit schedule property into manifest (#768)
Browse files Browse the repository at this point in the history
* chore: add for schedule property

* feat: output `schedule` property into functions manifest

* 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

Co-authored-by: Netlify Team Account 1 <netlify-team-account-1@users.noreply.github.com>
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
  • Loading branch information
3 people committed Oct 26, 2021
1 parent 3c982bd commit ce5ee5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Expand Up @@ -18,6 +18,7 @@ interface FunctionConfig {
nodeVersion?: NodeVersion
processDynamicNodeImports?: boolean
rustTargetDirectory?: string
schedule?: string
}

type GlobPattern = string
Expand Down
3 changes: 2 additions & 1 deletion src/manifest.ts
Expand Up @@ -18,11 +18,12 @@ const createManifest = async ({ functions, path }: { functions: FunctionResult[]
await writeFile(path, JSON.stringify(payload))
}

const formatFunctionForManifest = ({ mainFile, name, path, runtime }: FunctionResult) => ({
const formatFunctionForManifest = ({ config, mainFile, name, path, runtime }: FunctionResult) => ({
mainFile,
name,
path: resolve(path),
runtime,
schedule: config.schedule,
})

export { createManifest }
10 changes: 9 additions & 1 deletion tests/main.js
Expand Up @@ -2153,7 +2153,14 @@ test('Creates a manifest file with the list of created functions if the `manifes
const manifestPath = join(tmpDir, 'manifest.json')
const { files } = await zipNode(t, 'many-functions', {
length: FUNCTIONS_COUNT,
opts: { manifest: manifestPath },
opts: {
manifest: manifestPath,
config: {
five: {
schedule: '@daily',
},
},
},
})

const manifest = require(manifestPath)
Expand All @@ -2171,6 +2178,7 @@ test('Creates a manifest file with the list of created functions if the `manifes
t.is(fn.name, file.name)
t.is(fn.runtime, file.runtime)
t.is(fn.path, file.path)
t.is(fn.schedule, fn.name === 'five' ? '@daily' : undefined)
})
})

Expand Down

1 comment on commit ce5ee5e

@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: 7.9s

largeDepsNft: 53.6s

largeDepsZisi: 1m 7.2s

Please sign in to comment.