Parse the static sit config, inject pages url

This commit is contained in:
Smitha Borkar
2022-06-16 14:28:43 -07:00
parent dabdcba737
commit 351ece72e7
10 changed files with 14221 additions and 9 deletions

47
src/set-pages-path.js Normal file
View File

@@ -0,0 +1,47 @@
const core = require('@actions/core')
const axios = require('axios')
import ConfigParser from './config-parser.js'
async function setPagesPath({staticSiteGenerator, baseUrl}) {
try {
switch(staticSiteGenerator)
{
case 'nuxt':
var ssConfig = {
filePath:"./nuxt.config.js",
type: "nuxt",
pathName: "router",
subPathName: "base",
newPath: baseUrl
}
break;
case 'next':
var ssConfig = {
filePath:"./next.config.js",
type: "next",
pathName: "basePath",
newPath: baseUrl
}
break;
case 'gatsby':
var ssConfig = {
filePath: "./gatsby-config.js",
type: "gatsby",
pathName: "pathPrefix",
newPath: baseUrl
}
break;
default:
throw "Unknown config type"
}
let configParser = new ConfigParser(ssConfig)
if (configParser.config) configParser.parse()
} catch (error) {
core.error('Set pages path in the static site generator config failed', error)
throw error
}
}
module.exports = setPagesPath