This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add support to ISC parser * feat: use parsed values * chore: remove unneeded import * chore: prettier * fix: flip precedence and extract to own test * fix: fmt * fix: switch back to logical or
- Loading branch information
Showing
6 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/fixtures-esm/v2-api-name-generator/.netlify/functions-internal/server.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"config": { | ||
"name": "should not be respected, ISC takes precedence", | ||
"generator": "should not be respected, ISC takes precedence" | ||
}, | ||
"version": 1 | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/fixtures-esm/v2-api-name-generator/.netlify/functions-internal/server.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default () => new Response('hello world') | ||
|
||
export const config = { | ||
name: 'SSR Function', | ||
generator: '[email protected]', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -703,4 +703,19 @@ describe('V2 API', () => { | |
expect(routes).toEqual([{ pattern: '/products', literal: '/products', methods: [], prefer_static: true }]) | ||
}) | ||
}) | ||
|
||
test('Understands name and generator', () => { | ||
const source = ` | ||
export default async () => new Response("Hello!") | ||
export const config = { name: "foo", generator: "[email protected]" }` | ||
|
||
const isc = parseSource(source, options) | ||
expect(isc).toEqual({ | ||
inputModuleFormat: 'esm', | ||
routes: [], | ||
runtimeAPIVersion: 2, | ||
name: 'foo', | ||
generator: '[email protected]', | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -528,4 +528,26 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => { | |
expect(body).toBe('foo!bar') | ||
}) | ||
}) | ||
|
||
test('Name and Generator are taken from ISC and take precedence over deploy config', async () => { | ||
const { path: tmpDir } = await getTmpDir({ prefix: 'zip-it-test' }) | ||
const manifestPath = join(tmpDir, 'manifest.json') | ||
|
||
const fixtureName = 'v2-api-name-generator' | ||
const pathInternal = join(fixtureName, '.netlify', 'functions-internal') | ||
|
||
const { | ||
files: [func], | ||
} = await zipFixture(pathInternal, { | ||
fixtureDir: FIXTURES_ESM_DIR, | ||
length: 1, | ||
opts: { | ||
manifest: manifestPath, | ||
configFileDirectories: [join(FIXTURES_ESM_DIR, fixtureName)], | ||
}, | ||
}) | ||
|
||
expect(func.displayName).toBe('SSR Function') | ||
expect(func.generator).toBe('[email protected]') | ||
}) | ||
}) |
7b03070
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏱ Benchmark results