##// END OF EJS Templates
cli: add command 'kallithea-cli front-end-build'...
Thomas De Schampheleire -
r7358:b66725ba default
parent child Browse files
Show More
@@ -0,0 +1,50 b''
1 # -*- coding: utf-8 -*-
2 # This program is free software: you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation, either version 3 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
15 import click
16 import kallithea.bin.kallithea_cli_base as cli_base
17
18 import os
19 import subprocess
20
21 import kallithea
22
23 @cli_base.register_command()
24 @click.option('--install-deps/--no-install-deps', default=True,
25 help='Skip installation of dependencies, via "npm".')
26 @click.option('--generate/--no-generate', default=True,
27 help='Skip generation of front-end files.')
28 def front_end_build(install_deps, generate):
29 """Build the front-end.
30
31 Install required dependencies for the front-end and generate the necessary
32 files. This step is complementary to any 'pip install' step which only
33 covers Python dependencies.
34
35 The installation of front-end dependencies happens via the tool 'npm' which
36 is expected to be installed already.
37 """
38 rootdir = os.path.dirname(os.path.dirname(os.path.abspath(kallithea.__file__)))
39
40 if install_deps:
41 click.echo("Running 'npm install' to install front-end dependencies from package.json")
42 subprocess.check_call(['npm', 'install'], cwd=rootdir)
43
44 if generate:
45 click.echo("Generating CSS")
46 lesscpath = os.path.join(rootdir, 'node_modules', '.bin', 'lessc')
47 lesspath = os.path.join(rootdir, 'kallithea', 'public', 'less', 'main.less')
48 csspath = os.path.join(rootdir, 'kallithea', 'public', 'css', 'style.css')
49 subprocess.check_call([lesscpath, '--relative-urls', '--source-map',
50 '--source-map-less-inline', lesspath, csspath])
@@ -37,10 +37,9 b' To get started with Kallithea developmen'
37 pip install --upgrade pip setuptools
37 pip install --upgrade pip setuptools
38 pip install --upgrade -e .
38 pip install --upgrade -e .
39 pip install --upgrade -r dev_requirements.txt
39 pip install --upgrade -r dev_requirements.txt
40 npm install # install dependencies - both tools and data
41 npm run less # for generating css from less
42 kallithea-cli config-create my.ini
40 kallithea-cli config-create my.ini
43 kallithea-cli db-create -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp
41 kallithea-cli db-create -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp
42 kallithea-cli front-end-build
44 gearbox serve -c my.ini --reload &
43 gearbox serve -c my.ini --reload &
45 firefox http://127.0.0.1:5000/
44 firefox http://127.0.0.1:5000/
46
45
@@ -69,11 +69,9 b' installed.'
69 (``pip install kallithea`` from a source tree will do pretty much the same
69 (``pip install kallithea`` from a source tree will do pretty much the same
70 but build the Kallithea package itself locally instead of downloading it.)
70 but build the Kallithea package itself locally instead of downloading it.)
71
71
72 .. note:: The front-end code is built with Node. Currently, it must be built
72 .. note:: Kallithea includes front-end code that needs to be processed first.
73 locally after installing Kallithea. Assuming Node and the Node
73 The tool npm_ is used to download external dependencies and orchestrate the
74 Package Manager is available, other tools and source code will be
74 processing. The ``npm`` binary must thus be available.
75 downloaded and installed. The front-end code can then be built from
76 source locally.
77
75
78
76
79 Web server
77 Web server
@@ -144,3 +142,4 b' continuous hammering from the internet.'
144 .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
142 .. _WSGI: http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
145 .. _HAProxy: http://www.haproxy.org/
143 .. _HAProxy: http://www.haproxy.org/
146 .. _Varnish: https://www.varnish-cache.org/
144 .. _Varnish: https://www.varnish-cache.org/
145 .. _npm: https://www.npmjs.com/
@@ -5,22 +5,6 b' Setup'
5 =====
5 =====
6
6
7
7
8 Preparing front-end
9 -------------------
10
11 Temporarily, in the current Kallithea version, some extra steps are required to
12 build front-end files:
13
14 Find the right ``kallithea/public/less`` path with::
15
16 python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')"
17
18 Then run::
19
20 npm install
21 npm run less
22
23
24 Setting up Kallithea
8 Setting up Kallithea
25 --------------------
9 --------------------
26
10
@@ -70,6 +54,10 b' path to the root).'
70 but when trying to do a push it will fail with permission
54 but when trying to do a push it will fail with permission
71 denied errors unless it has write access.
55 denied errors unless it has write access.
72
56
57 Finally, prepare the front-end by running::
58
59 kallithea-cli front-end-build
60
73 You are now ready to use Kallithea. To run it simply execute::
61 You are now ready to use Kallithea. To run it simply execute::
74
62
75 gearbox serve -c my.ini
63 gearbox serve -c my.ini
@@ -86,18 +86,7 b' If you originally installed from version'
86 cd my-kallithea-clone
86 cd my-kallithea-clone
87 hg pull -u
87 hg pull -u
88 pip install --upgrade -e .
88 pip install --upgrade -e .
89
89 kallithea-cli front-end-build
90 Temporarily, in the current version, an extra step is required to build
91 front-end files:
92
93 Find the right ``kallithea/public/less`` path with::
94
95 python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')"
96
97 Then run::
98
99 npm install
100 npm run less
101
90
102
91
103 5. Upgrade your configuration
92 5. Upgrade your configuration
@@ -28,13 +28,10 b' directory, you can use this file to over'
28 you can use this to override ``@kallithea-theme-main-color``,
28 you can use this to override ``@kallithea-theme-main-color``,
29 ``@kallithea-logo-url`` or other `Bootstrap variables`_.
29 ``@kallithea-logo-url`` or other `Bootstrap variables`_.
30
30
31 After creating the ``theme.less`` file, you need to regenerate the CSS files.
31 After creating the ``theme.less`` file, you need to regenerate the CSS files, by
32 Install npm for your platform and run::
32 running::
33
33
34 npm install
34 kallithea-cli front-end-build --no-install-deps
35 npm run less
36
37 in the Kallithea root directory.
38
35
39 .. _bootstrap 3: https://getbootstrap.com/docs/3.3/
36 .. _bootstrap 3: https://getbootstrap.com/docs/3.3/
40 .. _bootstrap variables: https://getbootstrap.com/docs/3.3/customize/#less-variables
37 .. _bootstrap variables: https://getbootstrap.com/docs/3.3/customize/#less-variables
@@ -20,6 +20,7 b' import kallithea.bin.kallithea_cli_celer'
20 import kallithea.bin.kallithea_cli_config
20 import kallithea.bin.kallithea_cli_config
21 import kallithea.bin.kallithea_cli_db
21 import kallithea.bin.kallithea_cli_db
22 import kallithea.bin.kallithea_cli_extensions
22 import kallithea.bin.kallithea_cli_extensions
23 import kallithea.bin.kallithea_cli_front_end
23 import kallithea.bin.kallithea_cli_iis
24 import kallithea.bin.kallithea_cli_iis
24 import kallithea.bin.kallithea_cli_index
25 import kallithea.bin.kallithea_cli_index
25 import kallithea.bin.kallithea_cli_ishell
26 import kallithea.bin.kallithea_cli_ishell
@@ -7,8 +7,5 b''
7 "devDependencies": {
7 "devDependencies": {
8 "less": "~2.7",
8 "less": "~2.7",
9 "less-plugin-clean-css": "~1.5"
9 "less-plugin-clean-css": "~1.5"
10 },
11 "scripts": {
12 "less": "lessc --relative-urls --source-map --source-map-less-inline kallithea/public/less/main.less kallithea/public/css/style.css"
13 }
10 }
14 }
11 }
General Comments 0
You need to be logged in to leave comments. Login now