pake-cli 1.0.0-beta.0 โ†’ 1.0.0

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,38 +6,38 @@ 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';
17
17
 
18
- /******************************************************************************
19
- Copyright (c) Microsoft Corporation.
20
-
21
- Permission to use, copy, modify, and/or distribute this software for any
22
- purpose with or without fee is hereby granted.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
25
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
27
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
- PERFORMANCE OF THIS SOFTWARE.
31
- ***************************************************************************** */
32
-
33
- function __awaiter(thisArg, _arguments, P, generator) {
34
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
- return new (P || (P = Promise))(function (resolve, reject) {
36
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
37
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
38
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39
- step((generator = generator.apply(thisArg, _arguments || [])).next());
40
- });
18
+ /******************************************************************************
19
+ Copyright (c) Microsoft Corporation.
20
+
21
+ Permission to use, copy, modify, and/or distribute this software for any
22
+ purpose with or without fee is hereby granted.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
25
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
27
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
+ PERFORMANCE OF THIS SOFTWARE.
31
+ ***************************************************************************** */
32
+
33
+ function __awaiter(thisArg, _arguments, P, generator) {
34
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
35
+ return new (P || (P = Promise))(function (resolve, reject) {
36
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
37
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
38
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
39
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
40
+ });
41
41
  }
42
42
 
43
43
  const DEFAULT_PAKE_OPTIONS = {
@@ -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
  }
@@ -1942,7 +1974,8 @@ var tauri = {
1942
1974
  ],
1943
1975
  shortDescription: "",
1944
1976
  targets: [
1945
- "deb"
1977
+ "deb",
1978
+ "appimage"
1946
1979
  ]
1947
1980
  }
1948
1981
  };
@@ -1995,8 +2028,14 @@ class MacBuilder {
1995
2028
  log.debug('PakeAppOptions', options);
1996
2029
  const { name } = options;
1997
2030
  yield mergeTauriConfig(url, options, tauriConf);
1998
- yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
1999
- const arch = process.arch;
2031
+ yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
2032
+ let arch = "x64";
2033
+ if (process.arch === "arm64") {
2034
+ arch = "aarch64";
2035
+ }
2036
+ else {
2037
+ arch = process.arch;
2038
+ }
2000
2039
  const dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`;
2001
2040
  const appPath = this.getBuildedAppPath(npmDirectory, dmgName);
2002
2041
  const distPath = path.resolve(`${name}.dmg`);
@@ -2039,7 +2078,7 @@ class WinBuilder {
2039
2078
  logger.debug('PakeAppOptions', options);
2040
2079
  const { name } = options;
2041
2080
  yield mergeTauriConfig(url, options, tauriConf);
2042
- yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
2081
+ yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
2043
2082
  const language = tauriConf.tauri.bundle.windows.wix.language[0];
2044
2083
  const arch = process.arch;
2045
2084
  const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`;
@@ -2084,22 +2123,7 @@ class LinuxBuilder {
2084
2123
  logger.debug('PakeAppOptions', options);
2085
2124
  const { name } = options;
2086
2125
  yield mergeTauriConfig(url, options, tauriConf);
2087
- // write desktop
2088
- const assertSrc = `src-tauri/assets/${name}.desktop`;
2089
- const assertPath = path.join(npmDirectory, assertSrc);
2090
- const desktopStr = `
2091
- [Desktop Entry]
2092
- Encoding=UTF-8
2093
- Categories=Office
2094
- Exec=${name}
2095
- Icon=${name}
2096
- Name=${name}
2097
- StartupNotify=true
2098
- Terminal=false
2099
- Type=Application
2100
- `;
2101
- yield fs.writeFile(assertPath, desktopStr);
2102
- yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
2126
+ yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
2103
2127
  let arch = "";
2104
2128
  if (process.arch === "x64") {
2105
2129
  arch = "amd64";
@@ -2108,22 +2132,27 @@ Type=Application
2108
2132
  arch = process.arch;
2109
2133
  }
2110
2134
  const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
2111
- const appPath = this.getBuildedAppPath(npmDirectory, debName);
2135
+ const appPath = this.getBuildedAppPath(npmDirectory, "deb", debName);
2112
2136
  const distPath = path.resolve(`${name}.deb`);
2113
2137
  yield fs.copyFile(appPath, distPath);
2114
2138
  yield fs.unlink(appPath);
2139
+ const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
2140
+ const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName);
2141
+ const distAppPath = path.resolve(`${name}.AppImage`);
2142
+ yield fs.copyFile(appImagePath, distAppPath);
2143
+ yield fs.unlink(appImagePath);
2115
2144
  logger.success('Build success!');
2116
- logger.success('You can find the app installer in', distPath);
2145
+ logger.success('You can find the deb app installer in', distPath);
2146
+ logger.success('You can find the Appimage app installer in', distAppPath);
2117
2147
  });
2118
2148
  }
2119
- getBuildedAppPath(npmDirectory, dmgName) {
2120
- return path.join(npmDirectory, 'src-tauri/target/release/bundle/deb', dmgName);
2149
+ getBuildedAppPath(npmDirectory, packageType, packageName) {
2150
+ return path.join(npmDirectory, 'src-tauri/target/release/bundle/', packageType, packageName);
2121
2151
  }
2122
2152
  }
2123
2153
 
2124
2154
  class BuilderFactory {
2125
2155
  static create() {
2126
- console.log("now platform is ", process.platform);
2127
2156
  if (IS_MAC) {
2128
2157
  return new MacBuilder();
2129
2158
  }
@@ -2138,7 +2167,7 @@ class BuilderFactory {
2138
2167
  }
2139
2168
 
2140
2169
  var name = "pake-cli";
2141
- var version = "1.0.0-beta.0";
2170
+ var version = "0.1.2";
2142
2171
  var description = "๐Ÿคฑ๐Ÿป ๅพˆ็ฎ€ๅ•็š„็”จ Rust ๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆๅพˆๅฐ็š„ๆกŒ้ข App ๐Ÿคฑ๐Ÿป A simple way to make any web page a desktop application using Rust.";
2143
2172
  var bin = {
2144
2173
  pake: "./cli.js"
@@ -2154,14 +2183,13 @@ var author = {
2154
2183
  var files = [
2155
2184
  "dist",
2156
2185
  "src-tauri",
2157
- "cli.js",
2158
- "pake-default.icns"
2186
+ "cli.js"
2159
2187
  ];
2160
2188
  var scripts = {
2161
2189
  start: "npm run dev",
2162
2190
  dev: "npm run tauri dev",
2163
2191
  "dev:debug": "npm run tauri dev -- --features devtools",
2164
- "build:release": "npm run tauri build --release",
2192
+ build: "npm run tauri build --release",
2165
2193
  "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
2166
2194
  "build:all-windows": ".\\script\\build.bat",
2167
2195
  tauri: "tauri",
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0",
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",