Skip to content

Commit

Permalink
Associate version to entry files (#1060)
Browse files Browse the repository at this point in the history
* Associate version to entry files

* Modified path joins for configs

* Made changes based on comments
  • Loading branch information
vera-liu authored Sep 16, 2016
1 parent 2132f67 commit 2432c31
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 28 deletions.
3 changes: 0 additions & 3 deletions caravel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
from flask_cache import Cache
from flask_migrate import Migrate

from caravel import version

VERSION = version.VERSION_STRING

APP_DIR = os.path.dirname(__file__)
CONFIG_MODULE = os.environ.get('CARAVEL_CONFIG', 'caravel.config')
Expand Down
2 changes: 1 addition & 1 deletion caravel/assets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "caravel",
"version": "0.1.0",
"version": "0.10.0",
"description": "Caravel is a data exploration platform designed to be visual, intuitive, and interactive.",
"directories": {
"doc": "docs",
Expand Down
5 changes: 4 additions & 1 deletion caravel/assets/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');

// input dir
const APP_DIR = path.resolve(__dirname, './');

// output dir
const BUILD_DIR = path.resolve(__dirname, './dist');

const VERSION_STRING = JSON.parse(fs.readFileSync('package.json')).version;

const config = {
entry: {
'css-theme': APP_DIR + '/javascripts/css-theme.js',
Expand All @@ -19,7 +22,7 @@ const config = {
},
output: {
path: BUILD_DIR,
filename: '[name].entry.js',
filename: `[name].${VERSION_STRING}.entry.js`,
},
resolve: {
extensions: [
Expand Down
2 changes: 1 addition & 1 deletion caravel/bin/caravel
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def version(verbose):
"-----------------------\n"
"Caravel {version}\n"
"-----------------------").format(
boat=ascii_art.boat, version=caravel.VERSION)
boat=ascii_art.boat, version=config.get('VERSION_STRING'))
print(s)
if verbose:
print("[DB] : " + "{}".format(db.engine))
Expand Down
7 changes: 7 additions & 0 deletions caravel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from caravel import app

import json
import os

from dateutil import tz
Expand All @@ -22,6 +24,11 @@
# ---------------------------------------------------------
# Caravel specific config
# ---------------------------------------------------------
PACKAGE_DIR = os.path.join(BASE_DIR, 'static', 'assets')
PACKAGE_FILE = os.path.join(PACKAGE_DIR, 'package.json')
with open(PACKAGE_FILE) as package_file:
VERSION_STRING = json.load(package_file)['version']

ROW_LIMIT = 50000
CARAVEL_WORKERS = 16

Expand Down
10 changes: 7 additions & 3 deletions caravel/templates/caravel/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

{% block head_js %}
{{super()}}
<script src="/static/assets/dist/css-theme.entry.js"></script>
{% with filename="css-theme" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% endblock %}

{% block tail_js %}
{{super()}}
<script src="/static/assets/dist/common.entry.js"></script>
{{super()}}
{% with filename="common" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% endblock %}
4 changes: 3 additions & 1 deletion caravel/templates/caravel/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<link rel="icon" type="image/png" href="/static/assets/images/favicon.png">
{% endblock %}
{% block head_js %}
<script src="/static/assets/dist/css-theme.entry.js"></script>
{% with filename="css-theme" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% endblock %}
</head>

Expand Down
4 changes: 3 additions & 1 deletion caravel/templates/caravel/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

{% block head_js %}
{{ super() }}
<script src="/static/assets/dist/dashboard.entry.js"></script>
{% with filename="dashboard" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% endblock %}
{% block title %}[dashboard] {{ dashboard.dashboard_title }}{% endblock %}
{% block body %}
Expand Down
4 changes: 3 additions & 1 deletion caravel/templates/caravel/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -335,5 +335,7 @@ <h4 class="modal-title">{{ _("Save a Slice") }}</h4>

{% block tail_js %}
{{ super() }}
<script src="/static/assets/dist/explore.entry.js"></script>
{% with filename="explore" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% endblock %}
4 changes: 4 additions & 0 deletions caravel/templates/caravel/partials/_script_tag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% set VERSION_STRING = appbuilder.get_app.config.get("VERSION_STRING") %}
{% block tail_js %}
<script src="/static/assets/dist/{{filename}}.{{VERSION_STRING}}.entry.js"></script>
{% endblock %}
4 changes: 3 additions & 1 deletion caravel/templates/caravel/sqllab.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

{% block tail_js %}
{{ super() }}
<script src="/static/assets/dist/sqllab.entry.js"></script>
{% with filename="sqllab" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% endblock %}
8 changes: 6 additions & 2 deletions caravel/templates/caravel/standalone.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
<div id="{{ viz.token }}_con" class="slice_container" style="height: 100%; width: 100%"></div>
</div>
</body>
<script src="/static/assets/dist/css-theme.entry.js"></script>
<script src="/static/assets/dist/standalone.entry.js"></script>
{% with filename="css-theme" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% with filename="standalone" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
</html>

6 changes: 4 additions & 2 deletions caravel/templates/caravel/welcome.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% extends "caravel/basic.html" %}

{% block head_js %}
{{ super() }}
<script src="/static/assets/dist/welcome.entry.js"></script>
{{ super() }}
{% with filename="welcome" %}
{% include "caravel/partials/_script_tag.html" %}
{% endwith %}
{% endblock %}

{% block title %}{{ _("Welcome!") }}{% endblock %}
Expand Down
7 changes: 0 additions & 7 deletions caravel/version.py

This file was deleted.

12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import imp
import os
import json
from setuptools import setup, find_packages

version = imp.load_source(
'version', os.path.join('caravel', 'version.py'))
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
PACKAGE_DIR = os.path.join(BASE_DIR, 'caravel', 'static', 'assets')
PACKAGE_FILE = os.path.join(PACKAGE_DIR, 'package.json')
with open(PACKAGE_FILE) as package_file:
version_string = json.load(package_file)['version']

setup(
name='caravel',
description=(
"A interactive data visualization platform build on SqlAlchemy "
"and druid.io"),
version=version.VERSION_STRING,
version=version_string,
packages=find_packages(),
include_package_data=True,
zip_safe=False,
Expand Down Expand Up @@ -55,7 +59,7 @@
author_email='maximebeauchemin@gmail.com',
url='https://github.com/airbnb/caravel',
download_url=(
'https://github.com/airbnb/caravel/tarball/' + version.VERSION_STRING),
'https://github.com/airbnb/caravel/tarball/' + version_string),
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
Expand Down

0 comments on commit 2432c31

Please sign in to comment.