Skip to content

Commit

Permalink
add fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
yimysty committed Jun 17, 2022
1 parent 9a28a8d commit 7c74d60
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 14 deletions.
11 changes: 5 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14542,6 +14542,10 @@ const espreeOptions = {

class ConfigParser {
constructor(staticSiteConfig) {
this.pathPropertyNuxt = `router: {\n base: '{0}'\n }`
this.pathPropertyNext = `basePath: '{0}'`
this.pathPropertyGatsby = `pathPrefix: '{0}'`
this.configskeleton = `export default {\n {0}\n}`
this.staticSiteConfig = staticSiteConfig
this.config = fs.existsSync(this.staticSiteConfig.filePath) ? fs.readFileSync(this.staticSiteConfig.filePath, "utf8") : null
this.validate()
Expand All @@ -14558,11 +14562,6 @@ class ConfigParser {
}
}

pathPropertyNuxt = `router: {\n base: '{0}'\n }`
pathPropertyNext = `basePath: '{0}'`
pathPropertyGatsby = `pathPrefix: '{0}'`
configskeleton = `export default {\n {0}\n}`

generateConfigFile() {
switch (this.staticSiteConfig.type) {
case "nuxt":
Expand Down Expand Up @@ -14680,13 +14679,13 @@ class ConfigParser {
parseNextGatsby(pathNode) {
if (pathNode) {
console.log("base node = " + JSON.stringify(pathNode.value))

const newConfig = this.config.slice(0, pathNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(pathNode.value.range[1])
console.log("new config = \n" + newConfig)
}
}
}


/***/ }),

/***/ 1319:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions src/config-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const espreeOptions = {

class ConfigParser {
constructor(staticSiteConfig) {
this.pathPropertyNuxt = `router: {\n base: '{0}'\n }`
this.pathPropertyNext = `basePath: '{0}'`
this.pathPropertyGatsby = `pathPrefix: '{0}'`
this.configskeleton = `export default {\n {0}\n}`
this.staticSiteConfig = staticSiteConfig
this.config = fs.existsSync(this.staticSiteConfig.filePath) ? fs.readFileSync(this.staticSiteConfig.filePath, "utf8") : null
this.validate()
Expand All @@ -27,11 +31,6 @@ class ConfigParser {
}
}

pathPropertyNuxt = `router: {\n base: '{0}'\n }`
pathPropertyNext = `basePath: '{0}'`
pathPropertyGatsby = `pathPrefix: '{0}'`
configskeleton = `export default {\n {0}\n}`

generateConfigFile() {
switch (this.staticSiteConfig.type) {
case "nuxt":
Expand Down Expand Up @@ -149,9 +148,8 @@ class ConfigParser {
parseNextGatsby(pathNode) {
if (pathNode) {
console.log("base node = " + JSON.stringify(pathNode.value))

const newConfig = this.config.slice(0, pathNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(pathNode.value.range[1])
console.log("new config = \n" + newConfig)
}
}
}
}
14 changes: 14 additions & 0 deletions src/config-parser.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const ConfigParser = require('./config-parser')

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()
})
})
8 changes: 8 additions & 0 deletions src/fixtures/gatsby-config.js
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: '/prefix',/* test */
}
3 changes: 3 additions & 0 deletions src/fixtures/gatsby-config.old.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
pathPrefix: '/prefix'
}
9 changes: 9 additions & 0 deletions src/fixtures/next.config.js
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: '/gh-pages-test'/* test */,
}
4 changes: 4 additions & 0 deletions src/fixtures/next.config.old.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports={
basePath: '/gh-pages-test'/* test */,
}

4 changes: 4 additions & 0 deletions src/fixtures/next.config.old.missing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports={

}

11 changes: 11 additions & 0 deletions src/fixtures/nuxt.config.js
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: 'some/path'
}
}
8 changes: 8 additions & 0 deletions src/fixtures/nuxt.config.missing.js
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')
},
target: 'static'
}
10 changes: 10 additions & 0 deletions src/fixtures/nuxt.config.old.js
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: 'some/path'
}
}

0 comments on commit 7c74d60

Please sign in to comment.