-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat: add Frameworks API #5668
feat: add Frameworks API #5668
Conversation
This pull request adds or modifies JavaScript ( |
logDryRunStep({ logs, step, index, netlifyConfig, eventWidth, stepsCount }) | ||
}) | ||
successSteps | ||
.filter((step) => !step.quiet) |
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.
Filtering before iterating means we have the right value for index
.
storeOpts.experimentalRegion = 'auto' | ||
} | ||
|
||
const blobStore = getDeployStore(storeOpts) | ||
const keys = await getKeysToUpload(blobs.directory) | ||
const blobsToUpload = blobs.apiVersion >= 3 ? await getBlobs(blobs.directory) : await getKeysToUpload(blobs.directory) |
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.
blobsToUpload
is now an array of objects with the following properties:
key
: The blob keycontentPath
: The absolute path to the blob content filemetadataPath
: The absolute path to the blob metadata file (doesn't mean that one exists)
coreStepDescription: () => '', | ||
condition: ({ featureFlags }) => featureFlags?.netlify_build_deploy_configuration_api, |
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.
Removed the feature flag because it's been fully rolled out.
generatedFunctionsPath = frameworksAPISrcPath | ||
} | ||
|
||
const frameworkImportMap = resolve( |
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.
We now look for import maps on a specific location, as opposed to reading that from the legacy manifest.json
file.
* result is an array with the blob key, the path to its data file, and the | ||
* path to its metadata file. | ||
*/ | ||
export const getKeysToUpload = async (blobsDir: string) => { |
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 the old method for the legacy APIs (file-based uploads and Deploy Configuration API). We're just changing the shape of the return value to be an array of objects.
}) | ||
}) | ||
|
||
return blobsToUpload | ||
} | ||
|
||
/** Read a file and its metadata file from the blobs directory */ | ||
export const getFileWithMetadata = async ( |
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.
Because of the changes we made to getKeysToUpload
, this method is now simpler and receives the path of the content and metadata files, as opposed to having to compute them itself.
@@ -37,10 +37,6 @@ const NORMALIZE_REGEXPS = [ | |||
/(^|[ "'(=])((?:\.{0,2}|([A-Z]:)|file:\/\/)(\/[^ "')\n]+))/gm, | |||
|
|||
(_, prefix, pathMatch, winDrive, pathTrail) => { | |||
if (pathMatch.includes('/$netlify-snapshot-preserve/')) { |
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.
We're not using this.
🔪 snapshots
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.
LGTM 🚀
}) | ||
}) | ||
|
||
return blobsToUpload |
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.
nit: would be interesting to understand the rationale for using forEach
here instead of map
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.
Good question! No reason, this should definitely be a map
. I'll do this in a follow-up.
Summary
Extends the Deploy Configuration API and renames it to Frameworks API. The PR ended up getting larger than I'd want, but I felt it was important to land the different endpoints together. Plus, the bulk of the diff is changes to tests.
To make it easier to review, I've separated the different parts of the API into different commits. I recommend reviewing them one by one, in the order below. I'll also add inline comments whenever I feel it helps.
config.json
endpoint and rename the feature to Frameworks API