Skip to content

Commit

Permalink
Merge pull request #6 from noelmcloughlin/edition
Browse files Browse the repository at this point in the history
fix(edition): better edition jinja code
  • Loading branch information
noelmcloughlin authored Jun 15, 2020
2 parents 771f394 + 3a6f3ba commit 1b2ff6d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion clion/archive/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ clion-package-archive-clean-file-absent:
file.absent:
- names:
- {{ clion.pkg.archive.path }}
- /usr/local/jetbrains/clion-{{ clion.edition }}-*
- /usr/local/jetbrains/clion-*
2 changes: 1 addition & 1 deletion clion/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ clion-config-clean-file-absent:
{%- if grains.kernel|lower == 'linux' %}
- {{ clion.linux.desktop_file }}
{%- elif grains.os == 'MacOS' %}
- {{ clion.dir.homes }}/{{ clion.identity.user }}/Desktop/{{ clion.pkg.name }}{{ ' %sE'|format(clion.edition) if clion.edition else '' }} # noqa 204
- {{ clion.dir.homes }}/{{ clion.identity.user }}/Desktop/{{ clion.pkg.name }}{{ '' if 'edition' not in clion else ' %sE'|format(clion.edition) }} # noqa 204
{%- endif %}
- require:
- sls: {{ sls_package_clean }}
2 changes: 1 addition & 1 deletion clion/config/environ.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clion-config-file-file-managed-environ_file:
- template: jinja
- context:
{%- if clion.pkg.use_upstream_macapp %}
path: '/Applications/{{ clion.pkg.name }}{{ '\ %sE'|format(clion.edition) }}.app/Contents/MacOS'
path: '/Applications/{{ clion.pkg.name }}{{ '' if 'edition' not in clion else '\ %sE'|format(clion.edition) }}.app/Contents/MacOS' # noqa 204
{%- else %}
path: {{ clion.pkg.archive.path }}/bin
{%- endif %}
Expand Down
2 changes: 1 addition & 1 deletion clion/config/shortcut.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ clion-config-file-file-managed-desktop-shortcut_file:
- template: jinja
- context:
appname: {{ clion.pkg.name }}
edition: {{ clion.edition|json }}
edition: {{ '' if 'edition' not in clion else clion.edition|json }}
command: {{ clion.command|json }}
{%- if clion.pkg.use_upstream_macapp %}
path: {{ clion.pkg.macapp.path }}
Expand Down
4 changes: 2 additions & 2 deletions clion/files/default/shortcut.desktop.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Encoding=UTF-8
Name={{ appname }}{{ ' %sE'|format(edition) if edition else '' }}
Comment={{ appname }}{{ ' %sE'|format(edition) if edition else '' }}
Name={{ appname }}{{ '' if not edition else ' %sE'|format(edition) }}
Comment={{ appname }}{{ '' if not edition else ' %sE'|format(edition) }}
Icon={{ path }}/{{ command.split('.')[0] }}.png
Exec={{ path }}/{{ command }}
Terminal=false
Expand Down
2 changes: 1 addition & 1 deletion clion/files/mac_shortcut.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

Source="/Applications/{{ appname }}{{ ' %sE'|format(edition) if edition else '' }}.app"
Source="/Applications/{{ appname }}{{ '' if not edition else ' %sE'|format(edition) }}.app"
Destination="{{ homes }}/{{ user }}/Desktop"
/usr/bin/osascript -e "tell application \"Finder\" to make alias file to POSIX file \"$Source\" at POSIX file \"$Destination\""
2 changes: 1 addition & 1 deletion clion/macapp/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ clion-macos-app-clean-files:
file.absent:
- names:
- {{ clion.dir.tmp }}
- /Applications/{{ clion.pkg.name }}{{ ' %sE'|format(clion.edition) if clion.edition else '' }}.app
- /Applications/{{ clion.pkg.name }}{{ '' if not edition else ' %sE'|format(edition) }}.app
{%- else %}
Expand Down
2 changes: 1 addition & 1 deletion clion/macapp/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ clion-macos-app-install-macpackage:
- template: jinja
- context:
appname: {{ clion.pkg.name }}
edition: {{ clion.edition }}
edition: {{ '' if 'edition' not in clion else clion.edition }}
user: {{ clion.identity.user }}
homes: {{ clion.dir.homes }}
cmd.run:
Expand Down
36 changes: 20 additions & 16 deletions clion/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@
)
)
%}
{%- set clion = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %}
{%- set c = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %}

