Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

Commit 4bc81e6

Browse files
authored
Revert "Revert "Types""
1 parent 83cab90 commit 4bc81e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+433
-372
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
local
1+
local
2+
dist

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ files/
7474

7575
# log folder
7676
logs/
77+
78+
# ignore compiled code
79+
dist/

app/handler/index.js

-78
This file was deleted.

app/resources/paths.js

-18
This file was deleted.

package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-11
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@
1919
"url": "https://github.com/Nicklason/tf2-automatic/issues"
2020
},
2121
"homepage": "https://github.com/Nicklason/tf2-automatic#readme",
22-
"_moduleAliases": {
23-
"@root": ".",
24-
"app": "app",
25-
"utils": "app/utils",
26-
"resources": "app/resources",
27-
"handler": "app/handler",
28-
"lib": "lib",
29-
"classes": "classes",
30-
"schemas": "schemas"
31-
},
3222
"dependencies": {
3323
"@nicklason/request-retry": "^1.1.2",
3424
"async": "^3.1.0",
@@ -43,9 +33,9 @@
4333
"is-path-inside": "^3.0.2",
4434
"isobject": "^4.0.0",
4535
"jsonschema": "^1.2.5",
46-
"module-alias": "^2.2.2",
4736
"moment": "^2.24.0",
4837
"path": "^0.12.7",
38+
"pjson": "^1.0.9",
4939
"pluralize": "^8.0.0",
5040
"pm2": "^4.2.1",
5141
"retry": "^0.12.0",

app.js src/app.js

+25-33
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
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-
91
const dotenv = require('dotenv');
102
dotenv.config();
113

12-
const log = require('lib/logger');
4+
const log = require('./lib/logger');
135

146
if (process.env.pm_id === undefined) {
157
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');
168
}
179

18-
const handlerManager = require('app/handler-manager');
10+
const handlerManager = require('./app/handler-manager');
1911
handlerManager.setup();
2012

2113
const handler = handlerManager.getHandler();
@@ -24,18 +16,18 @@ const EconItem = require('steam-tradeoffer-manager/lib/classes/EconItem.js');
2416
const CEconItem = require('steamcommunity/classes/CEconItem.js');
2517

2618
['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);
2820
EconItem.prototype[v] = func;
2921
CEconItem.prototype[v] = func;
3022
});
3123

3224
const TradeOffer = require('steam-tradeoffer-manager/lib/classes/TradeOffer');
3325

3426
['log', 'summarize'].forEach(function (v) {
35-
TradeOffer.prototype[v] = require('utils/offer/' + v);
27+
TradeOffer.prototype[v] = require('./app/utils/offer/' + v);
3628
});
3729

38-
const package = require('@root/package.json');
30+
const pjson = require('pjson');
3931

