u2a 3.5.2 → 3.5.4
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/.github/workflows/npm-publish.yml +22 -33
- package/package.json +1 -2
- package/src/commands/configure.js +184 -124
- package/src/commands/remove.js +18 -14
- package/src/utils/app.js +244 -0
- package/src/utils/appGenerator.js +124 -349
- package/src/utils/builder.js +125 -125
- package/src/utils/favicon.js +2 -2
- package/src/utils/logger.js +10 -6
- package/src/utils/noroot.js +41 -41
- package/src/utils/osIntegration.js +187 -187
- package/src/utils/postinstall.js +156 -119
- package/src/utils/sanitize.js +20 -20
- package/src/utils/securexec.js +12 -12
- package/src/utils/settings.js +114 -110
- package/src/utils/upgradeLA.js +141 -0
- package/src/utils/versionCheck.js +149 -149
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
name: Node.js Package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
paths:
|
|
6
|
-
- 'package.json'
|
|
7
|
-
branches:
|
|
8
|
-
- main
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- uses: actions/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
runs-on: ubuntu-latest
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v4
|
|
26
|
-
- uses: actions/setup-node@v4
|
|
27
|
-
with:
|
|
28
|
-
node-version: 20
|
|
29
|
-
registry-url: https://registry.npmjs.org/
|
|
30
|
-
- run: npm ci
|
|
31
|
-
- run: npm publish
|
|
32
|
-
env:
|
|
33
|
-
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
|
|
1
|
+
name: Node.js Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
paths:
|
|
6
|
+
- 'package.json'
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
|
|
12
|
+
publish-npm:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20
|
|
19
|
+
registry-url: https://registry.npmjs.org/
|
|
20
|
+
- run: npm publish
|
|
21
|
+
env:
|
|
22
|
+
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "u2a",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.4",
|
|
4
4
|
"description": "URL to App - Turn any URL into a desktop application",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node src/index.js",
|
|
11
|
-
"debug": "set DEBUG=1 && node src/index.js",
|
|
12
11
|
"postinstall": "node src/utils/postinstall.js"
|
|
13
12
|
},
|
|
14
13
|
"keywords": [
|
|
@@ -1,125 +1,185 @@
|
|
|
1
|
-
const Logger = require('../utils/logger');
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const { initSettings, getSetting, setSetting, resetSetting, DEFAULT_SETTINGS } = require('../utils/settings');
|
|
4
|
-
const inquirer = require('inquirer');
|
|
5
|
-
|
|
6
|
-
const logger = new Logger('configure');
|
|
7
|
-
|
|
8
|
-
function configureReports(action) {
|
|
9
|
-
try {
|
|
10
|
-
if (action === 'status') {
|
|
11
|
-
const status = getSetting('send_anon_reports');
|
|
12
|
-
logger.info(`Anonymous reports are currently ${status ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
13
|
-
logger.info(`Default setting is: ${DEFAULT_SETTINGS.send_anon_reports ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
14
|
-
return;
|
|
15
|
-
} else if (action === 'enable') {
|
|
16
|
-
setSetting('send_anon_reports', true);
|
|
17
|
-
logger.info(chalk.green('Anonymous reports have been enabled'));
|
|
18
|
-
} else if (action === 'disable') {
|
|
19
|
-
setSetting('send_anon_reports', false);
|
|
20
|
-
logger.info(chalk.yellow('Anonymous reports have been disabled'));
|
|
21
|
-
} else if (action === 'reset') {
|
|
22
|
-
resetSetting('send_anon_reports');
|
|
23
|
-
logger.info(`Anonymous reports have been resetted to: ${DEFAULT_SETTINGS.send_anon_reports ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
24
|
-
} else {
|
|
25
|
-
logger.error(`Invalid action: ${action}`);
|
|
26
|
-
logger.info('Available actions: status, enable, disable, reset');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
} catch (err) {
|
|
30
|
-
logger.error(`Error configuring reports`, err.message);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function configureVersionCheck(action) {
|
|
35
|
-
try {
|
|
36
|
-
if (action === 'status') {
|
|
37
|
-
const status = getSetting('version_check');
|
|
38
|
-
logger.info(`Version check is currently ${status ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
39
|
-
logger.info(`Default setting is: ${DEFAULT_SETTINGS.version_check ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
40
|
-
return;
|
|
41
|
-
} else if (action === 'enable') {
|
|
42
|
-
setSetting('version_check', true);
|
|
43
|
-
logger.info(chalk.green('Version check has been enabled'));
|
|
44
|
-
} else if (action === 'disable') {
|
|
45
|
-
setSetting('version_check', false);
|
|
46
|
-
logger.info(chalk.yellow('Version check has been disabled'));
|
|
47
|
-
} else if (action === 'reset') {
|
|
48
|
-
resetSetting('version_check');
|
|
49
|
-
logger.info(`Version check has been resetted to: ${DEFAULT_SETTINGS.
|
|
50
|
-
} else {
|
|
51
|
-
logger.error(`Invalid action: ${action}`);
|
|
52
|
-
logger.info('Available actions: status, enable, disable, reset');
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
} catch (err) {
|
|
56
|
-
logger.error(`Error configuring version check`, err.message);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
if (action === '
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
logger.info(
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
const Logger = require('../utils/logger');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const { initSettings, getSetting, setSetting, resetSetting, DEFAULT_SETTINGS } = require('../utils/settings');
|
|
4
|
+
const inquirer = require('inquirer');
|
|
5
|
+
|
|
6
|
+
const logger = new Logger('configure');
|
|
7
|
+
|
|
8
|
+
function configureReports(action) {
|
|
9
|
+
try {
|
|
10
|
+
if (action === 'status') {
|
|
11
|
+
const status = getSetting('send_anon_reports');
|
|
12
|
+
logger.info(`Anonymous reports are currently ${status ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
13
|
+
logger.info(`Default setting is: ${DEFAULT_SETTINGS.send_anon_reports ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
14
|
+
return;
|
|
15
|
+
} else if (action === 'enable') {
|
|
16
|
+
setSetting('send_anon_reports', true);
|
|
17
|
+
logger.info(chalk.green('Anonymous reports have been enabled'));
|
|
18
|
+
} else if (action === 'disable') {
|
|
19
|
+
setSetting('send_anon_reports', false);
|
|
20
|
+
logger.info(chalk.yellow('Anonymous reports have been disabled'));
|
|
21
|
+
} else if (action === 'reset') {
|
|
22
|
+
resetSetting('send_anon_reports');
|
|
23
|
+
logger.info(`Anonymous reports have been resetted to: ${DEFAULT_SETTINGS.send_anon_reports ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
24
|
+
} else {
|
|
25
|
+
logger.error(`Invalid action: ${action}`);
|
|
26
|
+
logger.info('Available actions: status, enable, disable, reset');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
logger.error(`Error configuring reports`, err.message);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function configureVersionCheck(action) {
|
|
35
|
+
try {
|
|
36
|
+
if (action === 'status') {
|
|
37
|
+
const status = getSetting('version_check');
|
|
38
|
+
logger.info(`Version check is currently ${status ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
39
|
+
logger.info(`Default setting is: ${DEFAULT_SETTINGS.version_check ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
40
|
+
return;
|
|
41
|
+
} else if (action === 'enable') {
|
|
42
|
+
setSetting('version_check', true);
|
|
43
|
+
logger.info(chalk.green('Version check has been enabled'));
|
|
44
|
+
} else if (action === 'disable') {
|
|
45
|
+
setSetting('version_check', false);
|
|
46
|
+
logger.info(chalk.yellow('Version check has been disabled'));
|
|
47
|
+
} else if (action === 'reset') {
|
|
48
|
+
resetSetting('version_check');
|
|
49
|
+
logger.info(`Version check has been resetted to: ${DEFAULT_SETTINGS.version_check ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
50
|
+
} else {
|
|
51
|
+
logger.error(`Invalid action: ${action}`);
|
|
52
|
+
logger.info('Available actions: status, enable, disable, reset');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
} catch (err) {
|
|
56
|
+
logger.error(`Error configuring version check`, err.message);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function configureDebug(action) {
|
|
61
|
+
try {
|
|
62
|
+
if (action === 'status') {
|
|
63
|
+
const status = getSetting('always_show_debug');
|
|
64
|
+
logger.info(`Debug logs are currently ${status ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
65
|
+
logger.info(`Default setting is: ${DEFAULT_SETTINGS.always_show_debug ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
66
|
+
return;
|
|
67
|
+
} else if (action === 'enable') {
|
|
68
|
+
setSetting('always_show_debug', true);
|
|
69
|
+
logger.info(chalk.green('Debug logs have been enabled'));
|
|
70
|
+
} else if (action === 'disable') {
|
|
71
|
+
setSetting('always_show_debug', false);
|
|
72
|
+
logger.info(chalk.yellow('Debug logs have been disabled'));
|
|
73
|
+
} else if (action === 'reset') {
|
|
74
|
+
resetSetting('always_show_debug');
|
|
75
|
+
logger.info(`Debug logs have been resetted to: ${DEFAULT_SETTINGS.always_show_debug ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
76
|
+
} else {
|
|
77
|
+
logger.error(`Invalid action: ${action}`);
|
|
78
|
+
logger.info('Available actions: status, enable, disable, reset');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
} catch (err) {
|
|
82
|
+
logger.error(`Error configuring debug logs`, err.message);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function configureAutoUpgrade(action) {
|
|
87
|
+
try {
|
|
88
|
+
if (action === 'status') {
|
|
89
|
+
const status = getSetting('autoupgrade_localapps');
|
|
90
|
+
logger.info(`Debug logs are currently ${status ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
91
|
+
logger.info(`Default setting is: ${DEFAULT_SETTINGS.autoupgrade_localapps ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
92
|
+
return;
|
|
93
|
+
} else if (action === 'enable') {
|
|
94
|
+
setSetting('autoupgrade_localapps', true);
|
|
95
|
+
logger.info(chalk.green('Automatic upgrades have been enabled'));
|
|
96
|
+
} else if (action === 'disable') {
|
|
97
|
+
setSetting('autoupgrade_localapps', false);
|
|
98
|
+
logger.info(chalk.yellow('Automatic upgrades have been disabled'));
|
|
99
|
+
} else if (action === 'reset') {
|
|
100
|
+
resetSetting('autoupgrade_localapps');
|
|
101
|
+
logger.info(`Automatic upgrades have been resetted to: ${DEFAULT_SETTINGS.autoupgrade_localapps ? chalk.green('enabled') : chalk.yellow('disabled')}`);
|
|
102
|
+
} else {
|
|
103
|
+
logger.error(`Invalid action: ${action}`);
|
|
104
|
+
logger.info('Available actions: status, enable, disable, reset');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
} catch (err) {
|
|
108
|
+
logger.error(`Error configuring auto upgrade`, err.message);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async function resetSettings(action) {
|
|
113
|
+
try {
|
|
114
|
+
if (action === 'reset') {
|
|
115
|
+
const answer = await inquirer.prompt([
|
|
116
|
+
{
|
|
117
|
+
type: 'confirm',
|
|
118
|
+
name: 'confirm',
|
|
119
|
+
message: `Are you sure you want to reset all settings to default?`,
|
|
120
|
+
default: false
|
|
121
|
+
}
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
if (!answer.confirm) {
|
|
125
|
+
logger.info('Operation canceled');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
initSettings(true);
|
|
130
|
+
logger.info(chalk.green('All settings have been reset'));
|
|
131
|
+
return;
|
|
132
|
+
} else {
|
|
133
|
+
logger.error(`Invalid action: ${action}`);
|
|
134
|
+
logger.info('Available actions: reset');
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
logger.error(`Error resetting settings`, err.message);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function configure(category, action) {
|
|
143
|
+
if (!category || !action) {
|
|
144
|
+
logger.error('Missing category or action');
|
|
145
|
+
logger.info('Usage: u2a configure [category] [action]');
|
|
146
|
+
logger.info('Available categories:');
|
|
147
|
+
logger.info(' autoupgrade - Configure automatic upgrade on installed localapps on update');
|
|
148
|
+
logger.info(' debug - Configure always showing debug logs');
|
|
149
|
+
logger.info(' reports - Configure anonymous usage reports');
|
|
150
|
+
logger.info(' settings - Resets settings (only reset action)');
|
|
151
|
+
logger.info(' vcheck - Configure automatic version check');
|
|
152
|
+
logger.info('Available actions:');
|
|
153
|
+
logger.info(' status - Check current status');
|
|
154
|
+
logger.info(' enable - Enable specified category');
|
|
155
|
+
logger.info(' disable - Disable specified category');
|
|
156
|
+
logger.info(' reset - Resets specified category to default');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
switch (category) {
|
|
161
|
+
case 'reports':
|
|
162
|
+
configureReports(action);
|
|
163
|
+
break;
|
|
164
|
+
case 'vcheck':
|
|
165
|
+
configureVersionCheck(action);
|
|
166
|
+
break;
|
|
167
|
+
case 'debug':
|
|
168
|
+
configureDebug(action);
|
|
169
|
+
break;
|
|
170
|
+
case 'settings':
|
|
171
|
+
await resetSettings(action);
|
|
172
|
+
break;
|
|
173
|
+
case 'autoupgrade':
|
|
174
|
+
await configureAutoUpgrade(action);
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
logger.error(`Unknown configuration category: ${category}`);
|
|
178
|
+
logger.info('Available categories: debug, reports, vcheck, settings');
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
module.exports = {
|
|
184
|
+
configure
|
|
125
185
|
};
|
package/src/commands/remove.js
CHANGED
|
@@ -9,7 +9,7 @@ const { getDomainName } = require('../utils/url');
|
|
|
9
9
|
|
|
10
10
|
const logger = new Logger('remove');
|
|
11
11
|
|
|
12
|
-
async function processRemoval(appName) {
|
|
12
|
+
async function processRemoval(appName, useInquirer) {
|
|
13
13
|
try {
|
|
14
14
|
const db = readDB();
|
|
15
15
|
|
|
@@ -18,18 +18,22 @@ async function processRemoval(appName) {
|
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
if (useInquirer) {
|
|
22
|
+
|
|
23
|
+
const { confirm } = await inquirer.prompt([
|
|
24
|
+
{
|
|
25
|
+
type: 'confirm',
|
|
26
|
+
name: 'confirm',
|
|
27
|
+
message: `Are you sure you want to remove the application for ${appName}?`,
|
|
28
|
+
default: false
|
|
29
|
+
}
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
if (!confirm) {
|
|
33
|
+
logger.info('Operation canceled');
|
|
34
|
+
return;
|
|
27
35
|
}
|
|
28
|
-
]);
|
|
29
36
|
|
|
30
|
-
if (!confirm) {
|
|
31
|
-
logger.info('Operation canceled');
|
|
32
|
-
return;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
const appInfo = db[appName];
|
|
@@ -47,7 +51,7 @@ async function processRemoval(appName) {
|
|
|
47
51
|
|
|
48
52
|
const packageName = `u2a-${appName.replace(/\s+/g, '-')}`;
|
|
49
53
|
let appDataPath;
|
|
50
|
-
|
|
54
|
+
|
|
51
55
|
if (process.platform === 'win32') {
|
|
52
56
|
appDataPath = path.join(process.env.APPDATA, packageName);
|
|
53
57
|
} else if (process.platform === 'darwin') {
|
|
@@ -73,9 +77,9 @@ async function processRemoval(appName) {
|
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
async function removeApp(appName) {
|
|
80
|
+
async function removeApp(appName, useInquirer = true) {
|
|
77
81
|
const sAppName = sanitizeInput(appName);
|
|
78
|
-
await processRemoval(sAppName);
|
|
82
|
+
await processRemoval(sAppName, useInquirer);
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
module.exports = {
|