{%- set pcode = clion.product ~ clion.edition if clion.edition else clion.product %}
{%- set jdata = salt['cmd.run']('curl -s -L {0}{1}'.format(clion.pkg.archive.uri, pcode))|load_yaml %}
{%- do clion.update({ 'version': jdata[ pcode ][0]['version'] }) %}
{%- set edition = '' if 'edition' not in c else c.edition %}
{%- set pcode = c.product ~ edition %}
{%- set jdata = salt['cmd.run']('curl -s -L {0}{1}'.format(c.pkg.archive.uri, pcode))|load_yaml %}
{%- do c.update({ 'version': jdata[ pcode ][0]['version'] }) %}

{%- set dirname = 'clion-%s-%s'|format( clion.edition if clion.edition else '', clion.version) %}
{%- set url = jdata[ pcode ][0]['downloads'][ clion.flavour ]['link'] %}
{%- set hash = salt['cmd.run']('curl -L -s {0}'.format( jdata[ pcode ][0]['downloads'][ clion.flavour ]['checksumLink'])).split(' ')[0] %} # noqa 204
{%- set dirname = 'c-%s-%s'|format( edition, c.version) %}
{%- set url = jdata[ pcode ][0]['downloads'][ c.flavour ]['link'] %}
{%- set hash = salt['cmd.run']('curl -L -s {0}'.format( jdata[ pcode ][0]['downloads'][ c.flavour ]['checksumLink'])).split(' ')[0] %} # noqa 204

{%- if clion.pkg.use_upstream_archive %}
{%- do clion.pkg.archive.update({'name': clion.dir.archive ~ '/' ~ dirname,
'path': clion.dir.archive ~ '/' ~ dirname,
'source': url,
'source_hash': hash }) %}
{%- if c.pkg.use_upstream_archive %}
{%- do c.pkg.archive.update({'name': c.dir.archive ~ '/' ~ dirname,
'path': c.dir.archive ~ '/' ~ dirname,
'source': url,
'source_hash': hash }) %}
{%- endif %}

{%- if clion.pkg.use_upstream_macapp %}
{%- do clion.pkg.macapp.update({
'name': '/Applications', 'path': '/Applications', 'source': url, 'source_hash': hash }) %}
{%- if c.pkg.use_upstream_macapp %}
{%- do c.pkg.macapp.update({'name': '/Applications',
'path': '/Applications',
'source': url,
'source_hash': hash }) %}
{%- endif %}

{%- set clion = c %}
20 changes: 10 additions & 10 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Available states
:local:

``clion``
^^^^^^^
^^^^^^^^^

*Meta-state (This is a state that includes other states)*.

Expand All @@ -64,28 +64,28 @@ manages Clion configuration file and then
configures the development environment.

``clion.archive``
^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^

This state will install Clion from archive only.

``clion.macapp``
^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^

This state will install Clion from source only.

``clion.config``
^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^

This state will configure npmrc and/or environment and has a dependency on ``clion.install``
via include list.

``clion.linuxenv``
^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^

This state will install some Clion linux-alternatives on GNU/Linux.

``clion.clean``
^^^^^^^^^^^^^
^^^^^^^^^^^^^^^

*Meta-state (This is a state that includes other states)*.

Expand All @@ -94,25 +94,25 @@ removes the configuration file and
then uninstalls the package.

``clion.config.clean``
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^

This state will remove the configuration of Clion and has a
dependency on ``clion.package.clean`` via include list.

``clion.archive.clean``
^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^

This state will remove Clion package and has a dependency on
``clion.config.clean`` via include list.

``clion.macapp.clean``
^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^

This state will remove Clion package and has a dependency on
``clion.config.clean`` via include list.

``clion.linuxenv.clean``
^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^

This state will remove Clion linux-alternatives on GNU/Linux.

Expand Down

0 comments on commit 1b2ff6d

Please sign in to comment.