Commit 3d2b2986 authored by indeavr's avatar indeavr

feat: Slight improvement to the console output

parent 23920658
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
"postpublish": "rimraf chugsplash L1 L2 libraries standards", "postpublish": "rimraf chugsplash L1 L2 libraries standards",
"prepack": "yarn prepublishOnly", "prepack": "yarn prepublishOnly",
"postpack": "yarn postpublish", "postpack": "yarn postpublish",
"pre-commit": "lint-staged" "pre-commit": "lint-staged",
"docify": "ts-node scripts/generate-docs.ts"
}, },
"keywords": [ "keywords": [
"optimism", "optimism",
...@@ -62,7 +63,8 @@ ...@@ -62,7 +63,8 @@
"@ethersproject/abstract-provider": "^5.4.1", "@ethersproject/abstract-provider": "^5.4.1",
"@ethersproject/abstract-signer": "^5.4.1", "@ethersproject/abstract-signer": "^5.4.1",
"@ethersproject/hardware-wallets": "^5.4.0", "@ethersproject/hardware-wallets": "^5.4.0",
"@primitivefi/hardhat-dodoc": "^0.1.3" "@primitivefi/hardhat-dodoc": "^0.1.3",
"chalk": "^4.1.2"
}, },
"devDependencies": { "devDependencies": {
"@codechecks/client": "^0.1.11", "@codechecks/client": "^0.1.11",
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { task } from 'hardhat/config' import { task } from 'hardhat/config'
import { CompilerOutputContractWithDocumentation } from '@primitivefi/hardhat-dodoc/dist/src/dodocTypes' import { CompilerOutputContractWithDocumentation } from '@primitivefi/hardhat-dodoc/dist/src/dodocTypes'
import { TASK_COMPILE } from 'hardhat/builtin-tasks/task-names' import { TASK_COMPILE } from 'hardhat/builtin-tasks/task-names'
import chalk from "chalk";
// import { CompilerOutputContractWithDocumentation, Doc } from './dodocTypes'; // import { CompilerOutputContractWithDocumentation, Doc } from './dodocTypes';
// import { decodeAbi } from './abiDecoder'; // import { decodeAbi } from './abiDecoder';
...@@ -63,7 +64,7 @@ const setupErrors = ...@@ -63,7 +64,7 @@ const setupErrors =
} }
} }
return `Error in ${fileName} at path: ${fileSource}\n ---> ${typeToMessage()}` return `Error: ${typeToMessage()}\n @ ${fileName} \n --> ${fileSource}\n`
} }
type CompilerOutputWithDocsAndPath = CompilerOutputContractWithDocumentation & { type CompilerOutputWithDocsAndPath = CompilerOutputContractWithDocumentation & {
...@@ -88,16 +89,7 @@ task(TASK_COMPILE, async (args, hre, runSuper) => { ...@@ -88,16 +89,7 @@ task(TASK_COMPILE, async (args, hre, runSuper) => {
// return; // return;
// } // }
console.log('<<< Starting Output Checks >>> ')
const allContracts = await hre.artifacts.getAllFullyQualifiedNames()
// console.log("allContracts", allContracts);
const qualifiedNames = allContracts.filter((str) =>
str.startsWith('contracts')
)
console.log('qualifiedNames', qualifiedNames)
// Loops through all the qualified names to get all the compiled contracts // Loops through all the qualified names to get all the compiled contracts
const getBuildInfo = async ( const getBuildInfo = async (
qualifiedName: string qualifiedName: string
): Promise<CompilerOutputWithDocsAndPath | undefined> => { ): Promise<CompilerOutputWithDocsAndPath | undefined> => {
...@@ -217,6 +209,15 @@ task(TASK_COMPILE, async (args, hre, runSuper) => { ...@@ -217,6 +209,15 @@ task(TASK_COMPILE, async (args, hre, runSuper) => {
return foundErrors return foundErrors
} }
console.log('<<< Starting Output Checks >>> ')
const allContracts = await hre.artifacts.getAllFullyQualifiedNames()
// console.log("allContracts", allContracts);
const qualifiedNames = allContracts.filter((str) =>
str.startsWith('contracts')
)
console.log('qualifiedNames', qualifiedNames)
// 1. Setup // 1. Setup
const buildInfo: CompilerOutputWithDocsAndPath[] = ( const buildInfo: CompilerOutputWithDocsAndPath[] = (
await Promise.all(qualifiedNames.map(getBuildInfo)) await Promise.all(qualifiedNames.map(getBuildInfo))
...@@ -225,7 +226,6 @@ task(TASK_COMPILE, async (args, hre, runSuper) => { ...@@ -225,7 +226,6 @@ task(TASK_COMPILE, async (args, hre, runSuper) => {
// 2. Check // 2. Check
const errors = buildInfo.reduce((foundErrors, info) => { const errors = buildInfo.reduce((foundErrors, info) => {
const docErrors = checkForErrors(info) const docErrors = checkForErrors(info)
console.log('DOC ERRORS: ', docErrors)
if (docErrors && docErrors.length > 0) { if (docErrors && docErrors.length > 0) {
foundErrors[info.filePath] = docErrors foundErrors[info.filePath] = docErrors
...@@ -242,9 +242,9 @@ task(TASK_COMPILE, async (args, hre, runSuper) => { ...@@ -242,9 +242,9 @@ task(TASK_COMPILE, async (args, hre, runSuper) => {
if (errorsInfo && errorsInfo.length > 0) { if (errorsInfo && errorsInfo.length > 0) {
;(errorsInfo as ErrorInfo[]).forEach((erIn) => { ;(errorsInfo as ErrorInfo[]).forEach((erIn) => {
if ((level === 'error')) { if ((level === 'error')) {
console.error(erIn.text) console.error(chalk.red(erIn.text))
} else { } else {
console.warn(erIn.text) console.warn(chalk.yellow(erIn.text))
} }
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment