From e88adfb9fab1b694bc33cf563d2809290fbe38e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Mar 2022 22:21:37 +0800 Subject: [PATCH] Build(deps): Bump html-void-elements from 1.0.5 to 2.0.0 (#10623) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: fisker Cheung --- package.json | 2 +- scripts/vendors/bundle-vendors.mjs | 33 ++++++++++++++++++++++-------- scripts/vendors/vendor-meta.json | 23 +++++++++++++++++++++ scripts/vendors/vendors.mjs | 9 +++++++- src/language-handlebars/utils.js | 2 +- vendors/html-void-elements.json | 27 ++++++++++++++++++++++++ yarn.lock | 8 ++++---- 7 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 vendors/html-void-elements.json diff --git a/package.json b/package.json index dd4b8d486..bc7731ce2 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "html-element-attributes": "2.3.0", "html-styles": "1.0.0", "html-tag-names": "1.1.5", - "html-void-elements": "1.0.5", + "html-void-elements": "2.0.1", "ignore": "5.2.0", "jest-docblock": "27.5.1", "json5": "2.2.1", diff --git a/scripts/vendors/bundle-vendors.mjs b/scripts/vendors/bundle-vendors.mjs index 992ca3ce3..8b17a9583 100644 --- a/scripts/vendors/bundle-vendors.mjs +++ b/scripts/vendors/bundle-vendors.mjs @@ -1,11 +1,12 @@ #!/usr/bin/env node import fs from "node:fs/promises"; +import assert from "node:assert"; import { fileURLToPath } from "node:url"; import createEsmUtils from "esm-utils"; import esbuild from "esbuild"; import { outdent } from "outdent"; -import { PROJECT_ROOT } from "../utils/index.mjs"; +import { PROJECT_ROOT, writeJson } from "../utils/index.mjs"; import esbuildPluginLicense from "../build/esbuild-plugins/license.mjs"; import vendors from "./vendors.mjs"; import { vendorMetaFile, saveVendorLicenses } from "./utils.mjs"; @@ -16,8 +17,18 @@ const rootDir = new URL("../../", import.meta.url); // prettier/vendors const vendorsDir = new URL("./vendors/", rootDir); // prettier/vendors/*.js -const getVendorFilePath = (vendorName) => - fileURLToPath(new URL(`./${vendorName}.js`, vendorsDir)); +const getVendorFilePath = (vendorName, extension = "js") => + fileURLToPath(new URL(`./${vendorName}.${extension}`, vendorsDir)); + +// Unsafe, but good enough for now. +const isJson = (value) => { + try { + assert.deepStrictEqual(JSON.parse(JSON.stringify(value)), { ...value }); + return true; + } catch { + return false; + } +}; async function clean() { for (const directoryOrFile of [vendorsDir, vendorMetaFile]) { @@ -29,10 +40,8 @@ async function clean() { } } -async function generateDts(vendor) { - const hasDefault = await import(vendor).then((module) => - Boolean(module.default) - ); +async function generateDts({ vendor, module }) { + const hasDefault = Boolean(module.default); await fs.writeFile( new URL(`${vendor}.d.ts`, vendorsDir), [ @@ -70,7 +79,15 @@ async function bundle(vendor, options) { }; await esbuild.build(esbuildOption); - await generateDts(vendor); + // Still running esbuild, because we want collect license + const module = await import(vendor); + if (isJson(module)) { + await fs.rm(outfile); + await writeJson(getVendorFilePath(vendor, "json"), module); + return; + } + + await generateDts({ vendor, module }); } async function main() { diff --git a/scripts/vendors/vendor-meta.json b/scripts/vendors/vendor-meta.json index 7002ff55c..4cae144b2 100644 --- a/scripts/vendors/vendor-meta.json +++ b/scripts/vendors/vendor-meta.json @@ -1491,6 +1491,29 @@ "licenseText": "MIT License\n\nCopyright (c) Sindre Sorhus (https://sindresorhus.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", "author": null, "contributors": [] + }, + { + "name": "html-void-elements", + "maintainers": [], + "version": "2.0.1", + "description": "List of HTML void tag names", + "repository": "wooorm/html-void-elements", + "homepage": null, + "private": false, + "license": "MIT", + "licenseText": "(The MIT License)\n\nCopyright (c) 2016 Titus Wormer \n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n", + "author": { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "https://wooorm.com" + }, + "contributors": [ + { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "https://wooorm.com" + } + ] } ] } diff --git a/scripts/vendors/vendors.mjs b/scripts/vendors/vendors.mjs index 46a67f445..26f75ad0f 100644 --- a/scripts/vendors/vendors.mjs +++ b/scripts/vendors/vendors.mjs @@ -1,3 +1,10 @@ -const vendors = ["string-width", "mem", "execa", "tempy", "chalk"]; +const vendors = [ + "string-width", + "mem", + "execa", + "tempy", + "chalk", + "html-void-elements", +]; export default vendors; diff --git a/src/language-handlebars/utils.js b/src/language-handlebars/utils.js index abcf1a968..b6bc2f57f 100644 --- a/src/language-handlebars/utils.js +++ b/src/language-handlebars/utils.js @@ -1,6 +1,6 @@ "use strict"; -const htmlVoidElements = require("html-void-elements"); +const { htmlVoidElements } = require("../../vendors/html-void-elements.json"); const getLast = require("../utils/get-last.js"); function isLastNodeOfSiblings(path) { diff --git a/vendors/html-void-elements.json b/vendors/html-void-elements.json new file mode 100644 index 000000000..f20eebfdf --- /dev/null +++ b/vendors/html-void-elements.json @@ -0,0 +1,27 @@ +{ + "htmlVoidElements": [ + "area", + "base", + "basefont", + "bgsound", + "br", + "col", + "command", + "embed", + "frame", + "hr", + "image", + "img", + "input", + "isindex", + "keygen", + "link", + "menuitem", + "meta", + "nextid", + "param", + "source", + "track", + "wbr" + ] +} diff --git a/yarn.lock b/yarn.lock index e316f1695..eba705f9a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3618,10 +3618,10 @@ html-tag-names@1.1.5: resolved "https://registry.yarnpkg.com/html-tag-names/-/html-tag-names-1.1.5.tgz#f537420c16769511283f8ae1681785fbc89ee0a9" integrity sha512-aI5tKwNTBzOZApHIynaAwecLBv8TlZTEy/P4Sj2SzzAhBrGuI8yGZ0UIXVPQzOHGS+to2mjb04iy6VWt/8+d8A== -html-void-elements@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/html-void-elements/-/html-void-elements-1.0.5.tgz#ce9159494e86d95e45795b166c2021c2cfca4483" - integrity sha512-uE/TxKuyNIcx44cIWnjr/rfIATDH7ZaOMmstu0CwhFG1Dunhlp4OC6/NMbhiwoq5BpW0ubi303qnEk/PZj614w== +html-void-elements@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/html-void-elements/-/html-void-elements-2.0.1.tgz#29459b8b05c200b6c5ee98743c41b979d577549f" + integrity sha512-0quDb7s97CfemeJAnW9wC0hw78MtW7NU3hqtCD75g2vFlDLt36llsYD7uB7SUzojLMP24N5IatXf7ylGXiGG9A== http-proxy-agent@^4.0.1: version "4.0.1"