]> git.wincent.com - wincent.git/commitdiff
feat: create seed version of "install-next" script
authorGreg Hurrell <greg@hurrell.net>
Tue, 17 Mar 2020 23:53:31 +0000 (00:53 +0100)
committerGreg Hurrell <greg@hurrell.net>
Fri, 20 Mar 2020 09:53:24 +0000 (10:53 +0100)
Just playing around at this point to see if I could make something that
was very close to zero-dependencies (other than the language runtime and
its standard library), unlike Ansible, which sits atop pile of Python
infrastructure.

Related: https://github.com/wincent/wincent/issues/82

install-next [new file with mode: 0755]
lib/main.ts [new file with mode: 0644]
tsconfig.json [new file with mode: 0644]
vendor/deno/.gitignore [new file with mode: 0644]

diff --git a/install-next b/install-next
new file mode 100755 (executable)
index 0000000..1d7e1d6
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+set -e
+
+REPO_ROOT="${BASH_SOURCE%/*}"
+DENO_BASE="$REPO_ROOT/vendor/deno"
+DENO_INSTALLER="$DENO_BASE/install.sh"
+DENO_INSTALL="$DENO_BASE/local"
+DENO_EXE="$DENO_INSTALL/bin/deno"
+DENO_TYPES="$DENO_BASE/types.d.ts"
+
+for ARG in "$@"; do
+  if [ "$ARG" = "--force" -o "$ARG" = "-f" ]; then
+    FORCE=1
+  fi
+done
+
+if [[ ! -e "$DENO_INSTALLER" || $FORCE ]]; then
+  echo "[status] Fetching Deno installer"
+  command curl -fsSL -o "$DENO_INSTALLER" https://deno.land/x/install/install.sh
+else
+  echo "[skip] Fetch Deno installer; use -f to force re-fetch"
+fi
+
+if [[ ! -e "$DENO_EXE" || $FORCE ]]; then
+  echo "[status] Run Deno installer"
+  export DENO_INSTALL
+  command sh "$DENO_INSTALLER"
+else
+  echo "[skip] Run Deno installer; use -f to force re-install"
+fi
+
+if [[ ! -e "$DENO_TYPES" || $FORCE ]]; then
+  echo "[status] Generate Deno types"
+  "$DENO_EXE" types > "$DENO_TYPES"
+else
+  echo "[skip] Generate Deno types; use -f to force re-generation"
+fi
+
+echo "[status] Running main"
+"$DENO_EXE" run --allow-all lib/main.ts "$@"
diff --git a/lib/main.ts b/lib/main.ts
new file mode 100644 (file)
index 0000000..c2aebde
--- /dev/null
@@ -0,0 +1,4 @@
+// This is only for the benefit of the LanguageClient.
+import type Deno from '../vendor/deno/types.d.ts';
+
+console.log(Deno.args);
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/vendor/deno/.gitignore b/vendor/deno/.gitignore
new file mode 100644 (file)
index 0000000..120f485
--- /dev/null
@@ -0,0 +1,2 @@
+*
+!/.gitignore