Re: [PATCH 2 of 3 PoC] cli: add commands to handle front-end generation

2018-10-02 Thread Thomas De Schampheleire
El dom., 30 sept. 2018 a las 16:02, Mads Kiilerich
() escribió:
>
> On 9/26/18 9:34 PM, Thomas De Schampheleire wrote:
> > Currently implemented CLI is as follows:
>
>
> Nice and helpful overview!
>
>
> > kallithea config create
> > kallithea frontend create
> >
> > and the specific commands that 'frontend create' is wrapping:
>
>
> Should the sub-commands perhaps more be seen as optional parts of
> "create", and be controlled by passing options like --install-deps and
> --generate to the sub command create?

Yes, I can try that. If you don't specify anything then you get the
full generation, and if you specify at least one, only those steps are
done?

>
> > kallithea frontend install-deps
> > kallithea frontend generate-css
>
>
> I think the css and js parts will be hard/wrong to separate. It should
> thus probably just be named something like 'generate' from the start?

ok

>
>
> > The way I saw the conversion of existing commands:
> >
> > kallithea cache-keys showcache-keys --show
> > kallithea cache-keys cleanup  cache-keys --cleanup
> >
> > kallithea celery run  celeryd
> >
> > kallithea repo cleanup   cleanup-repos
>
>
> ('cleanup' is also badly named. Something like 'purge' or
> 'purge-deleted' or 'purge-backups' seems more correct and intuitive.)

'purge' on its own may be too confusing with 'hg purge'.
'purge-deleted' is better in that respect.

>
> > kallithea repo scan repo-scan
> > kallithea repo update-cache update-repoinfo
> > kallithea repo invalidate-cache   update-repoinfo --invalidatecache
> > (Not exactly sure about the difference between both, to be discussed)
> >
> > kallithea iis install install-iis
>
> (The two levels of sub-commands seem a bit redundant. But consistency is
> nice. Then, should it be "create" instead of "install"?)

I agree that it's odd here.
The command is doing something that is necessary for the installation.
It is not actually creating but rather installing.
I would also have preferred consistency in the 'create' stanza, but
here I felt it is too far off.

>
> > kallithea ishell   ishell

I wonder, should it be 'ishell run' here to align with 'celery run' ?

> >
> > kallithea config create  make-config
> >
> > kallithea index create   make-index -f (full)
> > kallithea index update  make-index(parameters to this
> > tool are unclear to me)
> >
> > kallithea extensions create   make-rcext
> >
> > kallithea db createsetup-db
>
> (I agree 'create' is better than 'setup'. But still not spot-on, as it
> doesn't really create the database - in only populates it with tables
> and initial data. That should probably just be clarified in documentation.)

I would be fine with 'initialize' here too, for example.

>
> > kallithea db upgradeupgrade-db
> >
> > kallithea front-end create
>
> (we need consistent spelling ;-) )
>
> >>> +subprocess.check_call(['npm', 'run', 'less'], cwd=rootdir)
> >>> +
> >>> +@frontend.command()
> >>> +@click.pass_context
> >>> +def create(ctx):
> >>> +"""Create the front-end completely"""
> >>> +ctx.invoke(install_deps)
> >>> +ctx.invoke(generate_css)
> > I was thinking that we maybe should make it more clear that the
> > 'create' step is the master command that does everything, and the
> > other steps are just for finer control for power users. Not sure how
> > to do that best...
>
> (discussed above)
>
> /Mads
>
>
___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general


Re: [PATCH 2 of 3 PoC] cli: add commands to handle front-end generation

2018-09-30 Thread Mads Kiilerich

On 9/26/18 9:34 PM, Thomas De Schampheleire wrote:
Currently implemented CLI is as follows: 



Nice and helpful overview!



kallithea config create
kallithea frontend create

and the specific commands that 'frontend create' is wrapping:



Should the sub-commands perhaps more be seen as optional parts of 
"create", and be controlled by passing options like --install-deps and 
--generate to the sub command create?



kallithea frontend install-deps
kallithea frontend generate-css



I think the css and js parts will be hard/wrong to separate. It should 
thus probably just be named something like 'generate' from the start?




The way I saw the conversion of existing commands:

kallithea cache-keys showcache-keys --show
kallithea cache-keys cleanup  cache-keys --cleanup

kallithea celery run  celeryd

kallithea repo cleanup   cleanup-repos



('cleanup' is also badly named. Something like 'purge' or 
'purge-deleted' or 'purge-backups' seems more correct and intuitive.)



kallithea repo scan repo-scan
kallithea repo update-cache update-repoinfo
kallithea repo invalidate-cache   update-repoinfo --invalidatecache
(Not exactly sure about the difference between both, to be discussed)

kallithea iis install install-iis


(The two levels of sub-commands seem a bit redundant. But consistency is 
nice. Then, should it be "create" instead of "install"?)



kallithea ishell   ishell

kallithea config create  make-config

kallithea index create   make-index -f (full)
kallithea index update  make-index(parameters to this
tool are unclear to me)

kallithea extensions create   make-rcext

kallithea db createsetup-db


(I agree 'create' is better than 'setup'. But still not spot-on, as it 
doesn't really create the database - in only populates it with tables 
and initial data. That should probably just be clarified in documentation.)



kallithea db upgradeupgrade-db

kallithea front-end create


(we need consistent spelling ;-) )


+subprocess.check_call(['npm', 'run', 'less'], cwd=rootdir)
+
+@frontend.command()
+@click.pass_context
+def create(ctx):
+"""Create the front-end completely"""
+ctx.invoke(install_deps)
+ctx.invoke(generate_css)

I was thinking that we maybe should make it more clear that the
'create' step is the master command that does everything, and the
other steps are just for finer control for power users. Not sure how
to do that best...


(discussed above)

/Mads


___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general


Re: [PATCH 2 of 3 PoC] cli: add commands to handle front-end generation

2018-09-26 Thread Thomas De Schampheleire
El mié., 26 sept. 2018 a las 13:00, Mads Kiilerich
() escribió:
>
> On 9/24/18 10:45 PM, Thomas De Schampheleire wrote:
> > # HG changeset patch
> > # User Thomas De Schampheleire 
> > # Date 1537814676 -7200
> > #  Mon Sep 24 20:44:36 2018 +0200
> > # Node ID b807b1e90e61d2c8c16c5e3ec5978ef7dd7a2d31
> > # Parent  dd4da443ed94fd93ca09d5f5fd9cf1b2c72b3cc4
> > cli: add commands to handle front-end generation
>
>
> It would be nice with examples of how to use it and what the user
> experience is.
>
> (It will probably also be obvious from the accompanying documentation
> changes.)
>
>
> > diff --git a/kallithea/bin/kallithea_cli.py b/kallithea/bin/kallithea_cli.py
> > --- a/kallithea/bin/kallithea_cli.py
> > +++ b/kallithea/bin/kallithea_cli.py
> > @@ -14,7 +14,11 @@
> >
> >   import click
> >
> > +from kallithea.bin.kallithea_cli_frontend import frontend
> > +
> >   @click.group()
> >   def cli():
> >   """Various commands to set up a Kallithea instance."""
> >   pass
> > +
> > +cli.add_command(frontend)
> > diff --git a/kallithea/bin/kallithea_cli_frontend.py 
> > b/kallithea/bin/kallithea_cli_frontend.py
> > new file mode 100644
> > --- /dev/null
> > +++ b/kallithea/bin/kallithea_cli_frontend.py
> > @@ -0,0 +1,52 @@
> > +# -*- 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 .
> > +
> > +import click
> > +import os
> > +import subprocess
> > +
> > +import kallithea
> > +
> > +rootdir = 
> > os.path.dirname(os.path.dirname(os.path.abspath(kallithea.__file__)))
> > +
> > +@click.group(name='front-end')
> > +def frontend():
> > +pass
>
>
> I haven't tested and don't know exactly how this shows up, but could it
> be confusing that this "sub command" "isn't the front-end itself", but
> just tooling for management/installation of the front-end?

Currently implemented CLI is as follows:

kallithea config create
kallithea frontend create

and the specific commands that 'frontend create' is wrapping:
kallithea frontend install-deps
kallithea frontend generate-css

The way I saw the conversion of existing commands:

