Merge pull request #74 from NebulaServices/main
Remove bare switcher & update Devcontainer files
This commit is contained in:
commit
4235be8e02
9 changed files with 597 additions and 858 deletions
|
|
@ -1,14 +1,12 @@
|
|||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=16-bullseye
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
|
||||
FROM node:18
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
# Install basic development tools
|
||||
RUN apt update && apt install -y less man-db sudo
|
||||
|
||||
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||
# ARG EXTRA_NODE_VERSION=10
|
||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||
# Ensure default `node` user has access to `sudo`
|
||||
ARG USERNAME=node
|
||||
RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
|
||||
&& chmod 0440 /etc/sudoers.d/$USERNAME
|
||||
|
||||
# [Optional] Uncomment if you want to install more global node modules
|
||||
# RUN su node -c "npm install -g <your-package-list-here>"
|
||||
# Set `DEVCONTAINER` environment variable to help with orientation
|
||||
ENV DEVCONTAINER=true
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=16-bullseye
|
||||
FROM node:${VARIANT}
|
||||
|
||||
# [Option] Install zsh
|
||||
ARG INSTALL_ZSH="true"
|
||||
# [Option] Upgrade OS packages to their latest versions
|
||||
ARG UPGRADE_PACKAGES="true"
|
||||
|
||||
# Install needed packages, yarn, nvm and setup non-root user. Use a separate RUN statement to add your own dependencies.
|
||||
ARG USERNAME=node
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
ENV NVM_DIR=/usr/local/share/nvm
|
||||
ENV NVM_SYMLINK_CURRENT=true \
|
||||
PATH=${NPM_GLOBAL}/bin:${NVM_DIR}/current/bin:${PATH}
|
||||
COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
|
||||
&& apt-get purge -y imagemagick imagemagick-6-common \
|
||||
# Install common packages, non-root user, update yarn and install nvm
|
||||
&& bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
|
||||
# Install yarn, nvm
|
||||
&& rm -rf /opt/yarn-* /usr/local/bin/yarn /usr/local/bin/yarnpkg \
|
||||
&& bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "none" "${USERNAME}" \
|
||||
# Configure global npm install location, use group to adapt to UID/GID changes
|
||||
&& if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
||||
&& usermod -a -G npm ${USERNAME} \
|
||||
&& umask 0002 \
|
||||
&& mkdir -p ${NPM_GLOBAL} \
|
||||
&& touch /usr/local/etc/npmrc \
|
||||
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
|
||||
&& chmod g+s ${NPM_GLOBAL} \
|
||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& sudo -u ${USERNAME} npm config -g set prefix ${NPM_GLOBAL} \
|
||||
# Install eslint
|
||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||
&& npm cache clean --force > /dev/null 2>&1 \
|
||||
# Install python-is-python3 on bullseye to prevent node-gyp regressions
|
||||
&& . /etc/os-release \
|
||||
&& if [ "${VERSION_CODENAME}" = "bullseye" ]; then apt-get -y install --no-install-recommends python-is-python3; fi \
|
||||
# Clean up
|
||||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /root/.gnupg /tmp/library-scripts
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
|
||||
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||
# ARG EXTRA_NODE_VERSION=10
|
||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||
|
||||
# [Optional] Uncomment if you want to install more global node modules
|
||||
# RUN su node -c "npm install -g <your-package-list-here>""
|
||||
|
|
@ -1,32 +1,9 @@
|
|||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/javascript-node
|
||||
// See https://containers.dev/implementors/json_reference/ for configuration reference
|
||||
{
|
||||
"name": "Node.js",
|
||||
"name": "Nebula",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
// Update 'VARIANT' to pick a Node version: 18, 16, 14.
|
||||
// Append -bullseye or -buster to pin to an OS version.
|
||||
// Use -bullseye variants on local arm64/Apple Silicon.
|
||||
"args": { "VARIANT": "16-bullseye" }
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"dbaeumer.vscode-eslint"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "npm install",
|
||||
|
||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
||||
"remoteUser": "node"
|
||||
"remoteUser": "node",
|
||||
"postCreateCommand": "npm install"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
<!-- Embed -->
|
||||
|
||||
<script src="../uv/uv.bundle.js"></script>
|
||||
<script src="../resources/appModules/BareSwitcher.js"></script>
|
||||
<script src="../resources/options.js"></script>
|
||||
<meta name="theme-color" content="#5a189a">
|
||||
<meta property=og:title content=Nebula>
|
||||
|
|
@ -141,13 +140,6 @@
|
|||
<label disabled for="ssuggestion" style="background: grey;">
|
||||
</label>
|
||||
</div>
|
||||
<div class="settings-cont">
|
||||
<p class="name" style="font-size: 24px;"> Bare location </p>
|
||||
<p class="description">Choose the location where a bare server is hosted. </p>
|
||||
<input id="bareLocationInput" class="bareLocationInput" type="url">
|
||||
<p id="validIndicator" class="bareValidSignal" > </p>
|
||||
</label>
|
||||
</div>
|
||||
<div class="settings-cont">
|
||||
<p class="name"> Misc </p>
|
||||
<p class="description"></p>
|
||||
|
|
@ -187,11 +179,6 @@ if (cloakStored == "on") {
|
|||
}
|
||||
themeSelector.value = themeStored
|
||||
proxySel.value = proxyStored
|
||||
|
||||
getBareLocation().then(bareLocation => {
|
||||
document.getElementById("bareLocationInput").value = bareLocation;
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,103 +0,0 @@
|
|||
// NOTE: THIS FILE MUST BE ACCOMPANIED BY THE ULTRAVIOLET BUNDLE BECAUSE IT CONTAINS THE INDEXEDDB LIBRARY
|
||||
|
||||
const dbPromise = Ultraviolet.openDB('keyval-store', 1, {
|
||||
upgrade (db) {
|
||||
db.createObjectStore('keyval')
|
||||
}
|
||||
})
|
||||
|
||||
function getBareLocation () {
|
||||
return dbPromise
|
||||
.then(db => db.get('keyval', 'bareLocation'))
|
||||
.then(value => value || '')
|
||||
}
|
||||
|
||||
self.storage = {
|
||||
async get (key) {
|
||||
return (await dbPromise).get('keyval', key)
|
||||
},
|
||||
|
||||
async set (key, val) {
|
||||
return (await dbPromise).put('keyval', val, key)
|
||||
},
|
||||
|
||||
async del (key) {
|
||||
return (await dbPromise).delete('keyval', key)
|
||||
}
|
||||
}
|
||||
|
||||
function setBareLocation (location) {
|
||||
if (
|
||||
/^http(s?):\/\//.test(location) ||
|
||||
(location.includes('.') && val.substr(0, 1) !== ' ') ||
|
||||
location.includes('/bare/')
|
||||
) {
|
||||
storage.set('bareLocation', location)
|
||||
return 'Bare is located at: ' + location
|
||||
} else {
|
||||
console.log(
|
||||
'Invalid Location provided, please provide a server in the format of http(s)://server.domain.com/'
|
||||
)
|
||||
return 'Invalid Location provided'
|
||||
}
|
||||
}
|
||||
|
||||
function bareValidator (bareLocation) {
|
||||
try {
|
||||
// open a request to the bare location
|
||||
var xmlHttp = new XMLHttpRequest()
|
||||
xmlHttp.open('GET', bareLocation, false) // false for synchronous request
|
||||
xmlHttp.send(null)
|
||||
const _response = xmlHttp.responseText
|
||||
// turn the response text into json
|
||||
|
||||
const response = JSON.parse(_response)
|
||||
|
||||
if (response.project.name === 'bare-server-node') {
|
||||
console.log('Bare located at: ' + bareLocation + '')
|
||||
return true
|
||||
} else {
|
||||
console.error('Bare not found at: ' + bareLocation)
|
||||
return false
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
'An error occured while attempting to identify the bare server at: ' +
|
||||
bareLocation
|
||||
)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
console.log('Loaded ')
|
||||
const _loc = document.getElementById('bareLocationInput')
|
||||
const indicator = document.getElementById('validIndicator')
|
||||
|
||||
// wait 3 seconds
|
||||
setTimeout(() => {
|
||||
if (bareValidator(_loc.value) === true) {
|
||||
indicator.innerText = 'Connected to server: ' + _loc.value
|
||||
indicator.style.color = '#42f851'
|
||||
} else if (bareValidator(_loc.value) === false) {
|
||||
indicator.innerText = 'Could not connect to server: ' + _loc.value
|
||||
indicator.style.color = '#f45145bd'
|
||||
}
|
||||
}, 1000)
|
||||
|
||||
document
|
||||
.getElementById('bareLocationInput')
|
||||
.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
if (bareValidator(_loc.value) === true) {
|
||||
indicator.innerText = 'Connected to server: ' + _loc.value
|
||||
indicator.style.color = '#42f851'
|
||||
setBareLocation(_loc.value)
|
||||
} else if (bareValidator(_loc.value) === false) {
|
||||
_loc.value = ''
|
||||
indicator.innerText = 'Could not connect to server: ' + _loc.value
|
||||
indicator.style.color = '#f45145bd'
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// NOTE - This file is not used in the current version of the app.
|
||||
// this is just a snippet of code that I am keeping for future reference.
|
||||
// NOTE: THIS FILE MUST BE ACCOMPANIED BY THE ULTRAVIOLET BUNDLE BECAUSE IT CONTAINS THE INDEXEDDB LIBRARY
|
||||
|
||||
|
||||
const dbPromise = Ultraviolet.openDB('keyval-store', 1, {
|
||||
upgrade (db) {
|
||||
db.createObjectStore('keyval')
|
||||
}
|
||||
})
|
||||
|
||||
self.storage = {
|
||||
async get (key) {
|
||||
return (await dbPromise).get('keyval', key)
|
||||
},
|
||||
|
||||
async set (key, val) {
|
||||
return (await dbPromise).put('keyval', val, key)
|
||||
},
|
||||
|
||||
async del (key) {
|
||||
return (await dbPromise).delete('keyval', key)
|
||||
}
|
||||
}
|
||||
|
|
@ -40,26 +40,6 @@ window.addEventListener('load', () => {
|
|||
}
|
||||
}
|
||||
|
||||
function getBareLocation () {
|
||||
return dbPromise
|
||||
.then(db => db.get('keyval', 'bareLocation'))
|
||||
.then(value => value || '')
|
||||
}
|
||||
|
||||
getBareLocation().then(bareLocation => {
|
||||
|
||||
console.log('Bare Location: ' + bareLocation)
|
||||
if (bareLocation === '') {
|
||||
console.log('No bare location found, automatically setting to default')
|
||||
storage.set('bareLocation', '/bare/')
|
||||
|
||||
}
|
||||
|
||||
// if bare location is not only whitespace
|
||||
// if (bareLocation.trim() !== '') {
|
||||
|
||||
})
|
||||
|
||||
navigator.serviceWorker.register('./sw.js', {
|
||||
scope: '/service/'
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
self.__uv$config = {
|
||||
prefix: '/service/go/',
|
||||
bare: '',
|
||||
bare: '/bare/',
|
||||
encodeUrl: Ultraviolet.codec.xor.encode,
|
||||
decodeUrl: Ultraviolet.codec.xor.decode,
|
||||
handler: '/uv/uv.handler.js',
|
||||
|
|
|
|||
1183
static/uv/uv.sw.js
1183
static/uv/uv.sw.js
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue