-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yimysty
committed
Jun 18, 2022
1 parent
7c74d60
commit 0af6e78
Showing
15 changed files
with
193 additions
and
58 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
| export default { | ||
| router: { | ||
| base: '/amazing-new-repo/' | ||
| } | ||
| } |
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,14 +1,83 @@ | ||
| const ConfigParser = require('./config-parser') | ||
| const { ConfigParser } = require('./config-parser') | ||
| const fs = require("fs") | ||
| const assert = require('assert') | ||
|
|
||
| const srcFolder = `src/fixtures` | ||
| const tmpFolder = `src/fixtures/tmp` | ||
| const expectedFolder = `src/fixtures/expected` | ||
|
|
||
| const repoPath = "/amazing-new-repo/" | ||
|
|
||
| const cases = [ | ||
| ["next.config.js", { | ||
| filePath: `${tmpFolder}/next.config.js`, | ||
| type: "next", | ||
| pathName: "basePath", | ||
| newPath: repoPath | ||
| }], | ||
| ["next.config.old.js", { | ||
| filePath: `${tmpFolder}/next.config.old.js`, | ||
| type: "next", | ||
| pathName: "basePath", | ||
| newPath: repoPath | ||
| }], | ||
| ["next.config.old.missing.js", { | ||
| filePath: `${tmpFolder}/next.config.old.missing.js`, | ||
| type: "next", | ||
| pathName: "basePath", | ||
| newPath: repoPath | ||
| }], | ||
| ["gatsby-config.js", { | ||
| filePath: `${tmpFolder}/gatsby-config.js`, | ||
| type: "gatsby", | ||
| pathName: "pathPrefix", | ||
| newPath: repoPath | ||
| }], | ||
| ["gatsby-config.old.js", { | ||
| filePath: `${tmpFolder}/gatsby-config.old.js`, | ||
| type: "gatsby", | ||
| pathName: "pathPrefix", | ||
| newPath: repoPath | ||
| }], | ||
| ["nuxt.config.js", { | ||
| filePath:`${tmpFolder}/nuxt.config.js`, | ||
| type: "nuxt", | ||
| pathName: "router", | ||
| subPathName: "base", | ||
| newPath: repoPath | ||
| }], | ||
| ["nuxt.config.missing.js", { | ||
| filePath:`${tmpFolder}/nuxt.config.missing.js`, | ||
| type: "nuxt", | ||
| pathName: "router", | ||
| subPathName: "base", | ||
| newPath: repoPath | ||
| }], | ||
| ["nuxt.config.old.js", { | ||
| filePath:`${tmpFolder}/nuxt.config.old.js`, | ||
| type: "nuxt", | ||
| pathName: "router", | ||
| subPathName: "base", | ||
| newPath: repoPath | ||
| }], | ||
| ]; | ||
|
|
||
| describe('configParser', () => { | ||
| it('set nextjs url correctly', async () => { | ||
| // parser = new ConfigParser({ | ||
| // filePath:"./nuxt.config.js", | ||
| // type: "nuxt", | ||
| // pathName: "router", | ||
| // subPathName: "base", | ||
| // newPath: baseUrl | ||
| // }) | ||
| // parser.generateConfigFile() | ||
| }) | ||
| }) | ||
| test.each(cases)( | ||
| "%p parsed correctly", | ||
| (fileName, configuration) => { | ||
| srcFileName = `${srcFolder}/${fileName}` | ||
| tmpFileName = `${tmpFolder}/${fileName}` | ||
| expectedFileName = `${expectedFolder}/${fileName}` | ||
|
|
||
| fs.copyFileSync(srcFileName, tmpFileName) | ||
| const parser = new ConfigParser(configuration) | ||
| parser.parse() | ||
|
|
||
| var expectedContent = fs.readFileSync(expectedFileName).toString() | ||
| var actualContent = fs.readFileSync(tmpFileName).toString() | ||
| assert.equal(actualContent, expectedContent) | ||
| fs.rmSync(tmpFileName) | ||
| } | ||
| ) | ||
| }) |
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,8 @@ | ||
| import { resolve } from 'path' | ||
|
|
||
| export default { | ||
| alias: { | ||
| 'style': resolve(__dirname, './assets/style') | ||
| }, | ||
| pathPrefix: '/amazing-new-repo/',/* test */ | ||
| } |
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,3 @@ | ||
| module.exports = { | ||
| pathPrefix: '/amazing-new-repo/' | ||
| } |
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,9 @@ | ||
|
|
||
| import { resolve } from 'path' | ||
|
|
||
| export default { | ||
| alias: { | ||
| 'style': resolve(__dirname, './assets/style') | ||
| }, | ||
| basePath: '/amazing-new-repo/'/* test */, | ||
| } |
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,4 @@ | ||
| module.exports={ | ||
| basePath: '/amazing-new-repo/'/* test */, | ||
| } | ||
|
|
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,4 @@ | ||
| module.exports={ | ||
| basePath: '/amazing-new-repo/' | ||
| } | ||
|
|
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,11 @@ | ||
| import { resolve } from 'path' | ||
|
|
||
| export default { | ||
| alias: { | ||
| 'style': resolve(__dirname, './assets/style') | ||
| }, | ||
| target: 'static', | ||
| router: { | ||
| base: '/amazing-new-repo/' | ||
| } | ||
| } |
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,11 @@ | ||
| import { resolve } from 'path' | ||
|
|
||
| export default { | ||
| router: { | ||
| base: '/amazing-new-repo/' | ||
| }, | ||
| alias: { | ||
| 'style': resolve(__dirname, './assets/style') | ||
| }, | ||
| target: 'static' | ||
| } |
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,10 @@ | ||
|
|
||
| module.exports={ | ||
| alias: { | ||
| 'style': resolve(__dirname, './assets/style') | ||
| }, | ||
| target: 'static', | ||
| router: { | ||
| base: '/amazing-new-repo/' | ||
| } | ||
| } |
Oops, something went wrong.