Skip to content

Conversation

fcastilloec
Copy link
Collaborator

For both .ejs files, I've removed all unnecessary if statements, based on options that do have a default so they won't be undefined.
For spec.ejs, I'm trying to follow this guide and some other conventions.
One of the requirements, keeping two lines between sections, it's impossible to follow when using lodash. We would have to switch to ejs in order to fine control the spacing between sections.

@fcastilloec fcastilloec requested a review from malept July 10, 2020 02:52
@fcastilloec fcastilloec marked this pull request as draft July 10, 2020 04:19
@malept malept mentioned this pull request Jul 10, 2020
@fcastilloec
Copy link
Collaborator Author

I've decided to close this PR. The goal was to make .ejs files more readable and to adhere to conventions regarding the SPEC file. This is not possible if using lodash. We can make our code very readable, but that would make the SPEC file way out of line from conventions. If trying to comply with conventions, the ejs files will become less readable; and it's virtually impossible to 100% comply with conventions using lodash (regardless of readability), a different library is needed for this.
The current code it's not perfect, but it's working. Unless we change -common to use ejs for templates, this PR is unnecessary.

@fcastilloec
Copy link
Collaborator Author

fcastilloec commented Jul 21, 2020

I'm reopening this PR. With some help from others, I'm using the function print, which is built into lodash, to better control inserting an empty line.
The new code is much more readable, and it always adheres to the guidelines.

@malept it's ready for review

@fcastilloec fcastilloec reopened this Jul 21, 2020
@fcastilloec fcastilloec marked this pull request as ready for review July 21, 2020 18:28
Copy link
Member

@malept malept left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine. Can you give some examples of what the generated desktop/spec files look like?

Co-authored-by: Mark Lee <malept@users.noreply.github.com>
@fcastilloec
Copy link
Collaborator Author

fcastilloec commented Jul 22, 2020

Here's an example of how the output will look like with :

{
  name: 'name',
  compressionLevel: 2,
  version: 3,
  revision: 1,
  productName: 'productName',
  genericName: 'genericName',
  description: 'description',
  productDescription: 'prodDesc',
  license: 'license',
  homepage: 'http://homepage.com',
  requires: ['r1', 'r2'],
  execArguments: undefined,
  categories: ['c1', 'c2', 'c3'],
  mimeType: ['m1', 'm2'],
  icon: 'test/fixtures/scaled-icon.png',
  pre: 'pre',
  preun: 'preun',
  post: 'post',
  postun: 'postun'
}
%define _binary_payload w2.xzdio

Name: name
Version: 3
Release: 1%{?dist}
Summary: description

License: license
URL: http://homepage.com

Requires: r1, r2
AutoReqProv: no

%description
prodDesc


%install
mkdir -p %{buildroot}/usr/
cp -r usr/* %{buildroot}/usr/


%files
/usr/bin/name
/usr/lib/name/
/usr/share/applications/name.desktop
/usr/share/doc/name/
/usr/share/pixmaps/name.png


%pre
pre


%preun
preun


%post
post


%postun
postun

The spacing between sections will stay the same, even if any of the optional sections are undefined.

@fcastilloec
Copy link
Collaborator Author

Another example:

{
  name: 'name',
  compressionLevel: 2,
  version: 3,
  revision: 1,
  productName: 'productName',
  genericName: 'genericName',
  description: undefined,
  productDescription: undefined,
  license: undefined,
  homepage: 'http://homepage.com',
  requires: ['r1', 'r2'],
  execArguments: undefined,
  categories: ['c1', 'c2', 'c3'],
  mimeType: ['m1', 'm2'],
  icon: 'test/fixtures/scaled-icon.png',
  pre: undefined,
  preun: 'preun',
  post: undefined,
  postun: undefined
}
%define _binary_payload w2.xzdio

Name: name
Version: 3
Release: 1%{?dist}

URL: http://homepage.com

Requires: r1, r2
AutoReqProv: no

%install
mkdir -p %{buildroot}/usr/
cp -r usr/* %{buildroot}/usr/


%files
/usr/bin/name
/usr/lib/name/
/usr/share/applications/name.desktop
/usr/share/doc/name/
/usr/share/pixmaps/name.png


%preun
preun

@malept
Copy link
Member

malept commented Jul 22, 2020

Any difference in how the .desktop files are rendered?

@fcastilloec
Copy link
Collaborator Author

fcastilloec commented Jul 22, 2020

Any difference in how the .desktop files are rendered?

There's no difference for that one. The changes there better show which arguments are optional, and which ones are mandatory

@malept malept merged commit 603172b into master Jul 22, 2020
@malept malept deleted the ejs-fixes branch July 22, 2020 03:02
@fcastilloec fcastilloec mentioned this pull request Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants