7 Commits

Author SHA1 Message Date
James M. Greene
45efe60937 Apply consistent spacing and use of single quotes 2022-09-11 10:23:22 -05:00
James M. Greene
35c001ded6 Dereference as 'path'
This minimizes the changes to the codebase, as well as slightly clarifying that its value may not remain the same as the 'pathname'
2022-09-11 10:23:22 -05:00
James M. Greene
27457957e6 Merge pull request #21 from AndrewLester/ssg-origin
Use GitHub Pages site origin for setting up SSG configs
2022-09-11 10:21:18 -05:00
AndrewLester
7ec0edaa8e Fix prepare output 2022-08-19 15:10:01 -05:00
AndrewLester
d48340abcd Use GitHub Pages site origin for setting up SSG configs 2022-08-19 14:33:39 -05:00
James M. Greene
f53b57ff56 Merge pull request #20 from actions/update-major-on-full-releases
Update major version only on full releases
2022-08-19 13:21:44 -05:00
James M. Greene
6d1d650751 Update major version only on full releases 2022-08-19 12:44:16 -05:00
26 changed files with 142 additions and 148 deletions

View File

@@ -1,7 +1,7 @@
name: Release
on:
release:
types: [published]
types: [released]
workflow_dispatch:
inputs:
TAG_NAME:

View File

@@ -2,7 +2,7 @@
A GitHub Action to enable Pages and extract various metadata about a site. It can also be used to configure various static site generators we support as [starter workflows][starter-workflows].
See [`set-pages-path.js`](src/set-pages-path.js) for more details on how we configure static site generators to work "out of the box" with GitHub Pages.
See [`set-pages-config.js`](src/set-pages-config.js) for more details on how we configure static site generators to work "out of the box" with GitHub Pages.
# Usage

30
dist/index.js vendored
View File

@@ -15438,7 +15438,7 @@ class ConfigParser {
throw 'Could not find a configuration object in the configuration file'
}
// A property may be nested in the configuration file. Split the property name with `.`
// A property may be nested in the configuration file. Split the property name with '.'
// then walk the configuration object one property at a time.
var depth = 0
const properties = propertyName.split('.')
@@ -15519,7 +15519,7 @@ class ConfigParser {
}
// Logging
core.info(`Injection successful, new configuration:`)
core.info('Injection successful, new configuration:')
core.info(this.configuration)
// Finally write the new configuration in the file
@@ -15599,7 +15599,7 @@ module.exports = function removeTrailingSlash(str) {
/***/ }),
/***/ 4770:
/***/ 6310:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
const core = __nccwpck_require__(2186)
@@ -15607,8 +15607,10 @@ const { ConfigParser } = __nccwpck_require__(8395)
const removeTrailingSlash = __nccwpck_require__(9255)
// Return the settings to be passed to a {ConfigParser} for a given static site generator,
// optional configuration file path, and a Pages path value to inject
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path }) {
// optional configuration file path, and a Pages siteUrl value to inject
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
let { pathname: path, origin } = siteUrl
switch (staticSiteGenerator) {
case 'nuxt':
return {
@@ -15645,7 +15647,9 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
blankConfigurationFile: __nccwpck_require__.ab + "gatsby.js",
properties: {
// Configure a path prefix
pathPrefix: path
pathPrefix: path,
// Configure a site url
'siteMetadata.siteUrl': origin
}
}
case 'sveltekit':
@@ -15657,7 +15661,9 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
blankConfigurationFile: __nccwpck_require__.ab + "sveltekit.js",
properties: {
// Configure a base path
'kit.paths.base': path
'kit.paths.base': path,
// Configure a prerender origin
'kit.prerender.origin': origin
}
}
default:
@@ -15666,10 +15672,10 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
}
// Inject Pages configuration in a given static site generator's configuration file
function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
try {
// Parse the configuration file and try to inject the Pages configuration in it
const settings = getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path })
const settings = getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl })
new ConfigParser(settings).injectAll()
} catch (error) {
// Logging
@@ -15680,7 +15686,7 @@ function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
}
}
module.exports = { getConfigParserSettings, setPagesPath }
module.exports = { getConfigParserSettings, setPagesConfig }
/***/ }),
@@ -17175,7 +17181,7 @@ const core = __nccwpck_require__(2186)
const { getContext } = __nccwpck_require__(1319)
const { findOrCreatePagesSite } = __nccwpck_require__(9432)
const { setPagesPath } = __nccwpck_require__(4770)
const { setPagesConfig } = __nccwpck_require__(6310)
const outputPagesBaseUrl = __nccwpck_require__(7527)
async function main() {
@@ -17186,7 +17192,7 @@ async function main() {
const siteUrl = new URL(pageObject.html_url)
if (staticSiteGenerator) {
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl })
}
outputPagesBaseUrl(siteUrl)
core.exportVariable('GITHUB_PAGES', 'true')

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -184,7 +184,7 @@ class ConfigParser {
throw 'Could not find a configuration object in the configuration file'
}
// A property may be nested in the configuration file. Split the property name with `.`
// A property may be nested in the configuration file. Split the property name with '.'
// then walk the configuration object one property at a time.
var depth = 0
const properties = propertyName.split('.')
@@ -265,7 +265,7 @@ class ConfigParser {
}
// Logging
core.info(`Injection successful, new configuration:`)
core.info('Injection successful, new configuration:')
core.info(this.configuration)
// Finally write the new configuration in the file

