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