parent
ba8e431dec
commit
f45b02a156
5 changed files with 91 additions and 47 deletions
5
scripts/.gitignore
vendored
Normal file
5
scripts/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
.venv
|
||||
build
|
||||
dist
|
||||
*.exe
|
||||
*.spec
|
|
@ -1,32 +1,49 @@
|
|||
import os
|
||||
import sys
|
||||
import json
|
||||
from argparse import ArgumentParser
|
||||
|
||||
# 1. Read plugin_dir
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('plugin_dir')
|
||||
args = parser.parse_args()
|
||||
plugin_dir = args.plugin_dir
|
||||
def run():
|
||||
# check path, must be in root folder
|
||||
if not os.path.exists('plugin.json'):
|
||||
os.chdir('..')
|
||||
if not os.path.exists('plugin.json'):
|
||||
print('plugin.json not found, exit')
|
||||
return
|
||||
|
||||
# 2. Read name in plugin.json
|
||||
with open('plugin.json', 'r', encoding='utf-8') as f:
|
||||
content = json.load(f)
|
||||
name = content.get('name')
|
||||
# 1. Read plugin_dir
|
||||
plugin_dir = ''
|
||||
if len(sys.argv) > 1:
|
||||
plugin_dir = sys.argv[1]
|
||||
while not os.path.exists(plugin_dir):
|
||||
plugin_dir = input('Please input the directory of siyuan/data/plugins: ')
|
||||
if plugin_dir == 'exit' or plugin_dir == 'quit' or plugin_dir == 'q':
|
||||
return
|
||||
if not os.path.exists(plugin_dir):
|
||||
print('plugin_dir not found!')
|
||||
continue
|
||||
|
||||
# ...error if name not found
|
||||
if not name or name == '':
|
||||
print('"name" in plugin.json not found, exit')
|
||||
exit()
|
||||
|
||||
dev_dir = os.path.abspath('dev')
|
||||
if not os.path.exists(dev_dir):
|
||||
os.mkdir(dev_dir)
|
||||
# 2. Read name in plugin.json
|
||||
with open('plugin.json', 'r', encoding='utf-8') as f:
|
||||
content = json.load(f)
|
||||
name = content.get('name')
|
||||
|
||||
# 3. Create symlink
|
||||
if not os.path.exists(os.path.join(plugin_dir, name)):
|
||||
link = os.path.join(plugin_dir, name)
|
||||
os.symlink(dev_dir, link)
|
||||
print('Symlink created:', link)
|
||||
else:
|
||||
print('Folder already exists, exit')
|
||||
exit()
|
||||
# ...error if name not found
|
||||
if not name or name == '':
|
||||
print('"name" in plugin.json not found, exit')
|
||||
return
|
||||
|
||||
dev_dir = os.path.abspath('dev')
|
||||
if not os.path.exists(dev_dir):
|
||||
os.mkdir(dev_dir)
|
||||
|
||||
# 3. Create symlink
|
||||
if not os.path.exists(os.path.join(plugin_dir, name)):
|
||||
link = os.path.join(plugin_dir, name)
|
||||
os.symlink(dev_dir, link)
|
||||
print('Symlink created:', link)
|
||||
else:
|
||||
print('Folder already exists, exit')
|
||||
return
|
||||
|
||||
run()
|
||||
os.system('pause')
|
||||
|
|
4
scripts/py2exe.bat
Normal file
4
scripts/py2exe.bat
Normal file
|
@ -0,0 +1,4 @@
|
|||
.venv/Script/activate
|
||||
pyinstaller --noconfirm --onefile --console "./make_dev_link.py"
|
||||
rm ./make_dev_link.exe
|
||||
mv ./dist/make_dev_link.exe .
|
Loading…
Add table
Add a link
Reference in a new issue