Is there a replacement for Bixby JavaScript API module textLib? - bixby

The Bixby Import and search template uses a library module textLib which throws an error due to the library having been deprecated. The template uses a javascript file named "transaction_util.js" that requires the library via var textLib = require('textLib'). The library contains functions that were used for various text-related functions for fuzzy matching.
Is there a replacement module or a workaround for this?

Sorry for the inconvenience. We had an emergency update to the template capsule. You can try it now and should use externalTextLib which is included in the template.
If you already started your coding, you may want to create a new template capsules, copy and paste code/lib/externalTextLib.js to your existing capsule and change the line to var textLib = require('externalTextLib'), which should work without any additional coding change.
Or start a new project with the new template. It might be a safer option.

Related

Revit API: NewFamilyDocument - where to get the template?

My code doc.Application.NewFamilyDocument(template_path); requires a path to a Revit family template. Currently we made a copy of, say "Metric Mass.rft" and redistribute this.
Is there a way to either/or
get the default path for these family templates
create a family document without the template
instead?
The default library paths are accessible via the GetLibraryPaths method. For examples of using it, please refer to the Revit SDK samples, e.g., RoutingPreferenceTools, UIAPI, RevitCommands, and The Building Coder samples external command CmdLibraryPaths, described in the article on Library Paths
.

How to rename an existing Hybris extension

I am working on Hybris and I generated a new extension using hybris command (ant extgen) with default settings. During extension generation, I did not change default values like I let the project name to be "training". I started developing some code just for the sake of trying it but now I wrote quite a lot of code and instead of generating a new extension, I am trying to rename "training" to a new name which is more suitable for my project.
My question is - Is there any shortcut to rename "training" to a new name. By rename I don't mean standard intellij or eclipse module rename but also updating all extension specific properties which are referring to extension name "training". Is there any hybris ant command for it?
Here is the way I can think of.
You can declare your extension as a template for extgen and then generate a new extension based on it with a new name and structure.
Let me take training as your current extension which you want to convert to some other name. Below are the steps you need to perform.
Make sure your extension (training) is there in the localextensions.xml
Update extensioninfo.xml to mark the extension as a template by adding below meta tag
<meta key="extgen-template-extension" value="true"/>
Look like
<coremodule generated="true" manager="org.training.jalo.TrainingManager" packageroot="org.training"/>
<meta key="extgen-template-extension" value="true"/>
<webmodule jspcompile="false" webroot="/training"/>
Create an extgen.properties inside training extension/folder with below properties
Please note, If your current extension is with a different name then training in that case you need to change below values accordingly.
extgen.properties:
YEXTNAME_TOKEN=training
YMODULE_TOKEN=training
YMODULE_PACKAGE_ROOT=training
YMODULE_CLASS_PREFIX=training
YPACKAGE_TOKEN=org.training
YMANAGER_TOKEN=TrainingManager
YCLASSPREFIX_TOKEN=Training
YGENERATED_TOKEN=Generated
Run ant extgen and select your extension (training) from the given selection option and give the name and package the way you want when it prompt for it.
Now replace training extension with the newly created extension inside localextensions.xml
Test and patch wherever needed! :-)
I don't think so. It might also be easier just to create a new one and move the code into the new extension.
No it is not possible. The generated extension itself was created from a template where the word "training" is inserted into many places (class names, package names, configurations...) .
The other approach would be to look into the ext-template folder (6.7). There are all templates. Search for any token in the templates and make appropriate change in your generated extensions.
Depending on the amount of your extensions, it will also take some time... and you need to understand how extgen works, first.

Best template engine for generate javascript from Node.js

For me, to produce HTML or XML, pug is favorite one.
However, when the expected result is not based on mark up language, I used to use Handlebars. But When I produce javascript dynamically using handlebar, It makes very difficulties to maintain templates and terrible readability to keep generated code pretty.
When I do same thing with java, I prefer to use Xtend.
Is there any template engine that is intended to generate code?
(which is not based on AST)
Full Scenario
I made a Java Script library using TypeScript.
To make Eclipse's Java Script type inference engine can support content assist for this library, I needed to create some TS to JS-skeleton trans-compiler. (result js just contains scheme and js-doc for Eclipse JS capability)
I used type-script from NPM to inspect library scheme.
I transformed TypeScript AST to my own purpose model to generate JavaScript files.
Then I need to generate Java Script files from this model, And I'm looking for best template engine.
The template engine should be easy to manage indent, iteration, conditional templates to generate clear code with readable template.

Resharper SDK - Create File

I'm attempting to make a Resharper plugin to help do some specialized refactoring on a project I've got.
The gist of it is that I have a static function in a class and I want to create a new class and move the static function into it.
I thought it was going to be much more straightforward but I'm having difficulty finding examples or starting points in the SDK documentation.
Specifically, I can't figure out how to create a new file contains a new class. While I can't say for certain, I feel like I've run across a couple of examples of creating a new class (though I ignored them at the time because I was hung up on this new file thing).
Does anyone know the magic words to make the ReSharper SDK create this new file?
Creating a new file can be as simple as CSharpElementFactory.CreateFile but you might also want to consider using a refactoring instead. What you can do is create your new class, put the method in there, add it to the current file and then execute MoveIntoMatchingFilesRefactoring.

How can I perform Search&Replace on an XML file after WIX installation?

After installing my files using WIX 3.5 I would like to changes some values in one of my xml files.
Currently there are multiple entries like this:
<endpoint address="net.tcp://localhost/XYZ" .../>
I would like to change the localhost to the real servername wich is available due to a property. How can I perform this replacement on each entry inside this xml file? Is there a way to do this without writing an own CA?
Thanks in advance!
XmlConfig and/or XmlFile elements are your friends here.
UPDATE: Well, according to the comments below, it turns out that only part of the attribute (or element) value should be changed. This seems not to be supported by either of two referenced elements.
I would take one of the two approaches then:
Use third-party "read XML" actions, like this one
It's better than creating your own because you can rely on deeper testing in this case
Teach your build script to control the string pattern
Let's say you put `net.tcp://localhost/XYZ` to build file and your code is pointed out to take this value as a string pattern to use at install time. For instance, keep the string pattern as a Property in your MSI package. When it changes, e.g. to `net.tcp://localhost/ABC` you'll have to change nothing in your action. In this case from a XMLFile perspective you always know your FROM and TO attribute values.
If your XML configuration file is not large, you can load the file into memory and perform replace using JScript.
var s = "<endpoint address=\"net.tcp://localhost/XYZ\" .../>";
var re = /"net.tcp:\/\/localhost\//g;
var r = s.replace(re, "\"http://newhost.com/");
Here s is your complete XML file, re is the regular expression, and r would contain the result or replace.
You can read and write to public properties of Windows Installer using JScript. Yet there's still one problem: you have to read your XML file and to write it back to disk. To do it, you can use Win32_ReadFile and Win32_WriteFile custom actions from the AppSecInc. MSI Extensions library referenced by Yan in his answer.
However, it could be easier to write a complete Custom Action which will load your XML configuration file, do the replace, and write the file back to disk. To do it you can use XSLT and JScript (see an example code).
InstallShield has a built-in data driven custom action called Text Search. It basically allows for RegEx style replacements like what you are describing.
WiX doesn't have this functionality but you could write a custom action ( say using C#/DTF ) to do it for you.
There nothing in Wix, you can do to change something in a file without using a custom action. If you don't want to use CA, you can consider saving the settings in some other place e.g. User's registry and always read that setting from there

Resources