View File

@@ -14,79 +14,79 @@ const cases = [
//
{
property: 'property',
source: `export default {}`,
expected: `export default { property: "value" }`
source: 'export default {}',
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: 0 }`, // property exists and is a number
expected: `export default { property: "value" }`
source: 'export default { property: 0 }', // property exists and is a number
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: false }`, // property exists and is a boolean
expected: `export default { property: "value" }`
source: 'export default { property: false }', // property exists and is a boolean
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: "test" }`, // property exists and is a string
expected: `export default { property: "value" }`
source: 'export default { property: "test" }', // property exists and is a string
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: [1,2] }`, // property exists and is an array
expected: `export default { property: "value" }`
source: 'export default { property: [1,2] }', // property exists and is an array
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: null }`, // property exists and is null
expected: `export default { property: "value" }`
source: 'export default { property: null }', // property exists and is null
expected: 'export default { property: "value" }'
},
{
property: 'property',
source: `export default { property: {}}`, // property exists and is an object
expected: `export default { property: "value" }`
source: 'export default { property: { } }', // property exists and is an object
expected: 'export default { property: "value" }'
},
// Deep properties (injection 1)
{
property: 'property.b.c',
source: `export default {}`,
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default {}',
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: 0 }`, // property exists and is a number
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: 0 }', // property exists and is a number
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: {}}`, // property exists and is an object
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: { } }', // property exists and is an object
expected: 'export default { property: { b: { c: "value" } } }'
},
// Deep properties (injection 2)
{
property: 'property.b.c',
source: `export default { property: { b: 0 }}`, // property exists and is a number
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: { b: 0 } }', // property exists and is a number
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: { b: {}}}`, // property exists and is an object
expected: `export default { property: { b: { c: "value" }}}`
source: 'export default { property: { b: { } } }', // property exists and is an object
expected: 'export default { property: { b: { c: "value" } } }'
},
{
property: 'property.b.c',
source: `export default { property: { b: { hello: 123}}}`, // property exists and is a non-empty object
expected: `export default { property: { b: { c: "value", hello: 123 }}}`
source: 'export default { property: { b: { hello: 123 } } }', // property exists and is a non-empty object
expected: 'export default { property: { b: { c: "value", hello: 123 } } }'
},
// Deep properties (existing properties)
{
property: 'a1.a2',
source: `export default { a2: false, a1: { a3: [12]}}`, // property exists and is a non-empty object
expected: `export default { a2: false, a1: { a2: "value", a3: [12]}}`
source: 'export default { a2: false, a1: { a3: [12] } }', // property exists and is a non-empty object
expected: 'export default { a2: false, a1: { a2: "value", a3: [12] } }'
},
//
@@ -94,23 +94,23 @@ const cases = [
//
{
property: 'property',
source: `const config = {}; export default config`,
expected: `const config = { property: "value"}; export default config`
source: 'const config = {}; export default config',
expected: 'const config = { property: "value"}; export default config'
},
{
property: 'property',
source: `var config = {}; export default config`,
expected: `var config = { property: "value"}; export default config`
source: 'var config = {}; export default config',
expected: 'var config = { property: "value"}; export default config'
},
{
property: 'a.b.c',
source: `var config = {}; export default config`,
expected: `var config = { a: { b: { c: "value"}}}; export default config`
source: 'var config = {}; export default config',
expected: 'var config = { a: { b: { c: "value" } } }; export default config'
},
{
property: 'a.b.c',
source: `var config = { a: { b: [], c: "hello"}}; export default config`,
expected: `var config = { a: { b: { c: "value"}, c: "hello"}}; export default config`
source: 'var config = { a: { b: [], c: "hello" } }; export default config',
expected: 'var config = { a: { b: { c: "value"}, c: "hello" } }; export default config'
},
//
@@ -118,18 +118,18 @@ const cases = [
//
{
property: 'property',
source: `module.exports = {}`,
expected: `module.exports = { property: "value"}`
source: 'module.exports = {}',
expected: 'module.exports = { property: "value"}'
},
{
property: 'property',
source: `module.exports = { p1: 0}`,
expected: `module.exports = { property: "value", p1: 0}`
source: 'module.exports = { p1: 0}',
expected: 'module.exports = { property: "value", p1: 0}'
},
{
property: 'a.b.c',
source: `module.exports = { p1: 0}`,
expected: `module.exports = { a: { b: { c: "value" }}, p1: 0}`
source: 'module.exports = { p1: 0}',
expected: 'module.exports = { a: { b: { c: "value" } }, p1: 0}'
},
//
@@ -137,23 +137,23 @@ const cases = [
//
{
property: 'property',
source: `const config = {}; module.exports = config`,
expected: `const config = { property: "value"}; module.exports = config`
source: 'const config = {}; module.exports = config',
expected: 'const config = { property: "value"}; module.exports = config'
},
{
property: 'property',
source: `var config = {}; module.exports = config`,
expected: `var config = { property: "value"}; module.exports = config`
source: 'var config = {}; module.exports = config',
expected: 'var config = { property: "value"}; module.exports = config'
},
{
property: 'a.b.c',
source: `var config = {}; module.exports = config`,
expected: `var config = { a: { b: { c: "value"}}}; module.exports = config`
source: 'var config = {}; module.exports = config',
expected: 'var config = { a: { b: { c: "value" } } }; module.exports = config'
},
{
property: 'a.b.c',
source: `var config = { a: { b: [], c: "hello"}}; module.exports = config`,
expected: `var config = { a: { b: { c: "value"}, c: "hello"}}; module.exports = config`
source: 'var config = { a: { b: [], c: "hello" } }; module.exports = config',
expected: 'var config = { a: { b: { c: "value"}, c: "hello" } }; module.exports = config'
}
]

View File

@@ -1,2 +1,2 @@
// Default Pages configuration for Gatsby
module.exports = { pathPrefix: '/docs/' }
module.exports = { siteMetadata: { siteUrl: 'https://configure-pages.github.io' }, pathPrefix: '/docs/' }

View File

@@ -1,7 +1,6 @@
module.exports = {
siteMetadata: {
title: `My Gatsby Site`,
siteUrl: `https://www.yourdomain.tld`,
title: 'My Gatsby Site'
},
plugins: [],
plugins: []
}

View File

@@ -1,8 +1,8 @@
module.exports = {
pathPrefix: "/docs/",
pathPrefix: '/docs/',
siteMetadata: {
title: `My Gatsby Site`,
siteUrl: `https://www.yourdomain.tld`,
siteUrl: 'https://configure-pages.github.io',
title: 'My Gatsby Site'
},
plugins: [],
plugins: []
}

View File

@@ -1,8 +1,8 @@
module.exports = {
pathPrefix: '/docs/',
siteMetadata: {
title: `My Gatsby Site`,
siteUrl: `https://www.yourdomain.tld`
siteUrl: 'https://configure-pages.github.io',
title: 'My Gatsby Site'
},
plugins: []
}

View File

@@ -1,8 +1,8 @@
export default {
pathPrefix: "/docs/",
pathPrefix: '/docs/',
siteMetadata: {
title: `My Gatsby Site`,
siteUrl: `https://www.yourdomain.tld`,
siteUrl: 'https://configure-pages.github.io',
title: 'My Gatsby Site'
},
plugins: [],
plugins: []
}

View File

@@ -1,7 +1,6 @@
module.exports = {
siteMetadata: {
title: `My Gatsby Site`,
siteUrl: `https://www.yourdomain.tld`
title: 'My Gatsby Site'
},
plugins: []
}

View File

@@ -1,7 +1,6 @@
export default {
siteMetadata: {
title: `My Gatsby Site`,
siteUrl: `https://www.yourdomain.tld`,
title: 'My Gatsby Site'
},
plugins: [],
plugins: []
}

View File

@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {images: {unoptimized: true}},
experimental: { images: { unoptimized: true } },
basePath: '/docs',
reactStrictMode: true,
swcMinify: true

View File

@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {images: {unoptimized: true}},
experimental: { images: { unoptimized: true } },
basePath: '/docs',
reactStrictMode: true,
swcMinify: true

View File

@@ -7,7 +7,7 @@ const getAllDynamicRoute = async function() {
module.exports = {
target: 'static',
router: {base: '/docs/'},
router: { base: '/docs/' },
mode: 'universal',
generate: {
async routes () {

View File

@@ -7,7 +7,7 @@ const getAllDynamicRoute = async function() {
export default {
target: 'static',
router: {base: '/docs/'},
router: { base: '/docs/' },
mode: 'universal',
generate: {
async routes () {

View File

@@ -20,25 +20,20 @@ module.exports = {
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
],
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
],
buildModules: [],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
],
modules: [],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
}
build: {}
}

View File

@@ -1,7 +1,7 @@
module.exports = {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
target: 'static',
router: { base: "/docs/" },
router: { base: '/docs/' },
ssr: false,
// Global page headers: https://go.nuxtjs.dev/config-head
@@ -22,25 +22,20 @@ module.exports = {
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
],
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
],
buildModules: [],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
],
modules: [],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
}
build: {}
}

View File

@@ -1,7 +1,7 @@
export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
target: 'static',
router: { base: "/docs/" },
router: { base: '/docs/' },
ssr: false,
// Global page headers: https://go.nuxtjs.dev/config-head
@@ -22,25 +22,20 @@ export default {
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
],
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
],
buildModules: [],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
],
modules: [],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
}
build: {}
}

