gologin 2.0.8 → 2.0.10
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
|
@@ -9,6 +9,8 @@ import ProgressBar from 'progress';
|
|
|
9
9
|
import { createInterface } from 'readline';
|
|
10
10
|
import util from 'util';
|
|
11
11
|
|
|
12
|
+
import { findLatestBrowserVersionDirectory } from '../utils/utils.js';
|
|
13
|
+
|
|
12
14
|
const exec = util.promisify(execNonPromise);
|
|
13
15
|
const { access, mkdir, readdir, rmdir, unlink, copyFile, readlink, symlink, lstat } = _promises;
|
|
14
16
|
|
|
@@ -50,7 +52,12 @@ export class BrowserChecker {
|
|
|
50
52
|
|
|
51
53
|
let executableFilePath = join(this.#browserPath, 'orbita-browser', 'chrome');
|
|
52
54
|
if (PLATFORM === 'darwin') {
|
|
53
|
-
|
|
55
|
+
const orbitaFolderName = findLatestBrowserVersionDirectory(this.#browserPath);
|
|
56
|
+
if (orbitaFolderName === 'error') {
|
|
57
|
+
throw Error('Orbita folder not found in this directory: ' + this.#browserPath);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
executableFilePath = join(this.#browserPath, orbitaFolderName, 'Orbita-Browser.app', 'Contents', 'MacOS', 'Orbita');
|
|
54
61
|
} else if (PLATFORM === 'win32') {
|
|
55
62
|
executableFilePath = join(this.#browserPath, 'orbita-browser', 'chrome.exe');
|
|
56
63
|
}
|
package/src/gologin.js
CHANGED
|
@@ -584,15 +584,15 @@ export class GoLogin {
|
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
586
|
|
|
587
|
-
const
|
|
587
|
+
const languages = this.language.replace(/;|q=[\d\.]+/img, '')
|
|
588
588
|
|
|
589
589
|
if (preferences.gologin==null) {
|
|
590
590
|
preferences.gologin = {};
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
preferences.gologin.langHeader = gologin.language;
|
|
594
|
-
preferences.gologin.
|
|
595
|
-
|
|
594
|
+
preferences.gologin.language = languages;
|
|
595
|
+
|
|
596
596
|
await writeFile(join(profilePath, 'Default', 'Preferences'), JSON.stringify(Object.assign(preferences, {
|
|
597
597
|
gologin,
|
|
598
598
|
})));
|
package/src/utils/utils.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
1
2
|
import net from 'node:net';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
|
|
3
5
|
export const get = (value, path, defaultValue) =>
|
|
4
6
|
String(path).split('.').reduce((acc, v) => {
|
|
@@ -20,3 +22,28 @@ export const isPortReachable = (port) => new Promise(resolve => {
|
|
|
20
22
|
.listen(port);
|
|
21
23
|
});
|
|
22
24
|
|
|
25
|
+
export const findLatestBrowserVersionDirectory = (browserPath) => {
|
|
26
|
+
const folderContents = readdirSync(browserPath);
|
|
27
|
+
const directories = folderContents.filter(file => statSync(join(browserPath, file)).isDirectory());
|
|
28
|
+
|
|
29
|
+
const { folderName, version } = directories.reduce((newest, currentFolderName) => {
|
|
30
|
+
const match = currentFolderName.match(/\d+/);
|
|
31
|
+
|
|
32
|
+
if (match) {
|
|
33
|
+
const findedVersion = parseInt(match[0], 10);
|
|
34
|
+
|
|
35
|
+
if (findedVersion > newest.version) {
|
|
36
|
+
return { folderName: currentFolderName, version: findedVersion };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return newest;
|
|
41
|
+
}, { folderName: '', version: 0 });
|
|
42
|
+
|
|
43
|
+
if (!version) {
|
|
44
|
+
return 'error';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return folderName;
|
|
48
|
+
};
|
|
49
|
+
|