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/cli.js CHANGED
@@ -16,11 +16,11 @@ import updateNotifier from 'update-notifier';
16
16
  import axios from 'axios';
17
17
  import { dir } from 'tmp-promise';
18
18
  import { fileTypeFromBuffer } from 'file-type';
19
- import psl from 'psl';
19
+ import * as psl from 'psl';
20
20
  import isUrl from 'is-url';
21
21
 
22
22
  var name = "pake-cli";
23
- var version = "2.6.1";
23
+ var version$1 = "3.0.1";
24
24
  var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
25
25
  var engines = {
26
26
  node: ">=16.0.0"
@@ -68,8 +68,8 @@ var exports = "./dist/pake.js";
68
68
  var license = "MIT";
69
69
  var dependencies = {
70
70
  "@tauri-apps/api": "^1.6.0",
71
- "@tauri-apps/cli": "^1.6.1",
72
- axios: "^1.7.7",
71
+ "@tauri-apps/cli": "^2.1.0",
72
+ axios: "^1.7.9",
73
73
  chalk: "^5.3.0",
74
74
  commander: "^11.1.0",
75
75
  "file-type": "^18.7.0",
@@ -78,20 +78,20 @@ var dependencies = {
78
78
  loglevel: "^1.9.2",
79
79
  ora: "^7.0.1",
80
80
  prompts: "^2.4.2",
81
- psl: "^1.9.0",
81
+ psl: "^1.15.0",
82
82
  shelljs: "^0.8.5",
83
83
  "tmp-promise": "^3.0.3",
84
84
  "update-notifier": "^7.3.1"
85
85
  };
86
86
  var devDependencies = {
87
- "@rollup/plugin-alias": "^5.1.0",
87
+ "@rollup/plugin-alias": "^5.1.1",
88
88
  "@rollup/plugin-commonjs": "^25.0.8",
89
89
  "@rollup/plugin-json": "^6.1.0",
90
90
  "@rollup/plugin-replace": "^5.0.7",
91
91
  "@rollup/plugin-terser": "^0.4.4",
92
92
  "@types/fs-extra": "^11.0.4",
93
93
  "@types/is-url": "^1.2.32",
94
- "@types/node": "^20.16.5",
94
+ "@types/node": "^20.17.10",
95
95
  "@types/page-icon": "^0.3.6",
96
96
  "@types/prompts": "^2.4.9",
97
97
  "@types/psl": "^1.1.3",
@@ -100,14 +100,14 @@ var devDependencies = {
100
100
  "@types/update-notifier": "^6.0.8",
101
101
  "app-root-path": "^3.1.0",
102
102
  "cross-env": "^7.0.3",
103
- rollup: "^4.21.3",
103
+ rollup: "^4.28.1",
104
104
  "rollup-plugin-typescript2": "^0.36.0",
105
- tslib: "^2.7.0",
106
- typescript: "^5.6.2"
105
+ tslib: "^2.8.1",
106
+ typescript: "^5.7.2"
107
107
  };
108
108
  var packageJson = {
109
109
  name: name,
110
- version: version,
110
+ version: version$1,
111
111
  description: description,
112
112
  engines: engines,
113
113
  bin: bin,
@@ -132,8 +132,8 @@ var windows = [
132
132
  width: 1200,
133
133
  height: 780,
134
134
  resizable: true,
135
- dark_mode: false,
136
135
  always_on_top: false,
136
+ dark_mode: false,
137
137
  activation_shortcut: "",
138
138
  disabled_web_shortcuts: false
139
139
  }
@@ -148,139 +148,89 @@ var system_tray = {
148
148
  linux: true,
149
149
  windows: true
150
150
  };
151
+ var system_tray_path = "icons/icon.png";
151
152
  var inject = [
152
153
  ];
154
+ var proxy_url = "";
153
155
  var pakeConf = {
154
156
  windows: windows,
155
157
  user_agent: user_agent,
156
158
  system_tray: system_tray,
157
- inject: inject
159
+ system_tray_path: system_tray_path,
160
+ inject: inject,
161
+ proxy_url: proxy_url
158
162
  };
159
163
 
160
- var tauri$3 = {
161
- security: {
162
- csp: null,
163
- dangerousRemoteDomainIpcAccess: [
164
- {
165
- domain: "weread.qq.com",
166
- windows: [
167
- "pake"
168
- ],
169
- enableTauriAPI: true
170
- }
171
- ]
172
- },
173
- updater: {
174
- active: false
175
- },
176
- systemTray: {
177
- iconPath: "png/icon_512.png",
178
- iconAsTemplate: false
179
- },
180
- allowlist: {
181
- all: true,
182
- fs: {
183
- all: true,
184
- scope: [
185
- "$DOWNLOAD/*"
186
- ]
187
- }
164
+ var productName$1 = "WeRead";
165
+ var identifier = "com.pake.weread";
166
+ var version = "1.0.0";
167
+ var app = {
168
+ withGlobalTauri: true,
169
+ trayIcon: {
170
+ iconPath: "png/weread_512.png",
171
+ iconAsTemplate: false,
172
+ id: "pake-tray"
188
173
  }
189
174
  };
190
175
  var build = {
191
- withGlobalTauri: true,
192
- devPath: "../dist",
193
- distDir: "../dist",
194
- beforeBuildCommand: "",
195
- beforeDevCommand: ""
176
+ frontendDist: "../dist"
196
177
  };
197
178
  var CommonConf = {
198
- "package": {
199
- productName: "WeRead",
200
- version: "1.0.0"
201
- },
202
- tauri: tauri$3,
179
+ productName: productName$1,
180
+ identifier: identifier,
181
+ version: version,
182
+ app: app,
203
183
  build: build
204
184
  };
205
185
 
206
- var tauri$2 = {
207
- bundle: {
208
- icon: [
209
- "png/weread_256.ico",
210
- "png/weread_32.ico"
211
- ],
212
- identifier: "com.pake.weread",
213
- active: true,
214
- category: "DeveloperTool",
215
- copyright: "",
216
- externalBin: [
217
- ],
218
- longDescription: "",
219
- resources: [
220
- "png/weread_32.ico"
221
- ],
222
- shortDescription: "",
223
- targets: [
224
- "msi"
225
- ],
226
- windows: {
227
- certificateThumbprint: null,
228
- digestAlgorithm: "sha256",
229
- timestampUrl: "",
230
- wix: {
231
- language: [
232
- "en-US"
233
- ],
234
- template: "assets/main.wxs"
235
- }
186
+ var bundle$2 = {
187
+ icon: [
188
+ "png/weread_256.ico",
189
+ "png/weread_32.ico"
190
+ ],
191
+ active: true,
192
+ resources: [
193
+ "png/weread_32.ico"
194
+ ],
195
+ targets: [
196
+ "msi"
197
+ ],
198
+ windows: {
199
+ digestAlgorithm: "sha256",
200
+ wix: {
201
+ language: [
202
+ "en-US"
203
+ ],
204
+ template: "assets/main.wxs"
236
205
  }
237
206
  }
238
207
  };
239
208
  var WinConf = {
240
- tauri: tauri$2
209
+ bundle: bundle$2
241
210
  };
242
211
 
243
- var tauri$1 = {
244
- bundle: {
245
- icon: [
246
- "icons/weread.icns"
247
- ],
248
- identifier: "com.pake.weread",
249
- active: true,
250
- category: "DeveloperTool",
251
- copyright: "",
252
- externalBin: [
253
- ],
254
- longDescription: "",
255
- macOS: {
256
- entitlements: null,
257
- exceptionDomain: "",
258
- frameworks: [
259
- ],
260
- providerShortName: null,
261
- signingIdentity: null
262
- },
263
- resources: [
264
- ],
265
- shortDescription: "",
266
- targets: [
267
- "dmg"
268
- ]
269
- }
212
+ var bundle$1 = {
213
+ icon: [
214
+ "icons/weread.icns"
215
+ ],
216
+ active: true,
217
+ macOS: {
218
+ },
219
+ targets: [
220
+ "dmg"
221
+ ]
270
222
  };
271
223
  var MacConf = {
272
- tauri: tauri$1
224
+ bundle: bundle$1
273
225
  };
274
226
 
275
- var tauri = {
276
- bundle: {
277
- icon: [
278
- "png/weread_512.png"
279
- ],
280
- identifier: "com.pake.weread",
281
- active: true,
282
- category: "DeveloperTool",
283
- copyright: "",
227
+ var productName = "we-read";
228
+ var bundle = {
229
+ icon: [
230
+ "png/weread_512.png"
231
+ ],
232
+ active: true,
233
+ linux: {
284
234
  deb: {
285
235
  depends: [
286
236
  "curl",
@@ -289,21 +239,16 @@ var tauri = {
289
239
  files: {
290
240
  "/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"
291
241
  }
292
- },
293
- externalBin: [
294
- ],
295
- longDescription: "",
296
- resources: [
297
- ],
298
- shortDescription: "",
299
- targets: [
300
- "deb",
301
- "appimage"
302
- ]
303
- }
242
+ }
243
+ },
244
+ targets: [
245
+ "deb",
246
+ "appimage"
247
+ ]
304
248
  };
305
249
  var LinuxConf = {
306
- tauri: tauri
250
+ productName: productName,
251
+ bundle: bundle
307
252
  };
308
253
 
309
254
  const platformConfigs = {
@@ -315,11 +260,15 @@ const { platform: platform$2 } = process;
315
260
  // @ts-ignore
316
261
  const platformConfig = platformConfigs[platform$2];
317
262
  let tauriConfig = {
318
- tauri: {
319
- ...CommonConf.tauri,
320
- bundle: platformConfig.tauri.bundle,
263
+ ...CommonConf,
264
+ bundle: platformConfig.bundle,
265
+ app: {
266
+ ...CommonConf.app,
267
+ trayIcon: {
268
+ ...CommonConf.app.trayIcon,
269
+ ...(platformConfig?.app?.trayIcon ?? {}),
270
+ },
321
271
  },
322
- package: CommonConf.package,
323
272
  build: CommonConf.build,
324
273
  pake: pakeConf,
325
274
  };
@@ -477,7 +426,7 @@ async function combineFiles(files, output) {
477
426
  }
478
427
 
479
428
  async function mergeConfig(url, options, tauriConf) {
480
- const { width, height, fullscreen, hideTitleBar, alwaysOnTop, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, safeDomain, installerLanguage, } = options;
429
+ const { width, height, fullscreen, hideTitleBar, alwaysOnTop, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, } = options;
481
430
  const { platform } = process;
482
431
  // Set Windows parameters.
483
432
  const tauriConfWindowOptions = {
@@ -492,10 +441,10 @@ async function mergeConfig(url, options, tauriConf) {
492
441
  disabled_web_shortcuts: disabledWebShortcuts,
493
442
  };
494
443
  Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
495
- tauriConf.package.productName = name;
496
- tauriConf.tauri.bundle.identifier = identifier;
497
- if (platform == "win32") {
498
- tauriConf.tauri.bundle.windows.wix.language[0] = installerLanguage;
444
+ tauriConf.productName = name;
445
+ tauriConf.identifier = identifier;
446
+ if (platform == 'win32') {
447
+ tauriConf.bundle.windows.wix.language[0] = installerLanguage;
499
448
  }
500
449
  //Judge the type of URL, whether it is a file or a website.
501
450
  const pathExists = await fsExtra.pathExists(url);
@@ -523,24 +472,6 @@ async function mergeConfig(url, options, tauriConf) {
523
472
  }
524
473
  else {
525
474
  tauriConf.pake.windows[0].url_type = 'web';
526
- // Set the secure domain for calling window.__TAURI__ to the application domain that has been set.
527
- tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
528
- {
529
- domain: new URL(url).hostname,
530
- windows: ['pake'],
531
- enableTauriAPI: true,
532
- },
533
- ];
534
- }
535
- if (safeDomain.length > 0) {
536
- tauriConf.tauri.security.dangerousRemoteDomainIpcAccess = [
537
- ...tauriConf.tauri.security.dangerousRemoteDomainIpcAccess,
538
- ...safeDomain.map(domain => ({
539
- domain,
540
- windows: ['pake'],
541
- enableTauriAPI: true,
542
- })),
543
- ];
544
475
  }
545
476
  const platformMap = {
546
477
  win32: 'windows',
@@ -554,10 +485,10 @@ async function mergeConfig(url, options, tauriConf) {
554
485
  tauriConf.pake.system_tray[currentPlatform] = showSystemTray;
555
486
  // Processing targets are currently only open to Linux.
556
487
  if (platform === 'linux') {
557
- delete tauriConf.tauri.bundle.deb.files;
558
- const validTargets = ['all', 'deb', 'appimage'];
488
+ delete tauriConf.bundle.linux.deb.files;
489
+ const validTargets = ['all', 'deb', 'appimage', 'rpm'];
559
490
  if (validTargets.includes(options.targets)) {
560
- tauriConf.tauri.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
491
+ tauriConf.bundle.targets = options.targets === 'all' ? ['deb', 'appimage', 'rpm'] : [options.targets];
561
492
  }
562
493
  else {
563
494
  logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
@@ -592,15 +523,15 @@ async function mergeConfig(url, options, tauriConf) {
592
523
  if (customIconExt !== iconInfo.fileExt) {
593
524
  updateIconPath = false;
594
525
  logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);
595
- tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
526
+ tauriConf.bundle.icon = [iconInfo.defaultIcon];
596
527
  }
597
528
  else {
598
529
  const iconPath = path.join(npmDirectory, 'src-tauri/', iconInfo.path);
599
- tauriConf.tauri.bundle.resources = [iconInfo.path];
530
+ tauriConf.bundle.resources = [iconInfo.path];
600
531
  await fsExtra.copy(options.icon, iconPath);
601
532
  }
602
533
  if (updateIconPath) {
603
- tauriConf.tauri.bundle.icon = [options.icon];
534
+ tauriConf.bundle.icon = [options.icon];
604
535
  }
605
536
  else {
606
537
  logger.warn(`✼ Icon will remain as default.`);
@@ -608,10 +539,10 @@ async function mergeConfig(url, options, tauriConf) {
608
539
  }
609
540
  else {
610
541
  logger.warn('✼ Custom icon path may be invalid, default icon will be used instead.');
611
- tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
542
+ tauriConf.bundle.icon = [iconInfo.defaultIcon];
612
543
  }
613
544
  // Set tray icon path.
614
- let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.tauri.bundle.icon[0];
545
+ let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.bundle.icon[0];
615
546
  if (systemTrayIcon.length > 0) {
616
547
  try {
617
548
  await fsExtra.pathExists(systemTrayIcon);
@@ -632,7 +563,9 @@ async function mergeConfig(url, options, tauriConf) {
632
563
  logger.warn(`✼ Default system tray icon will remain unchanged.`);
633
564
  }
634
565
  }
635
- tauriConf.tauri.systemTray.iconPath = trayIconPath;
566
+ tauriConf.app.trayIcon.iconPath = trayIconPath;
567
+ tauriConf.pake.system_tray_path = trayIconPath;
568
+ delete tauriConf.app.trayIcon;
636
569
  const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
637
570
  // inject js or css files
638
571
  if (inject?.length > 0) {
@@ -648,6 +581,7 @@ async function mergeConfig(url, options, tauriConf) {
648
581
  tauriConf.pake.inject = [];
649
582
  await fsExtra.writeFile(injectFilePath, '');
650
583
  }
584
+ tauriConf.pake.proxy_url = proxyUrl || '';
651
585
  // Save config file.
652
586
  const platformConfigPaths = {
653
587
  win32: 'tauri.windows.conf.json',
@@ -655,13 +589,13 @@ async function mergeConfig(url, options, tauriConf) {
655
589
  linux: 'tauri.linux.conf.json',
656
590
  };
657
591
  const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
658
- const bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
592
+ const bundleConf = { bundle: tauriConf.bundle };
593
+ console.log('pakeConfig', tauriConf.pake);
659
594
  await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
660
595
  const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
661
596
  await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
662
597
  let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
663
598
  delete tauriConf2.pake;
664
- delete tauriConf2.tauri.bundle;
665
599
  const configJsonPath = path.join(tauriConfigDirectory, 'tauri.conf.json');
666
600
  await fsExtra.outputJSON(configJsonPath, tauriConf2, { spaces: 4 });
667
601
  }
@@ -676,7 +610,7 @@ class BaseBuilder {
676
610
  const tauriTargetPathExists = await fsExtra.pathExists(tauriTargetPath);
677
611
  if (!IS_MAC && !tauriTargetPathExists) {
678
612
  logger.warn('✼ The first use requires installing system dependencies.');
679
- logger.warn('✼ See more in https://tauri.app/v1/guides/getting-started/prerequisites.');
613
+ logger.warn('✼ See more in https://tauri.app/guides/getting-started/prerequisites.');
680
614
  }
681
615
  if (!checkRustInstalled()) {
682
616
  const res = await prompts({
@@ -764,7 +698,7 @@ class MacBuilder extends BaseBuilder {
764
698
  else {
765
699
  arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
766
700
  }
767
- return `${name}_${tauriConfig.package.version}_${arch}`;
701
+ return `${name}_${tauriConfig.version}_${arch}`;
768
702
  }
769
703
  getBuildCommand() {
770
704
  return this.options.multiArch ? 'npm run build:mac' : super.getBuildCommand();
@@ -784,8 +718,8 @@ class WinBuilder extends BaseBuilder {
784
718
  getFileName() {
785
719
  const { name } = this.options;
786
720
  const { arch } = process;
787
- const language = tauriConfig.tauri.bundle.windows.wix.language[0];
788
- return `${name}_${tauriConfig.package.version}_${arch}_${language}`;
721
+ const language = tauriConfig.bundle.windows.wix.language[0];
722
+ return `${name}_${tauriConfig.version}_${arch}_${language}`;
789
723
  }
790
724
  }
791
725
 
@@ -796,7 +730,7 @@ class LinuxBuilder extends BaseBuilder {
796
730
  getFileName() {
797
731
  const { name } = this.options;
798
732
  const arch = process.arch === 'x64' ? 'amd64' : process.arch;
799
- return `${name}_${tauriConfig.package.version}_${arch}`;
733
+ return `${name}_${tauriConfig.version}_${arch}`;
800
734
  }
801
735
  // Customize it, considering that there are all targets.
802
736
  async build(url) {
@@ -848,9 +782,9 @@ const DEFAULT_PAKE_OPTIONS = {
848
782
  targets: 'deb',
849
783
  useLocalFile: false,
850
784
  systemTrayIcon: '',
785
+ proxyUrl: "",
851
786
  debug: false,
852
787
  inject: [],
853
- safeDomain: [],
854
788
  installerLanguage: 'en-US',
855
789
  };
856
790
 
@@ -1034,9 +968,10 @@ program
1034
968
  .option('--fullscreen', 'Start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
1035
969
  .option('--hide-title-bar', 'Only for Mac, hide title bar', DEFAULT_PAKE_OPTIONS.hideTitleBar)
1036
970
  .option('--activation-shortcut <string>', 'Shortcut key to active App', DEFAULT_PAKE_OPTIONS.activationShortcut)
1037
- .option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch)
1038
- .option('--inject [injects...]', 'Injection of .js or .css Files', DEFAULT_PAKE_OPTIONS.inject)
971
+ .option('--inject <url>', 'Injection of .js or .css files', DEFAULT_PAKE_OPTIONS.inject)
972
+ .option('--proxy-url <url>', "Proxy URL for all network requests", DEFAULT_PAKE_OPTIONS.proxyUrl)
1039
973
  .option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug)
974
+ .option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch)
1040
975
  .addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp())
1041
976
  .addOption(new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT_PAKE_OPTIONS.targets).hideHelp())
1042
977
  .addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT_PAKE_OPTIONS.alwaysOnTop).hideHelp())
@@ -1044,9 +979,6 @@ program
1044
979
  .addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
1045
980
  .default(DEFAULT_PAKE_OPTIONS.disabledWebShortcuts)
1046
981
  .hideHelp())
1047
- .addOption(new Option('--safe-domain [domains...]', 'Domains that Require Security Configuration')
1048
- .default(DEFAULT_PAKE_OPTIONS.safeDomain)
1049
- .hideHelp())
1050
982
  .addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT_PAKE_OPTIONS.showSystemTray).hideHelp())
1051
983
  .addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp())
1052
984
  .addOption(new Option('--installer-language <string>', 'Installer language').default(DEFAULT_PAKE_OPTIONS.installerLanguage).hideHelp())