pake-cli 2.1.6 → 2.1.7
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/dist/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ import isUrl from 'is-url';
|
|
|
20
20
|
import fs from 'fs';
|
|
21
21
|
|
|
22
22
|
var name = "pake-cli";
|
|
23
|
-
var version = "2.1.
|
|
23
|
+
var version = "2.1.7";
|
|
24
24
|
var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App。";
|
|
25
25
|
var engines = {
|
|
26
26
|
node: ">=16.0.0"
|
|
@@ -305,7 +305,7 @@ var LinuxConf = {
|
|
|
305
305
|
const platformConfigs = {
|
|
306
306
|
win32: WinConf,
|
|
307
307
|
darwin: MacConf,
|
|
308
|
-
linux: LinuxConf
|
|
308
|
+
linux: LinuxConf,
|
|
309
309
|
};
|
|
310
310
|
const { platform: platform$2 } = process;
|
|
311
311
|
// @ts-ignore
|
|
@@ -317,15 +317,12 @@ let tauriConfig = {
|
|
|
317
317
|
},
|
|
318
318
|
package: CommonConf.package,
|
|
319
319
|
build: CommonConf.build,
|
|
320
|
-
pake: pakeConf
|
|
320
|
+
pake: pakeConf,
|
|
321
321
|
};
|
|
322
322
|
|
|
323
323
|
// Generates an identifier based on the given URL.
|
|
324
324
|
function getIdentifier(url) {
|
|
325
|
-
const postFixHash = crypto.createHash('md5')
|
|
326
|
-
.update(url)
|
|
327
|
-
.digest('hex')
|
|
328
|
-
.substring(0, 6);
|
|
325
|
+
const postFixHash = crypto.createHash('md5').update(url).digest('hex').substring(0, 6);
|
|
329
326
|
return `pake-${postFixHash}`;
|
|
330
327
|
}
|
|
331
328
|
async function promptText(message, initial) {
|
|
@@ -342,19 +339,14 @@ function capitalizeFirstLetter(string) {
|
|
|
342
339
|
}
|
|
343
340
|
function getSpinner(text) {
|
|
344
341
|
const loadingType = {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
"✦",
|
|
348
|
-
"✶",
|
|
349
|
-
"✺",
|
|
350
|
-
"✵",
|
|
351
|
-
"✸",
|
|
352
|
-
"✴︎",
|
|
353
|
-
"✹",
|
|
354
|
-
"✺",
|
|
355
|
-
]
|
|
342
|
+
interval: 80,
|
|
343
|
+
frames: ['✦', '✶', '✺', '✵', '✸', '✹', '✺'],
|
|
356
344
|
};
|
|
357
|
-
return ora({
|
|
345
|
+
return ora({
|
|
346
|
+
text: `${chalk.cyan(text)}\n`,
|
|
347
|
+
spinner: loadingType,
|
|
348
|
+
color: 'cyan',
|
|
349
|
+
}).start();
|
|
358
350
|
}
|
|
359
351
|
|
|
360
352
|
const { platform: platform$1 } = process;
|
|
@@ -369,7 +361,7 @@ const npmDirectory = path.join(path.dirname(currentModulePath), '..');
|
|
|
369
361
|
|
|
370
362
|
function shellExec(command) {
|
|
371
363
|
return new Promise((resolve, reject) => {
|
|
372
|
-
shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory },
|
|
364
|
+
shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory }, code => {
|
|
373
365
|
if (code === 0) {
|
|
374
366
|
resolve(0);
|
|
375
367
|
}
|
|
@@ -382,20 +374,20 @@ function shellExec(command) {
|
|
|
382
374
|
|
|
383
375
|
const logger = {
|
|
384
376
|
info(...msg) {
|
|
385
|
-
log.info(...msg.map(
|
|
377
|
+
log.info(...msg.map(m => chalk.white(m)));
|
|
386
378
|
},
|
|
387
379
|
debug(...msg) {
|
|
388
380
|
log.debug(...msg);
|
|
389
381
|
},
|
|
390
382
|
error(...msg) {
|
|
391
|
-
log.error(...msg.map(
|
|
383
|
+
log.error(...msg.map(m => chalk.red(m)));
|
|
392
384
|
},
|
|
393
385
|
warn(...msg) {
|
|
394
|
-
log.info(...msg.map(
|
|
386
|
+
log.info(...msg.map(m => chalk.yellow(m)));
|
|
395
387
|
},
|
|
396
388
|
success(...msg) {
|
|
397
|
-
log.info(...msg.map(
|
|
398
|
-
}
|
|
389
|
+
log.info(...msg.map(m => chalk.green(m)));
|
|
390
|
+
},
|
|
399
391
|
};
|
|
400
392
|
|
|
401
393
|
const resolve = promisify(dns.resolve);
|
|
@@ -405,12 +397,12 @@ const ping = async (host) => {
|
|
|
405
397
|
const start = new Date();
|
|
406
398
|
// Prevent timeouts from affecting user experience.
|
|
407
399
|
const requestPromise = new Promise((resolve, reject) => {
|
|
408
|
-
const req = http.get(`http://${ip.address}`,
|
|
400
|
+
const req = http.get(`http://${ip.address}`, res => {
|
|
409
401
|
const delay = new Date().getTime() - start.getTime();
|
|
410
402
|
res.resume();
|
|
411
403
|
resolve(delay);
|
|
412
404
|
});
|
|
413
|
-
req.on('error',
|
|
405
|
+
req.on('error', err => {
|
|
414
406
|
reject(err);
|
|
415
407
|
});
|
|
416
408
|
});
|
|
@@ -444,7 +436,7 @@ async function isChinaIP(ip, domain) {
|
|
|
444
436
|
}
|
|
445
437
|
|
|
446
438
|
async function installRust() {
|
|
447
|
-
const isInChina = await isChinaDomain(
|
|
439
|
+
const isInChina = await isChinaDomain('sh.rustup.rs');
|
|
448
440
|
const rustInstallScriptForMac = isInChina
|
|
449
441
|
? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh'
|
|
450
442
|
: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
|
|
@@ -495,7 +487,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
495
487
|
fsExtra.moveSync(distDir, distBakDir, { overwrite: true });
|
|
496
488
|
fsExtra.copySync(dirName, distDir, { overwrite: true });
|
|
497
489
|
const filesToCopyBack = ['cli.js', 'about_pake.html'];
|
|
498
|
-
await Promise.all(filesToCopyBack.map(
|
|
490
|
+
await Promise.all(filesToCopyBack.map(file => fsExtra.copy(path.join(distBakDir, file), path.join(distDir, file))));
|
|
499
491
|
}
|
|
500
492
|
tauriConf.pake.windows[0].url = fileName;
|
|
501
493
|
tauriConf.pake.windows[0].url_type = 'local';
|
|
@@ -503,8 +495,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
503
495
|
else {
|
|
504
496
|
tauriConf.pake.windows[0].url_type = 'web';
|
|
505
497
|
// Set the secure domain for calling window.__TAURI__ to the application domain that has been set.
|
|
506
|
-
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess[0].domain =
|
|
507
|
-
new URL(url).hostname;
|
|
498
|
+
tauriConf.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = new URL(url).hostname;
|
|
508
499
|
}
|
|
509
500
|
const platformMap = {
|
|
510
501
|
win32: 'windows',
|
|
@@ -522,7 +513,8 @@ async function mergeConfig(url, options, tauriConf) {
|
|
|
522
513
|
delete tauriConf.tauri.bundle.deb.files;
|
|
523
514
|
const validTargets = ['all', 'deb', 'appimage'];
|
|
524
515
|
if (validTargets.includes(options.targets)) {
|
|
525
|
-
tauriConf.tauri.bundle.targets =
|
|
516
|
+
tauriConf.tauri.bundle.targets =
|
|
517
|
+
options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
|
|
526
518
|
}
|
|
527
519
|
else {
|
|
528
520
|
logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
|
|
@@ -622,8 +614,8 @@ class BaseBuilder {
|
|
|
622
614
|
}
|
|
623
615
|
async prepare() {
|
|
624
616
|
if (!IS_MAC) {
|
|
625
|
-
logger.info('
|
|
626
|
-
logger.info('
|
|
617
|
+
logger.info('✺ The first use requires installing system dependencies.');
|
|
618
|
+
logger.info('✺ See more in https://tauri.app/v1/guides/getting-started/prerequisites.');
|
|
627
619
|
}
|
|
628
620
|
if (!checkRustInstalled()) {
|
|
629
621
|
const res = await prompts({
|
|
@@ -639,14 +631,14 @@ class BaseBuilder {
|
|
|
639
631
|
process.exit(0);
|
|
640
632
|
}
|
|
641
633
|
}
|
|
642
|
-
const isChina = await isChinaDomain(
|
|
634
|
+
const isChina = await isChinaDomain('www.npmjs.com');
|
|
643
635
|
const spinner = getSpinner('Installing package...');
|
|
644
636
|
if (isChina) {
|
|
645
|
-
logger.info(
|
|
646
|
-
const rustProjectDir = path.join(npmDirectory, 'src-tauri',
|
|
637
|
+
logger.info('✺ Located in China, using npm/rsProxy CN mirror.');
|
|
638
|
+
const rustProjectDir = path.join(npmDirectory, 'src-tauri', '.cargo');
|
|
647
639
|
await fsExtra.ensureDir(rustProjectDir);
|
|
648
|
-
const projectCnConf = path.join(npmDirectory,
|
|
649
|
-
const projectConf = path.join(rustProjectDir,
|
|
640
|
+
const projectCnConf = path.join(npmDirectory, 'src-tauri', 'rust_proxy.toml');
|
|
641
|
+
const projectConf = path.join(rustProjectDir, 'config');
|
|
650
642
|
await fsExtra.copy(projectCnConf, projectConf);
|
|
651
643
|
await shellExec(`cd "${npmDirectory}" && npm install --registry=https://registry.npmmirror.com`);
|
|
652
644
|
}
|
|
@@ -679,7 +671,7 @@ class BaseBuilder {
|
|
|
679
671
|
return target;
|
|
680
672
|
}
|
|
681
673
|
getBuildCommand() {
|
|
682
|
-
return
|
|
674
|
+
return 'npm run build';
|
|
683
675
|
}
|
|
684
676
|
getBasePath() {
|
|
685
677
|
return 'src-tauri/target/release/bundle/';
|
|
@@ -692,7 +684,7 @@ class BaseBuilder {
|
|
|
692
684
|
class MacBuilder extends BaseBuilder {
|
|
693
685
|
constructor(options) {
|
|
694
686
|
super(options);
|
|
695
|
-
this.options.targets =
|
|
687
|
+
this.options.targets = 'dmg';
|
|
696
688
|
}
|
|
697
689
|
getFileName() {
|
|
698
690
|
const { name } = this.options;
|
|
@@ -701,7 +693,7 @@ class MacBuilder extends BaseBuilder {
|
|
|
701
693
|
arch = 'universal';
|
|
702
694
|
}
|
|
703
695
|
else {
|
|
704
|
-
arch = process.arch ===
|
|
696
|
+
arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
|
|
705
697
|
}
|
|
706
698
|
return `${name}_${tauriConfig.package.version}_${arch}`;
|
|
707
699
|
}
|
|
@@ -718,7 +710,7 @@ class MacBuilder extends BaseBuilder {
|
|
|
718
710
|
class WinBuilder extends BaseBuilder {
|
|
719
711
|
constructor(options) {
|
|
720
712
|
super(options);
|
|
721
|
-
this.options.targets =
|
|
713
|
+
this.options.targets = 'msi';
|
|
722
714
|
}
|
|
723
715
|
getFileName() {
|
|
724
716
|
const { name } = this.options;
|
|
@@ -734,14 +726,14 @@ class LinuxBuilder extends BaseBuilder {
|
|
|
734
726
|
}
|
|
735
727
|
getFileName() {
|
|
736
728
|
const { name } = this.options;
|
|
737
|
-
const arch = process.arch ===
|
|
729
|
+
const arch = process.arch === 'x64' ? 'amd64' : process.arch;
|
|
738
730
|
return `${name}_${tauriConfig.package.version}_${arch}`;
|
|
739
731
|
}
|
|
740
732
|
// Customize it, considering that there are all targets.
|
|
741
733
|
async build(url) {
|
|
742
|
-
const targetTypes = [
|
|
734
|
+
const targetTypes = ['deb', 'appimage'];
|
|
743
735
|
for (const target of targetTypes) {
|
|
744
|
-
if (this.options.targets === target || this.options.targets ===
|
|
736
|
+
if (this.options.targets === target || this.options.targets === 'all') {
|
|
745
737
|
await this.buildAndCopy(url, target);
|
|
746
738
|
}
|
|
747
739
|
}
|
|
@@ -802,7 +794,11 @@ async function handleIcon(options) {
|
|
|
802
794
|
}
|
|
803
795
|
else {
|
|
804
796
|
logger.warn('✼ No icon given, default in use. For a custom icon, use --icon option.');
|
|
805
|
-
const iconPath = IS_WIN
|
|
797
|
+
const iconPath = IS_WIN
|
|
798
|
+
? 'src-tauri/png/icon_256.ico'
|
|
799
|
+
: IS_LINUX
|
|
800
|
+
? 'src-tauri/png/icon_512.png'
|
|
801
|
+
: 'src-tauri/icons/icon.icns';
|
|
806
802
|
return path.join(npmDirectory, iconPath);
|
|
807
803
|
}
|
|
808
804
|
}
|
|
@@ -840,7 +836,7 @@ function getDomain(inputUrl) {
|
|
|
840
836
|
// Use PSL to parse domain names.
|
|
841
837
|
const parsed = psl.parse(url.hostname);
|
|
842
838
|
// If domain is available, split it and return the SLD.
|
|
843
|
-
if (
|
|
839
|
+
if ('domain' in parsed && parsed.domain) {
|
|
844
840
|
return parsed.domain.split('.')[0];
|
|
845
841
|
}
|
|
846
842
|
else {
|
|
@@ -890,7 +886,7 @@ async function handleOptions(options, url) {
|
|
|
890
886
|
let name = options.name;
|
|
891
887
|
const pathExists = await fsExtra.pathExists(url);
|
|
892
888
|
if (!options.name) {
|
|
893
|
-
const defaultName = pathExists ?
|
|
889
|
+
const defaultName = pathExists ? '' : resolveAppName(url, platform);
|
|
894
890
|
const promptMessage = 'Enter your application name';
|
|
895
891
|
const namePrompt = await promptText(promptMessage, defaultName);
|
|
896
892
|
name = namePrompt || defaultName;
|
|
@@ -961,10 +957,10 @@ program
|
|
|
961
957
|
.action(async (url, options) => {
|
|
962
958
|
await checkUpdateTips();
|
|
963
959
|
if (!url) {
|
|
964
|
-
program.outputHelp(
|
|
960
|
+
program.outputHelp(str => {
|
|
965
961
|
return str
|
|
966
962
|
.split('\n')
|
|
967
|
-
.filter(
|
|
963
|
+
.filter(line => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line))
|
|
968
964
|
.join('\n');
|
|
969
965
|
});
|
|
970
966
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -136,8 +136,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
136
136
|
document.body.appendChild(m);
|
|
137
137
|
setTimeout(function () {
|
|
138
138
|
const d = 0.5;
|
|
139
|
-
m.style.transition =
|
|
140
|
-
'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
|
|
139
|
+
m.style.transition = 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
|
|
141
140
|
m.style.opacity = '0';
|
|
142
141
|
setTimeout(function () {
|
|
143
142
|
document.body.removeChild(m);
|
|
@@ -151,14 +150,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
151
150
|
if (window.location.hostname === 'chat.openai.com') {
|
|
152
151
|
const originFetch = fetch;
|
|
153
152
|
window.fetch = (url, options) => {
|
|
154
|
-
return originFetch(url, options).then(async
|
|
153
|
+
return originFetch(url, options).then(async response => {
|
|
155
154
|
if (url.indexOf('/backend-api/models') === -1) {
|
|
156
155
|
return response;
|
|
157
156
|
}
|
|
158
157
|
const responseClone = response.clone();
|
|
159
158
|
let res = await responseClone.json();
|
|
160
|
-
res.models = res.models.map(
|
|
161
|
-
m.tags = m.tags.filter(
|
|
159
|
+
res.models = res.models.map(m => {
|
|
160
|
+
m.tags = m.tags.filter(t => {
|
|
162
161
|
return t !== 'mobile';
|
|
163
162
|
});
|
|
164
163
|
if (m.slug === 'gpt-4-mobile') {
|
|
@@ -82,14 +82,14 @@ async function invoke(cmd, args) {
|
|
|
82
82
|
|
|
83
83
|
// Judgment of file download.
|
|
84
84
|
function isDownloadLink(url) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
const fileExtensions = [
|
|
86
|
+
'3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx', 'fla', 'flv', 'gif', 'gz', 'gzip',
|
|
87
|
+
'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg',
|
|
88
|
+
'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg',
|
|
89
|
+
'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip',
|
|
90
|
+
];
|
|
91
|
+
const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i');
|
|
92
|
+
return downloadLinkPattern.test(url);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// No need to go to the download link.
|
|
@@ -185,7 +185,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
185
185
|
|
|
186
186
|
// Rewrite the window.open function.
|
|
187
187
|
const originalWindowOpen = window.open;
|
|
188
|
-
window.open = function
|
|
188
|
+
window.open = function(url, name, specs) {
|
|
189
189
|
// Apple login and google login
|
|
190
190
|
if (name === 'AppleAuthentication') {
|
|
191
191
|
//do nothing
|
|
@@ -278,7 +278,7 @@ function downloadFromBlobUrl(blobUrl, filename) {
|
|
|
278
278
|
function detectDownloadByCreateAnchor() {
|
|
279
279
|
const createEle = document.createElement;
|
|
280
280
|
document.createElement = (el) => {
|
|
281
|
-
if (el !==
|
|
281
|
+
if (el !== 'a') return createEle.call(document, el);
|
|
282
282
|
const anchorEle = createEle.call(document, el);
|
|
283
283
|
|
|
284
284
|
// use addEventListener to avoid overriding the original click event.
|
|
@@ -290,5 +290,5 @@ function detectDownloadByCreateAnchor() {
|
|
|
290
290
|
});
|
|
291
291
|
|
|
292
292
|
return anchorEle;
|
|
293
|
-
}
|
|
293
|
+
};
|
|
294
294
|
}
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
"dangerousRemoteDomainIpcAccess": [
|
|
10
10
|
{
|
|
11
11
|
"domain": "weread.qq.com",
|
|
12
|
-
"windows": [
|
|
13
|
-
"pake"
|
|
14
|
-
],
|
|
12
|
+
"windows": ["pake"],
|
|
15
13
|
"enableTauriAPI": true
|
|
16
14
|
}
|
|
17
15
|
]
|
|
@@ -27,9 +25,7 @@
|
|
|
27
25
|
"all": true,
|
|
28
26
|
"fs": {
|
|
29
27
|
"all": true,
|
|
30
|
-
"scope": [
|
|
31
|
-
"$DOWNLOAD/*"
|
|
32
|
-
]
|
|
28
|
+
"scope": ["$DOWNLOAD/*"]
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
},
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"copyright": "",
|
|
9
9
|
"deb": {
|
|
10
10
|
"depends": ["curl", "wget"],
|
|
11
|
-
"files": {
|
|
11
|
+
"files": {
|
|
12
|
+
"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"
|
|
13
|
+
}
|
|
12
14
|
},
|
|
13
15
|
"externalBin": [],
|
|
14
16
|
"longDescription": "",
|