pake-cli 2.6.1 → 3.0.1

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/dev.js CHANGED
@@ -9,7 +9,7 @@ import crypto from 'crypto';
9
9
  import prompts from 'prompts';
10
10
  import ora from 'ora';
11
11
  import { fileTypeFromBuffer } from 'file-type';
12
- import psl from 'psl';
12
+ import * as psl from 'psl';
13
13
  import 'is-url';
14
14
  import shelljs from 'shelljs';
15
15
  import dns from 'dns';
@@ -23,27 +23,28 @@ const DEFAULT_PAKE_OPTIONS = {
23
23
  width: 1200,
24
24
  fullscreen: false,
25
25
  resizable: true,
26
- transparent: false,
26
+ hideTitleBar: false,
27
27
  alwaysOnTop: false,
28
+ darkMode: false,
28
29
  disabledWebShortcuts: false,
29
30
  activationShortcut: '',
30
31
  userAgent: '',
31
32
  showSystemTray: false,
32
33
  multiArch: false,
33
34
  targets: 'deb',
34
- iterCopyFile: false,
35
+ useLocalFile: false,
35
36
  systemTrayIcon: '',
37
+ proxyUrl: "",
36
38
  debug: false,
37
39
  inject: [],
38
- safeDomain: [],
40
+ installerLanguage: 'en-US',
39
41
  };
40
42
  // Just for cli development
41
43
  const DEFAULT_DEV_PAKE_OPTIONS = {
42
44
  ...DEFAULT_PAKE_OPTIONS,
43
45
  url: 'https://weread.qq.com',
44
46
  name: 'WeRead',
45
- safeDomain: ['weread.qq.com'],
46
- transparent: true,
47
+ hideTitleBar: true,
47
48
  };
48
49
 
