-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow complete opt-in file downloading (#470)
* chore: update @prismicio packages * refactor(source): remove explicit default client pageSize * chore: update dependencies * feat(source): add support for complete file downloading opt-in * chore: update dependencies * refactor(source): remove unused import * fix(previews): add empty styles.css for easier migration * fix(source): remove auto parameter from locally downloaded files * refactor: remove unnecessary test plugin option
- Loading branch information
1 parent
a8dc1fd
commit c1b27b3
Showing
19 changed files
with
2,770 additions
and
3,292 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
import { defineSirocConfig } from "siroc"; | ||
import postcss from "rollup-plugin-postcss"; | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
|
||
export default defineSirocConfig({ | ||
rollup: { | ||
plugins: [postcss({ inject: false })], | ||
output: { sourcemap: true }, | ||
}, | ||
hooks: { | ||
"build:done": () => { | ||
console.log("Copying static files from ./static into ./dist"); | ||
|
||
const staticDir = path.resolve("./static"); | ||
const files = fs.readdirSync(staticDir); | ||
|
||
for (const file of files) { | ||
fs.copyFileSync( | ||
path.resolve(staticDir, file), | ||
path.resolve("./dist", file), | ||
); | ||
} | ||
}, | ||
}, | ||
}); |
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,5 @@ | ||
/** | ||
* This is a placeholder CSS file to ease the migration from gatsby-plugin-prismic-previews V4 to V5. | ||
* | ||
* The `gatsby-plugin-prismic-previews/dist/styles.css` import can be removed in V5. | ||
*/ |
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
13 changes: 3 additions & 10 deletions
13
packages/gatsby-plugin-prismic-previews/test/__testutils__/isValidAccessToken.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 |
---|---|---|
@@ -1,20 +1,13 @@ | ||
import * as msw from "msw"; | ||
|
||
// TODO: Uncomment when the Authorization header can be used | ||
// @see Related issue - {@link https://github.com/prismicio/issue-tracker-wroom/issues/351} | ||
// import { createAuthorizationHeader } from "./createAuthorizationHeader"; | ||
import { createAuthorizationHeader } from "./createAuthorizationHeader"; | ||
|
||
export const isValidAccessToken = ( | ||
accessToken: string | undefined, | ||
req: msw.RestRequest, | ||
): boolean => { | ||
// TODO: Uncomment when the Authorization header can be used | ||
// @see Related issue - {@link https://github.com/prismicio/issue-tracker-wroom/issues/351} | ||
// return typeof accessToken === "string" | ||
// ? req.headers.get("Authorization") === | ||
// createAuthorizationHeader(accessToken) | ||
// : true; | ||
return typeof accessToken === "string" | ||
? req.url.searchParams.get("access_token") === accessToken | ||
? req.headers.get("Authorization") === | ||
createAuthorizationHeader(accessToken) | ||
: true; | ||
}; |
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
15 changes: 15 additions & 0 deletions
15
packages/gatsby-source-prismic/src/lib/removeAutoURLParameter.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,15 @@ | ||
/** | ||
* Removes a URL parameter from a given URL. | ||
* | ||
* @param url - URL to modify. | ||
* @param paramKey - Key of the URL parameter to remove. | ||
* | ||
* @returns `url` without the `paramKey` URL parameter. | ||
*/ | ||
export const removeURLParameter = (url: string, paramKey: string) => { | ||
const instance = new URL(url); | ||
|
||
instance.searchParams.delete(paramKey); | ||
|
||
return instance.toString(); | ||
}; |
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.