-
-
Notifications
You must be signed in to change notification settings - Fork 77
automatic merging of next.config.js files #222
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e398387
rough draft
roggenkemper 14baa1b
updates
roggenkemper e07067d
Merge branch 'master' into roggenkemper/mergenextjs
roggenkemper cac5515
edits
roggenkemper 7ba6320
Merge branch 'roggenkemper/mergenextjs' of https://github.com/getsent…
roggenkemper b732737
small edits
roggenkemper b881fb5
newline
roggenkemper 6ebd9da
new line issue
roggenkemper d679945
updated process
roggenkemper 2e1ec1f
Merge branch 'master' into roggenkemper/mergenextjs
roggenkemper cadab7d
small update to cli
roggenkemper 99a0e01
merge
roggenkemper ea5d250
updated template
roggenkemper c50f130
updates
roggenkemper cb82756
new function for merging
roggenkemper e628ea9
lint errors
roggenkemper 0c801a0
Merge branch 'master' into roggenkemper/mergenextjs
roggenkemper 5dc5c3d
added tests
roggenkemper 3f6fba3
Merge branch 'roggenkemper/mergenextjs' of https://github.com/getsent…
roggenkemper 61daf90
fix import order
roggenkemper 1af61df
fix import order
roggenkemper ba78505
fixes
roggenkemper a134b04
edits
roggenkemper fa7095e
fix linter folder
roggenkemper 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 hidden or 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 hidden or 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 hidden or 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,18 @@ | ||
| import * as fs from 'fs'; | ||
|
|
||
| // merges the config files | ||
| export function mergeConfigFile( | ||
| sourcePath: string, | ||
| templatePath: string, | ||
| ): boolean { | ||
| try { | ||
| const templateFile = fs.readFileSync(templatePath, 'utf8'); | ||
| const sourceFile = fs.readFileSync(sourcePath, 'utf8'); | ||
| const newText = templateFile.replace('// ORIGINAL CONFIG', sourceFile); | ||
| Function(newText); // check if the file is valid javascript | ||
| fs.writeFileSync(sourcePath, newText); | ||
| return true; | ||
| } catch (error) { | ||
| return false; | ||
| } | ||
| } | ||
This file contains hidden or 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,77 @@ | ||
| /// <reference types="jest" /> | ||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
|
|
||
| import { mergeConfigFile } from '../MergeConfig'; | ||
|
|
||
| const configPath = path.join(__dirname, '..', 'test-fixtures/next.config.js'); | ||
| const templatePath = path.join( | ||
| __dirname, | ||
| '..', | ||
| '..', | ||
| '..', | ||
| 'scripts/NextJS/configs/next.config.template.js', | ||
| ); | ||
|
|
||
| function configFileNames(num: number): { | ||
| sourcePath: string; | ||
| mergedPath: string; | ||
| } { | ||
| const sourcePath = path.join( | ||
| __dirname, | ||
| '..', | ||
| `test-fixtures/next.config.${num}.js`, | ||
| ); | ||
| const mergedPath = path.join( | ||
| __dirname, | ||
| '..', | ||
| `test-fixtures/next.config.${num}-merged.js`, | ||
| ); | ||
| return { sourcePath, mergedPath }; | ||
| } | ||
|
|
||
| describe('Merging next.config.js', () => { | ||
| test('merge basic next.config.js', () => { | ||
| const { sourcePath, mergedPath } = configFileNames(1); | ||
| fs.copyFileSync(sourcePath, configPath); | ||
|
|
||
| expect(mergeConfigFile(configPath, templatePath)).toBe(true); | ||
| expect( | ||
| fs.readFileSync(configPath, 'utf8') === | ||
| fs.readFileSync(mergedPath, 'utf8'), | ||
| ).toBe(true); | ||
| fs.unlinkSync(configPath); | ||
| }); | ||
|
|
||
| test('merge invalid javascript config', () => { | ||
| const { sourcePath } = configFileNames(2); | ||
| fs.copyFileSync(sourcePath, configPath); | ||
|
|
||
| expect(mergeConfigFile(configPath, templatePath)).toBe(false); | ||
| fs.unlinkSync(configPath); | ||
| }); | ||
|
|
||
| test('merge more complicated next.config.js', () => { | ||
| const { sourcePath, mergedPath } = configFileNames(3); | ||
| fs.copyFileSync(sourcePath, configPath); | ||
|
|
||
| expect(mergeConfigFile(configPath, templatePath)).toBe(true); | ||
| expect( | ||
| fs.readFileSync(configPath, 'utf8') === | ||
| fs.readFileSync(mergedPath, 'utf8'), | ||
| ).toBe(true); | ||
| fs.unlinkSync(configPath); | ||
| }); | ||
|
|
||
| test('merge next.config.js with function', () => { | ||
| const { sourcePath, mergedPath } = configFileNames(4); | ||
| fs.copyFileSync(sourcePath, configPath); | ||
|
|
||
| expect(mergeConfigFile(configPath, templatePath)).toBe(true); | ||
| expect( | ||
| fs.readFileSync(configPath, 'utf8') === | ||
| fs.readFileSync(mergedPath, 'utf8'), | ||
| ).toBe(true); | ||
| fs.unlinkSync(configPath); | ||
| }); | ||
| }); |
This file contains hidden or 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,18 @@ | ||
| // This file sets a custom webpack configuration to use your Next.js app | ||
| // with Sentry. | ||
| // https://nextjs.org/docs/api-reference/next.config.js/introduction | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ | ||
| const { withSentryConfig } = require('@sentry/nextjs'); | ||
|
|
||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| reactStrictMode: true, | ||
| }; | ||
|
|
||
| module.exports = nextConfig; | ||
|
|
||
| module.exports = withSentryConfig( | ||
| module.exports, | ||
| { silent: true }, | ||
| { hideSourcemaps: true }, | ||
| ); |
This file contains hidden or 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,6 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| reactStrictMode: true, | ||
| }; | ||
|
|
||
| module.exports = nextConfig; |
This file contains hidden or 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,8 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| reactStrictMode: true, | ||
|
|
||
|
|
||
|
|
||
|
|
||
| module.exports = nextConfig; |
This file contains hidden or 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,21 @@ | ||
| // This file sets a custom webpack configuration to use your Next.js app | ||
| // with Sentry. | ||
| // https://nextjs.org/docs/api-reference/next.config.js/introduction | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ | ||
| const { withSentryConfig } = require('@sentry/nextjs'); | ||
|
|
||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| reactStrictMode: true, | ||
| images: { | ||
| domains: [], | ||
| }, | ||
| }; | ||
|
|
||
| module.exports = nextConfig; | ||
|
|
||
| module.exports = withSentryConfig( | ||
| module.exports, | ||
| { silent: true }, | ||
| { hideSourcemaps: true }, | ||
| ); |
This file contains hidden or 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,9 @@ | ||
| /** @type {import('next').NextConfig} */ | ||
| const nextConfig = { | ||
| reactStrictMode: true, | ||
| images: { | ||
| domains: [], | ||
| }, | ||
| }; | ||
|
|
||
| module.exports = nextConfig; |
This file contains hidden or 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,21 @@ | ||
| // This file sets a custom webpack configuration to use your Next.js app | ||
| // with Sentry. | ||
| // https://nextjs.org/docs/api-reference/next.config.js/introduction | ||
| // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ | ||
| const { withSentryConfig } = require('@sentry/nextjs'); | ||
|
|
||
| module.exports = (phase, { defaultConfig }) => { | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const nextConfig = { | ||
| /* config options here */ | ||
| }; | ||
| return nextConfig; | ||
| }; | ||
|
|
||
| module.exports = withSentryConfig( | ||
| module.exports, | ||
| { silent: true }, | ||
| { hideSourcemaps: true }, | ||
| ); |
This file contains hidden or 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,9 @@ | ||
| module.exports = (phase, { defaultConfig }) => { | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const nextConfig = { | ||
| /* config options here */ | ||
| }; | ||
| return nextConfig; | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.