-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby-adapter-netlify): handler generation on windows #38900
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
8bef331
test: add unit test for produced handler
pieh 616479c
actually failing test in windows
pieh 3faca33
fix(gatsby-adapter-netlify): produce working function handlers on win…
pieh 80a6f74
fix(gatsby): functions compilation on windows
pieh 4a46d08
tmp: prepare cross-platform binaries for SSR/DSG
pieh 530800b
fix: lint
pieh ea45d1f
feat: add a way to configure functions executing platform/arch and ad…
pieh 407f6be
refactor: move some utility functions around, cleanup standalone-rege…
pieh e2bdeac
chore: add jsdocs description for functionsPlatform and functionsArch…
pieh 95c7a1f
chore: make sure fs wrapper is first
pieh 96217df
fix: actually use values reported by adapter
pieh 6b9ecde
test: try to setup windows adapters smoke test
pieh a09a65d
test: typo
pieh d1c7612
test: maybe cd into dirs?
pieh 1cb2fe1
test: no powershell fro smoke test
pieh 2a9f921
chore: single quote to double
pieh 28dea6e
Merge remote-tracking branch 'origin/master' into fix/win-lambda
pieh 686912b
chore: install node-gyp requirements
pieh 18263ae
chore: install deps in win smoke
pieh 3979168
?
pieh 9af58b3
newer node needed for ntl-cli
pieh 8c55e40
run ntl through yarn
pieh ec1e319
Revert "run ntl through yarn"
pieh 6713e37
install ntl-cli in circleci pipeline
pieh 6f7db06
test: adjust lmdb regeneration test to changed internal-packages loca…
pieh 6509104
test: run windows deploy/smoke test after unit tests passed
pieh e25d4e5
chore: use path.posix to load engines in serve command
pieh c507fb6
chore: use default value when destructuring instead of nullish coales…
pieh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,24 @@ | ||
import assert from "node:assert" | ||
|
||
{ | ||
// check index page (SSG) | ||
const response = await fetch(process.env.DEPLOY_URL) | ||
assert.equal(response.status, 200) | ||
|
||
const body = await response.text() | ||
assert.match(body, /<h1>Adapters<\/h1>/) | ||
assert.match(body, /<title[^>]*>Adapters E2E<\/title>/) | ||
} | ||
|
||
{ | ||
// check SSR page | ||
const response = await fetch( | ||
process.env.DEPLOY_URL + `/routes/ssr/remote-file/` | ||
) | ||
assert.equal(response.status, 200) | ||
|
||
const body = await response.text() | ||
// inline css for placeholder - this tests both LMDB and SHARP | ||
// (LMDB because of page query and sharp because page query will use sharp to generate placeholder values) | ||
assert.match(body, /background-color:rgb\(232,184,8\)/) | ||
} |
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
Empty file.
Empty file.
46 changes: 46 additions & 0 deletions
46
packages/gatsby-adapter-netlify/src/__tests__/lambda-handler.ts
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,46 @@ | ||
import fs from "fs-extra" | ||
import { prepareFunction } from "../lambda-handler" | ||
import { join, relative } from "path" | ||
import { slash } from "gatsby-core-utils/path" | ||
|
||
const writeFileSpy = jest | ||
.spyOn(fs, `writeFile`) | ||
.mockImplementation(async () => {}) | ||
const writeJsonSpy = jest | ||
.spyOn(fs, `writeJSON`) | ||
.mockImplementation(async () => {}) | ||
|
||
const fixturePath = join( | ||
relative(process.cwd(), __dirname), | ||
`fixtures`, | ||
`lambda-handler` | ||
) | ||
const pathToEntryPoint = join(fixturePath, `entry.js`) | ||
const requiredFile = join(fixturePath, `included.js`) | ||
|
||
test(`produced handler is correct`, async () => { | ||
await prepareFunction({ | ||
functionId: `test`, | ||
name: `test`, | ||
pathToEntryPoint, | ||
requiredFiles: [requiredFile], | ||
}) | ||
const handlerCode = writeFileSpy.mock.calls[0][1] | ||
// expect require in produced code (this is to mostly to make sure handlerCode is actual handler code) | ||
expect(handlerCode).toMatch(/require\(["'][^"']*["']\)/) | ||
// require paths should not have backward slashes (win paths) | ||
expect(handlerCode).not.toMatch(/require\(["'][^"']*\\[^"']*["']\)/) | ||
|
||
expect(writeJsonSpy).toBeCalledWith( | ||
expect.any(String), | ||
expect.objectContaining({ | ||
config: expect.objectContaining({ | ||
name: `test`, | ||
generator: expect.stringContaining(`gatsby-adapter-netlify`), | ||
includedFiles: [slash(requiredFile)], | ||
externalNodeModules: [`msgpackr-extract`], | ||
}), | ||
version: 1, | ||
}) | ||
) | ||
}) |
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Did you mean DSG?
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.
This is actually SSG so comment is correct. Just making sure that static content (.html) files are deployed correctly