omegga 0.1.65 → 0.1.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omegga",
3
- "version": "0.1.65",
3
+ "version": "0.1.66",
4
4
  "description": "Brickadia server installer, manager, wrapper, configurator, and automator",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/cli/auth.js CHANGED
@@ -31,15 +31,17 @@ async function prompt() {
31
31
  ];
32
32
  }
33
33
 
34
- async function authFromPrompt() {
35
- let email, password, files;
34
+ async function authFromPrompt({email, password, debug=false}) {
35
+ let files;
36
36
 
37
- // prompt for user credentials
38
- try {
39
- [email, password] = await prompt();
40
- } catch (err) {
41
- console.error('!>'.red, 'Error prompting credentials\n', err);
42
- return false;
37
+ if (!email || !password) {
38
+ // prompt for user credentials
39
+ try {
40
+ [email, password] = await prompt();
41
+ } catch (err) {
42
+ console.error('!>'.red, 'Error prompting credentials\n', err);
43
+ return false;
44
+ }
43
45
  }
44
46
 
45
47
  // generate auth tokens
@@ -48,7 +50,7 @@ async function authFromPrompt() {
48
50
  console.log('>>'.green, 'Probably also installing the game...');
49
51
  }, 10000);
50
52
  try {
51
- files = await genAuthFiles(email, password);
53
+ files = await genAuthFiles(email, password, debug);
52
54
  clearTimeout(timeout);
53
55
  } catch (err) {
54
56
  clearTimeout(timeout);
@@ -56,6 +58,11 @@ async function authFromPrompt() {
56
58
  return false;
57
59
  }
58
60
 
61
+ if (!files) {
62
+ console.error('!>'.red, 'Authentication Failed');
63
+ return;
64
+ }
65
+
59
66
  // save the tokens to the config path (will be copied when omegga starts)
60
67
  try {
61
68
  console.log('>>'.green, 'Storing auth tokens...');
@@ -85,4 +92,5 @@ module.exports = {
85
92
  prompt: authFromPrompt,
86
93
  exists: authExists,
87
94
  clean: deleteAuthFiles,
95
+ AUTH_PATH,
88
96
  };
package/src/main.js CHANGED
@@ -93,7 +93,7 @@ const program = require('commander')
93
93
 
94
94
  // check if the auth files don't exist
95
95
  if (!auth.exists(path.join(workDir, soft.DATA_PATH, 'Saved/Auth')) && !auth.exists()) {
96
- const success = await auth.prompt();
96
+ const success = await auth.prompt({ debug });
97
97
  if (!success) {
98
98
  err('Start aborted - could not generate auth tokens');
99
99
  process.exit(1);
@@ -163,18 +163,27 @@ program
163
163
  .command('auth')
164
164
  .option('-g, --global', 'Remove global auth files')
165
165
  .option('-l, --local', 'Remove local auth files')
166
+ .option('-u, --email <email>', 'User email (must provide password)')
167
+ .option('-p, --pass <password>', 'User password (must provide email)')
168
+ .option('-v, --verbose', 'Print extra messages for debugging purposes')
166
169
  .description('Generates server auth tokens from brickadia account email+password')
167
- .action(() => {
168
- const { global, local } = program.opts();
169
- if (global || local) {
170
- log('Clearing old auth files');
171
- if (global)
170
+ .action(async ({ email, pass: password, local: localAuth, global: globalAuth }) => {
171
+ const { verbose, debug } = program.opts();
172
+ global.VERBOSE = verbose;
173
+
174
+ if (globalAuth || localAuth) {
175
+ if (globalAuth) {
176
+ log('Clearing auth files from', auth.AUTH_PATH.yellow);
172
177
  auth.clean();
173
- if (local)
174
- file.rmdir(path.join(__dirname, 'data/Saved/Auth'));
178
+ }
179
+ if (localAuth) {
180
+ const localPath = path.resolve('data/Saved/Auth');
181
+ log('Clearing auth files from', localPath.yellow);
182
+ await file.rmdir(localPath);
183
+ }
175
184
  return;
176
185
  } else {
177
- auth.prompt();
186
+ auth.prompt({email, password, debug});
178
187
  }
179
188
  });
180
189
 
@@ -44,7 +44,7 @@ function writeAuthFiles(dstDir, files) {
44
44
  }
45
45
 
46
46
  // from credentials, build brickadia auth tokens
47
- async function genAuthFiles(email, password) {
47
+ async function genAuthFiles(email, password, debug=false) {
48
48
  verboseLog('Generating auth files');
49
49
 
50
50
  // remove existing temporary install path
@@ -70,6 +70,7 @@ async function genAuthFiles(email, password) {
70
70
  noauth: true,
71
71
  noplugin: true,
72
72
  noweb: true,
73
+ debug,
73
74
  };
74
75
 
75
76
  // create a dummy omegga
@@ -107,7 +108,6 @@ async function genAuthFiles(email, password) {
107
108
  if (finished) return;
108
109
  finished = true;
109
110
  verboseLog('Brickadia', name, 'with code', ...args);
110
- removeTempDir();
111
111
  if (!resolved) reject('temp server could not start');
112
112
  };
113
113
 
@@ -118,7 +118,7 @@ async function genAuthFiles(email, password) {
118
118
  });
119
119
 
120
120
  // read the auth files on success
121
- const files = success ? readAuthFiles() : undefined;
121
+ const files = success ? readAuthFiles() : null;
122
122
 
123
123
  // remove temp dir
124
124
  removeTempDir();
package/src/util/file.js CHANGED
@@ -77,13 +77,13 @@ function mkdir(path) {
77
77
 
78
78
  // rm -rf a path
79
79
  function rmdir(dir) {
80
- if (!fs.existsSync(dir)) return;
80
+ if (!fs.existsSync(dir)) return false;
81
81
  return new Promise((resolve, reject) => {
82
82
  rimraf(dir, error => {
83
83
  if (error)
84
84
  reject(error);
85
85
  else
86
- resolve();
86
+ resolve(true);
87
87
  });
88
88
  });
89
89
  }