Move version out of config.js

We now store this in a file called VERSION inside the tarball
itself.
This commit is contained in:
Girish Ramakrishnan
2018-10-27 10:53:47 -07:00
parent 7ad069fd94
commit 2688a57d46
10 changed files with 15 additions and 18 deletions

1
.gitignore vendored
View File

@@ -6,4 +6,3 @@ installer/src/certs/server.key
# vim swap files
*.swp

1
VERSION Normal file
View File

@@ -0,0 +1 @@
# release version. do not edit manually

View File

@@ -173,8 +173,7 @@ data=$(cat <<EOF
"provider": "${provider}",
"edition": "${edition}",
"apiServerOrigin": "${apiServerOrigin}",
"webServerOrigin": "${webServerOrigin}",
"version": "${version}"
"webServerOrigin": "${webServerOrigin}"
}
EOF
)
@@ -200,7 +199,6 @@ echo "=> Installing version ${version} (this takes some time) ..."
mkdir -p /etc/cloudron
cat > "/etc/cloudron/cloudron.conf" <<CONF_END
{
"version": "${version}",
"apiServerOrigin": "${apiServerOrigin}",
"webServerOrigin": "${webServerOrigin}",
"provider": "${provider}",

View File

@@ -7,21 +7,28 @@ set -eu
[[ $(uname -s) == "Darwin" ]] && GNU_GETOPT="/usr/local/opt/gnu-getopt/bin/getopt" || GNU_GETOPT="getopt"
readonly GNU_GETOPT
args=$(${GNU_GETOPT} -o "" -l "output:" -n "$0" -- "$@")
args=$(${GNU_GETOPT} -o "" -l "output:,version:" -n "$0" -- "$@")
eval set -- "${args}"
readonly SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
bundle_file=""
version=""
while true; do
case "$1" in
--output) bundle_file="$2"; shift 2;;
--version) version="$2"; shift 2;;
--) break;;
*) echo "Unknown option $1"; exit 1;;
esac
done
if [[ -z "${version}" ]]; then
echo "--version is required"
exit 1
fi
readonly TMPDIR=${TMPDIR:-/tmp} # why is this not set on mint?
if ! $(cd "${SOURCE_DIR}" && git diff --exit-code >/dev/null); then
@@ -50,6 +57,7 @@ echo "==> Checking out code box version [${box_version}] and dashboard version [
(cd "${SOURCE_DIR}" && git archive --format=tar ${box_version} | (cd "${bundle_dir}" && tar xf -))
(cd "${SOURCE_DIR}/../dashboard" && git archive --format=tar ${dashboard_version} | (mkdir -p "${bundle_dir}/dashboard.build" && cd "${bundle_dir}/dashboard.build" && tar xf -))
(cp "${SOURCE_DIR}/../dashboard/LICENSE" "${bundle_dir}")
echo "${version}" > "${bundle_dir}/VERSION"
echo "==> Installing modules for dashboard asset generation"
(cd "${bundle_dir}/dashboard.build" && npm install --production)

View File

@@ -45,7 +45,6 @@ exports = module.exports = {
isAdminDomainLocked: isAdminDomainLocked,
// for testing resets to defaults
_setVersion: setVersion,
_reset: _reset
};
@@ -211,11 +210,7 @@ function sysadminOrigin() {
}
function version() {
return get('version');
}
function setVersion(version) {
set('version', version);
return fs.readFileSync(path.join(__dirname, '../VERSION'), 'utf8').trim();
}
function database() {

View File

@@ -50,7 +50,6 @@ function setup(done) {
nock.cleanAll();
config._reset();
config.set('provider', 'caas');
config._setVersion('1.2.3');
async.series([
server.start.bind(server),

View File

@@ -20,7 +20,6 @@ var token = null;
function setup(done) {
config._reset();
config._setVersion('1.2.3');
async.series([
server.start,

View File

@@ -32,7 +32,6 @@ const DOMAIN_0 = {
function setup(done) {
config._reset();
config.setFqdn(DOMAIN_0.domain);
config._setVersion('1.2.3');
async.series([
server.start,

View File

@@ -24,9 +24,9 @@ describe('config', function () {
done();
});
it('can get and set version', function (done) {
config._setVersion('1.2.3');
expect(config.version()).to.be('1.2.3');
it('can get version', function (done) {
expect(config.version()).to.be.ok(); // this gets a dummy text string
expect(config.version().includes('\n')).to.not.be.ok();
done();
});

View File

@@ -22,7 +22,6 @@ var assert = require('assert'),
paths = require('./paths.js'),
progress = require('./progress.js'),
safe = require('safetydance'),
semver = require('semver'),
shell = require('./shell.js'),
updateChecker = require('./updatechecker.js'),
util = require('util'),