-
Notifications
You must be signed in to change notification settings - Fork 12
/
config.js
66 lines (54 loc) · 2.32 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Server configuration
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
const fs = require('fs');
const os = require('os');
const path = require('path');
const yargs = require('yargs');
const {isLightweightMobile, isStandaloneMobile} = require('./isMobile.js');
const argv = yargs
.option('spatialToolboxPath', {
description: 'The absolute path to the spatialToolbox directory (default ~/Documents/spatialToolbox)',
type: 'string',
})
.option('udpPort', {
description: 'The port on which udp discovery broadcasts occur (default 52316)',
type: 'number',
})
.option('secure', {
description: 'Enable the server\'s secure (https) mode',
type: 'boolean',
})
.help()
.argv;
const spatialToolboxPath = argv.spatialToolboxPath || path.join(os.homedir(), 'Documents', 'spatialToolbox');
const oldRealityObjectsPath = path.join(os.homedir(), 'Documents', 'realityobjects');
// All objects are stored in this folder:
// Look for objects in the user Documents directory instead of __dirname+"/objects"
let objectsPath = spatialToolboxPath;
if (process.env.NODE_ENV === 'test' || os.platform() === 'android' || !fs.existsSync(path.join(os.homedir(), 'Documents'))) {
objectsPath = path.join(__dirname, 'spatialToolbox');
}
// Default back to old realityObjects dir if it exists
if (!fs.existsSync(objectsPath) &&
objectsPath === spatialToolboxPath &&
fs.existsSync(oldRealityObjectsPath)) {
console.warn('Please rename your realityobjects directory to spatialToolbox');
objectsPath = oldRealityObjectsPath;
}
// create objects folder at objectsPath if necessary
if (!fs.existsSync(objectsPath)) {
fs.mkdirSync(objectsPath);
}
module.exports.objectsPath = objectsPath;
// this is the port for UDP broadcasting so that the objects find each other
module.exports.beatPort = argv.udpPort || 52316;
// Port of the API and configuration UI server
module.exports.serverPort = (isLightweightMobile || isStandaloneMobile) ? 49369 : 8080;
// Whether to enable the offline clone functionality
module.exports.persistToCloud = false;
module.exports.allowSecureMode = argv.secure || process.env.ALLOW_SECURE_MODE === 'true';