View File

@@ -20,25 +20,20 @@ export default {
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
],
plugins: [],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
],
buildModules: [],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
],
modules: [],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
}
build: {}
}

View File

@@ -3,6 +3,7 @@ import adapter from '@sveltejs/adapter-auto'
export default {
kit: {
prerender: { origin: 'https://configure-pages.github.io' },
paths: { base: '/docs' },
adapter: adapter()
}

View File

@@ -3,6 +3,7 @@ import adapter from '@sveltejs/adapter-auto'
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
prerender: { origin: 'https://configure-pages.github.io' },
paths: { base: '/docs' },
adapter: adapter()
}

View File

@@ -4,7 +4,7 @@ const core = require('@actions/core')
const { getContext } = require('./context')
const { findOrCreatePagesSite } = require('./api-client')
const { setPagesPath } = require('./set-pages-path')
const { setPagesConfig } = require('./set-pages-config')
const outputPagesBaseUrl = require('./output-pages-base-url')
async function main() {
@@ -15,7 +15,7 @@ async function main() {
const siteUrl = new URL(pageObject.html_url)
if (staticSiteGenerator) {
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl })
}
outputPagesBaseUrl(siteUrl)
core.exportVariable('GITHUB_PAGES', 'true')

View File

@@ -3,8 +3,10 @@ const { ConfigParser } = require('./config-parser')
const removeTrailingSlash = require('./remove-trailing-slash')
// Return the settings to be passed to a {ConfigParser} for a given static site generator,
// optional configuration file path, and a Pages path value to inject
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path }) {
// optional configuration file path, and a Pages siteUrl value to inject
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
let { pathname: path, origin } = siteUrl
switch (staticSiteGenerator) {
case 'nuxt':
return {
@@ -41,7 +43,9 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
blankConfigurationFile: `${__dirname}/blank-configurations/gatsby.js`,
properties: {
// Configure a path prefix
pathPrefix: path
pathPrefix: path,
// Configure a site url
'siteMetadata.siteUrl': origin
}
}
case 'sveltekit':
@@ -53,7 +57,9 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
blankConfigurationFile: `${__dirname}/blank-configurations/sveltekit.js`,
properties: {
// Configure a base path
'kit.paths.base': path
'kit.paths.base': path,
// Configure a prerender origin
'kit.prerender.origin': origin
}
}
default:
@@ -62,10 +68,10 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
}
// Inject Pages configuration in a given static site generator's configuration file
function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
try {
// Parse the configuration file and try to inject the Pages configuration in it
const settings = getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path })
const settings = getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl })
new ConfigParser(settings).injectAll()
} catch (error) {
// Logging
@@ -76,4 +82,4 @@ function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
}
}
module.exports = { getConfigParserSettings, setPagesPath }
module.exports = { getConfigParserSettings, setPagesConfig }

