pake-cli 1.0.0-beta.1 โ†’ 1.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
@@ -6,11 +6,11 @@ import isurl from 'is-url';
6
6
  import prompts from 'prompts';
7
7
  import path from 'path';
8
8
  import fs from 'fs/promises';
9
+ import chalk from 'chalk';
9
10
  import crypto from 'crypto';
10
11
  import axios from 'axios';
11
12
  import { fileTypeFromBuffer } from 'file-type';
12
13
  import { dir } from 'tmp-promise';
13
- import chalk from 'chalk';
14
14
  import ora from 'ora';
15
15
  import shelljs from 'shelljs';
16
16
  import updateNotifier from 'update-notifier';
@@ -42,8 +42,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
42
42
 
43
43
  const DEFAULT_PAKE_OPTIONS = {
44
44
  icon: '',
45
- height: 800,
46
- width: 1280,
45
+ height: 780,
46
+ width: 1200,
47
47
  fullscreen: false,
48
48
  resizable: true,
49
49
  transparent: false,
@@ -1593,6 +1593,24 @@ function validateUrlInput(url) {
1593
1593
 
1594
1594
  const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
1595
1595
 
1596
+ const logger = {
1597
+ info(...msg) {
1598
+ log.info(...msg.map((m) => chalk.blue.bold(m)));
1599
+ },
1600
+ debug(...msg) {
1601
+ log.debug(...msg);
1602
+ },
1603
+ error(...msg) {
1604
+ log.error(...msg.map((m) => chalk.red.bold(m)));
1605
+ },
1606
+ warn(...msg) {
1607
+ log.info(...msg.map((m) => chalk.yellow.bold(m)));
1608
+ },
1609
+ success(...msg) {
1610
+ log.info(...msg.map((m) => chalk.green.bold(m)));
1611
+ }
1612
+ };
1613
+
1596
1614
  function promptText(message, initial) {
1597
1615
  return __awaiter(this, void 0, void 0, function* () {
1598
1616
  const response = yield prompts({
@@ -1617,18 +1635,43 @@ function mergeTauriConfig(url, options, tauriConf) {
1617
1635
  Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions));
1618
1636
  tauriConf.package.productName = name;
1619
1637
  tauriConf.tauri.bundle.identifier = identifier;
1620
- tauriConf.tauri.bundle.icon = [options.icon];
1621
- if (process.platform === "win32") {
1622
- const ico_path = path.join(npmDirectory, 'src-tauri/png/weread_32.ico');
1623
- yield fs.copyFile(options.icon, ico_path);
1638
+ const exists = yield fs.stat(options.icon)
1639
+ .then(() => true)
1640
+ .catch(() => false);
1641
+ if (exists) {
1642
+ let updateIconPath = true;
1643
+ let customIconExt = path.extname(options.icon).toLowerCase();
1644
+ if (process.platform === "win32") {
1645
+ if (customIconExt === ".ico") {
1646
+ const ico_path = path.join(npmDirectory, `src-tauri/png/${name.toLowerCase()}_32.ico`);
1647
+ tauriConf.tauri.bundle.resources = [`png/${name.toLowerCase()}_32.ico`];
1648
+ yield fs.copyFile(options.icon, ico_path);
1649
+ }
1650
+ else {
1651
+ updateIconPath = false;
1652
+ logger.warn(`icon file in Windows must be 256 * 256 pix with .ico type, but you give ${customIconExt}`);
1653
+ }
1654
+ }
1655
+ if (process.platform === "linux") {
1656
+ delete tauriConf.tauri.bundle.deb.files;
1657
+ if (customIconExt != ".png") {
1658
+ updateIconPath = false;
1659
+ logger.warn(`icon file in Linux must be 512 * 512 pix with .png type, but you give ${customIconExt}`);
1660
+ }
1661
+ }
1662
+ if (process.platform === "darwin" && customIconExt !== ".icns") {
1663
+ updateIconPath = false;
1664
+ logger.warn(`icon file in MacOS must be .icns type, but you give ${customIconExt}`);
1665
+ }
1666
+ if (updateIconPath) {
1667
+ tauriConf.tauri.bundle.icon = [options.icon];
1668
+ }
1669
+ else {
1670
+ logger.warn(`icon file will not change with default.`);
1671
+ }
1624
1672
  }
1625
- if (process.platform === "linux") {
1626
- const installSrc = `/usr/share/applications/${name}.desktop`;
1627
- const assertSrc = `src-tauri/assets/${name}.desktop`;
1628
- const assertPath = path.join(npmDirectory, assertSrc);
1629
- tauriConf.tauri.bundle.deb.files = {
1630
- [installSrc]: assertPath
1631
- };
1673
+ else {
1674
+ logger.warn("the custom icon path may not exists. we will use default icon to replace it");
1632
1675
  }
1633
1676
  let configPath = "";
1634
1677
  switch (process.platform) {
@@ -1659,23 +1702,9 @@ function getIdentifier(name, url) {
1659
1702
  return `pake-${postFixHash}`;
1660
1703
  }
1661
1704
 
1662
- const logger = {
1663
- info(...msg) {
1664
- log.info(...msg.map((m) => chalk.blue.bold(m)));
1665
- },
1666
- debug(...msg) {
1667
- log.debug(...msg);
1668
- },
1669
- error(...msg) {
1670
- log.error(...msg.map((m) => chalk.red.bold(m)));
1671
- },
1672
- warn(...msg) {
1673
- log.info(...msg.map((m) => chalk.yellow.bold(m)));
1674
- },
1675
- success(...msg) {
1676
- log.info(...msg.map((m) => chalk.green.bold(m)));
1677
- }
1678
- };
1705
+ const IS_MAC = process.platform === 'darwin';
1706
+ const IS_WIN = process.platform === 'win32';
1707
+ const IS_LINUX = process.platform === 'linux';
1679
1708
 
1680
1709
  function handleIcon(options, url) {
1681
1710
  return __awaiter(this, void 0, void 0, function* () {
@@ -1688,15 +1717,21 @@ function handleIcon(options, url) {
1688
1717
  }
1689
1718
  }
1690
1719
  if (!options.icon) {
1691
- return inferIcon(options.name);
1720
+ return getDefaultIcon();
1692
1721
  }
1693
1722
  });
1694
1723
  }
1695
- function inferIcon(name, url) {
1724
+ function getDefaultIcon() {
1696
1725
  return __awaiter(this, void 0, void 0, function* () {
1697
1726
  logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)');
1698
- const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
1699
- return path.join(npmDirectory, 'pake-default.icns');
1727
+ let iconPath = 'src-tauri/icons/icon.icns';
1728
+ if (IS_WIN) {
1729
+ iconPath = 'src-tauri/png/icon_256.ico';
1730
+ }
1731
+ else if (IS_LINUX) {
1732
+ iconPath = 'src-tauri/png/icon_512.png';
1733
+ }
1734
+ return path.join(npmDirectory, iconPath);
1700
1735
  });
1701
1736
  }
1702
1737
  // export async function getIconFromPageUrl(url: string) {
@@ -1772,10 +1807,6 @@ function handleOptions(options, url) {
1772
1807
  });
1773
1808
  }
1774
1809
 
1775
- const IS_MAC = process.platform === 'darwin';
1776
- const IS_WIN = process.platform === 'win32';
1777
- const IS_LINUX = process.platform === 'linux';
1778
-
1779
1810
  function shellExec(command) {
1780
1811
  return new Promise((resolve, reject) => {
1781
1812
  shelljs.exec(command, { async: true, silent: false }, (code) => {
@@ -1816,7 +1847,7 @@ var tauri$3 = {
1816
1847
  transparent: true,
1817
1848
  fullscreen: false,
1818
1849
  width: 1200,
1819
- height: 728,
1850
+ height: 780,
1820
1851
  resizable: true
1821
1852
  }
1822
1853
  ],
@@ -1869,7 +1900,8 @@ var tauri$2 = {
1869
1900
  wix: {
1870
1901
  language: [
1871
1902
  "en-US"
1872
- ]
1903
+ ],
1904
+ template: "assets/main.wxs"
1873
1905
  }
1874
1906
  }
1875
1907
  }
@@ -1929,7 +1961,9 @@ var tauri = {
1929
1961
  "libssl-dev",
1930
1962
  "libgtk-3-dev",
1931
1963
  "libayatana-appindicator3-dev",
1932
- "librsvg2-dev"
1964
+ "librsvg2-dev",
1965
+ "gnome-video-effects",
1966
+ "gnome-video-effects-extra"
1933
1967
  ],
1934
1968
  files: {
1935
1969
  "/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"
@@ -1942,7 +1976,8 @@ var tauri = {
1942
1976
  ],
1943
1977
  shortDescription: "",
1944
1978
  targets: [
1945
- "deb"
1979
+ "deb",
1980
+ "appimage"
1946
1981
  ]
1947
1982
  }
1948
1983
  };
@@ -1995,7 +2030,7 @@ class MacBuilder {
1995
2030
  log.debug('PakeAppOptions', options);
1996
2031
  const { name } = options;
1997
2032
  yield mergeTauriConfig(url, options, tauriConf);
1998
- yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
2033
+ yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
1999
2034
  let arch = "x64";
2000
2035
  if (process.arch === "arm64") {
2001
2036
  arch = "aarch64";
@@ -2045,7 +2080,7 @@ class WinBuilder {
2045
2080
  logger.debug('PakeAppOptions', options);
2046
2081
  const { name } = options;
2047
2082
  yield mergeTauriConfig(url, options, tauriConf);
2048
- yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
2083
+ yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
2049
2084
  const language = tauriConf.tauri.bundle.windows.wix.language[0];
2050
2085
  const arch = process.arch;
2051
2086
  const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`;
@@ -2090,22 +2125,7 @@ class LinuxBuilder {
2090
2125
  logger.debug('PakeAppOptions', options);
2091
2126
  const { name } = options;
2092
2127
  yield mergeTauriConfig(url, options, tauriConf);
2093
- // write desktop
2094
- const assertSrc = `src-tauri/assets/${name}.desktop`;
2095
- const assertPath = path.join(npmDirectory, assertSrc);
2096
- const desktopStr = `
2097
- [Desktop Entry]
2098
- Encoding=UTF-8
2099
- Categories=Office
2100
- Exec=${name}
2101
- Icon=${name}
2102
- Name=${name}
2103
- StartupNotify=true
2104
- Terminal=false
2105
- Type=Application
2106
- `;
2107
- yield fs.writeFile(assertPath, desktopStr);
2108
- yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
2128
+ yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
2109
2129
  let arch = "";
2110
2130
  if (process.arch === "x64") {
2111
2131
  arch = "amd64";
@@ -2114,22 +2134,27 @@ Type=Application
2114
2134
  arch = process.arch;
2115
2135
  }
2116
2136
  const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
2117
- const appPath = this.getBuildedAppPath(npmDirectory, debName);
2137
+ const appPath = this.getBuildedAppPath(npmDirectory, "deb", debName);
2118
2138
  const distPath = path.resolve(`${name}.deb`);
2119
2139
  yield fs.copyFile(appPath, distPath);
2120
2140
  yield fs.unlink(appPath);
2141
+ const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
2142
+ const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName);
2143
+ const distAppPath = path.resolve(`${name}.AppImage`);
2144
+ yield fs.copyFile(appImagePath, distAppPath);
2145
+ yield fs.unlink(appImagePath);
2121
2146
  logger.success('Build success!');
2122
- logger.success('You can find the app installer in', distPath);
2147
+ logger.success('You can find the deb app installer in', distPath);
2148
+ logger.success('You can find the Appimage app installer in', distAppPath);
2123
2149
  });
2124
2150
  }
2125
- getBuildedAppPath(npmDirectory, dmgName) {
2126
- return path.join(npmDirectory, 'src-tauri/target/release/bundle/deb', dmgName);
2151
+ getBuildedAppPath(npmDirectory, packageType, packageName) {
2152
+ return path.join(npmDirectory, 'src-tauri/target/release/bundle/', packageType, packageName);
2127
2153
  }
2128
2154
  }
2129
2155
 
2130
2156
  class BuilderFactory {
2131
2157
  static create() {
2132
- console.log("now platform is ", process.platform);
2133
2158
  if (IS_MAC) {
2134
2159
  return new MacBuilder();
2135
2160
  }
@@ -2144,8 +2169,11 @@ class BuilderFactory {
2144
2169
  }
2145
2170
 
2146
2171
  var name = "pake-cli";
2147
- var version = "1.0.0-beta.1";
2172
+ var version = "1.0.1";
2148
2173
  var description = "๐Ÿคฑ๐Ÿป ๅพˆ็ฎ€ๅ•็š„็”จ Rust ๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆๅพˆๅฐ็š„ๆกŒ้ข App ๐Ÿคฑ๐Ÿป A simple way to make any web page a desktop application using Rust.";
2174
+ var engines = {
2175
+ node: "^14.13 || >=16.0.0"
2176
+ };
2149
2177
  var bin = {
2150
2178
  pake: "./cli.js"
2151
2179
  };
@@ -2157,17 +2185,25 @@ var author = {
2157
2185
  name: "Tw93",
2158
2186
  email: "tw93@qq.com"
2159
2187
  };
2188
+ var keywords = [
2189
+ "pake",
2190
+ "pake-cli",
2191
+ "rust",
2192
+ "tauri",
2193
+ "no-electron",
2194
+ "productivity"
2195
+ ];
2160
2196
  var files = [
2161
2197
  "dist",
2162
2198
  "src-tauri",
2163
- "cli.js",
2164
- "pake-default.icns"
2199
+ "cli.js"
2165
2200
  ];
2166
2201
  var scripts = {
2167
2202
  start: "npm run dev",
2168
2203
  dev: "npm run tauri dev",
2169
2204
  "dev:debug": "npm run tauri dev -- --features devtools",
2170
- "build:release": "npm run tauri build --release",
2205
+ build: "npm run tauri build --release",
2206
+ "build:mac": "npm run tauri build -- --target universal-apple-darwin",
2171
2207
  "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
2172
2208
  "build:all-windows": ".\\script\\build.bat",
2173
2209
  tauri: "tauri",
@@ -2180,7 +2216,7 @@ var exports = "./dist/pake.js";
2180
2216
  var license = "MIT";
2181
2217
  var dependencies = {
2182
2218
  "@tauri-apps/api": "^1.2.0",
2183
- "@tauri-apps/cli": "^1.2.1",
2219
+ "@tauri-apps/cli": "^1.2.2",
2184
2220
  axios: "^1.1.3",
2185
2221
  chalk: "^5.1.2",
2186
2222
  commander: "^9.4.1",
@@ -2216,9 +2252,11 @@ var packageJson = {
2216
2252
  name: name,
2217
2253
  version: version,
2218
2254
  description: description,
2255
+ engines: engines,
2219
2256
  bin: bin,
2220
2257
  repository: repository,
2221
2258
  author: author,
2259
+ keywords: keywords,
2222
2260
  files: files,
2223
2261
  scripts: scripts,
2224
2262
  type: type,
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.1",
4
4
  "description": "๐Ÿคฑ๐Ÿป ๅพˆ็ฎ€ๅ•็š„็”จ Rust ๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆๅพˆๅฐ็š„ๆกŒ้ข App ๐Ÿคฑ๐Ÿป A simple way to make any web page a desktop application using Rust.",
5
+ "engines": {
6
+ "node": "^14.13 || >=16.0.0"
7
+ },
5
8
  "bin": {
6
9
  "pake": "./cli.js"
7
10
  },
@@ -13,17 +16,25 @@
13
16
  "name": "Tw93",
14
17
  "email": "tw93@qq.com"
15
18
  },
19
+ "keywords": [
20
+ "pake",
21
+ "pake-cli",
22
+ "rust",
23
+ "tauri",
24
+ "no-electron",
25
+ "productivity"
26
+ ],
16
27
  "files": [
17
28
  "dist",
18
29
  "src-tauri",
19
- "cli.js",
20
- "pake-default.icns"
30
+ "cli.js"
21
31
  ],
22
32
  "scripts": {
23
33
  "start": "npm run dev",
24
34
  "dev": "npm run tauri dev",
25
35
  "dev:debug": "npm run tauri dev -- --features devtools",
26
- "build:release": "npm run tauri build --release",
36
+ "build": "npm run tauri build --release",
37
+ "build:mac": "npm run tauri build -- --target universal-apple-darwin",
27
38
  "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
28
39
  "build:all-windows": ".\\script\\build.bat",
29
40
  "tauri": "tauri",
@@ -36,7 +47,7 @@
36
47
  "license": "MIT",
37
48
  "dependencies": {
38
49
  "@tauri-apps/api": "^1.2.0",
39
- "@tauri-apps/cli": "^1.2.1",
50
+ "@tauri-apps/cli": "^1.2.2",
40
51
  "axios": "^1.1.3",
41
52
  "chalk": "^5.1.2",
42
53
  "commander": "^9.4.1",