优化electron脚本命令
This commit is contained in:
parent
a7ac2cee13
commit
26d9e63e83
18
.github/workflows/electron.yml
vendored
18
.github/workflows/electron.yml
vendored
@ -14,20 +14,20 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build Changelog
|
||||
id: github_release
|
||||
uses: mikepenz/release-changelog-builder-action@v1
|
||||
- name: Create changelog text
|
||||
id: changelog
|
||||
uses: loopwerk/tag-changelog@v1
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
|
||||
- name: Create release
|
||||
uses: actions/create-release@latest
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
|
||||
- name: Create Release
|
||||
uses: actions/create-release@v1
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
body: ${{steps.github_release.outputs.changelog}}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||
body: ${{ steps.changelog.outputs.changes }}
|
||||
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
22
cmd
22
cmd
@ -66,7 +66,6 @@ docker_name() {
|
||||
|
||||
run_compile() {
|
||||
local type=$1
|
||||
local npxcmd=""
|
||||
check_node
|
||||
if [ ! -d "./node_modules" ]; then
|
||||
npm install
|
||||
@ -74,29 +73,38 @@ run_compile() {
|
||||
run_exec php "php bin/run --mode=$type"
|
||||
supervisorctl_restart php
|
||||
#
|
||||
mix -V &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
npxcmd="npx"
|
||||
fi
|
||||
if [ "$type" = "prod" ]; then
|
||||
rm -rf "./public/js/build"
|
||||
$npxcmd mix --production
|
||||
npx mix --production
|
||||
else
|
||||
$npxcmd mix watch --hot
|
||||
npx mix watch --hot
|
||||
fi
|
||||
}
|
||||
|
||||
run_electron() {
|
||||
local argv=$@
|
||||
check_node
|
||||
if [ ! -d "./node_modules" ]; then
|
||||
npm install
|
||||
fi
|
||||
if [ ! -d "./electron/node_modules" ]; then
|
||||
pushd electron
|
||||
npm install
|
||||
popd
|
||||
fi
|
||||
#
|
||||
if [ -d "./electron/dist" ]; then
|
||||
rm -rf "./electron/dist"
|
||||
fi
|
||||
if [ -d "./electron/public" ]; then
|
||||
rm -rf "./electron/public"
|
||||
fi
|
||||
mkdir -p ./electron/public
|
||||
cp ./electron/index.html ./electron/public/index.html
|
||||
#
|
||||
if [ "$argv" != "dev" ]; then
|
||||
npx mix --production -- --env --electron
|
||||
fi
|
||||
node ./electron/build.js $argv
|
||||
}
|
||||
|
||||
|
69
electron/build.js
vendored
69
electron/build.js
vendored
@ -104,19 +104,8 @@ const nativeCachePath = path.resolve(__dirname, ".native");
|
||||
const devloadCachePath = path.resolve(__dirname, ".devload");
|
||||
const platform = ["build-mac", "build-mac-arm", "build-win"];
|
||||
|
||||
// 编译网站
|
||||
function step1() {
|
||||
if (fs.existsSync(electronDir)) {
|
||||
deleteFile(electronDir);
|
||||
}
|
||||
fs.mkdirSync(electronDir);
|
||||
copyFile(path.resolve(__dirname, "index.html"), electronDir + "/index.html")
|
||||
//
|
||||
child_process.spawnSync("mix", ["--production", "--", "--env", "--electron"], {stdio: "inherit"});
|
||||
}
|
||||
|
||||
// 生成配置、编译应用
|
||||
function step2(data, publish) {
|
||||
function step1(data, publish) {
|
||||
let systemInfo = `window.systemInformation = {
|
||||
version: "${config.version}",
|
||||
origin: "./",
|
||||
@ -138,7 +127,7 @@ function step2(data, publish) {
|
||||
}
|
||||
|
||||
// 还原配置
|
||||
function step3() {
|
||||
function step2() {
|
||||
let packageFile = path.resolve(__dirname, "package.json");
|
||||
let packageString = fs.readFileSync(packageFile, 'utf8');
|
||||
packageString = packageString.replace(/"name":\s*"(.*?)"/, `"name": "${config.name}"`);
|
||||
@ -147,7 +136,21 @@ function step3() {
|
||||
fs.writeFileSync(packageFile, packageString, 'utf8');
|
||||
}
|
||||
|
||||
if (["build", "prod"].includes(argv[2])) {
|
||||
if (["dev"].includes(argv[2])) {
|
||||
// 开发模式
|
||||
fs.writeFileSync(devloadCachePath, formatUrl("127.0.0.1:" + env.parsed.APP_PORT), 'utf8');
|
||||
child_process.spawn("npx", ["mix", "watch", "--hot", "--", "--env", "--electron"], {stdio: "inherit"});
|
||||
child_process.spawn("npm", ["run", "start-quiet"], {stdio: "inherit", cwd: "electron"});
|
||||
} else if (platform.includes(argv[2])) {
|
||||
// 自动编译
|
||||
config.app.sites.forEach((data) => {
|
||||
if (data.name && data.id && data.url) {
|
||||
data.platform = argv[2];
|
||||
step1(data, true)
|
||||
}
|
||||
})
|
||||
step2();
|
||||
} else {
|
||||
// 自定义编译
|
||||
const questions = [
|
||||
{
|
||||
@ -187,36 +190,16 @@ if (["build", "prod"].includes(argv[2])) {
|
||||
}
|
||||
];
|
||||
inquirer.prompt(questions).then(answers => {
|
||||
step1();
|
||||
setTimeout(() => {
|
||||
answers.platform.forEach(platform => {
|
||||
step2({
|
||||
"name": config.name,
|
||||
"id": config.app.id,
|
||||
"url": answers.website,
|
||||
"platform": platform
|
||||
}, false)
|
||||
});
|
||||
step3();
|
||||
}, 3000)
|
||||
answers.platform.forEach(platform => {
|
||||
step1({
|
||||
"name": config.name,
|
||||
"id": config.app.id,
|
||||
"url": answers.website,
|
||||
"platform": platform
|
||||
}, false)
|
||||
});
|
||||
step2();
|
||||
});
|
||||
} else if (platform.includes(argv[2])) {
|
||||
// 自动编译
|
||||
step1();
|
||||
setTimeout(() => {
|
||||
config.app.sites.forEach((data) => {
|
||||
if (data.name && data.id && data.url) {
|
||||
data.platform = argv[2];
|
||||
step2(data)
|
||||
}
|
||||
})
|
||||
step3();
|
||||
}, 3000);
|
||||
} else {
|
||||
// 开发模式
|
||||
fs.writeFileSync(devloadCachePath, formatUrl("127.0.0.1:" + env.parsed.APP_PORT), 'utf8');
|
||||
child_process.spawn("mix", ["watch", "--hot", "--", "--env", "--electron"], {stdio: "inherit"});
|
||||
child_process.spawn("npm", ["run", "start-quiet"], {stdio: "inherit", cwd: "electron"});
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
"appId": "com.dootask.task",
|
||||
"artifactName": "${productName}-v${version}-${os}-${arch}.${ext}",
|
||||
"files": [
|
||||
"public",
|
||||
"public/**/*",
|
||||
"main.js",
|
||||
"preload.js"
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user