u2a 3.4.13 → 3.4.16
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/commands/create.js +25 -16
- package/src/commands/remove.js +4 -2
- package/src/index.js +1 -0
- package/src/utils/versionCheck.js +1 -0
package/package.json
CHANGED
package/src/commands/create.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
3
|
const { normalizeUrl, getDomainName } = require('../utils/url');
|
|
5
4
|
const { getFavicon, processFavicon } = require('../utils/favicon');
|
|
6
5
|
const { APPS_DIR, readDB, writeDB } = require('../utils/config');
|
|
@@ -57,7 +56,20 @@ async function createApp(url, options) {
|
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
let iconPath;
|
|
60
|
+
if (options.icon) {
|
|
61
|
+
const iconFilePath = path.resolve(options.icon);
|
|
62
|
+
if (fs.existsSync(iconFilePath) && path.extname(iconFilePath) === '.ico') {
|
|
63
|
+
iconPath = iconFilePath;
|
|
64
|
+
logger.success(`Using ${iconPath} for ${appName}`)
|
|
65
|
+
} else {
|
|
66
|
+
logger.warn(`Provided icon path is not a valid .ico file: ${iconFilePath}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!iconPath) {
|
|
71
|
+
iconPath = await getFavicon(url);
|
|
72
|
+
}
|
|
61
73
|
|
|
62
74
|
const appDir = path.join(APPS_DIR, appName);
|
|
63
75
|
if (!fs.existsSync(appDir)) {
|
|
@@ -99,41 +111,38 @@ async function createApp(url, options) {
|
|
|
99
111
|
const setupPath = await buildSetup(appDir, targetPlatform, options.arch);
|
|
100
112
|
if (setupPath) {
|
|
101
113
|
logger.debug(`Setup installer created at: ${setupPath}`);
|
|
102
|
-
|
|
114
|
+
|
|
103
115
|
const currentDir = process.cwd();
|
|
104
116
|
const setupTargetDir = path.join(currentDir, `${appName}-setup`);
|
|
105
|
-
|
|
117
|
+
|
|
106
118
|
if (!fs.existsSync(setupTargetDir)) {
|
|
107
119
|
fs.mkdirSync(setupTargetDir, { recursive: true });
|
|
108
120
|
}
|
|
109
|
-
|
|
121
|
+
|
|
110
122
|
copyFolderRecursiveSync(setupPath, setupTargetDir);
|
|
111
123
|
logger.success(`Setup installer created at: ${setupTargetDir}`);
|
|
112
124
|
}
|
|
113
125
|
}
|
|
114
|
-
|
|
126
|
+
|
|
115
127
|
if (executablePath) {
|
|
116
128
|
logger.debug(`Executable created at: ${executablePath}`);
|
|
117
|
-
|
|
129
|
+
|
|
118
130
|
const currentDir = process.cwd();
|
|
119
131
|
const targetDir = path.join(currentDir, `${appName}-executable`);
|
|
120
|
-
|
|
132
|
+
|
|
121
133
|
if (!fs.existsSync(targetDir)) {
|
|
122
134
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
123
135
|
}
|
|
124
|
-
|
|
136
|
+
|
|
125
137
|
copyFolderRecursiveSync(executablePath, targetDir);
|
|
126
|
-
|
|
138
|
+
|
|
127
139
|
logger.success(`Executable created at: ${targetDir}`);
|
|
128
|
-
|
|
140
|
+
|
|
129
141
|
executablePath = targetDir;
|
|
130
|
-
|
|
142
|
+
|
|
131
143
|
removeAppFromOS(appName);
|
|
132
144
|
remove(appDir);
|
|
133
|
-
|
|
134
|
-
remove(iconPath);
|
|
135
|
-
}
|
|
136
|
-
|
|
145
|
+
|
|
137
146
|
logger.debug(`Temporary application files removed after executable creation`);
|
|
138
147
|
return;
|
|
139
148
|
}
|
package/src/commands/remove.js
CHANGED
|
@@ -5,6 +5,7 @@ const Logger = require('../utils/logger');
|
|
|
5
5
|
const { removeAppFromOS } = require('./create');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const { sanitizeInput } = require('../utils/sanitize');
|
|
8
|
+
const { getDomainName } = require('../utils/url');
|
|
8
9
|
|
|
9
10
|
const logger = new Logger('remove');
|
|
10
11
|
|
|
@@ -32,12 +33,13 @@ async function processRemoval(appName) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
const appInfo = db[appName];
|
|
36
|
+
const domain = getDomainName(appInfo.url)
|
|
35
37
|
const appDir = appInfo.path;
|
|
36
38
|
|
|
37
39
|
logger.info(`Removing the application ${appName}...`);
|
|
38
40
|
removeAppFromOS(appName);
|
|
39
41
|
|
|
40
|
-
const iconPath = path.join(APPS_DIR, `${
|
|
42
|
+
const iconPath = path.join(APPS_DIR, `${domain}.ico`);
|
|
41
43
|
if (fs.existsSync(iconPath)) {
|
|
42
44
|
fs.unlinkSync(iconPath);
|
|
43
45
|
logger.success(`Icon for ${appName} removed`);
|
|
@@ -60,8 +62,8 @@ async function processRemoval(appName) {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
fs.rmSync(appDir, { recursive: true, force: true });
|
|
65
|
+
logger.success(`Application files removed: ${appDir}`);
|
|
63
66
|
|
|
64
|
-
fs.rmSync(appDir, { recursive: true, force: true });
|
|
65
67
|
delete db[appName];
|
|
66
68
|
writeDB(db);
|
|
67
69
|
|
package/src/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const { checkVersion } = require('./utils/versionCheck');
|
|
|
30
30
|
.option('--name <name>', 'Specify the application name')
|
|
31
31
|
.option('--width <width>', 'Specify the window width', parseInt)
|
|
32
32
|
.option('--height <height>', 'Specify the window height', parseInt)
|
|
33
|
+
.option('--icon <path>', 'Use a custom icon (.ico) instead of the default one')
|
|
33
34
|
.option('--executable [windows|darwin|linux]', 'Create a single executable for the target system')
|
|
34
35
|
.option('--arch [x64|armv7l|arm64|universal]', 'Specify the target architecture for the executable')
|
|
35
36
|
.option('--setup', 'Creates a setup file for the executable')
|
|
@@ -19,6 +19,7 @@ async function checkVersion(silent = false) {
|
|
|
19
19
|
|
|
20
20
|
if (!silent && needsUpdate && latestVersion !== version) {
|
|
21
21
|
logger.debug(`New update available: ${latestVersion}`);
|
|
22
|
+
console.log('');
|
|
22
23
|
logger.warn(`A new update (${latestVersion}) is available ! Current version: ${version}`);
|
|
23
24
|
logger.warn(`Update u2a with: npm install -g u2a@${latestVersion}`);
|
|
24
25
|
}
|