49
50
  const logger = {
@@ -68,7 +69,7 @@ const logger = {
68
69
  const currentModulePath = fileURLToPath(import.meta.url);
69
70
  // Resolve the parent directory of the current module
70
71
  const npmDirectory = path.join(path.dirname(currentModulePath), '..');
71
- const tauriConfigDirectory = path.join(npmDirectory, 'src-tauri', '.pake') ;
72
+ const tauriConfigDirectory = path.join(npmDirectory, 'src-tauri');
72
73
 
73
74
  const { platform: platform$2 } = process;
74
75
  const IS_MAC = platform$2 === 'darwin';
@@ -226,12 +227,13 @@ var windows = [
226
227
  {
227
228
  url: "https://weread.qq.com",
228
229
  url_type: "web",
229
- transparent: true,
230
+ hide_title_bar: true,
230
231
  fullscreen: false,
231
232
  width: 1200,
232
233
  height: 780,
233
234
  resizable: true,
234
235
  always_on_top: false,
236
+ dark_mode: false,
235
237
  activation_shortcut: "",
236
238
  disabled_web_shortcuts: false
237
239
  }
@@ -246,139 +248,89 @@ var system_tray = {
246
248
  linux: true,
247
249
  windows: true
248
250
  };
251
+ var system_tray_path = "icons/icon.png";
249
252
  var inject = [
250
253
  ];
254
+ var proxy_url = "";
251
255
  var pakeConf = {
252
256
  windows: windows,
253
257
  user_agent: user_agent,
254
258
  system_tray: system_tray,
255
- inject: inject
259
+ system_tray_path: system_tray_path,
260
+ inject: inject,
261
+ proxy_url: proxy_url
256
262
  };
257
263
 
258
- var tauri$3 = {
259
- security: {
260
- csp: null,
261
- dangerousRemoteDomainIpcAccess: [
262
- {
263
- domain: "weread.qq.com",
264
- windows: [
265
- "pake"
266
- ],
267
- enableTauriAPI: true
268
- }
269
- ]
270
- },
271
- updater: {
272
- active: false
273
- },
274
- systemTray: {
275
- iconPath: "png/icon_512.png",
276
- iconAsTemplate: false
277
- },
278
- allowlist: {
279
- all: true,
280
- fs: {
281
- all: true,
282
- scope: [
283
- "$DOWNLOAD/*"
284
- ]
285
- }
264
+ var productName$1 = "WeRead";
265
+ var identifier = "com.pake.weread";
266
+ var version = "1.0.0";
267
+ var app = {
268
+ withGlobalTauri: true,
269
+ trayIcon: {
270
+ iconPath: "png/weread_512.png",
271
+ iconAsTemplate: false,
272
+ id: "pake-tray"
286
273
  }
287
274
  };
288
275
  var build = {
289
- withGlobalTauri: true,
290
- devPath: "../dist",
291
- distDir: "../dist",
292
- beforeBuildCommand: "",
293
- beforeDevCommand: ""
276
+ frontendDist: "../dist"
294
277
  };
295
278
  var CommonConf = {
296
- "package": {
297
- productName: "WeRead",
298
- version: "1.0.0"
299
- },
300
- tauri: tauri$3,
279
+ productName: productName$1,
280
+ identifier: identifier,
281
+ version: version,
282
+ app: app,
301
283
  build: build
302
284
  };
303
285
 
304
- var tauri$2 = {
305
- bundle: {
306
- icon: [
307
- "png/weread_256.ico",
308
- "png/weread_32.ico"
309
- ],
310
- identifier: "com.pake.weread",
311
- active: true,
312
- category: "DeveloperTool",
313
- copyright: "",
314
- externalBin: [
315
- ],
316
- longDescription: "",
317
- resources: [
318
- "png/weread_32.ico"
319
- ],
320
- shortDescription: "",
321
- targets: [
322
- "msi"
323
- ],
324
- windows: {
325
- certificateThumbprint: null,
326
- digestAlgorithm: "sha256",
327
- timestampUrl: "",
328
- wix: {
329
- language: [
330
- "en-US"
331
- ],
332
- template: "assets/main.wxs"
333
- }
286
+ var bundle$2 = {
287
+ icon: [
288
+ "png/weread_256.ico",
289
+ "png/weread_32.ico"
290
+ ],
291
+ active: true,
292
+ resources: [
293
+ "png/weread_32.ico"
294
+ ],
295
+ targets: [
296
+ "msi"
297
+ ],
298
+ windows: {
299
+ digestAlgorithm: "sha256",
300
+ wix: {
301
+ language: [
302
+ "en-US"
303
+ ],
304
+ template: "assets/main.wxs"
334
305
  }
335
306
  }
336
307
  };
337
308
  var WinConf = {
338
- tauri: tauri$2
309
+ bundle: bundle$2
339
310
  };
340
311
 
341
- var tauri$1 = {
342
- bundle: {
343
- icon: [
344
- "icons/weread.icns"
345
- ],
346
- identifier: "com.pake.weread",
347
- active: true,
348
- category: "DeveloperTool",
349
- copyright: "",
350
- externalBin: [
351
- ],
352
- longDescription: "",
353
- macOS: {
354
- entitlements: null,
355
- exceptionDomain: "",
356
- frameworks: [
357
- ],
358
- providerShortName: null,
359
- signingIdentity: null
360
- },
361
- resources: [
362
- ],
363
- shortDescription: "",
364
- targets: [
365
- "dmg"
366
- ]
367
- }
312
+ var bundle$1 = {
313
+ icon: [
314
+ "icons/weread.icns"
315
+ ],
316
+ active: true,
317
+ macOS: {
318
+ },
319
+ targets: [
320
+ "dmg"
321
+ ]
368
322
  };
369
323
  var MacConf = {
370
- tauri: tauri$1
324
+ bundle: bundle$1
371
325
  };
372
326
 
373
- var tauri = {
374
- bundle: {
375
- icon: [
376
- "png/weread_512.png"
377
- ],
378
- identifier: "com.pake.weread",
379
- active: true,
380
- category: "DeveloperTool",
381
- copyright: "",
327
+ var productName = "we-read";
328
+ var bundle = {
329
+ icon: [
330
+ "png/weread_512.png"
331
+ ],
332
+ active: true,
333
+ linux: {
382
334
  deb: {
383
335
  depends: [
384
336
  "curl",
@@ -387,21 +339,16 @@ var tauri = {
387
339
  files: {
388
340
  "/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"
389
341
  }
390
- },
391
- externalBin: [
392
- ],
393
- longDescription: "",
394
- resources: [
395
- ],
396
- shortDescription: "",
397
- targets: [
398
- "deb",
399
- "appimage"
400
- ]
401
- }
342
+ }
343
+ },
344
+ targets: [
345
+ "deb",
346
+ "appimage"
347
+ ]
402
348
  };
403
349
  var LinuxConf = {
404
- tauri: tauri
350
+ productName: productName,
351
+ bundle: bundle
405
352
  };
406
353
 
407
354
  const platformConfigs = {
@@ -413,11 +360,15 @@ const { platform: platform$1 } = process;
413
360
  // @ts-ignore
414
361
  const platformConfig = platformConfigs[platform$1];
415
362
  let tauriConfig = {
416
- tauri: {
417
- ...CommonConf.tauri,
418
- bundle: platformConfig.tauri.bundle,
363
+ ...CommonConf,
364
+ bundle: platformConfig.bundle,
365
+ app: {
366
+ ...CommonConf.app,
367
+ trayIcon: {
368
+ ...CommonConf.app.trayIcon,
369
+ ...(platformConfig?.app?.trayIcon ?? {}),
370
+ },
419
371
  },
420
- package: CommonConf.package,
421
372
  build: CommonConf.build,
422
373
  pake: pakeConf,
423
374
  };
@@ -506,30 +457,37 @@ async function combineFiles(files, output) {
506
457
  const contents = files.map(file => {
507
458
  const fileContent = fs.readFileSync(file);
508
459
  if (file.endsWith('.css')) {
509
- return "window.addEventListener('DOMContentLoaded', (_event) => { const css = `" + fileContent + "`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });";
460
+ return ("window.addEventListener('DOMContentLoaded', (_event) => { const css = `" +
461
+ fileContent +
462
+ "`; const style = document.createElement('style'); style.innerHTML = css; document.head.appendChild(style); });");
510
463
  }
511
- return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + " });";
464
+ return "window.addEventListener('DOMContentLoaded', (_event) => { " + fileContent + ' });';
512
465
  });
513
466
  fs.writeFileSync(output, contents.join('\n'));
514
467
  return files;
515
468
  }
516
469
 
517
470
  async function mergeConfig(url, options, tauriConf) {
518
- const { width, height, fullscreen, transparent, alwaysOnTop, disabledWebShortcuts, userAgent, showSystemTray, systemTrayIcon, iterCopyFile, identifier, name, resizable = true, inject, safeDomain, } = options;
471
+ const { width, height, fullscreen, hideTitleBar, alwaysOnTop, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, } = options;
519
472
  const { platform } = process;
520
473
  // Set Windows parameters.
521
474
  const tauriConfWindowOptions = {
522
475
  width,
523
476
  height,
524
477
  fullscreen,
525
- transparent,
526
- alwaysOnTop,
527
- disabledWebShortcuts,
528
478
  resizable,
479
+ hide_title_bar: hideTitleBar,
480
+ activation_shortcut: activationShortcut,
481
+ always_on_top: alwaysOnTop,
482
+ dark_mode: darkMode,
483
+ disabled_web_shortcuts: disabledWebShortcuts,
529
484
  };
530
485
  Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
531
- tauriConf.package.productName = name;
532
- tauriConf.tauri.bundle.identifier = identifier;
486
+ tauriConf.productName = name;
487
+ tauriConf.identifier = identifier;
488
+ if (platform == 'win32') {
489
+ tauriConf.bundle.windows.wix.language[0] = installerLanguage;
490
+ }
533
491
  //Judge the type of URL, whether it is a file or a website.
534
492
  const pathExists = await fsExtra.pathExists(url);
535
493
  if (pathExists) {
@@ -539,7 +497,7 @@ async function mergeConfig(url, options, tauriConf) {
539
497
  const dirName = path.dirname(url);
540
498
  const distDir = path.join(npmDirectory, 'dist');
541
499
  const distBakDir = path.join(npmDirectory, 'dist_bak');
542
- if (!iterCopyFile) {
500
+ if (!useLocalFile) {
543
501
  const urlPath = path.join(distDir, fileName);
544
502
  await fsExtra.copy(url, urlPath);
545
503
  }
@@ -556,24 +514,6 @@ async function mergeConfig(url, options, tauriConf) {
556
514
  }
557
515
  else {
558
516
  tauriConf.pake.windows[0].url_type = 'web';
559
- // Set the secure domain for calling window.__TAURI__ to the application domain that has been set.
560
- tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
561
- {
562
- domain: new URL(url).hostname,
563
- windows: ['pake'],
564
- enableTauriAPI: true,
565
- },
566
- ];
567
- }
568
- if (safeDomain.length > 0) {
569
- tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
570
- ...tauriConf.tauri.security.dangerousRemoteDomainIpcAccess,
571
- ...safeDomain.map(domain => ({
572
- domain,
573
- windows: ['pake'],
574
- enableTauriAPI: true,
575
- })),
576
- ];
577
517
  }
578
518
  const platformMap = {
579
519
  win32: 'windows',
@@ -587,10 +527,10 @@ async function mergeConfig(url, options, tauriConf) {
587
527
  tauriConf.pake.system_tray[currentPlatform] = showSystemTray;
588
528
  // Processing targets are currently only open to Linux.
589
529
  if (platform === 'linux') {
590
- delete tauriConf.tauri.bundle.deb.files;
591
- const validTargets = ['all', 'deb', 'appimage'];
530
+ delete tauriConf.bundle.linux.deb.files;
531
+ const validTargets = ['all', 'deb', 'appimage', 'rpm'];
592
532
  if (validTargets.includes(options.targets)) {
593
- tauriConf.tauri.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
533
+ tauriConf.bundle.targets = options.targets === 'all' ? ['deb', 'appimage', 'rpm'] : [options.targets];
594
534
  }
595
535
  else {
596
536
  logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
@@ -625,15 +565,15 @@ async function mergeConfig(url, options, tauriConf) {
625
565
  if (customIconExt !== iconInfo.fileExt) {
626
566
  updateIconPath = false;
627
567
  logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);
628
- tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
568
+ tauriConf.bundle.icon = [iconInfo.defaultIcon];
629
569
  }
630
570
  else {
631
571
  const iconPath = path.join(npmDirectory, 'src-tauri/', iconInfo.path);
632
- tauriConf.tauri.bundle.resources = [iconInfo.path];
572
+ tauriConf.bundle.resources = [iconInfo.path];
633
573
  await fsExtra.copy(options.icon, iconPath);
634
574
  }
635
575
  if (updateIconPath) {
636
- tauriConf.tauri.bundle.icon = [options.icon];
576
+ tauriConf.bundle.icon = [options.icon];
637
577
  }
638
578
  else {
639
579
  logger.warn(`✼ Icon will remain as default.`);
@@ -641,10 +581,10 @@ async function mergeConfig(url, options, tauriConf) {
641
581
  }
642
582
  else {
643
583
  logger.warn('✼ Custom icon path may be invalid, default icon will be used instead.');
644
- tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
584
+ tauriConf.bundle.icon = [iconInfo.defaultIcon];
645
585
  }
646
586
  // Set tray icon path.
647
- let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.tauri.bundle.icon[0];
587
+ let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.bundle.icon[0];
648
588
  if (systemTrayIcon.length > 0) {
649
589
  try {
650
590
  await fsExtra.pathExists(systemTrayIcon);
@@ -665,7 +605,9 @@ async function mergeConfig(url, options, tauriConf) {
665
605
  logger.warn(`✼ Default system tray icon will remain unchanged.`);
666
606
  }
667
607
  }
668
- tauriConf.tauri.systemTray.iconPath = trayIconPath;
608
+ tauriConf.app.trayIcon.iconPath = trayIconPath;
609
+ tauriConf.pake.system_tray_path = trayIconPath;
610
+ delete tauriConf.app.trayIcon;
669
611
  const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
670
612
  // inject js or css files
671
613
  if (inject?.length > 0) {
@@ -673,7 +615,7 @@ async function mergeConfig(url, options, tauriConf) {
673
615
  logger.error('The injected file must be in either CSS or JS format.');
674
616
  return;
675
617
  }
676
- const files = inject.map(filepath => path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath));
618
+ const files = inject.map(filepath => (path.isAbsolute(filepath) ? filepath : path.join(process.cwd(), filepath)));
677
619
  tauriConf.pake.inject = files;
678
620
  await combineFiles(files, injectFilePath);
679
621
  }
@@ -681,6 +623,7 @@ async function mergeConfig(url, options, tauriConf) {
681
623
  tauriConf.pake.inject = [];
682
624
  await fsExtra.writeFile(injectFilePath, '');
683
625
  }
626
+ tauriConf.pake.proxy_url = proxyUrl || '';
684
627
  // Save config file.
685
628
  const platformConfigPaths = {
686
629
  win32: 'tauri.windows.conf.json',
@@ -688,16 +631,13 @@ async function mergeConfig(url, options, tauriConf) {
688
631
  linux: 'tauri.linux.conf.json',
689
632
  };
690
633
  const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
691
- const bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
634
+ const bundleConf = { bundle: tauriConf.bundle };
635
+ console.log('pakeConfig', tauriConf.pake);
692
636
  await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
693
637
  const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
694
638
  await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
695
639
  let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
696
640
  delete tauriConf2.pake;
697
- delete tauriConf2.tauri.bundle;
698
- {
699
- tauriConf2.tauri.bundle = bundleConf.tauri.bundle;
700
- }
701
641
  const configJsonPath = path.join(tauriConfigDirectory, 'tauri.conf.json');
702
642
  await fsExtra.outputJSON(configJsonPath, tauriConf2, { spaces: 4 });
703
643
  }
@@ -712,7 +652,7 @@ class BaseBuilder {
712
652
  const tauriTargetPathExists = await fsExtra.pathExists(tauriTargetPath);
713
653
  if (!IS_MAC && !tauriTargetPathExists) {
714
654
  logger.warn('✼ The first use requires installing system dependencies.');
715
- logger.warn('✼ See more in https://tauri.app/v1/guides/getting-started/prerequisites.');
655
+ logger.warn('✼ See more in https://tauri.app/guides/getting-started/prerequisites.');
716
656
  }
717
657
  if (!checkRustInstalled()) {
718
658
  const res = await prompts({
@@ -778,7 +718,8 @@ class BaseBuilder {
778
718
  return this.options.debug ? 'npm run build:debug' : 'npm run build';
779
719
  }
780
720
  getBasePath() {
781
- return 'src-tauri/target/release/bundle/';
721
+ const basePath = this.options.debug ? 'debug' : 'release';
722
+ return `src-tauri/target/${basePath}/bundle/`;
782
723
  }
783
724
  getBuildAppPath(npmDirectory, fileName, fileType) {
784
725
  return path.join(npmDirectory, this.getBasePath(), fileType.toLowerCase(), `${fileName}.${fileType}`);
@@ -799,7 +740,7 @@ class MacBuilder extends BaseBuilder {
799
740
  else {
800
741
  arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
801
742
  }
802
- return `${name}_${tauriConfig.package.version}_${arch}`;
743
+ return `${name}_${tauriConfig.version}_${arch}`;
803
744
  }
804
745
  getBuildCommand() {
805
746
  return this.options.multiArch ? 'npm run build:mac' : super.getBuildCommand();
@@ -819,8 +760,8 @@ class WinBuilder extends BaseBuilder {
819
760
  getFileName() {
820
761
  const { name } = this.options;
821
762
  const { arch } = process;
822
- const language = tauriConfig.tauri.bundle.windows.wix.language[0];
823
- return `${name}_${tauriConfig.package.version}_${arch}_${language}`;
763
+ const language = tauriConfig.bundle.windows.wix.language[0];
764
+ return `${name}_${tauriConfig.version}_${arch}_${language}`;
824
765
  }
825
766
  }
826
767
 
@@ -831,7 +772,7 @@ class LinuxBuilder extends BaseBuilder {
831
772
  getFileName() {
832
773
  const { name } = this.options;
833
774
  const arch = process.arch === 'x64' ? 'amd64' : process.arch;
834
- return `${name}_${tauriConfig.package.version}_${arch}`;
775
+ return `${name}_${tauriConfig.version}_${arch}`;
835
776
  }
836
777
  // Customize it, considering that there are all targets.
837
778
  async build(url) {