Skip to content

Commit 52ec87e

Browse files
authored
Merge pull request #20 from oracle/v2.4.1
Release 2.4.1
2 parents 6ae16e0 + 958d3cd commit 52ec87e

File tree

736 files changed

+39397
-18762
lines changed

Some content is hidden

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

736 files changed

+39397
-18762
lines changed

assembly/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<artifactId>console-backend</artifactId>
1111
<groupId>com.oracle.weblogic</groupId>
12-
<version>2.4.0</version>
12+
<version>2.4.1</version>
1313
</parent>
1414

1515
<packaging>pom</packaging>

build-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.oracle.weblogic.console-backend</groupId>
88
<artifactId>build-tools</artifactId>
9-
<version>2.4.0</version>
9+
<version>2.4.1</version>
1010
<name>Build Tools</name>
1111

1212
<properties>

electron/app/js/auto-prefs-json.js

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2022, Oracle and/or its affiliates.
4+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
* @ignore
6+
*/
7+
8+
'use strict';
9+
10+
/**
11+
*
12+
* See {@link https://stackabuse.com/javascripts-immediately-invoked-function-expressions/}
13+
* @type {{getAll, get, set, read, write}}
14+
* @example
15+
* AutoPrefs.read(`${app.getPath('appData')}/weblogic-remote-console`);
16+
* let props = {
17+
* version: '2.4.1',
18+
* location: '/Applications/WebLogic Remote Console.app/Contents/MacOS/WebLogic Remote Console'
19+
* };
20+
* AutoPrefs.set(props);
21+
* const width = AutoPref.get('width');
22+
* console.log(width);
23+
* props = AutoPrefs.getAll();
24+
* console.log(JSON.stringify(props));
25+
* // The following line raises a TypeError in strict mode
26+
* props['width'] = 1470;
27+
* // Do this to not raise the TypeError
28+
* AutoPrefs.set({width: 1470});
29+
* // The following works because you can add new
30+
* // properties, you just can't modify existing
31+
* // without using the AutoPrefs.set() function.
32+
* props['canAddNewProperty'] = true;
33+
* // The following updates the auto-prefs.json file,
34+
* // using the previous value for userDataPath as
35+
* // the path to it. You can also just pass in the
36+
* // path if you want, just like you did previously
37+
* // with AutoPrefs.read(<user-data-path>).
38+
* AutoPrefs.write();
39+
*/
40+
const AutoPrefs = (() => {
41+
const fs = require('fs');
42+
const {log} = require('./console-logger');
43+
const UserProjects = require('./user-projects-json');
44+
const UserPrefs = require('./user-prefs-json');
45+
46+
const _appPaths = {};
47+
let _fields = {};
48+
49+
((version, width, height, location) => {
50+
_fields['version'] = version;
51+
_fields['width'] = width;
52+
_fields['height'] = height;
53+
_fields['location'] = location;
54+
})(null, 1600, 1000, null);
55+
56+
return {
57+
/**
58+
* Gets an immutable, shallow copy of the in-memory data that ``AutoPrefs`` knows about.
59+
* <p>You can add new in-memory data, but you can only change the value of existing ones using the ``AutoPrefs.set()`` function.</p>
60+
* @returns {readonly}
61+
*/
62+
getAll: () => { return Object.freeze(_fields); },
63+
/**
64+
* Gets the value of the ``AutoPrefs`` in-memory field with a given ``key``.
65+
* @param {string} [key='']
66+
* @returns {object|undefined}
67+
*/
68+
get: (key = '') => { return _fields[key]; },
69+
/**
70+
* Upserts the in-memory data that ``AutoPrefs`` knows about.
71+
* @param {object} [fields={}]
72+
*/
73+
set: (fields = {}) => {
74+
if (fields.version) _fields.version = fields.version;
75+
if (fields.width) _fields.width = fields.width;
76+
if (fields.height) _fields.height = fields.height;
77+
if (fields.location) _fields.location = fields.location;
78+
},
79+
/**
80+
* Removes in-memory field from ``AutoPrefs`` with a given ``key``.
81+
* @param {string} [key='']
82+
*/
83+
remove: (key = '') => {
84+
delete _fields[key];
85+
},
86+
/**
87+
* Removes all the in-memory data from ``AutoPrefs``.
88+
*/
89+
clear: () => {
90+
_fields = {};
91+
},
92+
/**
93+
* Populates the in-memory data that ``AutoPrefs`` knows about, by reading and parsing the JSON content in the ``auto-prefs.json`` file.
94+
* <p>If the <code>userDataPath</code> argument was passed, it's used as the path to the <code>auto-prefs.json</code> file. Otherwise, a check is done to see if a <code>userDataPath</code> in-memory field has been set. If so, then the value assigned to that field is used used as the path to the <code>auto-prefs.json</code> file.</p>
95+
* @param {string} [userDataPath]
96+
*/
97+
read: (userDataPath) => {
98+
if (!userDataPath) userDataPath = _appPaths.userDataPath;
99+
if (userDataPath) {
100+
// Update _fields.userDataPath with value passed as
101+
// function argument, regardless.
102+
_appPaths.userDataPath = userDataPath;
103+
// Construct full path to auto-prefs.json file
104+
const filepath = `${userDataPath}/auto-prefs.json`;
105+
if (fs.existsSync(filepath)) {
106+
try {
107+
const props = JSON.parse(fs.readFileSync(filepath));
108+
// Update all the other _fields with values from the
109+
// file just read.
110+
AutoPrefs.set(props);
111+
// See if auto-prefs.json contained a projects field
112+
if (typeof props.projects !== 'undefined') {
113+
// It did, so use it to do a UserProjects.putAll()
114+
UserProjects.putAll(props.projects);
115+
// Use UserProjects.write() to write out the
116+
// in-memory projects.
117+
UserProjects.write(userDataPath);
118+
}
119+
// See if auto-prefs.json contained a preferences field
120+
if (typeof props.preferences !== 'undefined') {
121+
// It did, so use it to do a UserPrefs.putAll()
122+
UserPrefs.putAll(props.preferences);
123+
// Use UserPrefs.write() to write out the
124+
// in-memory preferences.
125+
UserPrefs.write(userDataPath);
126+
}
127+
// The auto-prefs.json field could have contained a
128+
// projects or preferences field, which will not be
129+
// in the _fields. Write out the updated _fields.
130+
AutoPrefs.write(userDataPath);
131+
}
132+
catch(err) {
133+
log('error', err);
134+
}
135+
}
136+
}
137+
},
138+
/**
139+
* Writes in-memory data that ``AutoPrefs``knows about to the ``auto-prefs.json`` file.
140+
* <p>If the <code>userDataPath</code> argument was passed, it's used as the path to the <code>auto-prefs.json</code> file. Otherwise, a check is done to see if a <code>userDataPath</code> in-memory field has been set. If so, then the value assigned to that field is used used as the path to the <code>auto-prefs.json</code> file.</p>
141+
* <p>An attempt is made to create the <code>userDataPath/auto-prefs.json</code> file, if it doesn't already exists.t</p>
142+
* @param {string} [userDataPath]
143+
*/
144+
write: (userDataPath) => {
145+
if (!userDataPath) userDataPath = _appPaths.userDataPath;
146+
if (userDataPath) {
147+
try {
148+
// Update _fields.userDataPath with value passed as
149+
// function argument, regardless.
150+
_appPaths.userDataPath = userDataPath;
151+
// Construct full path to auto-prefs.json file
152+
const filepath = `${userDataPath}/auto-prefs.json`;
153+
// Remove _fields.userDataPath property, so it won't
154+
// get written out.
155+
delete _fields.userDataPath;
156+
// The openstack.org convention is to use 4 spaces
157+
// for indentation.
158+
fs.writeFileSync(filepath, JSON.stringify(_fields, null, 4));
159+
}
160+
catch(err) {
161+
log('error', err);
162+
}
163+
}
164+
}
165+
};
166+
167+
})();
168+
169+
module.exports = AutoPrefs;

