1
- try {
2
- require ( 'module-alias/register' ) ;
3
- } catch ( err ) {
4
- /* eslint-disable-next-line no-console */
5
- console . error ( 'Missing dependencies! Install them with `npm install`' ) ;
6
- process . exit ( 1 ) ;
7
- }
8
-
9
1
const dotenv = require ( 'dotenv' ) ;
10
2
dotenv . config ( ) ;
11
3
12
- const log = require ( 'lib/logger' ) ;
4
+ const log = require ( './ lib/logger' ) ;
13
5
14
6
if ( process . env . pm_id === undefined ) {
15
7
log . warn ( 'You are not running the bot with PM2! If the bot crashes it won\'t start again, see the documentation: https://github.com/Nicklason/tf2-automatic/wiki/PM2' ) ;
16
8
}
17
9
18
- const handlerManager = require ( 'app/handler-manager' ) ;
10
+ const handlerManager = require ( './ app/handler-manager' ) ;
19
11
handlerManager . setup ( ) ;
20
12
21
13
const handler = handlerManager . getHandler ( ) ;
@@ -24,18 +16,18 @@ const EconItem = require('steam-tradeoffer-manager/lib/classes/EconItem.js');
24
16
const CEconItem = require ( 'steamcommunity/classes/CEconItem.js' ) ;
25
17
26
18
[ 'hasDescription' , 'getAction' , 'getTag' , 'getItem' , 'getSKU' , 'getName' , 'getPrice' ] . forEach ( function ( v ) {
27
- const func = require ( 'utils/item/' + v ) ;
19
+ const func = require ( './app/ utils/item/' + v ) ;
28
20
EconItem . prototype [ v ] = func ;
29
21
CEconItem . prototype [ v ] = func ;
30
22
} ) ;
31
23
32
24
const TradeOffer = require ( 'steam-tradeoffer-manager/lib/classes/TradeOffer' ) ;
33
25
34
26
[ 'log' , 'summarize' ] . forEach ( function ( v ) {
35
- TradeOffer . prototype [ v ] = require ( 'utils/offer/' + v ) ;
27
+ TradeOffer . prototype [ v ] = require ( './app/ utils/offer/' + v ) ;
36
28
} ) ;
37
29
38
- const package = require ( '@root/package.json ' ) ;
30
+ const pjson = require ( 'pjson ' ) ;
39
31
40
32
require ( 'death' ) ( { uncaughtException : true } ) ( function ( signal , err ) {
41
33
const crashed = typeof err !== 'string' ;
@@ -46,8 +38,8 @@ require('death')({ uncaughtException: true })(function (signal, err) {
46
38
}
47
39
48
40
log . error ( [
49
- package . name + ( ! handler . isReady ( ) ? ' failed to start properly, this is most likely a temporary error. See the log:' : ' crashed! Please create an issue with the following log:' ) ,
50
- `package.version: ${ package . version || undefined } ; node: ${ process . version } ${ process . platform } ${ process . arch } }` ,
41
+ pjson . name + ( ! handler . isReady ( ) ? ' failed to start properly, this is most likely a temporary error. See the log:' : ' crashed! Please create an issue with the following log:' ) ,
42
+ `package.version: ${ pjson . version || undefined } ; node: ${ process . version } ${ process . platform } ${ process . arch } }` ,
51
43
'Stack trace:' ,
52
44
require ( 'util' ) . inspect ( err )
53
45
] . join ( '\r\n' ) ) ;
@@ -79,18 +71,18 @@ const SteamUser = require('steam-user');
79
71
const async = require ( 'async' ) ;
80
72
81
73
// Set up node-tf2
82
- require ( 'lib/tf2' ) ;
74
+ require ( './ lib/tf2' ) ;
83
75
84
76
const pm2 = require ( 'pm2' ) ;
85
77
86
- const client = require ( 'lib/client' ) ;
87
- const manager = require ( 'lib/manager' ) ;
88
- const community = require ( 'lib/community' ) ;
78
+ const client = require ( './ lib/client' ) ;
79
+ const manager = require ( './ lib/manager' ) ;
80
+ const community = require ( './ lib/community' ) ;
89
81
90
- const schemaManager = require ( 'lib/tf2-schema' ) ;
91
- const listingManager = require ( 'lib/bptf-listings' ) ;
82
+ const schemaManager = require ( './ lib/tf2-schema' ) ;
83
+ const listingManager = require ( './ lib/bptf-listings' ) ;
92
84
93
- log . info ( package . name + ' v' + package . version + ' is starting...' ) ;
85
+ log . info ( pjson . name + ' v' + pjson . version + ' is starting...' ) ;
94
86
95
87
start ( ) ;
96
88
@@ -121,13 +113,13 @@ function start () {
121
113
log . info ( 'Setting up pricelist...' ) ;
122
114
123
115
// Set up pricelist
124
- require ( 'app/prices' ) . init ( callback ) ;
116
+ require ( './ app/prices' ) . init ( callback ) ;
125
117
} ,
126
118
function ( callback ) {
127
119
// Sign in to Steam
128
120
log . info ( 'Signing in to Steam...' ) ;
129
121
130
- const login = require ( 'app/login' ) ;
122
+ const login = require ( './ app/login' ) ;
131
123
132
124
const loginKey = opts . loginKey || null ;
133
125
let lastLoginFailed = false ;
@@ -159,7 +151,7 @@ function start () {
159
151
160
152
log . verbose ( 'Checking account limitations...' ) ;
161
153
162
- require ( 'utils/limitationsCallback' ) ( function ( err , limitations ) {
154
+ require ( './app/ utils/limitationsCallback' ) ( function ( err , limitations ) {
163
155
if ( err ) {
164
156
return callback ( err ) ;
165
157
}
@@ -182,7 +174,7 @@ function start () {
182
174
log . debug ( 'Waiting for web session...' ) ;
183
175
184
176
// Wait for steamcommunity session
185
- require ( 'utils/communityLoginCallback' ) ( false , function ( err , v ) {
177
+ require ( './app/ utils/communityLoginCallback' ) ( false , function ( err , v ) {
186
178
if ( err ) {
187
179
return callback ( err ) ;
188
180
}
@@ -194,9 +186,9 @@ function start () {
194
186
} ,
195
187
function ( callback ) {
196
188
// Sign in to backpack.tf if needed
197
- require ( 'lib/bptf-login' ) . setCookies ( cookies ) ;
189
+ require ( './ lib/bptf-login' ) . setCookies ( cookies ) ;
198
190
199
- require ( 'app/bptf' ) . setup ( callback ) ;
191
+ require ( './ app/bptf' ) . setup ( callback ) ;
200
192
} ,
201
193
function ( callback ) {
202
194
// Set up tf2-schema
@@ -227,7 +219,7 @@ function start () {
227
219
async . parallel ( {
228
220
inventory : function ( callback ) {
229
221
// Load inventory
230
- require ( 'app/inventory' ) . getInventory ( client . steamID , callback ) ;
222
+ require ( './ app/inventory' ) . getInventory ( client . steamID , callback ) ;
231
223
} ,
232
224
listings : function ( callback ) {
233
225
// Initialize bptf-listings
@@ -251,13 +243,13 @@ function start () {
251
243
// Create listings
252
244
log . info ( 'Creating listings...' ) ;
253
245
254
- require ( 'handler/listings' ) . redoListings ( callback ) ;
246
+ require ( './app/ handler/listings' ) . redoListings ( callback ) ;
255
247
} ,
256
248
function ( callback ) {
257
249
// Set up trade offer manager
258
250
259
251
// Connect to socketio server after creating listings
260
- require ( 'lib/ptf-socket' ) . open ( ) ;
252
+ require ( './ lib/ptf-socket' ) . open ( ) ;
261
253
262
254
log . info ( 'Getting Steam API key...' ) ;
263
255
@@ -266,7 +258,7 @@ function start () {
266
258
} ,
267
259
function ( callback ) {
268
260
// Get friends limit
269
- require ( 'handler/friends' ) . getMaxFriends ( callback ) ;
261
+ require ( './app/ handler/friends' ) . getMaxFriends ( callback ) ;
270
262
}
271
263
] , function ( item , callback ) {
272
264
// Check if we are trying to shut down
@@ -289,6 +281,6 @@ function start () {
289
281
handler . onReady ( ) ;
290
282
291
283
// Start version checker
292
- require ( 'app/version-check' ) . startVersionChecker ( ) ;
284
+ require ( './ app/version-check' ) . startVersionChecker ( ) ;
293
285
} ) ;
294
286
}
0 commit comments