@@ -26,6 +26,7 @@ import {
26
26
} from "@ignored/hardhat-vnext-errors" ;
27
27
import { isCi } from "@ignored/hardhat-vnext-utils/ci" ;
28
28
import { kebabToCamelCase } from "@ignored/hardhat-vnext-utils/string" ;
29
+ import debug from "debug" ;
29
30
30
31
import { resolveHardhatConfigPath } from "../../config.js" ;
31
32
import { createHardhatRuntimeEnvironment } from "../../hre.js" ;
@@ -45,18 +46,26 @@ export async function main(
45
46
cliArguments : string [ ] ,
46
47
print : ( message : string ) => void = console . log ,
47
48
) : Promise < void > {
49
+ const log = debug ( "hardhat:core:cli:main" ) ;
50
+
48
51
let builtinGlobalOptions ;
49
52
53
+ log ( "Hardhat CLI started with arguments:" , cliArguments ) ;
54
+
50
55
try {
51
56
const usedCliArguments : boolean [ ] = new Array ( cliArguments . length ) . fill (
52
57
false ,
53
58
) ;
54
59
60
+ log ( "Parsing builtin global options" ) ;
61
+
55
62
builtinGlobalOptions = await parseBuiltinGlobalOptions (
56
63
cliArguments ,
57
64
usedCliArguments ,
58
65
) ;
59
66
67
+ log ( "Parsed builtin global options:" , builtinGlobalOptions ) ;
68
+
60
69
if ( builtinGlobalOptions . version ) {
61
70
return await printVersionMessage ( print ) ;
62
71
}
@@ -65,15 +74,27 @@ export async function main(
65
74
return await initHardhat ( ) ;
66
75
}
67
76
77
+ log ( "Checking telemetry consent" ) ;
78
+
68
79
// TODO: the consent will be enabled in the other PRs related to telemetry
69
80
const _telemetryConsent = await getTelemetryConsent ( ) ;
70
81
82
+ log ( "Telemetry consent:" , _telemetryConsent ) ;
83
+
71
84
if ( builtinGlobalOptions . configPath === undefined ) {
85
+ log ( "Config path not provided, attempting to resolve it" ) ;
86
+
72
87
builtinGlobalOptions . configPath = await resolveHardhatConfigPath ( ) ;
88
+
89
+ log ( "Resolved config path:" , builtinGlobalOptions . configPath ) ;
73
90
}
74
91
92
+ log ( "Importing user config" ) ;
93
+
75
94
const userConfig = await importUserConfig ( builtinGlobalOptions . configPath ) ;
76
95
96
+ log ( "User config imported:" , userConfig ) ;
97
+
77
98
const configPlugins = Array . isArray ( userConfig . plugins )
78
99
? userConfig . plugins
79
100
: [ ] ;
@@ -83,6 +104,8 @@ export async function main(
83
104
builtinGlobalOptions . configPath ,
84
105
) ;
85
106
107
+ log ( "Resolved plugins:" , resolvedPlugins ) ;
108
+
86
109
const pluginGlobalOptionDefinitions =
87
110
buildGlobalOptionDefinitions ( resolvedPlugins ) ;
88
111
const globalOptionDefinitions = new Map ( [
@@ -95,6 +118,10 @@ export async function main(
95
118
usedCliArguments ,
96
119
) ;
97
120
121
+ log ( "User provided global options:" , userProvidedGlobalOptions ) ;
122
+
123
+ log ( "Creating Hardhat Runtime Environment" ) ;
124
+
98
125
const hre = await createHardhatRuntimeEnvironment (
99
126
userConfig ,
100
127
{ ...builtinGlobalOptions , ...userProvidedGlobalOptions } ,
@@ -106,6 +133,8 @@ export async function main(
106
133
107
134
const taskOrId = parseTask ( cliArguments , usedCliArguments , hre ) ;
108
135
136
+ log ( "Parsed task:" , taskOrId ) ;
137
+
109
138
if ( Array . isArray ( taskOrId ) ) {
110
139
if ( taskOrId . length === 0 ) {
111
140
const globalHelp = await getGlobalHelpString (
@@ -138,6 +167,8 @@ export async function main(
138
167
task ,
139
168
) ;
140
169
170
+ log ( `Running task "${ task . id . join ( " " ) } " with arguments:` , taskArguments ) ;
171
+
141
172
await task . run ( taskArguments ) ;
142
173
} catch ( error ) {
143
174
printErrorMessages ( error , builtinGlobalOptions ?. showStackTraces ) ;
0 commit comments