pake-cli 2.6.1 → 3.0.0-beta

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.0-beta";
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.8",
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.9",
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.0",
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,121 @@ 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 = {
164
+ var productName$1 = "WeRead";
165
+ var identifier = "com.pake.weread";
166
+ var version = "2.0.0";
167
+ var plugins = {
168
+ };
169
+ var app = {
161
170
  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
171
+ csp: null
175
172
  },
176
- systemTray: {
177
- iconPath: "png/icon_512.png",
178
- iconAsTemplate: false
173
+ trayIcon: {
174
+ iconPath: "png/weread_512.png",
175
+ iconAsTemplate: false,
176
+ id: "pake-tray"
179
177
  },
180
- allowlist: {
181
- all: true,
182
- fs: {
183
- all: true,
184
- scope: [
185
- "$DOWNLOAD/*"
186
- ]
187
- }
188
- }
178
+ withGlobalTauri: true
189
179
  };
190
180
  var build = {
191
- withGlobalTauri: true,
192
- devPath: "../dist",
193
- distDir: "../dist",
194
181
  beforeBuildCommand: "",
182
+ frontendDist: "../dist",
195
183
  beforeDevCommand: ""
196
184
  };
197
185
  var CommonConf = {
198
- "package": {
199
- productName: "WeRead",
200
- version: "1.0.0"
201
- },
202
- tauri: tauri$3,
186
+ productName: productName$1,
187
+ identifier: identifier,
188
+ version: version,
189
+ plugins: plugins,
190
+ app: app,
203
191
  build: build
204
192
  };
205
193
 
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
- }
194
+ var bundle$2 = {
195
+ icon: [
196
+ "png/weread_256.ico",
197
+ "png/weread_32.ico"
198
+ ],
199
+ active: true,
200
+ category: "DeveloperTool",
201
+ copyright: "",
202
+ externalBin: [
203
+ ],
204
+ longDescription: "",
205
+ resources: [
206
+ "png/weread_32.ico"
207
+ ],
208
+ shortDescription: "",
209
+ targets: [
210
+ "msi"
211
+ ],
212
+ windows: {
213
+ certificateThumbprint: null,
214
+ digestAlgorithm: "sha256",
215
+ timestampUrl: "",
216
+ wix: {
217
+ language: [
218
+ "en-US"
219
+ ],
220
+ template: "assets/main.wxs"
236
221
  }
237
222
  }
238
223
  };
239
224
  var WinConf = {
240
- tauri: tauri$2
225
+ bundle: bundle$2
241
226
  };
242
227
 
