Changeset - 96b53ab02c2a
[Not reviewed]
default
0 3 0
Mads Kiilerich - 7 years ago 2018-12-25 20:23:42
mads@kiilerich.com
front-end: use license-checker to generate information about code used to build the front-end
3 files changed with 32 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_front_end.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import click
 
import kallithea.bin.kallithea_cli_base as cli_base
 

	
 
import os
 
import subprocess
 
import json
 

	
 
import kallithea
 

	
 
@cli_base.register_command()
 
@click.option('--install-deps/--no-install-deps', default=True,
 
        help='Skip installation of dependencies, via "npm".')
 
@click.option('--generate/--no-generate', default=True,
 
        help='Skip generation of front-end files.')
 
def front_end_build(install_deps, generate):
 
    """Build the front-end.
 

	
 
    Install required dependencies for the front-end and generate the necessary
 
    files.  This step is complementary to any 'pip install' step which only
 
    covers Python dependencies.
 

	
 
    The installation of front-end dependencies happens via the tool 'npm' which
 
    is expected to be installed already.
 
    """
 
    front_end_dir = os.path.abspath(os.path.join(kallithea.__file__, '..', 'front-end'))
 
    public_dir = os.path.abspath(os.path.join(kallithea.__file__, '..', 'public'))
 

	
 
    if install_deps:
 
        click.echo("Running 'npm install' to install front-end dependencies from package.json")
 
        subprocess.check_call(['npm', 'install'], cwd=front_end_dir)
 

	
 
    if generate:
 
        tmp_dir = os.path.join(front_end_dir, 'tmp')
 
        if not os.path.isdir(tmp_dir):
 
            os.mkdir(tmp_dir)
 

	
 
        click.echo("Generating CSS")
 
        with open(os.path.join(tmp_dir, 'pygments.css'), 'w') as f:
 
            subprocess.check_call(['pygmentize',
 
                    '-S', 'default',
 
                    '-f', 'html',
 
                    '-a', '.code-highlight'],
 
                    stdout=f)
 
        lesscpath = os.path.join(front_end_dir, 'node_modules', '.bin', 'lessc')
 
        lesspath = os.path.join(public_dir, 'less', 'main.less')
 
        csspath = os.path.join(public_dir, 'css', 'style.css')
 
        subprocess.check_call([lesscpath, '--relative-urls', '--source-map',
 
                '--source-map-less-inline', lesspath, csspath],
 
                cwd=front_end_dir)
 

	
 
        click.echo("Generating LICENSES.txt")
 
        check_licensing_json_path = os.path.join(tmp_dir, 'licensing.json')
 
        licensing_txt_path = os.path.join(public_dir, 'LICENSES.txt')
 
        subprocess.check_call([
 
            os.path.join(front_end_dir, 'node_modules', '.bin', 'license-checker'),
 
            '--json',
 
            '--out', check_licensing_json_path,
 
            ], cwd=front_end_dir)
 
        with open(check_licensing_json_path) as jsonfile:
 
            rows = json.loads(jsonfile.read())
 
            with open(licensing_txt_path, 'w') as out:
 
                out.write("The Kallithea front-end was built using the following Node modules:\n\n")
 
                for name_version, values in sorted(rows.items()):
 
                    name, version = name_version.rsplit('@', 1)
 
                    line = "%s from https://www.npmjs.com/package/%s/v/%s\n  License: %s\n  Repository: %s\n" % (
 
                        name_version, name, version, values['licenses'], values.get('repository', '-'))
 
                    if values.get('copyright'):
 
                        line += "  Copyright: %s\n" % (values['copyright'])
 
                    out.write(line + '\n')
kallithea/front-end/package.json
Show inline comments
 
{
 
  "name": "kallithea",
 
  "private": true,
 
  "dependencies": {
 
    "bootstrap": "3.3.7"
 
  },
 
  "devDependencies": {
 
    "less": "~2.7",
 
    "less-plugin-clean-css": "~1.5"
 
    "less-plugin-clean-css": "~1.5",
 
    "license-checker": "24.1.0"
 
  }
 
}
kallithea/templates/about.html
Show inline comments
 
