| 1992 | * @returns The normalized manifest. |
| 1993 | */ |
| 1994 | export function normalizeManifest<T>( |
| 1995 | manifest: unknown, |
| 1996 | replacements: [search: string, replace: string][] |
| 1997 | ): T { |
| 1998 | return JSON.parse( |
| 1999 | replacements.reduce( |
| 2000 | (acc, [search, replace]) => |
| 2001 | acc.replace( |
| 2002 | new RegExp( |
| 2003 | // We want to match the literal string, so we need to escape it |
| 2004 | // again |
| 2005 | escapeRegex( |
| 2006 | JSON.stringify( |
| 2007 | // The output has already been escaped, so we need to escape our |
| 2008 | // search string. |
| 2009 | escapeRegex(search) |
| 2010 | ) |
| 2011 | // Remove the quotes added by the JSON.stringify call. |
| 2012 | .replace(/^"(.*)"/, '$1') |
| 2013 | ), |
| 2014 | 'g' |
| 2015 | ), |
| 2016 | replace |
| 2017 | ), |
| 2018 | // We'll perform the replacements on the JSON stringified manifest. |
| 2019 | JSON.stringify(manifest) |
| 2020 | ) |
| 2021 | ) |
| 2022 | } |
| 2023 | |
| 2024 | export function getDistDir(): '.next' | '.next/dev' { |
| 2025 | // global.isNextDev is set in e2e/development/production tests. |