@@ -16,7 +16,7 @@ const {logger} = require('../../common-utils');
1616const { REMOVE_UNUSED_SCREENS : commandName } = cliCommands ;
1717
1818// TODO: remove hack after add ability to add controllers from plugin in silent mode
19- function proxyHermione ( ) {
19+ function proxyTestplane ( ) {
2020 const proxyHandler = {
2121 get ( target , prop ) {
2222 return prop in target ? target [ prop ] : new Proxy ( ( ) => { } , this ) ;
@@ -26,31 +26,33 @@ function proxyHermione() {
2626 }
2727 } ;
2828
29- global . hermione = new Proxy ( global . hermione || { } , proxyHandler ) ;
29+ global . hermione = global . testplane = new Proxy ( global . testplane || global . hermione || { } , proxyHandler ) ;
3030}
3131
32- module . exports = ( program , pluginConfig , hermione ) => {
32+ module . exports = ( program , pluginConfig , testplane ) => {
33+ const toolName = program . name ?. ( ) || 'hermione' ;
34+
3335 program
3436 . command ( commandName )
3537 . description ( 'remove screenshots which were not used when running tests' )
3638 . option ( '-p, --pattern <pattern>' , 'pattern for searching screenshots on the file system' , collect )
3739 . option ( '--skip-questions' , 'do not ask questions during execution (default values will be used)' )
38- . on ( '--help' , ( ) => logger . log ( getHelpMessage ( ) ) )
40+ . on ( '--help' , ( ) => logger . log ( getHelpMessage ( toolName ) ) )
3941 . action ( async ( options ) => {
4042 try {
41- proxyHermione ( ) ;
43+ proxyTestplane ( ) ;
4244
4345 const { pattern : userPatterns } = options ;
4446
4547 if ( _ . isEmpty ( userPatterns ) ) {
46- throw new Error ( `option "pattern" is required. See examples of usage: ${ chalk . green ( `npx hermione ${ commandName } --help` ) } ` ) ;
48+ throw new Error ( `option "pattern" is required. See examples of usage: ${ chalk . green ( `npx ${ toolName } ${ commandName } --help` ) } ` ) ;
4749 }
4850
4951 const userScreenPatterns = transformPatternOption ( userPatterns ) ;
5052 const spinner = ora ( { spinner : 'point' } ) ;
5153
52- spinner . start ( ' Reading hermione tests from file system' ) ;
53- const fsTests = await getTestsFromFs ( hermione ) ;
54+ spinner . start ( ` Reading ${ toolName } tests from file system` ) ;
55+ const fsTests = await getTestsFromFs ( testplane ) ;
5456 spinner . succeed ( ) ;
5557
5658 logger . log ( `${ chalk . green ( fsTests . count ) } uniq tests were read in browsers: ${ [ ...fsTests . browserIds ] . join ( ', ' ) } ` ) ;
@@ -80,7 +82,7 @@ module.exports = (program, pluginConfig, hermione) => {
8082 } , options ) ;
8183
8284 if ( shouldIdentifyUnused ) {
83- await handleUnusedScreens ( foundScreenPaths , fsTests , { hermione , pluginConfig, spinner, cliOpts : options } ) ;
85+ await handleUnusedScreens ( foundScreenPaths , fsTests , { testplane , pluginConfig, spinner, cliOpts : options } ) ;
8486 }
8587 } catch ( err ) {
8688 logger . error ( err . stack || err ) ;
@@ -100,7 +102,7 @@ async function handleOutdatedScreens(screenPaths, screenPatterns, opts = {}) {
100102}
101103
102104async function handleUnusedScreens ( screenPaths , fsTests , opts = { } ) {
103- const { hermione , pluginConfig, spinner, cliOpts} = opts ;
105+ const { testplane , pluginConfig, spinner, cliOpts} = opts ;
104106 const mainDatabaseUrls = path . resolve ( pluginConfig . path , DATABASE_URLS_JSON_NAME ) ;
105107
106108 const isReportPathExists = await fs . pathExists ( pluginConfig . path ) ;
@@ -109,7 +111,7 @@ async function handleUnusedScreens(screenPaths, fsTests, opts = {}) {
109111 }
110112
111113 spinner . start ( 'Loading databases with the test results in order to identify unused screenshots in tests' ) ;
112- const dbPaths = await hermione . htmlReporter . downloadDatabases ( [ mainDatabaseUrls ] , { pluginConfig} ) ;
114+ const dbPaths = await testplane . htmlReporter . downloadDatabases ( [ mainDatabaseUrls ] , { pluginConfig} ) ;
113115 spinner . succeed ( ) ;
114116
115117 if ( _ . isEmpty ( dbPaths ) ) {
@@ -121,14 +123,14 @@ async function handleUnusedScreens(screenPaths, fsTests, opts = {}) {
121123
122124 if ( ! _ . isEmpty ( srcDbPaths ) ) {
123125 spinner . start ( 'Merging databases' ) ;
124- await hermione . htmlReporter . mergeDatabases ( srcDbPaths , pluginConfig . path ) ;
126+ await testplane . htmlReporter . mergeDatabases ( srcDbPaths , pluginConfig . path ) ;
125127 spinner . succeed ( ) ;
126128
127129 logger . log ( `${ chalk . green ( srcDbPaths . length ) } databases were merged to ${ chalk . green ( mergedDbPath ) } ` ) ;
128130 }
129131
130132 spinner . start ( `Identifying unused reference images (tests passed successfully for them, but they were not used during execution)` ) ;
131- const unusedScreenPaths = identifyUnusedScreens ( fsTests , { hermione , mergedDbPath} ) ;
133+ const unusedScreenPaths = identifyUnusedScreens ( fsTests , { testplane , mergedDbPath} ) ;
132134 spinner . succeed ( ) ;
133135
134136 await handleScreens ( screenPaths , { paths : unusedScreenPaths , type : 'unused' } , { spinner, cliOpts} ) ;
@@ -204,13 +206,13 @@ function collect(newValue, array = []) {
204206 return array . concat ( newValue ) ;
205207}
206208
207- function getHelpMessage ( ) {
208- const rmUnusedScreens = `npx hermione ${ commandName } ` ;
209+ function getHelpMessage ( toolName ) {
210+ const rmUnusedScreens = `npx ${ toolName } ${ commandName } ` ;
209211
210212 return `
211213 Example of usage:
212214 Specify the folder in which all reference screenshots are located:
213- ${ chalk . green ( `${ rmUnusedScreens } -p 'hermione -screens-folder'` ) }
215+ ${ chalk . green ( `${ rmUnusedScreens } -p '${ toolName } -screens-folder'` ) }
214216
215217 Specify the mask by which all reference screenshots will be found:
216218 ${ chalk . green ( `${ rmUnusedScreens } -p 'screens/**/*.png'` ) }
@@ -219,7 +221,7 @@ function getHelpMessage() {
219221 ${ chalk . green ( `${ rmUnusedScreens } -p 'screens/**/chrome/*.png' -p 'screens/**/firefox/*.png'` ) }
220222
221223 Don't ask me about anything and just delete unused reference screenshots:
222- ${ chalk . green ( `${ rmUnusedScreens } -p 'hermione -screens-folder' --skip-questions` ) } ` ;
224+ ${ chalk . green ( `${ rmUnusedScreens } -p '${ toolName } -screens-folder' --skip-questions` ) } ` ;
223225}
224226
225227function transformPatternOption ( patterns ) {
0 commit comments