From a0c01f7b46ba74e7e82cae3a353041b24604b3f3 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 22:21:10 +0800 Subject: [PATCH 01/10] misc: convert all internal scripts to ESM --- .eslintignore | 6 +- .eslintrc.js | 2 +- .../scripts/generateExamples.mjs | 135 +++++++++--------- admin/scripts/image-resize.mjs | 6 +- package.json | 2 +- packages/create-docusaurus/.npmignore | 2 +- packages/docusaurus-logger/.npmignore | 2 +- packages/docusaurus-mdx-loader/.npmignore | 2 +- packages/docusaurus-migrate/.npmignore | 2 +- .../.npmignore | 2 +- .../docusaurus-plugin-content-blog/.npmignore | 2 +- .../docusaurus-plugin-content-docs/.npmignore | 2 +- .../.npmignore | 2 +- packages/docusaurus-plugin-debug/.npmignore | 2 +- .../copyUntypedFiles.mjs} | 6 +- packages/docusaurus-plugin-debug/package.json | 4 +- .../.npmignore | 2 +- .../docusaurus-plugin-google-gtag/.npmignore | 2 +- .../docusaurus-plugin-ideal-image/.npmignore | 2 +- .../copyUntypedFiles.mjs} | 6 +- .../package.json | 2 +- packages/docusaurus-plugin-pwa/.npmignore | 2 +- .../copyUntypedFiles.mjs} | 6 +- packages/docusaurus-plugin-pwa/package.json | 2 +- packages/docusaurus-plugin-sitemap/.npmignore | 2 +- packages/docusaurus-preset-classic/.npmignore | 2 +- .../.npmignore | 2 +- packages/docusaurus-theme-classic/.npmignore | 2 +- packages/docusaurus-theme-common/.npmignore | 2 +- .../copyUntypedFiles.mjs} | 6 +- packages/docusaurus-theme-common/package.json | 4 +- .../.npmignore | 2 +- .../copyUntypedFiles.js | 20 --- .../copyUntypedFiles.mjs | 20 +++ .../package.json | 4 +- .../.npmignore | 2 +- .../copyUntypedFiles.js | 20 --- .../copyUntypedFiles.mjs | 20 +++ .../package.json | 2 +- .../docusaurus-theme-translations/.npmignore | 2 +- packages/docusaurus-utils-common/.npmignore | 2 +- .../docusaurus-utils-validation/.npmignore | 2 +- packages/docusaurus-utils/.npmignore | 2 +- packages/docusaurus/.npmignore | 2 +- packages/docusaurus/copyUntypedFiles.js | 20 --- packages/docusaurus/copyUntypedFiles.mjs | 20 +++ packages/docusaurus/package.json | 4 +- packages/lqip-loader/.npmignore | 2 +- website/{delayCrowdin.js => delayCrowdin.mjs} | 29 ++-- website/package.json | 6 +- website/{testCSSOrder.js => testCSSOrder.mjs} | 14 +- .../{waitForCrowdin.js => waitForCrowdin.mjs} | 52 +++---- 52 files changed, 219 insertions(+), 251 deletions(-) rename generateExamples.js => admin/scripts/generateExamples.mjs (68%) rename packages/{docusaurus-theme-common/copyUntypedFiles.js => docusaurus-plugin-debug/copyUntypedFiles.mjs} (82%) rename packages/{docusaurus-plugin-debug/copyUntypedFiles.js => docusaurus-plugin-ideal-image/copyUntypedFiles.mjs} (82%) rename packages/{docusaurus-plugin-ideal-image/copyUntypedFiles.js => docusaurus-plugin-pwa/copyUntypedFiles.mjs} (82%) rename packages/{docusaurus-plugin-pwa/copyUntypedFiles.js => docusaurus-theme-common/copyUntypedFiles.mjs} (82%) delete mode 100644 packages/docusaurus-theme-live-codeblock/copyUntypedFiles.js create mode 100644 packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs delete mode 100644 packages/docusaurus-theme-search-algolia/copyUntypedFiles.js create mode 100644 packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs delete mode 100644 packages/docusaurus/copyUntypedFiles.js create mode 100644 packages/docusaurus/copyUntypedFiles.mjs rename website/{delayCrowdin.js => delayCrowdin.mjs} (60%) rename website/{testCSSOrder.js => testCSSOrder.mjs} (90%) rename website/{waitForCrowdin.js => waitForCrowdin.mjs} (53%) diff --git a/.eslintignore b/.eslintignore index a3f68ec57826..df78c0c54950 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,9 +12,9 @@ packages/lqip-loader/lib/ packages/docusaurus/lib/ packages/docusaurus-*/lib/* packages/docusaurus-*/lib-next/ -packages/docusaurus-plugin-pwa/copyUntypedFiles.js -packages/docusaurus-plugin-ideal-image/copyUntypedFiles.js -packages/docusaurus-theme-search-algolia/copyUntypedFiles.js +packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs +packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs +packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs packages/create-docusaurus/lib/* packages/create-docusaurus/templates/facebook/.eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js index 6c548184c3c0..d811d6c9e1a4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -198,7 +198,7 @@ module.exports = { }, }, { - files: ['*.js'], + files: ['*.js', '*.mjs', '.cjs'], rules: { // Make JS code directly runnable in Node. '@typescript-eslint/no-var-requires': OFF, diff --git a/generateExamples.js b/admin/scripts/generateExamples.mjs similarity index 68% rename from generateExamples.js rename to admin/scripts/generateExamples.mjs index 698aecd2a571..c9c9c66adc5a 100644 --- a/generateExamples.js +++ b/admin/scripts/generateExamples.mjs @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -// eslint-disable-next-line import/no-extraneous-dependencies -const rimraf = require('rimraf'); -const {readFileSync, writeFileSync, readdirSync} = require('fs'); -const {execSync} = require('child_process'); +/* eslint-disable import/no-extraneous-dependencies */ + +import fs from 'fs-extra'; +import shell from 'shelljs'; const NODE_MAJOR_VERSION = parseInt(process.versions.node.split('.')[0], 10); if (NODE_MAJOR_VERSION < 16) { @@ -20,7 +20,7 @@ if (NODE_MAJOR_VERSION < 16) { // Generate one example per init template // We use those generated examples as CodeSandbox projects // See https://github.com/facebook/docusaurus/issues/1699 -function generateTemplateExample(template) { +async function generateTemplateExample(template) { try { console.log( `generating ${template} template for codesandbox in the examples folder...`, @@ -30,20 +30,17 @@ function generateTemplateExample(template) { const command = template.endsWith('-typescript') ? template.replace('-typescript', ' -- --typescript') : template; - execSync( + shell.exec( // /!\ we use the published init script on purpose, // because using the local init script is too early and could generate upcoming/unavailable config options // remember CodeSandbox templates will use the published version, not the repo version `npm init docusaurus@latest examples/${template} ${command}`, // `node ./packages/docusaurus-init/bin/index.js init examples/${template} ${template}`, - { - stdio: 'inherit', - }, ); // read the content of the package.json const templatePackageJson = JSON.parse( - readFileSync(`examples/${template}/package.json`, 'utf8'), + await fs.readFile(`examples/${template}/package.json`, 'utf8'), ); // attach the dev script which would be used in code sandbox by default @@ -64,7 +61,7 @@ function generateTemplateExample(template) { : `Docusaurus example project (${template} template)`; // rewrite the package.json file with the new edit - writeFileSync( + await fs.writeFile( `./examples/${template}/package.json`, `${JSON.stringify(templatePackageJson, null, 2)}\n`, ); @@ -80,7 +77,7 @@ function generateTemplateExample(template) { node: '14', }, }; - writeFileSync( + await fs.writeFile( `./examples/${template}/sandbox.config.json`, `${JSON.stringify(codeSanboxConfig, null, 2)}\n`, ); @@ -89,7 +86,7 @@ function generateTemplateExample(template) { installDependencies: true, startCommand: 'npm start', }; - writeFileSync( + await fs.writeFile( `./examples/${template}/.stackblitzrc`, `${JSON.stringify(stackBlitzConfig, null, 2)}\n`, ); @@ -115,7 +112,7 @@ function updateStarters() { const command = `git push ${remote} \`git subtree split --prefix ${subfolder}\`:${remoteBranch} --force`; try { console.log(`forcePushGitSubtree command: ${command}`); - execSync(command); + shell.exec(command); console.log('forcePushGitSubtree success!'); } catch (e) { console.error( @@ -150,60 +147,60 @@ function updateStarters() { console.log(''); } -function run() { - const branch = execSync('git rev-parse --abbrev-ref HEAD').toString(); - if (branch === 'main') { - throw new Error( - "Please don't generate Docusaurus examples from the main branch!\nWe are going to commit during this process!", - ); - } - try { - execSync('git diff --exit-code'); - } catch (e) { - throw new Error( - 'Please run the generate examples command with a clean Git state and no uncommited local changes. git diff should display nothing!', - ); - } - - console.log(''); - console.log('# Generate examples start!'); - console.log(''); - - // delete the examples directories if they exists - console.log('-------'); - console.log('## Removing example folders...'); - rimraf.sync('./examples/classic'); - rimraf.sync('./examples/classic-typescript'); - rimraf.sync('./examples/facebook'); - console.log(''); - - // get the list of all available templates - console.log('-------'); - console.log('## Generate example folders...'); - console.log(''); - const excludes = ['README.md', 'shared']; - const templates = readdirSync( - './packages/create-docusaurus/templates', - ).filter((name) => !excludes.includes(name)); - console.log(`Will generate examples for templates: ${templates}`); - templates.forEach(generateTemplateExample); - console.log('Commiting changes'); - execSync('git add examples'); - execSync("git commit -am 'update examples' --allow-empty"); - console.log(''); - - // update starters - console.log('-------'); - console.log('# Updating starter repos and branches ...'); - console.log('It can take some time... please wait until done...'); - updateStarters(); - - console.log(''); - console.log('-------'); - console.log(''); - console.log('Generate examples end!'); - console.log("Don't forget to push and merge your pull-request!"); - console.log(''); +const branch = shell.exec('git rev-parse --abbrev-ref HEAD').stdout; +if (branch === 'main') { + throw new Error( + "Please don't generate Docusaurus examples from the main branch!\nWe are going to commit during this process!", + ); +} +try { + shell.exec('git diff --exit-code'); +} catch (e) { + throw new Error( + 'Please run the generate examples command with a clean Git state and no uncommitted local changes. git diff should display nothing!', + ); } -run(); +console.log(` +# Generate examples start! +`); + +// delete the examples directories if they exists +console.log(`------- +## Removing example folders... +`); +await fs.rm('./examples/classic', {recursive: true, force: true}); +await fs.rm('./examples/classic-typescript', {recursive: true, force: true}); +await fs.rm('./examples/facebook', {recursive: true, force: true}); + +// get the list of all available templates +console.log(` +------- +## Generate example folders... +`); +const excludes = ['README.md', 'shared']; +const templates = (await fs.readdir( + './packages/create-docusaurus/templates', +)).filter((name) => !excludes.includes(name)); +console.log(`Will generate examples for templates: ${templates.join(',')}`); +// eslint-disable-next-line no-restricted-syntax +for (const template of templates) { + await generateTemplateExample(template); +} +console.log('Commiting changes'); +shell.exec('git add examples'); +shell.exec("git commit -am 'update examples' --allow-empty"); + +// update starters +console.log(` +------- +# Updating starter repos and branches ... +It can take some time... please wait until done... +`); +updateStarters(); + +console.log(` +------- +Generate examples end! +Don't forget to push and merge your pull request! +`); diff --git a/admin/scripts/image-resize.mjs b/admin/scripts/image-resize.mjs index 0cb0d9da68db..770fee99e587 100644 --- a/admin/scripts/image-resize.mjs +++ b/admin/scripts/image-resize.mjs @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -// eslint-disable-next-line import/no-extraneous-dependencies +/* eslint-disable import/no-extraneous-dependencies */ + import sharp from 'sharp'; -import fs from 'fs/promises'; +import fs from 'fs-extra'; import path from 'path'; -// eslint-disable-next-line import/no-extraneous-dependencies import imageSize from 'image-size'; const allImages = ( diff --git a/package.json b/package.json index 03c940482cfb..6747e28d51e5 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "start:website:baseUrl": "yarn workspace website start:baseUrl", "start:website:blogOnly": "yarn workspace website start:blogOnly", "start:website:deployPreview": "cross-env NETLIFY=true CONTEXT='deploy-preview' yarn workspace website start", - "examples:generate": "node generateExamples", + "examples:generate": "node admin/scripts/generateExamples.mjs", "build": "yarn build:packages && yarn build:website", "build:packages": "lerna run build --no-private", "build:website": "yarn workspace website build", diff --git a/packages/create-docusaurus/.npmignore b/packages/create-docusaurus/.npmignore index cdb76275d38d..85863592b4d7 100644 --- a/packages/create-docusaurus/.npmignore +++ b/packages/create-docusaurus/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo __tests__ diff --git a/packages/docusaurus-logger/.npmignore b/packages/docusaurus-logger/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-logger/.npmignore +++ b/packages/docusaurus-logger/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-mdx-loader/.npmignore b/packages/docusaurus-mdx-loader/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-mdx-loader/.npmignore +++ b/packages/docusaurus-mdx-loader/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-migrate/.npmignore b/packages/docusaurus-migrate/.npmignore index 194434f1981f..ba8304029eb7 100644 --- a/packages/docusaurus-migrate/.npmignore +++ b/packages/docusaurus-migrate/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-client-redirects/.npmignore b/packages/docusaurus-plugin-client-redirects/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-client-redirects/.npmignore +++ b/packages/docusaurus-plugin-client-redirects/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-content-blog/.npmignore b/packages/docusaurus-plugin-content-blog/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-content-blog/.npmignore +++ b/packages/docusaurus-plugin-content-blog/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-content-docs/.npmignore b/packages/docusaurus-plugin-content-docs/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-content-docs/.npmignore +++ b/packages/docusaurus-plugin-content-docs/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-content-pages/.npmignore b/packages/docusaurus-plugin-content-pages/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-content-pages/.npmignore +++ b/packages/docusaurus-plugin-content-pages/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-debug/.npmignore b/packages/docusaurus-plugin-debug/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-debug/.npmignore +++ b/packages/docusaurus-plugin-debug/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-theme-common/copyUntypedFiles.js b/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs similarity index 82% rename from packages/docusaurus-theme-common/copyUntypedFiles.js rename to packages/docusaurus-plugin-debug/copyUntypedFiles.mjs index e5555c55368f..2743e7c438c1 100644 --- a/packages/docusaurus-theme-common/copyUntypedFiles.js +++ b/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -const path = require('path'); -const fs = require('fs-extra'); +import path from 'path'; +import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ const srcDir = path.resolve(__dirname, 'src'); const libDir = path.resolve(__dirname, 'lib'); -fs.copySync(srcDir, libDir, { +await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); }, diff --git a/packages/docusaurus-plugin-debug/package.json b/packages/docusaurus-plugin-debug/package.json index 6ca9542c077b..5b2adfba397e 100644 --- a/packages/docusaurus-plugin-debug/package.json +++ b/packages/docusaurus-plugin-debug/package.json @@ -5,8 +5,8 @@ "main": "lib/index.js", "types": "src/plugin-debug.d.ts", "scripts": { - "build": "tsc && node copyUntypedFiles.js", - "watch": "node copyUntypedFiles.js && tsc --watch" + "build": "tsc && node copyUntypedFiles.mjs", + "watch": "node copyUntypedFiles.mjs && tsc --watch" }, "publishConfig": { "access": "public" diff --git a/packages/docusaurus-plugin-google-analytics/.npmignore b/packages/docusaurus-plugin-google-analytics/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-google-analytics/.npmignore +++ b/packages/docusaurus-plugin-google-analytics/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-google-gtag/.npmignore b/packages/docusaurus-plugin-google-gtag/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-google-gtag/.npmignore +++ b/packages/docusaurus-plugin-google-gtag/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-ideal-image/.npmignore b/packages/docusaurus-plugin-ideal-image/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-ideal-image/.npmignore +++ b/packages/docusaurus-plugin-ideal-image/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-debug/copyUntypedFiles.js b/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs similarity index 82% rename from packages/docusaurus-plugin-debug/copyUntypedFiles.js rename to packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs index e5555c55368f..2743e7c438c1 100644 --- a/packages/docusaurus-plugin-debug/copyUntypedFiles.js +++ b/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -const path = require('path'); -const fs = require('fs-extra'); +import path from 'path'; +import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ const srcDir = path.resolve(__dirname, 'src'); const libDir = path.resolve(__dirname, 'lib'); -fs.copySync(srcDir, libDir, { +await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); }, diff --git a/packages/docusaurus-plugin-ideal-image/package.json b/packages/docusaurus-plugin-ideal-image/package.json index a6ffa21be89e..60a26a9c6773 100644 --- a/packages/docusaurus-plugin-ideal-image/package.json +++ b/packages/docusaurus-plugin-ideal-image/package.json @@ -8,7 +8,7 @@ "build": "yarn build:server && yarn build:browser && yarn build:copy && yarn build:format", "build:server": "tsc --project tsconfig.server.json", "build:browser": "tsc --project tsconfig.browser.json", - "build:copy": "node copyUntypedFiles.js", + "build:copy": "node copyUntypedFiles.mjs", "build:format": "prettier --config ../../.prettierrc --write \"lib/**/*.js\"" }, "publishConfig": { diff --git a/packages/docusaurus-plugin-pwa/.npmignore b/packages/docusaurus-plugin-pwa/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-pwa/.npmignore +++ b/packages/docusaurus-plugin-pwa/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.js b/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs similarity index 82% rename from packages/docusaurus-plugin-ideal-image/copyUntypedFiles.js rename to packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs index e5555c55368f..2743e7c438c1 100644 --- a/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.js +++ b/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -const path = require('path'); -const fs = require('fs-extra'); +import path from 'path'; +import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ const srcDir = path.resolve(__dirname, 'src'); const libDir = path.resolve(__dirname, 'lib'); -fs.copySync(srcDir, libDir, { +await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); }, diff --git a/packages/docusaurus-plugin-pwa/package.json b/packages/docusaurus-plugin-pwa/package.json index 3aeb16285d33..50a603c33a1a 100644 --- a/packages/docusaurus-plugin-pwa/package.json +++ b/packages/docusaurus-plugin-pwa/package.json @@ -8,7 +8,7 @@ "build": "yarn build:server && yarn build:browser && yarn build:copy", "build:server": "tsc --project tsconfig.server.json", "build:browser": "tsc --project tsconfig.browser.json", - "build:copy": "node copyUntypedFiles.js" + "build:copy": "node copyUntypedFiles.mjs" }, "publishConfig": { "access": "public" diff --git a/packages/docusaurus-plugin-sitemap/.npmignore b/packages/docusaurus-plugin-sitemap/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-plugin-sitemap/.npmignore +++ b/packages/docusaurus-plugin-sitemap/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-preset-classic/.npmignore b/packages/docusaurus-preset-classic/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-preset-classic/.npmignore +++ b/packages/docusaurus-preset-classic/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-remark-plugin-npm2yarn/.npmignore b/packages/docusaurus-remark-plugin-npm2yarn/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-remark-plugin-npm2yarn/.npmignore +++ b/packages/docusaurus-remark-plugin-npm2yarn/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-theme-classic/.npmignore b/packages/docusaurus-theme-classic/.npmignore index 2dd760ffdae8..3e3575db0c5a 100644 --- a/packages/docusaurus-theme-classic/.npmignore +++ b/packages/docusaurus-theme-classic/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-theme-common/.npmignore b/packages/docusaurus-theme-common/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-theme-common/.npmignore +++ b/packages/docusaurus-theme-common/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-plugin-pwa/copyUntypedFiles.js b/packages/docusaurus-theme-common/copyUntypedFiles.mjs similarity index 82% rename from packages/docusaurus-plugin-pwa/copyUntypedFiles.js rename to packages/docusaurus-theme-common/copyUntypedFiles.mjs index e5555c55368f..2743e7c438c1 100644 --- a/packages/docusaurus-plugin-pwa/copyUntypedFiles.js +++ b/packages/docusaurus-theme-common/copyUntypedFiles.mjs @@ -5,15 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -const path = require('path'); -const fs = require('fs-extra'); +import path from 'path'; +import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ const srcDir = path.resolve(__dirname, 'src'); const libDir = path.resolve(__dirname, 'lib'); -fs.copySync(srcDir, libDir, { +await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); }, diff --git a/packages/docusaurus-theme-common/package.json b/packages/docusaurus-theme-common/package.json index 6e6f181a31ba..9dbb6dc20c01 100644 --- a/packages/docusaurus-theme-common/package.json +++ b/packages/docusaurus-theme-common/package.json @@ -5,8 +5,8 @@ "main": "./lib/index.js", "types": "./lib/index.d.ts", "scripts": { - "build": "node copyUntypedFiles.js && tsc", - "watch": "node copyUntypedFiles.js && tsc --watch" + "build": "node copyUntypedFiles.mjs && tsc", + "watch": "node copyUntypedFiles.mjs && tsc --watch" }, "publishConfig": { "access": "public" diff --git a/packages/docusaurus-theme-live-codeblock/.npmignore b/packages/docusaurus-theme-live-codeblock/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-theme-live-codeblock/.npmignore +++ b/packages/docusaurus-theme-live-codeblock/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.js b/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.js deleted file mode 100644 index e5555c55368f..000000000000 --- a/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const path = require('path'); -const fs = require('fs-extra'); - -/** - * Copy all untyped and static assets files to lib. - */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); -fs.copySync(srcDir, libDir, { - filter(filepath) { - return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); - }, -}); diff --git a/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs b/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs new file mode 100644 index 000000000000..2743e7c438c1 --- /dev/null +++ b/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs @@ -0,0 +1,20 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import path from 'path'; +import fs from 'fs-extra'; + +/** + * Copy all untyped and static assets files to lib. + */ +const srcDir = path.resolve(__dirname, 'src'); +const libDir = path.resolve(__dirname, 'lib'); +await fs.copy(srcDir, libDir, { + filter(filepath) { + return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); + }, +}); diff --git a/packages/docusaurus-theme-live-codeblock/package.json b/packages/docusaurus-theme-live-codeblock/package.json index d85634bb5924..86249042b0ba 100644 --- a/packages/docusaurus-theme-live-codeblock/package.json +++ b/packages/docusaurus-theme-live-codeblock/package.json @@ -7,8 +7,8 @@ "access": "public" }, "scripts": { - "build": "tsc && node copyUntypedFiles.js", - "watch": "node copyUntypedFiles.js && tsc --watch" + "build": "tsc && node copyUntypedFiles.mjs", + "watch": "node copyUntypedFiles.mjs && tsc --watch" }, "repository": { "type": "git", diff --git a/packages/docusaurus-theme-search-algolia/.npmignore b/packages/docusaurus-theme-search-algolia/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-theme-search-algolia/.npmignore +++ b/packages/docusaurus-theme-search-algolia/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-theme-search-algolia/copyUntypedFiles.js b/packages/docusaurus-theme-search-algolia/copyUntypedFiles.js deleted file mode 100644 index e5555c55368f..000000000000 --- a/packages/docusaurus-theme-search-algolia/copyUntypedFiles.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const path = require('path'); -const fs = require('fs-extra'); - -/** - * Copy all untyped and static assets files to lib. - */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); -fs.copySync(srcDir, libDir, { - filter(filepath) { - return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); - }, -}); diff --git a/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs b/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs new file mode 100644 index 000000000000..2743e7c438c1 --- /dev/null +++ b/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs @@ -0,0 +1,20 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import path from 'path'; +import fs from 'fs-extra'; + +/** + * Copy all untyped and static assets files to lib. + */ +const srcDir = path.resolve(__dirname, 'src'); +const libDir = path.resolve(__dirname, 'lib'); +await fs.copy(srcDir, libDir, { + filter(filepath) { + return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); + }, +}); diff --git a/packages/docusaurus-theme-search-algolia/package.json b/packages/docusaurus-theme-search-algolia/package.json index cda043d49a7d..10f2ff6f85b9 100644 --- a/packages/docusaurus-theme-search-algolia/package.json +++ b/packages/docusaurus-theme-search-algolia/package.json @@ -17,7 +17,7 @@ "build": "yarn build:server && yarn build:browser && yarn build:copy", "build:server": "tsc --project tsconfig.server.json", "build:browser": "tsc --project tsconfig.browser.json", - "build:copy": "node copyUntypedFiles.js" + "build:copy": "node copyUntypedFiles.mjs" }, "dependencies": { "@docsearch/react": "^3.0.0-alpha.39", diff --git a/packages/docusaurus-theme-translations/.npmignore b/packages/docusaurus-theme-translations/.npmignore index 30fe02a5ea98..1b59b1ca638c 100644 --- a/packages/docusaurus-theme-translations/.npmignore +++ b/packages/docusaurus-theme-translations/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-utils-common/.npmignore b/packages/docusaurus-utils-common/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-utils-common/.npmignore +++ b/packages/docusaurus-utils-common/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-utils-validation/.npmignore b/packages/docusaurus-utils-validation/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-utils-validation/.npmignore +++ b/packages/docusaurus-utils-validation/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus-utils/.npmignore b/packages/docusaurus-utils/.npmignore index 3eabd2dd8d60..f2b994d4e359 100644 --- a/packages/docusaurus-utils/.npmignore +++ b/packages/docusaurus-utils/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus/.npmignore b/packages/docusaurus/.npmignore index 194434f1981f..ba8304029eb7 100644 --- a/packages/docusaurus/.npmignore +++ b/packages/docusaurus/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/packages/docusaurus/copyUntypedFiles.js b/packages/docusaurus/copyUntypedFiles.js deleted file mode 100644 index e5555c55368f..000000000000 --- a/packages/docusaurus/copyUntypedFiles.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const path = require('path'); -const fs = require('fs-extra'); - -/** - * Copy all untyped and static assets files to lib. - */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); -fs.copySync(srcDir, libDir, { - filter(filepath) { - return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); - }, -}); diff --git a/packages/docusaurus/copyUntypedFiles.mjs b/packages/docusaurus/copyUntypedFiles.mjs new file mode 100644 index 000000000000..2743e7c438c1 --- /dev/null +++ b/packages/docusaurus/copyUntypedFiles.mjs @@ -0,0 +1,20 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import path from 'path'; +import fs from 'fs-extra'; + +/** + * Copy all untyped and static assets files to lib. + */ +const srcDir = path.resolve(__dirname, 'src'); +const libDir = path.resolve(__dirname, 'lib'); +await fs.copy(srcDir, libDir, { + filter(filepath) { + return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); + }, +}); diff --git a/packages/docusaurus/package.json b/packages/docusaurus/package.json index 6b2678ab1a29..cacf7bcf564b 100644 --- a/packages/docusaurus/package.json +++ b/packages/docusaurus/package.json @@ -24,8 +24,8 @@ "docusaurus": "bin/docusaurus.js" }, "scripts": { - "build": "tsc && tsc -p tsconfig.client.json && node copyUntypedFiles.js", - "watch": "node copyUntypedFiles.js && concurrently -n \"server,client\" --kill-others \"tsc --watch\" \"tsc -p tsconfig.client.json --watch\"" + "build": "tsc && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs", + "watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc --watch\" \"tsc -p tsconfig.client.json --watch\"" }, "bugs": { "url": "https://github.com/facebook/docusaurus/issues" diff --git a/packages/lqip-loader/.npmignore b/packages/lqip-loader/.npmignore index 194434f1981f..ba8304029eb7 100644 --- a/packages/lqip-loader/.npmignore +++ b/packages/lqip-loader/.npmignore @@ -1,4 +1,4 @@ -copyUntypedFiles.js +copyUntypedFiles.mjs .tsbuildinfo tsconfig* __tests__ diff --git a/website/delayCrowdin.js b/website/delayCrowdin.mjs similarity index 60% rename from website/delayCrowdin.js rename to website/delayCrowdin.mjs index ee41cb04338f..31063fc49f93 100644 --- a/website/delayCrowdin.js +++ b/website/delayCrowdin.mjs @@ -19,25 +19,12 @@ async function delay(ms) { }); } -async function run() { - if ( - process.env.NETLIFY === 'true' && - process.env.SITE_NAME === 'docusaurus-i18n-staging' - ) { - console.log( - '[Crowdin] Delaying the docusaurus-i18n-staging deployment to avoid 409 errors', - ); - await delay(30000); - } +if ( + process.env.NETLIFY === 'true' && + process.env.SITE_NAME === 'docusaurus-i18n-staging' +) { + console.log( + '[Crowdin] Delaying the docusaurus-i18n-staging deployment to avoid 409 errors', + ); + await delay(30000); } - -run().then( - () => { - process.exit(0); - }, - (e) => { - console.error(e.message); - console.error(e.stack); - process.exit(1); - }, -); diff --git a/website/package.json b/website/package.json index 7f12557cfdea..4921add5822b 100644 --- a/website/package.json +++ b/website/package.json @@ -10,7 +10,7 @@ "deploy": "docusaurus deploy", "clear": "docusaurus clear", "serve": "docusaurus serve", - "test:css-order": "node testCSSOrder.js", + "test:css-order": "node testCSSOrder.mjs", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "start:baseUrl": "cross-env BASE_URL='/build/' yarn start", @@ -20,8 +20,8 @@ "build:fast": "cross-env BUILD_FAST=true yarn build --locale en", "netlify:build:production": "yarn docusaurus write-translations && yarn netlify:crowdin:delay && yarn netlify:crowdin:uploadSources && yarn netlify:crowdin:downloadTranslations && yarn build && yarn test:css-order", "netlify:build:deployPreview": "yarn docusaurus write-translations --locale fr --messagePrefix '(fr) ' && yarn build && yarn test:css-order", - "netlify:crowdin:delay": "node delayCrowdin.js", - "netlify:crowdin:wait": "node waitForCrowdin.js", + "netlify:crowdin:delay": "node delayCrowdin.mjs", + "netlify:crowdin:wait": "node waitForCrowdin.mjs", "netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website", "netlify:crowdin:downloadTranslationsFailSafe": "yarn netlify:crowdin:wait && (yarn --cwd .. crowdin:download:website || echo 'Crowdin translation download failure (only internal PRs have access to the Crowdin env token)')", "netlify:crowdin:uploadSources": "yarn --cwd .. crowdin:upload:website", diff --git a/website/testCSSOrder.js b/website/testCSSOrder.mjs similarity index 90% rename from website/testCSSOrder.js rename to website/testCSSOrder.mjs index 6acee5b7f1d5..07012da2097a 100644 --- a/website/testCSSOrder.js +++ b/website/testCSSOrder.mjs @@ -5,8 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -const path = require('path'); -const fs = require('fs'); +import path from 'path'; +// eslint-disable-next-line import/no-extraneous-dependencies +import fs from 'fs-extra'; /* This verifies CSS ordering on the Docusaurus site itself, @@ -53,9 +54,7 @@ const EXPECTED_CSS_MARKERS = [ const cssDirName = path.join(__dirname, 'build', 'assets', 'css'); -const cssFileNames = fs - .readdirSync(cssDirName) - .filter((file) => file.endsWith('.css')); +const cssFileNames = (await fs.readdir(cssDirName)).filter((file) => file.endsWith('.css')); if (cssFileNames.length !== 1) { throw new Error('unexpected: more than 1 css file'); @@ -64,7 +63,7 @@ const cssFile = path.join(cssDirName, cssFileNames[0]); console.log('Inspecting CSS file for test CSS markers', cssFile); -const cssFileContent = fs.readFileSync(cssFile, 'utf8'); +const cssFileContent = await fs.readFile(cssFile, 'utf8'); const cssMarkersWithPositions = EXPECTED_CSS_MARKERS.map((marker) => { const position = cssFileContent.indexOf(marker); @@ -88,8 +87,7 @@ const sortBy = (key) => (a, b) => // eslint-disable-next-line no-nested-ternary a[key] > b[key] ? 1 : b[key] > a[key] ? -1 : 0; -const sortedCSSMarkers = cssMarkersWithPositions - .concat() +const sortedCSSMarkers = [...cssMarkersWithPositions] .sort(sortBy('position')) .map(({marker}) => marker); diff --git a/website/waitForCrowdin.js b/website/waitForCrowdin.mjs similarity index 53% rename from website/waitForCrowdin.js rename to website/waitForCrowdin.mjs index 1b07771db1a4..ba0bcbfbbdbd 100644 --- a/website/waitForCrowdin.js +++ b/website/waitForCrowdin.mjs @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -const {Translations} = require('@crowdin/crowdin-api-client'); +import {Translations} from '@crowdin/crowdin-api-client'; /* Crowdin does not support concurrent "project builds" (downloads of translations). @@ -24,9 +24,7 @@ const timeout = 5 * 60 * 1000; const projectId = 428890; const token = process.env.CROWDIN_PERSONAL_TOKEN; // set on Netlify -const translations = new Translations({ - token, -}); +const translations = new Translations({token}); async function delay(ms) { return new Promise((resolve) => { @@ -39,35 +37,23 @@ async function hasBuildInProgress() { return projectBuilds.data.some((build) => build.data.status === 'inProgress'); } -async function run() { - const timeBefore = Date.now(); - // eslint-disable-next-line no-constant-condition - while (true) { - if (Date.now() - timeBefore > timeout) { - console.warn( - '[Crowdin] Timeout of wait script reached => will try to proceed but download translations is likely to fail...', - ); - break; - } +const timeBefore = Date.now(); - const inProgress = await hasBuildInProgress(); - if (inProgress) { - console.log('[Crowdin] A build is still in progress => waiting...'); - await delay(pollInterval); - } else { - console.warn('[Crowdin] No build in progress => lets continue'); - break; - } +// eslint-disable-next-line no-constant-condition +while (true) { + if (Date.now() - timeBefore > timeout) { + console.warn( + '[Crowdin] Timeout of wait script reached => will try to proceed but download translations is likely to fail...', + ); + break; } -} -run().then( - () => { - process.exit(0); - }, - (e) => { - console.error(e.message); - console.error(e.stack); - process.exit(1); - }, -); + const inProgress = await hasBuildInProgress(); + if (inProgress) { + console.log('[Crowdin] A build is still in progress => waiting...'); + await delay(pollInterval); + } else { + console.warn('[Crowdin] No build in progress => lets continue'); + break; + } +} From f838da0edb8f6b28521cf30920fee31aee79c59a Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 22:26:36 +0800 Subject: [PATCH 02/10] fixes --- .eslintignore | 4 +--- admin/scripts/generateExamples.mjs | 4 +--- website/waitForCrowdin.mjs | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.eslintignore b/.eslintignore index df78c0c54950..85470d48eb03 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,9 +12,7 @@ packages/lqip-loader/lib/ packages/docusaurus/lib/ packages/docusaurus-*/lib/* packages/docusaurus-*/lib-next/ -packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs -packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs -packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs +copyUntypedFiles.mjs packages/create-docusaurus/lib/* packages/create-docusaurus/templates/facebook/.eslintrc.js diff --git a/admin/scripts/generateExamples.mjs b/admin/scripts/generateExamples.mjs index c9c9c66adc5a..b7329ece43e7 100644 --- a/admin/scripts/generateExamples.mjs +++ b/admin/scripts/generateExamples.mjs @@ -153,9 +153,7 @@ if (branch === 'main') { "Please don't generate Docusaurus examples from the main branch!\nWe are going to commit during this process!", ); } -try { - shell.exec('git diff --exit-code'); -} catch (e) { +if (shell.exec('git diff --exit-code').code !== 0) { throw new Error( 'Please run the generate examples command with a clean Git state and no uncommitted local changes. git diff should display nothing!', ); diff --git a/website/waitForCrowdin.mjs b/website/waitForCrowdin.mjs index ba0bcbfbbdbd..e9bd89811bed 100644 --- a/website/waitForCrowdin.mjs +++ b/website/waitForCrowdin.mjs @@ -53,7 +53,7 @@ while (true) { console.log('[Crowdin] A build is still in progress => waiting...'); await delay(pollInterval); } else { - console.warn('[Crowdin] No build in progress => lets continue'); + console.warn("[Crowdin] No build in progress => let's continue"); break; } } From 1f284c6fe6b55f376c95a4417d210aa505336237 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 22:32:30 +0800 Subject: [PATCH 03/10] fix --- packages/docusaurus-plugin-debug/copyUntypedFiles.mjs | 4 ++-- packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs | 4 ++-- packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs | 4 ++-- packages/docusaurus-theme-common/copyUntypedFiles.mjs | 4 ++-- .../docusaurus-theme-live-codeblock/copyUntypedFiles.mjs | 4 ++-- .../docusaurus-theme-search-algolia/copyUntypedFiles.mjs | 4 ++-- packages/docusaurus/copyUntypedFiles.mjs | 5 ++--- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs b/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs index 2743e7c438c1..c01ebb16dea1 100644 --- a/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs +++ b/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs @@ -11,8 +11,8 @@ import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); +const srcDir = new URL('src', import.meta.url).pathname; +const libDir = new URL('lib', import.meta.url).pathname; await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs b/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs index 2743e7c438c1..c01ebb16dea1 100644 --- a/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs +++ b/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs @@ -11,8 +11,8 @@ import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); +const srcDir = new URL('src', import.meta.url).pathname; +const libDir = new URL('lib', import.meta.url).pathname; await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs b/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs index 2743e7c438c1..c01ebb16dea1 100644 --- a/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs +++ b/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs @@ -11,8 +11,8 @@ import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); +const srcDir = new URL('src', import.meta.url).pathname; +const libDir = new URL('lib', import.meta.url).pathname; await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-theme-common/copyUntypedFiles.mjs b/packages/docusaurus-theme-common/copyUntypedFiles.mjs index 2743e7c438c1..c01ebb16dea1 100644 --- a/packages/docusaurus-theme-common/copyUntypedFiles.mjs +++ b/packages/docusaurus-theme-common/copyUntypedFiles.mjs @@ -11,8 +11,8 @@ import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); +const srcDir = new URL('src', import.meta.url).pathname; +const libDir = new URL('lib', import.meta.url).pathname; await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs b/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs index 2743e7c438c1..c01ebb16dea1 100644 --- a/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs +++ b/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs @@ -11,8 +11,8 @@ import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); +const srcDir = new URL('src', import.meta.url).pathname; +const libDir = new URL('lib', import.meta.url).pathname; await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs b/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs index 2743e7c438c1..c01ebb16dea1 100644 --- a/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs +++ b/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs @@ -11,8 +11,8 @@ import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); +const srcDir = new URL('src', import.meta.url).pathname; +const libDir = new URL('lib', import.meta.url).pathname; await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus/copyUntypedFiles.mjs b/packages/docusaurus/copyUntypedFiles.mjs index 2743e7c438c1..31fc758bf742 100644 --- a/packages/docusaurus/copyUntypedFiles.mjs +++ b/packages/docusaurus/copyUntypedFiles.mjs @@ -5,14 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import fs from 'fs-extra'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = path.resolve(__dirname, 'src'); -const libDir = path.resolve(__dirname, 'lib'); +const srcDir = new URL('src', import.meta.url).pathname; +const libDir = new URL('lib', import.meta.url).pathname; await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); From 5ed0f2ed9caecb20d24e8c10d8df60ec84dc5b80 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 22:52:29 +0800 Subject: [PATCH 04/10] fixes --- admin/scripts/image-resize.mjs | 5 +++-- .../docusaurus-plugin-debug/copyUntypedFiles.mjs | 6 +++--- .../copyUntypedFiles.mjs | 6 +++--- packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs | 6 +++--- .../docusaurus-theme-common/copyUntypedFiles.mjs | 6 +++--- .../copyUntypedFiles.mjs | 6 +++--- .../copyUntypedFiles.mjs | 6 +++--- packages/docusaurus/copyUntypedFiles.mjs | 5 +++-- website/docusaurus.config.js | 13 +++++-------- ...eRequestsPlugin.js => FeatureRequestsPlugin.mjs} | 8 +++----- .../src/remark/{configTabs.js => configTabs.mjs} | 6 ++---- 11 files changed, 34 insertions(+), 39 deletions(-) rename website/src/featureRequests/{FeatureRequestsPlugin.js => FeatureRequestsPlugin.mjs} (77%) rename website/src/remark/{configTabs.js => configTabs.mjs} (98%) diff --git a/admin/scripts/image-resize.mjs b/admin/scripts/image-resize.mjs index 770fee99e587..c0dcb7093e06 100644 --- a/admin/scripts/image-resize.mjs +++ b/admin/scripts/image-resize.mjs @@ -11,6 +11,7 @@ import sharp from 'sharp'; import fs from 'fs-extra'; import path from 'path'; import imageSize from 'image-size'; +import {fileURLToPath} from 'url'; const allImages = ( await fs.readdir(new URL('../../website/src/data/showcase', import.meta.url)) @@ -21,10 +22,10 @@ const images = selectedImages.length > 0 ? selectedImages : allImages; await Promise.all( images.map(async (img) => { - const imgPath = new URL( + const imgPath = fileURLToPath(new URL( `../../website/src/data/showcase/${img}`, import.meta.url, - ).pathname; + )); const {width, height} = imageSize(imgPath); if (width === 640 && height === 320) { // Do not emit if no resized. Important because we diff --git a/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs b/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs index c01ebb16dea1..8b230152f1af 100644 --- a/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs +++ b/packages/docusaurus-plugin-debug/copyUntypedFiles.mjs @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import fs from 'fs-extra'; +import {fileURLToPath} from 'url'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = new URL('src', import.meta.url).pathname; -const libDir = new URL('lib', import.meta.url).pathname; +const srcDir = fileURLToPath(new URL('src', import.meta.url)); +const libDir = fileURLToPath(new URL('lib', import.meta.url)); await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs b/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs index c01ebb16dea1..8b230152f1af 100644 --- a/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs +++ b/packages/docusaurus-plugin-ideal-image/copyUntypedFiles.mjs @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import fs from 'fs-extra'; +import {fileURLToPath} from 'url'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = new URL('src', import.meta.url).pathname; -const libDir = new URL('lib', import.meta.url).pathname; +const srcDir = fileURLToPath(new URL('src', import.meta.url)); +const libDir = fileURLToPath(new URL('lib', import.meta.url)); await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs b/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs index c01ebb16dea1..8b230152f1af 100644 --- a/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs +++ b/packages/docusaurus-plugin-pwa/copyUntypedFiles.mjs @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import fs from 'fs-extra'; +import {fileURLToPath} from 'url'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = new URL('src', import.meta.url).pathname; -const libDir = new URL('lib', import.meta.url).pathname; +const srcDir = fileURLToPath(new URL('src', import.meta.url)); +const libDir = fileURLToPath(new URL('lib', import.meta.url)); await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-theme-common/copyUntypedFiles.mjs b/packages/docusaurus-theme-common/copyUntypedFiles.mjs index c01ebb16dea1..8b230152f1af 100644 --- a/packages/docusaurus-theme-common/copyUntypedFiles.mjs +++ b/packages/docusaurus-theme-common/copyUntypedFiles.mjs @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import fs from 'fs-extra'; +import {fileURLToPath} from 'url'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = new URL('src', import.meta.url).pathname; -const libDir = new URL('lib', import.meta.url).pathname; +const srcDir = fileURLToPath(new URL('src', import.meta.url)); +const libDir = fileURLToPath(new URL('lib', import.meta.url)); await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs b/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs index c01ebb16dea1..8b230152f1af 100644 --- a/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs +++ b/packages/docusaurus-theme-live-codeblock/copyUntypedFiles.mjs @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import fs from 'fs-extra'; +import {fileURLToPath} from 'url'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = new URL('src', import.meta.url).pathname; -const libDir = new URL('lib', import.meta.url).pathname; +const srcDir = fileURLToPath(new URL('src', import.meta.url)); +const libDir = fileURLToPath(new URL('lib', import.meta.url)); await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs b/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs index c01ebb16dea1..8b230152f1af 100644 --- a/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs +++ b/packages/docusaurus-theme-search-algolia/copyUntypedFiles.mjs @@ -5,14 +5,14 @@ * LICENSE file in the root directory of this source tree. */ -import path from 'path'; import fs from 'fs-extra'; +import {fileURLToPath} from 'url'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = new URL('src', import.meta.url).pathname; -const libDir = new URL('lib', import.meta.url).pathname; +const srcDir = fileURLToPath(new URL('src', import.meta.url)); +const libDir = fileURLToPath(new URL('lib', import.meta.url)); await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/packages/docusaurus/copyUntypedFiles.mjs b/packages/docusaurus/copyUntypedFiles.mjs index 31fc758bf742..8b230152f1af 100644 --- a/packages/docusaurus/copyUntypedFiles.mjs +++ b/packages/docusaurus/copyUntypedFiles.mjs @@ -6,12 +6,13 @@ */ import fs from 'fs-extra'; +import {fileURLToPath} from 'url'; /** * Copy all untyped and static assets files to lib. */ -const srcDir = new URL('src', import.meta.url).pathname; -const libDir = new URL('lib', import.meta.url).pathname; +const srcDir = fileURLToPath(new URL('src', import.meta.url)); +const libDir = fileURLToPath(new URL('lib', import.meta.url)); await fs.copy(srcDir, libDir, { filter(filepath) { return !/__tests__/.test(filepath) && !/\.tsx?$/.test(filepath); diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 8e3808f84d3e..08c887af610c 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -12,9 +12,7 @@ const math = require('remark-math'); const katex = require('rehype-katex'); const VersionsArchived = require('./versionsArchived.json'); const {dogfoodingPluginInstances} = require('./_dogfooding/dogfooding.config'); -const FeatureRequestsPlugin = require('./src/featureRequests/FeatureRequestsPlugin'); const npm2yarn = require('@docusaurus/remark-plugin-npm2yarn'); -const configTabs = require('./src/remark/configTabs'); const lightTheme = require('./src/utils/prismLight'); const darkTheme = require('./src/utils/prismDark'); @@ -120,7 +118,6 @@ const config = { ], themes: ['live-codeblock'], plugins: [ - FeatureRequestsPlugin, [ 'content-docs', /** @type {import('@docusaurus/plugin-content-docs').Options} */ @@ -265,7 +262,7 @@ const config = { }, showLastUpdateAuthor: true, showLastUpdateTime: true, - remarkPlugins: [math, [npm2yarn, {sync: true}], configTabs], + remarkPlugins: [math, [npm2yarn, {sync: true}]], rehypePlugins: [katex], disableVersioning: isVersioningDisabled, lastVersion: isDev || isDeployPreview ? 'current' : undefined, @@ -519,11 +516,11 @@ const config = { }), }; -// TODO temporary dogfood async config, remove soon async function createConfig() { - await new Promise((resolve) => { - setTimeout(resolve, 0); - }); + const FeatureRequestsPlugin = (await import('./src/featureRequests/FeatureRequestsPlugin.mjs')).default; + const configTabs = (await import('./src/remark/configTabs.mjs')).default; + config.plugins?.push(FeatureRequestsPlugin); + config.presets[0][1].docs.remarkPlugins.push(configTabs); return config; } diff --git a/website/src/featureRequests/FeatureRequestsPlugin.js b/website/src/featureRequests/FeatureRequestsPlugin.mjs similarity index 77% rename from website/src/featureRequests/FeatureRequestsPlugin.js rename to website/src/featureRequests/FeatureRequestsPlugin.mjs index 2aad9eb2dc96..36093a91466a 100644 --- a/website/src/featureRequests/FeatureRequestsPlugin.js +++ b/website/src/featureRequests/FeatureRequestsPlugin.mjs @@ -5,17 +5,17 @@ * LICENSE file in the root directory of this source tree. */ -const {normalizeUrl} = require('@docusaurus/utils'); +import utils from '@docusaurus/utils'; /** * @param {import('@docusaurus/types').LoadContext} context * @returns {import('@docusaurus/types').Plugin} */ -function FeatureRequestsPlugin(context) { +export default function FeatureRequestsPlugin(context) { return { name: 'feature-requests-plugin', async contentLoaded({actions}) { - const basePath = normalizeUrl([context.baseUrl, '/feature-requests']); + const basePath = utils.normalizeUrl([context.baseUrl, '/feature-requests']); await actions.createData('paths.json', JSON.stringify(basePath)); actions.addRoute({ path: basePath, @@ -28,5 +28,3 @@ function FeatureRequestsPlugin(context) { }, }; } - -module.exports = FeatureRequestsPlugin; diff --git a/website/src/remark/configTabs.js b/website/src/remark/configTabs.mjs similarity index 98% rename from website/src/remark/configTabs.js rename to website/src/remark/configTabs.mjs index 3746858ca959..3c72ce9334f7 100644 --- a/website/src/remark/configTabs.js +++ b/website/src/remark/configTabs.mjs @@ -5,12 +5,12 @@ * LICENSE file in the root directory of this source tree. */ -const visit = require('unist-util-visit'); +import visit from 'unist-util-visit'; /** * Turns a "```js config-tabs" code block into a "plugin options" and a "preset options" tab */ -const plugin = () => { +export default function plugin() { const transformer = (root) => { let tabsImported = false; let codeBlockImported = false; @@ -166,5 +166,3 @@ const plugin = () => { }; return transformer; }; - -module.exports = plugin; From beb589b01b2cea0852889e8f8389fa79228582d5 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 23:00:46 +0800 Subject: [PATCH 05/10] fix! --- website/testCSSOrder.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/testCSSOrder.mjs b/website/testCSSOrder.mjs index 07012da2097a..cfb12a5c128a 100644 --- a/website/testCSSOrder.mjs +++ b/website/testCSSOrder.mjs @@ -6,6 +6,7 @@ */ import path from 'path'; +import {fileURLToPath} from 'url'; // eslint-disable-next-line import/no-extraneous-dependencies import fs from 'fs-extra'; @@ -52,7 +53,7 @@ const EXPECTED_CSS_MARKERS = [ '.DocSearch-Modal', ]; -const cssDirName = path.join(__dirname, 'build', 'assets', 'css'); +const cssDirName = fileURLToPath(new URL('build/assets/css', import.meta.url)); const cssFileNames = (await fs.readdir(cssDirName)).filter((file) => file.endsWith('.css')); From 8662cce1d8634a780558a3c64875a9699c5f320d Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 23:07:25 +0800 Subject: [PATCH 06/10] complete eslint --- .eslintrc.js | 1 + admin/scripts/generateExamples.mjs | 6 +++--- admin/scripts/image-resize.mjs | 9 ++++----- package.json | 8 ++++---- website/src/featureRequests/FeatureRequestsPlugin.mjs | 5 ++++- website/src/remark/configTabs.mjs | 2 +- website/testCSSOrder.mjs | 4 +++- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d811d6c9e1a4..62068bcee308 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -39,6 +39,7 @@ module.exports = { }, }, }, + reportUnusedDisableDirectives: true, plugins: ['react-hooks', 'header'], rules: { 'react-hooks/rules-of-hooks': ERROR, diff --git a/admin/scripts/generateExamples.mjs b/admin/scripts/generateExamples.mjs index b7329ece43e7..6539ab6835a1 100644 --- a/admin/scripts/generateExamples.mjs +++ b/admin/scripts/generateExamples.mjs @@ -177,9 +177,9 @@ console.log(` ## Generate example folders... `); const excludes = ['README.md', 'shared']; -const templates = (await fs.readdir( - './packages/create-docusaurus/templates', -)).filter((name) => !excludes.includes(name)); +const templates = ( + await fs.readdir('./packages/create-docusaurus/templates') +).filter((name) => !excludes.includes(name)); console.log(`Will generate examples for templates: ${templates.join(',')}`); // eslint-disable-next-line no-restricted-syntax for (const template of templates) { diff --git a/admin/scripts/image-resize.mjs b/admin/scripts/image-resize.mjs index c0dcb7093e06..2b221835be81 100644 --- a/admin/scripts/image-resize.mjs +++ b/admin/scripts/image-resize.mjs @@ -17,15 +17,14 @@ const allImages = ( await fs.readdir(new URL('../../website/src/data/showcase', import.meta.url)) ).filter((file) => ['.png', 'jpg', '.jpeg'].includes(path.extname(file))); -const [,,...selectedImages] = process.argv; +const [, , ...selectedImages] = process.argv; const images = selectedImages.length > 0 ? selectedImages : allImages; await Promise.all( images.map(async (img) => { - const imgPath = fileURLToPath(new URL( - `../../website/src/data/showcase/${img}`, - import.meta.url, - )); + const imgPath = fileURLToPath( + new URL(`../../website/src/data/showcase/${img}`, import.meta.url), + ); const {width, height} = imageSize(imgPath); if (width === 640 && height === 320) { // Do not emit if no resized. Important because we diff --git a/package.json b/package.json index 6747e28d51e5..eace1b012204 100644 --- a/package.json +++ b/package.json @@ -41,13 +41,13 @@ "postinstall": "run-p postinstall:**", "postinstall:main": "yarn lock:update && yarn build:packages", "postinstall:dev": "is-ci || husky install", - "format": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx,json}\"", - "format:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx,json}\"", + "format": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx,json,mjs}\"", + "format:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx,json,mjs}\"", "format-docs": "prettier --config .prettierrc --write \"**/*.{md,mdx}\"", "format-docs:diff": "prettier --config .prettierrc --list-different \"**/*.{md,mdx}\"", "lint": "yarn lint:js && yarn lint:style", - "lint:ci": "yarn lint:js --quiet --report-unused-disable-directives && yarn lint:style", - "lint:js": "eslint --cache \"**/*.{js,jsx,ts,tsx}\"", + "lint:ci": "yarn lint:js --quiet && yarn lint:style", + "lint:js": "eslint --cache --report-unused-disable-directives \"**/*.{js,jsx,ts,tsx,mjs}\"", "lint:style": "stylelint \"**/*.css\"", "lerna": "lerna", "test": "cross-env TZ=UTC jest", diff --git a/website/src/featureRequests/FeatureRequestsPlugin.mjs b/website/src/featureRequests/FeatureRequestsPlugin.mjs index 36093a91466a..6e1b9aa4f78f 100644 --- a/website/src/featureRequests/FeatureRequestsPlugin.mjs +++ b/website/src/featureRequests/FeatureRequestsPlugin.mjs @@ -15,7 +15,10 @@ export default function FeatureRequestsPlugin(context) { return { name: 'feature-requests-plugin', async contentLoaded({actions}) { - const basePath = utils.normalizeUrl([context.baseUrl, '/feature-requests']); + const basePath = utils.normalizeUrl([ + context.baseUrl, + '/feature-requests', + ]); await actions.createData('paths.json', JSON.stringify(basePath)); actions.addRoute({ path: basePath, diff --git a/website/src/remark/configTabs.mjs b/website/src/remark/configTabs.mjs index 3c72ce9334f7..de958dfd8bde 100644 --- a/website/src/remark/configTabs.mjs +++ b/website/src/remark/configTabs.mjs @@ -165,4 +165,4 @@ export default function plugin() { } }; return transformer; -}; +} diff --git a/website/testCSSOrder.mjs b/website/testCSSOrder.mjs index cfb12a5c128a..3e54d6929f0c 100644 --- a/website/testCSSOrder.mjs +++ b/website/testCSSOrder.mjs @@ -55,7 +55,9 @@ const EXPECTED_CSS_MARKERS = [ const cssDirName = fileURLToPath(new URL('build/assets/css', import.meta.url)); -const cssFileNames = (await fs.readdir(cssDirName)).filter((file) => file.endsWith('.css')); +const cssFileNames = (await fs.readdir(cssDirName)).filter((file) => + file.endsWith('.css'), +); if (cssFileNames.length !== 1) { throw new Error('unexpected: more than 1 css file'); From e3468854287ce0a701c90ccbfc4c873a177ac7b2 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 23:10:56 +0800 Subject: [PATCH 07/10] more move --- website/docusaurus.config.js | 11 +++++++---- website/src/utils/{prismDark.js => prismDark.mjs} | 4 ++-- website/src/utils/{prismLight.js => prismLight.mjs} | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) rename website/src/utils/{prismDark.js => prismDark.mjs} (94%) rename website/src/utils/{prismLight.js => prismLight.mjs} (94%) diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 08c887af610c..f22f7bcaa96a 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -13,8 +13,6 @@ const katex = require('rehype-katex'); const VersionsArchived = require('./versionsArchived.json'); const {dogfoodingPluginInstances} = require('./_dogfooding/dogfooding.config'); const npm2yarn = require('@docusaurus/remark-plugin-npm2yarn'); -const lightTheme = require('./src/utils/prismLight'); -const darkTheme = require('./src/utils/prismDark'); const ArchivedVersionsDropdownItems = Object.entries(VersionsArchived).splice( 0, @@ -329,8 +327,6 @@ const config = { content: `⭐️ If you like Docusaurus, give it a star on GitHub and follow us on Twitter ${TwitterSvg}`, }, prism: { - theme: lightTheme, - darkTheme, // We need to load markdown again so that YAML is loaded before MD // and the YAML front matter is highlighted correctly. // TODO after we have forked prism-react-renderer, we should tweak the @@ -519,8 +515,15 @@ const config = { async function createConfig() { const FeatureRequestsPlugin = (await import('./src/featureRequests/FeatureRequestsPlugin.mjs')).default; const configTabs = (await import('./src/remark/configTabs.mjs')).default; + const lightTheme = (await import('./src/utils/prismLight.mjs')).default; + const darkTheme = (await import('./src/utils/prismDark.mjs')).default; config.plugins?.push(FeatureRequestsPlugin); + // @ts-expect-error: we know it exists, right config.presets[0][1].docs.remarkPlugins.push(configTabs); + // @ts-expect-error: we know it exists, right + config.themeConfig.prism.theme = lightTheme; + // @ts-expect-error: we know it exists, right + config.themeConfig.prism.darkTheme = darkTheme; return config; } diff --git a/website/src/utils/prismDark.js b/website/src/utils/prismDark.mjs similarity index 94% rename from website/src/utils/prismDark.js rename to website/src/utils/prismDark.mjs index 45b365e7e51f..2c1c08123c06 100644 --- a/website/src/utils/prismDark.js +++ b/website/src/utils/prismDark.mjs @@ -6,9 +6,9 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -const darkTheme = require('prism-react-renderer/themes/vsDark'); +import darkTheme from 'prism-react-renderer/themes/vsDark'; -module.exports = { +export default { plain: { color: '#D4D4D4', backgroundColor: '#1E1E1E', diff --git a/website/src/utils/prismLight.js b/website/src/utils/prismLight.mjs similarity index 94% rename from website/src/utils/prismLight.js rename to website/src/utils/prismLight.mjs index a34030a8d910..bc9c76997a79 100644 --- a/website/src/utils/prismLight.js +++ b/website/src/utils/prismLight.mjs @@ -6,9 +6,9 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -const lightTheme = require('prism-react-renderer/themes/github'); +import lightTheme from 'prism-react-renderer/themes/github'; -module.exports = { +export default { ...lightTheme, styles: [ ...lightTheme.styles, From 4bf8d154eb20d2509cfda96a2fb250541cd6edb2 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 7 Jan 2022 23:16:38 +0800 Subject: [PATCH 08/10] fix! --- website/src/utils/prismDark.mjs | 2 +- website/src/utils/prismLight.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/src/utils/prismDark.mjs b/website/src/utils/prismDark.mjs index 2c1c08123c06..8a90868aefb7 100644 --- a/website/src/utils/prismDark.mjs +++ b/website/src/utils/prismDark.mjs @@ -6,7 +6,7 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -import darkTheme from 'prism-react-renderer/themes/vsDark'; +import darkTheme from 'prism-react-renderer/themes/vsDark/index.js'; export default { plain: { diff --git a/website/src/utils/prismLight.mjs b/website/src/utils/prismLight.mjs index bc9c76997a79..906ca3415216 100644 --- a/website/src/utils/prismLight.mjs +++ b/website/src/utils/prismLight.mjs @@ -6,7 +6,7 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -import lightTheme from 'prism-react-renderer/themes/github'; +import lightTheme from 'prism-react-renderer/themes/github/index.js'; export default { ...lightTheme, From 136fd34f2907b96ae8cc1c06ef4422fb0fca6aaa Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 8 Jan 2022 07:48:54 +0800 Subject: [PATCH 09/10] This looks better? --- website/src/utils/prismDark.mjs | 2 +- website/src/utils/prismLight.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/website/src/utils/prismDark.mjs b/website/src/utils/prismDark.mjs index 8a90868aefb7..892f9451256d 100644 --- a/website/src/utils/prismDark.mjs +++ b/website/src/utils/prismDark.mjs @@ -6,7 +6,7 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -import darkTheme from 'prism-react-renderer/themes/vsDark/index.js'; +import darkTheme from 'prism-react-renderer/themes/vsDark/index.cjs.js'; export default { plain: { diff --git a/website/src/utils/prismLight.mjs b/website/src/utils/prismLight.mjs index 906ca3415216..ac7ee2c78580 100644 --- a/website/src/utils/prismLight.mjs +++ b/website/src/utils/prismLight.mjs @@ -6,7 +6,7 @@ */ // eslint-disable-next-line import/no-extraneous-dependencies -import lightTheme from 'prism-react-renderer/themes/github/index.js'; +import lightTheme from 'prism-react-renderer/themes/github/index.cjs.js'; export default { ...lightTheme, From f6562c0d046c263a85f9f0fae82ffb342fc34c45 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 8 Jan 2022 12:20:47 +0800 Subject: [PATCH 10/10] Final ones --- jest.config.js => jest.config.mjs | 6 +- package.json | 2 +- ...ig.test.js => validateThemeConfig.test.ts} | 13 ++- ...ig.test.js => validateThemeConfig.test.ts} | 7 +- .../src/validateThemeConfig.ts | 3 +- .../__tests__/update.test.ts | 47 +++++++++ .../docusaurus-theme-translations/update.d.ts | 12 +++ .../update.test.js | 42 -------- .../__tests__/{index.js => index.test.js} | 0 yarn.lock | 97 +++++++++++++++---- 10 files changed, 150 insertions(+), 79 deletions(-) rename jest.config.js => jest.config.mjs (93%) rename packages/docusaurus-theme-classic/src/__tests__/{validateThemeConfig.test.js => validateThemeConfig.test.ts} (97%) rename packages/docusaurus-theme-search-algolia/src/__tests__/{validateThemeConfig.test.js => validateThemeConfig.test.ts} (91%) create mode 100644 packages/docusaurus-theme-translations/__tests__/update.test.ts create mode 100644 packages/docusaurus-theme-translations/update.d.ts delete mode 100644 packages/docusaurus-theme-translations/update.test.js rename packages/stylelint-copyright/__tests__/{index.js => index.test.js} (100%) diff --git a/jest.config.js b/jest.config.mjs similarity index 93% rename from jest.config.js rename to jest.config.mjs index f9cdbb7e90d7..93119e4ac94b 100644 --- a/jest.config.js +++ b/jest.config.mjs @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -const path = require('path'); +import {fileURLToPath} from 'url'; const ignorePatterns = [ '/node_modules/', @@ -21,8 +21,8 @@ const ignorePatterns = [ '/packages/docusaurus-migrate/lib', ]; -module.exports = { - rootDir: path.resolve(__dirname), +export default { + rootDir: fileURLToPath(new URL('.', import.meta.url)), verbose: true, testURL: 'http://localhost/', testEnvironment: 'node', diff --git a/package.json b/package.json index eace1b012204..0860ce99c0af 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "rimraf": "^3.0.2", "serve": "^12.0.1", "sharp": "^0.29.1", - "stylelint": "^13.10.0", + "stylelint": "^14.2.0", "tslib": "^2.3.1", "typescript": "^4.5.2" }, diff --git a/packages/docusaurus-theme-classic/src/__tests__/validateThemeConfig.test.js b/packages/docusaurus-theme-classic/src/__tests__/validateThemeConfig.test.ts similarity index 97% rename from packages/docusaurus-theme-classic/src/__tests__/validateThemeConfig.test.js rename to packages/docusaurus-theme-classic/src/__tests__/validateThemeConfig.test.ts index e987f2ac6935..4b6f4b17c161 100644 --- a/packages/docusaurus-theme-classic/src/__tests__/validateThemeConfig.test.js +++ b/packages/docusaurus-theme-classic/src/__tests__/validateThemeConfig.test.ts @@ -6,21 +6,20 @@ */ import {merge} from 'lodash'; +import {ThemeConfigSchema, DEFAULT_CONFIG} from '../validateThemeConfig'; -const {ThemeConfigSchema, DEFAULT_CONFIG} = require('../validateThemeConfig'); +import {normalizeThemeConfig} from '@docusaurus/utils-validation'; +import theme from 'prism-react-renderer/themes/github'; +import darkTheme from 'prism-react-renderer/themes/dracula'; -const {normalizeThemeConfig} = require('@docusaurus/utils-validation'); -const theme = require('prism-react-renderer/themes/github'); -const darkTheme = require('prism-react-renderer/themes/dracula'); - -function testValidateThemeConfig(partialThemeConfig) { +function testValidateThemeConfig(partialThemeConfig: Record) { return normalizeThemeConfig(ThemeConfigSchema, { ...DEFAULT_CONFIG, ...partialThemeConfig, }); } -function testOk(partialThemeConfig) { +function testOk(partialThemeConfig: Record) { expect( testValidateThemeConfig({...DEFAULT_CONFIG, ...partialThemeConfig}), ).toEqual({ diff --git a/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.js b/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.ts similarity index 91% rename from packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.js rename to packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.ts index 6725671573c6..8aef03a32553 100644 --- a/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.js +++ b/packages/docusaurus-theme-search-algolia/src/__tests__/validateThemeConfig.test.ts @@ -5,10 +5,11 @@ * LICENSE file in the root directory of this source tree. */ -const {validateThemeConfig, DEFAULT_CONFIG} = require('../validateThemeConfig'); +import type {Joi} from '@docusaurus/utils-validation'; +import {validateThemeConfig, DEFAULT_CONFIG} from '../validateThemeConfig'; -function testValidateThemeConfig(themeConfig) { - function validate(schema, cfg) { +function testValidateThemeConfig(themeConfig: Record) { + function validate(schema: Joi.Schema, cfg: Record) { const {value, error} = schema.validate(cfg, { convert: false, }); diff --git a/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts b/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts index b2afb4c1aa84..74029a7206ce 100644 --- a/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts +++ b/packages/docusaurus-theme-search-algolia/src/validateThemeConfig.ts @@ -8,7 +8,7 @@ import {Joi} from '@docusaurus/utils-validation'; import type {ThemeConfig, Validate, ValidationResult} from '@docusaurus/types'; -const DEFAULT_CONFIG = { +export const DEFAULT_CONFIG = { contextualSearch: false, // future: maybe we want to enable this by default // By default, all Docusaurus sites are using the same AppId @@ -17,7 +17,6 @@ const DEFAULT_CONFIG = { searchParameters: {}, }; -exports.DEFAULT_CONFIG = DEFAULT_CONFIG; export const Schema = Joi.object({ algolia: Joi.object({ diff --git a/packages/docusaurus-theme-translations/__tests__/update.test.ts b/packages/docusaurus-theme-translations/__tests__/update.test.ts new file mode 100644 index 000000000000..21a2573e82f8 --- /dev/null +++ b/packages/docusaurus-theme-translations/__tests__/update.test.ts @@ -0,0 +1,47 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import {extractThemeCodeMessages} from '../update'; +import path from 'path'; +import fs from 'fs-extra'; +import {mapValues} from 'lodash'; + +// Seems the 5s default timeout fails sometimes +jest.setTimeout(15000); + +describe('theme-translations package', () => { + test(`to have base messages files contain EXACTLY all the translations extracted from the theme. Please run "yarn workspace @docusaurus/theme-translations update" to keep base messages files up-to-date.`, async () => { + const baseMessagesDirPath = path.join(__dirname, '../locales/base'); + const baseMessages = Object.fromEntries( + ( + await Promise.all( + ( + await fs.readdir(baseMessagesDirPath) + ).map(async (baseMessagesFile) => + Object.entries( + JSON.parse( + ( + await fs.readFile( + path.join(baseMessagesDirPath, baseMessagesFile), + ) + ).toString(), + ) as Record, + ), + ), + ) + ) + .flat() + .filter(([key]) => !key.endsWith('___DESCRIPTION')), + ); + const codeMessages = mapValues( + await extractThemeCodeMessages(), + (translation) => translation.message, + ); + + expect(codeMessages).toEqual(baseMessages); + }); +}); diff --git a/packages/docusaurus-theme-translations/update.d.ts b/packages/docusaurus-theme-translations/update.d.ts new file mode 100644 index 000000000000..ff8c770de0f1 --- /dev/null +++ b/packages/docusaurus-theme-translations/update.d.ts @@ -0,0 +1,12 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import type {TranslationFileContent} from '@docusaurus/types'; + +export function extractThemeCodeMessages( + targetDirs?: string[], +): Promise; diff --git a/packages/docusaurus-theme-translations/update.test.js b/packages/docusaurus-theme-translations/update.test.js deleted file mode 100644 index 4872d64701a1..000000000000 --- a/packages/docusaurus-theme-translations/update.test.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const {extractThemeCodeMessages} = require('./update'); -const path = require('path'); -const fs = require('fs-extra'); -const {mapValues, pickBy} = require('lodash'); - -// Seems the 5s default timeout fails sometimes -jest.setTimeout(15000); - -describe('theme-translations package', () => { - test(`to have base messages files contain EXACTLY all the translations extracted from the theme. Please run "yarn workspace @docusaurus/theme-translations update" to keep base messages files up-to-date.`, async () => { - const baseMessagesDirPath = path.join(__dirname, 'locales/base'); - const baseMessages = pickBy( - await fs - .readdirSync(baseMessagesDirPath) - .reduce(async (messages, baseMessagesFile) => { - const newMessages = { - ...(await messages), - ...JSON.parse( - await fs.readFile( - path.join(baseMessagesDirPath, baseMessagesFile), - ), - ), - }; - return newMessages; - }, {}), - (_, key) => !key.endsWith('___DESCRIPTION'), - ); - const codeMessages = mapValues( - await extractThemeCodeMessages(), - (translation) => translation.message, - ); - - expect(codeMessages).toEqual(baseMessages); - }); -}); diff --git a/packages/stylelint-copyright/__tests__/index.js b/packages/stylelint-copyright/__tests__/index.test.js similarity index 100% rename from packages/stylelint-copyright/__tests__/index.js rename to packages/stylelint-copyright/__tests__/index.test.js diff --git a/yarn.lock b/yarn.lock index 2ef195a11253..b4b018290470 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6561,10 +6561,10 @@ color@^4.0.1: color-convert "^2.0.1" color-string "^1.6.0" -colord@^2.9.1: - version "2.9.1" - resolved "https://registry.yarnpkg.com/colord/-/colord-2.9.1.tgz#c961ea0efeb57c9f0f4834458f26cb9cc4a3f90e" - integrity sha512-4LBMSt09vR0uLnPVkOUBnmxgoaeN4ewRbx801wY/bXcltXfpR/G46OdWn96XpYmCWuYvO46aBZP4NgX8HpNAcw== +colord@^2.9.1, colord@^2.9.2: + version "2.9.2" + resolved "https://registry.yarnpkg.com/colord/-/colord-2.9.2.tgz#25e2bacbbaa65991422c07ea209e2089428effb1" + integrity sha512-Uqbg+J445nc1TKn4FoDPS6ZZqAvEDnwrH42yo8B40JSOgSLxMZ/gt3h4nmCtPLQeXhjJJkqBx7SCY35WnIixaQ== colorette@^2.0.10, colorette@^2.0.16: version "2.0.16" @@ -7415,10 +7415,10 @@ debug@3.1.0: dependencies: ms "2.0.0" -debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1, debug@^4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b" - integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw== +debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3: + version "4.3.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" + integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== dependencies: ms "2.1.2" @@ -10642,10 +10642,10 @@ ignore@^4.0.3, ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.1.1, ignore@^5.1.4, ignore@^5.1.8: - version "5.1.9" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.9.tgz#9ec1a5cbe8e1446ec60d4420060d43aa6e7382fb" - integrity sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ== +ignore@^5.1.1, ignore@^5.1.4, ignore@^5.1.8, ignore@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" + integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== image-q@^1.1.1: version "1.1.1" @@ -12194,6 +12194,11 @@ known-css-properties@^0.21.0: resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.21.0.tgz#15fbd0bbb83447f3ce09d8af247ed47c68ede80d" integrity sha512-sZLUnTqimCkvkgRS+kbPlYW5o8q5w1cu+uIisKpEWkj31I8mx8kNG162DwRav8Zirkva6N5uoFsm9kzK4mUXjw== +known-css-properties@^0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.24.0.tgz#19aefd85003ae5698a5560d2b55135bf5432155c" + integrity sha512-RTSoaUAfLvpR357vWzAz/50Q/BmHfmE6ETSWfutT0AJiw10e6CmcdYRQJlLRd95B53D0Y2aD1jSxD3V3ySF+PA== + kuler@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/kuler/-/kuler-2.0.0.tgz#e2c570a3800388fb44407e851531c1d670b061b3" @@ -15360,6 +15365,11 @@ postcss-safe-parser@^4.0.2: dependencies: postcss "^7.0.26" +postcss-safe-parser@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/postcss-safe-parser/-/postcss-safe-parser-6.0.0.tgz#bb4c29894171a94bc5c996b9a30317ef402adaa1" + integrity sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ== + postcss-sass@^0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/postcss-sass/-/postcss-sass-0.4.4.tgz#91f0f3447b45ce373227a98b61f8d8f0785285a3" @@ -15375,10 +15385,10 @@ postcss-scss@^2.1.1: dependencies: postcss "^7.0.6" -postcss-selector-parser@^6.0.2, postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.5: - version "6.0.6" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.6.tgz#2c5bba8174ac2f6981ab631a42ab0ee54af332ea" - integrity sha512-9LXrvaaX3+mcv5xkg5kFwqSzSH1JIObIx51PrndZwlmznwXRfxMddDvo9gve3gVR8ZTKgoFDdWkbRFmEhT4PMg== +postcss-selector-parser@^6.0.2, postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.5, postcss-selector-parser@^6.0.7: + version "6.0.8" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.8.tgz#f023ed7a9ea736cd7ef70342996e8e78645a7914" + integrity sha512-D5PG53d209Z1Uhcc0qAZ5U3t5HagH3cxu+WLZ22jt3gLUpXM4eXXfiO14jiDWST3NNooX/E8wISfOhZ9eIjGTQ== dependencies: cssesc "^3.0.0" util-deprecate "^1.0.2" @@ -18001,7 +18011,7 @@ stylehacks@^5.0.1: browserslist "^4.16.0" postcss-selector-parser "^6.0.4" -stylelint@^13.10.0, stylelint@^13.2.1: +stylelint@^13.2.1: version "13.13.1" resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-13.13.1.tgz#fca9c9f5de7990ab26a00f167b8978f083a18f3c" integrity sha512-Mv+BQr5XTUrKqAXmpqm6Ddli6Ief+AiPZkRsIrAoUKFuq/ElkUh9ZMYxXD0iQNZ5ADghZKLOWz1h7hTClB7zgQ== @@ -18055,6 +18065,51 @@ stylelint@^13.10.0, stylelint@^13.2.1: v8-compile-cache "^2.3.0" write-file-atomic "^3.0.3" +stylelint@^14.2.0: + version "14.2.0" + resolved "https://registry.yarnpkg.com/stylelint/-/stylelint-14.2.0.tgz#da4f0f4580e66911c38c376ed82447b78e32b0fb" + integrity sha512-i0DrmDXFNpDsWiwx6SPRs4/pyw4kvZgqpDGvsTslQMY7hpUl6r33aQvNSn6cnTg2wtZ9rreFElI7XAKpOWi1vQ== + dependencies: + balanced-match "^2.0.0" + colord "^2.9.2" + cosmiconfig "^7.0.1" + debug "^4.3.3" + execall "^2.0.0" + fast-glob "^3.2.7" + fastest-levenshtein "^1.0.12" + file-entry-cache "^6.0.1" + get-stdin "^8.0.0" + global-modules "^2.0.0" + globby "^11.0.4" + globjoin "^0.1.4" + html-tags "^3.1.0" + ignore "^5.2.0" + import-lazy "^4.0.0" + imurmurhash "^0.1.4" + is-plain-object "^5.0.0" + known-css-properties "^0.24.0" + mathml-tag-names "^2.1.3" + meow "^9.0.0" + micromatch "^4.0.4" + normalize-path "^3.0.0" + normalize-selector "^0.2.0" + picocolors "^1.0.0" + postcss "^8.3.11" + postcss-media-query-parser "^0.2.3" + postcss-resolve-nested-selector "^0.1.1" + postcss-safe-parser "^6.0.0" + postcss-selector-parser "^6.0.7" + postcss-value-parser "^4.1.0" + resolve-from "^5.0.0" + specificity "^0.4.1" + string-width "^4.2.3" + strip-ansi "^6.0.1" + style-search "^0.1.0" + svg-tags "^1.0.0" + table "^6.7.5" + v8-compile-cache "^2.3.0" + write-file-atomic "^3.0.3" + sugarss@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/sugarss/-/sugarss-2.0.0.tgz#ddd76e0124b297d40bf3cca31c8b22ecb43bc61d" @@ -18142,10 +18197,10 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -table@^6.6.0: - version "6.7.3" - resolved "https://registry.yarnpkg.com/table/-/table-6.7.3.tgz#255388439715a738391bd2ee4cbca89a4d05a9b7" - integrity sha512-5DkIxeA7XERBqMwJq0aHZOdMadBx4e6eDoFRuyT5VR82J0Ycg2DwM6GfA/EQAhJ+toRTaS1lIdSQCqgrmhPnlw== +table@^6.6.0, table@^6.7.5: + version "6.8.0" + resolved "https://registry.yarnpkg.com/table/-/table-6.8.0.tgz#87e28f14fa4321c3377ba286f07b79b281a3b3ca" + integrity sha512-s/fitrbVeEyHKFa7mFdkuQMWlH1Wgw/yEXMt5xACT4ZpzWFluehAxRtUUQKPuWhaLAWhFcVx6w3oC8VKaUfPGA== dependencies: ajv "^8.0.1" lodash.truncate "^4.4.2"