@@ -113,58 +113,63 @@
 
  <li>Copyright &copy; 2013, Grzegorz Rożniecki</li>
 
  <li>Copyright &copy; 2013, Jonathan Sternberg</li>
 
  <li>Copyright &copy; 2013, Leonardo Carneiro</li>
 
  <li>Copyright &copy; 2013, Magnus Ericmats</li>
 
  <li>Copyright &copy; 2013, Martin Vium</li>
 
  <li>Copyright &copy; 2013, Simon Lopez</li>
 
  <li>Copyright &copy; 2011&ndash;2012, Augusto Herrmann</li>
 
  <li>Copyright &copy; 2012, Dan Sheridan</li>
 
  <li>Copyright &copy; 2012, H Waldo G</li>
 
  <li>Copyright &copy; 2012, hppj</li>
 
  <li>Copyright &copy; 2012, Indra Talip</li>
 
  <li>Copyright &copy; 2012, mikespook</li>
 
  <li>Copyright &copy; 2012, nansenat16</li>
 
  <li>Copyright &copy; 2012, Philip Jameson</li>
 
  <li>Copyright &copy; 2012, Raoul Thill</li>
 
  <li>Copyright &copy; 2012, Tony Bussieres</li>
 
  <li>Copyright &copy; 2012, Vincent Duvert</li>
 
  <li>Copyright &copy; 2012, Vladislav Poluhin</li>
 
  <li>Copyright &copy; 2012, Zachary Auclair</li>
 
  <li>Copyright &copy; 2011, Ankit Solanki</li>
 
  <li>Copyright &copy; 2011, Dmitri Kuznetsov</li>
 
  <li>Copyright &copy; 2011, Jared Bunting</li>
 
  <li>Copyright &copy; 2011, Jason Harris</li>
 
  <li>Copyright &copy; 2011, Les Peabody</li>
 
  <li>Copyright &copy; 2011, Liad Shani</li>
 
  <li>Copyright &copy; 2011, Lorenzo M. Catucci</li>
 
  <li>Copyright &copy; 2011, Matt Zuba</li>
 
  <li>Copyright &copy; 2011, Nicolas VINOT</li>
 
  <li>Copyright &copy; 2011, Shawn K. O'Shea</li>
 
  <li>Copyright &copy; 2010, Łukasz Balcerzak</li>
 

	
 
## We did not list the following copyright holders, given that they appeared
 
## to use for-profit company affiliations in their contribution in the
 
## Mercurial log and therefore I didn't know if copyright was theirs or
 
## their company's.
 
## Copyright &copy; 2011 Thayne Harbaugh <thayne@fusionio.com>
 
## Copyright &copy; 2012 Dies Koper <diesk@fast.au.fujitsu.com>
 
## Copyright &copy; 2012 Erwin Kroon <e.kroon@smartmetersolutions.nl>
 
## Copyright &copy; 2012 Vincent Caron <vcaron@bearstech.com>
 
##
 
## These contributors' contributions may not be copyrightable:
 
## philip.j@hostdime.com in 2012
 
## Stefan Engel <mail@engel-stefan.de> in 2012
 
## Ton Plomp <tcplomp@gmail.com> in 2013
 
##
 
  </ul>
 

	
 
  <p>The above are the copyright holders who have submitted direct
 
  contributions to the Kallithea repository.  In
 
  the <a href="https://kallithea-scm.org/repos/kallithea">Kallithea source
 
  code</a>, there is
 
  a <a href="https://kallithea-scm.org/repos/kallithea/files/tip/LICENSE.md">list
 
  contributions to the Kallithea repository.</p>
 

	
 
  <p>In the <a href="https://kallithea-scm.org/repos/kallithea">Kallithea
 
  source code</a>, there is a
 
  <a href="https://kallithea-scm.org/repos/kallithea/files/tip/LICENSE.md">list
 
  of third-party libraries and code that Kallithea incorporates</a>.</p>
 

	
 
  <p>The front-end contains a <a href="${h.url('/LICENSES.txt')}">list of
 
  software that is used to build the front-end</a> but isn't distributed as a
 
  part of Kallithea.</p>
 

	
 
  </div>
 
</div>
 

	
 
</%def>
0 comments (0 inline, 0 general)