-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
34 lines (32 loc) · 952 Bytes
/
Copy pathsetup.py
File metadata and controls
34 lines (32 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
from os import remove
from sys import argv
def setup(name):
with open('package.json', 'r+') as f:
pkg = json.load(f)
pkg["name"] = name
pkg["repository"] = f"https://github.com/mikezzb/{name}.git"
del pkg["scripts"]["bootstrap"]
f.seek(0)
f.truncate()
json.dump(pkg, f, indent=2)
f.write('\n')
with open('example/package.json', 'r+') as f:
pkg = json.load(f)
deps = pkg["dependencies"]
del deps["my-package"]
deps[name] = "file:../lib"
pkg["scripts"]["relink"] = f"yarn link {name}"
f.seek(0)
f.truncate()
json.dump(pkg, f, indent=2)
f.write('\n')
with open('example/src/App.tsx', 'r+') as f:
data = f.read()
data = data.replace('my-package', name)
f.seek(0)
f.truncate()
f.write(data)
name = input('Your package name: ')
setup(name)
remove(argv[0])