pake-cli 0.0.1-beta.8 → 0.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.
Files changed (90) hide show
  1. package/.ecrc.json +3 -0
  2. package/.editorconfig +24 -0
  3. package/.github/FUNDING.yml +2 -2
  4. package/.github/ISSUE_TEMPLATE/bug.md +13 -0
  5. package/.github/workflows/editorconfig-check.yml +23 -0
  6. package/.github/workflows/main.yml +17 -0
  7. package/.github/workflows/rust-code-quality-check.yml +89 -0
  8. package/.prettierignore +4 -0
  9. package/.vscode/settings.json +1 -0
  10. package/CODE_OF_CONDUCT.md +128 -0
  11. package/CONTRIBUTING.md +26 -0
  12. package/LICENSE +21 -0
  13. package/README.md +175 -54
  14. package/README_EN.md +91 -53
  15. package/app.csv +9 -0
  16. package/bin/README.md +72 -0
  17. package/bin/builders/MacBuilder.ts +13 -14
  18. package/bin/builders/base.ts +10 -1
  19. package/bin/builders/common.ts +7 -25
  20. package/bin/cli.ts +12 -5
  21. package/bin/defaults.ts +1 -0
  22. package/bin/options/icon.ts +51 -53
  23. package/bin/options/index.ts +3 -5
  24. package/bin/types.ts +3 -3
  25. package/bin/utils/shell.ts +1 -0
  26. package/bin/utils/tlds.ts +1489 -0
  27. package/bin/utils/url.ts +26 -0
  28. package/dist/cli.js +1620 -101
  29. package/dist/twitter.css +176 -0
  30. package/icns2png.py +38 -0
  31. package/package.json +8 -7
  32. package/pake-default.icns +0 -0
  33. package/rollup.config.js +1 -1
  34. package/script/build.bat +80 -0
  35. package/script/build.sh +122 -0
  36. package/script/sd-apple-x64 +0 -0
  37. package/script/sd-linux-x64 +0 -0
  38. package/script/sd.exe +0 -0
  39. package/src-tauri/Cargo.lock +344 -65
  40. package/src-tauri/Cargo.toml +14 -6
  41. package/src-tauri/assets/com-tw93-weread.desktop +10 -0
  42. package/src-tauri/build.rs +1 -1
  43. package/src-tauri/icons/icon.icns +0 -0
  44. package/src-tauri/icons/reference.icns +0 -0
  45. package/src-tauri/icons/translate.icns +0 -0
  46. package/src-tauri/icons/twitter.icns +0 -0
  47. package/src-tauri/icons/{weRead.icns → weread.icns} +0 -0
  48. package/src-tauri/icons/youtube.icns +0 -0
  49. package/src-tauri/png/code_256.ico +0 -0
  50. package/src-tauri/png/code_32.ico +0 -0
  51. package/src-tauri/png/code_512.png +0 -0
  52. package/src-tauri/png/flomo_256.ico +0 -0
  53. package/src-tauri/png/flomo_32.ico +0 -0
  54. package/src-tauri/png/flomo_512.png +0 -0
  55. package/src-tauri/png/reference_256.ico +0 -0
  56. package/src-tauri/png/reference_32.ico +0 -0
  57. package/src-tauri/png/reference_512.png +0 -0
  58. package/src-tauri/png/tool_256.ico +0 -0
  59. package/src-tauri/png/tool_32.ico +0 -0
  60. package/src-tauri/png/tool_512.png +0 -0
  61. package/src-tauri/png/translate_256.ico +0 -0
  62. package/src-tauri/png/translate_32.ico +0 -0
  63. package/src-tauri/png/translate_512.png +0 -0
  64. package/src-tauri/png/twitter_256.ico +0 -0
  65. package/src-tauri/png/twitter_32.ico +0 -0
  66. package/src-tauri/png/twitter_512.png +0 -0
  67. package/src-tauri/png/weread_256.ico +0 -0
  68. package/src-tauri/png/weread_32.ico +0 -0
  69. package/src-tauri/png/weread_512.png +0 -0
  70. package/src-tauri/png/witeboard_256.ico +0 -0
  71. package/src-tauri/png/witeboard_32.ico +0 -0
  72. package/src-tauri/png/witeboard_512.png +0 -0
  73. package/src-tauri/png/youtube_256.ico +0 -0
  74. package/src-tauri/png/youtube_32.ico +0 -0
  75. package/src-tauri/png/youtube_512.png +0 -0
  76. package/src-tauri/png/yuque_256.ico +0 -0
  77. package/src-tauri/png/yuque_32.ico +0 -0
  78. package/src-tauri/png/yuque_512.png +0 -0
  79. package/src-tauri/src/main.rs +130 -25
  80. package/src-tauri/src/pake.js +140 -77
  81. package/src-tauri/tauri.conf.json +30 -13
  82. package/bin/options/title.ts +0 -14
  83. package/src-tauri/icons/anymind.icns +0 -0
  84. package/src-tauri/icons/fanfou.icns +0 -0
  85. package/src-tauri/icons/fone.icns +0 -0
  86. package/src-tauri/icons/jdread.icns +0 -0
  87. package/src-tauri/icons/jike.icns +0 -0
  88. package/src-tauri/icons/roam.icns +0 -0
  89. package/src-tauri/icons/vercel.icns +0 -0
  90. package/src-tauri/icons/whatsapp.icns +0 -0
