mirror of
https://github.com/actions/configure-pages.git
synced 2026-03-29 17:34:52 +00:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d875fa8dc1 | ||
|
|
67f329fcfd | ||
|
|
2ce6d5eaa1 | ||
|
|
bb6976f8d1 | ||
|
|
f2098a32c3 | ||
|
|
7fa35a05fd | ||
|
|
c3113876b0 | ||
|
|
af5f3c3f72 | ||
|
|
ad83b485e7 | ||
|
|
a84400a87f | ||
|
|
7a0a617c8a | ||
|
|
062df390be | ||
|
|
7619de7040 | ||
|
|
66e9ac3c2e | ||
|
|
4012a9fa87 | ||
|
|
4a12ff50fb | ||
|
|
a07391ec25 | ||
|
|
2491ca8488 | ||
|
|
875ec87ff9 | ||
|
|
4eadc891b5 | ||
|
|
c4feb8d01e | ||
|
|
1f9ca39237 | ||
|
|
1cefe6fc7c | ||
|
|
25a1ec8799 | ||
|
|
b9c4ac6c14 | ||
|
|
6e4f93b15d | ||
|
|
069c984c5e | ||
|
|
b030b061cb | ||
|
|
45efe60937 | ||
|
|
35c001ded6 | ||
|
|
27457957e6 | ||
|
|
7ec0edaa8e | ||
|
|
d48340abcd | ||
|
|
f53b57ff56 | ||
|
|
6d1d650751 | ||
|
|
61fd3a3cc1 | ||
|
|
0ec542a837 | ||
|
|
3a90973fd3 | ||
|
|
dc5b850bfd |
17
.eslintrc.json
Normal file
17
.eslintrc.json
Normal 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/"]
|
||||||
|
}
|
||||||
42
.github/release-drafter.yml
vendored
42
.github/release-drafter.yml
vendored
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name-template: "v$RESOLVED_VERSION"
|
name-template: 'v$RESOLVED_VERSION'
|
||||||
tag-template: "v$RESOLVED_VERSION"
|
tag-template: 'v$RESOLVED_VERSION'
|
||||||
template: |
|
template: |
|
||||||
# Changelog
|
# 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.
|
See details of [all code changes](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release.
|
||||||
categories:
|
categories:
|
||||||
- title: "🚀 Features"
|
- title: '🚀 Features'
|
||||||
labels:
|
labels:
|
||||||
- "feature"
|
- 'feature'
|
||||||
- "enhancement"
|
- 'enhancement'
|
||||||
- title: "🐛 Bug Fixes"
|
- title: '🐛 Bug Fixes'
|
||||||
labels:
|
labels:
|
||||||
- "fix"
|
- 'fix'
|
||||||
- "bugfix"
|
- 'bugfix'
|
||||||
- "bug"
|
- 'bug'
|
||||||
- title: "🧰 Maintenance"
|
- title: '🧰 Maintenance'
|
||||||
labels:
|
labels:
|
||||||
- "infrastructure"
|
- 'infrastructure'
|
||||||
- "automation"
|
- 'automation'
|
||||||
- "documentation"
|
- 'documentation'
|
||||||
- title: "🏎 Performance"
|
- title: '🏎 Performance'
|
||||||
label: "performance"
|
label: 'performance'
|
||||||
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
|
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
||||||
version-resolver:
|
version-resolver:
|
||||||
major:
|
major:
|
||||||
labels:
|
labels:
|
||||||
- "type: breaking"
|
- 'type: breaking'
|
||||||
minor:
|
minor:
|
||||||
labels:
|
labels:
|
||||||
- "type: enhancement"
|
- 'type: enhancement'
|
||||||
patch:
|
patch:
|
||||||
labels:
|
labels:
|
||||||
- "type: bug"
|
- 'type: bug'
|
||||||
- "type: maintenance"
|
- 'type: maintenance'
|
||||||
- "type: documentation"
|
- 'type: documentation'
|
||||||
default: patch
|
default: patch
|
||||||
|
|||||||
5
.github/workflows/check-formatting.yml
vendored
5
.github/workflows/check-formatting.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Checking formatting
|
name: Check formatting
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -17,11 +17,12 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 2
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.JS
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
|
|||||||
35
.github/workflows/lint.yml
vendored
Normal file
35
.github/workflows/lint.yml
vendored
Normal 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
|
||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -1,11 +1,11 @@
|
|||||||
name: Release
|
name: Release
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [released]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
TAG_NAME:
|
TAG_NAME:
|
||||||
description: "Tag name that the major tag will point to"
|
description: 'Tag name that the major tag will point to'
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|||||||
5
.prettierignore
Normal file
5
.prettierignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Ignore build artifacts
|
||||||
|
/dist/
|
||||||
|
|
||||||
|
# Ignore all Markdown files
|
||||||
|
*.md
|
||||||
@@ -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].
|
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
|
# Usage
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ The scripts and documentation in this project are released under the [MIT Licens
|
|||||||
|
|
||||||
<!-- references -->
|
<!-- references -->
|
||||||
[starter-workflows]: https://github.com/actions/starter-workflows/tree/main/pages
|
[starter-workflows]: https://github.com/actions/starter-workflows/tree/main/pages
|
||||||
[release-list]: /releases
|
[release-list]: https://github.com/actions/configure-pages/releases
|
||||||
[draft-release]: .github/workflows/draft-release.yml
|
[draft-release]: .github/workflows/draft-release.yml
|
||||||
[release]: .github/workflows/release.yml
|
[release]: .github/workflows/release.yml
|
||||||
[release-workflow-runs]: /actions/workflows/release.yml
|
[release-workflow-runs]: https://github.com/actions/configure-pages/actions/workflows/release.yml
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
base_url:
|
base_url:
|
||||||
description: 'GitHub Pages site full base URL. Examples: "https://octocat.github.io/my-repo/", "https://octocat.github.io/", "https://www.example.com/"'
|
description: 'GitHub Pages site full base URL. Examples: "https://octocat.github.io/my-repo", "https://octocat.github.io", "https://www.example.com"'
|
||||||
origin:
|
origin:
|
||||||
description: 'GitHub Pages site origin. Examples: "https://octocat.github.io", "https://www.example.com"'
|
description: 'GitHub Pages site origin. Examples: "https://octocat.github.io", "https://www.example.com"'
|
||||||
host:
|
host:
|
||||||
description: 'GitHub Pages site host. Examples: "octocat.github.io", "www.example.com"'
|
description: 'GitHub Pages site host. Examples: "octocat.github.io", "www.example.com"'
|
||||||
base_path:
|
base_path:
|
||||||
description: 'GitHub Pages site full base path. Examples: "/my-repo/" or "/"'
|
description: 'GitHub Pages site full base path. Examples: "/my-repo" or ""'
|
||||||
|
|||||||
252
dist/index.js
vendored
252
dist/index.js
vendored
@@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(717);
|
|||||||
const utils_1 = __nccwpck_require__(5278);
|
const utils_1 = __nccwpck_require__(5278);
|
||||||
const os = __importStar(__nccwpck_require__(2037));
|
const os = __importStar(__nccwpck_require__(2037));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const uuid_1 = __nccwpck_require__(5840);
|
|
||||||
const oidc_utils_1 = __nccwpck_require__(8041);
|
const oidc_utils_1 = __nccwpck_require__(8041);
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
@@ -170,20 +169,9 @@ function exportVariable(name, val) {
|
|||||||
process.env[name] = convertedVal;
|
process.env[name] = convertedVal;
|
||||||
const filePath = process.env['GITHUB_ENV'] || '';
|
const filePath = process.env['GITHUB_ENV'] || '';
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
|
||||||
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
|
|
||||||
if (name.includes(delimiter)) {
|
|
||||||
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
|
||||||
}
|
|
||||||
if (convertedVal.includes(delimiter)) {
|
|
||||||
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
|
||||||
}
|
|
||||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
|
||||||
file_command_1.issueCommand('ENV', commandValue);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
|
||||||
}
|
}
|
||||||
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
@@ -201,7 +189,7 @@ exports.setSecret = setSecret;
|
|||||||
function addPath(inputPath) {
|
function addPath(inputPath) {
|
||||||
const filePath = process.env['GITHUB_PATH'] || '';
|
const filePath = process.env['GITHUB_PATH'] || '';
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
file_command_1.issueCommand('PATH', inputPath);
|
file_command_1.issueFileCommand('PATH', inputPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
command_1.issueCommand('add-path', {}, inputPath);
|
||||||
@@ -241,7 +229,10 @@ function getMultilineInput(name, options) {
|
|||||||
const inputs = getInput(name, options)
|
const inputs = getInput(name, options)
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter(x => x !== '');
|
.filter(x => x !== '');
|
||||||
return inputs;
|
if (options && options.trimWhitespace === false) {
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
return inputs.map(input => input.trim());
|
||||||
}
|
}
|
||||||
exports.getMultilineInput = getMultilineInput;
|
exports.getMultilineInput = getMultilineInput;
|
||||||
/**
|
/**
|
||||||
@@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function setOutput(name, value) {
|
function setOutput(name, value) {
|
||||||
|
const filePath = process.env['GITHUB_OUTPUT'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
|
||||||
|
}
|
||||||
process.stdout.write(os.EOL);
|
process.stdout.write(os.EOL);
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
/**
|
/**
|
||||||
@@ -404,7 +399,11 @@ exports.group = group;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function saveState(name, value) {
|
function saveState(name, value) {
|
||||||
command_1.issueCommand('save-state', { name }, value);
|
const filePath = process.env['GITHUB_STATE'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
|
||||||
|
}
|
||||||
|
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
|
||||||
}
|
}
|
||||||
exports.saveState = saveState;
|
exports.saveState = saveState;
|
||||||
/**
|
/**
|
||||||
@@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.issueCommand = void 0;
|
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
|
||||||
// We use any as a valid input type
|
// We use any as a valid input type
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
const os = __importStar(__nccwpck_require__(2037));
|
const os = __importStar(__nccwpck_require__(2037));
|
||||||
|
const uuid_1 = __nccwpck_require__(5840);
|
||||||
const utils_1 = __nccwpck_require__(5278);
|
const utils_1 = __nccwpck_require__(5278);
|
||||||
function issueCommand(command, message) {
|
function issueFileCommand(command, message) {
|
||||||
const filePath = process.env[`GITHUB_${command}`];
|
const filePath = process.env[`GITHUB_${command}`];
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||||||
@@ -488,7 +488,22 @@ function issueCommand(command, message) {
|
|||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.issueCommand = issueCommand;
|
exports.issueFileCommand = issueFileCommand;
|
||||||
|
function prepareKeyValueMessage(key, value) {
|
||||||
|
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
||||||
|
const convertedValue = utils_1.toCommandValue(value);
|
||||||
|
// These should realistically never happen, but just in case someone finds a
|
||||||
|
// way to exploit uuid generation let's not allow keys or values that contain
|
||||||
|
// the delimiter.
|
||||||
|
if (key.includes(delimiter)) {
|
||||||
|
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
||||||
|
}
|
||||||
|
if (convertedValue.includes(delimiter)) {
|
||||||
|
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
||||||
|
}
|
||||||
|
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
|
||||||
|
}
|
||||||
|
exports.prepareKeyValueMessage = prepareKeyValueMessage;
|
||||||
//# sourceMappingURL=file-command.js.map
|
//# sourceMappingURL=file-command.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -2836,10 +2851,10 @@ module.exports = {
|
|||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
// `ecmaVersion` indicates the ECMAScript version to parse. Must be
|
// `ecmaVersion` indicates the ECMAScript version to parse. Must be
|
||||||
// either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
|
// either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10
|
||||||
// (2019), 11 (2020), 12 (2021), 13 (2022), or `"latest"` (the
|
// (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"`
|
||||||
// latest version the library supports). This influences support
|
// (the latest version the library supports). This influences
|
||||||
// for strict mode, the set of reserved words, and support for
|
// support for strict mode, the set of reserved words, and support
|
||||||
// new syntax features.
|
// for new syntax features.
|
||||||
ecmaVersion: null,
|
ecmaVersion: null,
|
||||||
// `sourceType` indicates the mode the code should be parsed in.
|
// `sourceType` indicates the mode the code should be parsed in.
|
||||||
// Can be either `"script"` or `"module"`. This influences global
|
// Can be either `"script"` or `"module"`. This influences global
|
||||||
@@ -2873,8 +2888,9 @@ module.exports = {
|
|||||||
// When enabled, super identifiers are not constrained to
|
// When enabled, super identifiers are not constrained to
|
||||||
// appearing in methods and do not raise an error when they appear elsewhere.
|
// appearing in methods and do not raise an error when they appear elsewhere.
|
||||||
allowSuperOutsideMethod: null,
|
allowSuperOutsideMethod: null,
|
||||||
// When enabled, hashbang directive in the beginning of file
|
// When enabled, hashbang directive in the beginning of file is
|
||||||
// is allowed and treated as a line comment.
|
// allowed and treated as a line comment. Enabled by default when
|
||||||
|
// `ecmaVersion` >= 2023.
|
||||||
allowHashBang: false,
|
allowHashBang: false,
|
||||||
// When `locations` is on, `loc` properties holding objects with
|
// When `locations` is on, `loc` properties holding objects with
|
||||||
// `start` and `end` properties in `{line, column}` form (with
|
// `start` and `end` properties in `{line, column}` form (with
|
||||||
@@ -2949,6 +2965,9 @@ module.exports = {
|
|||||||
if (options.allowReserved == null)
|
if (options.allowReserved == null)
|
||||||
{ options.allowReserved = options.ecmaVersion < 5; }
|
{ options.allowReserved = options.ecmaVersion < 5; }
|
||||||
|
|
||||||
|
if (opts.allowHashBang == null)
|
||||||
|
{ options.allowHashBang = options.ecmaVersion >= 14; }
|
||||||
|
|
||||||
if (isArray(options.onToken)) {
|
if (isArray(options.onToken)) {
|
||||||
var tokens = options.onToken;
|
var tokens = options.onToken;
|
||||||
options.onToken = function (token) { return tokens.push(token); };
|
options.onToken = function (token) { return tokens.push(token); };
|
||||||
@@ -3279,7 +3298,7 @@ module.exports = {
|
|||||||
if (refDestructuringErrors.trailingComma > -1)
|
if (refDestructuringErrors.trailingComma > -1)
|
||||||
{ this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
|
{ this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
|
||||||
var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
|
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) {
|
pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
|
||||||
@@ -4375,6 +4394,7 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
pp$8.isDirectiveCandidate = function(statement) {
|
pp$8.isDirectiveCandidate = function(statement) {
|
||||||
return (
|
return (
|
||||||
|
this.options.ecmaVersion >= 5 &&
|
||||||
statement.type === "ExpressionStatement" &&
|
statement.type === "ExpressionStatement" &&
|
||||||
statement.expression.type === "Literal" &&
|
statement.expression.type === "Literal" &&
|
||||||
typeof statement.expression.value === "string" &&
|
typeof statement.expression.value === "string" &&
|
||||||
@@ -4785,7 +4805,8 @@ module.exports = {
|
|||||||
{ this.exprAllowed = type.beforeExpr; }
|
{ 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) {
|
pp$6.overrideContext = function(tokenCtx) {
|
||||||
if (this.curContext() !== tokenCtx) {
|
if (this.curContext() !== tokenCtx) {
|
||||||
this.context[this.context.length - 1] = tokenCtx;
|
this.context[this.context.length - 1] = tokenCtx;
|
||||||
@@ -5601,15 +5622,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
return this.finishNode(prop, "RestElement")
|
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.
|
// Parse argument.
|
||||||
prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
|
prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
|
||||||
// To disallow trailing comma via `this.toAssignable()`.
|
// To disallow trailing comma via `this.toAssignable()`.
|
||||||
@@ -8039,7 +8051,7 @@ module.exports = {
|
|||||||
|
|
||||||
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
// Acorn is a tiny, fast JavaScript parser written in JavaScript.
|
||||||
|
|
||||||
var version = "8.7.1";
|
var version = "8.8.0";
|
||||||
|
|
||||||
Parser.acorn = {
|
Parser.acorn = {
|
||||||
Parser: Parser,
|
Parser: Parser,
|
||||||
@@ -15189,21 +15201,17 @@ async function enablePagesSite({ repositoryNwo, githubToken }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getPagesSite({ 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, {
|
const response = await axios.get(pagesEndpoint, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
Authorization: `Bearer ${githubToken}`
|
Authorization: `Bearer ${githubToken}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const pageObject = response.data
|
const pageObject = response.data
|
||||||
return pageObject
|
return pageObject
|
||||||
} catch (error) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findOrCreatePagesSite({ repositoryNwo, githubToken, enablement = true }) {
|
async function findOrCreatePagesSite({ repositoryNwo, githubToken, enablement = true }) {
|
||||||
@@ -15438,11 +15446,12 @@ class ConfigParser {
|
|||||||
throw 'Could not find a configuration object in the configuration file'
|
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.
|
// then walk the configuration object one property at a time.
|
||||||
var depth = 0
|
var depth = 0
|
||||||
const properties = propertyName.split('.')
|
const properties = propertyName.split('.')
|
||||||
var lastNode = configurationObject
|
var lastNode = configurationObject
|
||||||
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
// Find the node for the current property
|
// Find the node for the current property
|
||||||
var propertyNode = this.findProperty(lastNode, properties[depth])
|
var propertyNode = this.findProperty(lastNode, properties[depth])
|
||||||
@@ -15519,7 +15528,7 @@ class ConfigParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
core.info(`Injection successful, new configuration:`)
|
core.info('Injection successful, new configuration:')
|
||||||
core.info(this.configuration)
|
core.info(this.configuration)
|
||||||
|
|
||||||
// Finally write the new configuration in the file
|
// Finally write the new configuration in the file
|
||||||
@@ -15571,12 +15580,17 @@ module.exports = { getContext }
|
|||||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
|
const removeTrailingSlash = __nccwpck_require__(9255)
|
||||||
|
|
||||||
function outputPagesBaseUrl(siteUrl) {
|
function outputPagesBaseUrl(siteUrl) {
|
||||||
core.setOutput('base_url', siteUrl.href)
|
// Many static site generators do not want the trailing slash, and it is much easier to add than remove in a workflow
|
||||||
|
const baseUrl = removeTrailingSlash(siteUrl.href)
|
||||||
|
const basePath = removeTrailingSlash(siteUrl.pathname)
|
||||||
|
|
||||||
|
core.setOutput('base_url', baseUrl)
|
||||||
core.setOutput('origin', siteUrl.origin)
|
core.setOutput('origin', siteUrl.origin)
|
||||||
core.setOutput('host', siteUrl.host)
|
core.setOutput('host', siteUrl.host)
|
||||||
core.setOutput('base_path', siteUrl.pathname)
|
core.setOutput('base_path', basePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = outputPagesBaseUrl
|
module.exports = outputPagesBaseUrl
|
||||||
@@ -15584,15 +15598,28 @@ module.exports = outputPagesBaseUrl
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 4770:
|
/***/ 9255:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
module.exports = function removeTrailingSlash(str) {
|
||||||
|
return str.endsWith('/') ? str.slice(0, -1) : str
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6310:
|
||||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
const { ConfigParser } = __nccwpck_require__(8395)
|
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,
|
// 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
|
// optional configuration file path, and a Pages siteUrl value to inject
|
||||||
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path }) {
|
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
|
||||||
|
let { pathname: path, origin } = siteUrl
|
||||||
|
|
||||||
switch (staticSiteGenerator) {
|
switch (staticSiteGenerator) {
|
||||||
case 'nuxt':
|
case 'nuxt':
|
||||||
return {
|
return {
|
||||||
@@ -15609,9 +15636,7 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
|
|||||||
}
|
}
|
||||||
case 'next':
|
case 'next':
|
||||||
// Next does not want a trailing slash
|
// Next does not want a trailing slash
|
||||||
if (path.endsWith('/')) {
|
path = removeTrailingSlash(path)
|
||||||
path = path.slice(0, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configurationFile: generatorConfigFile || './next.config.js',
|
configurationFile: generatorConfigFile || './next.config.js',
|
||||||
@@ -15631,21 +15656,23 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
|
|||||||
blankConfigurationFile: __nccwpck_require__.ab + "gatsby.js",
|
blankConfigurationFile: __nccwpck_require__.ab + "gatsby.js",
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a path prefix
|
// Configure a path prefix
|
||||||
pathPrefix: path
|
pathPrefix: path,
|
||||||
|
// Configure a site url
|
||||||
|
'siteMetadata.siteUrl': origin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'sveltekit':
|
case 'sveltekit':
|
||||||
// SvelteKit does not want a trailing slash
|
// SvelteKit does not want a trailing slash
|
||||||
if (path.endsWith('/')) {
|
path = removeTrailingSlash(path)
|
||||||
path = path.slice(0, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configurationFile: generatorConfigFile || './svelte.config.js',
|
configurationFile: generatorConfigFile || './svelte.config.js',
|
||||||
blankConfigurationFile: __nccwpck_require__.ab + "sveltekit.js",
|
blankConfigurationFile: __nccwpck_require__.ab + "sveltekit.js",
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a base path
|
// Configure a base path
|
||||||
'kit.paths.base': path
|
'kit.paths.base': path,
|
||||||
|
// Configure a prerender origin
|
||||||
|
'kit.prerender.origin': origin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -15654,21 +15681,21 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inject Pages configuration in a given static site generator's configuration file
|
// Inject Pages configuration in a given static site generator's configuration file
|
||||||
function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
|
function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
|
||||||
try {
|
try {
|
||||||
// Parse the configuration file and try to inject the Pages configuration in it
|
// 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()
|
new ConfigParser(settings).injectAll()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Logging
|
// Logging
|
||||||
core.warning(
|
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
|
error
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { getConfigParserSettings, setPagesPath }
|
module.exports = { getConfigParserSettings, setPagesConfig }
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -16491,14 +16518,15 @@ TokenTranslator.prototype = {
|
|||||||
const SUPPORTED_VERSIONS = [
|
const SUPPORTED_VERSIONS = [
|
||||||
3,
|
3,
|
||||||
5,
|
5,
|
||||||
6,
|
6, // 2015
|
||||||
7,
|
7, // 2016
|
||||||
8,
|
8, // 2017
|
||||||
9,
|
9, // 2018
|
||||||
10,
|
10, // 2019
|
||||||
11,
|
11, // 2020
|
||||||
12,
|
12, // 2021
|
||||||
13
|
13, // 2022
|
||||||
|
14 // 2023
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16616,12 +16644,23 @@ const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
|
|||||||
* @param {int} end The index at which the comment ends.
|
* @param {int} end The index at which the comment ends.
|
||||||
* @param {Location} startLoc The location at which the comment starts.
|
* @param {Location} startLoc The location at which the comment starts.
|
||||||
* @param {Location} endLoc The location at which the comment ends.
|
* @param {Location} endLoc The location at which the comment ends.
|
||||||
|
* @param {string} code The source code being parsed.
|
||||||
* @returns {Object} The comment object.
|
* @returns {Object} The comment object.
|
||||||
* @private
|
* @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 = {
|
const comment = {
|
||||||
type: block ? "Block" : "Line",
|
type,
|
||||||
value: text
|
value: text
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -16666,6 +16705,25 @@ var espree = () => Parser => {
|
|||||||
? new TokenTranslator(tokTypes, code)
|
? new TokenTranslator(tokTypes, code)
|
||||||
: null;
|
: 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.
|
// Initialize acorn parser.
|
||||||
super({
|
super({
|
||||||
|
|
||||||
@@ -16684,38 +16742,28 @@ var espree = () => Parser => {
|
|||||||
if (tokenTranslator) {
|
if (tokenTranslator) {
|
||||||
|
|
||||||
// Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
|
// Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
|
||||||
tokenTranslator.onToken(token, this[STATE]);
|
tokenTranslator.onToken(token, state);
|
||||||
}
|
}
|
||||||
if (token.type !== tokTypes.eof) {
|
if (token.type !== tokTypes.eof) {
|
||||||
this[STATE].lastToken = token;
|
state.lastToken = token;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Collect comments
|
// Collect comments
|
||||||
onComment: (block, text, start, end, startLoc, endLoc) => {
|
onComment: (block, text, start, end, startLoc, endLoc) => {
|
||||||
if (this[STATE].comments) {
|
if (state.comments) {
|
||||||
const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc);
|
const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code);
|
||||||
|
|
||||||
this[STATE].comments.push(comment);
|
state.comments.push(comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, code);
|
}, code);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data that is unique to Espree and is not represented internally in
|
* We put all of this data into a symbol property as a way to avoid
|
||||||
* Acorn. We put all of this data into a symbol property as a way to
|
* potential naming conflicts with future versions of Acorn.
|
||||||
* avoid potential naming conflicts with future versions of Acorn.
|
|
||||||
*/
|
*/
|
||||||
this[STATE] = {
|
this[STATE] = 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: []
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenize() {
|
tokenize() {
|
||||||
@@ -16928,7 +16976,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.
|
* @fileoverview Main Espree file that converts Acorn into Esprima output.
|
||||||
@@ -17163,7 +17211,7 @@ const core = __nccwpck_require__(2186)
|
|||||||
const { getContext } = __nccwpck_require__(1319)
|
const { getContext } = __nccwpck_require__(1319)
|
||||||
|
|
||||||
const { findOrCreatePagesSite } = __nccwpck_require__(9432)
|
const { findOrCreatePagesSite } = __nccwpck_require__(9432)
|
||||||
const { setPagesPath } = __nccwpck_require__(4770)
|
const { setPagesConfig } = __nccwpck_require__(6310)
|
||||||
const outputPagesBaseUrl = __nccwpck_require__(7527)
|
const outputPagesBaseUrl = __nccwpck_require__(7527)
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -17174,7 +17222,7 @@ async function main() {
|
|||||||
const siteUrl = new URL(pageObject.html_url)
|
const siteUrl = new URL(pageObject.html_url)
|
||||||
|
|
||||||
if (staticSiteGenerator) {
|
if (staticSiteGenerator) {
|
||||||
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
|
setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl })
|
||||||
}
|
}
|
||||||
outputPagesBaseUrl(siteUrl)
|
outputPagesBaseUrl(siteUrl)
|
||||||
core.exportVariable('GITHUB_PAGES', 'true')
|
core.exportVariable('GITHUB_PAGES', 'true')
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
3868
package-lock.json
generated
3868
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@@ -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.",
|
"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",
|
"main": "./dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "prettier --write 'src/**/*.js'",
|
"all": "npm run format && npm run lint && npm run prepare && npm run test",
|
||||||
"format:check": "prettier --check 'src/**/*.js'",
|
"format": "prettier --write .",
|
||||||
"prepare": "npm run format && ncc build src/index.js -o dist --source-map --license licenses.txt",
|
"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"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -21,14 +24,15 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/configure-pages#readme",
|
"homepage": "https://github.com/actions/configure-pages#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.9.1",
|
"@actions/core": "^1.10.0",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"axios-retry": "^3.2.5",
|
"espree": "^9.3.2"
|
||||||
"espree": "^9.3.2",
|
|
||||||
"string-format": "^1.0.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.34.0",
|
"@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",
|
"jest": "^28.1.1",
|
||||||
"prettier": "^2.7.1"
|
"prettier": "^2.7.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,21 +33,17 @@ async function enablePagesSite({ repositoryNwo, githubToken }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getPagesSite({ 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, {
|
const response = await axios.get(pagesEndpoint, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/vnd.github.v3+json',
|
Accept: 'application/vnd.github.v3+json',
|
||||||
Authorization: `Bearer ${githubToken}`
|
Authorization: `Bearer ${githubToken}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const pageObject = response.data
|
const pageObject = response.data
|
||||||
return pageObject
|
return pageObject
|
||||||
} catch (error) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findOrCreatePagesSite({ repositoryNwo, githubToken, enablement = true }) {
|
async function findOrCreatePagesSite({ repositoryNwo, githubToken, enablement = true }) {
|
||||||
|
|||||||
@@ -184,11 +184,12 @@ class ConfigParser {
|
|||||||
throw 'Could not find a configuration object in the configuration file'
|
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.
|
// then walk the configuration object one property at a time.
|
||||||
var depth = 0
|
var depth = 0
|
||||||
const properties = propertyName.split('.')
|
const properties = propertyName.split('.')
|
||||||
var lastNode = configurationObject
|
var lastNode = configurationObject
|
||||||
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
// Find the node for the current property
|
// Find the node for the current property
|
||||||
var propertyNode = this.findProperty(lastNode, properties[depth])
|
var propertyNode = this.findProperty(lastNode, properties[depth])
|
||||||
@@ -265,7 +266,7 @@ class ConfigParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
core.info(`Injection successful, new configuration:`)
|
core.info('Injection successful, new configuration:')
|
||||||
core.info(this.configuration)
|
core.info(this.configuration)
|
||||||
|
|
||||||
// Finally write the new configuration in the file
|
// Finally write the new configuration in the file
|
||||||
|
|||||||
@@ -14,79 +14,79 @@ const cases = [
|
|||||||
//
|
//
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default {}`,
|
source: 'export default {}',
|
||||||
expected: `export default { property: "value" }`
|
expected: 'export default { property: "value" }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default { property: 0 }`, // property exists and is a number
|
source: 'export default { property: 0 }', // property exists and is a number
|
||||||
expected: `export default { property: "value" }`
|
expected: 'export default { property: "value" }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default { property: false }`, // property exists and is a boolean
|
source: 'export default { property: false }', // property exists and is a boolean
|
||||||
expected: `export default { property: "value" }`
|
expected: 'export default { property: "value" }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default { property: "test" }`, // property exists and is a string
|
source: 'export default { property: "test" }', // property exists and is a string
|
||||||
expected: `export default { property: "value" }`
|
expected: 'export default { property: "value" }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default { property: [1,2] }`, // property exists and is an array
|
source: 'export default { property: [1,2] }', // property exists and is an array
|
||||||
expected: `export default { property: "value" }`
|
expected: 'export default { property: "value" }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default { property: null }`, // property exists and is null
|
source: 'export default { property: null }', // property exists and is null
|
||||||
expected: `export default { property: "value" }`
|
expected: 'export default { property: "value" }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default { property: {}}`, // property exists and is an object
|
source: 'export default { property: { } }', // property exists and is an object
|
||||||
expected: `export default { property: "value" }`
|
expected: 'export default { property: "value" }'
|
||||||
},
|
},
|
||||||
|
|
||||||
// Deep properties (injection 1)
|
// Deep properties (injection 1)
|
||||||
{
|
{
|
||||||
property: 'property.b.c',
|
property: 'property.b.c',
|
||||||
source: `export default {}`,
|
source: 'export default {}',
|
||||||
expected: `export default { property: { b: { c: "value" }}}`
|
expected: 'export default { property: { b: { c: "value" } } }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property.b.c',
|
property: 'property.b.c',
|
||||||
source: `export default { property: 0 }`, // property exists and is a number
|
source: 'export default { property: 0 }', // property exists and is a number
|
||||||
expected: `export default { property: { b: { c: "value" }}}`
|
expected: 'export default { property: { b: { c: "value" } } }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property.b.c',
|
property: 'property.b.c',
|
||||||
source: `export default { property: {}}`, // property exists and is an object
|
source: 'export default { property: { } }', // property exists and is an object
|
||||||
expected: `export default { property: { b: { c: "value" }}}`
|
expected: 'export default { property: { b: { c: "value" } } }'
|
||||||
},
|
},
|
||||||
|
|
||||||
// Deep properties (injection 2)
|
// Deep properties (injection 2)
|
||||||
{
|
{
|
||||||
property: 'property.b.c',
|
property: 'property.b.c',
|
||||||
source: `export default { property: { b: 0 }}`, // property exists and is a number
|
source: 'export default { property: { b: 0 } }', // property exists and is a number
|
||||||
expected: `export default { property: { b: { c: "value" }}}`
|
expected: 'export default { property: { b: { c: "value" } } }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property.b.c',
|
property: 'property.b.c',
|
||||||
source: `export default { property: { b: {}}}`, // property exists and is an object
|
source: 'export default { property: { b: { } } }', // property exists and is an object
|
||||||
expected: `export default { property: { b: { c: "value" }}}`
|
expected: 'export default { property: { b: { c: "value" } } }'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property.b.c',
|
property: 'property.b.c',
|
||||||
source: `export default { property: { b: { hello: 123}}}`, // property exists and is a non-empty object
|
source: 'export default { property: { b: { hello: 123 } } }', // property exists and is a non-empty object
|
||||||
expected: `export default { property: { b: { c: "value", hello: 123 }}}`
|
expected: 'export default { property: { b: { c: "value", hello: 123 } } }'
|
||||||
},
|
},
|
||||||
|
|
||||||
// Deep properties (existing properties)
|
// Deep properties (existing properties)
|
||||||
{
|
{
|
||||||
property: 'a1.a2',
|
property: 'a1.a2',
|
||||||
source: `export default { a2: false, a1: { a3: [12]}}`, // property exists and is a non-empty object
|
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]}}`
|
expected: 'export default { a2: false, a1: { a2: "value", a3: [12] } }'
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -94,23 +94,23 @@ const cases = [
|
|||||||
//
|
//
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `const config = {}; export default config`,
|
source: 'const config = {}; export default config',
|
||||||
expected: `const config = { property: "value"}; export default config`
|
expected: 'const config = { property: "value"}; export default config'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `var config = {}; export default config`,
|
source: 'var config = {}; export default config',
|
||||||
expected: `var config = { property: "value"}; export default config`
|
expected: 'var config = { property: "value"}; export default config'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'a.b.c',
|
property: 'a.b.c',
|
||||||
source: `var config = {}; export default config`,
|
source: 'var config = {}; export default config',
|
||||||
expected: `var config = { a: { b: { c: "value"}}}; export default config`
|
expected: 'var config = { a: { b: { c: "value" } } }; export default config'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'a.b.c',
|
property: 'a.b.c',
|
||||||
source: `var config = { a: { b: [], 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`
|
expected: 'var config = { a: { b: { c: "value"}, c: "hello" } }; export default config'
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -118,18 +118,18 @@ const cases = [
|
|||||||
//
|
//
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `module.exports = {}`,
|
source: 'module.exports = {}',
|
||||||
expected: `module.exports = { property: "value"}`
|
expected: 'module.exports = { property: "value"}'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `module.exports = { p1: 0}`,
|
source: 'module.exports = { p1: 0}',
|
||||||
expected: `module.exports = { property: "value", p1: 0}`
|
expected: 'module.exports = { property: "value", p1: 0}'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'a.b.c',
|
property: 'a.b.c',
|
||||||
source: `module.exports = { p1: 0}`,
|
source: 'module.exports = { p1: 0}',
|
||||||
expected: `module.exports = { a: { b: { c: "value" }}, p1: 0}`
|
expected: 'module.exports = { a: { b: { c: "value" } }, p1: 0}'
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -137,23 +137,23 @@ const cases = [
|
|||||||
//
|
//
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `const config = {}; module.exports = config`,
|
source: 'const config = {}; module.exports = config',
|
||||||
expected: `const config = { property: "value"}; module.exports = config`
|
expected: 'const config = { property: "value"}; module.exports = config'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `var config = {}; module.exports = config`,
|
source: 'var config = {}; module.exports = config',
|
||||||
expected: `var config = { property: "value"}; module.exports = config`
|
expected: 'var config = { property: "value"}; module.exports = config'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'a.b.c',
|
property: 'a.b.c',
|
||||||
source: `var config = {}; module.exports = config`,
|
source: 'var config = {}; module.exports = config',
|
||||||
expected: `var config = { a: { b: { c: "value"}}}; module.exports = config`
|
expected: 'var config = { a: { b: { c: "value" } } }; module.exports = config'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'a.b.c',
|
property: 'a.b.c',
|
||||||
source: `var config = { a: { b: [], 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`
|
expected: 'var config = { a: { b: { c: "value"}, c: "hello" } }; module.exports = config'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// Default Pages configuration for Gatsby
|
// Default Pages configuration for Gatsby
|
||||||
module.exports = { pathPrefix: '/docs/' }
|
module.exports = { siteMetadata: { siteUrl: 'https://configure-pages.github.io' }, pathPrefix: '/docs/' }
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
title: 'My Gatsby Site'
|
||||||
siteUrl: `https://www.yourdomain.tld`,
|
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
pathPrefix: "/docs/",
|
pathPrefix: '/docs/',
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
siteUrl: 'https://configure-pages.github.io',
|
||||||
siteUrl: `https://www.yourdomain.tld`,
|
title: 'My Gatsby Site'
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
pathPrefix: '/docs/',
|
pathPrefix: '/docs/',
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
siteUrl: 'https://configure-pages.github.io',
|
||||||
siteUrl: `https://www.yourdomain.tld`
|
title: 'My Gatsby Site'
|
||||||
},
|
},
|
||||||
plugins: []
|
plugins: []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
export default {
|
export default {
|
||||||
pathPrefix: "/docs/",
|
pathPrefix: '/docs/',
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
siteUrl: 'https://configure-pages.github.io',
|
||||||
siteUrl: `https://www.yourdomain.tld`,
|
title: 'My Gatsby Site'
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
title: 'My Gatsby Site'
|
||||||
siteUrl: `https://www.yourdomain.tld`
|
|
||||||
},
|
},
|
||||||
plugins: []
|
plugins: []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
title: 'My Gatsby Site'
|
||||||
siteUrl: `https://www.yourdomain.tld`,
|
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
swcMinify: true,
|
swcMinify: true
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = nextConfig
|
module.exports = nextConfig
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
experimental: {images: {unoptimized: true}},
|
experimental: { images: { unoptimized: true } },
|
||||||
basePath: '/docs',
|
basePath: '/docs',
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
swcMinify: true
|
swcMinify: true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
experimental: {images: {unoptimized: true}},
|
experimental: { images: { unoptimized: true } },
|
||||||
basePath: '/docs',
|
basePath: '/docs',
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
swcMinify: true
|
swcMinify: true
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
swcMinify: true,
|
swcMinify: true
|
||||||
}
|
}
|
||||||
|
|
||||||
export default nextConfig
|
export default nextConfig
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
const getAllDynamicRoute = async function() {
|
const getAllDynamicRoute = async function () {
|
||||||
const routes = await (async () => {
|
const routes = await (async () => {
|
||||||
return ['/posts/hello-world', '/posts/hello-again'];
|
return ['/posts/hello-world', '/posts/hello-again']
|
||||||
})();
|
})()
|
||||||
return routes;
|
return routes
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: 'universal',
|
mode: 'universal',
|
||||||
generate: {
|
generate: {
|
||||||
async routes () {
|
async routes() {
|
||||||
return getAllDynamicRoute();
|
return getAllDynamicRoute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
const getAllDynamicRoute = async function() {
|
const getAllDynamicRoute = async function () {
|
||||||
const routes = await (async () => {
|
const routes = await (async () => {
|
||||||
return ['/posts/hello-world', '/posts/hello-again'];
|
return ['/posts/hello-world', '/posts/hello-again']
|
||||||
})();
|
})()
|
||||||
return routes;
|
return routes
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
target: 'static',
|
target: 'static',
|
||||||
router: {base: '/docs/'},
|
router: { base: '/docs/' },
|
||||||
mode: 'universal',
|
mode: 'universal',
|
||||||
generate: {
|
generate: {
|
||||||
async routes () {
|
async routes() {
|
||||||
return getAllDynamicRoute();
|
return getAllDynamicRoute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
const getAllDynamicRoute = async function() {
|
const getAllDynamicRoute = async function () {
|
||||||
const routes = await (async () => {
|
const routes = await (async () => {
|
||||||
return ['/posts/hello-world', '/posts/hello-again'];
|
return ['/posts/hello-world', '/posts/hello-again']
|
||||||
})();
|
})()
|
||||||
return routes;
|
return routes
|
||||||
};
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
target: 'static',
|
target: 'static',
|
||||||
router: {base: '/docs/'},
|
router: { base: '/docs/' },
|
||||||
mode: 'universal',
|
mode: 'universal',
|
||||||
generate: {
|
generate: {
|
||||||
async routes () {
|
async routes() {
|
||||||
return getAllDynamicRoute();
|
return getAllDynamicRoute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
const getAllDynamicRoute = async function() {
|
const getAllDynamicRoute = async function () {
|
||||||
const routes = await (async () => {
|
const routes = await (async () => {
|
||||||
return ['/posts/hello-world', '/posts/hello-again'];
|
return ['/posts/hello-world', '/posts/hello-again']
|
||||||
})();
|
})()
|
||||||
return routes;
|
return routes
|
||||||
};
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mode: 'universal',
|
mode: 'universal',
|
||||||
generate: {
|
generate: {
|
||||||
async routes () {
|
async routes() {
|
||||||
return getAllDynamicRoute();
|
return getAllDynamicRoute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -14,31 +14,24 @@ module.exports = {
|
|||||||
{ hid: 'description', name: 'description', content: '' },
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
{ name: 'format-detection', content: 'telephone=no' }
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
],
|
],
|
||||||
link: [
|
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
||||||
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global CSS: https://go.nuxtjs.dev/config-css
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
css: [
|
css: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
plugins: [
|
plugins: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Auto import components: https://go.nuxtjs.dev/config-components
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
components: true,
|
components: true,
|
||||||
|
|
||||||
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
buildModules: [
|
buildModules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Modules: https://go.nuxtjs.dev/config-modules
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
modules: [
|
modules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Build Configuration: https://go.nuxtjs.dev/config-build
|
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||||
build: {
|
build: {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
||||||
target: 'static',
|
target: 'static',
|
||||||
router: { base: "/docs/" },
|
router: { base: '/docs/' },
|
||||||
ssr: false,
|
ssr: false,
|
||||||
|
|
||||||
// Global page headers: https://go.nuxtjs.dev/config-head
|
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||||
@@ -16,31 +16,24 @@ module.exports = {
|
|||||||
{ hid: 'description', name: 'description', content: '' },
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
{ name: 'format-detection', content: 'telephone=no' }
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
],
|
],
|
||||||
link: [
|
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
||||||
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global CSS: https://go.nuxtjs.dev/config-css
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
css: [
|
css: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
plugins: [
|
plugins: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Auto import components: https://go.nuxtjs.dev/config-components
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
components: true,
|
components: true,
|
||||||
|
|
||||||
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
buildModules: [
|
buildModules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Modules: https://go.nuxtjs.dev/config-modules
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
modules: [
|
modules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Build Configuration: https://go.nuxtjs.dev/config-build
|
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||||
build: {
|
build: {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
||||||
target: 'static',
|
target: 'static',
|
||||||
router: { base: "/docs/" },
|
router: { base: '/docs/' },
|
||||||
ssr: false,
|
ssr: false,
|
||||||
|
|
||||||
// Global page headers: https://go.nuxtjs.dev/config-head
|
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||||
@@ -16,31 +16,24 @@ export default {
|
|||||||
{ hid: 'description', name: 'description', content: '' },
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
{ name: 'format-detection', content: 'telephone=no' }
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
],
|
],
|
||||||
link: [
|
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
||||||
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global CSS: https://go.nuxtjs.dev/config-css
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
css: [
|
css: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
plugins: [
|
plugins: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Auto import components: https://go.nuxtjs.dev/config-components
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
components: true,
|
components: true,
|
||||||
|
|
||||||
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
buildModules: [
|
buildModules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Modules: https://go.nuxtjs.dev/config-modules
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
modules: [
|
modules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Build Configuration: https://go.nuxtjs.dev/config-build
|
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||||
build: {
|
build: {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,31 +14,24 @@ export default {
|
|||||||
{ hid: 'description', name: 'description', content: '' },
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
{ name: 'format-detection', content: 'telephone=no' }
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
],
|
],
|
||||||
link: [
|
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
||||||
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global CSS: https://go.nuxtjs.dev/config-css
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
css: [
|
css: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
plugins: [
|
plugins: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Auto import components: https://go.nuxtjs.dev/config-components
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
components: true,
|
components: true,
|
||||||
|
|
||||||
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
buildModules: [
|
buildModules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Modules: https://go.nuxtjs.dev/config-modules
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
modules: [
|
modules: [],
|
||||||
],
|
|
||||||
|
|
||||||
// Build Configuration: https://go.nuxtjs.dev/config-build
|
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||||
build: {
|
build: {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import adapter from '@sveltejs/adapter-auto'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
kit: {
|
kit: {
|
||||||
|
prerender: { origin: 'https://configure-pages.github.io' },
|
||||||
paths: { base: '/docs' },
|
paths: { base: '/docs' },
|
||||||
adapter: adapter()
|
adapter: adapter()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import adapter from '@sveltejs/adapter-auto'
|
|||||||
/** @type {import('@sveltejs/kit').Config} */
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
kit: {
|
kit: {
|
||||||
|
prerender: { origin: 'https://configure-pages.github.io' },
|
||||||
paths: { base: '/docs' },
|
paths: { base: '/docs' },
|
||||||
adapter: adapter()
|
adapter: adapter()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const core = require('@actions/core')
|
|||||||
const { getContext } = require('./context')
|
const { getContext } = require('./context')
|
||||||
|
|
||||||
const { findOrCreatePagesSite } = require('./api-client')
|
const { findOrCreatePagesSite } = require('./api-client')
|
||||||
const { setPagesPath } = require('./set-pages-path')
|
const { setPagesConfig } = require('./set-pages-config')
|
||||||
const outputPagesBaseUrl = require('./output-pages-base-url')
|
const outputPagesBaseUrl = require('./output-pages-base-url')
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -15,7 +15,7 @@ async function main() {
|
|||||||
const siteUrl = new URL(pageObject.html_url)
|
const siteUrl = new URL(pageObject.html_url)
|
||||||
|
|
||||||
if (staticSiteGenerator) {
|
if (staticSiteGenerator) {
|
||||||
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
|
setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl })
|
||||||
}
|
}
|
||||||
outputPagesBaseUrl(siteUrl)
|
outputPagesBaseUrl(siteUrl)
|
||||||
core.exportVariable('GITHUB_PAGES', 'true')
|
core.exportVariable('GITHUB_PAGES', 'true')
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
|
const removeTrailingSlash = require('./remove-trailing-slash')
|
||||||
|
|
||||||
function outputPagesBaseUrl(siteUrl) {
|
function outputPagesBaseUrl(siteUrl) {
|
||||||
core.setOutput('base_url', siteUrl.href)
|
// Many static site generators do not want the trailing slash, and it is much easier to add than remove in a workflow
|
||||||
|
const baseUrl = removeTrailingSlash(siteUrl.href)
|
||||||
|
const basePath = removeTrailingSlash(siteUrl.pathname)
|
||||||
|
|
||||||
|
core.setOutput('base_url', baseUrl)
|
||||||
core.setOutput('origin', siteUrl.origin)
|
core.setOutput('origin', siteUrl.origin)
|
||||||
core.setOutput('host', siteUrl.host)
|
core.setOutput('host', siteUrl.host)
|
||||||
core.setOutput('base_path', siteUrl.pathname)
|
core.setOutput('base_path', basePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = outputPagesBaseUrl
|
module.exports = outputPagesBaseUrl
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
|
|
||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', 'https://octocat.github.io')
|
||||||
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('host', 'octocat.github.io')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets expected outputs for project site', async () => {
|
it('gets expected outputs for project site', async () => {
|
||||||
@@ -34,10 +34,10 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
|
|
||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', 'https://octocat.github.io/my-repo')
|
||||||
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('host', 'octocat.github.io')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/my-repo/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/my-repo')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('gets expected outputs for site with custom domain name', async () => {
|
it('gets expected outputs for site with custom domain name', async () => {
|
||||||
@@ -45,9 +45,9 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
|
|
||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', 'https://www.example.com')
|
||||||
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('host', 'www.example.com')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
3
src/remove-trailing-slash.js
Normal file
3
src/remove-trailing-slash.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function removeTrailingSlash(str) {
|
||||||
|
return str.endsWith('/') ? str.slice(0, -1) : str
|
||||||
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const { ConfigParser } = require('./config-parser')
|
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,
|
// 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
|
// optional configuration file path, and a Pages siteUrl value to inject
|
||||||
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path }) {
|
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
|
||||||
|
let { pathname: path, origin } = siteUrl
|
||||||
|
|
||||||
switch (staticSiteGenerator) {
|
switch (staticSiteGenerator) {
|
||||||
case 'nuxt':
|
case 'nuxt':
|
||||||
return {
|
return {
|
||||||
@@ -20,9 +23,7 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
|
|||||||
}
|
}
|
||||||
case 'next':
|
case 'next':
|
||||||
// Next does not want a trailing slash
|
// Next does not want a trailing slash
|
||||||
if (path.endsWith('/')) {
|
path = removeTrailingSlash(path)
|
||||||
path = path.slice(0, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configurationFile: generatorConfigFile || './next.config.js',
|
configurationFile: generatorConfigFile || './next.config.js',
|
||||||
@@ -42,21 +43,23 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
|
|||||||
blankConfigurationFile: `${__dirname}/blank-configurations/gatsby.js`,
|
blankConfigurationFile: `${__dirname}/blank-configurations/gatsby.js`,
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a path prefix
|
// Configure a path prefix
|
||||||
pathPrefix: path
|
pathPrefix: path,
|
||||||
|
// Configure a site url
|
||||||
|
'siteMetadata.siteUrl': origin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'sveltekit':
|
case 'sveltekit':
|
||||||
// SvelteKit does not want a trailing slash
|
// SvelteKit does not want a trailing slash
|
||||||
if (path.endsWith('/')) {
|
path = removeTrailingSlash(path)
|
||||||
path = path.slice(0, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configurationFile: generatorConfigFile || './svelte.config.js',
|
configurationFile: generatorConfigFile || './svelte.config.js',
|
||||||
blankConfigurationFile: `${__dirname}/blank-configurations/sveltekit.js`,
|
blankConfigurationFile: `${__dirname}/blank-configurations/sveltekit.js`,
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a base path
|
// Configure a base path
|
||||||
'kit.paths.base': path
|
'kit.paths.base': path,
|
||||||
|
// Configure a prerender origin
|
||||||
|
'kit.prerender.origin': origin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -65,18 +68,18 @@ function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inject Pages configuration in a given static site generator's configuration file
|
// Inject Pages configuration in a given static site generator's configuration file
|
||||||
function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
|
function setPagesConfig({ staticSiteGenerator, generatorConfigFile, siteUrl }) {
|
||||||
try {
|
try {
|
||||||
// Parse the configuration file and try to inject the Pages configuration in it
|
// 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()
|
new ConfigParser(settings).injectAll()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Logging
|
// Logging
|
||||||
core.warning(
|
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
|
error
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { getConfigParserSettings, setPagesPath }
|
module.exports = { getConfigParserSettings, setPagesConfig }
|
||||||
@@ -2,7 +2,7 @@ const fs = require('fs')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
|
|
||||||
const { getConfigParserSettings } = require('./set-pages-path')
|
const { getConfigParserSettings } = require('./set-pages-config')
|
||||||
const { ConfigParser } = require('./config-parser')
|
const { ConfigParser } = require('./config-parser')
|
||||||
const { getTempFolder, compareFiles } = require('./test-helpers')
|
const { getTempFolder, compareFiles } = require('./test-helpers')
|
||||||
|
|
||||||
@@ -32,6 +32,9 @@ describe('configParser', () => {
|
|||||||
// Get fixture files, excluding expected results
|
// Get fixture files, excluding expected results
|
||||||
const configurationFiles = fs.readdirSync(fixtureFolder).filter(filename => !filename.includes('.expected.'))
|
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
|
// Iterate over the fixtures, outputting to default configuration file path
|
||||||
const defaultFileExtension = '.js'
|
const defaultFileExtension = '.js'
|
||||||
configurationFiles
|
configurationFiles
|
||||||
@@ -48,7 +51,7 @@ describe('configParser', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get settings for the static site generator
|
// Get settings for the static site generator
|
||||||
const settings = getConfigParserSettings({ staticSiteGenerator, path: '/docs/' })
|
const settings = getConfigParserSettings({ staticSiteGenerator, siteUrl })
|
||||||
// Update the settings
|
// Update the settings
|
||||||
settings.configurationFile = fixtureTargetFile
|
settings.configurationFile = fixtureTargetFile
|
||||||
// Do the injection
|
// Do the injection
|
||||||
@@ -84,7 +87,7 @@ describe('configParser', () => {
|
|||||||
const settings = getConfigParserSettings({
|
const settings = getConfigParserSettings({
|
||||||
staticSiteGenerator,
|
staticSiteGenerator,
|
||||||
generatorConfigFile: fixtureTargetFile,
|
generatorConfigFile: fixtureTargetFile,
|
||||||
path: '/docs/'
|
siteUrl
|
||||||
})
|
})
|
||||||
|
|
||||||
// Do the injection
|
// Do the injection
|
||||||
Reference in New Issue
Block a user