Merge branch 'main' into unused-deps

This commit is contained in:
James M. Greene
2022-09-26 10:58:37 -05:00
23 changed files with 4007 additions and 202 deletions

17
.eslintrc.json Normal file
View File

@@ -0,0 +1,17 @@
{
"env": {
"commonjs": true,
"es2021": true,
"node": true,
"jest": true
},
"plugins": ["github"],
"extends": ["eslint:recommended", "prettier", "plugin:github/internal"],
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"semi": ["error", "never"]
},
"ignorePatterns": ["/dist/", "/src/fixtures/", "/src/blank-configurations/"]
}

View File

@@ -1,6 +1,6 @@
---
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
# Changelog
@@ -8,33 +8,33 @@ template: |
See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release.
categories:
- title: "🚀 Features"
- title: '🚀 Features'
labels:
- "feature"
- "enhancement"
- title: "🐛 Bug Fixes"
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- "fix"
- "bugfix"
- "bug"
- title: "🧰 Maintenance"
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
labels:
- "infrastructure"
- "automation"
- "documentation"
- title: "🏎 Performance"
label: "performance"
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
- 'infrastructure'
- 'automation'
- 'documentation'
- title: '🏎 Performance'
label: 'performance'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
version-resolver:
major:
labels:
- "type: breaking"
- 'type: breaking'
minor:
labels:
- "type: enhancement"
- 'type: enhancement'
patch:
labels:
- "type: bug"
- "type: maintenance"
- "type: documentation"
- 'type: bug'
- 'type: maintenance'
- 'type: documentation'
default: patch

View File

@@ -1,4 +1,4 @@
name: Checking formatting
name: Check formatting
on:
push:
@@ -17,11 +17,12 @@ concurrency:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.JS
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x

35
.github/workflows/lint.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Lint code
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint:check

View File

@@ -5,7 +5,7 @@ on:
workflow_dispatch:
inputs:
TAG_NAME:
description: "Tag name that the major tag will point to"
description: 'Tag name that the major tag will point to'
required: true
env:

5
.prettierignore Normal file
View File

@@ -0,0 +1,5 @@
# Ignore build artifacts
/dist/
# Ignore all Markdown files
*.md

137
dist/index.js vendored
View File

