🐛 修复构建bug

This commit is contained in:
muwoo 2021-12-13 18:00:51 +08:00
parent 6f9830a181
commit a9538f5d86
14 changed files with 242 additions and 20 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
.DS_Store
node_modules
/dist
/build
# local env files

175
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "rubick2",
"version": "0.1.0",
"name": "rubick",
"version": "2.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -6209,6 +6209,11 @@
}
}
},
"default-shell": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/default-shell/-/default-shell-2.2.0.tgz",
"integrity": "sha512-sPpMZcVhRQ0nEMDtuMJ+RtCxt7iHPAMBU+I4tAlo5dU1sjRpNax0crj6nR3qKpvVnckaQ9U38enXcwW9nZJeCw=="
},
"defaults": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz",
@ -7553,6 +7558,65 @@
"safe-buffer": "^5.1.1"
}
},
"execa": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-6.0.0.tgz",
"integrity": "sha512-m4wU9j4Z9nXXoqT8RSfl28JSwmMNLFF69OON8H/lL3NeU0tNpGz313bcOfYoBBHokB0dC2tMl3VUcKgHELhL2Q==",
"requires": {
"cross-spawn": "^7.0.3",
"get-stream": "^6.0.1",
"human-signals": "^3.0.1",
"is-stream": "^3.0.0",
"merge-stream": "^2.0.0",
"npm-run-path": "^5.0.1",
"onetime": "^6.0.0",
"signal-exit": "^3.0.5",
"strip-final-newline": "^3.0.0"
},
"dependencies": {
"human-signals": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz",
"integrity": "sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ=="
},
"is-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz",
"integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA=="
},
"mimic-fn": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz",
"integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw=="
},
"npm-run-path": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.0.1.tgz",
"integrity": "sha512-ybBJQUSyFwEEhqO2lXmyKOl9ucHtyZBWVM0h0FiMfT/+WKxCUZFa95qAR2X3w/w6oigN3B0b2UNHZbD+kdfD5w==",
"requires": {
"path-key": "^4.0.0"
}
},
"onetime": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz",
"integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==",
"requires": {
"mimic-fn": "^4.0.0"
}
},
"path-key": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",
"integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ=="
},
"strip-final-newline": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz",
"integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw=="
}
}
},
"expand-brackets": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz",
@ -8028,6 +8092,14 @@
"path-exists": "^4.0.0"
}
},
"fix-path": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/fix-path/-/fix-path-4.0.0.tgz",
"integrity": "sha512-g31GX207Tt+psI53ZSaB1egprYbEN0ZYl90aKcO22A2LmCNnFsSq3b5YpoKp3E/QEiWByTXGJOkFQG4S07Bc1A==",
"requires": {
"shell-path": "^3.0.0"
}
},
"flat-cache": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz",
@ -8452,6 +8524,11 @@
"integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==",
"dev": true
},
"get-stream": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
"integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg=="
},
"get-symbol-description": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz",
@ -10886,8 +10963,7 @@
"merge-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
"dev": true
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="
},
"merge2": {
"version": "1.4.1",
@ -14072,6 +14148,91 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
"shell-env": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/shell-env/-/shell-env-4.0.1.tgz",
"integrity": "sha512-w3oeZ9qg/P6Lu6qqwavvMnB/bwfsz67gPB3WXmLd/n6zuh7TWQZtGa3iMEdmua0kj8rivkwl+vUjgLWlqZOMPw==",
"requires": {
"default-shell": "^2.0.0",
"execa": "^5.1.1",
"strip-ansi": "^7.0.1"
},
"dependencies": {
"ansi-regex": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz",
"integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA=="
},
"execa": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz",
"integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==",
"requires": {
"cross-spawn": "^7.0.3",
"get-stream": "^6.0.0",
"human-signals": "^2.1.0",
"is-stream": "^2.0.0",
"merge-stream": "^2.0.0",
"npm-run-path": "^4.0.1",
"onetime": "^5.1.2",
"signal-exit": "^3.0.3",
"strip-final-newline": "^2.0.0"
}
},
"human-signals": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz",
"integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="
},
"is-stream": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
"integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="
},
"mimic-fn": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg=="
},
"npm-run-path": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
"integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==",
"requires": {
"path-key": "^3.0.0"
}
},
"onetime": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz",
"integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==",
"requires": {
"mimic-fn": "^2.1.0"
}
},
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="
},
"strip-ansi": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz",
"integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==",
"requires": {
"ansi-regex": "^6.0.1"
}
}
}
},
"shell-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shell-path/-/shell-path-3.0.0.tgz",
"integrity": "sha512-HNIZ+W/3P0JuVTV03xjGqYKt3e3h0/Z4AH8TQWeth1LBtCusSjICgkdNdb3VZr6mI7ijE2AiFFpgkVMNKsALeQ==",
"requires": {
"shell-env": "^4.0.0"
}
},
"shell-quote": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz",
@ -14092,8 +14253,7 @@
"signal-exit": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz",
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==",
"dev": true
"integrity": "sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ=="
},
"simple-swizzle": {
"version": "0.2.2",
@ -14690,8 +14850,7 @@
"strip-final-newline": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==",
"dev": true
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA=="
},
"strip-indent": {
"version": "2.0.0",

View File

@ -18,6 +18,7 @@
"ant-design-vue": "^2.2.8",
"core-js": "^3.6.5",
"cross-spawn": "^7.0.3",
"fix-path": "^4.0.0",
"get-mac-apps": "^1.0.2",
"got": "^11.8.3",
"libnpmsearch": "^3.1.2",

BIN
public/icons/256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/icons/icon.icns Normal file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,4 +1,6 @@
import getMacApps from "get-mac-apps";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import getMacApps from "./get-mac-app";
import fs from "fs";
import path from "path";
@ -84,7 +86,7 @@ async function getAppIcon(
}
export default async (nativeImage: any) => {
let apps = await getMacApps.getApps();
let apps: any = await getMacApps.getApps();
apps = apps.filter((app: any) => {
const extname = path.extname(app.path);

View File

@ -0,0 +1,43 @@
import { spawn } from "child_process";
import plist from "plist";
export default function getApps(resolve, reject, filterByAppName = false) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
let resultBuffer = new Buffer.from([]);
const profileInstalledApps = spawn("/usr/sbin/system_profiler", [
"-xml",
"-detailLevel",
"mini",
"SPApplicationsDataType"
]);
profileInstalledApps.stdout.on("data", chunckBuffer => {
resultBuffer = Buffer.concat([resultBuffer, chunckBuffer]);
});
profileInstalledApps.on("exit", exitCode => {
if (exitCode !== 0) {
reject([]);
return;
}
try {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const [installedApps] = plist.parse(resultBuffer.toString());
if (!filterByAppName) return resolve(installedApps._items);
return resolve(
installedApps._items.filter(apps => apps._name === filterByAppName)
.length !== 0
);
} catch (err) {
reject(err);
}
});
profileInstalledApps.on("error", err => {
reject(err);
});
};

View File

@ -0,0 +1,10 @@
import getApps from "./getApps";
export default {
getApps: () => {
return new Promise((resolve, reject) => getApps(resolve, reject));
},
isInstalled: (appName) => {
return new Promise((resolve, reject) => getApps(resolve, reject, appName));
},
};

View File

@ -6,8 +6,11 @@ import fs from "fs-extra";
import search, { Result } from "libnpmsearch";
import path from "path";
import got from "got";
import fixPath from "fix-path";
import spwan from "cross-spawn";
import spawn from "cross-spawn";
fixPath();
/**
*
@ -146,7 +149,7 @@ class AdapterHandler {
.concat("--save");
if (cmd !== "uninstall")
args = args.concat(`--registry=${this.registry}`);
const npm = spwan("npm", args, {
const npm = spawn("npm", args, {
cwd: this.baseDir,
});

View File

@ -8,11 +8,14 @@ function createTray(window: BrowserWindow): Promise<Tray> {
return new Promise((resolve) => {
let icon;
if (commonConst.macOS()) {
icon = "./icon@3x.png";
icon = "./icons/icon@3x.png";
} else if (commonConst.windows()) {
icon = parseInt(os.release()) < 10 ? "./icon@2x.png" : "./icon.ico";
icon =
parseInt(os.release()) < 10
? "./icons/icon@2x.png"
: "./icons/icon.ico";
} else {
icon = "icon@2x.png";
icon = "./icons/icon@2x.png";
}
const appIcon = new Tray(path.join(__static, icon));
const contextMenu = Menu.buildFromTemplate([

View File

@ -2,6 +2,7 @@
const path = require("path");
module.exports = {
transpileDependencies: ["fix-path"],
configureWebpack: {
resolve: {
alias: {
@ -30,7 +31,7 @@ module.exports = {
directories: {
output: "build",
},
files: ["dist/electron/**/*"],
// files: ["dist_electron/**/*"],
dmg: {
contents: [
{
@ -47,14 +48,14 @@ module.exports = {
],
},
mac: {
icon: "build/icons/icon.icns",
icon: "public/icons/icon.icns",
target: "pkg",
extendInfo: {
LSUIElement: 1,
},
},
win: {
icon: "build/icons/icon.ico",
icon: "public/icons/icon.ico",
target: "nsis",
},
nsis: {
@ -62,7 +63,7 @@ module.exports = {
allowToChangeInstallationDirectory: true,
},
linux: {
icon: "build/icons/",
icon: "public/icons/",
publish: ["github"],
},
},