mirror of
https://github.com/danbulant/deno_install
synced 2026-06-24 09:12:14 +00:00
parent
b2cc01b571
commit
9a086b54a5
5 changed files with 14 additions and 261 deletions
|
|
@ -1,25 +1,4 @@
|
|||
environment:
|
||||
matrix:
|
||||
- TYPE: powershell
|
||||
- TYPE: python
|
||||
PYTHON_DIR: "C:\\Python27"
|
||||
- TYPE: python
|
||||
PYTHON_DIR: "C:\\Python33"
|
||||
|
||||
build: off
|
||||
|
||||
for:
|
||||
- matrix:
|
||||
only:
|
||||
- TYPE: powershell
|
||||
test_script:
|
||||
- ps: .\install_test.ps1
|
||||
- pwsh install_test.ps1
|
||||
|
||||
- matrix:
|
||||
only:
|
||||
- TYPE: python
|
||||
install:
|
||||
- "%PYTHON_DIR%\\python.exe install.py"
|
||||
test_script:
|
||||
- "%PYTHON_DIR%\\python.exe install_test.py"
|
||||
test_script:
|
||||
- ps: .\install_test.ps1
|
||||
- pwsh install_test.ps1
|
||||
|
|
|
|||
49
.travis.yml
49
.travis.yml
|
|
@ -1,19 +1,6 @@
|
|||
matrix:
|
||||
include:
|
||||
- language: python
|
||||
os:
|
||||
- linux
|
||||
# Travis does not support python on osx yet.
|
||||
# see: https://github.com/travis-ci/travis-ci/issues/2312
|
||||
# - osx
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.3"
|
||||
script:
|
||||
- ./install.py
|
||||
- ./install_test.py
|
||||
|
||||
- language: bash
|
||||
- language: sh
|
||||
os:
|
||||
- linux
|
||||
addons:
|
||||
|
|
@ -22,14 +9,19 @@ matrix:
|
|||
- shellcheck
|
||||
env:
|
||||
- SHFMT_VERSION=2.6.2
|
||||
- PATH=$HOME/bin/:$PATH
|
||||
- PWSH_VERSION=6.1.2
|
||||
- PATH=$HOME/bin/pwsh:$HOME/bin:$PATH
|
||||
before_script:
|
||||
- curl -sSL -o $HOME/bin/shfmt https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64
|
||||
- chmod +x $HOME/bin/shfmt
|
||||
- mkdir -p $HOME/bin/pwsh
|
||||
- curl -sSL -o $HOME/bin/pwsh/pwsh.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/powershell-$PWSH_VERSION-linux-x64.tar.gz
|
||||
- tar -xf $HOME/bin/pwsh/pwsh.tar.gz -C $HOME/bin/pwsh
|
||||
- chmod +x $HOME/bin/pwsh/pwsh
|
||||
script:
|
||||
- ./install_test.sh
|
||||
|
||||
- language: bash
|
||||
- ./install_test.ps1
|
||||
- language: sh
|
||||
os:
|
||||
- osx
|
||||
addons:
|
||||
|
|
@ -37,26 +29,6 @@ matrix:
|
|||
packages:
|
||||
- shellcheck
|
||||
- shfmt
|
||||
script:
|
||||
- ./install_test.sh
|
||||
|
||||
- language: minimal
|
||||
os:
|
||||
- linux
|
||||
env:
|
||||
- PWSH_VERSION=6.1.2
|
||||
- PATH=$HOME/bin/pwsh:$PATH
|
||||
before_script:
|
||||
- mkdir -p $HOME/bin/pwsh
|
||||
- curl -sSL -o $HOME/bin/pwsh/pwsh.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/powershell-$PWSH_VERSION-linux-x64.tar.gz
|
||||
- tar -xf $HOME/bin/pwsh/pwsh.tar.gz -C $HOME/bin/pwsh
|
||||
- chmod +x $HOME/bin/pwsh/pwsh
|
||||
script:
|
||||
- pwsh install_test.ps1
|
||||
|
||||
- language: minimal
|
||||
os:
|
||||
- osx
|
||||
env:
|
||||
- PWSH_VERSION=6.1.2
|
||||
- PATH=$HOME/bin/pwsh:$PATH
|
||||
|
|
@ -66,4 +38,5 @@ matrix:
|
|||
- tar -xf $HOME/bin/pwsh/pwsh.tar.gz -C $HOME/bin/pwsh
|
||||
- chmod +x $HOME/bin/pwsh/pwsh
|
||||
script:
|
||||
- pwsh install_test.ps1
|
||||
- ./install_test.sh
|
||||
- ./install_test.ps1
|
||||
|
|
|
|||
137
install.py
137
install.py
|
|
@ -1,137 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
# TODO(everyone) Keep this script simple and easily auditable.
|
||||
from __future__ import print_function
|
||||
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import zipfile
|
||||
import zlib
|
||||
|
||||
try:
|
||||
from urllib.request import urlopen
|
||||
except ImportError:
|
||||
from urllib2 import urlopen
|
||||
|
||||
DENO_REPO_URL = "https://github.com/denoland/deno"
|
||||
LATEST_RELEASE_URL = DENO_REPO_URL + "/releases/latest"
|
||||
TAG_URL = DENO_REPO_URL + "/releases/tag/"
|
||||
FILENAME_LOOKUP = {
|
||||
"darwin": "deno_osx_x64.gz",
|
||||
"linux": "deno_linux_x64.gz", # python3
|
||||
"linux2": "deno_linux_x64.gz", # python2
|
||||
"win32": "deno_win_x64.zip",
|
||||
"cygwin": "deno_win_x64.zip"
|
||||
}
|
||||
|
||||
|
||||
def release_url(platform, tag):
|
||||
try:
|
||||
filename = FILENAME_LOOKUP[platform]
|
||||
except KeyError:
|
||||
print("Unable to locate appropriate filename for", platform)
|
||||
sys.exit(1)
|
||||
|
||||
url = TAG_URL + tag if tag else LATEST_RELEASE_URL
|
||||
|
||||
try:
|
||||
html = urlopen(url).read().decode('utf-8')
|
||||
except:
|
||||
print("Unable to find release page for", tag)
|
||||
sys.exit(1)
|
||||
|
||||
urls = re.findall(r'href=[\'"]?([^\'" >]+)', html)
|
||||
matching = [u for u in urls if filename in u]
|
||||
|
||||
if len(matching) != 1:
|
||||
print("Unable to find download url for", filename)
|
||||
sys.exit(1)
|
||||
|
||||
return "https://github.com" + matching[0]
|
||||
|
||||
|
||||
def download_with_progress(url):
|
||||
print("Downloading", url)
|
||||
|
||||
remote_file = urlopen(url)
|
||||
total_size = int(remote_file.headers['Content-Length'].strip())
|
||||
|
||||
data = []
|
||||
bytes_read = 0.0
|
||||
|
||||
while True:
|
||||
d = remote_file.read(8192)
|
||||
|
||||
if not d:
|
||||
print()
|
||||
break
|
||||
|
||||
bytes_read += len(d)
|
||||
data.append(d)
|
||||
sys.stdout.write('\r%2.2f%% downloaded' % (bytes_read / total_size * 100))
|
||||
sys.stdout.flush()
|
||||
|
||||
return b''.join(data)
|
||||
|
||||
|
||||
def main():
|
||||
print("=========================================", file=sys.stderr)
|
||||
print("| WARNING: THIS INSTALLER IS DEPRECATED |", file=sys.stderr)
|
||||
print("| AND WILL BE REMOVED ON MARCH 1, 2019. |", file=sys.stderr)
|
||||
print("=========================================\n", file=sys.stderr)
|
||||
|
||||
print("Please use the Shell or Powershell installer instead.\n", file=sys.stderr)
|
||||
|
||||
print("Install Deno via Shell script:", file=sys.stderr)
|
||||
print(" $ curl -fL https://deno.land/x/install/install.sh | sh\n", file=sys.stderr)
|
||||
|
||||
print("Install Deno via PowerShell script:", file=sys.stderr)
|
||||
print(" > iex (iwr https://deno.land/x/install/install.ps1)\n", file=sys.stderr)
|
||||
|
||||
bin_dir = deno_bin_dir()
|
||||
exe_fn = os.path.join(bin_dir, "deno")
|
||||
|
||||
url = release_url(sys.platform, sys.argv[1] if len(sys.argv) > 1 else None)
|
||||
compressed = download_with_progress(url)
|
||||
|
||||
if url.endswith(".zip"):
|
||||
with zipfile.ZipFile(io.BytesIO(compressed), 'r') as z:
|
||||
with open(exe_fn, 'wb+') as exe:
|
||||
exe.write(z.read('deno.exe'))
|
||||
else:
|
||||
# Note: gzip.decompress is not available in python2.
|
||||
content = zlib.decompress(compressed, 15 + 32)
|
||||
with open(exe_fn, 'wb+') as exe:
|
||||
exe.write(content)
|
||||
os.chmod(exe_fn, 0o744)
|
||||
|
||||
print("DENO_EXE: " + exe_fn)
|
||||
print("Now manually add %s to your $PATH" % bin_dir)
|
||||
print("Example:")
|
||||
print()
|
||||
print(" echo export PATH=\"%s\":\\$PATH >> $HOME/.bash_profile" % bin_dir)
|
||||
print()
|
||||
|
||||
|
||||
def mkdir(d):
|
||||
if not os.path.exists(d):
|
||||
print("mkdir", d)
|
||||
os.mkdir(d)
|
||||
|
||||
|
||||
def deno_bin_dir():
|
||||
home = os.path.expanduser("~")
|
||||
deno = os.path.join(home, ".deno")
|
||||
mkdir(deno)
|
||||
deno_bin = os.path.join(deno, "bin")
|
||||
mkdir(deno_bin)
|
||||
return deno_bin
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
0
install_test.ps1
Normal file → Executable file
0
install_test.ps1
Normal file → Executable file
|
|
@ -1,62 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import shutil
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
this_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def bin_dir():
|
||||
home = os.path.expanduser("~")
|
||||
return os.path.join(home, ".deno", "bin")
|
||||
|
||||
|
||||
def test_install():
|
||||
os.chdir(this_dir)
|
||||
PATTERN = "DENO_EXE: "
|
||||
expected_bin_dir = bin_dir()
|
||||
print("Testing install.py ... Expect deno installed to ", expected_bin_dir)
|
||||
if os.path.exists(expected_bin_dir):
|
||||
shutil.rmtree(expected_bin_dir)
|
||||
expected_fn = os.path.join(expected_bin_dir, "deno")
|
||||
|
||||
cmd = [sys.executable, "install.py"]
|
||||
out = subprocess.check_output(cmd, universal_newlines=True)
|
||||
actual_fn = None
|
||||
for line in out.splitlines():
|
||||
print(line)
|
||||
if PATTERN in line:
|
||||
print("set actual")
|
||||
actual_fn = line[len(PATTERN):]
|
||||
assert actual_fn == expected_fn, "actual %s != expected %s" % (actual_fn,
|
||||
expected_fn)
|
||||
assert os.path.exists(actual_fn)
|
||||
|
||||
|
||||
def test_tag_install():
|
||||
print(
|
||||
"Testing install.py [tag_name] ... Expect specified version of deno installed"
|
||||
)
|
||||
cmd = [sys.executable, "install.py", "v0.1.11"]
|
||||
out = subprocess.check_output(cmd, universal_newlines=True)
|
||||
|
||||
bin_path = os.path.join(bin_dir(), "deno")
|
||||
cmd = [bin_path, "-v"]
|
||||
out = subprocess.check_output(cmd, universal_newlines=True)
|
||||
|
||||
assert "deno: 0.1.11" in out, "installed deno version is not 0.1.11"
|
||||
assert "v8: 7.1.302.4" in out, "v8 version is not 7.1.302.4"
|
||||
assert "typescript: 3.1.3" in out, "typescript version is not 3.1.3"
|
||||
|
||||
|
||||
def main():
|
||||
test_install()
|
||||
test_tag_install()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Reference in a new issue