electron/app/js/auto-update-utils.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2022, Oracle and/or its affiliates.
4+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
* @ignore
6+
*/
7+
8+
'use strict';
9+
10+
const { autoUpdater } = require('electron-updater');
11+
12+
let _updateInfo;
13+
14+
(() => {
15+
autoUpdater.autoDownload = false;
16+
})();
17+
18+
autoUpdater.on('update-available', (info) => {
19+
_updateInfo = info;
20+
});
21+
22+
async function checkForUpdates() {
23+
return Promise.resolve(getAutoUpdateInfo());
24+
}
25+
26+
function getAutoUpdateInfo() {
27+
return (typeof _updateInfo === 'undefined' ? {version: autoUpdater.currentVersion.version} : _updateInfo);
28+
}
29+
30+
module.exports = {
31+
getAutoUpdateInfo,
32+
checkForUpdates
33+
};

electron/app/js/config-json.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2022, Oracle and/or its affiliates.
4+
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
* @ignore
6+
*/
7+
8+
'use strict';
9+
10+
/**
11+
* See {@link https://stackabuse.com/javascripts-immediately-invoked-function-expressions/}
12+
* @type {{getFilename, getAll, set, read, get, initialize, write}}
13+
*/
14+
const AppConfig = (() => {
15+
const fs = require('fs');
16+
const {log} = require('./console-logger');
17+
18+
const _appPaths = {};
19+
const _config = {};
20+
21+
return {
22+
initialize: (options) => {
23+
_appPaths['userDataPath'] = options.appPaths.userData;
24+
_appPaths['exe'] = options.appPaths.exe;
25+
26+
_config['useTokenNotCookie'] = options.useTokenNotCookie;
27+
_config['showPort'] = options.showPort;
28+
_config['quiet'] = options.quiet;
29+
_config['checkPpidMillis'] = options.checkPpidMillis;
30+
_config['executableJar'] = `${options.appPaths.exe}/${options.executablePath}`;
31+
_config['javaBinary'] = `${options.appPaths.exe}/${options.javaPath}`;
32+
_config['persistenceDirectory'] = options.appPaths.userData;
33+
},
34+
getFilename: () => {
35+
return `${_appPaths.userDataPath}/config.json`;
36+
},
37+
getAll: () => {
38+
return _config;
39+
},
40+
get: (key = '') => { return _config[key]; },
41+
set: (settings) => {
42+
if (settings.useTokenNotCookie) _config['useTokenNotCookie'] = settings.useTokenNotCookie;
43+
if (settings.showPort) _config['showPort'] = settings.showPort;
44+
if (settings.quiet) _config['quiet'] = settings.quiet;
45+
if (settings.checkPpidMillis) _config['checkPpidMillis'] = settings.checkPpidMillis;
46+
if (settings.javaPath) _config['javaBinary'] = `${_appPaths.exe}/${settings.javaPath}`;
47+
if (settings.executablePath) _config['executableJar'] = `${_appPaths.exe}/${settings.executablePath}`;
48+
},
49+
read: () => {
50+
if (fs.existsSync(AppConfig.getFilename())) {
51+
try {
52+
const settings = JSON.parse(fs.readFileSync(AppConfig.getFilename()).toString());
53+
AppConfig.set(settings);
54+
}
55+
catch(err) {
56+
log('error', err);
57+
}
58+
}
59+
},
60+
write: () => {
61+
// Creates the file, if it doesn't exists
62+
fs.writeFileSync(AppConfig.getFilename(), JSON.stringify(_config, null, 4));
63+
}
64+
};
65+
66+
})();
67+
68+
module.exports = AppConfig;

0 commit comments

Comments
 (0)