@@ -0,0 +1,176 @@
1
+ [data-testid="placementTracking"] article,
2
+ a[href*="quick_promote_web"],
3
+ [data-testid="AppTabBar_Explore_Link"],
4
+ a[href*="/lists"][role="link"][aria-label],
5
+ a[href="/i/bookmarks"] {
6
+ display: none !important;
7
+ }
8
+
9
+ /* Hide Messages Drawer */
10
+ [data-testid="DMDrawer"] {
11
+ visibility: hidden !important;
12
+ }
13
+
14
+ [data-testid="primaryColumn"] > div > div {
15
+ position: relative !important;
16
+ }
17
+
18
+ /* Hide sidebar */
19
+ [data-testid="sidebarColumn"] {
20
+ visibility: hidden !important;
21
+ width: 0 !important;
22
+ margin: 0 !important;
23
+ padding: 0 !important;
24
+ z-index: 1 !important;
25
+ }
26
+
27
+ /* Twitter has a large screen breakpoint at 1000px */
28
+ /* Twitter web's small screen styles (< 988px) are minimal */
29
+ @media only screen and (min-width: 1000px) {
30
+ /* Center the Timeline */
31
+ /* Prevent horizontal scroll */
32
+ main[role="main"] {
33
+ align-items: center !important;
34
+ overflow-x: clip !important;
35
+ }
36
+
37
+ /* Match widths for feed */
38
+ [data-testid="primaryColumn"] {
39
+ width: 700px !important;
40
+ max-width: 700px !important;
41
+ margin: 0 auto !important;
42
+ }
43
+ [data-testid="primaryColumn"] > div > div:last-child,
44
+ [data-testid="primaryColumn"] > div > div:last-child div {
45
+ max-width: unset !important;
46
+ }
47
+
48
+ /* Nudge engagement row 81px right */
49
+ /* In default feed: 506px - 425px */
50
+ div[aria-label][role="group"][id^="id__"] {
51
+ margin-right: 81px !important;
52
+ }
53
+
54
+ /* Fix navigation to left */
55
+ header[role="banner"] {
56
+ position: fixed !important;
57
+ left: 0 !important;
58
+ }
59
+
60
+ header[role="banner"] > div > div > div {
61
+ justify-content: center !important;
62
+ padding-top: 0;
63
+ }
64
+
65
+ form[role="search"] > div:nth-child(1) > div {
66
+ background-color: transparent !important;
67
+ }
68
+
69
+ /* Align Twitter navigation icon with search */
70
+ h1[role="heading"] {
71
+ padding-top: 4px !important;
72
+ }
73
+
74
+ /* Navigation buttons labels and Account button label on hover */
75
+ header[role="banner"]
76
+ nav[role="navigation"]
77
+ *
78
+ div[dir="auto"]:not([aria-label])
79
+ > span,
80
+ [data-testid="SideNav_AccountSwitcher_Button"] > div:not(:first-child) {
81
+ display: inline-block !important;
82
+ opacity: 0 !important;
83
+ transition: 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
84
+ }
85
+ header[role="banner"]
86
+ nav[role="navigation"]:hover
87
+ *
88
+ div[dir="auto"]:not([aria-label])
89
+ > span,
90
+ [data-testid="SideNav_AccountSwitcher_Button"]:hover > div:not(:first-child) {
91
+ opacity: 1 !important;
92
+ }
93
+ header[role="banner"] nav[role="navigation"]:hover > * > div {
94
+ backdrop-filter: blur(12px) !important;
95
+ }
96
+ header[role="banner"] nav[role="navigation"] > a {
97
+ position: relative;
98
+ }
99
+
100
+ header[role="banner"] nav[role="navigation"] > a::before {
101
+ content: "";
102
+ position: absolute;
103
+ top: 0px;
104
+ right: -40px;
105
+ bottom: 0px;
106
+ left: 0px;
107
+ }
108
+ /* Align account button with floating tweet button */
109
+ [data-testid="SideNav_AccountSwitcher_Button"] {
110
+ bottom: 18px !important;
111
+ left: 1px !important;
112
+ }
113
+
114
+ /* Floating Tweet Button */
115
+ [data-testid="SideNav_NewTweet_Button"] {
116
+ position: fixed !important;
117
+ right: 16px !important;
118
+ bottom: 24px !important;
119
+ }
120
+ }
121
+
122
+ /* Add padding equal to navigation size when between 1000px-1265px */
123
+ @media only screen and (min-width: 1000px) and (max-width: 1265px) {
124
+ body {
125
+ padding-left: 88px;
126
+ }
127
+ }
128
+
129
+ /* Reveal searchbar and search filters at desktop breakpoint */
130
+ @media only screen and (min-width: 1265px) {
131
+ /* Reveal searchbar */
132
+ [data-testid="sidebarColumn"] form[role="search"] {
133
+ visibility: visible !important;
134
+ position: fixed !important;
135
+ top: 12px !important;
136
+ right: 16px !important;
137
+ }
138
+
139
+ /* Match size of input the placeholder content */
140
+ [data-testid="sidebarColumn"] input[placeholder="Search Twitter"] {
141
+ width: 150px;
142
+ }
143
+
144
+ /* Match size of focused search container to its dropdown */
145
+ /* Add blur filter to search container for overlap */
146
+ [data-testid="sidebarColumn"] form[role="search"]:focus-within {
147
+ width: 374px !important;
148
+ backdrop-filter: blur(12px) !important;
149
+ }
150
+
151
+ /* Match size of focused search input to its dropdown */
152
+ [data-testid="sidebarColumn"] input[placeholder="Search Twitter"]:focus {
153
+ width: 328px !important;
154
+ }
155
+
156
+ /* Reset width and left positioning to align search dropdown */
157
+ div[style*="left: -12px"] {
158
+ left: unset !important;
159
+ }
160
+ div[style="left: -8px; width: 306px;"] {
161
+ left: unset !important;
162
+ width: 374px !important;
163
+ }
164
+
165
+ /* Search Filters Custom Class */
166
+ .searchFilters {
167
+ visibility: visible !important;
168
+ position: fixed;
169
+ top: 12px;
170
+ right: 16px;
171
+ width: 240px;
172
+ }
173
+ .searchFilters > div > div:first-child {
174
+ display: none;
175
+ }
176
+ }
package/icns2png.py ADDED
@@ -0,0 +1,38 @@
1
+ """
2
+ 批量将icns文件转成png文件
3
+ Batch convert ICNS files to PNG files
4
+ """
5
+ import os
6
+
7
+ try:
8
+ from PIL import Image
9
+ except ImportError:
10
+ os.system("pip install Pillow")
11
+ from PIL import Image
12
+
13
+
14
+ if __name__ == "__main__":
15
+ now_dir = os.path.dirname(os.path.abspath(__file__))
16
+ icons_dir = os.path.join(now_dir, "src-tauri", "icons")
17
+ png_dir = os.path.join(now_dir, "src-tauri", "png")
18
+ if not os.path.exists(png_dir):
19
+ os.mkdir(png_dir)
20
+ file_list = os.listdir(icons_dir)
21
+ file_list = [file for file in file_list if file.endswith(".icns")]
22
+ for file in file_list:
23
+ icns_path = os.path.join(icons_dir, file)
24
+ image = Image.open(icns_path)
25
+ image_512 = image.copy().resize((512, 512))
26
+ image_256 = image.copy().resize((256, 256))
27
+ image_32 = image.copy().resize((32, 32))
28
+ image_name = os.path.splitext(file)[0]
29
+ image_512_path = os.path.join(png_dir, image_name + "_512.png")
30
+ image_256_path = os.path.join(png_dir, image_name + "_256.ico")
31
+ image_32_path = os.path.join(png_dir, image_name + "_32.ico")
32
+ image_512.save(image_512_path, "PNG")
33
+ image_256.save(image_256_path, "ICO")
34
+ image_32.save(image_32_path, "ICO")
35
+ print("png file write success.")
36
+ print(f"There are {len(os.listdir(png_dir))} png picture in ", png_dir)
37
+
38
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "0.0.1-beta.8",
3
+ "version": "0.0.1",
4
4
  "description": "用 Rust 来打包你的 App,底层使用 Tauri,当前支持微信读书、Flomo、Vercel",
