This is a migrated thread and some comments may be shown as answers.

How to ensure that license is valid during build?

5 Answers 4324 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Veteran
Christian asked on 16 Nov 2020, 08:03 AM

 

We recently upgraded to Kendo React 4.0.0 and introduced kendo-ui-licence. 

I want to make sure that future developers do not deploy a release with an invalid license. Console outputs on the deployed application will not get noticed.

What is the best practice to do that?

I would say the build has to fail if there is an invalid license. The documentation says: "A post-install script in @progress/kendo-licensing will automatically activate the license during installation." What does "post-install script" mean? Is this automatically triggered when I run `npm install` on my project? And will it fail if the license became invalid? And what's the impact of having some kind of npm caching mechanism (i.e. https://samiprogramming.medium.com/cache-your-npm-install-on-azure-devops-b45ead758c00)? Would it make sense to call `npx kendo-ui-license activate` explicitly so that it fails when the license is no longer valid?

 

5 Answers, 1 is accepted

Sort by
0
Christian
Top achievements
Rank 1
Veteran
answered on 16 Nov 2020, 08:25 AM

Just checked. The build is indeed failing when executing ``npm install`. 

Do you recommend to call `npx kendo-ui-license activate` explicitly in case there is some caching mechanism in place for the `npm install` step?

 

0
T. Tsonev
Telerik team
answered on 16 Nov 2020, 04:10 PM

Hi Christian,

Package post-install scripts run on "npm install". Currently, the script for kendo-licensing executes "kendo-ui-license activate" for convenience. It does not fail if a license is missing.

That said, your suggestion is very reasonable. It should be possible to assert that a license has been imported at build-time.

To make this possible, we've decided to change the behavior of the "kendo-ui-license activate" command. It would return a non-zero value when the license is missing. You need to execute it as part of your build script to assert that the activation is successful. The post-install script would still succeed to avoid breaking "npm install".

Caching does not affect the result from the "activate" operation.

These changes are not yet deployed. You can try them out by installing the development version of kendo-licensing: "npm install --save @progress/kendo-licensing@dev".

You should not see failures when running "npm install", at least not due to the license check. What is the error message that you see?

Best Regards,
T. Tsonev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Christian
Top achievements
Rank 1
Veteran
answered on 16 Nov 2020, 05:12 PM
This is the log returned by `npm install`. It is executed as one step in an Azure DevOps pipeline - and it breaks when there is an invalid license file (I just removed one character from the license file):

```
> @progress/kendo-licensing@1.0.2 postinstall C:\agent-d\_work\4\s\Sources\Tra\Mistra.Tra.Web.React\node_modules\@progress\kendo-licensing
> node ./bin/kendo-ui-license.js activate
(INFO) Kendo UI: Reading license from "C:\agent-d\_work\4\s\Sources\Tra\Mistra.Tra.Web.React\kendo-ui-license.txt"...
(ERROR) Kendo UI: License key signature is not valid. Please, download a new copy of the license and try again.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 4294967286
npm ERR! @progress/kendo-licensing@1.0.2 postinstall: `node ./bin/kendo-ui-license.js activate`
npm ERR! Exit status 4294967286
npm ERR!
npm ERR! Failed at the @progress/kendo-licensing@1.0.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\SVC_TfsBuild\AppData\Roaming\npm-cache\_logs\2020-11-16T08_18_39_471Z-debug.log
```
0
Christian
Top achievements
Rank 1
Veteran
answered on 16 Nov 2020, 05:15 PM
`npm install` itself is not failing, it just does not exit with exit code 0. And this makes the pipeline step fail.

Thanks for the information anyway.
0
T. Tsonev
Telerik team
answered on 17 Nov 2020, 12:06 PM

Hello,

Yes, this is correct—the command will return an error code in case of an invalid license.

We've released the updated @progress/kendo-license package (v1.1.0) that implements the new behavior.
It will now fail (return error code) if you execute `npx kendo-ui-license activate` as a part of the build pipeline.

Best Regards,
T. Tsonev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Christian
Top achievements
Rank 1
Veteran
Answers by
Christian
Top achievements
Rank 1
Veteran
T. Tsonev
Telerik team
Share this question
or