-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[html coverage] Add vendored package #7528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+4,567
−3
Merged
Changes from 36 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
731d409
mvp
ChristopherDedominici 4088b56
istanbul libCoverage: copy original js file in root assets folder
ChristopherDedominici e3d52e3
libReport
ChristopherDedominici 4dae722
report
ChristopherDedominici d002919
remove dependencies from istanbul in coverage-manager
ChristopherDedominici 95f8d9a
add 'node:' to imports
ChristopherDedominici f3e276f
replace import to istanbul with internal assets
ChristopherDedominici c77eb8d
remove unused library
ChristopherDedominici 7771d9f
replace html escape package
ChristopherDedominici 029bc26
replace make-dir with fs/promises
ChristopherDedominici 9be67d5
remove dependencies from istanbul npm packages
ChristopherDedominici 3a55628
base package
ChristopherDedominici cc5cb6a
move js istanbul libs in the new package
ChristopherDedominici 1856995
add postbuild script and re-organize coverage-manager
ChristopherDedominici e646399
exclude js, cjs, css, png from the gitignore
ChristopherDedominici 3047483
rename to hardhat-vendored
ChristopherDedominici c8ea036
exclude from gitignore
ChristopherDedominici 39ce891
delete test file
ChristopherDedominici c6f1e72
remove dist folder
ChristopherDedominici f78a224
fix package name and imports
ChristopherDedominici b28430a
rename folder to avoid gitignore
ChristopherDedominici 8c92ef9
fix copy-assets
ChristopherDedominici 022c6ae
fix exports after changing folder name
ChristopherDedominici a50b3b8
show colored lines in coverage report
ChristopherDedominici 0b89710
update tsconfig in new vendored package
ChristopherDedominici 50f3b4c
minor fixes
ChristopherDedominici f3591e7
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici d0fba8e
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici 3602408
lint:fix
ChristopherDedominici 006f834
Create gorgeous-swans-try.md
ChristopherDedominici f771d34
ignore spelling in vendored package src code
ChristopherDedominici 7724608
Merge branch 'html-coverage' of github.com:NomicFoundation/hardhat in…
ChristopherDedominici 9dde2ee
remove dependency from @nomicfoundation/hardhat-node-test-reporter
ChristopherDedominici 7542cdc
add reference to test reporter
ChristopherDedominici 8ed50de
Merge branch 'html-coverage' of github.com:NomicFoundation/hardhat in…
ChristopherDedominici f264363
add hardhat-node-test-reporter in package.json
ChristopherDedominici b26e193
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici af8b2df
Merge branch 'main' of github.com:NomicFoundation/hardhat into html-c…
ChristopherDedominici bad0838
remove code related to the `hardhat` package
ChristopherDedominici aed7c4f
modify changeset
ChristopherDedominici 392f8f9
add comment to justify empty test file
ChristopherDedominici b94e610
update pnpm.lock file
ChristopherDedominici fe70838
remove changeset as it is no longer needed
ChristopherDedominici a95f391
add file with vendored code info
ChristopherDedominici 92745d1
Update v-next/hardhat-vendored/package.json
ChristopherDedominici 2f7542a
include `VENDORED.md` in files property in package.json + add licenses
ChristopherDedominici e46739a
rename folders to match original packages
ChristopherDedominici 608ccbc
fix imports
ChristopherDedominici b0deb23
Merge branch 'html-coverage' of github.com:NomicFoundation/hardhat in…
ChristopherDedominici b36dca7
add comment mentioning license in every file
ChristopherDedominici 7309dcb
remove superfluous licenses and update license text in files
ChristopherDedominici c2f00cc
update missing license link comments
ChristopherDedominici 8d86a11
add `private` to package.json
ChristopherDedominici 5975fb2
chore: add `hardhat-vendored` exclusion releasable list
kanej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@nomicfoundation/hardhat": minor | ||
| "@nomicfoundation/hardhat-vendored": patch | ||
| --- | ||
|
|
||
| Added HTML coverage reporting and a new internal `hardhat-vendored` package ([7528](https://github.com/NomicFoundation/hardhat/pull/7528)). | ||
ChristopherDedominici marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ ignorePaths: | |
| - .github/config/regression-tests.yml | ||
| - archive/** | ||
| - pnpm-lock.yaml | ||
| - v-next/hardhat-vendored/src | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Node modules | ||
| /node_modules | ||
|
|
||
| # Compilation output | ||
| /dist | ||
|
|
||
| # pnpm deploy output | ||
| /bundle | ||
|
|
||
| # test coverage output | ||
| coverage | ||
|
|
||
| # all the tmp folders in the fixture projects | ||
| /test/fixture-projects/tmp/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /node_modules | ||
| /dist | ||
| /coverage | ||
| CHANGELOG.md | ||
| /test/fixture-projects/**/artifacts | ||
| /test/fixture-projects/**/cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 Nomic Foundation | ||
|
|
||
| Permission 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: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
|
||
| THE 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # hardhat-vendored | ||
|
|
||
| > ⚠️ This package is an internal Hardhat component and it's not meant to be used directly. | ||
|
|
||
| This package contains vendored code used by Hardhat 3 and its plugins. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { createConfig } from "../config/eslint.config.js"; | ||
|
|
||
| export default createConfig(import.meta.filename, { onlyHardhatError: false }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| { | ||
| "name": "@nomicfoundation/hardhat-vendored", | ||
| "version": "3.0.0", | ||
| "description": "Internal dependencies used by Hardhat that have been vendored to prevent bloating the main package", | ||
| "homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-vendored", | ||
ChristopherDedominici marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/NomicFoundation/hardhat", | ||
| "directory": "v-next/hardhat-vendored" | ||
| }, | ||
| "author": "Nomic Foundation", | ||
| "license": "MIT", | ||
| "type": "module", | ||
| "exports": { | ||
| "./coverage": "./dist/src/coverage-module/index.js", | ||
| "./coverage/types": "./dist/src/coverage-module/types.js" | ||
| }, | ||
| "keywords": [ | ||
| "hardhat" | ||
| ], | ||
| "scripts": { | ||
| "lint": "pnpm prettier --check && pnpm eslint", | ||
| "lint:fix": "pnpm prettier --write && pnpm eslint --fix", | ||
| "eslint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"", | ||
| "prettier": "prettier \"**/*.{ts,js,md,json}\"", | ||
| "test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", | ||
| "test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", | ||
| "test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"", | ||
| "pretest": "pnpm build", | ||
| "pretest:only": "pnpm build", | ||
| "build": "tsc --build .", | ||
| "postbuild": "node dist/src/copy-assets.js", | ||
ChristopherDedominici marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "prepublishOnly": "pnpm build", | ||
| "clean": "rimraf dist" | ||
| }, | ||
| "files": [ | ||
| "dist/src/", | ||
| "src/", | ||
| "CHANGELOG.md", | ||
| "LICENSE", | ||
| "README.md" | ||
| ], | ||
| "devDependencies": { | ||
| "@nomicfoundation/hardhat-node-test-reporter": "workspace:^3.0.0", | ||
| "@types/bn.js": "^5.1.5", | ||
| "@types/debug": "^4.1.7", | ||
| "@types/node": "^20.14.9", | ||
| "c8": "^9.1.0", | ||
| "eslint": "9.25.1", | ||
| "expect-type": "^1.2.1", | ||
| "prettier": "3.2.5", | ||
| "rimraf": "^5.0.5", | ||
| "tsx": "^4.19.3", | ||
| "typescript": "~5.8.0" | ||
| }, | ||
| "dependencies": {} | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { cp } from "node:fs/promises"; | ||
ChristopherDedominici marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import path from "node:path"; | ||
|
|
||
| async function copyFolder(from: string, to: string): Promise<void> { | ||
| const src = path.resolve(from); | ||
| const dest = path.resolve(to); | ||
|
|
||
| await cp(src, dest, { recursive: true, force: true }); | ||
| console.log(`Copied folder from ${src} -> ${dest}`); | ||
| } | ||
|
|
||
| // eslint-disable-next-line no-restricted-syntax -- allow in this post build script | ||
| await copyFolder( | ||
| path.resolve( | ||
| process.cwd(), | ||
| "src", | ||
| "coverage-module", | ||
| "istanbul-reports", | ||
| "lib", | ||
| "html", | ||
| "assets", | ||
| ), | ||
| path.resolve( | ||
| process.cwd(), | ||
| "dist", | ||
| "src", | ||
| "coverage-module", | ||
| "istanbul-reports", | ||
| "lib", | ||
| "html", | ||
| "assets", | ||
| ), | ||
| ); | ||
24 changes: 24 additions & 0 deletions
24
v-next/hardhat-vendored/src/coverage-module/html-escaper/index.cjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| const { replace } = ""; | ||
|
|
||
| // escape | ||
| const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; | ||
| const ca = /[&<>'"]/g; | ||
|
|
||
| const esca = { | ||
| "&": "&", | ||
| "<": "<", | ||
| ">": ">", | ||
| "'": "'", | ||
| '"': """, | ||
| }; | ||
| const pe = (m) => esca[m]; | ||
|
|
||
| /** | ||
| * Safely escape HTML entities such as `&`, `<`, `>`, `"`, and `'`. | ||
| * @param {string} es the input to safely escape | ||
| * @returns {string} the escaped input, and it **throws** an error if | ||
| * the input type is unexpected, except for boolean and numbers, | ||
| * converted as string. | ||
| */ | ||
| const escape = (es) => replace.call(es, ca, pe); | ||
| exports.escape = escape; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import libCoverage from "./lib-coverage/index.cjs"; | ||
| export { libCoverage }; | ||
|
|
||
| import libReport from "./lib-report/index.cjs"; | ||
| export { libReport }; | ||
|
|
||
| import reports from "./istanbul-reports/index.cjs"; | ||
| export { reports }; |
24 changes: 24 additions & 0 deletions
24
v-next/hardhat-vendored/src/coverage-module/istanbul-reports/index.cjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| "use strict"; | ||
| /* | ||
| Copyright 2012-2015, Yahoo Inc. | ||
| Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. | ||
| */ | ||
| const path = require("node:path"); | ||
|
|
||
| module.exports = { | ||
| create(name, cfg) { | ||
| cfg = cfg || {}; | ||
| let Cons; | ||
| try { | ||
| Cons = require(path.join(__dirname, "lib", name, "index.cjs")); | ||
| } catch (e) { | ||
| if (e.code !== "MODULE_NOT_FOUND") { | ||
| throw e; | ||
| } | ||
|
|
||
| Cons = require(name); | ||
| } | ||
|
|
||
| return new Cons(cfg); | ||
| }, | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.