11"use strict" ;
22
3- const { "Launcher" : EpicGames } = require ( "epicgames-client" ) ;
4- const { freeGamesPromotions } = require ( "./src/gamePromotions" ) ;
5- const Logger = require ( "tracer" ) . console ( `${ __dirname } /logger.js` ) ;
63const { writeFile, writeFileSync, existsSync, readFileSync } = require ( "fs" ) ;
7-
8- const Auths = require ( `${ __dirname } /data/device_auths.json` ) ;
9- const getLatestVersion = require ( "./src/checkUpdate.js" ) ;
104if ( ! existsSync ( `${ __dirname } /data/config.json` ) ) {
115 writeFileSync ( `${ __dirname } /data/config.json` , readFileSync ( `${ __dirname } /data/config.example.json` ) ) ;
126}
13- const Config = require ( `${ __dirname } /data/config.json` ) ;
14- const Fork = require ( "child_process" ) ;
157if ( ! existsSync ( `${ __dirname } /data/history.json` ) ) {
16- try {
17- writeFileSync ( `${ __dirname } /data/history.json` , "{}" ) ;
18- } catch ( err ) {
19- Logger . error ( `Failed to generate data/history.json file (${ err } )` ) ;
20- process . exit ( 1 ) ;
21- }
8+ writeFileSync ( `${ __dirname } /data/history.json` , "{}" ) ;
229}
10+
11+ const { "Launcher" : EpicGames } = require ( "epicgames-client" ) ;
12+ const { freeGamesPromotions } = require ( `${ __dirname } /src/gamePromotions` ) ;
13+ const { latestVersion } = require ( `${ __dirname } /src/latestVersion.js` ) ;
14+ const Auths = require ( `${ __dirname } /data/device_auths.json` ) ;
15+ const Config = require ( `${ __dirname } /data/config.json` ) ;
16+ const Fork = require ( "child_process" ) ;
2317const History = require ( `${ __dirname } /data/history.json` ) ;
24- const Package = require ( "./package.json" ) ;
18+ const Logger = require ( "tracer" ) . console ( `${ __dirname } /logger.js` ) ;
19+ const Package = require ( `${ __dirname } /package.json` ) ;
2520
2621function appriseNotify ( appriseUrl , notificationMessages ) {
2722 if ( ! appriseUrl || notificationMessages . length === 0 ) {
@@ -39,7 +34,7 @@ function appriseNotify(appriseUrl, notificationMessages) {
3934 appriseUrl ,
4035 ] ) ;
4136
42- let output = s . stdout ? s . stdout . toString ( ) : "ERROR: maybe apprise not found" ;
37+ let output = s . stdout ? s . stdout . toString ( ) : "ERROR: Maybe apprise not found? " ;
4338 if ( output && output . includes ( "ERROR" ) ) {
4439 Logger . error ( `Failed to send push notification (${ output } )` ) ;
4540 } else if ( output ) {
@@ -65,16 +60,17 @@ function sleep(delay) {
6560 let { options, delay, loop, appriseUrl } = Config ;
6661
6762 do {
68- Logger . info ( `Epicgames Freebies Claimer ${ Package . version } ` ) ;
69- let latestVersion = await getLatestVersion ( ) . catch ( ( err ) => {
63+ Logger . info ( `Epicgames Freebies Claimer (${ Package . version } ) by ${ Package . author . name || Package . author } ` ) ;
64+
65+ let latest = await latestVersion ( ) . catch ( ( err ) => {
7066 Logger . error ( `Failed to check for updates (${ err } )` ) ;
7167 } ) ;
72- if ( latestVersion && latestVersion !== Package . version ) {
73- Logger . warn ( `Latest release version ${ latestVersion } available: ${ Package . url } ` ) ;
68+
69+ if ( latest && latest !== Package . version ) {
70+ Logger . warn ( `There is a new release available (${ latest } ): ${ Package . url } ` ) ;
7471 }
7572
7673 let notificationMessages = [ ] ;
77-
7874 for ( let email in Auths ) {
7975 let { country } = Auths [ email ] ;
8076 let claimedPromos = History [ email ] || [ ] ;
@@ -83,6 +79,7 @@ function sleep(delay) {
8379 let rememberDevicesPath = `${ __dirname } /data/device_auths.json` ;
8480 let clientOptions = { email, ...options , rememberDevicesPath } ;
8581 let client = new EpicGames ( clientOptions ) ;
82+
8683 if ( ! await client . init ( ) ) {
8784 let errMess = "Error while initialize process." ;
8885 notificationMessages . push ( errMess ) ;
0 commit comments