Last Updated: June 28, 2019
·
759
· watsonallie

Tools and tips on migrating a large user-defined JavaScript codebase?

I help develop and manage software in which (among other things) users can provide their own JavaScript scripts to run macros and the like. We're using Mozilla Rhino in a Java context. We have quite a large "API", wherein there are a variety of well known variables and utility functions we place in the scopes a priori. For example, things like "cellObject.assignTo(name)" which are widely used, but obviously only make sense within the scope of our product.

This all works quite well, but now we're close to releasing a newer and better version of the software. Among other things, it will drastically update the API of various objects, and even change the names of some of the variables that are placed in scope (e.g. "cellObject" to "plot.getCell(0)").

Along with this new version, we're going to be including some automatic migration for user-defined scripts. So I was wondering, what would you guys suggest to be the best plan of action? Are there any reliable tools out there that might help? Currently we're looking into basically executing a number of very complex regular expressions on the scripts as a best-effort attempt at migration. Has anyone else ran into something similar?