4032
require('death')({ uncaughtException: true })(function (signal, err) {
4133
const crashed = typeof err !== 'string';
@@ -46,8 +38,8 @@ require('death')({ uncaughtException: true })(function (signal, err) {
4638
}
4739

4840
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}}`,
5143
'Stack trace:',
5244
require('util').inspect(err)
5345
].join('\r\n'));
@@ -79,18 +71,18 @@ const SteamUser = require('steam-user');
7971
const async = require('async');
8072

8173
// Set up node-tf2
82-
require('lib/tf2');
74+
require('./lib/tf2');
8375

8476
const pm2 = require('pm2');
8577

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');
8981

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');
9284

93-
log.info(package.name + ' v' + package.version + ' is starting...');
85+
log.info(pjson.name + ' v' + pjson.version + ' is starting...');
9486

9587
start();
9688

@@ -121,13 +113,13 @@ function start () {
121113
log.info('Setting up pricelist...');
122114

123115
// Set up pricelist
124-
require('app/prices').init(callback);
116+
require('./app/prices').init(callback);
125117
},
126118
function (callback) {
127119
// Sign in to Steam
128120
log.info('Signing in to Steam...');
129121

130-
const login = require('app/login');
122+
const login = require('./app/login');
131123

132124
const loginKey = opts.loginKey || null;
133125
let lastLoginFailed = false;
@@ -159,7 +151,7 @@ function start () {
159151

160152
log.verbose('Checking account limitations...');
161153

162-
require('utils/limitationsCallback')(function (err, limitations) {
154+
require('./app/utils/limitationsCallback')(function (err, limitations) {
163155
if (err) {
164156
return callback(err);
165157
}
@@ -182,7 +174,7 @@ function start () {
182174
log.debug('Waiting for web session...');
183175

184176
// Wait for steamcommunity session
185-
require('utils/communityLoginCallback')(false, function (err, v) {
177+
require('./app/utils/communityLoginCallback')(false, function (err, v) {
186178
if (err) {
187179
return callback(err);
188180
}
@@ -194,9 +186,9 @@ function start () {
194186
},
195187
function (callback) {
196188
// Sign in to backpack.tf if needed
197-
require('lib/bptf-login').setCookies(cookies);
189+
require('./lib/bptf-login').setCookies(cookies);
198190

199-
require('app/bptf').setup(callback);
191+
require('./app/bptf').setup(callback);
200192
},
201193
function (callback) {
202194
// Set up tf2-schema
@@ -227,7 +219,7 @@ function start () {
227219
async.parallel({
228220
inventory: function (callback) {
229221
// Load inventory
230-
require('app/inventory').getInventory(client.steamID, callback);
222+
require('./app/inventory').getInventory(client.steamID, callback);
231223
},
232224
listings: function (callback) {
233225
// Initialize bptf-listings
@@ -251,13 +243,13 @@ function start () {
251243
// Create listings
252244
log.info('Creating listings...');
253245

254-
require('handler/listings').redoListings(callback);
246+
require('./app/handler/listings').redoListings(callback);
255247
},
256248
function (callback) {
257249
// Set up trade offer manager
258250

259251
// Connect to socketio server after creating listings
260-
require('lib/ptf-socket').open();
252+
require('./lib/ptf-socket').open();
261253

262254
log.info('Getting Steam API key...');
263255

@@ -266,7 +258,7 @@ function start () {
266258
},
267259
function (callback) {
268260
// Get friends limit
269-
require('handler/friends').getMaxFriends(callback);
261+
require('./app/handler/friends').getMaxFriends(callback);
270262
}
271263
], function (item, callback) {
272264
// Check if we are trying to shut down
@@ -289,6 +281,6 @@ function start () {
289281
handler.onReady();
290282

291283
// Start version checker
292-
require('app/version-check').startVersionChecker();
284+
require('./app/version-check').startVersionChecker();
293285
});
294286
}

app/admins.js src/app/admins.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const SteamID = require('steamid');
22

3-
const client = require('lib/client');
3+
const client = require('../lib/client');
44

55
const admins = process.env.ADMINS === undefined ? [] : JSON.parse(process.env.ADMINS);
66

app/bptf.js src/app/bptf.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const async = require('async');
22

3-
const log = require('lib/logger');
4-
const bptfLogin = require('lib/bptf-login');
5-
const community = require('lib/community');
3+
const log = require('../lib/logger');
4+
const bptfLogin = require('../lib/bptf-login');
5+
const community = require('../lib/community');
66

7-
const handlerManager = require('app/handler-manager');
7+
const handlerManager = require('./handler-manager');
88

99
let hasLoggedIn = false;
1010

app/crafting.js src/app/crafting.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const log = require('lib/logger');
2-
const client = require('lib/client');
3-
const tf2 = require('lib/tf2');
1+
const log = require('../lib/logger');
2+
const client = require('../lib/client');
3+
const tf2 = require('../lib/tf2');
44

5-
const handlerManager = require('app/handler-manager');
6-
const inventoryManager = require('app/inventory');
5+
const handlerManager = require('./handler-manager');
6+
const inventoryManager = require('./inventory');
77

88
const jobs = [];
99

0 commit comments

Comments
 (0)