Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade docsearch-react to v3 stable, bump dependencies #6752

Merged
merged 5 commits into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ jobs:
# https://yarnpkg.com/features/pnp#fallback-mode
yarn config set pnpFallbackMode none

# Patch package so that peer deps are provided. This has been fixed in terser by making acorn a direct dependency
# TODO watch out for the next terser release. Commit: https://github.com/terser/terser/commit/05b23eeb682d732484ad51b19bf528258fd5dc2a
yarn config set packageExtensions --json '{"terser-webpack-plugin@*": {"dependencies": {"acorn": "^8.6.0"}}, "html-minifier-terser@*": {"dependencies": {"acorn": "^8.6.0"}}}'

yarn install
working-directory: ../test-website
env:
Expand Down
2 changes: 1 addition & 1 deletion admin/new.docusaurus.io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"@netlify/functions": "^1.0.0"
},
"devDependencies": {
"netlify-cli": "^9.4.0"
"netlify-cli": "^9.8.0"
}
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,28 @@
"lock:update": "npx yarn-deduplicate"
},
"devDependencies": {
"@babel/cli": "^7.17.3",
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.5",
"@babel/preset-typescript": "^7.16.7",
"@crowdin/cli": "^3.7.8",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.4.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.178",
"@types/node": "^17.0.18",
"@types/node": "^17.0.21",
"@types/prompts": "^2.0.14",
"@types/react": "^17.0.39",
"@types/react-dev-utils": "^9.0.10",
"@types/react-test-renderer": "^17.0.1",
"@types/semver": "^7.3.9",
"@types/shelljs": "^0.8.11",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"concurrently": "^7.0.0",
"cross-env": "^7.0.3",
"cspell": "^5.18.5",
"eslint": "^8.9.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^8.4.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.1",
Expand All @@ -92,7 +92,7 @@
"lerna": "^4.0.0",
"lerna-changelog": "^2.2.0",
"lint-staged": "^12.3.4",
"netlify-cli": "^9.6.5",
"netlify-cli": "^9.8.0",
"nodemon": "^2.0.15",
"prettier": "^2.5.1",
"react": "^17.0.2",
Expand All @@ -101,7 +101,7 @@
"remark-parse": "^8.0.2",
"rimraf": "^3.0.2",
"sharp": "^0.30.1",
"stylelint": "^14.5.1",
"stylelint": "^14.5.3",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-standard": "^25.0.0",
"typescript": "^4.5.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@docusaurus/logger": "2.0.0-beta.15",
"commander": "^5.1.0",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"lodash": "^4.17.21",
"prompts": "^2.4.2",
"semver": "^7.3.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-docusaurus/templates/facebook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"@babel/eslint-parser": "^7.16.3",
"eslint": "^8.8.0",
"eslint-config-airbnb": "^19.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^8.4.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.0",
"eslint-plugin-react-hooks": "^4.3.0",
"prettier": "^2.5.1",
"stylelint": "^14.3.0"
"stylelint": "^14.5.3"
},
"browserslist": {
"production": [
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@mdx-js/mdx": "^1.6.22",
"escape-html": "^1.0.3",
"file-loader": "^6.2.0",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"image-size": "^1.0.1",
"mdast-util-to-string": "^2.0.0",
"remark-emoji": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@mapbox/hast-util-to-jsx": "^2.0.0",
"color": "^4.0.1",
"commander": "^5.1.0",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"hast-util-to-string": "^1.0.4",
"html-tags": "^3.1.0",
"import-fresh": "^3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-client-redirects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@docusaurus/utils-common": "2.0.0-beta.15",
"@docusaurus/utils-validation": "2.0.0-beta.15",
"eta": "^1.12.3",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"lodash": "^4.17.21",
"tslib": "^2.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@docusaurus/utils-validation": "2.0.0-beta.15",
"cheerio": "^1.0.0-rc.10",
"feed": "^4.2.2",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"lodash": "^4.17.21",
"reading-time": "^1.5.0",
"remark-admonitions": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@docusaurus/utils": "2.0.0-beta.15",
"@docusaurus/utils-validation": "2.0.0-beta.15",
"combine-promises": "^1.1.0",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"import-fresh": "^3.3.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@docusaurus/mdx-loader": "2.0.0-beta.15",
"@docusaurus/utils": "2.0.0-beta.15",
"@docusaurus/utils-validation": "2.0.0-beta.15",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"remark-admonitions": "^1.2.1",
"tslib": "^2.3.1",
"webpack": "^5.69.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@docusaurus/core": "2.0.0-beta.15",
"@docusaurus/utils": "2.0.0-beta.15",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"react-json-view": "^1.21.3",
"tslib": "^2.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.15",
"@docusaurus/types": "2.0.0-beta.15",
"fs-extra": "^10.0.0"
"fs-extra": "^10.0.1"
},
"peerDependencies": {
"jimp": "*",
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"tslib": "^2.3.1",
"webpack": "^5.69.1",
"webpack-merge": "^5.8.0",
"workbox-build": "^6.4.2",
"workbox-precaching": "^6.1.1",
"workbox-window": "^6.4.2"
"workbox-build": "^6.5.0",
"workbox-precaching": "^6.5.0",
"workbox-window": "^6.5.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.15",
"fs-extra": "^10.0.0"
"fs-extra": "^10.0.1"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-sitemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@docusaurus/utils": "2.0.0-beta.15",
"@docusaurus/utils-common": "2.0.0-beta.15",
"@docusaurus/utils-validation": "2.0.0-beta.15",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"sitemap": "^7.1.1",
"tslib": "^2.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@types/prismjs": "^1.26.0",
"@types/rtlcss": "^3.1.2",
"cross-env": "^7.0.3",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"react-test-renderer": "^17.0.2",
"utility-types": "^3.10.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@docusaurus/module-type-aliases": "2.0.0-beta.15",
"@docusaurus/types": "2.0.0-beta.15",
"@testing-library/react-hooks": "^7.0.2",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"lodash": "^4.17.21"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-live-codeblock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@docusaurus/utils-validation": "2.0.0-beta.15",
"@philpl/buble": "^0.19.7",
"clsx": "^1.1.1",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"react-live": "2.2.3",
"tslib": "^2.3.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-search-algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"build:format": "prettier --config ../../.prettierrc --write \"lib/**/*.js\""
},
"dependencies": {
"@docsearch/react": "^3.0.0-alpha.50",
"@docsearch/react": "^3.0.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shortcuts Is this safe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is safe, but introduces a breaking change in DocSearch.

We now require users to provide an appId, which is a follow up of migrating to our new infra. All of the users have received their new credentials but not all of them migrated yet.

I believe upgrading will encourage people to migrate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was asking on Discord as well, but thought it may be faster to ask here :P

This means it will break for a minority of our users, but they could and should have upgraded right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was asking on Discord as well, but thought it may be faster to ask here :P

Sorry, I'll paste my answer to give users visibility on this too

This means it will break for a minority of our users, but they could and should have upgraded right?

Yes indeed, we are no longer maintaining the legacy infrastructure and are definitely pushing to the new infra, so this upgrade will also help!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we already agreed on Discord to do this upgrade

Maybe it could be better to do it in a separate PR to make it clear there's a breaking change @Josh-Cena ?

We also need to update the validation to mark appId as required + link to the PR or blog post so that we can explain this better to users

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, going to do it in this PR. This is the only significant bump anyways, otherwise I won't even put this in the changelog (I'm recently excluding some maintenance PRs from the changelog)

"@docusaurus/core": "2.0.0-beta.15",
"@docusaurus/logger": "2.0.0-beta.15",
"@docusaurus/theme-common": "2.0.0-beta.15",
Expand All @@ -36,7 +36,7 @@
"algoliasearch-helper": "^3.7.0",
"clsx": "^1.1.1",
"eta": "^1.12.3",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"lodash": "^4.17.21",
"tslib": "^2.3.1",
"utility-types": "^3.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('validateThemeConfig', () => {
const algolia = {
indexName: 'index',
apiKey: 'apiKey',
appId: 'BH4D9OD16A',
};
expect(testValidateThemeConfig({algolia})).toEqual({
algolia: {
Expand All @@ -41,6 +42,7 @@ describe('validateThemeConfig', () => {
indexName: 'index',
apiKey: 'apiKey',
unknownKey: 'unknownKey',
appId: 'BH4D9OD16A',
};
expect(testValidateThemeConfig({algolia})).toEqual({
algolia: {
Expand All @@ -67,15 +69,8 @@ describe('validateThemeConfig', () => {
);
});

test('empty config', () => {
const algolia = {};
expect(() =>
testValidateThemeConfig({algolia}),
).toThrowErrorMatchingInlineSnapshot(`"\\"algolia.apiKey\\" is required"`);
});

test('missing indexName config', () => {
const algolia = {apiKey: 'apiKey'};
const algolia = {apiKey: 'apiKey', appId: 'BH4D9OD16A'};
expect(() =>
testValidateThemeConfig({algolia}),
).toThrowErrorMatchingInlineSnapshot(
Expand All @@ -84,14 +79,24 @@ describe('validateThemeConfig', () => {
});

test('missing apiKey config', () => {
const algolia = {indexName: 'indexName'};
const algolia = {indexName: 'indexName', appId: 'BH4D9OD16A'};
expect(() =>
testValidateThemeConfig({algolia}),
).toThrowErrorMatchingInlineSnapshot(`"\\"algolia.apiKey\\" is required"`);
});

test('missing appId config', () => {
const algolia = {indexName: 'indexName', apiKey: 'apiKey'};
expect(() =>
testValidateThemeConfig({algolia}),
).toThrowErrorMatchingInlineSnapshot(
`"\\"algolia.appId\\" is required. If you haven't migrated to the new DocSearch infra, please refer to the blog post for instructions: https://docusaurus.io/blog/2021/11/21/algolia-docsearch-migration"`,
);
});

test('contextualSearch config', () => {
const algolia = {
appId: 'BH4D9OD16A',
indexName: 'index',
apiKey: 'apiKey',
contextualSearch: true,
Expand All @@ -106,6 +111,7 @@ describe('validateThemeConfig', () => {

test('externalUrlRegex config', () => {
const algolia = {
appId: 'BH4D9OD16A',
indexName: 'index',
apiKey: 'apiKey',
externalUrlRegex: 'http://external-domain.com',
Expand All @@ -120,6 +126,7 @@ describe('validateThemeConfig', () => {

test('searchParameters.facetFilters search config', () => {
const algolia = {
appId: 'BH4D9OD16A',
indexName: 'index',
apiKey: 'apiKey',
searchParameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ export const DEFAULT_CONFIG = {
// see also https://github.com/facebook/docusaurus/issues/5880
contextualSearch: true,

// By default, all Docusaurus sites are using the same AppId
// This has been designed on purpose with Algolia.
appId: 'BH4D9OD16A',

searchParameters: {},
searchPagePath: 'search',
};
Expand All @@ -27,7 +23,10 @@ export const Schema = Joi.object({
contextualSearch: Joi.boolean().default(DEFAULT_CONFIG.contextualSearch),
externalUrlRegex: Joi.string().optional(),
// Algolia attributes
appId: Joi.string().default(DEFAULT_CONFIG.appId),
appId: Joi.string().required().messages({
'any.required':
'"algolia.appId" is required. If you haven\'t migrated to the new DocSearch infra, please refer to the blog post for instructions: https://docusaurus.io/blog/2021/11/21/algolia-docsearch-migration',
}),
apiKey: Joi.string().required(),
indexName: Joi.string().required(),
searchParameters: Joi.object()
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-translations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"update": "node ./update.js"
},
"dependencies": {
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"tslib": "^2.3.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@docusaurus/logger": "2.0.0-beta.15",
"@svgr/webpack": "^6.0.0",
"file-loader": "^6.2.0",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"github-slugger": "^1.4.0",
"globby": "^11.0.4",
"gray-matter": "^4.0.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"autoprefixer": "^10.4.2",
"babel-loader": "^8.2.3",
"babel-plugin-dynamic-import-node": "2.3.0",
"boxen": "^5.1.2",
"boxen": "^6.2.1",
"chokidar": "^3.5.3",
"clean-css": "^5.2.4",
"combine-promises": "^1.1.0",
Expand All @@ -68,7 +68,7 @@
"escape-html": "^1.0.3",
"eta": "^1.12.3",
"file-loader": "^6.2.0",
"fs-extra": "^10.0.0",
"fs-extra": "^10.0.1",
"html-minifier-terser": "^6.1.0",
"html-tags": "^3.1.0",
"html-webpack-plugin": "^5.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-copyright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"directory": "packages/stylelint-copyright"
},
"dependencies": {
"stylelint": "^14.5.0"
"stylelint": "^14.5.3"
}
}
3 changes: 2 additions & 1 deletion website/docusaurus.config-blog-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ module.exports = {
themeConfig: {
image: 'img/docusaurus-soc.png',
algolia: {
apiKey: '47ecd3b21be71c5822571b9f59e52544',
appId: 'X1Z85QJPUV',
apiKey: 'bf7211c161e8205da2f933a02534105a',
indexName: 'docusaurus-2',
contextualSearch: true,
},
Expand Down