|
| 1 | +# Copyright (c) 2023, Terwer . All rights reserved. |
| 2 | +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 3 | +# |
| 4 | +# This code is free software; you can redistribute it and/or modify it |
| 5 | +# under the terms of the GNU General Public License version 2 only, as |
| 6 | +# published by the Free Software Foundation. Terwer designates this |
| 7 | +# particular file as subject to the "Classpath" exception as provided |
| 8 | +# by Terwer in the LICENSE file that accompanied this code. |
| 9 | +# |
| 10 | +# This code is distributed in the hope that it will be useful, but WITHOUT |
| 11 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | +# version 2 for more details (a copy is included in the LICENSE file that |
| 14 | +# accompanied this code). |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License version |
| 17 | +# 2 along with this work; if not, write to the Free Software Foundation, |
| 18 | +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | +# |
| 20 | +# Please contact Terwer, Shenzhen, Guangdong, China, [email protected] |
| 21 | +# or visit www.terwer.space if you need additional information or have any |
| 22 | +# questions. |
| 23 | + |
| 24 | +import os |
| 25 | + |
| 26 | +import scriptutils |
| 27 | + |
| 28 | +if __name__ == "__main__": |
| 29 | + # Switch to the working directory. |
| 30 | + scriptutils.switch_workdir() |
| 31 | + |
| 32 | + # Get the current working directory. |
| 33 | + cwd = scriptutils.get_workdir() |
| 34 | + |
| 35 | + # 获取当前工作目录 |
| 36 | + print(os.getcwd()) |
| 37 | + |
| 38 | + os.system("pnpm pluginBuild && pnpm siyuanBuild") |
| 39 | + dist_folder = "./dist" |
| 40 | + data = scriptutils.read_json_file(cwd + "package.json") |
| 41 | + v = data["version"] |
| 42 | + |
| 43 | + src_folder = dist_folder |
| 44 | + tmp_folder_name = "./siyuan-plugin-publisher" |
| 45 | + build_zip_path = "./build" |
| 46 | + build_zip_name = "siyuan-plugin-publisher-" + v + ".zip" |
| 47 | + |
| 48 | + try: |
| 49 | + # 压缩dist为zip |
| 50 | + scriptutils.zip_folder(src_folder, tmp_folder_name, build_zip_path, build_zip_name) |
| 51 | + scriptutils.cp_file(os.path.join(build_zip_path, build_zip_name), os.path.join(build_zip_path, "package.zip")) |
| 52 | + except Exception as e: |
| 53 | + print(f"打包错误,{str(e)}") |
| 54 | + print("插件打包完毕.") |
0 commit comments