diff --git a/packages/ckeditor5-dev-env/tests/release-tools/utils/getchangedfilesforcommit.js b/packages/ckeditor5-dev-env/tests/release-tools/utils/getchangedfilesforcommit.js index 01f9b887a..c00339c95 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/utils/getchangedfilesforcommit.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/utils/getchangedfilesforcommit.js @@ -39,7 +39,7 @@ describe( 'dev-env/release-tools/utils/transform-commit', () => { } ); afterEach( () => { - fs.rmdirSync( path.join( tmpCwd, '.git' ), { recursive: true } ); + fs.rmSync( path.join( tmpCwd, '.git' ), { recursive: true } ); fs.readdirSync( tmpCwd ).forEach( file => fs.unlinkSync( file ) ); } ); diff --git a/packages/ckeditor5-dev-env/tests/release-tools/utils/getcommits.js b/packages/ckeditor5-dev-env/tests/release-tools/utils/getcommits.js index 910fdd513..a63f467ff 100644 --- a/packages/ckeditor5-dev-env/tests/release-tools/utils/getcommits.js +++ b/packages/ckeditor5-dev-env/tests/release-tools/utils/getcommits.js @@ -69,7 +69,7 @@ describe( 'dev-env/release-tools/utils', () => { afterEach( () => { process.chdir( cwd ); - fs.rmdirSync( path.join( tmpCwd, '.git' ), { recursive: true } ); + fs.rmSync( path.join( tmpCwd, '.git' ), { recursive: true } ); sandbox.restore(); mockery.disable(); diff --git a/packages/ckeditor5-dev-utils/lib/styles/themeimporter.js b/packages/ckeditor5-dev-utils/lib/styles/themeimporter.js index c21672892..909122fe6 100644 --- a/packages/ckeditor5-dev-utils/lib/styles/themeimporter.js +++ b/packages/ckeditor5-dev-utils/lib/styles/themeimporter.js @@ -22,16 +22,13 @@ const getPackageName = require( './utils/getpackagename' ); * to reflect the structure of the CSS files in editor packages, * * E.g., if the path to the theme is: - * - * "/foo/bar/ckeditor5-theme-foo/theme/theme.css" + * `/foo/bar/ckeditor5-theme-foo/theme/theme.css` * * and the CSS to be themed is: + * `/baz/qux/ckeditor5-qux/theme/components/button.css` * - * "/baz/qux/ckeditor5-qux/theme/components/button.css" - * - * the theme file for "button.css" should be located under - * - * "/foo/bar/ckeditor5-theme-foo/ckeditor5-qux/theme/components/button.css" + * the theme file for `button.css` should be located under: + * `/foo/bar/ckeditor5-theme-foo/ckeditor5-qux/theme/components/button.css` * * See the `ThemeImporterOptions` to learn about importer options. * @@ -41,30 +38,37 @@ const getPackageName = require( './utils/getpackagename' ); * @param {ThemeImporterOptions} pluginOptions * @returns {Function} A PostCSS plugin. */ -module.exports = postcss.plugin( 'postcss-ckeditor5-theme-importer', ( pluginOptions = {} ) => { - return ( root, result ) => { - // Clone the options, don't alter the original options object. - const options = Object.assign( {}, pluginOptions, { - debug: pluginOptions.debug || false, - postCssOptions: { - plugins: [ - require( 'postcss-import' )(), - require( './themelogger' )() - ] - }, - root, result - } ); +module.exports = ( pluginOptions = {} ) => { + return { + postcssPlugin: 'postcss-ckeditor5-theme-importer', + Once( root, { result } ) { + // Clone the options, don't alter the original options object. + const options = Object.assign( {}, pluginOptions, { + debug: pluginOptions.debug || false, + postCssOptions: { + plugins: [ + require( 'postcss-import' )(), + require( './themelogger' )() + ] + }, + root, result + } ); - return importThemeFile( options ); + return importThemeFile( options ); + } }; -} ); - -// Imports a complementary theme file corresponding with a CSS file being processed by -// PostCSS, if such theme file exists. -// -// @private -// @param {Options} Plugin options. -// @returns {Promise} +}; + +module.exports.postcss = true; + +/** + * Imports a complementary theme file corresponding with a CSS file being processed by + * PostCSS, if such theme file exists. + * + * @private + * @param {Options} Plugin options. + * @returns {Promise} + */ function importThemeFile( options ) { const inputFilePath = options.root.source.input.file; @@ -83,12 +87,14 @@ function importThemeFile( options ) { } } -// Imports a CSS file specified in the options using the postcss-import -// plugin and appends its content to the css tree (root). -// -// @private -// @param {Options} Plugin options. -// @returns {Promise} +/** + * Imports a CSS file specified in the options using the postcss-import + * plugin and appends its content to the css tree (root). + * + * @private + * @param {Options} Plugin options. + * @returns {Promise} + */ function importFile( options ) { const { root, result, sourceMap } = options; const file = options.fileToImport; @@ -134,29 +140,24 @@ function importFile( options ) { } ); } -// For given: -// -// * path to the theme, -// * and path to the CSS file processed by PostCSS, -// -// it returns a path to the complementary file in the theme. -// -// E.g., if the path to the theme is: -// -// "/foo/bar/ckeditor5-theme-foo/theme/theme.css" -// -// and the CSS to be themed is: -// -// "/baz/qux/ckeditor5-qux/theme/components/button.css" -// -// this helper will return: -// -// "/foo/bar/ckeditor5-theme-foo/ckeditor5-qux/theme/components/button.css" -// -// @private -// @param {String} themePath Path to the theme. -// @param {String} inputFilePath Path to the CSS file which is to be themed. -// @returns {String} +/** + * For given path to the theme, and a path to the CSS file processed by + * PostCSS, it returns a path to the complementary file in the theme. + * + * E.g., if the path to the theme is: + * `/foo/bar/ckeditor5-theme-foo/theme/theme.css` + * + * and the CSS to be themed is: + * `/baz/qux/ckeditor5-qux/theme/components/button.css` + * + * this helper will return: + * `/foo/bar/ckeditor5-theme-foo/ckeditor5-qux/theme/components/button.css` + * + * @private + * @param {String} themePath Path to the theme. + * @param {String} inputFilePath Path to the CSS file which is to be themed. + * @returns {String} + */ function getThemeFilePath( themePath, inputFilePath ) { // ckeditor5-theme-foo/theme/theme.css -> ckeditor5-theme-foo/theme themePath = path.dirname( themePath ); diff --git a/packages/ckeditor5-dev-utils/lib/styles/themelogger.js b/packages/ckeditor5-dev-utils/lib/styles/themelogger.js index 2811b8e49..b419a8fc8 100644 --- a/packages/ckeditor5-dev-utils/lib/styles/themelogger.js +++ b/packages/ckeditor5-dev-utils/lib/styles/themelogger.js @@ -5,16 +5,19 @@ 'use strict'; -/* eslint-env node */ - -const postcss = require( 'postcss' ); - /** * A plugin that prepends a path to the file in the comment for each file * processed by PostCSS. * * @returns {Function} A PostCSS plugin. */ -module.exports = postcss.plugin( 'postcss-ckeditor5-theme-logger', () => { - return root => root.prepend( `/* ${ root.source.input.file } */ \n` ); -} ); +module.exports = () => { + return { + postcssPlugin: 'postcss-ckeditor5-theme-logger', + Once( root ) { + root.prepend( `/* ${ root.source.input.file } */ \n` ); + } + }; +}; + +module.exports.postcss = true; diff --git a/packages/ckeditor5-dev-utils/package.json b/packages/ckeditor5-dev-utils/package.json index ef50eb015..b7e11e066 100644 --- a/packages/ckeditor5-dev-utils/package.json +++ b/packages/ckeditor5-dev-utils/package.json @@ -18,11 +18,10 @@ "is-interactive": "^1.0.0", "javascript-stringify": "^1.6.0", "pofile": "^1.0.9", - "postcss": "^7.0.39", - "postcss-import": "^12.0.0", - "postcss-loader": "^3.0.0", - "postcss-mixins": "^6.2.0", - "postcss-nesting": "^7.0.0", + "postcss-import": "^14.0.2", + "postcss-loader": "^4.3.0", + "postcss-mixins": "^6.2.3", + "postcss-nesting": "^7.0.1", "raw-loader": "^4.0.1", "shelljs": "^0.8.1", "style-loader": "^2.0.0", @@ -38,6 +37,7 @@ "vinyl": "^2.1.0" }, "peerDependencies": { + "postcss": "^8.4.12", "webpack": "^4.43.0 || ^5.24.0" }, "engines": { diff --git a/packages/ckeditor5-dev-utils/tests/stream.js b/packages/ckeditor5-dev-utils/tests/stream.js index ed6d7b8bd..662bf834e 100644 --- a/packages/ckeditor5-dev-utils/tests/stream.js +++ b/packages/ckeditor5-dev-utils/tests/stream.js @@ -97,7 +97,7 @@ describe( 'stream', () => { const file = new Vinyl( { cwd: './', path, - contents: new Buffer( '' ) + contents: Buffer.from( '' ) } ); expect( utils.isTestFile( file ) ).to.equal( expected ); diff --git a/yarn.lock b/yarn.lock index 8cb30100c..26e1a1333 100644 --- a/yarn.lock +++ b/yarn.lock @@ -848,12 +848,7 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ajv-errors@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d" - integrity sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ== - -ajv-keywords@^3.1.0, ajv-keywords@^3.5.2: +ajv-keywords@^3.5.2: version "3.5.2" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== @@ -868,7 +863,7 @@ ajv@^5.0.0: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" -ajv@^6.1.0, ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: +ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -3746,13 +3741,6 @@ immutable@^4.0.0: resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.0.0.tgz#b86f78de6adef3608395efb269a91462797e2c23" integrity sha512-zIE9hX70qew5qTUjSS7wi1iwj/l7+m54KWU247nhM3v806UdGj1yDndXj+IOYxxtW9zyLI+xqFNZjTuDaLUqFw== -import-cwd@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9" - integrity sha1-qmzzbnInYShcs3HsZRn1PiQ1sKk= - dependencies: - import-from "^2.1.0" - import-fresh@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546" @@ -3769,13 +3757,6 @@ import-fresh@^3.0.0, import-fresh@^3.2.1: parent-module "^1.0.0" resolve-from "^4.0.0" -import-from@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/import-from/-/import-from-2.1.0.tgz#335db7f2a7affd53aaa471d4b8021dee36b7f3b1" - integrity sha1-M1238qev/VOqpHHUuAId7ja387E= - dependencies: - resolve-from "^3.0.0" - imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -5925,13 +5906,12 @@ postcss-discard-overridden@^4.0.1: dependencies: postcss "^7.0.0" -postcss-import@^12.0.0: - version "12.0.1" - resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-12.0.1.tgz#cf8c7ab0b5ccab5649024536e565f841928b7153" - integrity sha512-3Gti33dmCjyKBgimqGxL3vcV8w9+bsHwO5UrBawp796+jdardbcFl4RP5w/76BwNL7aGzpKstIfF9I+kdE8pTw== +postcss-import@^14.0.2: + version "14.0.2" + resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-14.0.2.tgz#60eff77e6be92e7b67fe469ec797d9424cae1aa1" + integrity sha512-BJ2pVK4KhUyMcqjuKs9RijV5tatNzNa73e/32aBVE/ejYPe37iH+6vAu9WvqUkB5OAYgLHzbSvzHnorybJCm9g== dependencies: - postcss "^7.0.1" - postcss-value-parser "^3.2.3" + postcss-value-parser "^4.0.0" read-cache "^1.0.0" resolve "^1.1.7" @@ -5943,24 +5923,6 @@ postcss-js@^2.0.3: camelcase-css "^2.0.1" postcss "^7.0.18" -postcss-load-config@^2.0.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-2.1.2.tgz#c5ea504f2c4aef33c7359a34de3573772ad7502a" - integrity sha512-/rDeGV6vMUo3mwJZmeHfEDvwnTKKqQ0S7OHUi/kJvvtx3aWtyWG2/0ZWnzCt2keEclwN6Tf0DST2v9kITdOKYw== - dependencies: - cosmiconfig "^5.0.0" - import-cwd "^2.0.0" - -postcss-loader@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-3.0.0.tgz#6b97943e47c72d845fa9e03f273773d4e8dd6c2d" - integrity sha512-cLWoDEY5OwHcAjDnkyRQzAXfs2jrKjXpO/HQFcc5b5u/r7aa471wdmChmwfnv7x2u840iat/wi0lQ5nbRgSkUA== - dependencies: - loader-utils "^1.1.0" - postcss "^7.0.0" - postcss-load-config "^2.0.0" - schema-utils "^1.0.0" - postcss-loader@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-4.3.0.tgz#2c4de9657cd4f07af5ab42bd60a673004da1b8cc" @@ -6084,7 +6046,7 @@ postcss-minify-selectors@^4.0.2: postcss "^7.0.0" postcss-selector-parser "^3.0.0" -postcss-mixins@^6.2.0: +postcss-mixins@^6.2.3: version "6.2.3" resolved "https://registry.yarnpkg.com/postcss-mixins/-/postcss-mixins-6.2.3.tgz#021893ba455d04b5baa052bf196297ddd70e4af1" integrity sha512-gfH5d09YilzDn/CLGFA9Lwv7GTezuyHgnAyXC8AfvhUMpl67ZTewhcpNuOgawClCOD+76XePE2IHO1xMgsOlvA== @@ -6123,7 +6085,7 @@ postcss-modules-values@^4.0.0: dependencies: icss-utils "^5.0.0" -postcss-nesting@^7.0.0: +postcss-nesting@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/postcss-nesting/-/postcss-nesting-7.0.1.tgz#b50ad7b7f0173e5b5e3880c3501344703e04c052" integrity sha512-FrorPb0H3nuVq0Sff7W2rnc3SmIcruVC6YwpcS+k687VxyxO33iE1amna7wHuRVzM8vfiYofXSBHNAZ3QhLvYg== @@ -6383,17 +6345,17 @@ postcss-unique-selectors@^4.0.1: postcss "^7.0.0" uniqs "^2.0.0" -postcss-value-parser@^3.0.0, postcss-value-parser@^3.2.3: +postcss-value-parser@^3.0.0: version "3.3.1" resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281" integrity sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ== -postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: +postcss-value-parser@^4.0.0, postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.18, postcss@^7.0.2, postcss@^7.0.21, postcss@^7.0.27, postcss@^7.0.39: +postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.18, postcss@^7.0.2, postcss@^7.0.21, postcss@^7.0.27: version "7.0.39" resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.39.tgz#9624375d965630e2e1f2c02a935c82a59cb48309" integrity sha512-yioayjNbHn6z1/Bywyb2Y4s3yvDAeXGOyxqD+LnVOinq6Mdmd++SW2wUNVzavyyHxd6+DxzWGIuosg6P1Rj8uA== @@ -6909,15 +6871,6 @@ schema-utils@^0.3.0: dependencies: ajv "^5.0.0" -schema-utils@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770" - integrity sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g== - dependencies: - ajv "^6.1.0" - ajv-errors "^1.0.0" - ajv-keywords "^3.1.0" - schema-utils@^2.6.5: version "2.7.1" resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"