243
- var tauri$1 = {
244
- bundle: {
245
- icon: [
246
- "icons/weread.icns"
228
+ var bundle$1 = {
229
+ icon: [
230
+ "icons/weread.icns"
231
+ ],
232
+ active: true,
233
+ category: "DeveloperTool",
234
+ copyright: "",
235
+ externalBin: [
236
+ ],
237
+ longDescription: "",
238
+ macOS: {
239
+ entitlements: null,
240
+ exceptionDomain: null,
241
+ frameworks: [
247
242
  ],
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
- }
243
+ providerShortName: null,
244
+ signingIdentity: null
245
+ },
246
+ resources: [
247
+ ],
248
+ shortDescription: "",
249
+ targets: [
250
+ "dmg"
251
+ ]
270
252
  };
271
253
  var MacConf = {
272
- tauri: tauri$1
254
+ bundle: bundle$1
273
255
  };
274
256
 
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: "",
257
+ var productName = "weread";
258
+ var bundle = {
259
+ icon: [
260
+ "png/weread_512.png"
261
+ ],
262
+ active: true,
263
+ category: "DeveloperTool",
264
+ copyright: "",
265
+ linux: {
284
266
  deb: {
285
267
  depends: [
286
268
  "curl",
@@ -289,21 +271,22 @@ var tauri = {
289
271
  files: {
290
272
  "/usr/share/applications/com-pake-weread.desktop": "assets/com-pake-weread.desktop"
291
273
  }
292
- },
293
- externalBin: [
294
- ],
295
- longDescription: "",
296
- resources: [
297
- ],
298
- shortDescription: "",
299
- targets: [
300
- "deb",
301
- "appimage"
302
- ]
303
- }
274
+ }
275
+ },
276
+ externalBin: [
277
+ ],
278
+ longDescription: "",
279
+ resources: [
280
+ ],
281
+ shortDescription: "",
282
+ targets: [
283
+ "deb",
284
+ "appimage"
285
+ ]
304
286
  };
305
287
  var LinuxConf = {
306
- tauri: tauri
288
+ productName: productName,
289
+ bundle: bundle
307
290
  };
308
291
 
309
292
  const platformConfigs = {
@@ -315,11 +298,15 @@ const { platform: platform$2 } = process;
315
298
  // @ts-ignore
316
299
  const platformConfig = platformConfigs[platform$2];
317
300
  let tauriConfig = {
318
- tauri: {
319
- ...CommonConf.tauri,
320
- bundle: platformConfig.tauri.bundle,
301
+ ...CommonConf,
302
+ bundle: platformConfig.bundle,
303
+ app: {
304
+ ...CommonConf.app,
305
+ trayIcon: {
306
+ ...CommonConf.app.trayIcon,
307
+ ...(platformConfig?.app?.trayIcon ?? {}),
308
+ },
321
309
  },
322
- package: CommonConf.package,
323
310
  build: CommonConf.build,
324
311
  pake: pakeConf,
325
312
  };
@@ -477,7 +464,7 @@ async function combineFiles(files, output) {
477
464
  }
478
465
 
479
466
  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;
467
+ const { width, height, fullscreen, hideTitleBar, alwaysOnTop, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, } = options;
481
468
  const { platform } = process;
482
469
  // Set Windows parameters.
483
470
  const tauriConfWindowOptions = {
@@ -492,10 +479,10 @@ async function mergeConfig(url, options, tauriConf) {
492
479
  disabled_web_shortcuts: disabledWebShortcuts,
493
480
  };
494
481
  Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
495
- tauriConf.package.productName = name;
496
- tauriConf.tauri.bundle.identifier = identifier;
482
+ tauriConf.productName = name;
483
+ tauriConf.identifier = identifier;
497
484
  if (platform == "win32") {
498
- tauriConf.tauri.bundle.windows.wix.language[0] = installerLanguage;
485
+ tauriConf.bundle.windows.wix.language[0] = installerLanguage;
499
486
  }
500
487
  //Judge the type of URL, whether it is a file or a website.
501
488
  const pathExists = await fsExtra.pathExists(url);
@@ -523,24 +510,6 @@ async function mergeConfig(url, options, tauriConf) {
523
510
  }
524
511
  else {
525
512
  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
513
  }
545
514
  const platformMap = {
546
515
  win32: 'windows',
@@ -554,10 +523,10 @@ async function mergeConfig(url, options, tauriConf) {
554
523
  tauriConf.pake.system_tray[currentPlatform] = showSystemTray;
555
524
  // Processing targets are currently only open to Linux.
556
525
  if (platform === 'linux') {
557
- delete tauriConf.tauri.bundle.deb.files;
558
- const validTargets = ['all', 'deb', 'appimage'];
526
+ delete tauriConf.bundle.linux.deb.files;
527
+ const validTargets = ['all', 'deb', 'appimage', 'rpm'];
559
528
  if (validTargets.includes(options.targets)) {
560
- tauriConf.tauri.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets];
529
+ tauriConf.bundle.targets = options.targets === 'all' ? ['deb', 'appimage', 'rpm'] : [options.targets];
561
530
  }
562
531
  else {
563
532
  logger.warn(`✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`);
@@ -592,15 +561,15 @@ async function mergeConfig(url, options, tauriConf) {
592
561
  if (customIconExt !== iconInfo.fileExt) {
593
562
  updateIconPath = false;
594
563
  logger.warn(`✼ ${iconInfo.message}, but you give ${customIconExt}`);
595
- tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
564
+ tauriConf.bundle.icon = [iconInfo.defaultIcon];
596
565
  }
597
566
  else {
598
567
  const iconPath = path.join(npmDirectory, 'src-tauri/', iconInfo.path);
599
- tauriConf.tauri.bundle.resources = [iconInfo.path];
568
+ tauriConf.bundle.resources = [iconInfo.path];
600
569
  await fsExtra.copy(options.icon, iconPath);
601
570
  }
602
571
  if (updateIconPath) {
603
- tauriConf.tauri.bundle.icon = [options.icon];
572
+ tauriConf.bundle.icon = [options.icon];
604
573
  }
605
574
  else {
606
575
  logger.warn(`✼ Icon will remain as default.`);
@@ -608,10 +577,10 @@ async function mergeConfig(url, options, tauriConf) {
608
577
  }
609
578
  else {
610
579
  logger.warn('✼ Custom icon path may be invalid, default icon will be used instead.');
611
- tauriConf.tauri.bundle.icon = [iconInfo.defaultIcon];
580
+ tauriConf.bundle.icon = [iconInfo.defaultIcon];
612
581
  }
613
582
  // Set tray icon path.
614
- let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.tauri.bundle.icon[0];
583
+ let trayIconPath = platform === 'darwin' ? 'png/icon_512.png' : tauriConf.bundle.icon[0];
615
584
  if (systemTrayIcon.length > 0) {
616
585
  try {
617
586
  await fsExtra.pathExists(systemTrayIcon);
@@ -632,7 +601,9 @@ async function mergeConfig(url, options, tauriConf) {
632
601
  logger.warn(`✼ Default system tray icon will remain unchanged.`);
633
602
  }
634
603
  }
635
- tauriConf.tauri.systemTray.iconPath = trayIconPath;
604
+ tauriConf.app.trayIcon.iconPath = trayIconPath;
605
+ tauriConf.pake.system_tray_path = trayIconPath;
606
+ delete tauriConf.app.trayIcon;
636
607
  const injectFilePath = path.join(npmDirectory, `src-tauri/src/inject/custom.js`);
637
608
  // inject js or css files
638
609
  if (inject?.length > 0) {
@@ -648,6 +619,7 @@ async function mergeConfig(url, options, tauriConf) {
648
619
  tauriConf.pake.inject = [];
649
620
  await fsExtra.writeFile(injectFilePath, '');
650
621
  }
622
+ tauriConf.pake.proxy_url = proxyUrl || "";
651
623
  // Save config file.
652
624
  const platformConfigPaths = {
653
625
  win32: 'tauri.windows.conf.json',
@@ -655,13 +627,13 @@ async function mergeConfig(url, options, tauriConf) {
655
627
  linux: 'tauri.linux.conf.json',
656
628
  };
657
629
  const configPath = path.join(tauriConfigDirectory, platformConfigPaths[platform]);
658
- const bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } };
630
+ const bundleConf = { bundle: tauriConf.bundle };
631
+ console.log('pakeConfig', tauriConf.pake);
659
632
  await fsExtra.outputJSON(configPath, bundleConf, { spaces: 4 });
660
633
  const pakeConfigPath = path.join(tauriConfigDirectory, 'pake.json');
661
634
  await fsExtra.outputJSON(pakeConfigPath, tauriConf.pake, { spaces: 4 });
662
635
  let tauriConf2 = JSON.parse(JSON.stringify(tauriConf));
663
636
  delete tauriConf2.pake;
664
- delete tauriConf2.tauri.bundle;
665
637
  const configJsonPath = path.join(tauriConfigDirectory, 'tauri.conf.json');
666
638
  await fsExtra.outputJSON(configJsonPath, tauriConf2, { spaces: 4 });
667
639
  }
@@ -676,7 +648,7 @@ class BaseBuilder {
676
648
  const tauriTargetPathExists = await fsExtra.pathExists(tauriTargetPath);
677
649
  if (!IS_MAC && !tauriTargetPathExists) {
678
650
  logger.warn('✼ The first use requires installing system dependencies.');
679
- logger.warn('✼ See more in https://tauri.app/v1/guides/getting-started/prerequisites.');
651
+ logger.warn('✼ See more in https://tauri.app/guides/getting-started/prerequisites.');
680
652
  }
681
653
  if (!checkRustInstalled()) {
682
654
  const res = await prompts({
@@ -764,7 +736,7 @@ class MacBuilder extends BaseBuilder {
764
736
  else {
765
737
  arch = process.arch === 'arm64' ? 'aarch64' : process.arch;
766
738
  }
767
- return `${name}_${tauriConfig.package.version}_${arch}`;
739
+ return `${name}_${tauriConfig.version}_${arch}`;
768
740
  }
769
741
  getBuildCommand() {
770
742
  return this.options.multiArch ? 'npm run build:mac' : super.getBuildCommand();
@@ -784,8 +756,8 @@ class WinBuilder extends BaseBuilder {
784
756
  getFileName() {
785
757
  const { name } = this.options;
786
758
  const { arch } = process;
787
- const language = tauriConfig.tauri.bundle.windows.wix.language[0];
788
- return `${name}_${tauriConfig.package.version}_${arch}_${language}`;
759
+ const language = tauriConfig.bundle.windows.wix.language[0];
760
+ return `${name}_${tauriConfig.version}_${arch}_${language}`;
789
761
  }
790
762
  }
791
763
 
@@ -796,7 +768,7 @@ class LinuxBuilder extends BaseBuilder {
796
768
  getFileName() {
797
769
  const { name } = this.options;
798
770
  const arch = process.arch === 'x64' ? 'amd64' : process.arch;
799
- return `${name}_${tauriConfig.package.version}_${arch}`;
771
+ return `${name}_${tauriConfig.version}_${arch}`;
800
772
  }
801
773
  // Customize it, considering that there are all targets.
802
774
  async build(url) {
@@ -848,9 +820,9 @@ const DEFAULT_PAKE_OPTIONS = {
848
820
  targets: 'deb',
849
821
  useLocalFile: false,
850
822
  systemTrayIcon: '',
823
+ proxyUrl: "",
851
824
  debug: false,
852
825
  inject: [],
853
- safeDomain: [],
854
826
  installerLanguage: 'en-US',
855
827
  };
856
828
 
@@ -1037,6 +1009,7 @@ program
1037
1009
  .option('--multi-arch', 'Only for Mac, supports both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch)
1038
1010
  .option('--inject [injects...]', 'Injection of .js or .css Files', DEFAULT_PAKE_OPTIONS.inject)
1039
1011
  .option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug)
1012
+ .option('--proxy-url', "Proxy URL", DEFAULT_PAKE_OPTIONS.proxyUrl)
1040
1013
  .addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp())
1041
1014
  .addOption(new Option('--targets <string>', 'Only for Linux, option "deb" or "appimage"').default(DEFAULT_PAKE_OPTIONS.targets).hideHelp())
1042
1015
  .addOption(new Option('--always-on-top', 'Always on the top level').default(DEFAULT_PAKE_OPTIONS.alwaysOnTop).hideHelp())
@@ -1044,9 +1017,6 @@ program
1044
1017
  .addOption(new Option('--disabled-web-shortcuts', 'Disabled webPage shortcuts')
1045
1018
  .default(DEFAULT_PAKE_OPTIONS.disabledWebShortcuts)
1046
1019
  .hideHelp())
1047
- .addOption(new Option('--safe-domain [domains...]', 'Domains that Require Security Configuration')
1048
- .default(DEFAULT_PAKE_OPTIONS.safeDomain)
1049
- .hideHelp())
1050
1020
  .addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT_PAKE_OPTIONS.showSystemTray).hideHelp())
1051
1021
  .addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp())
1052
1022
  .addOption(new Option('--installer-language <string>', 'Installer language').default(DEFAULT_PAKE_OPTIONS.installerLanguage).hideHelp())