mirror of
https://github.com/actions/configure-pages.git
synced 2026-03-30 18:14:51 +00:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a141972ca | ||
|
|
7d9bb68583 | ||
|
|
ec022f4ae9 | ||
|
|
f71d3d08f0 | ||
|
|
9ff7f29195 | ||
|
|
9b7553ef7f | ||
|
|
42451665cc | ||
|
|
adc528a6d8 | ||
|
|
789c331a21 | ||
|
|
ff1182a56a | ||
|
|
c872edcdfb | ||
|
|
c61e34fb27 | ||
|
|
a220556ffe | ||
|
|
491169de17 | ||
|
|
f19391002a | ||
|
|
742be05113 | ||
|
|
90b7c04b80 | ||
|
|
15f519fab9 | ||
|
|
f5b4063a62 | ||
|
|
d06799dbbe | ||
|
|
fad78054b6 | ||
|
|
64fa685553 | ||
|
|
891eba7f6e | ||
|
|
9f6ed02477 | ||
|
|
68595d0746 | ||
|
|
4f27d51853 | ||
|
|
1395534a78 | ||
|
|
7c3932ff89 | ||
|
|
404d23c4a6 | ||
|
|
06406d74b2 | ||
|
|
cc95980c79 | ||
|
|
4f84ed2a14 | ||
|
|
f19d25133d | ||
|
|
f24e879a69 | ||
|
|
da85ca493f | ||
|
|
d949e1515f | ||
|
|
c69bbc2c2c | ||
|
|
8441c1b1dc | ||
|
|
4036d0f035 | ||
|
|
5c1535b807 |
5
.github/workflows/check-dist.yml
vendored
5
.github/workflows/check-dist.yml
vendored
@@ -18,6 +18,11 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
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:
|
jobs:
|
||||||
check-dist:
|
check-dist:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
34
.github/workflows/check-formatting.yml
vendored
Normal file
34
.github/workflows/check-formatting.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
name: Checking formatting
|
||||||
|
|
||||||
|
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:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Node.JS
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.x
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Verify formatting
|
||||||
|
run: npm run format:check
|
||||||
3
.github/workflows/draft-release.yml
vendored
3
.github/workflows/draft-release.yml
vendored
@@ -4,6 +4,9 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
draft-release:
|
draft-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@@ -6,6 +6,14 @@ on:
|
|||||||
- main
|
- main
|
||||||
pull_request:
|
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:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# Prettier (formatter) configuration
|
# Prettier (formatter) configuration
|
||||||
---
|
---
|
||||||
printWidth: 80
|
printWidth: 120
|
||||||
tabWidth: 2
|
tabWidth: 2
|
||||||
useTabs: false
|
useTabs: false
|
||||||
semi: false
|
semi: false
|
||||||
singleQuote: true
|
singleQuote: true
|
||||||
trailingComma: none
|
trailingComma: none
|
||||||
bracketSpacing: false
|
bracketSpacing: true
|
||||||
arrowParens: avoid
|
arrowParens: avoid
|
||||||
21
README.md
21
README.md
@@ -1,8 +1,8 @@
|
|||||||
# Configure-Pages
|
# configure-pages
|
||||||
|
|
||||||
An 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-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.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
@@ -12,18 +12,13 @@ See [action.yml](action.yml) and the [Pages starter workflows][starter-workflows
|
|||||||
|
|
||||||
In order to release a new version of this Action:
|
In order to release a new version of this Action:
|
||||||
|
|
||||||
1. Locate the semantic version of the upcoming release (a draft is maintained by the [`draft-release` workflow][draft-release])
|
1. Locate the semantic version of the [upcoming release][release-list] (a draft is maintained by the [`draft-release` workflow][draft-release]).
|
||||||
|
|
||||||
2. Push a matching tag, for instance for `v0.1.0`:
|
2. Publish the draft release from the `main` branch with semantic version as the tag name, _with_ the checkbox to publish to the GitHub Marketplace checked. :ballot_box_with_check:
|
||||||
|
|
||||||
```bash
|
3. After publishing the release, the [`release` workflow][release] will automatically run to create/update the corresponding the major version tag such as `v0`.
|
||||||
git tag v0.1.0
|
|
||||||
git push origin v0.1.0
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Publish the draft release (the major tag such as `v0` will be created/updated by the [`release` workflow][release])
|
⚠️ Environment approval is required. Check the [Release workflow run list][release-workflow-runs].
|
||||||
|
|
||||||
⚠️ Environment approval is required.
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
@@ -31,5 +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
|
||||||
[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
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: 'Configure Pages'
|
name: 'Configure GitHub Pages'
|
||||||
description: 'A GitHub Action to enable Pages, extract various metadata about a site, and configure some supported static site generators.'
|
description: 'A GitHub Action to enable Pages, extract various metadata about a site, and configure some supported static site generators.'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
runs:
|
runs:
|
||||||
@@ -6,7 +6,10 @@ runs:
|
|||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
inputs:
|
inputs:
|
||||||
static_site_generator:
|
static_site_generator:
|
||||||
description: 'Optional static site generator to attempt to configure (nuxt, next or gatsby)'
|
description: 'Optional static site generator to attempt to configure: "nuxt", "next", "gatsby", or "sveltekit"'
|
||||||
|
required: false
|
||||||
|
generator_config_file:
|
||||||
|
description: 'Optional file path to static site generator configuration file'
|
||||||
required: false
|
required: false
|
||||||
token:
|
token:
|
||||||
description: 'GitHub token'
|
description: 'GitHub token'
|
||||||
|
|||||||
832
dist/index.js
vendored
832
dist/index.js
vendored
@@ -140,6 +140,7 @@ 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
|
||||||
@@ -169,7 +170,14 @@ 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 = '_GitHubActionsFileCommandDelimeter_';
|
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
||||||
|
// 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}`;
|
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||||
file_command_1.issueCommand('ENV', commandValue);
|
file_command_1.issueCommand('ENV', commandValue);
|
||||||
}
|
}
|
||||||
@@ -425,6 +433,13 @@ Object.defineProperty(exports, "summary", ({ enumerable: true, get: function ()
|
|||||||
*/
|
*/
|
||||||
var summary_2 = __nccwpck_require__(1327);
|
var summary_2 = __nccwpck_require__(1327);
|
||||||
Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
|
Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
|
||||||
|
/**
|
||||||
|
* Path exports
|
||||||
|
*/
|
||||||
|
var path_utils_1 = __nccwpck_require__(2981);
|
||||||
|
Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } }));
|
||||||
|
Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } }));
|
||||||
|
Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } }));
|
||||||
//# sourceMappingURL=core.js.map
|
//# sourceMappingURL=core.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -562,6 +577,71 @@ exports.OidcClient = OidcClient;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2981:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0;
|
||||||
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
|
/**
|
||||||
|
* toPosixPath converts the given path to the posix form. On Windows, \\ will be
|
||||||
|
* replaced with /.
|
||||||
|
*
|
||||||
|
* @param pth. Path to transform.
|
||||||
|
* @return string Posix path.
|
||||||
|
*/
|
||||||
|
function toPosixPath(pth) {
|
||||||
|
return pth.replace(/[\\]/g, '/');
|
||||||
|
}
|
||||||
|
exports.toPosixPath = toPosixPath;
|
||||||
|
/**
|
||||||
|
* toWin32Path converts the given path to the win32 form. On Linux, / will be
|
||||||
|
* replaced with \\.
|
||||||
|
*
|
||||||
|
* @param pth. Path to transform.
|
||||||
|
* @return string Win32 path.
|
||||||
|
*/
|
||||||
|
function toWin32Path(pth) {
|
||||||
|
return pth.replace(/[/]/g, '\\');
|
||||||
|
}
|
||||||
|
exports.toWin32Path = toWin32Path;
|
||||||
|
/**
|
||||||
|
* toPlatformPath converts the given path to a platform-specific path. It does
|
||||||
|
* this by replacing instances of / and \ with the platform-specific path
|
||||||
|
* separator.
|
||||||
|
*
|
||||||
|
* @param pth The path to platformize.
|
||||||
|
* @return string The platform-specific path.
|
||||||
|
*/
|
||||||
|
function toPlatformPath(pth) {
|
||||||
|
return pth.replace(/[/\\]/g, path.sep);
|
||||||
|
}
|
||||||
|
exports.toPlatformPath = toPlatformPath;
|
||||||
|
//# sourceMappingURL=path-utils.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 1327:
|
/***/ 1327:
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
@@ -12060,13 +12140,13 @@ module.exports = setup;
|
|||||||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||||||
module.exports = __nccwpck_require__(8222);
|
module.exports = __nccwpck_require__(8222);
|
||||||
} else {
|
} else {
|
||||||
module.exports = __nccwpck_require__(5332);
|
module.exports = __nccwpck_require__(4874);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 5332:
|
/***/ 4874:
|
||||||
/***/ ((module, exports, __nccwpck_require__) => {
|
/***/ ((module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14423,6 +14503,652 @@ if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
|||||||
exports.debug = debug; // for test
|
exports.debug = debug; // for test
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 5840:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "v1", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _v.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "v3", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _v2.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "v4", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _v3.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "v5", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _v4.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "NIL", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _nil.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "version", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _version.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "validate", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _validate.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "stringify", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _stringify.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
Object.defineProperty(exports, "parse", ({
|
||||||
|
enumerable: true,
|
||||||
|
get: function () {
|
||||||
|
return _parse.default;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
var _v = _interopRequireDefault(__nccwpck_require__(8628));
|
||||||
|
|
||||||
|
var _v2 = _interopRequireDefault(__nccwpck_require__(6409));
|
||||||
|
|
||||||
|
var _v3 = _interopRequireDefault(__nccwpck_require__(5122));
|
||||||
|
|
||||||
|
var _v4 = _interopRequireDefault(__nccwpck_require__(9120));
|
||||||
|
|
||||||
|
var _nil = _interopRequireDefault(__nccwpck_require__(5332));
|
||||||
|
|
||||||
|
var _version = _interopRequireDefault(__nccwpck_require__(1595));
|
||||||
|
|
||||||
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
||||||
|
|
||||||
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
||||||
|
|
||||||
|
var _parse = _interopRequireDefault(__nccwpck_require__(2746));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 4569:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _crypto = _interopRequireDefault(__nccwpck_require__(6113));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function md5(bytes) {
|
||||||
|
if (Array.isArray(bytes)) {
|
||||||
|
bytes = Buffer.from(bytes);
|
||||||
|
} else if (typeof bytes === 'string') {
|
||||||
|
bytes = Buffer.from(bytes, 'utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
return _crypto.default.createHash('md5').update(bytes).digest();
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = md5;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 5332:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
var _default = '00000000-0000-0000-0000-000000000000';
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 2746:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function parse(uuid) {
|
||||||
|
if (!(0, _validate.default)(uuid)) {
|
||||||
|
throw TypeError('Invalid UUID');
|
||||||
|
}
|
||||||
|
|
||||||
|
let v;
|
||||||
|
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
||||||
|
|
||||||
|
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
||||||
|
arr[1] = v >>> 16 & 0xff;
|
||||||
|
arr[2] = v >>> 8 & 0xff;
|
||||||
|
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
||||||
|
|
||||||
|
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
||||||
|
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
||||||
|
|
||||||
|
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
||||||
|
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
||||||
|
|
||||||
|
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
||||||
|
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
||||||
|
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
||||||
|
|
||||||
|
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
||||||
|
arr[11] = v / 0x100000000 & 0xff;
|
||||||
|
arr[12] = v >>> 24 & 0xff;
|
||||||
|
arr[13] = v >>> 16 & 0xff;
|
||||||
|
arr[14] = v >>> 8 & 0xff;
|
||||||
|
arr[15] = v & 0xff;
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = parse;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 814:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 807:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = rng;
|
||||||
|
|
||||||
|
var _crypto = _interopRequireDefault(__nccwpck_require__(6113));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
|
||||||
|
|
||||||
|
let poolPtr = rnds8Pool.length;
|
||||||
|
|
||||||
|
function rng() {
|
||||||
|
if (poolPtr > rnds8Pool.length - 16) {
|
||||||
|
_crypto.default.randomFillSync(rnds8Pool);
|
||||||
|
|
||||||
|
poolPtr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 5274:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _crypto = _interopRequireDefault(__nccwpck_require__(6113));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function sha1(bytes) {
|
||||||
|
if (Array.isArray(bytes)) {
|
||||||
|
bytes = Buffer.from(bytes);
|
||||||
|
} else if (typeof bytes === 'string') {
|
||||||
|
bytes = Buffer.from(bytes, 'utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
return _crypto.default.createHash('sha1').update(bytes).digest();
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = sha1;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 8950:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert array of 16 byte values to UUID string format of the form:
|
||||||
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
||||||
|
*/
|
||||||
|
const byteToHex = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < 256; ++i) {
|
||||||
|
byteToHex.push((i + 0x100).toString(16).substr(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
function stringify(arr, offset = 0) {
|
||||||
|
// Note: Be careful editing this code! It's been tuned for performance
|
||||||
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
||||||
|
const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
||||||
|
// of the following:
|
||||||
|
// - One or more input array values don't map to a hex octet (leading to
|
||||||
|
// "undefined" in the uuid)
|
||||||
|
// - Invalid input values for the RFC `version` or `variant` fields
|
||||||
|
|
||||||
|
if (!(0, _validate.default)(uuid)) {
|
||||||
|
throw TypeError('Stringified UUID is invalid');
|
||||||
|
}
|
||||||
|
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = stringify;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 8628:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _rng = _interopRequireDefault(__nccwpck_require__(807));
|
||||||
|
|
||||||
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
// **`v1()` - Generate time-based UUID**
|
||||||
|
//
|
||||||
|
// Inspired by https://github.com/LiosK/UUID.js
|
||||||
|
// and http://docs.python.org/library/uuid.html
|
||||||
|
let _nodeId;
|
||||||
|
|
||||||
|
let _clockseq; // Previous uuid creation time
|
||||||
|
|
||||||
|
|
||||||
|
let _lastMSecs = 0;
|
||||||
|
let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
|
||||||
|
|
||||||
|
function v1(options, buf, offset) {
|
||||||
|
let i = buf && offset || 0;
|
||||||
|
const b = buf || new Array(16);
|
||||||
|
options = options || {};
|
||||||
|
let node = options.node || _nodeId;
|
||||||
|
let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
|
||||||
|
// specified. We do this lazily to minimize issues related to insufficient
|
||||||
|
// system entropy. See #189
|
||||||
|
|
||||||
|
if (node == null || clockseq == null) {
|
||||||
|
const seedBytes = options.random || (options.rng || _rng.default)();
|
||||||
|
|
||||||
|
if (node == null) {
|
||||||
|
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
||||||
|
node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clockseq == null) {
|
||||||
|
// Per 4.2.2, randomize (14 bit) clockseq
|
||||||
|
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
|
||||||
|
}
|
||||||
|
} // UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
||||||
|
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
||||||
|
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
||||||
|
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
||||||
|
|
||||||
|
|
||||||
|
let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
|
||||||
|
// cycle to simulate higher resolution clock
|
||||||
|
|
||||||
|
let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
|
||||||
|
|
||||||
|
const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
|
||||||
|
|
||||||
|
if (dt < 0 && options.clockseq === undefined) {
|
||||||
|
clockseq = clockseq + 1 & 0x3fff;
|
||||||
|
} // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
||||||
|
// time interval
|
||||||
|
|
||||||
|
|
||||||
|
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
|
||||||
|
nsecs = 0;
|
||||||
|
} // Per 4.2.1.2 Throw error if too many uuids are requested
|
||||||
|
|
||||||
|
|
||||||
|
if (nsecs >= 10000) {
|
||||||
|
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastMSecs = msecs;
|
||||||
|
_lastNSecs = nsecs;
|
||||||
|
_clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
||||||
|
|
||||||
|
msecs += 12219292800000; // `time_low`
|
||||||
|
|
||||||
|
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
||||||
|
b[i++] = tl >>> 24 & 0xff;
|
||||||
|
b[i++] = tl >>> 16 & 0xff;
|
||||||
|
b[i++] = tl >>> 8 & 0xff;
|
||||||
|
b[i++] = tl & 0xff; // `time_mid`
|
||||||
|
|
||||||
|
const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
|
||||||
|
b[i++] = tmh >>> 8 & 0xff;
|
||||||
|
b[i++] = tmh & 0xff; // `time_high_and_version`
|
||||||
|
|
||||||
|
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
|
||||||
|
|
||||||
|
b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
||||||
|
|
||||||
|
b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
|
||||||
|
|
||||||
|
b[i++] = clockseq & 0xff; // `node`
|
||||||
|
|
||||||
|
for (let n = 0; n < 6; ++n) {
|
||||||
|
b[i + n] = node[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf || (0, _stringify.default)(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = v1;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6409:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _v = _interopRequireDefault(__nccwpck_require__(5998));
|
||||||
|
|
||||||
|
var _md = _interopRequireDefault(__nccwpck_require__(4569));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
const v3 = (0, _v.default)('v3', 0x30, _md.default);
|
||||||
|
var _default = v3;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 5998:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = _default;
|
||||||
|
exports.URL = exports.DNS = void 0;
|
||||||
|
|
||||||
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
||||||
|
|
||||||
|
var _parse = _interopRequireDefault(__nccwpck_require__(2746));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function stringToBytes(str) {
|
||||||
|
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
||||||
|
|
||||||
|
const bytes = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < str.length; ++i) {
|
||||||
|
bytes.push(str.charCodeAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
||||||
|
exports.DNS = DNS;
|
||||||
|
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
||||||
|
exports.URL = URL;
|
||||||
|
|
||||||
|
function _default(name, version, hashfunc) {
|
||||||
|
function generateUUID(value, namespace, buf, offset) {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
value = stringToBytes(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof namespace === 'string') {
|
||||||
|
namespace = (0, _parse.default)(namespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (namespace.length !== 16) {
|
||||||
|
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
||||||
|
} // Compute hash of namespace and value, Per 4.3
|
||||||
|
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
||||||
|
// hashfunc([...namespace, ... value])`
|
||||||
|
|
||||||
|
|
||||||
|
let bytes = new Uint8Array(16 + value.length);
|
||||||
|
bytes.set(namespace);
|
||||||
|
bytes.set(value, namespace.length);
|
||||||
|
bytes = hashfunc(bytes);
|
||||||
|
bytes[6] = bytes[6] & 0x0f | version;
|
||||||
|
bytes[8] = bytes[8] & 0x3f | 0x80;
|
||||||
|
|
||||||
|
if (buf) {
|
||||||
|
offset = offset || 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < 16; ++i) {
|
||||||
|
buf[offset + i] = bytes[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0, _stringify.default)(bytes);
|
||||||
|
} // Function#name is not settable on some platforms (#270)
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
generateUUID.name = name; // eslint-disable-next-line no-empty
|
||||||
|
} catch (err) {} // For CommonJS default export support
|
||||||
|
|
||||||
|
|
||||||
|
generateUUID.DNS = DNS;
|
||||||
|
generateUUID.URL = URL;
|
||||||
|
return generateUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 5122:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _rng = _interopRequireDefault(__nccwpck_require__(807));
|
||||||
|
|
||||||
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function v4(options, buf, offset) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
||||||
|
|
||||||
|
|
||||||
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
||||||
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
||||||
|
|
||||||
|
if (buf) {
|
||||||
|
offset = offset || 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < 16; ++i) {
|
||||||
|
buf[offset + i] = rnds[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0, _stringify.default)(rnds);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = v4;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9120:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _v = _interopRequireDefault(__nccwpck_require__(5998));
|
||||||
|
|
||||||
|
var _sha = _interopRequireDefault(__nccwpck_require__(5274));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
const v5 = (0, _v.default)('v5', 0x50, _sha.default);
|
||||||
|
var _default = v5;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6900:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _regex = _interopRequireDefault(__nccwpck_require__(814));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function validate(uuid) {
|
||||||
|
return typeof uuid === 'string' && _regex.default.test(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = validate;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 1595:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({
|
||||||
|
value: true
|
||||||
|
}));
|
||||||
|
exports["default"] = void 0;
|
||||||
|
|
||||||
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function version(uuid) {
|
||||||
|
if (!(0, _validate.default)(uuid)) {
|
||||||
|
throw TypeError('Invalid UUID');
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseInt(uuid.substr(14, 1), 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
var _default = version;
|
||||||
|
exports["default"] = _default;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9432:
|
/***/ 9432:
|
||||||
@@ -14584,16 +15310,32 @@ class ConfigParser {
|
|||||||
// Return the configuration object or null.
|
// Return the configuration object or null.
|
||||||
findConfigurationObject(ast) {
|
findConfigurationObject(ast) {
|
||||||
// Try to find a default export
|
// Try to find a default export
|
||||||
var defaultExport = ast.body.find(
|
var defaultExport = ast.body.find(node => node.type === 'ExportDefaultDeclaration')
|
||||||
node =>
|
|
||||||
node.type === 'ExportDefaultDeclaration' &&
|
// Direct default export
|
||||||
node.declaration.type === 'ObjectExpression'
|
if (defaultExport && defaultExport.declaration.type === 'ObjectExpression') {
|
||||||
)
|
core.info('Found configuration object in direct default export declaration')
|
||||||
if (defaultExport) {
|
|
||||||
core.info('Found configuration object in default export declaration')
|
|
||||||
return defaultExport.declaration
|
return defaultExport.declaration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Indirect default export
|
||||||
|
else if (defaultExport && defaultExport.declaration.type === 'Identifier') {
|
||||||
|
const identifierName = defaultExport.declaration.name
|
||||||
|
const identifierDefinition = ast.body.find(
|
||||||
|
node =>
|
||||||
|
node.type === 'VariableDeclaration' &&
|
||||||
|
node.declarations.length == 1 &&
|
||||||
|
node.declarations[0].type === 'VariableDeclarator' &&
|
||||||
|
node.declarations[0].id.type === 'Identifier' &&
|
||||||
|
node.declarations[0].id.name === identifierName &&
|
||||||
|
node.declarations[0].init.type === 'ObjectExpression'
|
||||||
|
)
|
||||||
|
if (identifierDefinition) {
|
||||||
|
core.info('Found configuration object in indirect default export declaration')
|
||||||
|
return identifierDefinition.declarations[0].init
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try to find a module export
|
// Try to find a module export
|
||||||
var moduleExport = ast.body.find(
|
var moduleExport = ast.body.find(
|
||||||
node =>
|
node =>
|
||||||
@@ -14608,19 +15350,13 @@ class ConfigParser {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Direct module export
|
// Direct module export
|
||||||
if (
|
if (moduleExport && moduleExport.expression.right.type === 'ObjectExpression') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'ObjectExpression'
|
|
||||||
) {
|
|
||||||
core.info('Found configuration object in direct module export')
|
core.info('Found configuration object in direct module export')
|
||||||
return moduleExport.expression.right
|
return moduleExport.expression.right
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indirect module export
|
// Indirect module export
|
||||||
else if (
|
else if (moduleExport && moduleExport.expression.right.type === 'Identifier') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'Identifier'
|
|
||||||
) {
|
|
||||||
const identifierName = moduleExport && moduleExport.expression.right.name
|
const identifierName = moduleExport && moduleExport.expression.right.name
|
||||||
const identifierDefinition = ast.body.find(
|
const identifierDefinition = ast.body.find(
|
||||||
node =>
|
node =>
|
||||||
@@ -14648,9 +15384,7 @@ class ConfigParser {
|
|||||||
// Try to find a property matching a given name
|
// Try to find a property matching a given name
|
||||||
const property =
|
const property =
|
||||||
object.type === 'ObjectExpression' &&
|
object.type === 'ObjectExpression' &&
|
||||||
object.properties.find(
|
object.properties.find(node => node.key.type === 'Identifier' && node.key.name === name)
|
||||||
node => node.key.type === 'Identifier' && node.key.name === name
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return the property's value (if found) or null
|
// Return the property's value (if found) or null
|
||||||
if (property) {
|
if (property) {
|
||||||
@@ -14670,9 +15404,7 @@ class ConfigParser {
|
|||||||
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
`${properties[startIndex]}: {` +
|
`${properties[startIndex]}: {` + this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) + '}'
|
||||||
this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) +
|
|
||||||
'}'
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14711,7 +15443,7 @@ class ConfigParser {
|
|||||||
var depth = 0
|
var depth = 0
|
||||||
const properties = propertyName.split('.')
|
const properties = propertyName.split('.')
|
||||||
var lastNode = configurationObject
|
var lastNode = configurationObject
|
||||||
while (1) {
|
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])
|
||||||
|
|
||||||
@@ -14750,11 +15482,7 @@ class ConfigParser {
|
|||||||
// Create nested properties in the configuration file
|
// Create nested properties in the configuration file
|
||||||
else {
|
else {
|
||||||
// Build the declaration to inject
|
// Build the declaration to inject
|
||||||
const declaration = this.getPropertyDeclaration(
|
const declaration = this.getPropertyDeclaration(properties, depth, propertyValue)
|
||||||
properties,
|
|
||||||
depth,
|
|
||||||
propertyValue
|
|
||||||
)
|
|
||||||
|
|
||||||
// The last node identified is an object expression, so do the assignment
|
// The last node identified is an object expression, so do the assignment
|
||||||
if (lastNode.type === 'ObjectExpression') {
|
if (lastNode.type === 'ObjectExpression') {
|
||||||
@@ -14817,6 +15545,7 @@ function getRequiredVars() {
|
|||||||
repositoryNwo: process.env.GITHUB_REPOSITORY,
|
repositoryNwo: process.env.GITHUB_REPOSITORY,
|
||||||
githubToken: core.getInput('token'),
|
githubToken: core.getInput('token'),
|
||||||
staticSiteGenerator: core.getInput('static_site_generator'),
|
staticSiteGenerator: core.getInput('static_site_generator'),
|
||||||
|
generatorConfigFile: core.getInput('generator_config_file'),
|
||||||
enablement: core.getInput('enablement') !== 'false'
|
enablement: core.getInput('enablement') !== 'false'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14861,13 +15590,13 @@ module.exports = outputPagesBaseUrl
|
|||||||
const core = __nccwpck_require__(2186)
|
const core = __nccwpck_require__(2186)
|
||||||
const { ConfigParser } = __nccwpck_require__(8395)
|
const { ConfigParser } = __nccwpck_require__(8395)
|
||||||
|
|
||||||
// Return the settings to be passed to a {ConfigParser} for a given
|
// Return the settings to be passed to a {ConfigParser} for a given static site generator,
|
||||||
// static site generator and a Pages path value to inject
|
// optional configuration file path, and a Pages path value to inject
|
||||||
function getConfigParserSettings(staticSiteGenerator, path) {
|
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path }) {
|
||||||
switch (staticSiteGenerator) {
|
switch (staticSiteGenerator) {
|
||||||
case 'nuxt':
|
case 'nuxt':
|
||||||
return {
|
return {
|
||||||
configurationFile: './nuxt.config.js',
|
configurationFile: generatorConfigFile || './nuxt.config.js',
|
||||||
blankConfigurationFile: __nccwpck_require__.ab + "nuxt.js",
|
blankConfigurationFile: __nccwpck_require__.ab + "nuxt.js",
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a base path on the router
|
// Configure a base path on the router
|
||||||
@@ -14885,7 +15614,7 @@ function getConfigParserSettings(staticSiteGenerator, path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configurationFile: './next.config.js',
|
configurationFile: generatorConfigFile || './next.config.js',
|
||||||
blankConfigurationFile: __nccwpck_require__.ab + "next.js",
|
blankConfigurationFile: __nccwpck_require__.ab + "next.js",
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a base path
|
// Configure a base path
|
||||||
@@ -14898,23 +15627,37 @@ function getConfigParserSettings(staticSiteGenerator, path) {
|
|||||||
}
|
}
|
||||||
case 'gatsby':
|
case 'gatsby':
|
||||||
return {
|
return {
|
||||||
configurationFile: './gatsby-config.js',
|
configurationFile: generatorConfigFile || './gatsby-config.js',
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 'sveltekit':
|
||||||
|
// SvelteKit does not want a trailing slash
|
||||||
|
if (path.endsWith('/')) {
|
||||||
|
path = path.slice(0, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
configurationFile: generatorConfigFile || './svelte.config.js',
|
||||||
|
blankConfigurationFile: __nccwpck_require__.ab + "sveltekit.js",
|
||||||
|
properties: {
|
||||||
|
// Configure a base path
|
||||||
|
'kit.paths.base': path
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw `Unsupported static site generator: ${staticSiteGenerator}`
|
throw `Unsupported static site generator: ${staticSiteGenerator}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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, path}) {
|
function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
|
||||||
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, path)
|
const settings = getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path })
|
||||||
new ConfigParser(settings).injectAll()
|
new ConfigParser(settings).injectAll()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Logging
|
// Logging
|
||||||
@@ -14938,6 +15681,14 @@ module.exports = require("assert");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6113:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
module.exports = require("crypto");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 2361:
|
/***/ 2361:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
@@ -16417,15 +17168,16 @@ const outputPagesBaseUrl = __nccwpck_require__(7527)
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const { repositoryNwo, githubToken, enablement, staticSiteGenerator } = getContext()
|
const { repositoryNwo, githubToken, enablement, staticSiteGenerator, generatorConfigFile } = getContext()
|
||||||
|
|
||||||
const pageObject = await findOrCreatePagesSite({ repositoryNwo, githubToken, enablement })
|
const pageObject = await findOrCreatePagesSite({ repositoryNwo, githubToken, enablement })
|
||||||
const siteUrl = new URL(pageObject.html_url)
|
const siteUrl = new URL(pageObject.html_url)
|
||||||
|
|
||||||
if (staticSiteGenerator) {
|
if (staticSiteGenerator) {
|
||||||
setPagesPath({ staticSiteGenerator, path: siteUrl.pathname })
|
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
|
||||||
}
|
}
|
||||||
outputPagesBaseUrl(siteUrl)
|
outputPagesBaseUrl(siteUrl)
|
||||||
|
core.exportVariable('GITHUB_PAGES', 'true')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error)
|
core.setFailed(error)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
13
dist/licenses.txt
vendored
13
dist/licenses.txt
vendored
@@ -608,3 +608,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
uuid
|
||||||
|
MIT
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|||||||
8
dist/sveltekit.js
vendored
Normal file
8
dist/sveltekit.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Default Pages configuration for SvelteKit
|
||||||
|
import adapter from '@sveltejs/adapter-auto'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
kit: {
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
}
|
||||||
33
package-lock.json
generated
33
package-lock.json
generated
@@ -9,7 +9,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.8.2",
|
"@actions/core": "^1.9.1",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"axios-retry": "^3.2.5",
|
"axios-retry": "^3.2.5",
|
||||||
"espree": "^9.3.2",
|
"espree": "^9.3.2",
|
||||||
@@ -22,11 +22,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.8.2",
|
"version": "1.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
||||||
"integrity": "sha512-FXcBL7nyik8K5ODeCKlxi+vts7torOkoDAKfeh61EAkAy1HAvwn9uVzZBY0f15YcQTcZZ2/iSGBFHEuioZWfDA==",
|
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^2.0.1"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client": {
|
"node_modules/@actions/http-client": {
|
||||||
@@ -3476,6 +3477,14 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/v8-to-istanbul": {
|
"node_modules/v8-to-istanbul": {
|
||||||
"version": "9.0.0",
|
"version": "9.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.0.tgz",
|
||||||
@@ -3595,11 +3604,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.8.2",
|
"version": "1.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.8.2.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
|
||||||
"integrity": "sha512-FXcBL7nyik8K5ODeCKlxi+vts7torOkoDAKfeh61EAkAy1HAvwn9uVzZBY0f15YcQTcZZ2/iSGBFHEuioZWfDA==",
|
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^2.0.1"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
@@ -6207,6 +6217,11 @@
|
|||||||
"integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
|
"integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||||
|
},
|
||||||
"v8-to-istanbul": {
|
"v8-to-istanbul": {
|
||||||
"version": "9.0.0",
|
"version": "9.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.0.tgz",
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
"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": {
|
||||||
"prepare": "ncc build src/index.js -o dist --source-map --license licenses.txt",
|
"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",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -19,7 +21,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/configure-pages#readme",
|
"homepage": "https://github.com/actions/configure-pages#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.8.2",
|
"@actions/core": "^1.9.1",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"axios-retry": "^3.2.5",
|
"axios-retry": "^3.2.5",
|
||||||
"espree": "^9.3.2",
|
"espree": "^9.3.2",
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ describe('apiClient', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('handles a 409 response when the page already exists', async () => {
|
it('handles a 409 response when the page already exists', async () => {
|
||||||
jest
|
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
||||||
.spyOn(axios, 'post')
|
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
|
||||||
|
|
||||||
// Simply assert that no error is raised
|
// Simply assert that no error is raised
|
||||||
const result = await apiClient.enablePagesSite({
|
const result = await apiClient.enablePagesSite({
|
||||||
@@ -67,9 +65,7 @@ describe('apiClient', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('re-raises errors on failure status codes', async () => {
|
it('re-raises errors on failure status codes', async () => {
|
||||||
jest
|
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
||||||
.spyOn(axios, 'post')
|
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
|
||||||
|
|
||||||
let erred = false
|
let erred = false
|
||||||
try {
|
try {
|
||||||
@@ -98,9 +94,7 @@ describe('apiClient', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('re-raises errors on failure status codes', async () => {
|
it('re-raises errors on failure status codes', async () => {
|
||||||
jest
|
jest.spyOn(axios, 'get').mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
||||||
.spyOn(axios, 'get')
|
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
|
||||||
|
|
||||||
let erred = false
|
let erred = false
|
||||||
try {
|
try {
|
||||||
@@ -203,7 +197,8 @@ describe('apiClient', () => {
|
|||||||
|
|
||||||
it('makes second request to get page if create fails because of existence', async () => {
|
it('makes second request to get page if create fails because of existence', async () => {
|
||||||
const PAGE_OBJECT = { html_url: 'https://actions.github.io/is-awesome/' }
|
const PAGE_OBJECT = { html_url: 'https://actions.github.io/is-awesome/' }
|
||||||
jest.spyOn(axios, 'get')
|
jest
|
||||||
|
.spyOn(axios, 'get')
|
||||||
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
.mockImplementationOnce(() => Promise.reject({ response: { status: 404 } }))
|
||||||
.mockImplementationOnce(() => Promise.resolve({ status: 200, data: PAGE_OBJECT }))
|
.mockImplementationOnce(() => Promise.resolve({ status: 200, data: PAGE_OBJECT }))
|
||||||
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
jest.spyOn(axios, 'post').mockImplementationOnce(() => Promise.reject({ response: { status: 409 } }))
|
||||||
@@ -217,5 +212,4 @@ describe('apiClient', () => {
|
|||||||
expect(axios.post).toHaveBeenCalledTimes(1)
|
expect(axios.post).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
8
src/blank-configurations/sveltekit.js
Normal file
8
src/blank-configurations/sveltekit.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Default Pages configuration for SvelteKit
|
||||||
|
import adapter from '@sveltejs/adapter-auto'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
kit: {
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,16 +56,32 @@ class ConfigParser {
|
|||||||
// Return the configuration object or null.
|
// Return the configuration object or null.
|
||||||
findConfigurationObject(ast) {
|
findConfigurationObject(ast) {
|
||||||
// Try to find a default export
|
// Try to find a default export
|
||||||
var defaultExport = ast.body.find(
|
var defaultExport = ast.body.find(node => node.type === 'ExportDefaultDeclaration')
|
||||||
node =>
|
|
||||||
node.type === 'ExportDefaultDeclaration' &&
|
// Direct default export
|
||||||
node.declaration.type === 'ObjectExpression'
|
if (defaultExport && defaultExport.declaration.type === 'ObjectExpression') {
|
||||||
)
|
core.info('Found configuration object in direct default export declaration')
|
||||||
if (defaultExport) {
|
|
||||||
core.info('Found configuration object in default export declaration')
|
|
||||||
return defaultExport.declaration
|
return defaultExport.declaration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Indirect default export
|
||||||
|
else if (defaultExport && defaultExport.declaration.type === 'Identifier') {
|
||||||
|
const identifierName = defaultExport.declaration.name
|
||||||
|
const identifierDefinition = ast.body.find(
|
||||||
|
node =>
|
||||||
|
node.type === 'VariableDeclaration' &&
|
||||||
|
node.declarations.length == 1 &&
|
||||||
|
node.declarations[0].type === 'VariableDeclarator' &&
|
||||||
|
node.declarations[0].id.type === 'Identifier' &&
|
||||||
|
node.declarations[0].id.name === identifierName &&
|
||||||
|
node.declarations[0].init.type === 'ObjectExpression'
|
||||||
|
)
|
||||||
|
if (identifierDefinition) {
|
||||||
|
core.info('Found configuration object in indirect default export declaration')
|
||||||
|
return identifierDefinition.declarations[0].init
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try to find a module export
|
// Try to find a module export
|
||||||
var moduleExport = ast.body.find(
|
var moduleExport = ast.body.find(
|
||||||
node =>
|
node =>
|
||||||
@@ -80,19 +96,13 @@ class ConfigParser {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Direct module export
|
// Direct module export
|
||||||
if (
|
if (moduleExport && moduleExport.expression.right.type === 'ObjectExpression') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'ObjectExpression'
|
|
||||||
) {
|
|
||||||
core.info('Found configuration object in direct module export')
|
core.info('Found configuration object in direct module export')
|
||||||
return moduleExport.expression.right
|
return moduleExport.expression.right
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indirect module export
|
// Indirect module export
|
||||||
else if (
|
else if (moduleExport && moduleExport.expression.right.type === 'Identifier') {
|
||||||
moduleExport &&
|
|
||||||
moduleExport.expression.right.type === 'Identifier'
|
|
||||||
) {
|
|
||||||
const identifierName = moduleExport && moduleExport.expression.right.name
|
const identifierName = moduleExport && moduleExport.expression.right.name
|
||||||
const identifierDefinition = ast.body.find(
|
const identifierDefinition = ast.body.find(
|
||||||
node =>
|
node =>
|
||||||
@@ -120,9 +130,7 @@ class ConfigParser {
|
|||||||
// Try to find a property matching a given name
|
// Try to find a property matching a given name
|
||||||
const property =
|
const property =
|
||||||
object.type === 'ObjectExpression' &&
|
object.type === 'ObjectExpression' &&
|
||||||
object.properties.find(
|
object.properties.find(node => node.key.type === 'Identifier' && node.key.name === name)
|
||||||
node => node.key.type === 'Identifier' && node.key.name === name
|
|
||||||
)
|
|
||||||
|
|
||||||
// Return the property's value (if found) or null
|
// Return the property's value (if found) or null
|
||||||
if (property) {
|
if (property) {
|
||||||
@@ -142,9 +150,7 @@ class ConfigParser {
|
|||||||
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
return `${properties[startIndex]}: ${JSON.stringify(propertyValue)}`
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
`${properties[startIndex]}: {` +
|
`${properties[startIndex]}: {` + this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) + '}'
|
||||||
this.getPropertyDeclaration(properties, startIndex + 1, propertyValue) +
|
|
||||||
'}'
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,7 +189,7 @@ class ConfigParser {
|
|||||||
var depth = 0
|
var depth = 0
|
||||||
const properties = propertyName.split('.')
|
const properties = propertyName.split('.')
|
||||||
var lastNode = configurationObject
|
var lastNode = configurationObject
|
||||||
while (1) {
|
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])
|
||||||
|
|
||||||
@@ -222,11 +228,7 @@ class ConfigParser {
|
|||||||
// Create nested properties in the configuration file
|
// Create nested properties in the configuration file
|
||||||
else {
|
else {
|
||||||
// Build the declaration to inject
|
// Build the declaration to inject
|
||||||
const declaration = this.getPropertyDeclaration(
|
const declaration = this.getPropertyDeclaration(properties, depth, propertyValue)
|
||||||
properties,
|
|
||||||
depth,
|
|
||||||
propertyValue
|
|
||||||
)
|
|
||||||
|
|
||||||
// The last node identified is an object expression, so do the assignment
|
// The last node identified is an object expression, so do the assignment
|
||||||
if (lastNode.type === 'ObjectExpression') {
|
if (lastNode.type === 'ObjectExpression') {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const core = require('@actions/core')
|
||||||
|
|
||||||
const { ConfigParser } = require('./config-parser')
|
const { ConfigParser } = require('./config-parser')
|
||||||
const { getTempFolder, compareFiles } = require('./test-helpers')
|
const { getTempFolder, compareFiles } = require('./test-helpers')
|
||||||
@@ -11,7 +12,6 @@ const cases = [
|
|||||||
//
|
//
|
||||||
// Default export
|
// Default export
|
||||||
//
|
//
|
||||||
|
|
||||||
{
|
{
|
||||||
property: 'property',
|
property: 'property',
|
||||||
source: `export default {}`,
|
source: `export default {}`,
|
||||||
@@ -89,6 +89,30 @@ const cases = [
|
|||||||
expected: `export default { a2: false, a1: { a2: "value", a3: [12]}}`
|
expected: `export default { a2: false, a1: { a2: "value", a3: [12]}}`
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// Indirect default export
|
||||||
|
//
|
||||||
|
{
|
||||||
|
property: 'property',
|
||||||
|
source: `const config = {}; export default config`,
|
||||||
|
expected: `const config = { property: "value"}; export default config`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
property: 'property',
|
||||||
|
source: `var config = {}; export default config`,
|
||||||
|
expected: `var config = { property: "value"}; export default config`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
property: 'a.b.c',
|
||||||
|
source: `var config = {}; export default config`,
|
||||||
|
expected: `var config = { a: { b: { c: "value"}}}; export default config`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
property: 'a.b.c',
|
||||||
|
source: `var config = { a: { b: [], c: "hello"}}; export default config`,
|
||||||
|
expected: `var config = { a: { b: { c: "value"}, c: "hello"}}; export default config`
|
||||||
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Direct module exports
|
// Direct module exports
|
||||||
//
|
//
|
||||||
@@ -134,8 +158,18 @@ const cases = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
describe('config-parser', () => {
|
describe('config-parser', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.restoreAllMocks()
|
||||||
|
|
||||||
|
// Mock error/warning/info/debug to silence their output
|
||||||
|
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
|
})
|
||||||
|
|
||||||
cases.forEach(({ property, source, expected }, index) => {
|
cases.forEach(({ property, source, expected }, index) => {
|
||||||
it(`Inject path properly for case #${index}`, () => {
|
it(`injects path properly for case #${index}`, () => {
|
||||||
// Write the source file
|
// Write the source file
|
||||||
const sourceFile = `${tempFolder}/source.js`
|
const sourceFile = `${tempFolder}/source.js`
|
||||||
fs.writeFileSync(sourceFile, source, { encoding: 'utf8' })
|
fs.writeFileSync(sourceFile, source, { encoding: 'utf8' })
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ function getRequiredVars() {
|
|||||||
repositoryNwo: process.env.GITHUB_REPOSITORY,
|
repositoryNwo: process.env.GITHUB_REPOSITORY,
|
||||||
githubToken: core.getInput('token'),
|
githubToken: core.getInput('token'),
|
||||||
staticSiteGenerator: core.getInput('static_site_generator'),
|
staticSiteGenerator: core.getInput('static_site_generator'),
|
||||||
|
generatorConfigFile: core.getInput('generator_config_file'),
|
||||||
enablement: core.getInput('enablement') !== 'false'
|
enablement: core.getInput('enablement') !== 'false'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// Default Pages configuration for Gatsby
|
// Default Pages configuration for Gatsby
|
||||||
module.exports = { pathPrefix: "/docs/" }
|
module.exports = { pathPrefix: '/docs/' }
|
||||||
|
|||||||
7
src/fixtures/gatsby/default.cjs
Normal file
7
src/fixtures/gatsby/default.cjs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
siteMetadata: {
|
||||||
|
title: `My Gatsby Site`,
|
||||||
|
siteUrl: `https://www.yourdomain.tld`,
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
8
src/fixtures/gatsby/default.expected.cjs
Normal file
8
src/fixtures/gatsby/default.expected.cjs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
pathPrefix: "/docs/",
|
||||||
|
siteMetadata: {
|
||||||
|
title: `My Gatsby Site`,
|
||||||
|
siteUrl: `https://www.yourdomain.tld`,
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
pathPrefix: "/docs/",
|
pathPrefix: '/docs/',
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
title: `My Gatsby Site`,
|
||||||
siteUrl: `https://www.yourdomain.tld`,
|
siteUrl: `https://www.yourdomain.tld`
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: []
|
||||||
}
|
}
|
||||||
8
src/fixtures/gatsby/default.expected.mjs
Normal file
8
src/fixtures/gatsby/default.expected.mjs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export default {
|
||||||
|
pathPrefix: "/docs/",
|
||||||
|
siteMetadata: {
|
||||||
|
title: `My Gatsby Site`,
|
||||||
|
siteUrl: `https://www.yourdomain.tld`,
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
siteMetadata: {
|
siteMetadata: {
|
||||||
title: `My Gatsby Site`,
|
title: `My Gatsby Site`,
|
||||||
siteUrl: `https://www.yourdomain.tld`,
|
siteUrl: `https://www.yourdomain.tld`
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: []
|
||||||
}
|
}
|
||||||
7
src/fixtures/gatsby/default.mjs
Normal file
7
src/fixtures/gatsby/default.mjs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
siteMetadata: {
|
||||||
|
title: `My Gatsby Site`,
|
||||||
|
siteUrl: `https://www.yourdomain.tld`,
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
// Default Pages configuration for Next
|
// Default Pages configuration for Next
|
||||||
const nextConfig = {
|
const nextConfig = { experimental: { images: { unoptimized: true } }, basePath: '/docs' }
|
||||||
experimental: {images: {unoptimized: true}},
|
|
||||||
basePath: '/docs'
|
|
||||||
}
|
|
||||||
module.exports = nextConfig
|
module.exports = nextConfig
|
||||||
|
|||||||
7
src/fixtures/next/default.cjs
Normal file
7
src/fixtures/next/default.cjs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
|
reactStrictMode: true,
|
||||||
|
swcMinify: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = nextConfig
|
||||||
9
src/fixtures/next/default.expected.cjs
Normal file
9
src/fixtures/next/default.expected.cjs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
|
experimental: {images: {unoptimized: true}},
|
||||||
|
basePath: '/docs',
|
||||||
|
reactStrictMode: true,
|
||||||
|
swcMinify: true
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = nextConfig
|
||||||
9
src/fixtures/next/default.expected.mjs
Normal file
9
src/fixtures/next/default.expected.mjs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
|
experimental: {images: {unoptimized: true}},
|
||||||
|
basePath: '/docs',
|
||||||
|
reactStrictMode: true,
|
||||||
|
swcMinify: true
|
||||||
|
}
|
||||||
|
|
||||||
|
export default nextConfig
|
||||||
@@ -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
|
||||||
7
src/fixtures/next/default.mjs
Normal file
7
src/fixtures/next/default.mjs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
|
reactStrictMode: true,
|
||||||
|
swcMinify: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default nextConfig
|
||||||
15
src/fixtures/nuxt/async.cjs
Normal file
15
src/fixtures/nuxt/async.cjs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
const getAllDynamicRoute = async function() {
|
||||||
|
const routes = await (async () => {
|
||||||
|
return ['/posts/hello-world', '/posts/hello-again'];
|
||||||
|
})();
|
||||||
|
return routes;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
mode: 'universal',
|
||||||
|
generate: {
|
||||||
|
async routes () {
|
||||||
|
return getAllDynamicRoute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
17
src/fixtures/nuxt/async.expected.cjs
Normal file
17
src/fixtures/nuxt/async.expected.cjs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const getAllDynamicRoute = async function() {
|
||||||
|
const routes = await (async () => {
|
||||||
|
return ['/posts/hello-world', '/posts/hello-again'];
|
||||||
|
})();
|
||||||
|
return routes;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
target: 'static',
|
||||||
|
router: {base: '/docs/'},
|
||||||
|
mode: 'universal',
|
||||||
|
generate: {
|
||||||
|
async routes () {
|
||||||
|
return getAllDynamicRoute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
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',
|
||||||
@@ -11,7 +11,7 @@ export default {
|
|||||||
mode: 'universal',
|
mode: 'universal',
|
||||||
generate: {
|
generate: {
|
||||||
async routes() {
|
async routes() {
|
||||||
return getAllDynamicRoute();
|
return getAllDynamicRoute()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|||||||
17
src/fixtures/nuxt/async.expected.mjs
Normal file
17
src/fixtures/nuxt/async.expected.mjs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
const getAllDynamicRoute = async function() {
|
||||||
|
const routes = await (async () => {
|
||||||
|
return ['/posts/hello-world', '/posts/hello-again'];
|
||||||
|
})();
|
||||||
|
return routes;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
target: 'static',
|
||||||
|
router: {base: '/docs/'},
|
||||||
|
mode: 'universal',
|
||||||
|
generate: {
|
||||||
|
async routes () {
|
||||||
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|||||||
15
src/fixtures/nuxt/async.mjs
Normal file
15
src/fixtures/nuxt/async.mjs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
const getAllDynamicRoute = async function() {
|
||||||
|
const routes = await (async () => {
|
||||||
|
return ['/posts/hello-world', '/posts/hello-again'];
|
||||||
|
})();
|
||||||
|
return routes;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mode: 'universal',
|
||||||
|
generate: {
|
||||||
|
async routes () {
|
||||||
|
return getAllDynamicRoute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
44
src/fixtures/nuxt/default.cjs
Normal file
44
src/fixtures/nuxt/default.cjs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
module.exports = {
|
||||||
|
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
||||||
|
ssr: false,
|
||||||
|
|
||||||
|
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||||
|
head: {
|
||||||
|
title: 'nuxt',
|
||||||
|
htmlAttrs: {
|
||||||
|
lang: 'en'
|
||||||
|
},
|
||||||
|
meta: [
|
||||||
|
{ charset: 'utf-8' },
|
||||||
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||||
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
|
],
|
||||||
|
link: [
|
||||||
|
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
|
css: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
|
plugins: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
|
components: true,
|
||||||
|
|
||||||
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
|
buildModules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
|
modules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||||
|
build: {
|
||||||
|
}
|
||||||
|
}
|
||||||
46
src/fixtures/nuxt/default.expected.cjs
Normal file
46
src/fixtures/nuxt/default.expected.cjs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
module.exports = {
|
||||||
|
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
||||||
|
target: 'static',
|
||||||
|
router: { base: "/docs/" },
|
||||||
|
ssr: false,
|
||||||
|
|
||||||
|
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||||
|
head: {
|
||||||
|
title: 'nuxt',
|
||||||
|
htmlAttrs: {
|
||||||
|
lang: 'en'
|
||||||
|
},
|
||||||
|
meta: [
|
||||||
|
{ charset: 'utf-8' },
|
||||||
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||||
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
|
],
|
||||||
|
link: [
|
||||||
|
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
|
css: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
|
plugins: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
|
components: true,
|
||||||
|
|
||||||
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
|
buildModules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
|
modules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Build Configuration: https://go.nuxtjs.dev/config-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: {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
46
src/fixtures/nuxt/default.expected.mjs
Normal file
46
src/fixtures/nuxt/default.expected.mjs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
export default {
|
||||||
|
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
||||||
|
target: 'static',
|
||||||
|
router: { base: "/docs/" },
|
||||||
|
ssr: false,
|
||||||
|
|
||||||
|
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||||
|
head: {
|
||||||
|
title: 'nuxt',
|
||||||
|
htmlAttrs: {
|
||||||
|
lang: 'en'
|
||||||
|
},
|
||||||
|
meta: [
|
||||||
|
{ charset: 'utf-8' },
|
||||||
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||||
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
|
],
|
||||||
|
link: [
|
||||||
|
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
|
css: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
|
plugins: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
|
components: true,
|
||||||
|
|
||||||
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
|
buildModules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
|
modules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Build Configuration: https://go.nuxtjs.dev/config-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: {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
44
src/fixtures/nuxt/default.mjs
Normal file
44
src/fixtures/nuxt/default.mjs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
export default {
|
||||||
|
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
|
||||||
|
ssr: false,
|
||||||
|
|
||||||
|
// Global page headers: https://go.nuxtjs.dev/config-head
|
||||||
|
head: {
|
||||||
|
title: 'nuxt',
|
||||||
|
htmlAttrs: {
|
||||||
|
lang: 'en'
|
||||||
|
},
|
||||||
|
meta: [
|
||||||
|
{ charset: 'utf-8' },
|
||||||
|
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||||
|
{ hid: 'description', name: 'description', content: '' },
|
||||||
|
{ name: 'format-detection', content: 'telephone=no' }
|
||||||
|
],
|
||||||
|
link: [
|
||||||
|
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
// Global CSS: https://go.nuxtjs.dev/config-css
|
||||||
|
css: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||||||
|
plugins: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Auto import components: https://go.nuxtjs.dev/config-components
|
||||||
|
components: true,
|
||||||
|
|
||||||
|
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||||||
|
buildModules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Modules: https://go.nuxtjs.dev/config-modules
|
||||||
|
modules: [
|
||||||
|
],
|
||||||
|
|
||||||
|
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||||||
|
build: {
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/fixtures/sveltekit/blank.expected.js
Normal file
9
src/fixtures/sveltekit/blank.expected.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// Default Pages configuration for SvelteKit
|
||||||
|
import adapter from '@sveltejs/adapter-auto'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
kit: {
|
||||||
|
paths: { base: '/docs' },
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/fixtures/sveltekit/blank.js
Normal file
1
src/fixtures/sveltekit/blank.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
// This file is not read by the test suite
|
||||||
11
src/fixtures/sveltekit/default.expected.js
Normal file
11
src/fixtures/sveltekit/default.expected.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import adapter from '@sveltejs/adapter-auto'
|
||||||
|
|
||||||
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
|
const config = {
|
||||||
|
kit: {
|
||||||
|
paths: { base: '/docs' },
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config
|
||||||
10
src/fixtures/sveltekit/default.js
Normal file
10
src/fixtures/sveltekit/default.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import adapter from '@sveltejs/adapter-auto'
|
||||||
|
|
||||||
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
|
const config = {
|
||||||
|
kit: {
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default config
|
||||||
@@ -9,15 +9,16 @@ const outputPagesBaseUrl = require('./output-pages-base-url')
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const { repositoryNwo, githubToken, enablement, staticSiteGenerator } = getContext()
|
const { repositoryNwo, githubToken, enablement, staticSiteGenerator, generatorConfigFile } = getContext()
|
||||||
|
|
||||||
const pageObject = await findOrCreatePagesSite({ repositoryNwo, githubToken, enablement })
|
const pageObject = await findOrCreatePagesSite({ repositoryNwo, githubToken, enablement })
|
||||||
const siteUrl = new URL(pageObject.html_url)
|
const siteUrl = new URL(pageObject.html_url)
|
||||||
|
|
||||||
if (staticSiteGenerator) {
|
if (staticSiteGenerator) {
|
||||||
setPagesPath({ staticSiteGenerator, path: siteUrl.pathname })
|
setPagesPath({ staticSiteGenerator, generatorConfigFile, path: siteUrl.pathname })
|
||||||
}
|
}
|
||||||
outputPagesBaseUrl(siteUrl)
|
outputPagesBaseUrl(siteUrl)
|
||||||
|
core.exportVariable('GITHUB_PAGES', 'true')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error)
|
core.setFailed(error)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
||||||
expect(core.setOutput).toHaveBeenCalledWith(
|
expect(core.setOutput).toHaveBeenCalledWith('origin', 'https://octocat.github.io')
|
||||||
'origin',
|
|
||||||
'https://octocat.github.io'
|
|
||||||
)
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
||||||
})
|
})
|
||||||
@@ -38,10 +35,7 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
||||||
expect(core.setOutput).toHaveBeenCalledWith(
|
expect(core.setOutput).toHaveBeenCalledWith('origin', 'https://octocat.github.io')
|
||||||
'origin',
|
|
||||||
'https://octocat.github.io'
|
|
||||||
)
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
expect(core.setOutput).toHaveBeenCalledWith('host', 'octocat.github.io')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/my-repo/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/my-repo/')
|
||||||
})
|
})
|
||||||
@@ -52,10 +46,7 @@ describe('outputPagesBaseUrl', () => {
|
|||||||
outputPagesBaseUrl(new URL(baseUrl))
|
outputPagesBaseUrl(new URL(baseUrl))
|
||||||
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
expect(core.setOutput).toHaveBeenCalledWith('base_url', baseUrl)
|
||||||
expect(core.setOutput).toHaveBeenCalledWith(
|
expect(core.setOutput).toHaveBeenCalledWith('origin', 'https://www.example.com')
|
||||||
'origin',
|
|
||||||
'https://www.example.com'
|
|
||||||
)
|
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('host', 'www.example.com')
|
expect(core.setOutput).toHaveBeenCalledWith('host', 'www.example.com')
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
expect(core.setOutput).toHaveBeenCalledWith('base_path', '/')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const { ConfigParser } = require('./config-parser')
|
const { ConfigParser } = require('./config-parser')
|
||||||
|
|
||||||
// Return the settings to be passed to a {ConfigParser} for a given
|
// Return the settings to be passed to a {ConfigParser} for a given static site generator,
|
||||||
// static site generator and a Pages path value to inject
|
// optional configuration file path, and a Pages path value to inject
|
||||||
function getConfigParserSettings(staticSiteGenerator, path) {
|
function getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path }) {
|
||||||
switch (staticSiteGenerator) {
|
switch (staticSiteGenerator) {
|
||||||
case 'nuxt':
|
case 'nuxt':
|
||||||
return {
|
return {
|
||||||
configurationFile: './nuxt.config.js',
|
configurationFile: generatorConfigFile || './nuxt.config.js',
|
||||||
blankConfigurationFile: `${__dirname}/blank-configurations/nuxt.js`,
|
blankConfigurationFile: `${__dirname}/blank-configurations/nuxt.js`,
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a base path on the router
|
// Configure a base path on the router
|
||||||
@@ -25,7 +25,7 @@ function getConfigParserSettings(staticSiteGenerator, path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
configurationFile: './next.config.js',
|
configurationFile: generatorConfigFile || './next.config.js',
|
||||||
blankConfigurationFile: `${__dirname}/blank-configurations/next.js`,
|
blankConfigurationFile: `${__dirname}/blank-configurations/next.js`,
|
||||||
properties: {
|
properties: {
|
||||||
// Configure a base path
|
// Configure a base path
|
||||||
@@ -38,23 +38,37 @@ function getConfigParserSettings(staticSiteGenerator, path) {
|
|||||||
}
|
}
|
||||||
case 'gatsby':
|
case 'gatsby':
|
||||||
return {
|
return {
|
||||||
configurationFile: './gatsby-config.js',
|
configurationFile: generatorConfigFile || './gatsby-config.js',
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 'sveltekit':
|
||||||
|
// SvelteKit does not want a trailing slash
|
||||||
|
if (path.endsWith('/')) {
|
||||||
|
path = path.slice(0, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
configurationFile: generatorConfigFile || './svelte.config.js',
|
||||||
|
blankConfigurationFile: `${__dirname}/blank-configurations/sveltekit.js`,
|
||||||
|
properties: {
|
||||||
|
// Configure a base path
|
||||||
|
'kit.paths.base': path
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw `Unsupported static site generator: ${staticSiteGenerator}`
|
throw `Unsupported static site generator: ${staticSiteGenerator}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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, path}) {
|
function setPagesPath({ staticSiteGenerator, generatorConfigFile, path }) {
|
||||||
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, path)
|
const settings = getConfigParserSettings({ staticSiteGenerator, generatorConfigFile, path })
|
||||||
new ConfigParser(settings).injectAll()
|
new ConfigParser(settings).injectAll()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Logging
|
// Logging
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const core = require('@actions/core')
|
||||||
|
|
||||||
const { getConfigParserSettings } = require('./set-pages-path')
|
const { getConfigParserSettings } = require('./set-pages-path')
|
||||||
const { ConfigParser } = require('./config-parser')
|
const { ConfigParser } = require('./config-parser')
|
||||||
@@ -8,42 +9,92 @@ const {getTempFolder, compareFiles} = require('./test-helpers')
|
|||||||
// Get the temp folder
|
// Get the temp folder
|
||||||
const tempFolder = getTempFolder()
|
const tempFolder = getTempFolder()
|
||||||
|
|
||||||
|
const SUPPORTED_GENERATORS = ['next', 'nuxt', 'gatsby', 'sveltekit']
|
||||||
|
const SUPPORTED_FILE_EXTENSIONS = ['.js', '.cjs', '.mjs']
|
||||||
|
|
||||||
// Test suite
|
// Test suite
|
||||||
describe('configParser', () => {
|
describe('configParser', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.restoreAllMocks()
|
||||||
|
|
||||||
|
// Mock error/warning/info/debug to silence their output
|
||||||
|
jest.spyOn(core, 'error').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'warning').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'info').mockImplementation(jest.fn())
|
||||||
|
jest.spyOn(core, 'debug').mockImplementation(jest.fn())
|
||||||
|
})
|
||||||
|
|
||||||
// Iterate over the static site generators
|
// Iterate over the static site generators
|
||||||
;['next', 'nuxt', 'gatsby'].forEach(staticSiteGenerator => {
|
SUPPORTED_GENERATORS.forEach(staticSiteGenerator => {
|
||||||
// Folder containing the fixtures for a given static site generator
|
// Folder containing the fixtures for a given static site generator
|
||||||
const fixtureFolder = `${__dirname}/fixtures/${staticSiteGenerator}`
|
const fixtureFolder = `${__dirname}/fixtures/${staticSiteGenerator}`
|
||||||
|
|
||||||
// Iterate over the fixtures
|
// Get fixture files, excluding expected results
|
||||||
fs.readdirSync(fixtureFolder).forEach(configurationFile => {
|
const configurationFiles = fs.readdirSync(fixtureFolder).filter(filename => !filename.includes('.expected.'))
|
||||||
// Ignore expectation
|
|
||||||
if (configurationFile.endsWith('.expected.js')) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
it(`Inject path properly for ${staticSiteGenerator} in ${configurationFile}`, async () => {
|
|
||||||
// Get settings for the static site generator
|
|
||||||
const settings = getConfigParserSettings(staticSiteGenerator, '/docs/')
|
|
||||||
|
|
||||||
|
// Iterate over the fixtures, outputting to default configuration file path
|
||||||
|
const defaultFileExtension = '.js'
|
||||||
|
configurationFiles
|
||||||
|
.filter(filename => filename.endsWith(defaultFileExtension))
|
||||||
|
.forEach(configurationFile => {
|
||||||
|
it(`injects path properly for ${staticSiteGenerator} in ${configurationFile} to default configuration file`, async () => {
|
||||||
// Copy the source fixture to a temp file
|
// Copy the source fixture to a temp file
|
||||||
const fixtureSourceFile = `${fixtureFolder}/${configurationFile}`
|
const fixtureSourceFile = `${fixtureFolder}/${configurationFile}`
|
||||||
const fixtureTargetFile = `${tempFolder}/${configurationFile}`
|
const fixtureTargetFile = `${tempFolder}/${configurationFile}`
|
||||||
if (configurationFile != 'blank.js') {
|
if (configurationFile !== 'blank.js') {
|
||||||
fs.copyFileSync(fixtureSourceFile, fixtureTargetFile)
|
fs.copyFileSync(fixtureSourceFile, fixtureTargetFile)
|
||||||
} else if (fs.existsSync(fixtureTargetFile)) {
|
} else if (fs.existsSync(fixtureTargetFile)) {
|
||||||
fs.rmSync(fixtureTargetFile)
|
fs.rmSync(fixtureTargetFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the settings and do the injection
|
// Get settings for the static site generator
|
||||||
|
const settings = getConfigParserSettings({ staticSiteGenerator, path: '/docs/' })
|
||||||
|
// Update the settings
|
||||||
settings.configurationFile = fixtureTargetFile
|
settings.configurationFile = fixtureTargetFile
|
||||||
|
// Do the injection
|
||||||
new ConfigParser(settings).injectAll()
|
new ConfigParser(settings).injectAll()
|
||||||
|
|
||||||
// Read the expected file
|
// Read the expected file
|
||||||
const expectedFile = `${fixtureFolder}/${path.basename(
|
const expectedFile = `${fixtureFolder}/${path.basename(
|
||||||
configurationFile,
|
configurationFile,
|
||||||
'.js'
|
defaultFileExtension
|
||||||
)}.expected.js`
|
)}.expected${defaultFileExtension}`
|
||||||
|
|
||||||
|
// Compare the actual and expected files
|
||||||
|
compareFiles(settings.configurationFile, expectedFile)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
SUPPORTED_FILE_EXTENSIONS.forEach(fileExtension => {
|
||||||
|
// Iterate over the fixtures, outputting to specified configuration file path
|
||||||
|
configurationFiles
|
||||||
|
.filter(filename => filename.endsWith(fileExtension))
|
||||||
|
.forEach(configurationFile => {
|
||||||
|
it(`injects path properly for ${staticSiteGenerator} in ${configurationFile} to specified *${fileExtension} configuration file`, async () => {
|
||||||
|
// Copy the source fixture to a temp file
|
||||||
|
const fixtureSourceFile = `${fixtureFolder}/${configurationFile}`
|
||||||
|
const fixtureTargetFile = `${tempFolder}/${configurationFile}`
|
||||||
|
if (configurationFile !== 'blank.js') {
|
||||||
|
fs.copyFileSync(fixtureSourceFile, fixtureTargetFile)
|
||||||
|
} else if (fs.existsSync(fixtureTargetFile)) {
|
||||||
|
fs.rmSync(fixtureTargetFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get settings for the static site generator
|
||||||
|
const settings = getConfigParserSettings({
|
||||||
|
staticSiteGenerator,
|
||||||
|
generatorConfigFile: fixtureTargetFile,
|
||||||
|
path: '/docs/'
|
||||||
|
})
|
||||||
|
|
||||||
|
// Do the injection
|
||||||
|
new ConfigParser(settings).injectAll()
|
||||||
|
|
||||||
|
// Read the expected file
|
||||||
|
const expectedFile = `${fixtureFolder}/${path.basename(
|
||||||
|
configurationFile,
|
||||||
|
fileExtension
|
||||||
|
)}.expected${fileExtension}`
|
||||||
|
|
||||||
// Compare the actual and expected files
|
// Compare the actual and expected files
|
||||||
compareFiles(settings.configurationFile, expectedFile)
|
compareFiles(settings.configurationFile, expectedFile)
|
||||||
@@ -51,3 +102,4 @@ describe('configParser', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|||||||
@@ -14,19 +14,21 @@ function getTempFolder() {
|
|||||||
// Read a JavaScript file and return it formatted
|
// Read a JavaScript file and return it formatted
|
||||||
function formatFile(file) {
|
function formatFile(file) {
|
||||||
const fileContent = fs.readFileSync(file, 'utf8')
|
const fileContent = fs.readFileSync(file, 'utf8')
|
||||||
return prettier.format(fileContent, {
|
return prettier
|
||||||
|
.format(fileContent, {
|
||||||
parser: 'espree',
|
parser: 'espree',
|
||||||
|
|
||||||
// Prettier options
|
// Prettier options
|
||||||
printWidth: 80,
|
printWidth: 120,
|
||||||
tabWidth: 2,
|
tabWidth: 2,
|
||||||
useTabs: false,
|
useTabs: false,
|
||||||
semi: false,
|
semi: false,
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
trailingComma: 'none',
|
trailingComma: 'none',
|
||||||
bracketSpacing: false,
|
bracketSpacing: true,
|
||||||
arrowParens: 'avoid'
|
arrowParens: 'avoid'
|
||||||
}).trim()
|
})
|
||||||
|
.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare two JavaScript files
|
// Compare two JavaScript files
|
||||||
|
|||||||
Reference in New Issue
Block a user