liferay / liferay-theme-tasks

A set of tasks for building and deploying Liferay Portal themes.
18 stars 24 forks source link

Including Build version/number into the theme war file and war file name #17

Closed maartenvh closed 7 years ago

maartenvh commented 8 years ago

Hi Robert & Nate,

I'm really happy with this project and how this enables us the rapidly develop themes.

However I would like to request some features regarding the build functionality.

Currently when I run the gulp build command a theme is created and placed into the dist folder. But this is always the same in terms of name & version. Unless you change the package.json. But this is not shown in the portal or the actual file name etc.

Would it be possible to have a build option where if you as a developer are done with the current task and you want to actually deliver the package you can give a build:[abcd] command which updates the package.json regarding the version number and and also includes this into the actual package name? So the package name could become: my-theme-6210-1.0.1.war or an other name convention option where the version of the server is included as well as the version.

So there is a difference for actually saving the file and thus the theme (gulp watch) and delivering the package to QA or delivery etc.

In light of this it would be nice to also be able to include a comment on this build command which would be stored in the package.json or a different object. (but this is totally a nice to have feature.)

Best regards, Maarten

robframpton commented 8 years ago

Hey Maarten,

Thanks for the feedback. I think we can definitely add more custom functionality to the gulp build/release process. We have a few ideas as to how to implement this functionality, but wanted to see if they are a good solution for your workflow.

One idea is to provide a configuration property that allows theme devs to specify a custom template for the filename of the released theme. So as an example, something like...

filenameTemplate: "{themeName}-{liferayVersion}-{themeVersion}"
// would return my-theme-6.2.10-1.0.1.war

That way theme devs can easily configure the name. This property would most likely exist in the theme's package.json. We could also create an environment variable you can set, so that you wouldn't have to set this property in every theme's package.json.

In regards to bumping the package.json version number, I would recommend using the npm version command, which bumps the version number and adds a git commit/tag for that version.

Let me know what you think,

maartenvh commented 8 years ago

Hi Robert

The npm version could indeed be used for the internal versioning in the package.json. This I already use.

In regards of the filenameTemplate I think this would work. It is corresponding to all major elements I need to be able to set. And combined with the npm version we would have a working solution.

Thanks & best Maarten

phancox commented 8 years ago

The version number set in "package.json" seems to be ignored completely. The portal always says this is theme version 7.0.1 when I'm generating and running for that version of the portal.

Is the version number relevant (but just hidden), or really not used?

robframpton commented 8 years ago

Hi @phancox

The version number in the package.json is used by npm. This number is necessary if you were to publish your theme as an npm package, every time you publish to npm you must increment this number.

It is possible to use this number in the name of the war file by using the distname setting, however when you deploy it via the deploy directory Portal will use the name of the war file as the context path of the theme. The result is if you deploy your theme with one version number and then again after incrementing, they will show up as two separate themes.

phancox commented 8 years ago

I'm using "gulp deploy" to build the distribution package. Is the version setting in "package.json" ignored in that case?

Which of npm or gulp is the preferred approach to building and deploying?

natecavanaugh commented 8 years ago

Hi @phancox Npm and gulp serve different purposes (with some very very minor overlap[0]).

NPM is the package manager and registry for node.js modules, so if you wish to share your theme, the package.json will act as the metadata for your module hosted on NPM.

Gulp is a task runner, and the deploy task is the task that compiles everything together and pushes it to your app server.

The version number in your theme's package.json is not really relevant to the portal, so it won't be used for anything.

If you DO wish to have it included in the name of the deployed war file, you can follow the instructions @Robert-Frampton linked to.

If you don't care about the name of your theme containing that version, then you don't need to do much.

Hopefully that helps, but of course, feel free to let us know if there's something we didn't cover.


[0] The only area where gulp and npm overlap is the fact that the npm command allows you to define scripts inside of your package.json, which you can run by doing something like npm run test. Gulp, however, is a much more powerful task runner that allows us to easily stream files through our processes and build the theme. You will only be able to run deploy with gulp, so currently, you won't be able to build with npm run deploy (unless you create a script yourself for it, but it kind of defeats the purpose :))

phancox commented 8 years ago

Thanks for the explanation.

When I run the "App Manager" in the portal and look at the Modules entry for my theme, it reports "Version: 7.0.1". Where does that version number come from? Is it the same for all themes built with a particular version of the build tools?

robframpton commented 7 years ago

Hey @phancox

Sorry for the delayed response.

It used to be that the theme version you found in the App Manager would just come from the Portal itself, but with the latest release of liferay-theme-tasks the theme version will now be pulled from the package.json file. So bumping the version in your package.json should result in a bump in the version in App Manager.

Hope that helps!