View File

@@ -2,7 +2,7 @@ const fs = require('fs')
const path = require('path')
const core = require('@actions/core')
const { getConfigParserSettings } = require('./set-pages-path')
const { getConfigParserSettings } = require('./set-pages-config')
const { ConfigParser } = require('./config-parser')
const { getTempFolder, compareFiles } = require('./test-helpers')
@@ -32,6 +32,9 @@ describe('configParser', () => {
// Get fixture files, excluding expected results
const configurationFiles = fs.readdirSync(fixtureFolder).filter(filename => !filename.includes('.expected.'))
// Create test siteUrl
const siteUrl = new URL('https://configure-pages.github.io/docs/')
// Iterate over the fixtures, outputting to default configuration file path
const defaultFileExtension = '.js'
configurationFiles
@@ -48,7 +51,7 @@ describe('configParser', () => {
}
// Get settings for the static site generator
const settings = getConfigParserSettings({ staticSiteGenerator, path: '/docs/' })
const settings = getConfigParserSettings({ staticSiteGenerator, siteUrl })
// Update the settings
settings.configurationFile = fixtureTargetFile
// Do the injection
@@ -84,7 +87,7 @@ describe('configParser', () => {
const settings = getConfigParserSettings({
staticSiteGenerator,
generatorConfigFile: fixtureTargetFile,
path: '/docs/'
siteUrl
})
// Do the injection