5
5
  "bin": {
6
6
  "pake": "./cli.js"
@@ -16,7 +16,10 @@
16
16
  "scripts": {
17
17
  "start": "npm run dev",
18
18
  "dev": "npm run tauri dev",
19
+ "dev:debug": "npm run tauri dev -- --features devtools",
19
20
  "build": "npm run tauri build -- --target universal-apple-darwin",
21
+ "build:windows": "npm run tauri build -- --target x86_64-pc-windows-msvc",
22
+ "build:linux": "npm run tauri build --release",
20
23
  "tauri": "tauri",
21
24
  "cli": "rollup -c rollup.config.js --watch",
22
25
  "cli:build": "rollup -c rollup.config.js"
@@ -25,16 +28,14 @@
25
28
  "exports": "./dist/pake.js",
26
29
  "license": "MIT",
27
30
  "dependencies": {
28
- "@tauri-apps/api": "^1.0.2",
29
- "app-root-path": "^3.1.0",
31
+ "@tauri-apps/api": "^1.2.0",
32
+ "@tauri-apps/cli": "^1.2.0",
30
33
  "axios": "^1.1.3",
31
34
  "commander": "^9.4.1",
32
35
  "file-type": "^18.0.0",
33
- "icojs": "^0.17.0",
34
36
  "is-url": "^1.2.4",
37
+ "loglevel": "^1.8.1",
35
38
  "ora": "^6.1.2",
36
- "page-icon": "^0.4.0",
37
- "png2icons": "^2.0.1",
38
39
  "prompts": "^2.4.2",
39
40
  "shelljs": "^0.8.5",
40
41
  "tmp-promise": "^3.0.3"
@@ -44,12 +45,12 @@
44
45
  "@rollup/plugin-commonjs": "^23.0.2",
45
46
  "@rollup/plugin-json": "^5.0.1",
46
47
  "@rollup/plugin-typescript": "^9.0.2",
47
- "@tauri-apps/cli": "^1.0.2",
48
48
  "@types/is-url": "^1.2.30",
49
49
  "@types/page-icon": "^0.3.4",
50
50
  "@types/prompts": "^2.4.1",
51
51
  "@types/shelljs": "^0.8.11",
52
52
  "@types/tmp": "^0.2.3",
53
+ "app-root-path": "^3.1.0",
53
54
  "concurrently": "^7.5.0",
54
55
  "rollup": "^3.3.0",
55
56
  "rollup-plugin-typescript2": "^0.34.1",
Binary file
package/rollup.config.js CHANGED
@@ -12,10 +12,10 @@ export default {
12
12
  format: 'es'
13
13
  },
14
14
  plugins: [
15
+ json(),
15
16
  typescript({
16
17
  sourceMap: false,
17
18
  }),
18
- json(),
19
19
  commonjs(),
20
20
  alias({
21
21
  entries: [{ find: '@', replacement: path.join(appRootPath.path, 'bin') }],
@@ -0,0 +1,80 @@
1
+ @echo off
2
+ chcp 65001
3
+
4
+ if not exist node_modules (
5
+ call npm i
6
+ )
7
+
8
+ if not exist output (
9
+ mkdir output
10
+ )
11
+
12
+
13
+ if not exist output\windows (
14
+ mkdir output\windows
15
+ )
16
+
17
+ echo.
18
+ echo =======================
19
+ echo "build for windows"
20
+ echo =======================
21
+ echo.
22
+
23
+ :: total package number
24
+ set /A index=1
25
+ for /f %%a in (' find /c /v "" ^<"app.csv" ') do set /A total=%%a
26
+ :: ignore first header line
27
+ set /A total=total-1
28
+
29
+ set old_name=weread
30
+ set old_title=WeRead
31
+ set old_zh_name=微信阅读
32
+ set old_url=https://weread.qq.com/
33
+
34
+ :: for windows, we need replace package name to title
35
+ .\script\sd.exe "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri\tauri.conf.json
36
+
37
+ for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do (
38
+ setlocal enabledelayedexpansion
39
+ set name=%%i
40
+ set title=%%j
41
+ set name_zh=%%k
42
+ set url=%%l
43
+ @echo on
44
+
45
+ ::echo name is !name! !name_zh! !url!
46
+ :: replace url
47
+ .\script\sd.exe !old_url! !url! src-tauri\tauri.conf.json
48
+ ::replace pacakge name
49
+ .\script\sd.exe !old_title! !title! src-tauri\tauri.conf.json
50
+ .\script\sd.exe !old_name! !name! src-tauri\tauri.conf.json
51
+ echo update ico with 32x32 pictue
52
+ .\script\sd.exe !old_name! !name! src-tauri\src\main.rs
53
+ ::copy src-tauri\png\!name!_32.ico src-tauri\icons\icon.ico
54
+ echo.
55
+ ::update package info
56
+ set old_zh_name=!name_zh!
57
+ set old_name=!name!
58
+ set old_title=!title!
59
+ set old_url=!url!
60
+ ::build package
61
+ echo building package !index!/!total!
62
+ echo package name is !name! !name_zh!
63
+ echo npm run build:windows
64
+ @echo off
65
+ call npm run tauri build -- --target x86_64-pc-windows-msvc
66
+ move src-tauri\target\x86_64-pc-windows-msvc\release\bundle\msi\*.msi output\windows
67
+
68
+ @echo on
69
+ echo package build success!
70
+ echo.
71
+ echo.
72
+
73
+ set /A index=index+1
74
+ @echo off
75
+
76
+ )
77
+
78
+ :: for windows, we need replace package name to lower again
79
+ .\script\sd.exe "\"productName\": \"WeRead\"" "\"productName\": \"weread\"" src-tauri\tauri.conf.json
80
+ echo "output dir is output\windows"
@@ -0,0 +1,122 @@
1
+ #!/bin/bash
2
+
3
+ if [ ! -d "node_modules" ]; then
4
+ npm i
5
+ fi
6
+
7
+
8
+ if [ ! -d "output" ]; then
9
+ mkdir output
10
+ fi
11
+
12
+ if [[ "$OSTYPE" =~ ^linux ]]; then
13
+ if [ ! -d "output/linux" ]; then
14
+ mkdir output/linux
15
+ fi
16
+ fi
17
+
18
+
19
+ if [[ "$OSTYPE" =~ ^darwin ]]; then
20
+ if [ ! -d "output/macos" ]; then
21
+ mkdir output/macos
22
+ fi
23
+ fi
24
+
25
+ SHELL_FOLDER=$(cd "$(dirname "$0")" || exit 1; pwd)
26
+ # total app number, ignore first line
27
+ total=$(sed -n '$=' app.csv)
28
+ export total=$((total-1))
29
+ export index=1
30
+
31
+ old_name="weread"
32
+ old_title="WeRead"
33
+ old_zh_name="微信阅读"
34
+ old_url="https://weread.qq.com/"
35
+ package_prefix="com-tw93"
36
+
37
+ if [[ "$OSTYPE" =~ ^linux ]]; then
38
+ echo "==============="
39
+ echo "Build for Linux"
40
+ echo "==============="
41
+ export sd=${SHELL_FOLDER}/sd-linux-x64
42
+ chmod +x "$sd"
43
+ # for linux, package name may be com.xxx.xxx
44
+ echo "rename package name"
45
+ export desktop_file="src-tauri/assets/${package_prefix}.weread.desktop"
46
+ # sed -i "s/\"productName\": \"weread\"/\"productName\": \"${package_prefix}-weread\"/g" src-tauri/tauri.conf.json
47
+ $sd "\"productName\": \"weread\"" "\"productName\": \"${package_prefix}-weread\"" src-tauri/tauri.conf.json
48
+ fi
49
+
50
+ if [[ "$OSTYPE" =~ ^darwin ]]; then
51
+ echo "==============="
52
+ echo "Build for MacOS"
53
+ echo "==============="
54
+
55
+ export sd=${SHELL_FOLDER}/sd-apple-x64
56
+ chmod +x "$sd"
57
+ echo "rename package name"
58
+ $sd "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri/tauri.conf.json
59
+ fi
60
+
61
+ tail -n +2 app.csv | while IFS=, read -r -a arr;
62
+ do
63
+ package_name=${arr[0]}
64
+ package_title=${arr[1]}
65
+ package_zh_name=${arr[2]}
66
+ url=${arr[3]}
67
+ echo "update package name and url"
68
+ # replace package info
69
+ $sd "${old_url}" "${url}" src-tauri/tauri.conf.json
70
+ $sd "${old_name}" "${package_name}" src-tauri/tauri.conf.json
71
+ echo "update ico with 32x32 pictue"
72
+ $sd "${old_name}" "${package_name}" src-tauri/src/main.rs
73
+
74
+ # for apple, need replace title
75
+ if [[ "$OSTYPE" =~ ^darwin ]]; then
76
+ $sd "${old_title}" "${package_title}" src-tauri/tauri.conf.json
77
+ fi
78
+
79
+ # echo "update ico with 32x32 pictue"
80
+ # cp "src-tauri/png/${package_name}_32.ico" "src-tauri/icons/icon.ico"
81
+
82
+ if [[ "$OSTYPE" =~ ^linux ]]; then
83
+ echo "update desktop"
84
+ old_desktop="src-tauri/assets/${package_prefix}-${old_name}.desktop"
85
+ new_desktop="src-tauri/assets/${package_prefix}-${package_name}.desktop"
86
+ mv "${old_desktop}" "${new_desktop}"
87
+ $sd "${old_zh_name}" "${package_zh_name}" "${new_desktop}"
88
+ $sd "${old_name}" "${package_name}" "${new_desktop}"
89
+ fi
90
+
91
+ # update package info
92
+ old_name=${package_name}
93
+ old_title=${package_title}
94
+ old_zh_name=${package_zh_name}
95
+ old_url=${url}
96
+
97
+ echo "building package ${index}/${total}"
98
+ echo "package name is ${package_name} (${package_zh_name})"
99
+ npm run tauri build
100
+ echo "package build success!"
101
+ index=$((index+1))
102
+
103
+ if [[ "$OSTYPE" =~ ^linux ]]; then
104
+ mv src-tauri/target/release/bundle/deb/*.deb output/linux
105
+ fi
106
+
107
+ if [[ "$OSTYPE" =~ ^darwin ]]; then
108
+ mv src-tauri/target/release/bundle/dmg/*.dmg output/macos
109
+ echo ""
110
+ fi
111
+ done
112
+
113
+ echo "build all package success!"
114
+ if [[ "$OSTYPE" =~ ^linux ]]; then
115
+ echo "result file in output/linux"
116
+ fi
117
+
118
+ if [[ "$OSTYPE" =~ ^darwin ]]; then
119
+ # replace again
120
+ $sd "\"productName\": \"WeRead\"" "\"productName\": \"weread\"" src-tauri/tauri.conf.json
121
+ echo "result file in output/macos"
122
+ fi
Binary file
Binary file
package/script/sd.exe ADDED
Binary file