Skip to content

Commit

Permalink
Update dist
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoann Chaudet committed Jul 19, 2022
1 parent ba4576e commit 8f29fe2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 43 deletions.
47 changes: 21 additions & 26 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63059,7 +63059,8 @@ class ConfigParser {
}
}

parse() {
// Parse a configuration file and try to inject Pages settings in it.
inject() {
// Logging
core.info(`Parsing configuration:\n${this.configuration}`)

Expand Down Expand Up @@ -63155,23 +63156,8 @@ class ConfigParser {
}
}

// Format the updated configuration with prettier's default settings
this.configuration = prettier.format(this.configuration, {
parser: 'espree',

// Matching this repo's prettier configuration
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
})

// Logging
core.info(`Parsing configuration:\n${this.configuration}`)
core.info(`Writing new configuration:\n${this.configuration}`)

// Finally write the new configuration in the file
fs.writeFileSync(this.configurationFile, this.configuration, {
Expand Down Expand Up @@ -63199,7 +63185,8 @@ function getRequiredVars() {
}
}

module.exports = function getContext() {
// Return the context object
function getContext() {
const requiredVars = getRequiredVars()
for (const variable in requiredVars) {
if (requiredVars[variable] === undefined) {
Expand All @@ -63210,6 +63197,8 @@ module.exports = function getContext() {
return requiredVars
}

module.exports = {getContext}


/***/ }),

Expand Down Expand Up @@ -63302,47 +63291,53 @@ module.exports = getPagesBaseUrl
const core = __nccwpck_require__(2186)
const {ConfigParser} = __nccwpck_require__(8395)

function getParserConfiguration(staticSiteGenerator, path) {
// Return the settings to be passed to a {ConfigParser} for a given
// static site generator and a Pages path value to inject
function getConfigParserSettings(staticSiteGenerator, path) {
switch (staticSiteGenerator) {
case 'nuxt':
return {
configurationFile: './nuxt.config.js',
propertyName: 'router.base',
propertyValue: path,
blankConfigurationFile: `${process.cwd()}/blank-configurations/nuxt.js`
blankConfigurationFile: __nccwpck_require__.ab + "nuxt.js"
}
case 'next':
return {
configurationFile: './next.config.js',
propertyName: 'basePath',
propertyValue: path,
blankConfigurationFile: `${process.cwd()}/blank-configurations/next.js`
blankConfigurationFile: __nccwpck_require__.ab + "next.js"
}
case 'gatsby':
return {
configurationFile: './gatsby-config.js',
propertyName: 'pathPrefix',
propertyValue: path,
blankConfigurationFile: `${process.cwd()}/blank-configurations/gatsby.js`
blankConfigurationFile: __nccwpck_require__.ab + "gatsby.js"
}
default:
throw `Unsupported static site generator: ${staticSiteGenerator}`
}
}

async function setPagesPath({staticSiteGenerator, path}) {
// Inject Pages configuration in a given static site generator's configuration file
function setPagesPath({staticSiteGenerator, path}) {
try {
// Parse/mutate the configuration file
new ConfigParser(getParserConfiguration(staticSiteGenerator, path)).parse()
// Parse the configuration file and try to inject the Pages configuration in it
new ConfigParser(
getConfigParserSettings(staticSiteGenerator, path)
).inject()
} catch (error) {
// Logging
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
)
}
}

module.exports = setPagesPath
module.exports = {getConfigParserSettings, setPagesPath}


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

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions src/config-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,8 @@ class ConfigParser {
}
}

// Format the updated configuration with prettier's default settings
this.configuration = prettier.format(this.configuration, {
parser: 'espree',

// Matching this repo's prettier configuration
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: true,
trailingComma: 'none',
bracketSpacing: false,
arrowParens: 'avoid'
})

// Logging
core.info(`Parsing configuration:\n${this.configuration}`)
core.info(`Writing new configuration:\n${this.configuration}`)

// Finally write the new configuration in the file
fs.writeFileSync(this.configurationFile, this.configuration, {
Expand Down

0 comments on commit 8f29fe2

Please sign in to comment.