kallithea cache-keys showcache-keys --show
kallithea cache-keys cleanup  cache-keys --cleanup

kallithea celery run  celeryd

kallithea repo cleanup   cleanup-repos
kallithea repo scan repo-scan
kallithea repo update-cache update-repoinfo
kallithea repo invalidate-cache   update-repoinfo --invalidatecache
(Not exactly sure about the difference between both, to be discussed)

kallithea iis install install-iis

kallithea ishell   ishell

kallithea config create  make-config

kallithea index create   make-index -f (full)
kallithea index update  make-index(parameters to this
tool are unclear to me)

kallithea extensions create   make-rcext

kallithea db createsetup-db
kallithea db upgradeupgrade-db

kallithea front-end create

>
>
> > +@frontend.command(name='install-deps')
> > +def install_deps():
> > +"""Install required dependencies"""
>
>
> I guess we should clarify that it is npm dependencies it is installing
> ... and that it thus needs npm.
>
> Especially, for a correct understanding of what is going on, it must be
> clear to the user that Python dependencies must be installed first ...
> and that the Python dependency installation doesn't cover this.
>

Ok


>
> > +click.echo("Running 'npm install' to install front-end dependencies 
> > from package.json\n")
> > +subprocess.check_call(['npm', 'install'], cwd=rootdir)
> > +
> > +@frontend.command(name='generate-css')
> > +def generate_css():
> > +"""Generate CSS files"""
> > +click.echo("\nGenerating pygments.css")
> > +with open(os.path.join(rootdir, 'kallithea', 'public', 'css', 
> > 'pygments.css'), 'w') as f:
> > +subprocess.check_call(['pygmentize',
> > +'-S', 'default',
> > +'-f', 'html',
> > +'-a', '.code-highlight'],
> > +stdout=f)
> > +
> > +click.echo("\nRunning 'npm run less' to generate CSS from LESS")
>
>
> The "less" command is our own custom command. That one should perhaps
> also be cleaned up, and more should be moved into this command?

Yes, I agree. It is doing:


Re: [PATCH 2 of 3 PoC] cli: add commands to handle front-end generation

2018-09-26 Thread Mads Kiilerich

On 9/24/18 10:45 PM, Thomas De Schampheleire wrote:

# HG changeset patch
# User Thomas De Schampheleire 
# Date 1537814676 -7200
#  Mon Sep 24 20:44:36 2018 +0200
# Node ID b807b1e90e61d2c8c16c5e3ec5978ef7dd7a2d31
# Parent  dd4da443ed94fd93ca09d5f5fd9cf1b2c72b3cc4
cli: add commands to handle front-end generation



It would be nice with examples of how to use it and what the user 
experience is.


(It will probably also be obvious from the accompanying documentation 
changes.)




diff --git a/kallithea/bin/kallithea_cli.py b/kallithea/bin/kallithea_cli.py
--- a/kallithea/bin/kallithea_cli.py
+++ b/kallithea/bin/kallithea_cli.py
@@ -14,7 +14,11 @@
  
  import click
  
+from kallithea.bin.kallithea_cli_frontend import frontend

+
  @click.group()
  def cli():
  """Various commands to set up a Kallithea instance."""
  pass
+
+cli.add_command(frontend)
diff --git a/kallithea/bin/kallithea_cli_frontend.py 
b/kallithea/bin/kallithea_cli_frontend.py
new file mode 100644
--- /dev/null
+++ b/kallithea/bin/kallithea_cli_frontend.py
@@ -0,0 +1,52 @@
+# -*- 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 .
+
+import click
+import os
+import subprocess
+
+import kallithea
+
+rootdir = os.path.dirname(os.path.dirname(os.path.abspath(kallithea.__file__)))
+
+@click.group(name='front-end')
+def frontend():
+pass



I haven't tested and don't know exactly how this shows up, but could it 
be confusing that this "sub command" "isn't the front-end itself", but 
just tooling for management/installation of the front-end?




+@frontend.command(name='install-deps')
+def install_deps():
+"""Install required dependencies"""



I guess we should clarify that it is npm dependencies it is installing 
... and that it thus needs npm.


Especially, for a correct understanding of what is going on, it must be 
clear to the user that Python dependencies must be installed first ... 
and that the Python dependency installation doesn't cover this.




+click.echo("Running 'npm install' to install front-end dependencies from 
package.json\n")
+subprocess.check_call(['npm', 'install'], cwd=rootdir)
+
+@frontend.command(name='generate-css')
+def generate_css():
+"""Generate CSS files"""
+click.echo("\nGenerating pygments.css")
+with open(os.path.join(rootdir, 'kallithea', 'public', 'css', 
'pygments.css'), 'w') as f:
+subprocess.check_call(['pygmentize',
+'-S', 'default',
+'-f', 'html',
+'-a', '.code-highlight'],
+stdout=f)
+
+click.echo("\nRunning 'npm run less' to generate CSS from LESS")



The "less" command is our own custom command. That one should perhaps 
also be cleaned up, and more should be moved into this command?


It is perhaps not so important that we generate from .less files. What 
really matters is that we generate from Kallithea source and npm package 
content (bootstrap) and perhaps user customization/configuration. (But 
ok, that bigger context might be covered by the previous "generating" 
message, and it is fine that this one just show actually is being run 
now ...)




+subprocess.check_call(['npm', 'run', 'less'], cwd=rootdir)
+
+@frontend.command()
+@click.pass_context
+def create(ctx):
+"""Create the front-end completely"""
+ctx.invoke(install_deps)
+ctx.invoke(generate_css)



/Mads

___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general


[PATCH 2 of 3 PoC] cli: add commands to handle front-end generation

2018-09-24 Thread Thomas De Schampheleire
# HG changeset patch
# User Thomas De Schampheleire 
# Date 1537814676 -7200
#  Mon Sep 24 20:44:36 2018 +0200
# Node ID b807b1e90e61d2c8c16c5e3ec5978ef7dd7a2d31
# Parent  dd4da443ed94fd93ca09d5f5fd9cf1b2c72b3cc4
cli: add commands to handle front-end generation

diff --git a/kallithea/bin/kallithea_cli.py b/kallithea/bin/kallithea_cli.py
--- a/kallithea/bin/kallithea_cli.py
+++ b/kallithea/bin/kallithea_cli.py
@@ -14,7 +14,11 @@
 
 import click
 
+from kallithea.bin.kallithea_cli_frontend import frontend
+
 @click.group()
 def cli():
 """Various commands to set up a Kallithea instance."""
 pass
+
+cli.add_command(frontend)
diff --git a/kallithea/bin/kallithea_cli_frontend.py 
b/kallithea/bin/kallithea_cli_frontend.py
new file mode 100644
--- /dev/null
+++ b/kallithea/bin/kallithea_cli_frontend.py
@@ -0,0 +1,52 @@
+# -*- 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 .
+
+import click
+import os
+import subprocess
+
+import kallithea
+
+rootdir = os.path.dirname(os.path.dirname(os.path.abspath(kallithea.__file__)))
+
+@click.group(name='front-end')
+def frontend():
+pass
+
+@frontend.command(name='install-deps')
+def install_deps():
+"""Install required dependencies"""
+click.echo("Running 'npm install' to install front-end dependencies from 
package.json\n")
+subprocess.check_call(['npm', 'install'], cwd=rootdir)
+
+@frontend.command(name='generate-css')
+def generate_css():
+"""Generate CSS files"""
+click.echo("\nGenerating pygments.css")
+with open(os.path.join(rootdir, 'kallithea', 'public', 'css', 
'pygments.css'), 'w') as f:
+subprocess.check_call(['pygmentize',
+'-S', 'default',
+'-f', 'html',
+'-a', '.code-highlight'],
+stdout=f)
+
+click.echo("\nRunning 'npm run less' to generate CSS from LESS")
+subprocess.check_call(['npm', 'run', 'less'], cwd=rootdir)
+
+@frontend.command()
+@click.pass_context
+def create(ctx):
+"""Create the front-end completely"""
+ctx.invoke(install_deps)
+ctx.invoke(generate_css)
___
kallithea-general mailing list
kallithea-general@sfconservancy.org
https://lists.sfconservancy.org/mailman/listinfo/kallithea-general