2022-06-16 14:28:43 -07:00
const core = require ( '@actions/core' )
const axios = require ( 'axios' )
2022-06-17 18:36:26 -07:00
const { ConfigParser } = require ( './config-parser' )
2022-06-16 14:28:43 -07:00
2022-06-17 18:36:26 -07:00
async function setPagesPath ({ staticSiteGenerator , path }) {
2022-06-16 14:28:43 -07:00
try {
switch ( staticSiteGenerator )
{
case 'nuxt' :
var ssConfig = {
filePath : "./nuxt.config.js" ,
type : "nuxt" ,
pathName : "router" ,
subPathName : "base" ,
2022-06-17 18:36:26 -07:00
newPath : path
2022-06-16 14:28:43 -07:00
}
break ;
case 'next' :
var ssConfig = {
filePath : "./next.config.js" ,
type : "next" ,
2022-06-17 15:13:00 -07:00
pathName : "basePath" ,
2022-06-17 18:36:26 -07:00
newPath : path
2022-06-16 14:28:43 -07:00
}
break ;
case 'gatsby' :
var ssConfig = {
filePath : "./gatsby-config.js" ,
type : "gatsby" ,
pathName : "pathPrefix" ,
2022-06-17 18:36:26 -07:00
newPath : path
2022-06-16 14:28:43 -07:00
}
break ;
default :
throw "Unknown config type"
}
let configParser = new ConfigParser ( ssConfig )
2022-06-17 18:36:26 -07:00
configParser . parse ()
2022-06-16 14:28:43 -07:00
} catch ( error ) {
2022-06-30 12:10:35 -07:00
core . warning ( `We were unable to determine how to inject the site metadata into your config. Generated URLs may be incorrect. The base URL for this site should be ${ path } . Please ensure your framework is configured to generate relative links appropriately.` , error )
2022-06-16 14:28:43 -07:00
}
}
module . exports = setPagesPath