mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 05:27:00 +02:00
chore(v2): upgrade dependencies + require Node 12 (#4223)
* chore(v2): upgrade dependencies * Set minimum Node.js version to 12.13 * Fix test * Upgrade copy-text-to-clipboard * Bump Node versions * Update .nvmrc * mark cacheTime as forbidded field * Downgrade jest to v25.2.7 * Increase Node version for Windows CI * Test fix * Attempt to fix Windows CI * Downgrade execa * fix async test errors * Upgrade execa Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
02f7722f2e
commit
f13448d5e1
49 changed files with 2097 additions and 1840 deletions
|
@ -26,7 +26,7 @@ aliases:
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
working_directory: ~/docusaurus
|
working_directory: ~/docusaurus
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:10
|
- image: circleci/node:12
|
||||||
resource_class: large
|
resource_class: large
|
||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
|
|
2
.github/workflows/canary-releases.yml
vendored
2
.github/workflows/canary-releases.yml
vendored
|
@ -25,7 +25,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [10.x]
|
node-version: [12.x]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
|
2
.github/workflows/e2e-test.yml
vendored
2
.github/workflows/e2e-test.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node: ['10']
|
node: ['12']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js ${{ matrix.node }}
|
- name: Use Node.js ${{ matrix.node }}
|
||||||
|
|
2
.github/workflows/migration-cli-e2e-test.yml
vendored
2
.github/workflows/migration-cli-e2e-test.yml
vendored
|
@ -23,7 +23,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node: ['10']
|
node: ['12']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Use Node.js ${{ matrix.node }}
|
- name: Use Node.js ${{ matrix.node }}
|
||||||
|
|
2
.github/workflows/nodejs-windows.yml
vendored
2
.github/workflows/nodejs-windows.yml
vendored
|
@ -10,7 +10,7 @@ jobs:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node: ['10']
|
node: ['12']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: dorny/paths-filter@v2
|
- uses: dorny/paths-filter@v2
|
||||||
|
|
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
_
|
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
yarn lint-staged --allow-empty
|
2
.nvmrc
2
.nvmrc
|
@ -1 +1 @@
|
||||||
10.15.1
|
12.13.0
|
||||||
|
|
43
package.json
43
package.json
|
@ -36,7 +36,9 @@
|
||||||
"canary:bumpVersion": "yarn lerna version 2.0.0-alpha.`git rev-parse --short HEAD` --exact --no-push --yes",
|
"canary:bumpVersion": "yarn lerna version 2.0.0-alpha.`git rev-parse --short HEAD` --exact --no-push --yes",
|
||||||
"canary:publish": "yarn lerna publish from-package --dist-tag canary --yes --no-verify-access",
|
"canary:publish": "yarn lerna publish from-package --dist-tag canary --yes --no-verify-access",
|
||||||
"changelog": "lerna-changelog",
|
"changelog": "lerna-changelog",
|
||||||
"postinstall": "yarn lock:update && yarn build:packages",
|
"postinstall": "run-p postinstall:**",
|
||||||
|
"postinstall:main": "yarn lock:update && yarn build:packages",
|
||||||
|
"postinstall:dev": "is-ci || husky install",
|
||||||
"prettier": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx}\"",
|
"prettier": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx}\"",
|
||||||
"prettier:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx}\"",
|
"prettier:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx}\"",
|
||||||
"prettier-docs": "prettier --config .prettierrc --write \"**/*.md\"",
|
"prettier-docs": "prettier --config .prettierrc --write \"**/*.md\"",
|
||||||
|
@ -62,16 +64,16 @@
|
||||||
"lock:update": "npx yarn-deduplicate"
|
"lock:update": "npx yarn-deduplicate"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.12.1",
|
"@babel/cli": "^7.12.16",
|
||||||
"@babel/core": "^7.12.3",
|
"@babel/core": "^7.12.16",
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.13",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
|
"@babel/plugin-proposal-optional-chaining": "^7.12.16",
|
||||||
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
|
"@babel/plugin-transform-modules-commonjs": "^7.12.13",
|
||||||
"@babel/preset-typescript": "^7.12.1",
|
"@babel/preset-typescript": "^7.12.16",
|
||||||
"@crowdin/cli": "^3.5.2",
|
"@crowdin/cli": "^3.5.3",
|
||||||
"@types/express": "^4.17.2",
|
"@types/express": "^4.17.2",
|
||||||
"@types/fs-extra": "^9.0.6",
|
"@types/fs-extra": "^9.0.6",
|
||||||
"@types/jest": "^25.2.1",
|
"@types/jest": "^26.0.20",
|
||||||
"@types/loader-utils": "^1.1.3",
|
"@types/loader-utils": "^1.1.3",
|
||||||
"@types/lodash.camelcase": "^4.3.6",
|
"@types/lodash.camelcase": "^4.3.6",
|
||||||
"@types/lodash.flatmap": "^4.5.6",
|
"@types/lodash.flatmap": "^4.5.6",
|
||||||
|
@ -86,7 +88,7 @@
|
||||||
"@types/node": "^14.14.22",
|
"@types/node": "^14.14.22",
|
||||||
"@types/prismjs": "^1.16.2",
|
"@types/prismjs": "^1.16.2",
|
||||||
"@types/prompts": "^2.0.9",
|
"@types/prompts": "^2.0.9",
|
||||||
"@types/react": "^16.9.52",
|
"@types/react": "^17.0.2",
|
||||||
"@types/react-dev-utils": "^9.0.1",
|
"@types/react-dev-utils": "^9.0.1",
|
||||||
"@types/react-helmet": "^6.0.0",
|
"@types/react-helmet": "^6.0.0",
|
||||||
"@types/react-loadable": "^5.5.3",
|
"@types/react-loadable": "^5.5.3",
|
||||||
|
@ -102,7 +104,7 @@
|
||||||
"babel-eslint": "^10.0.3",
|
"babel-eslint": "^10.0.3",
|
||||||
"concurrently": "^5.3.0",
|
"concurrently": "^5.3.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^7.13.0",
|
"eslint": "^7.20.0",
|
||||||
"eslint-config-airbnb": "^18.2.1",
|
"eslint-config-airbnb": "^18.2.1",
|
||||||
"eslint-config-prettier": "^6.15.0",
|
"eslint-config-prettier": "^6.15.0",
|
||||||
"eslint-plugin-header": "^3.0.0",
|
"eslint-plugin-header": "^3.0.0",
|
||||||
|
@ -111,19 +113,21 @@
|
||||||
"eslint-plugin-react": "^7.21.5",
|
"eslint-plugin-react": "^7.21.5",
|
||||||
"eslint-plugin-react-hooks": "^4.2.0",
|
"eslint-plugin-react-hooks": "^4.2.0",
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"husky": "^4.2.3",
|
"husky": "^5.0.9",
|
||||||
"jest": "^25.2.7",
|
"is-ci": "^2.0.0",
|
||||||
|
"jest": "^26.6.3",
|
||||||
"lerna": "^3.22.1",
|
"lerna": "^3.22.1",
|
||||||
"lerna-changelog": "^1.0.1",
|
"lerna-changelog": "^1.0.1",
|
||||||
"lint-staged": "^10.1.2",
|
"lint-staged": "^10.5.4",
|
||||||
"netlify-cli": "^2.58.0",
|
"netlify-cli": "^2.58.0",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^2.0.7",
|
||||||
"prettier": "^2.0.2",
|
"npm-run-all": "^4.1.5",
|
||||||
|
"prettier": "^2.2.1",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"serve": "^11.3.2",
|
"serve": "^11.3.2",
|
||||||
"stylelint": "^13.2.1",
|
"stylelint": "^13.10.0",
|
||||||
"typescript": "^3.9.5"
|
"typescript": "^3.9.5"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
@ -135,12 +139,7 @@
|
||||||
"prettier --write"
|
"prettier --write"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "lint-staged"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ module.exports = {
|
||||||
'react/forbid-prop-types': OFF, // 1
|
'react/forbid-prop-types': OFF, // 1
|
||||||
'react/require-default-props': OFF, // 1
|
'react/require-default-props': OFF, // 1
|
||||||
'jsx-a11y/control-has-associated-label': OFF, // 1
|
'jsx-a11y/control-has-associated-label': OFF, // 1
|
||||||
|
'react/jsx-no-target-blank': OFF, // 1
|
||||||
'react/jsx-props-no-spreading': OFF, // 2
|
'react/jsx-props-no-spreading': OFF, // 2
|
||||||
'max-classes-per-file': OFF, // 2
|
'max-classes-per-file': OFF, // 2
|
||||||
'prefer-object-spread': OFF, // 5
|
'prefer-object-spread': OFF, // 5
|
||||||
|
|
|
@ -31,6 +31,6 @@
|
||||||
"shelljs": "^0.8.4"
|
"shelljs": "^0.8.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/parser": "^7.12.5",
|
"@babel/parser": "^7.12.16",
|
||||||
"@babel/traverse": "^7.12.5",
|
"@babel/traverse": "^7.12.13",
|
||||||
"@docusaurus/core": "2.0.0-alpha.70",
|
"@docusaurus/core": "2.0.0-alpha.70",
|
||||||
"@docusaurus/utils": "2.0.0-alpha.70",
|
"@docusaurus/utils": "2.0.0-alpha.70",
|
||||||
"@mdx-js/mdx": "^1.6.21",
|
"@mdx-js/mdx": "^1.6.21",
|
||||||
|
@ -41,13 +41,13 @@
|
||||||
"remark-mdx": "^1.6.21",
|
"remark-mdx": "^1.6.21",
|
||||||
"to-vfile": "^6.0.0",
|
"to-vfile": "^6.0.0",
|
||||||
"unist-builder": "^2.0.3",
|
"unist-builder": "^2.0.3",
|
||||||
"unist-util-remove-position": "^2.0.1"
|
"unist-util-remove-position": "^3.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.4 || ^17.0.0",
|
"react": "^16.8.4 || ^17.0.0",
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"docusaurus-migrate": "bin/index.js"
|
"docusaurus-migrate": "bin/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/preset-env": "^7.1.6",
|
"@babel/preset-env": "^7.12.16",
|
||||||
"@mapbox/hast-util-to-jsx": "^1.0.0",
|
"@mapbox/hast-util-to-jsx": "^1.0.0",
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"color": "^3.1.3",
|
"color": "^3.1.3",
|
||||||
|
|
|
@ -592,9 +592,9 @@ function migrateVersionedSidebar(
|
||||||
acc: {[key: string]: Array<Record<string, unknown> | string>},
|
acc: {[key: string]: Array<Record<string, unknown> | string>},
|
||||||
val,
|
val,
|
||||||
) => {
|
) => {
|
||||||
acc[val[0].replace(versionRegex, '')] = (val[1] as Array<
|
acc[
|
||||||
any
|
val[0].replace(versionRegex, '')
|
||||||
>).map((item) => {
|
] = (val[1] as Array<any>).map((item) => {
|
||||||
if (typeof item === 'string') {
|
if (typeof item === 'string') {
|
||||||
return item.replace(versionRegex, '');
|
return item.replace(versionRegex, '');
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
"eta": "^1.11.0",
|
"eta": "^1.11.0",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
"globby": "^11.0.2",
|
"globby": "^11.0.2",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"lodash": "^4.17.20"
|
"lodash": "^4.17.20"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"feed": "^4.2.2",
|
"feed": "^4.2.2",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"globby": "^11.0.2",
|
"globby": "^11.0.2",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"loader-utils": "^1.2.3",
|
"loader-utils": "^1.2.3",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"reading-time": "^1.3.0",
|
"reading-time": "^1.3.0",
|
||||||
|
@ -39,6 +39,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,11 @@
|
||||||
"@docusaurus/utils": "2.0.0-alpha.70",
|
"@docusaurus/utils": "2.0.0-alpha.70",
|
||||||
"@docusaurus/utils-validation": "2.0.0-alpha.70",
|
"@docusaurus/utils-validation": "2.0.0-alpha.70",
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"execa": "^3.4.0",
|
"execa": "^5.0.0",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"globby": "^11.0.2",
|
"globby": "^11.0.2",
|
||||||
"import-fresh": "^3.2.2",
|
"import-fresh": "^3.2.2",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"loader-utils": "^1.2.3",
|
"loader-utils": "^1.2.3",
|
||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"lodash.flatmap": "^4.5.0",
|
"lodash.flatmap": "^4.5.0",
|
||||||
|
@ -52,6 +52,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,8 @@ describe('lastUpdate', () => {
|
||||||
);
|
);
|
||||||
expect(await getFileLastUpdate(nonExistingFilePath)).toBeNull();
|
expect(await getFileLastUpdate(nonExistingFilePath)).toBeNull();
|
||||||
expect(consoleMock).toHaveBeenCalledTimes(1);
|
expect(consoleMock).toHaveBeenCalledTimes(1);
|
||||||
expect(consoleMock).toHaveBeenCalledWith(
|
expect(consoleMock.mock.calls[0][0].message).toContain(
|
||||||
new Error(
|
`Command failed with exit code 128: git log -1 --format=%ct, %an ${nonExistingFilePath}`,
|
||||||
`Command failed with exit code 128: git log -1 --format=%ct, %an ${nonExistingFilePath}`,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
expect(await getFileLastUpdate(null)).toBeNull();
|
expect(await getFileLastUpdate(null)).toBeNull();
|
||||||
expect(await getFileLastUpdate(undefined)).toBeNull();
|
expect(await getFileLastUpdate(undefined)).toBeNull();
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
"@docusaurus/utils": "2.0.0-alpha.70",
|
"@docusaurus/utils": "2.0.0-alpha.70",
|
||||||
"@docusaurus/utils-validation": "2.0.0-alpha.70",
|
"@docusaurus/utils-validation": "2.0.0-alpha.70",
|
||||||
"globby": "^11.0.2",
|
"globby": "^11.0.2",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"loader-utils": "^1.2.3",
|
"loader-utils": "^1.2.3",
|
||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
|
@ -37,6 +37,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
"@docusaurus/core": "2.0.0-alpha.70",
|
"@docusaurus/core": "2.0.0-alpha.70",
|
||||||
"@docusaurus/types": "2.0.0-alpha.70",
|
"@docusaurus/types": "2.0.0-alpha.70",
|
||||||
"@docusaurus/utils": "2.0.0-alpha.70",
|
"@docusaurus/utils": "2.0.0-alpha.70",
|
||||||
"react-json-view": "^1.20.4"
|
"react-json-view": "^1.21.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.4 || ^17.0.0",
|
"react": "^16.8.4 || ^17.0.0",
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,20 +13,20 @@
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.13",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
|
"@babel/plugin-proposal-optional-chaining": "^7.12.16",
|
||||||
"@babel/preset-env": "^7.12.1",
|
"@babel/preset-env": "^7.12.16",
|
||||||
"@docusaurus/core": "2.0.0-alpha.70",
|
"@docusaurus/core": "2.0.0-alpha.70",
|
||||||
"babel-loader": "^8.2.1",
|
"babel-loader": "^8.2.2",
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
"core-js": "^2.6.5",
|
"core-js": "^2.6.5",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"terser-webpack-plugin": "^4.1.0",
|
"terser-webpack-plugin": "^4.1.0",
|
||||||
"webpack": "^4.44.1",
|
"webpack": "^4.44.1",
|
||||||
"webpack-merge": "^4.2.2",
|
"webpack-merge": "^4.2.2",
|
||||||
"workbox-build": "^6.0.2",
|
"workbox-build": "^6.1.0",
|
||||||
"workbox-precaching": "^6.0.2",
|
"workbox-precaching": "^6.1.0",
|
||||||
"workbox-window": "^6.0.2"
|
"workbox-window": "^6.1.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.4 || ^17.0.0",
|
"react": "^16.8.4 || ^17.0.0",
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
"@docusaurus/types": "2.0.0-alpha.70",
|
"@docusaurus/types": "2.0.0-alpha.70",
|
||||||
"@docusaurus/utils": "2.0.0-alpha.70",
|
"@docusaurus/utils": "2.0.0-alpha.70",
|
||||||
"fs-extra": "^9.1.0",
|
"fs-extra": "^9.1.0",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"sitemap": "^3.2.2"
|
"sitemap": "^6.3.6"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.4 || ^17.0.0",
|
"react": "^16.8.4 || ^17.0.0",
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,67 +9,58 @@ import createSitemap from '../createSitemap';
|
||||||
import {DocusaurusConfig} from '@docusaurus/types';
|
import {DocusaurusConfig} from '@docusaurus/types';
|
||||||
|
|
||||||
describe('createSitemap', () => {
|
describe('createSitemap', () => {
|
||||||
test('simple site', () => {
|
test('simple site', async () => {
|
||||||
const sitemap = createSitemap(
|
const sitemap = await createSitemap(
|
||||||
{
|
{
|
||||||
url: 'https://example.com',
|
url: 'https://example.com',
|
||||||
} as DocusaurusConfig,
|
} as DocusaurusConfig,
|
||||||
['/', '/test'],
|
['/', '/test'],
|
||||||
{
|
{
|
||||||
cacheTime: 600,
|
|
||||||
changefreq: 'daily',
|
changefreq: 'daily',
|
||||||
priority: 0.7,
|
priority: 0.7,
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(sitemap.toString()).toContain(
|
expect(sitemap).toContain(
|
||||||
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
|
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('empty site', () => {
|
test('empty site', () => {
|
||||||
expect(() => {
|
return expect(async () => {
|
||||||
createSitemap({} as DocusaurusConfig, [], {});
|
await createSitemap({} as DocusaurusConfig, [], {});
|
||||||
}).toThrowErrorMatchingInlineSnapshot(
|
}).rejects.toThrow('url in docusaurus.config.js cannot be empty/undefined');
|
||||||
`"url in docusaurus.config.js cannot be empty/undefined"`,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('exclusion of 404 page', () => {
|
test('exclusion of 404 page', async () => {
|
||||||
const sitemap = createSitemap(
|
const sitemap = await createSitemap(
|
||||||
{
|
{
|
||||||
url: 'https://example.com',
|
url: 'https://example.com',
|
||||||
} as DocusaurusConfig,
|
} as DocusaurusConfig,
|
||||||
['/', '/404.html', '/mypage'],
|
['/', '/404.html', '/mypage'],
|
||||||
{
|
{
|
||||||
cacheTime: 600,
|
|
||||||
changefreq: 'daily',
|
changefreq: 'daily',
|
||||||
priority: 0.7,
|
priority: 0.7,
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(sitemap.toString()).not.toContain('404');
|
expect(sitemap).not.toContain('404');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('add trailing slash', () => {
|
test('add trailing slash', async () => {
|
||||||
const sitemap = createSitemap(
|
const sitemap = await createSitemap(
|
||||||
{
|
{
|
||||||
url: 'https://example.com',
|
url: 'https://example.com',
|
||||||
} as DocusaurusConfig,
|
} as DocusaurusConfig,
|
||||||
['/', '/test'],
|
['/', '/test'],
|
||||||
{
|
{
|
||||||
cacheTime: 600,
|
|
||||||
changefreq: 'daily',
|
changefreq: 'daily',
|
||||||
priority: 0.7,
|
priority: 0.7,
|
||||||
trailingSlash: true,
|
trailingSlash: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(sitemap.toString()).toContain(
|
expect(sitemap).toContain('<loc>https://example.com/test/</loc>');
|
||||||
'<loc>https://example.com/test/</loc>',
|
expect(sitemap).not.toContain('<loc>https://example.com/test</loc>');
|
||||||
);
|
|
||||||
expect(sitemap.toString()).not.toContain(
|
|
||||||
'<loc>https://example.com/test</loc>',
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,7 +26,6 @@ describe('normalizeSitemapPluginOptions', () => {
|
||||||
|
|
||||||
test('should accept correctly defined user options', async () => {
|
test('should accept correctly defined user options', async () => {
|
||||||
const userOptions = {
|
const userOptions = {
|
||||||
cacheTime: 300,
|
|
||||||
changefreq: 'yearly',
|
changefreq: 'yearly',
|
||||||
priority: 0.9,
|
priority: 0.9,
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
|
@ -35,14 +34,6 @@ describe('normalizeSitemapPluginOptions', () => {
|
||||||
expect(value).toEqual(userOptions);
|
expect(value).toEqual(userOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should reject cacheTime inputs with wrong type', () => {
|
|
||||||
expect(() => {
|
|
||||||
normalizePluginOptions({
|
|
||||||
cacheTime: '42',
|
|
||||||
});
|
|
||||||
}).toThrowErrorMatchingInlineSnapshot(`"\\"cacheTime\\" must be a number"`);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should reject out-of-range priority inputs', () => {
|
test('should reject out-of-range priority inputs', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
normalizePluginOptions({
|
normalizePluginOptions({
|
||||||
|
|
|
@ -5,35 +5,41 @@
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import sitemap, {Sitemap, SitemapItemOptions} from 'sitemap';
|
import {SitemapStream, streamToPromise} from 'sitemap';
|
||||||
import {PluginOptions} from './types';
|
import {PluginOptions} from './types';
|
||||||
import {DocusaurusConfig} from '@docusaurus/types';
|
import {DocusaurusConfig} from '@docusaurus/types';
|
||||||
import {addTrailingSlash} from '@docusaurus/utils';
|
import {addTrailingSlash} from '@docusaurus/utils';
|
||||||
|
|
||||||
export default function createSitemap(
|
export default async function createSitemap(
|
||||||
siteConfig: DocusaurusConfig,
|
siteConfig: DocusaurusConfig,
|
||||||
routesPaths: string[],
|
routesPaths: string[],
|
||||||
options: PluginOptions,
|
options: PluginOptions,
|
||||||
): Sitemap {
|
): Promise<string> {
|
||||||
const {url: hostname} = siteConfig;
|
const {url: hostname} = siteConfig;
|
||||||
if (!hostname) {
|
if (!hostname) {
|
||||||
throw new Error('url in docusaurus.config.js cannot be empty/undefined');
|
throw new Error('url in docusaurus.config.js cannot be empty/undefined');
|
||||||
}
|
}
|
||||||
const {cacheTime, changefreq, priority, trailingSlash} = options;
|
const {changefreq, priority, trailingSlash} = options;
|
||||||
|
|
||||||
const urls = routesPaths
|
const sitemapStream = new SitemapStream({
|
||||||
|
hostname,
|
||||||
|
});
|
||||||
|
|
||||||
|
routesPaths
|
||||||
.filter((route) => !route.endsWith('404.html'))
|
.filter((route) => !route.endsWith('404.html'))
|
||||||
.map(
|
.map((routePath) =>
|
||||||
(routePath): SitemapItemOptions => ({
|
sitemapStream.write({
|
||||||
url: trailingSlash ? addTrailingSlash(routePath) : routePath,
|
url: trailingSlash ? addTrailingSlash(routePath) : routePath,
|
||||||
changefreq,
|
changefreq,
|
||||||
priority,
|
priority,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return sitemap.createSitemap({
|
sitemapStream.end();
|
||||||
hostname,
|
|
||||||
cacheTime,
|
const generatedSitemap = await streamToPromise(sitemapStream).then((sm) =>
|
||||||
urls,
|
sm.toString(),
|
||||||
});
|
);
|
||||||
|
|
||||||
|
return generatedSitemap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ export default function pluginSitemap(
|
||||||
|
|
||||||
async postBuild({siteConfig, routesPaths, outDir}: Props) {
|
async postBuild({siteConfig, routesPaths, outDir}: Props) {
|
||||||
// Generate sitemap.
|
// Generate sitemap.
|
||||||
const generatedSitemap = createSitemap(
|
const generatedSitemap = await createSitemap(
|
||||||
siteConfig,
|
siteConfig,
|
||||||
routesPaths,
|
routesPaths,
|
||||||
options,
|
options,
|
||||||
).toString();
|
);
|
||||||
|
|
||||||
// Write sitemap file.
|
// Write sitemap file.
|
||||||
const sitemapPath = path.join(outDir, 'sitemap.xml');
|
const sitemapPath = path.join(outDir, 'sitemap.xml');
|
||||||
|
|
|
@ -4,19 +4,23 @@
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Joi from 'joi';
|
import * as Joi from 'joi';
|
||||||
import {EnumChangefreq} from 'sitemap';
|
import {EnumChangefreq} from 'sitemap';
|
||||||
import {PluginOptions} from './types';
|
import {PluginOptions} from './types';
|
||||||
|
|
||||||
export const DEFAULT_OPTIONS: Required<PluginOptions> = {
|
export const DEFAULT_OPTIONS: Required<PluginOptions> = {
|
||||||
cacheTime: 600 * 1000, // 600 sec - cache purge period.
|
|
||||||
changefreq: EnumChangefreq.WEEKLY,
|
changefreq: EnumChangefreq.WEEKLY,
|
||||||
priority: 0.5,
|
priority: 0.5,
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PluginOptionSchema = Joi.object({
|
export const PluginOptionSchema = Joi.object({
|
||||||
cacheTime: Joi.number().positive().default(DEFAULT_OPTIONS.cacheTime),
|
// TODO temporary (@alpha-71)
|
||||||
|
cacheTime: Joi.forbidden().messages({
|
||||||
|
'any.unknown':
|
||||||
|
'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
|
||||||
|
}),
|
||||||
changefreq: Joi.string()
|
changefreq: Joi.string()
|
||||||
.valid(...Object.values(EnumChangefreq))
|
.valid(...Object.values(EnumChangefreq))
|
||||||
.default(DEFAULT_OPTIONS.changefreq),
|
.default(DEFAULT_OPTIONS.changefreq),
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {EnumChangefreq} from 'sitemap';
|
import {EnumChangefreq} from 'sitemap';
|
||||||
|
|
||||||
export interface PluginOptions {
|
export interface PluginOptions {
|
||||||
cacheTime?: number;
|
|
||||||
changefreq?: EnumChangefreq;
|
changefreq?: EnumChangefreq;
|
||||||
priority?: number;
|
priority?: number;
|
||||||
trailingSlash?: boolean;
|
trailingSlash?: boolean;
|
||||||
|
|
|
@ -24,6 +24,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
"@mdx-js/react": "^1.6.21",
|
"@mdx-js/react": "^1.6.21",
|
||||||
"@types/react-toggle": "^4.0.2",
|
"@types/react-toggle": "^4.0.2",
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
"copy-text-to-clipboard": "^2.2.0",
|
"copy-text-to-clipboard": "^3.0.0",
|
||||||
"infima": "0.2.0-alpha.19",
|
"infima": "0.2.0-alpha.19",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"parse-numeric-range": "^1.2.0",
|
"parse-numeric-range": "^1.2.0",
|
||||||
"postcss": "^7.0.2",
|
"postcss": "^7.0.2",
|
||||||
|
@ -54,6 +54,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ function Tabs(props: Props): JSX.Element {
|
||||||
const {lazy, block, defaultValue, values, groupId, className} = props;
|
const {lazy, block, defaultValue, values, groupId, className} = props;
|
||||||
const {tabGroupChoices, setTabGroupChoices} = useUserPreferencesContext();
|
const {tabGroupChoices, setTabGroupChoices} = useUserPreferencesContext();
|
||||||
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
||||||
const children = Children.toArray(props.children) as ReactElement<
|
const children = Children.toArray(
|
||||||
TabItemProps
|
props.children,
|
||||||
>[];
|
) as ReactElement<TabItemProps>[];
|
||||||
const tabRefs: (HTMLLIElement | null)[] = [];
|
const tabRefs: (HTMLLIElement | null)[] = [];
|
||||||
|
|
||||||
if (groupId != null) {
|
if (groupId != null) {
|
||||||
|
|
|
@ -32,6 +32,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"algoliasearch-helper": "^3.3.4",
|
"algoliasearch-helper": "^3.3.4",
|
||||||
"clsx": "^1.1.1",
|
"clsx": "^1.1.1",
|
||||||
"eta": "^1.12.1",
|
"eta": "^1.12.1",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"lodash": "^4.17.19"
|
"lodash": "^4.17.19"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
@ -29,6 +29,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@docusaurus/utils": "2.0.0-alpha.70",
|
"@docusaurus/utils": "2.0.0-alpha.70",
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"joi": "^17.2.1"
|
"joi": "^17.4.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,6 @@
|
||||||
"resolve-pathname": "^3.0.0"
|
"resolve-pathname": "^3.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,18 @@
|
||||||
"tmp-promise": "^3.0.2"
|
"tmp-promise": "^3.0.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.12.10",
|
"@babel/core": "^7.12.16",
|
||||||
"@babel/generator": "^7.12.11",
|
"@babel/generator": "^7.12.15",
|
||||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.13",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
|
"@babel/plugin-proposal-optional-chaining": "^7.12.16",
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
||||||
"@babel/plugin-transform-runtime": "^7.12.10",
|
"@babel/plugin-transform-runtime": "^7.12.15",
|
||||||
"@babel/preset-env": "^7.12.11",
|
"@babel/preset-env": "^7.12.16",
|
||||||
"@babel/preset-react": "^7.12.10",
|
"@babel/preset-react": "^7.12.13",
|
||||||
"@babel/preset-typescript": "^7.12.7",
|
"@babel/preset-typescript": "^7.12.16",
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@babel/runtime-corejs3": "^7.12.5",
|
"@babel/runtime-corejs3": "^7.12.13",
|
||||||
"@babel/traverse": "^7.12.12",
|
"@babel/traverse": "^7.12.13",
|
||||||
"@docusaurus/cssnano-preset": "2.0.0-alpha.70",
|
"@docusaurus/cssnano-preset": "2.0.0-alpha.70",
|
||||||
"@docusaurus/react-loadable": "5.5.0",
|
"@docusaurus/react-loadable": "5.5.0",
|
||||||
"@docusaurus/types": "2.0.0-alpha.70",
|
"@docusaurus/types": "2.0.0-alpha.70",
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
"@docusaurus/utils-validation": "2.0.0-alpha.70",
|
"@docusaurus/utils-validation": "2.0.0-alpha.70",
|
||||||
"@endiliey/static-site-generator-webpack-plugin": "^4.0.0",
|
"@endiliey/static-site-generator-webpack-plugin": "^4.0.0",
|
||||||
"@svgr/webpack": "^5.5.0",
|
"@svgr/webpack": "^5.5.0",
|
||||||
"babel-loader": "^8.2.1",
|
"babel-loader": "^8.2.2",
|
||||||
"babel-plugin-dynamic-import-node": "2.3.0",
|
"babel-plugin-dynamic-import-node": "2.3.0",
|
||||||
"boxen": "^5.0.0",
|
"boxen": "^5.0.0",
|
||||||
"cache-loader": "^4.1.0",
|
"cache-loader": "^4.1.0",
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
"commander": "^4.0.1",
|
"commander": "^4.0.1",
|
||||||
"copy-webpack-plugin": "^6.4.1",
|
"copy-webpack-plugin": "^6.4.1",
|
||||||
"core-js": "^2.6.5",
|
"core-js": "^2.6.5",
|
||||||
"css-loader": "^5.0.1",
|
"css-loader": "^5.0.2",
|
||||||
"del": "^6.0.0",
|
"del": "^6.0.0",
|
||||||
"detect-port": "^1.3.0",
|
"detect-port": "^1.3.0",
|
||||||
"eta": "^1.12.1",
|
"eta": "^1.12.1",
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
"html-webpack-plugin": "^4.5.0",
|
"html-webpack-plugin": "^4.5.0",
|
||||||
"import-fresh": "^3.3.0",
|
"import-fresh": "^3.3.0",
|
||||||
"is-root": "^2.1.0",
|
"is-root": "^2.1.0",
|
||||||
"joi": "^17.2.1",
|
"joi": "^17.4.0",
|
||||||
"leven": "^3.1.0",
|
"leven": "^3.1.0",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
"lodash.flatmap": "^4.5.0",
|
"lodash.flatmap": "^4.5.0",
|
||||||
|
@ -122,6 +122,6 @@
|
||||||
"react-dom": "^16.8.4 || ^17.0.0"
|
"react-dom": "^16.8.4 || ^17.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,12 +210,12 @@ function extractSourceCodeAstTranslations(
|
||||||
path.node.openingElement.name.name === 'Translate'
|
path.node.openingElement.name.name === 'Translate'
|
||||||
) {
|
) {
|
||||||
// We only handle the optimistic case where we have a single non-empty content
|
// We only handle the optimistic case where we have a single non-empty content
|
||||||
const singleChildren: NodePath | undefined = path
|
const singleChildren = path
|
||||||
.get('children')
|
.get('children')
|
||||||
// Remove empty/useless text nodes that might be around our translation!
|
// Remove empty/useless text nodes that might be around our translation!
|
||||||
// Makes the translation system more reliable to JSX formatting issues
|
// Makes the translation system more reliable to JSX formatting issues
|
||||||
.filter(
|
.filter(
|
||||||
(childrenPath: NodePath) =>
|
(childrenPath) =>
|
||||||
!(
|
!(
|
||||||
t.isJSXText(childrenPath.node) &&
|
t.isJSXText(childrenPath.node) &&
|
||||||
childrenPath.node.value.replace('\n', '').trim() === ''
|
childrenPath.node.value.replace('\n', '').trim() === ''
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
"sharp": "^0.27.1"
|
"sharp": "^0.27.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.15.1"
|
"node": ">=12.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,22 +49,19 @@ describe('lqip-loader', () => {
|
||||||
const imgPath = path.join(__dirname, '__fixtures__', 'endi.jpg');
|
const imgPath = path.join(__dirname, '__fixtures__', 'endi.jpg');
|
||||||
const invalidPath = path.join(__dirname, '__fixtures__', 'docusaurus.svg');
|
const invalidPath = path.join(__dirname, '__fixtures__', 'docusaurus.svg');
|
||||||
|
|
||||||
it('should reject unknown or unsupported file format', () => {
|
it('should reject unknown or unsupported file format', async () => {
|
||||||
expect(lqip.base64(invalidPath)).rejects.toBeTruthy();
|
await expect(lqip.base64(invalidPath)).rejects.toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate a valid base64', () => {
|
it('should generate a valid base64', async () => {
|
||||||
const expectedBase64 = 'data:image/jpeg;base64,/9j/2wBDA';
|
const expectedBase64 = 'data:image/jpeg;base64,/9j/2wBDA';
|
||||||
lqip.base64(imgPath).then((base64: string) => {
|
await expect(lqip.base64(imgPath)).resolves.toContain(expectedBase64);
|
||||||
expect(base64).toContain(expectedBase64);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate a valid color palette', () => {
|
it('should generate a valid color palette', async () => {
|
||||||
lqip.palette(imgPath).then((imgPalette: string[]) => {
|
const imgPalette = await lqip.palette(imgPath);
|
||||||
expect(imgPalette).toHaveLength(6);
|
expect(imgPalette).toHaveLength(6);
|
||||||
expect(imgPalette).toContain('#578ca1');
|
expect(imgPalette).toContain('#578ca1');
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,7 +26,6 @@ module.exports = {
|
||||||
[
|
[
|
||||||
'@docusaurus/plugin-sitemap',
|
'@docusaurus/plugin-sitemap',
|
||||||
{
|
{
|
||||||
cacheTime: 600 * 1000, // 600 sec - cache purge period
|
|
||||||
changefreq: 'weekly',
|
changefreq: 'weekly',
|
||||||
priority: 0.5,
|
priority: 0.5,
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
|
|
|
@ -13,7 +13,7 @@ Use **[new.docusaurus.io](https://new.docusaurus.io)** to test Docusaurus immedi
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- [Node.js](https://nodejs.org/en/download/) version >= 10.15.1 or above (which can be checked by running `node -v`). You can use [nvm](https://github.com/nvm-sh/nvm) for managing multiple Node versions on a single machine installed
|
- [Node.js](https://nodejs.org/en/download/) version >= 12.13.0 or above (which can be checked by running `node -v`). You can use [nvm](https://github.com/nvm-sh/nvm) for managing multiple Node versions on a single machine installed
|
||||||
- [Yarn](https://yarnpkg.com/en/) version >= 1.5 (which can be checked by running `yarn --version`). Yarn is a performant package manager for JavaScript and replaces the `npm` client. It is not strictly necessary but highly encouraged.
|
- [Yarn](https://yarnpkg.com/en/) version >= 1.5 (which can be checked by running `yarn --version`). Yarn is a performant package manager for JavaScript and replaces the `npm` client. It is not strictly necessary but highly encouraged.
|
||||||
|
|
||||||
## Scaffold project website
|
## Scaffold project website
|
||||||
|
|
|
@ -69,7 +69,7 @@ module.exports = {
|
||||||
[
|
[
|
||||||
'@docusaurus/plugin-sitemap',
|
'@docusaurus/plugin-sitemap',
|
||||||
{
|
{
|
||||||
cacheTime: 600 * 1000,
|
changefreq: 'weekly',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue