pake-cli 3.2.0-beta → 3.2.0-beta11

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.
Files changed (41) hide show
  1. package/dist/cli.js +106 -20
  2. package/dist/dev.js +276 -72
  3. package/dist/dev.js.map +1 -1
  4. package/package.json +10 -7
  5. package/src-tauri/.cargo/config.toml +19 -4
  6. package/src-tauri/.pake/icons/githubcustomtraypng.icns +0 -0
  7. package/src-tauri/.pake/icons/githubcustomtraytest.icns +0 -0
  8. package/src-tauri/.pake/icons/githubsystemtraytest.icns +0 -0
  9. package/src-tauri/.pake/icons/testfix.icns +0 -0
  10. package/src-tauri/.pake/icons/twi.icns +0 -0
  11. package/src-tauri/.pake/icons/twitter.icns +0 -0
  12. package/src-tauri/.pake/icons/twitter1.icns +0 -0
  13. package/src-tauri/.pake/icons/twitter3.icns +0 -0
  14. package/src-tauri/.pake/icons/twitter4.icns +0 -0
  15. package/src-tauri/.pake/icons/twitter5.icns +0 -0
  16. package/src-tauri/.pake/icons/twitterapp.icns +0 -0
  17. package/src-tauri/.pake/icons/twittercustomtray.icns +0 -0
  18. package/src-tauri/.pake/icons/twitterfinal.icns +0 -0
  19. package/src-tauri/.pake/icons/twitteroptimized.icns +0 -0
  20. package/src-tauri/.pake/icons/twittertest.icns +0 -0
  21. package/src-tauri/.pake/icons/wk.icns +0 -0
  22. package/src-tauri/.pake/icons/wk1.icns +0 -0
  23. package/src-tauri/.pake/pake.json +33 -0
  24. package/src-tauri/.pake/png/githubcustomtraypng.png +0 -0
  25. package/src-tauri/.pake/png/twi_tray.png +0 -0
  26. package/src-tauri/.pake/png/twitter5_tray.png +0 -0
  27. package/src-tauri/.pake/png/twittercustomtray.png +0 -0
  28. package/src-tauri/.pake/png/twitterfinal_tray.png +0 -0
  29. package/src-tauri/.pake/png/twitteroptimized_tray.png +0 -0
  30. package/src-tauri/.pake/tauri.conf.json +24 -0
  31. package/src-tauri/.pake/tauri.linux.conf.json +16 -0
  32. package/src-tauri/.pake/tauri.macos.conf.json +15 -0
  33. package/src-tauri/.pake/tauri.windows.conf.json +15 -0
  34. package/src-tauri/gen/schemas/acl-manifests.json +1 -1
  35. package/src-tauri/gen/schemas/desktop-schema.json +0 -198
  36. package/src-tauri/gen/schemas/macOS-schema.json +0 -198
  37. package/src-tauri/pake.json +2 -1
  38. package/src-tauri/src/app/config.rs +2 -0
  39. package/src-tauri/src/app/window.rs +11 -7
  40. package/src-tauri/tauri.linux.conf.json +2 -2
  41. package/cli.js +0 -2
package/dist/cli.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import chalk from 'chalk';
2
3
  import { InvalidArgumentError, program, Option } from 'commander';
3
4
  import log from 'loglevel';
@@ -19,13 +20,13 @@ import { fileTypeFromBuffer } from 'file-type';
19
20
  import * as psl from 'psl';
20
21
 
21
22
  var name = "pake-cli";
22
- var version$1 = "3.2.0-beta";
23
+ var version$1 = "3.2.0-beta11";
23
24
  var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";
24
25
  var engines = {
25
26
  node: ">=16.0.0"
26
27
  };
27
28
  var bin = {
28
- pake: "./cli.js"
29
+ pake: "./dist/cli.js"
29
30
  };
30
31
  var repository = {
31
32
  type: "git",
@@ -45,13 +46,12 @@ var keywords = [
45
46
  ];
46
47
  var files = [
47
48
  "dist",
48
- "src-tauri",
49
- "cli.js"
49
+ "src-tauri"
50
50
  ];
51
51
  var scripts = {
52
52
  start: "npm run dev",
53
53
  dev: "npm run tauri dev",
54
- build: "npm run tauri build --release",
54
+ build: "npm run tauri build --",
55
55
  "build:debug": "npm run tauri build -- --debug",
56
56
  "build:mac": "npm run tauri build -- --target universal-apple-darwin",
57
57
  "build:config": "chmod +x script/app_config.mjs && node script/app_config.mjs",
@@ -60,11 +60,13 @@ var scripts = {
60
60
  cli: "rollup -c rollup.config.js --watch",
61
61
  "cli:dev": "cross-env NODE_ENV=development rollup -c rollup.config.js -w",
62
62
  "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js",
63
- format: "npx prettier --write . --ignore-unknown && cd src-tauri && cargo fmt --verbose",
63
+ test: "npm run cli:build && PAKE_CREATE_APP=1 node tests/index.js",
64
+ format: "prettier --write . --ignore-unknown && cd src-tauri && cargo fmt --verbose",
65
+ "hooks:setup": "bash .githooks/setup.sh",
64
66
  prepublishOnly: "npm run cli:build"
65
67
  };
66
68
  var type = "module";
67
- var exports = "./dist/pake.js";
69
+ var exports = "./dist/cli.js";
68
70
  var license = "MIT";
69
71
  var dependencies = {
70
72
  "@tauri-apps/api": "^2.7.0",
@@ -77,6 +79,7 @@ var dependencies = {
77
79
  "fs-extra": "^11.3.1",
78
80
  loglevel: "^1.9.2",
79
81
  ora: "^8.2.0",
82
+ "pake-cli": "file:.yalc/pake-cli",
80
83
  prompts: "^2.4.2",
81
84
  psl: "^1.15.0",
82
85
  "tmp-promise": "^3.0.3",
@@ -97,6 +100,7 @@ var devDependencies = {
97
100
  "@types/update-notifier": "^6.0.8",
98
101
  "app-root-path": "^3.1.0",
99
102
  "cross-env": "^7.0.3",
103
+ prettier: "^3.4.2",
100
104
  rollup: "^4.46.2",
101
105
  "rollup-plugin-typescript2": "^0.36.0",
102
106
  tslib: "^2.8.1",
@@ -133,7 +137,8 @@ var windows = [
133
137
  dark_mode: false,
134
138
  activation_shortcut: "",
135
139
  disabled_web_shortcuts: false,
136
- hide_on_close: true
140
+ hide_on_close: true,
141
+ incognito: false
137
142
  }
138
143
  ];
139
144
  var user_agent = {
@@ -222,10 +227,10 @@ var MacConf = {
222
227
  bundle: bundle$1
223
228
  };
224
229
 
225
- var productName = "we-read";
230
+ var productName = "weekly";
226
231
  var bundle = {
227
232
  icon: [
228
- "png/weekly.png"
233
+ "png/weekly_512.png"
229
234
  ],
230
235
  active: true,
231
236
  linux: {
@@ -312,18 +317,25 @@ const IS_LINUX = platform$1 === 'linux';
312
317
  const currentModulePath = fileURLToPath(import.meta.url);
313
318
  // Resolve the parent directory of the current module
314
319
  const npmDirectory = path.join(path.dirname(currentModulePath), '..');
315
- const tauriConfigDirectory = path.join(npmDirectory, 'src-tauri');
320
+ const tauriConfigDirectory = path.join(npmDirectory, 'src-tauri', '.pake');
316
321
 
317
- async function shellExec(command) {
322
+ async function shellExec(command, timeout = 300000) {
318
323
  try {
319
324
  const { exitCode } = await execa(command, {
320
325
  cwd: npmDirectory,
321
326
  stdio: 'inherit',
327
+ shell: true,
328
+ timeout,
322
329
  });
323
330
  return exitCode;
324
331
  }
325
332
  catch (error) {
326
- throw new Error(`Error occurred while executing command "${command}". Exit code: ${error.exitCode}`);
333
+ const exitCode = error.exitCode ?? 'unknown';
334
+ const errorMessage = error.message || 'Unknown error occurred';
335
+ if (error.timedOut) {
336
+ throw new Error(`Command timed out after ${timeout}ms: "${command}". Try increasing timeout or check network connectivity.`);
337
+ }
338
+ throw new Error(`Error occurred while executing command "${command}". Exit code: ${exitCode}. Details: ${errorMessage}`);
327
339
  }
328
340
  }
329
341
 
@@ -435,7 +447,26 @@ async function combineFiles(files, output) {
435
447
  }
436
448
 
437
449
  async function mergeConfig(url, options, tauriConf) {
438
- const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, } = options;
450
+ // Ensure .pake directory exists and copy source templates if needed
451
+ const srcTauriDir = path.join(npmDirectory, 'src-tauri');
452
+ await fsExtra.ensureDir(tauriConfigDirectory);
453
+ // Copy source config files to .pake directory (as templates)
454
+ const sourceFiles = [
455
+ 'tauri.conf.json',
456
+ 'tauri.macos.conf.json',
457
+ 'tauri.windows.conf.json',
458
+ 'tauri.linux.conf.json',
459
+ 'pake.json',
460
+ ];
461
+ await Promise.all(sourceFiles.map(async (file) => {
462
+ const sourcePath = path.join(srcTauriDir, file);
463
+ const destPath = path.join(tauriConfigDirectory, file);
464
+ if ((await fsExtra.pathExists(sourcePath)) &&
465
+ !(await fsExtra.pathExists(destPath))) {
466
+ await fsExtra.copy(sourcePath, destPath);
467
+ }
468
+ }));
469
+ const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, } = options;
439
470
  const { platform } = process;
440
471
  // Set Windows parameters.
441
472
  const tauriConfWindowOptions = {
@@ -449,6 +480,8 @@ async function mergeConfig(url, options, tauriConf) {
449
480
  dark_mode: darkMode,
450
481
  disabled_web_shortcuts: disabledWebShortcuts,
451
482
  hide_on_close: hideOnClose,
483
+ incognito: incognito,
484
+ title: title || null,
452
485
  };
453
486
  Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
454
487
  tauriConf.productName = name;
@@ -642,14 +675,21 @@ class BaseBuilder {
642
675
  const rustProjectDir = path.join(tauriSrcPath, '.cargo');
643
676
  const projectConf = path.join(rustProjectDir, 'config.toml');
644
677
  await fsExtra.ensureDir(rustProjectDir);
678
+ // For global CLI installation, always use npm
679
+ const packageManager = 'npm';
680
+ const registryOption = isChina
681
+ ? ' --registry=https://registry.npmmirror.com'
682
+ : '';
683
+ // Windows环境下需要更长的超时时间
684
+ const timeout = process.platform === 'win32' ? 600000 : 300000;
645
685
  if (isChina) {
646
686
  logger.info('✺ Located in China, using npm/rsProxy CN mirror.');
647
687
  const projectCnConf = path.join(tauriSrcPath, 'rust_proxy.toml');
648
688
  await fsExtra.copy(projectCnConf, projectConf);
649
- await shellExec(`cd "${npmDirectory}" && npm install --registry=https://registry.npmmirror.com`);
689
+ await shellExec(`cd "${npmDirectory}" && ${packageManager} install${registryOption}`, timeout);
650
690
  }
651
691
  else {
652
- await shellExec(`cd "${npmDirectory}" && npm install`);
692
+ await shellExec(`cd "${npmDirectory}" && ${packageManager} install`, timeout);
653
693
  }
654
694
  spinner.succeed(chalk.green('Package installed!'));
655
695
  if (!tauriTargetPathExists) {
@@ -683,25 +723,66 @@ class BaseBuilder {
683
723
  return target;
684
724
  }
685
725
  getBuildCommand() {
686
- // the debug option should support `--debug` and `--release`
687
- return this.options.debug ? 'npm run build:debug' : 'npm run build';
726
+ const baseCommand = this.options.debug
727
+ ? 'npm run build:debug'
728
+ : 'npm run build';
729
+ // Use temporary config directory to avoid modifying source files
730
+ const configPath = path.join(npmDirectory, 'src-tauri', '.pake', 'tauri.conf.json');
731
+ let fullCommand = `${baseCommand} -- -c "${configPath}"`;
732
+ // For macOS, use app bundles by default unless DMG is explicitly requested
733
+ if (IS_MAC && this.options.targets === 'app') {
734
+ fullCommand += ' --bundles app';
735
+ }
736
+ // Add macos-proxy feature for modern macOS (Darwin 23+ = macOS 14+)
737
+ if (IS_MAC) {
738
+ const macOSVersion = this.getMacOSMajorVersion();
739
+ if (macOSVersion >= 23) {
740
+ fullCommand += ' --features macos-proxy';
741
+ }
742
+ }
743
+ return fullCommand;
744
+ }
745
+ getMacOSMajorVersion() {
746
+ try {
747
+ const os = require('os');
748
+ const release = os.release();
749
+ const majorVersion = parseInt(release.split('.')[0], 10);
750
+ return majorVersion;
751
+ }
752
+ catch (error) {
753
+ return 0; // Disable proxy feature if version detection fails
754
+ }
688
755
  }
689
756
  getBasePath() {
690
757
  const basePath = this.options.debug ? 'debug' : 'release';
691
758
  return `src-tauri/target/${basePath}/bundle/`;
692
759
  }
693
760
  getBuildAppPath(npmDirectory, fileName, fileType) {
694
- return path.join(npmDirectory, this.getBasePath(), fileType.toLowerCase(), `${fileName}.${fileType}`);
761
+ // For app bundles on macOS, the directory is 'macos', not 'app'
762
+ const bundleDir = fileType.toLowerCase() === 'app' ? 'macos' : fileType.toLowerCase();
763
+ return path.join(npmDirectory, this.getBasePath(), bundleDir, `${fileName}.${fileType}`);
695
764
  }
696
765
  }
697
766
 
698
767
  class MacBuilder extends BaseBuilder {
699
768
  constructor(options) {
700
769
  super(options);
701
- this.options.targets = 'dmg';
770
+ // Use DMG by default for distribution
771
+ // Only create app bundles for testing to avoid user interaction
772
+ if (process.env.PAKE_CREATE_APP === '1') {
773
+ this.options.targets = 'app';
774
+ }
775
+ else {
776
+ this.options.targets = 'dmg';
777
+ }
702
778
  }
703
779
  getFileName() {
704
780
  const { name } = this.options;
781
+ // For app bundles, use simple name without version/arch
782
+ if (this.options.targets === 'app') {
783
+ return name;
784
+ }
785
+ // For DMG files, use versioned filename
705
786
  let arch;
706
787
  if (this.options.multiArch) {
707
788
  arch = 'universal';
@@ -808,6 +889,7 @@ const DEFAULT_PAKE_OPTIONS = {
808
889
  inject: [],
809
890
  installerLanguage: 'en-US',
810
891
  hideOnClose: true,
892
+ incognito: false,
811
893
  };
812
894
 
813
895
  async function checkUpdateTips() {
@@ -1051,6 +1133,10 @@ program
1051
1133
  .addOption(new Option('--hide-on-close', 'Hide window on close instead of exiting')
1052
1134
  .default(DEFAULT_PAKE_OPTIONS.hideOnClose)
1053
1135
  .hideHelp())
1136
+ .addOption(new Option('--title <string>', 'Window title').hideHelp())
1137
+ .addOption(new Option('--incognito', 'Launch app in incognito/private mode')
1138
+ .default(DEFAULT_PAKE_OPTIONS.incognito)
1139
+ .hideHelp())
1054
1140
  .addOption(new Option('--installer-language <string>', 'Installer language')
1055
1141
  .default(DEFAULT_PAKE_OPTIONS.installerLanguage)
1056
1142
  .hideHelp())