mirror of
https://github.com/actions/configure-pages.git
synced 2026-02-09 03:45:14 +00:00
add test cases
This commit is contained in:
46
dist/index.js
vendored
46
dist/index.js
vendored
@@ -14527,7 +14527,7 @@ exports.debug = debug; // for test
|
|||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 8395:
|
/***/ 8395:
|
||||||
/***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => {
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
const fs = __nccwpck_require__(7147)
|
const fs = __nccwpck_require__(7147)
|
||||||
const espree = __nccwpck_require__(6910)
|
const espree = __nccwpck_require__(6910)
|
||||||
@@ -14595,6 +14595,7 @@ class ConfigParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse() {
|
parse() {
|
||||||
|
console.log(`original configuration:\n${this.config}`)
|
||||||
const ast = espree.parse(this.config, espreeOptions);
|
const ast = espree.parse(this.config, espreeOptions);
|
||||||
|
|
||||||
// Find the default export declaration node
|
// Find the default export declaration node
|
||||||
@@ -14621,6 +14622,9 @@ class ConfigParser {
|
|||||||
throw "Unknown config type"
|
throw "Unknown config type"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(`parsed configuration:\n${this.config}`)
|
||||||
|
fs.writeFileSync(this.staticSiteConfig.filePath, this.config)
|
||||||
|
return this.config
|
||||||
}
|
}
|
||||||
|
|
||||||
getPropertyModuleExport(exportNode) {
|
getPropertyModuleExport(exportNode) {
|
||||||
@@ -14632,11 +14636,11 @@ class ConfigParser {
|
|||||||
|
|
||||||
console.log("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
|
console.log("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
|
||||||
if (exportNode.expression.right.properties.length > 0) {
|
if (exportNode.expression.right.properties.length > 0) {
|
||||||
const newConfig = this.config.slice(0, exportNode.expression.right.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.expression.right.properties[0].range[0])
|
this.config = this.config.slice(0, exportNode.expression.right.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.expression.right.properties[0].range[0])
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
} else {
|
} else {
|
||||||
const newConfig = this.config.slice(0, exportNode.expression.right.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.expression.right.range[1] - 1)
|
this.config = this.config.slice(0, exportNode.expression.right.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.expression.right.range[1] - 1)
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return propertyNode
|
return propertyNode
|
||||||
@@ -14651,11 +14655,11 @@ class ConfigParser {
|
|||||||
|
|
||||||
console.log("Unable to find property, insert it " + this.staticSiteConfig.pathName)
|
console.log("Unable to find property, insert it " + this.staticSiteConfig.pathName)
|
||||||
if (exportNode.declaration.properties.length > 0) {
|
if (exportNode.declaration.properties.length > 0) {
|
||||||
const newConfig = this.config.slice(0, exportNode.declaration.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.declaration.properties[0].range[0])
|
this.config = this.config.slice(0, exportNode.declaration.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.declaration.properties[0].range[0])
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
} else {
|
} else {
|
||||||
const newConfig = this.config.slice(0, exportNode.declaration.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.declaration.range[1] - 1)
|
this.config = this.config.slice(0, exportNode.declaration.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.declaration.range[1] - 1)
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14667,24 +14671,20 @@ class ConfigParser {
|
|||||||
if (propertyNode && propertyNode.value.type === 'ObjectExpression') {
|
if (propertyNode && propertyNode.value.type === 'ObjectExpression') {
|
||||||
var baseNode = propertyNode.value.properties.find(node => node.key.type === 'Identifier' && node.key.name === this.staticSiteConfig.subPathName)//'base')
|
var baseNode = propertyNode.value.properties.find(node => node.key.type === 'Identifier' && node.key.name === this.staticSiteConfig.subPathName)//'base')
|
||||||
if (baseNode) {
|
if (baseNode) {
|
||||||
console.log("base node = " + JSON.stringify(baseNode.value))
|
|
||||||
|
|
||||||
// Swap the base value by a hardcoded string and print it
|
// Swap the base value by a hardcoded string and print it
|
||||||
const newConfig = this.config.slice(0, baseNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(baseNode.value.range[1])
|
this.config = this.config.slice(0, baseNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(baseNode.value.range[1])
|
||||||
console.log("new config = \n" + newConfig)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parseNextGatsby(pathNode) {
|
parseNextGatsby(pathNode) {
|
||||||
if (pathNode) {
|
if (pathNode) {
|
||||||
console.log("base node = " + JSON.stringify(pathNode.value))
|
this.config = this.config.slice(0, pathNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(pathNode.value.range[1])
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {ConfigParser}
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@@ -14781,7 +14781,7 @@ async function getPagesBaseUrl({ repositoryNwo, githubToken, staticSiteGenerator
|
|||||||
|
|
||||||
const siteUrl = new URL(pageObject.html_url)
|
const siteUrl = new URL(pageObject.html_url)
|
||||||
if ( staticSiteGenerator ) {
|
if ( staticSiteGenerator ) {
|
||||||
setPagesPath({staticSiteGenerator, baseUrl: siteUrl.origin})
|
setPagesPath({staticSiteGenerator, path: siteUrl.pathname})
|
||||||
}
|
}
|
||||||
|
|
||||||
core.setOutput('base_url', siteUrl.href)
|
core.setOutput('base_url', siteUrl.href)
|
||||||
@@ -14804,9 +14804,9 @@ module.exports = getPagesBaseUrl
|
|||||||
|
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
const axios = __nccwpck_require__(6545)
|
const axios = __nccwpck_require__(6545)
|
||||||
const ConfigParser = __nccwpck_require__(8395)
|
const { ConfigParser } = __nccwpck_require__(8395)
|
||||||
|
|
||||||
async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
async function setPagesPath({staticSiteGenerator, path}) {
|
||||||
try {
|
try {
|
||||||
switch(staticSiteGenerator)
|
switch(staticSiteGenerator)
|
||||||
{
|
{
|
||||||
@@ -14816,7 +14816,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
type: "nuxt",
|
type: "nuxt",
|
||||||
pathName: "router",
|
pathName: "router",
|
||||||
subPathName: "base",
|
subPathName: "base",
|
||||||
newPath: baseUrl
|
newPath: path
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'next':
|
case 'next':
|
||||||
@@ -14824,7 +14824,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
filePath:"./next.config.js",
|
filePath:"./next.config.js",
|
||||||
type: "next",
|
type: "next",
|
||||||
pathName: "basePath",
|
pathName: "basePath",
|
||||||
newPath: baseUrl
|
newPath: path
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'gatsby':
|
case 'gatsby':
|
||||||
@@ -14832,7 +14832,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
filePath: "./gatsby-config.js",
|
filePath: "./gatsby-config.js",
|
||||||
type: "gatsby",
|
type: "gatsby",
|
||||||
pathName: "pathPrefix",
|
pathName: "pathPrefix",
|
||||||
newPath: baseUrl
|
newPath: path
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -14840,7 +14840,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let configParser = new ConfigParser(ssConfig)
|
let configParser = new ConfigParser(ssConfig)
|
||||||
if (configParser.config) configParser.parse()
|
configParser.parse()
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error('Set pages path in the static site generator config failed', error)
|
core.error('Set pages path in the static site generator config failed', error)
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
5
nuxt.config.js
Normal file
5
nuxt.config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export default {
|
||||||
|
router: {
|
||||||
|
base: '/amazing-new-repo/'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,6 +64,7 @@ class ConfigParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parse() {
|
parse() {
|
||||||
|
console.log(`original configuration:\n${this.config}`)
|
||||||
const ast = espree.parse(this.config, espreeOptions);
|
const ast = espree.parse(this.config, espreeOptions);
|
||||||
|
|
||||||
// Find the default export declaration node
|
// Find the default export declaration node
|
||||||
@@ -90,6 +91,9 @@ class ConfigParser {
|
|||||||
throw "Unknown config type"
|
throw "Unknown config type"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(`parsed configuration:\n${this.config}`)
|
||||||
|
fs.writeFileSync(this.staticSiteConfig.filePath, this.config)
|
||||||
|
return this.config
|
||||||
}
|
}
|
||||||
|
|
||||||
getPropertyModuleExport(exportNode) {
|
getPropertyModuleExport(exportNode) {
|
||||||
@@ -101,11 +105,11 @@ class ConfigParser {
|
|||||||
|
|
||||||
console.log("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
|
console.log("Unable to find property, insert it : " + this.staticSiteConfig.pathName)
|
||||||
if (exportNode.expression.right.properties.length > 0) {
|
if (exportNode.expression.right.properties.length > 0) {
|
||||||
const newConfig = this.config.slice(0, exportNode.expression.right.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.expression.right.properties[0].range[0])
|
this.config = this.config.slice(0, exportNode.expression.right.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.expression.right.properties[0].range[0])
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
} else {
|
} else {
|
||||||
const newConfig = this.config.slice(0, exportNode.expression.right.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.expression.right.range[1] - 1)
|
this.config = this.config.slice(0, exportNode.expression.right.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.expression.right.range[1] - 1)
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return propertyNode
|
return propertyNode
|
||||||
@@ -120,11 +124,11 @@ class ConfigParser {
|
|||||||
|
|
||||||
console.log("Unable to find property, insert it " + this.staticSiteConfig.pathName)
|
console.log("Unable to find property, insert it " + this.staticSiteConfig.pathName)
|
||||||
if (exportNode.declaration.properties.length > 0) {
|
if (exportNode.declaration.properties.length > 0) {
|
||||||
const newConfig = this.config.slice(0, exportNode.declaration.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.declaration.properties[0].range[0])
|
this.config = this.config.slice(0, exportNode.declaration.properties[0].range[0]) + this.generateConfigProperty() + ',\n' + this.config.slice(exportNode.declaration.properties[0].range[0])
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
} else {
|
} else {
|
||||||
const newConfig = this.config.slice(0, exportNode.declaration.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.declaration.range[1] - 1)
|
this.config = this.config.slice(0, exportNode.declaration.range[0] + 1) + '\n ' + this.generateConfigProperty() + '\n' + this.config.slice(exportNode.declaration.range[1] - 1)
|
||||||
console.log("new config = \n" + newConfig)
|
console.log("new config = \n" + this.config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,20 +140,17 @@ class ConfigParser {
|
|||||||
if (propertyNode && propertyNode.value.type === 'ObjectExpression') {
|
if (propertyNode && propertyNode.value.type === 'ObjectExpression') {
|
||||||
var baseNode = propertyNode.value.properties.find(node => node.key.type === 'Identifier' && node.key.name === this.staticSiteConfig.subPathName)//'base')
|
var baseNode = propertyNode.value.properties.find(node => node.key.type === 'Identifier' && node.key.name === this.staticSiteConfig.subPathName)//'base')
|
||||||
if (baseNode) {
|
if (baseNode) {
|
||||||
console.log("base node = " + JSON.stringify(baseNode.value))
|
|
||||||
|
|
||||||
// Swap the base value by a hardcoded string and print it
|
// Swap the base value by a hardcoded string and print it
|
||||||
const newConfig = this.config.slice(0, baseNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(baseNode.value.range[1])
|
this.config = this.config.slice(0, baseNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(baseNode.value.range[1])
|
||||||
console.log("new config = \n" + newConfig)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parseNextGatsby(pathNode) {
|
parseNextGatsby(pathNode) {
|
||||||
if (pathNode) {
|
if (pathNode) {
|
||||||
console.log("base node = " + JSON.stringify(pathNode.value))
|
this.config = this.config.slice(0, pathNode.value.range[0]) + `'${this.staticSiteConfig.newPath}'` + this.config.slice(pathNode.value.range[1])
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {ConfigParser}
|
||||||
@@ -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', () => {
|
describe('configParser', () => {
|
||||||
it('set nextjs url correctly', async () => {
|
test.each(cases)(
|
||||||
// parser = new ConfigParser({
|
"%p parsed correctly",
|
||||||
// filePath:"./nuxt.config.js",
|
(fileName, configuration) => {
|
||||||
// type: "nuxt",
|
srcFileName = `${srcFolder}/${fileName}`
|
||||||
// pathName: "router",
|
tmpFileName = `${tmpFolder}/${fileName}`
|
||||||
// subPathName: "base",
|
expectedFileName = `${expectedFolder}/${fileName}`
|
||||||
// newPath: baseUrl
|
|
||||||
// })
|
fs.copyFileSync(srcFileName, tmpFileName)
|
||||||
// parser.generateConfigFile()
|
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)
|
||||||
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
8
src/fixtures/expected/gatsby-config.js
Normal file
8
src/fixtures/expected/gatsby-config.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { resolve } from 'path'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
alias: {
|
||||||
|
'style': resolve(__dirname, './assets/style')
|
||||||
|
},
|
||||||
|
pathPrefix: '/amazing-new-repo/',/* test */
|
||||||
|
}
|
||||||
3
src/fixtures/expected/gatsby-config.old.js
Normal file
3
src/fixtures/expected/gatsby-config.old.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
pathPrefix: '/amazing-new-repo/'
|
||||||
|
}
|
||||||
9
src/fixtures/expected/next.config.js
Normal file
9
src/fixtures/expected/next.config.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
import { resolve } from 'path'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
alias: {
|
||||||
|
'style': resolve(__dirname, './assets/style')
|
||||||
|
},
|
||||||
|
basePath: '/amazing-new-repo/'/* test */,
|
||||||
|
}
|
||||||
4
src/fixtures/expected/next.config.old.js
Normal file
4
src/fixtures/expected/next.config.old.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports={
|
||||||
|
basePath: '/amazing-new-repo/'/* test */,
|
||||||
|
}
|
||||||
|
|
||||||
4
src/fixtures/expected/next.config.old.missing.js
Normal file
4
src/fixtures/expected/next.config.old.missing.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports={
|
||||||
|
basePath: '/amazing-new-repo/'
|
||||||
|
}
|
||||||
|
|
||||||
11
src/fixtures/expected/nuxt.config.js
Normal file
11
src/fixtures/expected/nuxt.config.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { resolve } from 'path'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
alias: {
|
||||||
|
'style': resolve(__dirname, './assets/style')
|
||||||
|
},
|
||||||
|
target: 'static',
|
||||||
|
router: {
|
||||||
|
base: '/amazing-new-repo/'
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/fixtures/expected/nuxt.config.missing.js
Normal file
11
src/fixtures/expected/nuxt.config.missing.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { resolve } from 'path'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
router: {
|
||||||
|
base: '/amazing-new-repo/'
|
||||||
|
},
|
||||||
|
alias: {
|
||||||
|
'style': resolve(__dirname, './assets/style')
|
||||||
|
},
|
||||||
|
target: 'static'
|
||||||
|
}
|
||||||
10
src/fixtures/expected/nuxt.config.old.js
Normal file
10
src/fixtures/expected/nuxt.config.old.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
module.exports={
|
||||||
|
alias: {
|
||||||
|
'style': resolve(__dirname, './assets/style')
|
||||||
|
},
|
||||||
|
target: 'static',
|
||||||
|
router: {
|
||||||
|
base: '/amazing-new-repo/'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ async function getPagesBaseUrl({ repositoryNwo, githubToken, staticSiteGenerator
|
|||||||
|
|
||||||
const siteUrl = new URL(pageObject.html_url)
|
const siteUrl = new URL(pageObject.html_url)
|
||||||
if ( staticSiteGenerator ) {
|
if ( staticSiteGenerator ) {
|
||||||
setPagesPath({staticSiteGenerator, baseUrl: siteUrl.origin})
|
setPagesPath({staticSiteGenerator, path: siteUrl.pathname})
|
||||||
}
|
}
|
||||||
|
|
||||||
core.setOutput('base_url', siteUrl.href)
|
core.setOutput('base_url', siteUrl.href)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const ConfigParser = require('./config-parser')
|
const { ConfigParser } = require('./config-parser')
|
||||||
|
|
||||||
async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
async function setPagesPath({staticSiteGenerator, path}) {
|
||||||
try {
|
try {
|
||||||
switch(staticSiteGenerator)
|
switch(staticSiteGenerator)
|
||||||
{
|
{
|
||||||
@@ -12,7 +12,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
type: "nuxt",
|
type: "nuxt",
|
||||||
pathName: "router",
|
pathName: "router",
|
||||||
subPathName: "base",
|
subPathName: "base",
|
||||||
newPath: baseUrl
|
newPath: path
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'next':
|
case 'next':
|
||||||
@@ -20,7 +20,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
filePath:"./next.config.js",
|
filePath:"./next.config.js",
|
||||||
type: "next",
|
type: "next",
|
||||||
pathName: "basePath",
|
pathName: "basePath",
|
||||||
newPath: baseUrl
|
newPath: path
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'gatsby':
|
case 'gatsby':
|
||||||
@@ -28,7 +28,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
filePath: "./gatsby-config.js",
|
filePath: "./gatsby-config.js",
|
||||||
type: "gatsby",
|
type: "gatsby",
|
||||||
pathName: "pathPrefix",
|
pathName: "pathPrefix",
|
||||||
newPath: baseUrl
|
newPath: path
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -36,7 +36,7 @@ async function setPagesPath({staticSiteGenerator, baseUrl}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let configParser = new ConfigParser(ssConfig)
|
let configParser = new ConfigParser(ssConfig)
|
||||||
if (configParser.config) configParser.parse()
|
configParser.parse()
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error('Set pages path in the static site generator config failed', error)
|
core.error('Set pages path in the static site generator config failed', error)
|
||||||
|
|||||||
Reference in New Issue
Block a user