openhab-scripters / openhab-helper-libraries

Scripts and modules for use with openHAB
Eclipse Public License 1.0
88 stars 70 forks source link

Add Javascript libraries #120

Closed 5iver closed 5 years ago

5iver commented 5 years ago

Continuation of https://github.com/lewie/openhab2-javascript/issues/4 now that #94 is complete

@lewie, how would you like to proceed? Would you like me to get things copied over first, using the new directory structure, or would you prefer to do that yourself? I've already added startup delay scripts, and I have a JS OSGI library to add too.

Confectrician commented 5 years ago

Throwing in my offer to help again, but lets wait for lewie to share his ideas. 🙂

lewie commented 5 years ago

@openhab-5iver, It would help me if you made the first move, Thanks.

For the move, please use the version I already adapted for org.openhab.core: https://github.com/lewie/openhab2-javascript/tree/smarthome-To-openhab.core

@Confectrician, don't let me stop you from developing. Get started!

5iver commented 5 years ago

@lewie, I'm ready to push a commit, but noticed your copyrights. Would you mind if this was changed to be more generic, as is used in the openHAB statement?

Copyright (c) 2019 Contributors to the openHAB Scripters project

Created PR #124. There is still testing to do, but I'd like to get it into the repo so that others can test too.

lewie commented 5 years ago

@openhab-5iver, cool, LGTM! merge! Thank You very much!

I can also correct the header after the move. But it would be nice if something about me as the original author would be preserved.

Sure, it's just only a script, but I'd like to know who to contact if I have any questions for example.

Not specifically related to my files, what do you think about headers? Duty or voluntary, what is minimal required? Is a simple license hint still missing for scripts? Or at least what do we recommend to the developers?

The minimum that I would also require from example files:

/**
 * @copyright (c) 2019 Contributors to the openHAB Scripters project
 * @author Helmut Lehmeyer <helmut.lehmeyer@gmail.com> - initial contribution.
 */

Later, when we have created order for the core classes, would I include a description and the origin in the class? Like:

/**
 * @copyright (c) 2019 Contributors to the openHAB Scripters project
 * @license http://www.eclipse.org/legal/epl-2.0
 * @package openhab-helper-libraries - javascript
 * @author Helmut Lehmeyer <helmut.lehmeyer@gmail.com> - initial contribution.
 *
 * @description: 
 * JSR223 JavaScript scripting extensions and helper classes
 * for simplifying the definition of rules with JavaScript Code used in openHAB 2.x.
 *
 */
5iver commented 5 years ago

I can also correct the header after the move. But it would be nice if something about me as the original author would be preserved.

Sure, it's just only a script, but I'd like to know who to contact if I have any questions for example.

Absolutely understood. I did a second commit that changed the copyright, so I could easily pull it if you wanted to keep it as is. The author tags are still there and I plan to get author tags in all the files. Documentation too, but that may need to be handled differently than with the Jython helper libraries (JythonHLs? :slightly_smiling_face:). In my head, I tied that all in with adding versioning (#71), since it would mean touching all the files, but it would be best break this out into updating the files (copyright, license, author, version) and then use #71 for the actual version checking, notifying, etc.

Not specifically related to my files, what do you think about headers? Duty or voluntary, what is minimal required?

IMO definitely needed and should be required. We can catch these in the PRs. An automated check could be added if/when the contributions increase.

Is a simple license hint still missing for scripts? Or at least what do we recommend to the developers?

Yes. I think adopting the OH guidlines would be fitting (stock header with copyright and license, a main description with author tags, and documentation for classes and methods, etc. A formatter would be nice too (I think someone setup the OH one in VS Code).

I'll add some issues to continue this discussion. Could you please give me your thoughts on the suggestions over in #124? It would be easier/cleaner to just get those changes in now so that additional PRs aren't needed.

besynnerlig commented 5 years ago

I believe that adding the javascript libraries has to do with that I'm now getting double startup delays. Not that another delay matters for me but ...

2019-05-25 15:19:44.919 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'javascript/core/000_startup_delay.js'
2019-05-25 15:19:45.012 [INFO ] [jsr223.javascript.core.startup_delay] - Checking for initialized context
2019-05-25 15:19:45.025 [INFO ] [jsr223.javascript.core.startup_delay] - Context initialized... waiting 30s before allowing scripts to load
2019-05-25 15:20:15.035 [INFO ] [jsr223.javascript.core.startup_delay] - Complete
2019-05-25 15:20:15.036 [INFO ] [rt.internal.loader.ScriptFileWatcher] - Loading script 'python/core/000_startup_delay.py'
5iver commented 5 years ago

I believe that adding the javascript libraries has to do with that I'm now getting double startup delays.

Yes... each language has a startup delay. I haven't thought of a way to prevent this.