omegga 0.1.64 → 0.1.68
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 +1 -1
- package/src/cli/auth.js +17 -9
- package/src/cli/plugin.js +5 -9
- package/src/config/index.js +2 -2
- package/src/main.js +32 -14
- package/src/omegga/auth.js +3 -3
- package/src/omegga/server.js +2 -2
- package/src/util/file.js +2 -2
- package/.vscode/settings.json +0 -2
package/package.json
CHANGED
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
|
|
34
|
+
async function authFromPrompt({email, password, debug=false}) {
|
|
35
|
+
let files;
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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/cli/plugin.js
CHANGED
|
@@ -191,26 +191,22 @@ module.exports = {
|
|
|
191
191
|
'to setup one.'
|
|
192
192
|
);
|
|
193
193
|
|
|
194
|
-
plugins = plugins.map(transformUrl);
|
|
195
194
|
log('Attempting to install', (plugins.length + '').yellow, 'plugins...');
|
|
196
195
|
|
|
197
|
-
|
|
196
|
+
for (const pluginUrl of plugins) {
|
|
197
|
+
const plugin = transformUrl(pluginUrl);
|
|
198
|
+
|
|
198
199
|
// if the plugin wasn't transformed, try to extract its name from the git url
|
|
199
|
-
if (!plugin
|
|
200
|
+
if (!('name' in plugin)) {
|
|
200
201
|
try {
|
|
201
202
|
const { name } = path.parse(plugin.url);
|
|
202
203
|
plugin.name = name.replace(/^omegga-/, '');
|
|
203
|
-
return true;
|
|
204
204
|
} catch (e) {
|
|
205
205
|
console.error('!>'.red, 'Error parsing name from url', plugin.url);
|
|
206
|
-
|
|
206
|
+
break;
|
|
207
207
|
}
|
|
208
|
-
} else {
|
|
209
|
-
return true;
|
|
210
208
|
}
|
|
211
|
-
});
|
|
212
209
|
|
|
213
|
-
for (const plugin of plugins) {
|
|
214
210
|
log(
|
|
215
211
|
'Installing plugin',
|
|
216
212
|
plugin.name.yellow,
|
package/src/config/index.js
CHANGED
|
@@ -31,11 +31,11 @@ module.exports = {
|
|
|
31
31
|
defaultConfig: {
|
|
32
32
|
omegga: {
|
|
33
33
|
webui: true,
|
|
34
|
-
port: soft.DEFAULT_PORT,
|
|
34
|
+
port: process.env.OMEGGA_PORT ?? soft.DEFAULT_PORT,
|
|
35
35
|
https: true,
|
|
36
36
|
},
|
|
37
37
|
server: {
|
|
38
|
-
port: 7777,
|
|
38
|
+
port: process.env.BRICKADIA_PORT ?? 7777,
|
|
39
39
|
map: 'Plate'
|
|
40
40
|
},
|
|
41
41
|
},
|
package/src/main.js
CHANGED
|
@@ -93,7 +93,11 @@ 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({
|
|
97
|
+
debug,
|
|
98
|
+
email: process.env.BRICKADIA_USER ?? null,
|
|
99
|
+
password: process.env.BRICKADIA_PASS ?? null,
|
|
100
|
+
});
|
|
97
101
|
if (!success) {
|
|
98
102
|
err('Start aborted - could not generate auth tokens');
|
|
99
103
|
process.exit(1);
|
|
@@ -161,22 +165,36 @@ program
|
|
|
161
165
|
|
|
162
166
|
program
|
|
163
167
|
.command('auth')
|
|
164
|
-
.option('-
|
|
165
|
-
.option('-f, --force', 'Forcefully regenerate auth token')
|
|
168
|
+
.option('-g, --global', 'Remove global auth files')
|
|
166
169
|
.option('-l, --local', 'Remove local auth files')
|
|
170
|
+
.option('-w, --workdir', 'Remove configured location auth files')
|
|
171
|
+
.option('-u, --email <email>', 'User email (must provide password)')
|
|
172
|
+
.option('-p, --pass <password>', 'User password (must provide email)')
|
|
173
|
+
.option('-v, --verbose', 'Print extra messages for debugging purposes')
|
|
167
174
|
.description('Generates server auth tokens from brickadia account email+password')
|
|
168
|
-
.action(() => {
|
|
169
|
-
const {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
.action(async ({ email, pass: password, local: localAuth, workDir, global: globalAuth }) => {
|
|
176
|
+
const { verbose, debug } = program.opts();
|
|
177
|
+
global.VERBOSE = verbose;
|
|
178
|
+
|
|
179
|
+
if (globalAuth || localAuth) {
|
|
180
|
+
if (globalAuth) {
|
|
181
|
+
log('Clearing auth files from', auth.AUTH_PATH.yellow);
|
|
182
|
+
auth.clean();
|
|
183
|
+
}
|
|
184
|
+
if (workDir) {
|
|
185
|
+
const workdirPath = path.join(config.store.get('defaultOmegga'), 'data/Saved/Auth');
|
|
186
|
+
log('Clearing auth files from', workdirPath.yellow);
|
|
187
|
+
await file.rmdir(workdirPath);
|
|
188
|
+
}
|
|
189
|
+
if (localAuth) {
|
|
190
|
+
const localPath = path.resolve('data/Saved/Auth');
|
|
191
|
+
log('Clearing auth files from', localPath.yellow);
|
|
192
|
+
await file.rmdir(localPath);
|
|
193
|
+
}
|
|
194
|
+
return;
|
|
195
|
+
} else {
|
|
196
|
+
auth.prompt({email, password, debug});
|
|
178
197
|
}
|
|
179
|
-
auth.prompt();
|
|
180
198
|
});
|
|
181
199
|
|
|
182
200
|
program
|
package/src/omegga/auth.js
CHANGED
|
@@ -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() :
|
|
121
|
+
const files = success ? readAuthFiles() : null;
|
|
122
122
|
|
|
123
123
|
// remove temp dir
|
|
124
124
|
removeTempDir();
|
package/src/omegga/server.js
CHANGED
|
@@ -525,10 +525,10 @@ class Omegga extends OmeggaWrapper {
|
|
|
525
525
|
// wait for the server to save the file
|
|
526
526
|
await this.watchLogChunk(
|
|
527
527
|
`Bricks.Save "${saveFile}"`,
|
|
528
|
-
/^LogBrickSerializer: (.+)$/,
|
|
528
|
+
/^(LogBrickSerializer|LogTemp): (.+)$/,
|
|
529
529
|
{
|
|
530
530
|
first: match => match[0].endsWith(saveFile + '.brs...'),
|
|
531
|
-
last: match => match[
|
|
531
|
+
last: match => match[2].match(/Saved .+ bricks and .+ components from .+ owners|Error: No bricks in grid!/),
|
|
532
532
|
afterMatchDelay: 0,
|
|
533
533
|
timeoutDelay: 30000
|
|
534
534
|
},
|
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
|
}
|
package/.vscode/settings.json
DELETED