@@ -2836,10 +2836,10 @@ module.exports = {
var defaultOptions = {
// `ecmaVersion` indicates the ECMAScript version to parse. Must be
// either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
// (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"` (the
// latest version the library supports). This influences support
// for strict mode, the set of reserved words, and support for
// new syntax features.
// (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
// (the latest version the library supports). This influences
// support for strict mode, the set of reserved words, and support
// for new syntax features.
ecmaVersion: null,
// `sourceType` indicates the mode the code should be parsed in.
// Can be either `"script"` or `"module"`. This influences global
@@ -2873,8 +2873,9 @@ module.exports = {
// When enabled, super identifiers are not constrained to
// appearing in methods and do not raise an error when they appear elsewhere.
allowSuperOutsideMethod: null,
// When enabled, hashbang directive in the beginning of file
// is allowed and treated as a line comment.
// When enabled, hashbang directive in the beginning of file is
// allowed and treated as a line comment. Enabled by default when
// `ecmaVersion` >= 2023.
allowHashBang: false,
// When `locations` is on, `loc` properties holding objects with
// `start` and `end` properties in `{line, column}` form (with
@@ -2949,6 +2950,9 @@ module.exports = {
if (options.allowReserved == null)
{ options.allowReserved = options.ecmaVersion < 5; }
if (opts.allowHashBang == null)
{ options.allowHashBang = options.ecmaVersion >= 14; }
if (isArray(options.onToken)) {
var tokens = options.onToken;
options.onToken = function (token) { return tokens.push(token); };
@@ -3279,7 +3283,7 @@ module.exports = {
if (refDestructuringErrors.trailingComma > -1)
{ this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); }
};
pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
@@ -4375,6 +4379,7 @@ module.exports = {
};
pp$8.isDirectiveCandidate = function(statement) {
return (
this.options.ecmaVersion >= 5 &&
statement.type === "ExpressionStatement" &&
statement.expression.type === "Literal" &&
typeof statement.expression.value === "string" &&
@@ -4785,7 +4790,8 @@ module.exports = {
{ this.exprAllowed = type.beforeExpr; }
};
// Used to handle egde case when token context could not be inferred correctly in tokenize phase
// Used to handle egde cases when token context could not be inferred correctly during tokenization phase
pp$6.overrideContext = function(tokenCtx) {
if (this.curContext() !== tokenCtx) {
this.context[this.context.length - 1] = tokenCtx;
@@ -5601,15 +5607,6 @@ module.exports = {
}
return this.finishNode(prop, "RestElement")
}
// To disallow parenthesized identifier via `this.toAssignable()`.
if (this.type === types$1.parenL && refDestructuringErrors) {
if (refDestructuringErrors.parenthesizedAssign < 0) {
refDestructuringErrors.parenthesizedAssign = this.start;
}
if (refDestructuringErrors.parenthesizedBind < 0) {
refDestructuringErrors.parenthesizedBind = this.start;
}
}
// Parse argument.
prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
// To disallow trailing comma via `this.toAssignable()`.
@@ -8039,7 +8036,7 @@ module.exports = {
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
var version = "8.7.1";
var version = "8.8.0";
Parser.acorn = {
Parser: Parser,
@@ -15189,21 +15186,17 @@ async function enablePagesSite({ repositoryNwo, githubToken }) {
}
async function getPagesSite({ repositoryNwo, githubToken }) {
try {
const pagesEndpoint = `${getApiBaseUrl()}/repos/${repositoryNwo}/pages`
const pagesEndpoint = `${getApiBaseUrl()}/repos/${repositoryNwo}/pages`
const response = await axios.get(pagesEndpoint, {
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${githubToken}`
}
})
const response = await axios.get(pagesEndpoint, {
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${githubToken}`
}
})
const pageObject = response.data
return pageObject
} catch (error) {
throw error
}
const pageObject = response.data
return pageObject
}
async function findOrCreatePagesSite({ repositoryNwo, githubToken, enablement = true }) {
@@ -15443,6 +15436,7 @@ class ConfigParser {
var depth = 0
const properties = propertyName.split('.')
var lastNode = configurationObject
// eslint-disable-next-line no-constant-condition
while (true) {
// Find the node for the current property
var propertyNode = this.findProperty(lastNode, properties[depth])
@@ -15680,7 +15674,7 @@ function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
} 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.`,
`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 ${siteUrl}. Please ensure your framework is configured to generate relative links appropriately.`,
error
)
}
@@ -16509,14 +16503,15 @@ TokenTranslator.prototype = {
const SUPPORTED_VERSIONS = [
3,
5,
6,
7,
8,
9,
10,
11,
12,
13
6, // 2015
7, // 2016
8, // 2017
9, // 2018
10, // 2019
11, // 2020
12, // 2021
13, // 2022
14 // 2023
];
/**
@@ -16634,12 +16629,23 @@ const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
* @param {int} end The index at which the comment ends.
* @param {Location} startLoc The location at which the comment starts.
* @param {Location} endLoc The location at which the comment ends.
* @param {string} code The source code being parsed.
* @returns {Object} The comment object.
* @private
*/
function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc) {
function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code) {
let type;
if (block) {
type = "Block";
} else if (code.slice(start, start + 2) === "#!") {
type = "Hashbang";
} else {
type = "Line";
}
const comment = {
type: block ? "Block" : "Line",
type,
value: text
};
@@ -16684,6 +16690,25 @@ var espree = () => Parser => {
? new TokenTranslator(tokTypes, code)
: null;
/*
* Data that is unique to Espree and is not represented internally
* in Acorn.
*
* For ES2023 hashbangs, Espree will call `onComment()` during the
* constructor, so we must define state before having access to
* `this`.
*/
const state = {
originalSourceType: originalSourceType || options.sourceType,
tokens: tokenTranslator ? [] : null,
comments: options.comment === true ? [] : null,
impliedStrict: ecmaFeatures.impliedStrict === true && options.ecmaVersion >= 5,
ecmaVersion: options.ecmaVersion,
jsxAttrValueToken: false,
lastToken: null,
templateElements: []
};
// Initialize acorn parser.
super({
@@ -16702,38 +16727,28 @@ var espree = () => Parser => {
if (tokenTranslator) {
// Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
tokenTranslator.onToken(token, this[STATE]);
tokenTranslator.onToken(token, state);
}
if (token.type !== tokTypes.eof) {
this[STATE].lastToken = token;
state.lastToken = token;
}
},
// Collect comments
onComment: (block, text, start, end, startLoc, endLoc) => {
if (this[STATE].comments) {
const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);
if (state.comments) {
const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code);
this[STATE].comments.push(comment);
state.comments.push(comment);
}
}
}, code);
/*
* Data that is unique to Espree and is not represented internally in
* Acorn. We put all of this data into a symbol property as a way to
* avoid potential naming conflicts with future versions of Acorn.
* We put all of this data into a symbol property as a way to avoid
* potential naming conflicts with future versions of Acorn.
*/
this[STATE] = {
originalSourceType: originalSourceType || options.sourceType,
tokens: tokenTranslator ? [] : null,
comments: options.comment === true ? [] : null,
impliedStrict: ecmaFeatures.impliedStrict === true && this.options.ecmaVersion >= 5,
ecmaVersion: this.options.ecmaVersion,
jsxAttrValueToken: false,
lastToken: null,
templateElements: []
};
this[STATE] = state;
}
tokenize() {
@@ -16946,7 +16961,7 @@ var espree = () => Parser => {
};
};
const version$1 = "9.3.2";
const version$1 = "9.4.0";
/**
* @fileoverview Main Espree file that converts Acorn into Esprima output.

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

3835
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,9 +5,12 @@
"description": "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.",
"main": "./dist/index.js",
"scripts": {
"format": "prettier --write 'src/**/*.js'",
"format:check": "prettier --check 'src/**/*.js'",
"prepare": "npm run format && ncc build src/index.js -o dist --source-map --license licenses.txt",
"all": "npm run format && npm run lint && npm run prepare && npm run test",
"format": "prettier --write .",
"format:check": "prettier --check .",
"lint": "DEBUG=eslint:cli-engine eslint --fix .",
"lint:check": "DEBUG=eslint:cli-engine eslint .",
"prepare": "ncc build src/index.js -o dist --source-map --license licenses.txt",
"test": "jest"
},
"repository": {
@@ -27,6 +30,9 @@
},
"devDependencies": {
"@vercel/ncc": "^0.34.0",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-github": "^4.3.7",
"jest": "^28.1.1",
"prettier": "^2.7.1"
}

View File

@@ -33,21 +33,17 @@ async function enablePagesSite({ repositoryNwo, githubToken }) {
}
async function getPagesSite({ repositoryNwo, githubToken }) {
try {
const pagesEndpoint = `${getApiBaseUrl()}/repos/${repositoryNwo}/pages`
const pagesEndpoint = `${getApiBaseUrl()}/repos/${repositoryNwo}/pages`
const response = await axios.get(pagesEndpoint, {
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${githubToken}`
}
})
const response = await axios.get(pagesEndpoint, {
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${githubToken}`
}
})
const pageObject = response.data
return pageObject
} catch (error) {
throw error
}
const pageObject = response.data
return pageObject
}
async function findOrCreatePagesSite({ repositoryNwo, githubToken, enablement = true }) {

View File

@@ -189,6 +189,7 @@ class ConfigParser {
var depth = 0
const properties = propertyName.split('.')
var lastNode = configurationObject
// eslint-disable-next-line no-constant-condition
while (true) {
// Find the node for the current property
var propertyNode = this.findProperty(lastNode, properties[depth])

View File

@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
swcMinify: true
}
module.exports = nextConfig

View File

@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
swcMinify: true
}
export default nextConfig

View File

@@ -1,15 +1,15 @@
const getAllDynamicRoute = async function() {
const getAllDynamicRoute = async function () {
const routes = await (async () => {
return ['/posts/hello-world', '/posts/hello-again'];
})();
return routes;
};
return ['/posts/hello-world', '/posts/hello-again']
})()
return routes
}
module.exports = {
mode: 'universal',
generate: {
async routes () {
return getAllDynamicRoute();
async routes() {
return getAllDynamicRoute()
}
}
};
}

View File

@@ -1,17 +1,17 @@
const getAllDynamicRoute = async function() {
const getAllDynamicRoute = async function () {
const routes = await (async () => {
return ['/posts/hello-world', '/posts/hello-again'];
})();
return routes;
};
return ['/posts/hello-world', '/posts/hello-again']
})()
return routes
}
module.exports = {
target: 'static',
router: { base: '/docs/' },
mode: 'universal',
generate: {
async routes () {
return getAllDynamicRoute();
async routes() {
return getAllDynamicRoute()
}
}
};
}

View File

@@ -1,17 +1,17 @@
const getAllDynamicRoute = async function() {
const getAllDynamicRoute = async function () {
const routes = await (async () => {
return ['/posts/hello-world', '/posts/hello-again'];
})();
return routes;
};
return ['/posts/hello-world', '/posts/hello-again']
})()
return routes
}
export default {
target: 'static',
router: { base: '/docs/' },
mode: 'universal',
generate: {
async routes () {
return getAllDynamicRoute();
async routes() {
return getAllDynamicRoute()
}
}
};
}

View File

@@ -1,15 +1,15 @@
const getAllDynamicRoute = async function() {
const getAllDynamicRoute = async function () {
const routes = await (async () => {
return ['/posts/hello-world', '/posts/hello-again'];
})();
return routes;
};
return ['/posts/hello-world', '/posts/hello-again']
})()
return routes
}
export default {
mode: 'universal',
generate: {
async routes () {
return getAllDynamicRoute();
async routes() {
return getAllDynamicRoute()
}
}
};
}

View File

@@ -14,9 +14,7 @@ module.exports = {
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
// Global CSS: https://go.nuxtjs.dev/config-css
@@ -36,4 +34,4 @@ module.exports = {
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {}
}
}

View File

@@ -16,9 +16,7 @@ module.exports = {
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
// Global CSS: https://go.nuxtjs.dev/config-css
@@ -38,4 +36,4 @@ module.exports = {
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {}
}
}

View File

@@ -16,9 +16,7 @@ export default {
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
// Global CSS: https://go.nuxtjs.dev/config-css
@@ -38,4 +36,4 @@ export default {
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {}
}
}

View File

@@ -14,9 +14,7 @@ export default {
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
// Global CSS: https://go.nuxtjs.dev/config-css
@@ -36,4 +34,4 @@ export default {
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {}
}
}

View File

@@ -76,7 +76,7 @@ function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
} 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.`,
`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 ${siteUrl}. Please ensure your framework is configured to generate relative links appropriately.`,
error
)
}