diff --git a/.gitignore b/.gitignore index 6f8dd99..31b9985 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ lerna-debug.log* node_modules dist-ssr -dist/cli.js *.local # Editor directories and files @@ -25,6 +24,9 @@ dist/cli.js *.sw? .npmrc output +*.msi +*.deb +*.dmg package-lock.json yarn.lock diff --git a/README.md b/README.md index 6918d69..131271a 100644 --- a/README.md +++ b/README.md @@ -145,14 +145,9 @@ npm i // 调试 npm run dev -// 打包 Mac 应用 -npm run build +// 打包应用 +npm run build:release -// 打包 Windows 应用 -npm run build:windows - -// 打包 Linux 应用 -npm run build:linux ``` ## 打新包 diff --git a/README_EN.md b/README_EN.md index 360868a..510fc5d 100644 --- a/README_EN.md +++ b/README_EN.md @@ -144,14 +144,8 @@ npm i // Local development npm run dev -// Pack Mac application -npm run build - -// Pack Windows application -npm run build:windows - -// Pack Linux application -npm run build:linux +// Pack application +npm run build:release ``` diff --git a/app.csv b/app.csv index 0750cb5..adcc6d9 100644 --- a/app.csv +++ b/app.csv @@ -5,5 +5,5 @@ reference,Reference,Reference,https://wangchujiang.com/reference/index.html code,Code,Code,https://riju.codes/ yuque,YuQue,语雀,https://www.yuque.com/ flomo,Flomo,浮墨,https://flomoapp.com/mine -weread,WeRead,微信阅读,https://weread.qq.com/ qwerty,Qwerty,Qwerty,https://qwerty.kaiyi.cool/ +weread,WeRead,微信阅读,https://weread.qq.com/ diff --git a/bin/builders/BuilderFactory.ts b/bin/builders/BuilderFactory.ts index 908c78b..bec51fc 100644 --- a/bin/builders/BuilderFactory.ts +++ b/bin/builders/BuilderFactory.ts @@ -1,13 +1,17 @@ -import { IS_MAC } from '@/utils/platform.js'; +import { IS_MAC, IS_WIN } from '@/utils/platform.js'; import { IBuilder } from './base.js'; import MacBuilder from './MacBuilder.js'; import WinBuilder from './WinBulider.js'; export default class BuilderFactory { static create(): IBuilder { + console.log("now platform is ", process.platform); if (IS_MAC) { return new MacBuilder(); } - throw new Error('The current system does not support'); + if (IS_WIN) { + return new WinBuilder(); + } + throw new Error('The current system does not support!!'); } } diff --git a/bin/builders/MacBuilder.ts b/bin/builders/MacBuilder.ts index 4677eeb..057761f 100644 --- a/bin/builders/MacBuilder.ts +++ b/bin/builders/MacBuilder.ts @@ -6,7 +6,8 @@ import { PakeAppOptions } from '@/types.js'; import { IBuilder } from './base.js'; import { shellExec } from '@/utils/shell.js'; // @ts-expect-error 加上resolveJsonModule rollup会打包报错 -import tauriConf from '../../src-tauri/tauri.conf.json'; +// import tauriConf from '../../src-tauri/tauri.macos.conf.json'; +import tauriConf from './tauriConf.js'; import log from 'loglevel'; import { mergeTauriConfig } from './common.js'; import { npmDirectory } from '@/utils/dir.js'; @@ -39,10 +40,11 @@ export default class MacBuilder implements IBuilder { await mergeTauriConfig(url, options, tauriConf); - const code = await shellExec(`cd ${npmDirectory} && npm run build`); - const dmgName = `${name}_${tauriConf.package.version}_universal.dmg`; + const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build:release`); + const arch = process.arch; + const dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`; const appPath = this.getBuildedAppPath(npmDirectory, dmgName); - const distPath = path.resolve(`${name}_universal.dmg`); + const distPath = path.resolve(`${name}.dmg`); await fs.copyFile(appPath, distPath); await fs.unlink(appPath); @@ -53,7 +55,7 @@ export default class MacBuilder implements IBuilder { getBuildedAppPath(npmDirectory: string, dmgName: string) { return path.join( npmDirectory, - 'src-tauri/target/universal-apple-darwin/release/bundle/dmg', + 'src-tauri/target/release/bundle/dmg', dmgName ); } diff --git a/bin/builders/WinBulider.ts b/bin/builders/WinBulider.ts index d67ee29..a6978b2 100644 --- a/bin/builders/WinBulider.ts +++ b/bin/builders/WinBulider.ts @@ -6,7 +6,9 @@ import { PakeAppOptions } from '@/types.js'; import { IBuilder } from './base.js'; import { shellExec } from '@/utils/shell.js'; // @ts-expect-error 加上resolveJsonModule rollup会打包报错 -import tauriConf from '../../src-tauri/tauri.conf.json'; +// import tauriConf from '../../src-tauri/tauri.windows.conf.json'; +import tauriConf from './tauriConf.js'; + import { fileURLToPath } from 'url'; import logger from '@/options/logger.js'; import { mergeTauriConfig } from './common.js'; @@ -41,19 +43,26 @@ export default class WinBuilder implements IBuilder { async build(url: string, options: PakeAppOptions) { logger.debug('PakeAppOptions', options); + const { name } = options; await mergeTauriConfig(url, options, tauriConf); - const code = await shellExec(`cd ${npmDirectory} && npm run build:windows`); - // const dmgName = `${name}_${tauriConf.package.version}_universal.dmg`; - // const appPath = this.getBuildedAppPath(npmDirectory, dmgName); - // await fs.copyFile(appPath, path.resolve(`${name}_universal.dmg`)); + const _ = await shellExec(`cd ${npmDirectory} && npm install && npm run build:release`); + const language = tauriConf.tauri.bundle.windows.wix.language[0]; + const arch = process.arch; + const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`; + const appPath = this.getBuildedAppPath(npmDirectory, msiName); + const distPath = path.resolve(`${name}.msi`); + await fs.copyFile(appPath, distPath); + await fs.unlink(appPath); + logger.success('Build success!'); + logger.success('You can find the app installer in', distPath); } getBuildedAppPath(npmDirectory: string, dmgName: string) { return path.join( npmDirectory, - 'src-tauri/target/universal-apple-darwin/release/bundle/dmg', + 'src-tauri/target/release/bundle/msi', dmgName ); } diff --git a/bin/builders/common.ts b/bin/builders/common.ts index 7fced8b..91ad334 100644 --- a/bin/builders/common.ts +++ b/bin/builders/common.ts @@ -41,9 +41,31 @@ export async function mergeTauriConfig( tauriConf.package.productName = name; tauriConf.tauri.bundle.identifier = identifier; tauriConf.tauri.bundle.icon = [options.icon]; + if (process.platform === "win32") { + const ico_path = path.join(npmDirectory, 'src-tauri/png/weread_32.ico'); + await fs.copyFile(options.icon, ico_path); + + } + let configPath = ""; + switch (process.platform) { + case "win32": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.windows.conf.json'); + break; + } + case "darwin": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.macos.conf.json'); + break; + } + } + + let bundleConf = {tauri: {bundle: tauriConf.tauri.bundle}}; + await fs.writeFile( + configPath, + Buffer.from(JSON.stringify(bundleConf), 'utf-8') + ); - const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json'); + const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json') await fs.writeFile( configJsonPath, Buffer.from(JSON.stringify(tauriConf), 'utf-8') diff --git a/bin/builders/tauriConf.js b/bin/builders/tauriConf.js new file mode 100644 index 0000000..6fa52e9 --- /dev/null +++ b/bin/builders/tauriConf.js @@ -0,0 +1,22 @@ +import CommonConf from '../../src-tauri/tauri.conf.json'; +import WinConf from '../../src-tauri/tauri.windows.conf.json'; +import MacConf from '../../src-tauri/tauri.macos.conf.json'; + +let tauriConf = { + package: CommonConf.package, + tauri: CommonConf.tauri +} +switch (process.platform) { + case "win32": { + tauriConf.tauri.bundle = WinConf.tauri.bundle; + break; + } + case "darwin": { + tauriConf.tauri.bundle = MacConf.tauri.bundle; + break; + } +} + +export default tauriConf; + + diff --git a/bin/cli.ts b/bin/cli.ts index 3e6490a..14a6d0e 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -8,7 +8,7 @@ import handleInputOptions from './options/index.js'; import BuilderFactory from './builders/BuilderFactory.js'; import { checkUpdateTips } from './helpers/updater.js'; // @ts-expect-error -import packageJson from '../../package.json'; +import packageJson from '../package.json'; import logger from './options/logger.js'; program.version(packageJson.version).description('A cli application can package a web page to desktop application.'); diff --git a/dist/cli.js b/dist/cli.js new file mode 100644 index 0000000..018abeb --- /dev/null +++ b/dist/cli.js @@ -0,0 +1,2158 @@ +import * as Commander from 'commander'; +import { program } from 'commander'; +import log from 'loglevel'; +import url, { fileURLToPath } from 'url'; +import isurl from 'is-url'; +import prompts from 'prompts'; +import path from 'path'; +import fs from 'fs/promises'; +import crypto from 'crypto'; +import axios from 'axios'; +import { fileTypeFromBuffer } from 'file-type'; +import { dir } from 'tmp-promise'; +import chalk from 'chalk'; +import ora from 'ora'; +import shelljs from 'shelljs'; +import updateNotifier from 'update-notifier'; + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +const DEFAULT_PAKE_OPTIONS = { + icon: '', + height: 800, + width: 1280, + fullscreen: false, + resizable: true, + transparent: false, + debug: false, +}; + +const tlds = [ + "aaa", + "aarp", + "abarth", + "abb", + "abbott", + "abbvie", + "abc", + "able", + "abogado", + "abudhabi", + "ac", + "academy", + "accenture", + "accountant", + "accountants", + "aco", + "actor", + "ad", + "adac", + "ads", + "adult", + "ae", + "aeg", + "aero", + "aetna", + "af", + "afl", + "africa", + "ag", + "agakhan", + "agency", + "ai", + "aig", + "airbus", + "airforce", + "airtel", + "akdn", + "al", + "alfaromeo", + "alibaba", + "alipay", + "allfinanz", + "allstate", + "ally", + "alsace", + "alstom", + "am", + "amazon", + "americanexpress", + "americanfamily", + "amex", + "amfam", + "amica", + "amsterdam", + "analytics", + "android", + "anquan", + "anz", + "ao", + "aol", + "apartments", + "app", + "apple", + "aq", + "aquarelle", + "ar", + "arab", + "aramco", + "archi", + "army", + "arpa", + "art", + "arte", + "as", + "asda", + "asia", + "associates", + "at", + "athleta", + "attorney", + "au", + "auction", + "audi", + "audible", + "audio", + "auspost", + "author", + "auto", + "autos", + "avianca", + "aw", + "aws", + "ax", + "axa", + "az", + "azure", + "ba", + "baby", + "baidu", + "banamex", + "bananarepublic", + "band", + "bank", + "bar", + "barcelona", + "barclaycard", + "barclays", + "barefoot", + "bargains", + "baseball", + "basketball", + "bauhaus", + "bayern", + "bb", + "bbc", + "bbt", + "bbva", + "bcg", + "bcn", + "bd", + "be", + "beats", + "beauty", + "beer", + "bentley", + "berlin", + "best", + "bestbuy", + "bet", + "bf", + "bg", + "bh", + "bharti", + "bi", + "bible", + "bid", + "bike", + "bing", + "bingo", + "bio", + "biz", + "bj", + "black", + "blackfriday", + "blockbuster", + "blog", + "bloomberg", + "blue", + "bm", + "bms", + "bmw", + "bn", + "bnpparibas", + "bo", + "boats", + "boehringer", + "bofa", + "bom", + "bond", + "boo", + "book", + "booking", + "bosch", + "bostik", + "boston", + "bot", + "boutique", + "box", + "br", + "bradesco", + "bridgestone", + "broadway", + "broker", + "brother", + "brussels", + "bs", + "bt", + "build", + "builders", + "business", + "buy", + "buzz", + "bv", + "bw", + "by", + "bz", + "bzh", + "ca", + "cab", + "cafe", + "cal", + "call", + "calvinklein", + "cam", + "camera", + "camp", + "canon", + "capetown", + "capital", + "capitalone", + "car", + "caravan", + "cards", + "care", + "career", + "careers", + "cars", + "casa", + "case", + "cash", + "casino", + "cat", + "catering", + "catholic", + "cba", + "cbn", + "cbre", + "cbs", + "cc", + "cd", + "center", + "ceo", + "cern", + "cf", + "cfa", + "cfd", + "cg", + "ch", + "chanel", + "channel", + "charity", + "chase", + "chat", + "cheap", + "chintai", + "christmas", + "chrome", + "church", + "ci", + "cipriani", + "circle", + "cisco", + "citadel", + "citi", + "citic", + "city", + "cityeats", + "ck", + "cl", + "claims", + "cleaning", + "click", + "clinic", + "clinique", + "clothing", + "cloud", + "club", + "clubmed", + "cm", + "cn", + "co", + "coach", + "codes", + "coffee", + "college", + "cologne", + "com", + "comcast", + "commbank", + "community", + "company", + "compare", + "computer", + "comsec", + "condos", + "construction", + "consulting", + "contact", + "contractors", + "cooking", + "cookingchannel", + "cool", + "coop", + "corsica", + "country", + "coupon", + "coupons", + "courses", + "cpa", + "cr", + "credit", + "creditcard", + "creditunion", + "cricket", + "crown", + "crs", + "cruise", + "cruises", + "cu", + "cuisinella", + "cv", + "cw", + "cx", + "cy", + "cymru", + "cyou", + "cz", + "dabur", + "dad", + "dance", + "data", + "date", + "dating", + "datsun", + "day", + "dclk", + "dds", + "de", + "deal", + "dealer", + "deals", + "degree", + "delivery", + "dell", + "deloitte", + "delta", + "democrat", + "dental", + "dentist", + "desi", + "design", + "dev", + "dhl", + "diamonds", + "diet", + "digital", + "direct", + "directory", + "discount", + "discover", + "dish", + "diy", + "dj", + "dk", + "dm", + "dnp", + "do", + "docs", + "doctor", + "dog", + "domains", + "dot", + "download", + "drive", + "dtv", + "dubai", + "dunlop", + "dupont", + "durban", + "dvag", + "dvr", + "dz", + "earth", + "eat", + "ec", + "eco", + "edeka", + "edu", + "education", + "ee", + "eg", + "email", + "emerck", + "energy", + "engineer", + "engineering", + "enterprises", + "epson", + "equipment", + "er", + "ericsson", + "erni", + "es", + "esq", + "estate", + "et", + "etisalat", + "eu", + "eurovision", + "eus", + "events", + "exchange", + "expert", + "exposed", + "express", + "extraspace", + "fage", + "fail", + "fairwinds", + "faith", + "family", + "fan", + "fans", + "farm", + "farmers", + "fashion", + "fast", + "fedex", + "feedback", + "ferrari", + "ferrero", + "fi", + "fiat", + "fidelity", + "fido", + "film", + "final", + "finance", + "financial", + "fire", + "firestone", + "firmdale", + "fish", + "fishing", + "fit", + "fitness", + "fj", + "fk", + "flickr", + "flights", + "flir", + "florist", + "flowers", + "fly", + "fm", + "fo", + "foo", + "food", + "foodnetwork", + "football", + "ford", + "forex", + "forsale", + "forum", + "foundation", + "fox", + "fr", + "free", + "fresenius", + "frl", + "frogans", + "frontdoor", + "frontier", + "ftr", + "fujitsu", + "fun", + "fund", + "furniture", + "futbol", + "fyi", + "ga", + "gal", + "gallery", + "gallo", + "gallup", + "game", + "games", + "gap", + "garden", + "gay", + "gb", + "gbiz", + "gd", + "gdn", + "ge", + "gea", + "gent", + "genting", + "george", + "gf", + "gg", + "ggee", + "gh", + "gi", + "gift", + "gifts", + "gives", + "giving", + "gl", + "glass", + "gle", + "global", + "globo", + "gm", + "gmail", + "gmbh", + "gmo", + "gmx", + "gn", + "godaddy", + "gold", + "goldpoint", + "golf", + "goo", + "goodyear", + "goog", + "google", + "gop", + "got", + "gov", + "gp", + "gq", + "gr", + "grainger", + "graphics", + "gratis", + "green", + "gripe", + "grocery", + "group", + "gs", + "gt", + "gu", + "guardian", + "gucci", + "guge", + "guide", + "guitars", + "guru", + "gw", + "gy", + "hair", + "hamburg", + "hangout", + "haus", + "hbo", + "hdfc", + "hdfcbank", + "health", + "healthcare", + "help", + "helsinki", + "here", + "hermes", + "hgtv", + "hiphop", + "hisamitsu", + "hitachi", + "hiv", + "hk", + "hkt", + "hm", + "hn", + "hockey", + "holdings", + "holiday", + "homedepot", + "homegoods", + "homes", + "homesense", + "honda", + "horse", + "hospital", + "host", + "hosting", + "hot", + "hoteles", + "hotels", + "hotmail", + "house", + "how", + "hr", + "hsbc", + "ht", + "hu", + "hughes", + "hyatt", + "hyundai", + "ibm", + "icbc", + "ice", + "icu", + "id", + "ie", + "ieee", + "ifm", + "ikano", + "il", + "im", + "imamat", + "imdb", + "immo", + "immobilien", + "in", + "inc", + "industries", + "infiniti", + "info", + "ing", + "ink", + "institute", + "insurance", + "insure", + "int", + "international", + "intuit", + "investments", + "io", + "ipiranga", + "iq", + "ir", + "irish", + "is", + "ismaili", + "ist", + "istanbul", + "it", + "itau", + "itv", + "jaguar", + "java", + "jcb", + "je", + "jeep", + "jetzt", + "jewelry", + "jio", + "jll", + "jm", + "jmp", + "jnj", + "jo", + "jobs", + "joburg", + "jot", + "joy", + "jp", + "jpmorgan", + "jprs", + "juegos", + "juniper", + "kaufen", + "kddi", + "ke", + "kerryhotels", + "kerrylogistics", + "kerryproperties", + "kfh", + "kg", + "kh", + "ki", + "kia", + "kids", + "kim", + "kinder", + "kindle", + "kitchen", + "kiwi", + "km", + "kn", + "koeln", + "komatsu", + "kosher", + "kp", + "kpmg", + "kpn", + "kr", + "krd", + "kred", + "kuokgroup", + "kw", + "ky", + "kyoto", + "kz", + "la", + "lacaixa", + "lamborghini", + "lamer", + "lancaster", + "lancia", + "land", + "landrover", + "lanxess", + "lasalle", + "lat", + "latino", + "latrobe", + "law", + "lawyer", + "lb", + "lc", + "lds", + "lease", + "leclerc", + "lefrak", + "legal", + "lego", + "lexus", + "lgbt", + "li", + "lidl", + "life", + "lifeinsurance", + "lifestyle", + "lighting", + "like", + "lilly", + "limited", + "limo", + "lincoln", + "linde", + "link", + "lipsy", + "live", + "living", + "lk", + "llc", + "llp", + "loan", + "loans", + "locker", + "locus", + "loft", + "lol", + "london", + "lotte", + "lotto", + "love", + "lpl", + "lplfinancial", + "lr", + "ls", + "lt", + "ltd", + "ltda", + "lu", + "lundbeck", + "luxe", + "luxury", + "lv", + "ly", + "ma", + "macys", + "madrid", + "maif", + "maison", + "makeup", + "man", + "management", + "mango", + "map", + "market", + "marketing", + "markets", + "marriott", + "marshalls", + "maserati", + "mattel", + "mba", + "mc", + "mckinsey", + "md", + "me", + "med", + "media", + "meet", + "melbourne", + "meme", + "memorial", + "men", + "menu", + "merckmsd", + "mg", + "mh", + "miami", + "microsoft", + "mil", + "mini", + "mint", + "mit", + "mitsubishi", + "mk", + "ml", + "mlb", + "mls", + "mm", + "mma", + "mn", + "mo", + "mobi", + "mobile", + "moda", + "moe", + "moi", + "mom", + "monash", + "money", + "monster", + "mormon", + "mortgage", + "moscow", + "moto", + "motorcycles", + "mov", + "movie", + "mp", + "mq", + "mr", + "ms", + "msd", + "mt", + "mtn", + "mtr", + "mu", + "museum", + "music", + "mutual", + "mv", + "mw", + "mx", + "my", + "mz", + "na", + "nab", + "nagoya", + "name", + "natura", + "navy", + "nba", + "nc", + "ne", + "nec", + "net", + "netbank", + "netflix", + "network", + "neustar", + "new", + "news", + "next", + "nextdirect", + "nexus", + "nf", + "nfl", + "ng", + "ngo", + "nhk", + "ni", + "nico", + "nike", + "nikon", + "ninja", + "nissan", + "nissay", + "nl", + "no", + "nokia", + "northwesternmutual", + "norton", + "now", + "nowruz", + "nowtv", + "np", + "nr", + "nra", + "nrw", + "ntt", + "nu", + "nyc", + "nz", + "obi", + "observer", + "office", + "okinawa", + "olayan", + "olayangroup", + "oldnavy", + "ollo", + "om", + "omega", + "one", + "ong", + "onl", + "online", + "ooo", + "open", + "oracle", + "orange", + "org", + "organic", + "origins", + "osaka", + "otsuka", + "ott", + "ovh", + "pa", + "page", + "panasonic", + "paris", + "pars", + "partners", + "parts", + "party", + "passagens", + "pay", + "pccw", + "pe", + "pet", + "pf", + "pfizer", + "pg", + "ph", + "pharmacy", + "phd", + "philips", + "phone", + "photo", + "photography", + "photos", + "physio", + "pics", + "pictet", + "pictures", + "pid", + "pin", + "ping", + "pink", + "pioneer", + "pizza", + "pk", + "pl", + "place", + "play", + "playstation", + "plumbing", + "plus", + "pm", + "pn", + "pnc", + "pohl", + "poker", + "politie", + "porn", + "post", + "pr", + "pramerica", + "praxi", + "press", + "prime", + "pro", + "prod", + "productions", + "prof", + "progressive", + "promo", + "properties", + "property", + "protection", + "pru", + "prudential", + "ps", + "pt", + "pub", + "pw", + "pwc", + "py", + "qa", + "qpon", + "quebec", + "quest", + "racing", + "radio", + "re", + "read", + "realestate", + "realtor", + "realty", + "recipes", + "red", + "redstone", + "redumbrella", + "rehab", + "reise", + "reisen", + "reit", + "reliance", + "ren", + "rent", + "rentals", + "repair", + "report", + "republican", + "rest", + "restaurant", + "review", + "reviews", + "rexroth", + "rich", + "richardli", + "ricoh", + "ril", + "rio", + "rip", + "ro", + "rocher", + "rocks", + "rodeo", + "rogers", + "room", + "rs", + "rsvp", + "ru", + "rugby", + "ruhr", + "run", + "rw", + "rwe", + "ryukyu", + "sa", + "saarland", + "safe", + "safety", + "sakura", + "sale", + "salon", + "samsclub", + "samsung", + "sandvik", + "sandvikcoromant", + "sanofi", + "sap", + "sarl", + "sas", + "save", + "saxo", + "sb", + "sbi", + "sbs", + "sc", + "sca", + "scb", + "schaeffler", + "schmidt", + "scholarships", + "school", + "schule", + "schwarz", + "science", + "scot", + "sd", + "se", + "search", + "seat", + "secure", + "security", + "seek", + "select", + "sener", + "services", + "ses", + "seven", + "sew", + "sex", + "sexy", + "sfr", + "sg", + "sh", + "shangrila", + "sharp", + "shaw", + "shell", + "shia", + "shiksha", + "shoes", + "shop", + "shopping", + "shouji", + "show", + "showtime", + "si", + "silk", + "sina", + "singles", + "site", + "sj", + "sk", + "ski", + "skin", + "sky", + "skype", + "sl", + "sling", + "sm", + "smart", + "smile", + "sn", + "sncf", + "so", + "soccer", + "social", + "softbank", + "software", + "sohu", + "solar", + "solutions", + "song", + "sony", + "soy", + "spa", + "space", + "sport", + "spot", + "sr", + "srl", + "ss", + "st", + "stada", + "staples", + "star", + "statebank", + "statefarm", + "stc", + "stcgroup", + "stockholm", + "storage", + "store", + "stream", + "studio", + "study", + "style", + "su", + "sucks", + "supplies", + "supply", + "support", + "surf", + "surgery", + "suzuki", + "sv", + "swatch", + "swiss", + "sx", + "sy", + "sydney", + "systems", + "sz", + "tab", + "taipei", + "talk", + "taobao", + "target", + "tatamotors", + "tatar", + "tattoo", + "tax", + "taxi", + "tc", + "tci", + "td", + "tdk", + "team", + "tech", + "technology", + "tel", + "temasek", + "tennis", + "teva", + "tf", + "tg", + "th", + "thd", + "theater", + "theatre", + "tiaa", + "tickets", + "tienda", + "tiffany", + "tips", + "tires", + "tirol", + "tj", + "tjmaxx", + "tjx", + "tk", + "tkmaxx", + "tl", + "tm", + "tmall", + "tn", + "to", + "today", + "tokyo", + "tools", + "top", + "toray", + "toshiba", + "total", + "tours", + "town", + "toyota", + "toys", + "tr", + "trade", + "trading", + "training", + "travel", + "travelchannel", + "travelers", + "travelersinsurance", + "trust", + "trv", + "tt", + "tube", + "tui", + "tunes", + "tushu", + "tv", + "tvs", + "tw", + "tz", + "ua", + "ubank", + "ubs", + "ug", + "uk", + "unicom", + "university", + "uno", + "uol", + "ups", + "us", + "uy", + "uz", + "va", + "vacations", + "vana", + "vanguard", + "vc", + "ve", + "vegas", + "ventures", + "verisign", + "vermögensberater", + "vermögensberatung", + "versicherung", + "vet", + "vg", + "vi", + "viajes", + "video", + "vig", + "viking", + "villas", + "vin", + "vip", + "virgin", + "visa", + "vision", + "viva", + "vivo", + "vlaanderen", + "vn", + "vodka", + "volkswagen", + "volvo", + "vote", + "voting", + "voto", + "voyage", + "vu", + "vuelos", + "wales", + "walmart", + "walter", + "wang", + "wanggou", + "watch", + "watches", + "weather", + "weatherchannel", + "webcam", + "weber", + "website", + "wed", + "wedding", + "weibo", + "weir", + "wf", + "whoswho", + "wien", + "wiki", + "williamhill", + "win", + "windows", + "wine", + "winners", + "wme", + "wolterskluwer", + "woodside", + "work", + "works", + "world", + "wow", + "ws", + "wtc", + "wtf", + "xbox", + "xerox", + "xfinity", + "xihuan", + "xin", + "xxx", + "xyz", + "yachts", + "yahoo", + "yamaxun", + "yandex", + "ye", + "yodobashi", + "yoga", + "yokohama", + "you", + "youtube", + "yt", + "yun", + "za", + "zappos", + "zara", + "zero", + "zip", + "zm", + "zone", + "zuerich", + "zw", + "ελ", + "ευ", + "бг", + "бел", + "дети", + "ею", + "католик", + "ком", + "мкд", + "мон", + "москва", + "онлайн", + "орг", + "рус", + "рф", + "сайт", + "срб", + "укр", + "қаз", + "հայ", + "ישראל", + "קום", + "ابوظبي", + "اتصالات", + "ارامكو", + "الاردن", + "البحرين", + "الجزائر", + "السعودية", + "العليان", + "المغرب", + "امارات", + "ایران", + "بارت", + "بازار", + "بيتك", + "بھارت", + "تونس", + "سودان", + "سورية", + "شبكة", + "عراق", + "عرب", + "عمان", + "فلسطين", + "قطر", + "كاثوليك", + "كوم", + "مصر", + "مليسيا", + "موريتانيا", + "موقع", + "همراه", + "پاکستان", + "ڀارت", + "कॉम", + "नेट", + "भारत", + "भारतम्", + "भारोत", + "संगठन", + "বাংলা", + "ভারত", + "ভাৰত", + "ਭਾਰਤ", + "ભારત", + "ଭାରତ", + "இந்தியா", + "இலங்கை", + "சிங்கப்பூர்", + "భారత్", + "ಭಾರತ", + "ഭാരതം", + "ලංකා", + "คอม", + "ไทย", + "ລາວ", + "გე", + "みんな", + "アマゾン", + "クラウド", + "グーグル", + "コム", + "ストア", + "セール", + "ファッション", + "ポイント", + "世界", + "中信", + "中国", + "中國", + "中文网", + "亚马逊", + "企业", + "佛山", + "信息", + "健康", + "八卦", + "公司", + "公益", + "台湾", + "台灣", + "商城", + "商店", + "商标", + "嘉里", + "嘉里大酒店", + "在线", + "大拿", + "天主教", + "娱乐", + "家電", + "广东", + "微博", + "慈善", + "我爱你", + "手机", + "招聘", + "政务", + "政府", + "新加坡", + "新闻", + "时尚", + "書籍", + "机构", + "淡马锡", + "游戏", + "澳門", + "点看", + "移动", + "组织机构", + "网址", + "网店", + "网站", + "网络", + "联通", + "诺基亚", + "谷歌", + "购物", + "通販", + "集团", + "電訊盈科", + "飞利浦", + "食品", + "餐厅", + "香格里拉", + "香港", + "닷넷", + "닷컴", + "삼성", + "한국", +]; + +function getDomain(inputUrl) { + const parsed = url.parse(inputUrl).host; + var parts = parsed.split('.'); + if (parts[0] === 'www' && parts[1] !== 'com') { + parts.shift(); + } + var ln = parts.length, i = ln, minLength = parts[parts.length - 1].length, part; + // iterate backwards + while ((part = parts[--i])) { + // stop when we find a non-TLD part + if (i === 0 || // 'asia.com' (last remaining must be the SLD) + i < ln - 2 || // TLDs only span 2 levels + part.length < minLength || // 'www.cn.com' (valid TLD as second-level domain) + tlds.indexOf(part) < 0 // officialy not a TLD + ) { + return part; + } + } +} +function appendProtocol(inputUrl) { + const parsed = url.parse(inputUrl); + if (!parsed.protocol) { + const urlWithProtocol = `https://${inputUrl}`; + return urlWithProtocol; + } + return inputUrl; +} +function normalizeUrl(urlToNormalize) { + const urlWithProtocol = appendProtocol(urlToNormalize); + if (isurl(urlWithProtocol)) { + return urlWithProtocol; + } + else { + throw new Error(`Your url "${urlWithProtocol}" is invalid`); + } +} + +function validateNumberInput(value) { + const parsedValue = Number(value); + if (isNaN(parsedValue)) { + throw new Commander.InvalidArgumentError('Not a number.'); + } + return parsedValue; +} +function validateUrlInput(url) { + try { + return normalizeUrl(url); + } + catch (error) { + throw new Commander.InvalidArgumentError(error.message); + } +} + +const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); + +function promptText(message, initial) { + return __awaiter(this, void 0, void 0, function* () { + const response = yield prompts({ + type: 'text', + name: 'content', + message, + initial, + }); + return response.content; + }); +} +function mergeTauriConfig(url, options, tauriConf) { + return __awaiter(this, void 0, void 0, function* () { + const { width, height, fullscreen, transparent, resizable, identifier, name, } = options; + const tauriConfWindowOptions = { + width, + height, + fullscreen, + transparent, + resizable, + }; + Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions)); + tauriConf.package.productName = name; + tauriConf.tauri.bundle.identifier = identifier; + tauriConf.tauri.bundle.icon = [options.icon]; + if (process.platform === "win32") { + const ico_path = path.join(npmDirectory, 'src-tauri/png/weread_32.ico'); + // tauriConf.tauri.bundle.resources = [options.icon]; + yield fs.copyFile(options.icon, ico_path); + } + let configPath = ""; + switch (process.platform) { + case "win32": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.windows.conf.json'); + break; + } + case "darwin": { + configPath = path.join(npmDirectory, 'src-tauri/tauri.macos.conf.json'); + break; + } + } + let bundleConf = { tauri: { bundle: tauriConf.tauri.bundle } }; + yield fs.writeFile(configPath, Buffer.from(JSON.stringify(bundleConf), 'utf-8')); + // delete tauriConf.tauri.bundle; + const configJsonPath = path.join(npmDirectory, 'src-tauri/tauri.conf.json'); + yield fs.writeFile(configJsonPath, Buffer.from(JSON.stringify(tauriConf), 'utf-8')); + }); +} + +function getIdentifier(name, url) { + const hash = crypto.createHash('md5'); + hash.update(url); + const postFixHash = hash.digest('hex').substring(0, 6); + return `pake-${postFixHash}`; +} + +const logger = { + info(...msg) { + log.info(...msg.map((m) => chalk.blue.bold(m))); + }, + debug(...msg) { + log.debug(...msg); + }, + error(...msg) { + log.error(...msg.map((m) => chalk.red.bold(m))); + }, + warn(...msg) { + log.info(...msg.map((m) => chalk.yellow.bold(m))); + }, + success(...msg) { + log.info(...msg.map((m) => chalk.green.bold(m))); + } +}; + +function handleIcon(options, url) { + return __awaiter(this, void 0, void 0, function* () { + if (options.icon) { + if (options.icon.startsWith('http')) { + return downloadIcon(options.icon); + } + else { + return path.resolve(options.icon); + } + } + if (!options.icon) { + return inferIcon(options.name); + } + }); +} +function inferIcon(name, url) { + return __awaiter(this, void 0, void 0, function* () { + logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)'); + const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); + return path.join(npmDirectory, 'pake-default.icns'); + }); +} +// export async function getIconFromPageUrl(url: string) { +// const icon = await pageIcon(url); +// console.log(icon); +// if (icon.ext === '.ico') { +// const a = await ICO.parse(icon.data); +// icon.data = Buffer.from(a[0].buffer); +// } +// const iconDir = (await dir()).path; +// const iconPath = path.join(iconDir, `/icon.icns`); +// const out = png2icons.createICNS(icon.data, png2icons.BILINEAR, 0); +// await fs.writeFile(iconPath, out); +// return iconPath; +// } +// export async function getIconFromMacosIcons(name: string) { +// const data = { +// query: name, +// filters: 'approved:true', +// hitsPerPage: 10, +// page: 1, +// }; +// const res = await axios.post('https://p1txh7zfb3-2.algolianet.com/1/indexes/macOSicons/query?x-algolia-agent=Algolia%20for%20JavaScript%20(4.13.1)%3B%20Browser', data, { +// headers: { +// 'x-algolia-api-key': '0ba04276e457028f3e11e38696eab32c', +// 'x-algolia-application-id': 'P1TXH7ZFB3', +// }, +// }); +// if (!res.data.hits.length) { +// return ''; +// } else { +// return downloadIcon(res.data.hits[0].icnsUrl); +// } +// } +function downloadIcon(iconUrl) { + return __awaiter(this, void 0, void 0, function* () { + let iconResponse; + try { + iconResponse = yield axios.get(iconUrl, { + responseType: 'arraybuffer', + }); + } + catch (error) { + if (error.response && error.response.status === 404) { + return null; + } + throw error; + } + const iconData = yield iconResponse.data; + if (!iconData) { + return null; + } + const fileDetails = yield fileTypeFromBuffer(iconData); + if (!fileDetails) { + return null; + } + const { path } = yield dir(); + const iconPath = `${path}/icon.${fileDetails.ext}`; + yield fs.writeFile(iconPath, iconData); + return iconPath; + }); +} + +function handleOptions(options, url) { + return __awaiter(this, void 0, void 0, function* () { + const appOptions = Object.assign(Object.assign({}, options), { identifier: '' }); + if (!appOptions.name) { + appOptions.name = yield promptText('please input your application name', getDomain(url)); + } + appOptions.identifier = getIdentifier(appOptions.name, url); + appOptions.icon = yield handleIcon(appOptions); + return appOptions; + }); +} + +const IS_MAC = process.platform === 'darwin'; +const IS_WIN = process.platform === 'win32'; +process.platform === 'linux'; + +function shellExec(command) { + return new Promise((resolve, reject) => { + shelljs.exec(command, { async: true, silent: false }, (code) => { + if (code === 0) { + resolve(0); + } + else { + reject(new Error(`${code}`)); + } + }); + }); +} + +const RustInstallScriptFocMac = "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"; +const RustInstallScriptForWin = 'winget install --id Rustlang.Rustup'; +function installRust() { + return __awaiter(this, void 0, void 0, function* () { + const spinner = ora('Downloading Rust').start(); + try { + yield shellExec(IS_WIN ? RustInstallScriptForWin : RustInstallScriptFocMac); + spinner.succeed(); + } + catch (error) { + console.error('install rust return code', error.message); + spinner.fail(); + process.exit(1); + } + }); +} +function checkRustInstalled() { + return shelljs.exec('rustc --version', { silent: true }).code === 0; +} + +var tauri$2 = { + windows: [ + { + url: "https://www.baidu.com", + transparent: false, + fullscreen: false, + width: 1280, + height: 800, + resizable: true + } + ], + security: { + csp: null + }, + updater: { + active: false + }, + bundle: { + icon: [ + "C:\\Users\\18826\\Documents\\electron_build\\Pake\\src-tauri\\png\\code_256.ico" + ], + identifier: "pake-f9751d", + active: true, + category: "DeveloperTool", + copyright: "", + externalBin: [ + ], + longDescription: "", + resources: [ + "C:\\Users\\18826\\Documents\\electron_build\\Pake\\src-tauri\\png\\code_256.ico" + ], + shortDescription: "", + targets: [ + "msi" + ], + windows: { + certificateThumbprint: null, + digestAlgorithm: "sha256", + timestampUrl: "", + wix: { + language: [ + "en-US" + ] + } + } + } +}; +var CommonConf = { + "package": { + version: "1.0.0", + productName: "baidu" +}, + tauri: tauri$2 +}; + +var tauri$1 = { + bundle: { + icon: [ + "png/weread_256.ico", + "png/weread_32.ico" + ], + identifier: "com.tw93.weread", + active: true, + category: "DeveloperTool", + copyright: "", + externalBin: [ + ], + longDescription: "", + resources: [ + "png/weread_32.ico" + ], + shortDescription: "", + targets: [ + "msi" + ], + windows: { + certificateThumbprint: null, + digestAlgorithm: "sha256", + timestampUrl: "", + wix: { + language: [ + "en-US" + ] + } + } + } +}; +var WinConf = { + tauri: tauri$1 +}; + +var tauri = { + bundle: { + icon: [ + "icons/weread.icns" + ], + identifier: "com.tw93.weread", + active: true, + category: "DeveloperTool", + copyright: "", + externalBin: [ + ], + longDescription: "", + macOS: { + entitlements: null, + exceptionDomain: "", + frameworks: [ + ], + providerShortName: null, + signingIdentity: null + }, + resources: [ + ], + shortDescription: "", + targets: [ + "dmg" + ] + } +}; +var MacConf = { + tauri: tauri +}; + +let tauriConf = { + package: CommonConf.package, + tauri: CommonConf.tauri +}; +switch (process.platform) { + case "win32": { + tauriConf.tauri.bundle = WinConf.tauri.bundle; + break; + } + case "darwin": { + tauriConf.tauri.bundle = MacConf.tauri.bundle; + break; + } +} + +class MacBuilder { + prepare() { + return __awaiter(this, void 0, void 0, function* () { + if (checkRustInstalled()) { + return; + } + const res = yield prompts({ + type: 'confirm', + message: 'We detected that you have not installed Rust. Install it now?', + name: 'value', + }); + if (res.value) { + // TODO 国内有可能会超时 + yield installRust(); + } + else { + log.error('Error: Pake need Rust to package your webapp!!!'); + process.exit(2); + } + }); + } + build(url, options) { + return __awaiter(this, void 0, void 0, function* () { + log.debug('PakeAppOptions', options); + const { name } = options; + yield mergeTauriConfig(url, options, tauriConf); + yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`); + const arch = process.arch; + const dmgName = `${name}_${tauriConf.package.version}_${arch}.dmg`; + const appPath = this.getBuildedAppPath(npmDirectory, dmgName); + const distPath = path.resolve(`${name}.dmg`); + yield fs.copyFile(appPath, distPath); + yield fs.unlink(appPath); + logger.success('Build success!'); + logger.success('You can find the app installer in', distPath); + }); + } + getBuildedAppPath(npmDirectory, dmgName) { + return path.join(npmDirectory, 'src-tauri/target/release/bundle/dmg', dmgName); + } +} + +class WinBuilder { + prepare() { + return __awaiter(this, void 0, void 0, function* () { + logger.info('To build the Windows app, you need to install Rust and VS Build Tools.'); + logger.info('See more in https://tauri.app/v1/guides/getting-started/prerequisites#installing\n'); + if (checkRustInstalled()) { + return; + } + const res = yield prompts({ + type: 'confirm', + message: 'We detected that you have not installed Rust. Install it now?', + name: 'value', + }); + if (res.value) { + // TODO 国内有可能会超时 + yield installRust(); + } + else { + logger.error('Error: Pake needs Rust to package your webapp!!!'); + process.exit(2); + } + }); + } + build(url, options) { + return __awaiter(this, void 0, void 0, function* () { + logger.debug('PakeAppOptions', options); + const { name } = options; + yield mergeTauriConfig(url, options, tauriConf); + yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`); + const language = tauriConf.tauri.bundle.windows.wix.language[0]; + const arch = process.arch; + const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`; + const appPath = this.getBuildedAppPath(npmDirectory, msiName); + const distPath = path.resolve(`${name}.msi`); + yield fs.copyFile(appPath, distPath); + yield fs.unlink(appPath); + logger.success('Build success!'); + logger.success('You can find the app installer in', distPath); + }); + } + getBuildedAppPath(npmDirectory, dmgName) { + return path.join(npmDirectory, 'src-tauri/target/release/bundle/msi', dmgName); + } +} + +class BuilderFactory { + static create() { + console.log("now platform is ", process.platform); + if (IS_MAC) { + return new MacBuilder(); + } + if (IS_WIN) { + return new WinBuilder(); + } + throw new Error('The current system does not support!!'); + } +} + +var name = "pake-cli"; +var version = "0.0.6"; +var description = "🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App 🤱🏻 A simple way to make any web page a desktop application using Rust."; +var bin = { + pake: "./cli.js" +}; +var repository = { + type: "git", + url: "https://github.com/tw93/pake.git" +}; +var author = { + name: "Tw93", + email: "tw93@qq.com" +}; +var files = [ + "dist", + "src-tauri", + "cli.js", + "pake-default.icns" +]; +var scripts = { + start: "npm run dev", + dev: "npm run tauri dev", + "dev:debug": "npm run tauri dev -- --features devtools", + "build:release": "npm run tauri build --release", + "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", + "build:all-windows": ".\\script\\build.bat", + tauri: "tauri", + cli: "rollup -c rollup.config.js --watch", + "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", + "cli:publish": "npm run cli:build && npm publish" +}; +var type = "module"; +var exports = "./dist/pake.js"; +var license = "MIT"; +var dependencies = { + "@tauri-apps/api": "^1.2.0", + "@tauri-apps/cli": "^1.2.1", + axios: "^1.1.3", + chalk: "^5.1.2", + commander: "^9.4.1", + "file-type": "^18.0.0", + "is-url": "^1.2.4", + loglevel: "^1.8.1", + ora: "^6.1.2", + prompts: "^2.4.2", + shelljs: "^0.8.5", + "tmp-promise": "^3.0.3", + "update-notifier": "^6.0.2" +}; +var devDependencies = { + "@rollup/plugin-alias": "^4.0.2", + "@rollup/plugin-commonjs": "^23.0.2", + "@rollup/plugin-json": "^5.0.1", + "@rollup/plugin-terser": "^0.1.0", + "@rollup/plugin-typescript": "^9.0.2", + "@types/is-url": "^1.2.30", + "@types/page-icon": "^0.3.4", + "@types/prompts": "^2.4.1", + "@types/shelljs": "^0.8.11", + "@types/tmp": "^0.2.3", + "@types/update-notifier": "^6.0.1", + "app-root-path": "^3.1.0", + concurrently: "^7.5.0", + "cross-env": "^7.0.3", + rollup: "^3.3.0", + tslib: "^2.4.1", + typescript: "^4.9.3" +}; +var packageJson = { + name: name, + version: version, + description: description, + bin: bin, + repository: repository, + author: author, + files: files, + scripts: scripts, + type: type, + exports: exports, + license: license, + dependencies: dependencies, + devDependencies: devDependencies +}; + +function checkUpdateTips() { + return __awaiter(this, void 0, void 0, function* () { + updateNotifier({ pkg: packageJson }).notify(); + }); +} + +program.version(packageJson.version).description('A cli application can package a web page to desktop application.'); +program + .showHelpAfterError() + .argument('[url]', 'the web url you want to package', validateUrlInput) + .option('--name ', 'application name') + .option('--icon ', 'application icon', DEFAULT_PAKE_OPTIONS.icon) + .option('--height ', 'window height', validateNumberInput, DEFAULT_PAKE_OPTIONS.height) + .option('--width ', 'window width', validateNumberInput, DEFAULT_PAKE_OPTIONS.width) + .option('--no-resizable', 'whether the window can be resizable', DEFAULT_PAKE_OPTIONS.resizable) + .option('--fullscreen', 'makes the packaged app start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen) + .option('--transparent', 'transparent title bar', DEFAULT_PAKE_OPTIONS.transparent) + .option('--debug', 'debug', DEFAULT_PAKE_OPTIONS.transparent) + .action((url, options) => __awaiter(void 0, void 0, void 0, function* () { + checkUpdateTips(); + if (!url) { + // 直接 pake 不需要出现url提示 + program.help(); + } + log.setDefaultLevel('info'); + if (options.debug) { + log.setLevel('debug'); + } + const builder = BuilderFactory.create(); + yield builder.prepare(); + const appOptions = yield handleOptions(options, url); + builder.build(url, appOptions); +})); +program.parse(); diff --git a/package.json b/package.json index 2e1d2b0..02ebe3d 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,7 @@ "start": "npm run dev", "dev": "npm run tauri dev", "dev:debug": "npm run tauri dev -- --features devtools", - "build": "npm run tauri build -- --target universal-apple-darwin", - "build:windows": "npm run tauri build -- --target x86_64-pc-windows-msvc", - "build:linux": "npm run tauri build --release", + "build:release": "npm run tauri build --release", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", "build:all-windows": ".\\script\\build.bat", "tauri": "tauri", @@ -68,6 +66,6 @@ "cross-env": "^7.0.3", "rollup": "^3.3.0", "tslib": "^2.4.1", - "typescript": "^4.8.4" + "typescript": "^4.9.3" } } diff --git a/script/build.bat b/script/build.bat index 1137d95..c510081 100644 --- a/script/build.bat +++ b/script/build.bat @@ -31,8 +31,14 @@ set old_title=WeRead set old_zh_name=微信阅读 set old_url=https://weread.qq.com/ +:: set init name, we will recovery code to init when build finish. +set init_name=%old_name% +set init_title=%old_title% +set init_zh_name=%old_zh_name% +set init_url=%old_url% + :: for windows, we need replace package name to title -.\script\sd.exe "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri\tauri.conf.json +:: .\script\sd.exe "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri\tauri.conf.json for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do ( setlocal enabledelayedexpansion @@ -47,10 +53,10 @@ for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do ( .\script\sd.exe !old_url! !url! src-tauri\tauri.conf.json ::replace pacakge name .\script\sd.exe !old_title! !title! src-tauri\tauri.conf.json - .\script\sd.exe !old_name! !name! src-tauri\tauri.conf.json + .\script\sd.exe !old_name! !name! src-tauri\tauri.windows.conf.json echo update ico with 32x32 pictue .\script\sd.exe !old_name! !name! src-tauri\src\main.rs - ::copy src-tauri\png\!name!_32.ico src-tauri\icons\icon.ico + echo. ::update package info set old_zh_name=!name_zh! @@ -86,3 +92,9 @@ for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do ( :: for windows, we need replace package name to lower again :: .\script\sd.exe "\"productName\": \"WeRead\"" "\"productName\": \"weread\"" src-tauri\tauri.conf.json echo "output dir is output\windows" + +::recovery code +.\script\sd.exe %url% %init_url% src-tauri\tauri.conf.json +.\script\sd.exe %title% %init_title% src-tauri\tauri.conf.json +.\script\sd.exe %name% %init_name% src-tauri\tauri.windows.conf.json +.\script\sd.exe %name% %init_name% src-tauri\src\main.rs diff --git a/script/build.sh b/script/build.sh index 95e5ca9..36f71ad 100755 --- a/script/build.sh +++ b/script/build.sh @@ -34,6 +34,13 @@ old_zh_name="微信阅读" old_url="https://weread.qq.com/" package_prefix="com-tw93" + +# set init name, we will recovery code to init when build finish. +export init_name=${old_name} +export init_title=${old_title} +export init_zh_name=${old_zh_name} +export init_url=${old_url} + if [[ "$OSTYPE" =~ ^linux ]]; then echo "===============" echo "Build for Linux" @@ -73,6 +80,7 @@ do # for apple, need replace title if [[ "$OSTYPE" =~ ^darwin ]]; then + $sd "${old_name}" "${package_name}" src-tauri/tauri.macos.conf.json $sd "${old_title}" "${package_title}" src-tauri/tauri.conf.json fi @@ -80,6 +88,7 @@ do # cp "src-tauri/png/${package_name}_32.ico" "src-tauri/icons/icon.ico" if [[ "$OSTYPE" =~ ^linux ]]; then + $sd "${old_name}" "${package_name}" src-tauri/tauri.linux.conf.json echo "update desktop" old_desktop="src-tauri/assets/${package_prefix}-${old_name}.desktop" new_desktop="src-tauri/assets/${package_prefix}-${package_name}.desktop" @@ -115,12 +124,20 @@ done echo "build all package success!" if [[ "$OSTYPE" =~ ^linux ]]; then -$sd "\"productName\": \"com-tw93-weread\"" "\"productName\": \"WeRead\"" src-tauri/tauri.conf.json + # recovery linux code + $sd "\"productName\": \"com-tw93-weread\"" "\"productName\": \"WeRead\"" src-tauri/tauri.conf.json + $sd "${package_name}" "${init_name}" src-tauri/tauri.linux.conf.json echo "result file in output/linux" fi if [[ "$OSTYPE" =~ ^darwin ]]; then - # replace again + # recovery macos code $sd "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri/tauri.conf.json + $sd "${package_name}" "${init_name}" src-tauri/tauri.macos.conf.json echo "result file in output/macos" fi + +# recovery code +$sd "${url}" "${init_url}" src-tauri/tauri.conf.json +$sd ${package_name}" "${init_name}" src-tauri/tauri.conf.json +$sd ${package_name}" "${init_name}" src-tauri/src/main.rs \ No newline at end of file diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 9cc86ca..2aa29d5 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -76,22 +76,6 @@ dependencies = [ "system-deps 6.0.3", ] -[[package]] -name = "attohttpc" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcf00bc6d5abb29b5f97e3c61a90b6d3caa12f3faf897d4a3e3607c050a35a7" -dependencies = [ - "flate2", - "http", - "log", - "native-tls", - "serde", - "serde_json", - "serde_urlencoded", - "url", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -514,17 +498,6 @@ dependencies = [ "syn", ] -[[package]] -name = "dbus" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f8bcdd56d2e5c4ed26a529c5a9029f5db8290d433497506f958eae3be148eb6" -dependencies = [ - "libc", - "libdbus-sys", - "winapi", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -660,7 +633,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -1382,15 +1355,6 @@ version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" -[[package]] -name = "libdbus-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c185b5b7ad900923ef3a8ff594083d4d9b5aea80bb4f32b8342363138c0d456b" -dependencies = [ - "pkg-config", -] - [[package]] name = "line-wrap" version = "0.1.1" @@ -1440,19 +1404,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" -[[package]] -name = "mac-notification-sys" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e72d50edb17756489e79d52eb146927bec8eba9dd48faadf9ef08bca3791ad5" -dependencies = [ - "cc", - "dirs-next", - "objc-foundation", - "objc_id", - "time", -] - [[package]] name = "malloc_buf" version = "0.0.6" @@ -1533,24 +1484,6 @@ dependencies = [ "getrandom 0.2.8", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "ndk" version = "0.6.0" @@ -1591,17 +1524,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -[[package]] -name = "notify-rust" -version = "4.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368e89ea58df747ce88be669ae44e79783c1d30bfd540ad0fc520b3f41f0b3b0" -dependencies = [ - "dbus", - "mac-notification-sys", - "tauri-winrt-notification", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1683,17 +1605,6 @@ dependencies = [ "objc_exception", ] -[[package]] -name = "objc-foundation" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" -dependencies = [ - "block", - "objc", - "objc_id", -] - [[package]] name = "objc_exception" version = "0.1.2" @@ -1718,82 +1629,6 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" -[[package]] -name = "open" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8" -dependencies = [ - "pathdiff", - "windows-sys 0.42.0", -] - -[[package]] -name = "openssl" -version = "0.10.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "os_info" -version = "3.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4750134fb6a5d49afc80777394ad5d95b04bc12068c6abb92fae8f43817270f" -dependencies = [ - "log", - "serde", - "winapi", -] - -[[package]] -name = "os_pipe" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a252f1f8c11e84b3ab59d7a488e48e4478a93937e027076638c49536204639" -dependencies = [ - "libc", - "windows-sys 0.42.0", -] - [[package]] name = "overload" version = "0.1.1" @@ -1845,7 +1680,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -1854,12 +1689,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" -[[package]] -name = "pathdiff" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" - [[package]] name = "percent-encoding" version = "2.2.0" @@ -2100,15 +1929,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "quick-xml" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bafc859c6815fbaffbbbf4229ecb767ac913fecb27f9ad4343662e9ef099ea" -dependencies = [ - "memchr", -] - [[package]] name = "quote" version = "1.0.21" @@ -2286,30 +2106,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rfd" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0149778bd99b6959285b0933288206090c50e2327f47a9c463bfdbf45c8823ea" -dependencies = [ - "block", - "dispatch", - "glib-sys", - "gobject-sys", - "gtk-sys", - "js-sys", - "lazy_static", - "log", - "objc", - "objc-foundation", - "objc_id", - "raw-window-handle", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows 0.37.0", -] - [[package]] name = "rustc_version" version = "0.3.3" @@ -2355,16 +2151,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" -dependencies = [ - "lazy_static", - "windows-sys 0.36.1", -] - [[package]] name = "scoped-tls" version = "1.0.1" @@ -2383,29 +2169,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "security-framework" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "selectors" version = "0.22.0" @@ -2495,18 +2258,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa 1.0.4", - "ryu", - "serde", -] - [[package]] name = "serde_with" version = "1.14.0" @@ -2581,16 +2332,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shared_child" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d94659ad3c2137fef23ae75b03d5241d633f8acded53d672decfa0e6e0caef" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "siphasher" version = "0.3.10" @@ -2696,27 +2437,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "strum" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7ac893c7d471c8a21f31cfe213ec4f6d9afeed25537c772e08ef3f005f8729e" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "339f799d8b549e3744c7ac7feb216383e4005d94bdb22561b3ab8f3b808ae9fb" -dependencies = [ - "heck 0.3.3", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "syn" version = "1.0.104" @@ -2864,7 +2584,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18203448b9d4dcad55607eafeda6dc7fe135848e5f567cd8bdade6cafd8b1a85" dependencies = [ "anyhow", - "attohttpc", "cocoa", "dirs-next", "embed_plist", @@ -2877,23 +2596,16 @@ dependencies = [ "heck 0.4.0", "http", "ignore", - "notify-rust", "objc", "once_cell", - "open", - "os_info", - "os_pipe", "percent-encoding", "rand 0.8.5", "raw-window-handle", - "regex", - "rfd", "semver 1.0.14", "serde", "serde_json", "serde_repr", "serialize-to-javascript", - "shared_child", "state", "tar", "tauri-macros", @@ -2940,7 +2652,6 @@ dependencies = [ "png", "proc-macro2", "quote", - "regex", "semver 1.0.14", "serde", "serde_json", @@ -3034,17 +2745,6 @@ dependencies = [ "windows 0.39.0", ] -[[package]] -name = "tauri-winrt-notification" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58de036c4d2e20717024de2a3c4bf56c301f07b21bc8ef9b57189fce06f1f3b" -dependencies = [ - "quick-xml", - "strum", - "windows 0.39.0", -] - [[package]] name = "tempfile" version = "3.3.0" @@ -3338,12 +3038,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version-compare" version = "0.0.11" @@ -3410,18 +3104,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.83" @@ -3618,19 +3300,6 @@ dependencies = [ "windows_x86_64_msvc 0.32.0", ] -[[package]] -name = "windows" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647" -dependencies = [ - "windows_aarch64_msvc 0.37.0", - "windows_i686_gnu 0.37.0", - "windows_i686_msvc 0.37.0", - "windows_x86_64_gnu 0.37.0", - "windows_x86_64_msvc 0.37.0", -] - [[package]] name = "windows" version = "0.39.0" @@ -3671,19 +3340,6 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278" -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - [[package]] name = "windows-sys" version = "0.42.0" @@ -3717,18 +3373,6 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" - [[package]] name = "windows_aarch64_msvc" version = "0.39.0" @@ -3747,18 +3391,6 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - -[[package]] -name = "windows_i686_gnu" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" - [[package]] name = "windows_i686_gnu" version = "0.39.0" @@ -3777,18 +3409,6 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_i686_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" - [[package]] name = "windows_i686_msvc" version = "0.39.0" @@ -3807,18 +3427,6 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" - [[package]] name = "windows_x86_64_gnu" version = "0.39.0" @@ -3843,18 +3451,6 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" - [[package]] name = "windows_x86_64_msvc" version = "0.39.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b64ef54..f9a5cb4 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.2.1", features = [] } [dependencies] serde_json = "1.0.88" serde = { version = "1.0.147", features = ["derive"] } -tauri = { version = "1.2.1", features = ["api-all"] } +tauri = { version = "1.2.1", features = [] } image = "0.24.5" tauri-utils = "1.2.1" webbrowser = "0.8.2" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 02499b7..298cff6 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -14,56 +14,6 @@ "resizable": true } ], - "allowlist": { - "all": true - }, - "bundle": { - "icon": [ - "icons/weread.icns", - "png/weread_256.ico", - "png/weread_32.ico", - "png/weread_512.png" - ], - "identifier": "com.tw93.weread", - "active": true, - "category": "DeveloperTool", - "copyright": "", - "deb": { - "depends": [ - "libwebkit2gtk-4.0-dev", - "build-essential", - "curl", - "wget", - "libssl-dev", - "libgtk-3-dev", - "libayatana-appindicator3-dev", - "librsvg2-dev" - ], - "files": { - "/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop" - } - }, - "externalBin": [], - "longDescription": "", - "macOS": { - "entitlements": null, - "exceptionDomain": "", - "frameworks": [], - "providerShortName": null, - "signingIdentity": null - }, - "resources": ["png/weread_32.ico"], - "shortDescription": "", - "targets": ["deb", "msi", "dmg"], - "windows": { - "certificateThumbprint": null, - "digestAlgorithm": "sha256", - "timestampUrl": "", - "wix": { - "language": ["en-US"] - } - } - }, "security": { "csp": null }, diff --git a/src-tauri/tauri.conf.json.bak b/src-tauri/tauri.conf.json.bak new file mode 100644 index 0000000..298cff6 --- /dev/null +++ b/src-tauri/tauri.conf.json.bak @@ -0,0 +1,30 @@ +{ + "package": { + "productName": "WeRead", + "version": "1.0.0" + }, + "tauri": { + "windows": [ + { + "url": "https://weread.qq.com/", + "transparent": true, + "fullscreen": false, + "width": 1200, + "height": 728, + "resizable": true + } + ], + "security": { + "csp": null + }, + "updater": { + "active": false + } + }, + "build": { + "devPath": "../dist", + "distDir": "../dist", + "beforeBuildCommand": "", + "beforeDevCommand": "" + } +} diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json new file mode 100644 index 0000000..3235abd --- /dev/null +++ b/src-tauri/tauri.linux.conf.json @@ -0,0 +1,34 @@ +{ + "tauri": { + "bundle": { + "icon": [ + "png/weread_256.ico", + "png/weread_512.png" + ], + "identifier": "com.tw93.weread", + "active": true, + "category": "DeveloperTool", + "copyright": "", + "deb": { + "depends": [ + "libwebkit2gtk-4.0-dev", + "build-essential", + "curl", + "wget", + "libssl-dev", + "libgtk-3-dev", + "libayatana-appindicator3-dev", + "librsvg2-dev" + ], + "files": { + "/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop" + } + }, + "externalBin": [], + "longDescription": "", + "resources": [], + "shortDescription": "", + "targets": ["deb"] + } + } +} diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.json new file mode 100644 index 0000000..5b09612 --- /dev/null +++ b/src-tauri/tauri.macos.conf.json @@ -0,0 +1,25 @@ +{ + "tauri": { + "bundle": { + "icon": [ + "icons/weread.icns" + ], + "identifier": "com.tw93.weread", + "active": true, + "category": "DeveloperTool", + "copyright": "", + "externalBin": [], + "longDescription": "", + "macOS": { + "entitlements": null, + "exceptionDomain": "", + "frameworks": [], + "providerShortName": null, + "signingIdentity": null + }, + "resources": [], + "shortDescription": "", + "targets": ["dmg"] + } + } +} diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json new file mode 100644 index 0000000..357f830 --- /dev/null +++ b/src-tauri/tauri.windows.conf.json @@ -0,0 +1,27 @@ +{ + "tauri": { + "bundle": { + "icon": [ + "png/weread_256.ico", + "png/weread_32.ico" + ], + "identifier": "com.tw93.weread", + "active": true, + "category": "DeveloperTool", + "copyright": "", + "externalBin": [], + "longDescription": "", + "resources": ["png/weread_32.ico"], + "shortDescription": "", + "targets": ["msi"], + "windows": { + "certificateThumbprint": null, + "digestAlgorithm": "sha256", + "timestampUrl": "", + "wix": { + "language": ["en-US"] + } + } + } + } +}