migrations
migrations copied to clipboard
config as YAML
Hooks seem like a really cool and powerful feature. But the config syntax is a bit messy:
hook_after_down=JavaScript:printvar.js:when=after:what=down
would be much more inuitive as YAML:
events:
hook_after_down:
hooks:
- script: printvars.js
type: javascript
properties:
when: after
what: down
Also, declaring JavaScript is redundant if you go by convention: .js or Groovy as .groovy
Hi @chb0github ,
YAML might be nice, but not nice enough to complicate the implementation, but this is my personal opinion. I appreciate your feedbacks and ideas, so please do not get me wrong. :)
declaring JavaScript is redundant if you go by convention: .js or Groovy as .groovy
The language name is declared by each implementation and Migrations just calls ScriptEngineManager#getEngineByName().
In case of JavaScript, both javascript and js should work.
As I read into the spec I realized exactly how this is implemented: Just taken the name given and ask the factory for the script engine with that name:
Try this:
public class A {
public static void main( String[] args ) {
ScriptEngineManager mgr = new ScriptEngineManager();
List<ScriptEngineFactory> factories = mgr.getEngineFactories();
for (ScriptEngineFactory factory : factories) {
System.out.println("ScriptEngineFactory Info");
String engName = factory.getEngineName();
String engVersion = factory.getEngineVersion();
String langName = factory.getLanguageName();
String langVersion = factory.getLanguageVersion();
System.out.printf("\tScript Engine: %s (%s)%n", engName, engVersion);
List<String> engNames = factory.getNames();
for(String name : engNames) {
System.out.printf("\tEngine Alias: %s%n", name);
}
System.out.printf("\tLanguage: %s (%s)%n", langName, langVersion);
}
}
}
Gives you this:
cbongiorno@dvm-cbongiorno1:~$ java A
ScriptEngineFactory Info
Script Engine: Oracle Nashorn (1.8.0_144)
Engine Alias: nashorn
Engine Alias: Nashorn
Engine Alias: js
Engine Alias: JS
Engine Alias: JavaScript
Engine Alias: javascript
Engine Alias: ECMAScript
Engine Alias: ecmascript
Language: ECMAScript (ECMA - 262 Edition 5.1)
Any of those Aliases would work.
The documentation is a bit incomplete - So, I guess then my only ask would be to update the docs a bit to make clear it's the the Engine alias (you can even paste the above code so people can interrogate their system if trying to use other scripts)
The question to ask yourself about a feature request: Is it about having pretty code or a bad-ass app? I mean, I am evaluating the app, not the code. I am probably submit a PR for the job if it's gonna make it in
@chb0github I've been considering allowing configurations to be handled differently for a while, including allowing overrides (would be great for different environments that mostly share the same values) and allowing different configuration syntax so a PR would definitely be interesting. As with any PR, we can't guarantee that it would make it in but at least it opens the discussion.
Is Java 8 allowed?