Compare commits
8 Commits
2c40b78cce
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c399b938df | |||
| 189ffd55d2 | |||
| 4e8ecce090 | |||
| c14dbeccda | |||
| 869474e8e6 | |||
| aba37f05ee | |||
| 05fa927fd3 | |||
| d4ce4252f6 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
package.json
|
||||||
|
package-lock.json
|
||||||
@@ -1,16 +1,49 @@
|
|||||||
from os import system
|
from os import system, mkdir
|
||||||
from re import findall, match, search
|
from re import findall
|
||||||
from sys import argv
|
from sys import argv
|
||||||
|
import requests
|
||||||
|
|
||||||
def npm_create_package_lock_file(package):
|
def npm_create_package_lock_file(package):
|
||||||
system("npm i --package-lock-only " + package)
|
system("npm i --package-lock-only " + package)
|
||||||
|
|
||||||
|
|
||||||
def get_all_urls_packages():
|
def get_all_urls_packages():
|
||||||
return findall("https://.+.tgz", open("package-lock.json", "rt").read())
|
with open("package-lock.json", "rt") as package_lock_file:
|
||||||
|
content = package_lock_file.read()
|
||||||
|
return list(dict.fromkeys(findall("https://.+.tgz", content)))
|
||||||
|
|
||||||
|
|
||||||
|
def download_npm_package(url:str, dir="npm-packages"):
|
||||||
|
try:
|
||||||
|
mkdir(dir)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
with open(dir + "/" + url.split("/")[-1], "wb") as npm_package_file:
|
||||||
|
npm_package_file.write(requests.get(url))
|
||||||
|
|
||||||
|
|
||||||
|
def download_all_package():
|
||||||
|
packages_urls = get_all_urls_packages()
|
||||||
|
for package_url in packages_urls:
|
||||||
|
download_npm_package(package_url, "npm-packages")
|
||||||
|
|
||||||
|
def upload_package(nexus_host, repository, package_file):
|
||||||
|
if nexus_host[-1] != "/":
|
||||||
|
nexus_host += "/"
|
||||||
|
res = requests.post(
|
||||||
|
nexus_host + "service/rest/v1/components?repository=" + repository,
|
||||||
|
headers={
|
||||||
|
"accept": "application/json",
|
||||||
|
"Content-Type": "multipart/form-data"
|
||||||
|
},
|
||||||
|
files={
|
||||||
|
"npm.asset": open(package_file, "rb")
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def publish_all_packages():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user