mirror of
https://github.com/actions/configure-pages.git
synced 2025-12-09 00:26:08 +00:00
Update all source files to match expected Prettier formatting
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
# Prettier (formatter) configuration
|
# Prettier (formatter) configuration
|
||||||
---
|
---
|
||||||
printWidth: 80
|
printWidth: 120
|
||||||
tabWidth: 2
|
tabWidth: 2
|
||||||
useTabs: false
|
useTabs: false
|
||||||
semi: false
|
semi: false
|
||||||
singleQuote: true
|
singleQuote: true
|
||||||
trailingComma: none
|
trailingComma: none
|
||||||
bracketSpacing: false
|
bracketSpacing: true
|
||||||
arrowParens: avoid
|
arrowParens: avoid
|
||||||
|
|||||||
28
dist/index.js
vendored
28
dist/index.js
vendored
@@ -14585,9 +14585,7 @@ class ConfigParser {
|
|||||||
findConfigurationObject(ast) {
|
findConfigurationObject(ast) {
|
||||||
// Try to find a default export
|
// Try to find a default export
|
||||||
var defaultExport = ast.body.find(
|
var defaultExport = ast.body.find(
|
||||||
node =>
|
node => node.type === 'ExportDefaultDeclaration' && node.declaration.type === 'ObjectExpression'
|
||||||
node.type === 'ExportDefaultDeclaration' &&
|
|
||||||
node.declaration.type === 'ObjectExpression'
|
|
||||||
)
|
)
|
||||||
if (defaultExport) {
|
if (defaultExport) {
|
||||||
core.info('Found configuration object in default export declaration')
|
core.info('Found configuration object in default export declaration')
|
||||||
@@ -14608,19 +14606,13 @@ class ConfigParser {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Direct module export
|
// Direct module export
|
||||||
if (
|
if (moduleExport && moduleExport.expression.right.type === 'ObjectExpression') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'ObjectExpression'
|
|
||||||
) {
|
|
||||||
core.info('Found configuration object in direct module export')
|
core.info('Found configuration object in direct module export')
|
||||||
return moduleExport.expression.right
|
return moduleExport.expression.right
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indirect module export
|
// Indirect module export
|
||||||
else if (
|
else if (moduleExport && moduleExport.expression.right.type === 'Identifier') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'Identifier'
|
|
||||||
) {
|
|
||||||
const identifierName = moduleExport && moduleExport.expression.right.name
|
const identifierName = moduleExport && moduleExport.expression.right.name
|
||||||
const identifierDefinition = ast.body.find(
|
const identifierDefinition = ast.body.find(
|
||||||
node =>
|
node =>
|
||||||
@@ -14648,9 +14640,7 @@ class ConfigParser {
|
|||||||
// Try to find a property matching a given name
|
// Try to find a property matching a given name
|
||||||
const property =
|
const property =
|
||||||
object.type === 'ObjectExpression' &&
|
object.type === 'ObjectExpression' &&
|
||||||
object.properties.find(
|
object.properties.find(node => node.key.type === 'Identifier' && node.key.name === name)
|
||||||
node => node.key.type === 'Identifier' && node.key.name === name
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return the property's value (if found) or null
|
// Return the property's value (if found) or null
|
||||||
if (property) {
|
if (property) {
|
||||||
@@ -14670,9 +14660,7 @@ class ConfigParser {
|
|||||||
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
`${properties[startIndex]}: {` +
|
`${properties[startIndex]}: {` + this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) + '}'
|
||||||
this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) +
|
|
||||||
'}'
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14750,11 +14738,7 @@ class ConfigParser {
|
|||||||
// Create nested properties in the configuration file
|
// Create nested properties in the configuration file
|
||||||
else {
|
else {
|
||||||
// Build the declaration to inject
|
// Build the declaration to inject
|
||||||
const declaration = this.getPropertyDeclaration(
|
const declaration = this.getPropertyDeclaration(properties, depth, propertyValue)
|
||||||
properties,
|
|
||||||
depth,
|
|
||||||
propertyValue
|
|
||||||
)
|
|
||||||
|
|
||||||
// The last node identified is an object expression, so do the assignment
|
// The last node identified is an object expression, so do the assignment
|
||||||
if (lastNode.type === 'ObjectExpression') {
|
if (lastNode.type === 'ObjectExpression') {
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -53,9 +53,7 @@ describe('apiClient', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('handles a 409 response when the page already exists', async () => {
|
it('handles a 409 response when the page already exists', async () => {
|
||||||
jest
|
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
||||||
.spyOn(axios, 'post')
|
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
|
||||||
|
|
||||||
// Simply assert that no error is raised
|
// Simply assert that no error is raised
|
||||||
const result = await apiClient.enablePagesSite({
|
const result = await apiClient.enablePagesSite({
|
||||||
@@ -67,9 +65,7 @@ describe('apiClient', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('re-raises errors on failure status codes', async () => {
|
it('re-raises errors on failure status codes', async () => {
|
||||||
jest
|
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
||||||
.spyOn(axios, 'post')
|
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
|
||||||
|
|
||||||
let erred = false
|
let erred = false
|
||||||
try {
|
try {
|
||||||
@@ -98,9 +94,7 @@ describe('apiClient', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('re-raises errors on failure status codes', async () => {
|
it('re-raises errors on failure status codes', async () => {
|
||||||
jest
|
jest.spyOn(axios, 'get').mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
||||||
.spyOn(axios, 'get')
|
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
|
||||||
|
|
||||||
let erred = false
|
let erred = false
|
||||||
try {
|
try {
|
||||||
@@ -203,7 +197,8 @@ describe('apiClient', () => {
|
|||||||
|
|
||||||
it('makes second request to get page if create fails because of existence', async () => {
|
it('makes second request to get page if create fails because of existence', async () => {
|
||||||
const PAGE_OBJECT = { html_url: 'https://actions.github.io/is-awesome/' }
|
const PAGE_OBJECT = { html_url: 'https://actions.github.io/is-awesome/' }
|
||||||
jest.spyOn(axios, 'get')
|
jest
|
||||||
|
.spyOn(axios, 'get')
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
||||||
.mockImplementationOnce(() => Promise.resolve({ status: 200, data: PAGE_OBJECT }))
|
.mockImplementationOnce(() => Promise.resolve({ status: 200, data: PAGE_OBJECT }))
|
||||||
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
||||||
@@ -217,5 +212,4 @@ describe('apiClient', () => {
|
|||||||
expect(axios.post).toHaveBeenCalledTimes(1)
|
expect(axios.post).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ class ConfigParser {
|
|||||||
findConfigurationObject(ast) {
|
findConfigurationObject(ast) {
|
||||||
// Try to find a default export
|
// Try to find a default export
|
||||||
var defaultExport = ast.body.find(
|
var defaultExport = ast.body.find(
|
||||||
node =>
|
node => node.type === 'ExportDefaultDeclaration' && node.declaration.type === 'ObjectExpression'
|
||||||
node.type === 'ExportDefaultDeclaration' &&
|
|
||||||
node.declaration.type === 'ObjectExpression'
|
|
||||||
)
|
)
|
||||||
if (defaultExport) {
|
if (defaultExport) {
|
||||||
core.info('Found configuration object in default export declaration')
|
core.info('Found configuration object in default export declaration')
|
||||||
@@ -80,19 +78,13 @@ class ConfigParser {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Direct module export
|
// Direct module export
|
||||||
if (
|
if (moduleExport && moduleExport.expression.right.type === 'ObjectExpression') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'ObjectExpression'
|
|
||||||
) {
|
|
||||||
core.info('Found configuration object in direct module export')
|
core.info('Found configuration object in direct module export')
|
||||||
return moduleExport.expression.right
|
return moduleExport.expression.right
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indirect module export
|
// Indirect module export
|
||||||
else if (
|
else if (moduleExport && moduleExport.expression.right.type === 'Identifier') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'Identifier'
|
|
||||||
) {
|
|
||||||
const identifierName = moduleExport && moduleExport.expression.right.name
|
const identifierName = moduleExport && moduleExport.expression.right.name
|
||||||
const identifierDefinition = ast.body.find(
|
const identifierDefinition = ast.body.find(
|
||||||
node =>
|
node =>
|
||||||
@@ -120,9 +112,7 @@ class ConfigParser {
|
|||||||
// Try to find a property matching a given name
|
// Try to find a property matching a given name
|
||||||
const property =
|
const property =
|
||||||
object.type === 'ObjectExpression' &&
|
object.type === 'ObjectExpression' &&
|
||||||
object.properties.find(
|
object.properties.find(node => node.key.type === 'Identifier' && node.key.name === name)
|
||||||
node => node.key.type === 'Identifier' && node.key.name === name
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return the property's value (if found) or null
|
// Return the property's value (if found) or null
|
||||||
if (property) {
|
if (property) {
|
||||||
@@ -142,9 +132,7 @@ class ConfigParser {
|
|||||||
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
`${properties[startIndex]}: {` +
|
`${properties[startIndex]}: {` + this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) + '}'
|
||||||
this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) +
|
|
||||||
'}'
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,11 +210,7 @@ class ConfigParser {
|
|||||||
// Create nested properties in the configuration file
|
// Create nested properties in the configuration file
|
||||||
else {
|
else {
|
||||||
// Build the declaration to inject
|
// Build the declaration to inject
|
||||||
const declaration = this.getPropertyDeclaration(
|
const declaration = this.getPropertyDeclaration(properties, depth, propertyValue)
|
||||||
properties,
|
|
||||||
depth,
|
|
||||||
propertyValue
|
|
||||||
)
|
|
||||||
|
|
||||||
// The last node identified is an object expression, so do the assignment
|
// The last node identified is an object expression, so do the assignment
|
||||||
if (lastNode.type === 'ObjectExpression') {
|
if (lastNode.type === 'ObjectExpression') {
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
||||||
expect(core.setOutput).toHaveBeenCalledWith(
|
expect(core.setOutput).toHaveBeenCalledWith('origin', 'https://octocat.github.io')
|
||||||
'origin',
|
|
||||||
'https://octocat.github.io'
|
|
||||||
)
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
||||||
})
|
})
|
||||||
@@ -38,10 +35,7 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
||||||
expect(core.setOutput).toHaveBeenCalledWith(
|
expect(core.setOutput).toHaveBeenCalledWith('origin', 'https://octocat.github.io')
|
||||||
'origin',
|
|
||||||
'https://octocat.github.io'
|
|
||||||
)
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/my-repo/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/my-repo/')
|
||||||
})
|
})
|
||||||
@@ -52,10 +46,7 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
||||||
expect(core.setOutput).toHaveBeenCalledWith(
|
expect(core.setOutput).toHaveBeenCalledWith('origin', 'https://www.example.com')
|
||||||
'origin',
|
|
||||||
'https://www.example.com'
|
|
||||||
)
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('host', 'www.example.com')
|
expect(core.setOutput).toHaveBeenCalledWith('host', 'www.example.com')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -40,10 +40,7 @@ describe('configParser', () => {
|
|||||||
new ConfigParser(settings).injectAll()
|
new ConfigParser(settings).injectAll()
|
||||||
|
|
||||||
// Read the expected file
|
// Read the expected file
|
||||||
const expectedFile = `${fixtureFolder}/${path.basename(
|
const expectedFile = `${fixtureFolder}/${path.basename(configurationFile, '.js')}.expected.js`
|
||||||
configurationFile,
|
|
||||||
'.js'
|
|
||||||
)}.expected.js`
|
|
||||||
|
|
||||||
// Compare the actual and expected files
|
// Compare the actual and expected files
|
||||||
compareFiles(settings.configurationFile, expectedFile)
|
compareFiles(settings.configurationFile, expectedFile)
|
||||||
|
|||||||
@@ -14,19 +14,21 @@ function getTempFolder() {
|
|||||||
// Read a JavaScript file and return it formatted
|
// Read a JavaScript file and return it formatted
|
||||||
function formatFile(file) {
|
function formatFile(file) {
|
||||||
const fileContent = fs.readFileSync(file, 'utf8')
|
const fileContent = fs.readFileSync(file, 'utf8')
|
||||||
return prettier.format(fileContent, {
|
return prettier
|
||||||
|
.format(fileContent, {
|
||||||
parser: 'espree',
|
parser: 'espree',
|
||||||
|
|
||||||
// Prettier options
|
// Prettier options
|
||||||
printWidth: 80,
|
printWidth: 120,
|
||||||
tabWidth: 2,
|
tabWidth: 2,
|
||||||
useTabs: false,
|
useTabs: false,
|
||||||
semi: false,
|
semi: false,
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
trailingComma: 'none',
|
trailingComma: 'none',
|
||||||
bracketSpacing: false,
|
bracketSpacing: true,
|
||||||
arrowParens: 'avoid'
|
arrowParens: 'avoid'
|
||||||
}).trim()
|
})
|
||||||
|
.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare two JavaScript files
|
// Compare two JavaScript files
|
||||||
|
|||||||
Reference in New Issue
Block a user