-
Notifications
You must be signed in to change notification settings - Fork 357
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 for the Frameworks API (#6735)
* feat: add support for the Frameworks API * chore: fix tests * fix: oops
- Loading branch information
1 parent
73f4eb5
commit 6a48a38
Showing
12 changed files
with
161 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { mkdir } from 'fs/promises' | ||
import { resolve } from 'node:path' | ||
|
||
interface FrameworksAPIPath { | ||
path: string | ||
ensureExists: () => Promise<void> | ||
} | ||
|
||
/** | ||
* Returns an object containing the paths for all the operations of the | ||
* Frameworks API. Each key maps to an object containing a `path` property | ||
* with the path of the operation and a `ensureExists` methos that creates | ||
* the directory in case it doesn't exist. | ||
*/ | ||
export const getFrameworksAPIPaths = (basePath: string, packagePath?: string) => { | ||
const root = resolve(basePath, packagePath || '', '.netlify/v1') | ||
const paths = { | ||
root, | ||
config: resolve(root, 'config.json'), | ||
functions: resolve(root, 'functions'), | ||
edgeFunctions: resolve(root, 'edge-functions'), | ||
blobs: resolve(root, 'blobs'), | ||
} | ||
|
||
return Object.entries(paths).reduce( | ||
(acc, [name, path]) => ({ | ||
...acc, | ||
[name]: { | ||
path, | ||
ensureExists: async () => { | ||
await mkdir(path, { recursive: true }) | ||
}, | ||
}, | ||
}), | ||
{} as Record<keyof typeof paths, FrameworksAPIPath>, | ||
) | ||
} |
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.
6a48a38
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
6a48a38
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