From d48a628693117278953369af9f21546efa9d7bd5 Mon Sep 17 00:00:00 2001 From: xiangyu <3170102889@zju.edu.cn> Date: Wed, 11 Jan 2023 12:56:29 +0800 Subject: [PATCH] update: scripts --- .vscode/launch.json | 7 +++++++ package.json | 10 ++++++---- scripts/build.js | 13 +------------ scripts/restart.js | 8 -------- 4 files changed, 14 insertions(+), 24 deletions(-) delete mode 100644 scripts/restart.js diff --git a/.vscode/launch.json b/.vscode/launch.json index 393360c..1b6e48b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,6 +10,13 @@ "name": "Restart", "runtimeExecutable": "npm", "runtimeArgs": ["run", "restart"], + }, + { + "type": "node", + "request": "launch", + "name": "Restart in Prod Mode", + "runtimeExecutable": "npm", + "runtimeArgs": ["run", "restart-prod"], } ] } \ No newline at end of file diff --git a/package.json b/package.json index 7b24c54..6693d65 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,13 @@ "main": "src/index.ts", "scripts": { "build-dev": "cross-env NODE_ENV=development node scripts/build.js", - "build": "cross-env NODE_ENV=production node scripts/build.js", + "build-prod": "cross-env NODE_ENV=production node scripts/build.js", + "build": "npm run build-prod", "start": "node scripts/start.js", "stop": "node scripts/stop.js", - "prerestart": "npm run build-dev", - "restart": "node scripts/restart.js", + "restart-dev": "npm run build-dev && npm run stop && npm run start", + "restart-prod": "npm run build-prod && npm run stop && npm run start", + "restart": "npm run restart-dev", "release": "release-it", "test": "echo \"Error: no test specified\" && exit 1" }, @@ -31,7 +33,7 @@ }, "homepage": "https://github.com/windingwind/zotero-addon-template#readme", "dependencies": { - "zotero-plugin-toolkit": "^1.0.1" + "zotero-plugin-toolkit": "^1.0.3" }, "devDependencies": { "@types/node": "^18.11.17", diff --git a/scripts/build.js b/scripts/build.js index 7344c1c..30792c9 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -104,8 +104,8 @@ async function main() { __env__: `"${process.env.NODE_ENV}"`, }, bundle: true, - // Entry should be the same as addon/chrome/content/overlay.xul outfile: path.join(buildDir, "addon/chrome/content/scripts/index.js"), + // Don't turn minify on // minify: true, }) .catch(() => process.exit(1)); @@ -161,17 +161,6 @@ async function main() { ) ); - // _ = replace.sync({ - // files: [path.join(buildDir, "addon/chrome/content/scripts/index.js")], - // from: [/__env__/g] - // }); - // console.log( - // "[Build] Run replace in ", - // _.filter((f) => f.hasChanged).map( - // (f) => `${f.file} : ${f.numReplacements} / ${f.numMatches}` - // ) - // ); - console.log("[Build] Replace OK"); console.log("[Build] Addon prepare OK"); diff --git a/scripts/restart.js b/scripts/restart.js deleted file mode 100644 index be1fe1e..0000000 --- a/scripts/restart.js +++ /dev/null @@ -1,8 +0,0 @@ -const { execSync } = require("child_process"); -const { killZotero, startZotero } = require("./zotero-cmd.json"); - -try { - execSync(killZotero); -} catch (e) {} - -execSync(startZotero);