We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

This resource has not currently been approved, and is not currently linked to from our directory of resources. It is being displayed here for preview by the author and moderators only.
Rated
Read 190 times

Contents

Related Categories

JavaScript Packaging using Humax - Versioning Package

udooz

Versioning Package

Referencing and Using a Package

Humax introduces require() method to allow the use of types declared in a package into current script file.

Humax.require(<package name>, [version]);

For example,

Humax.require("husmoh.pms.core.validator");

Discipline #7. From v0.2.1 onwards, a package a.k.a Humax compatible script file should be referenced by Humax.require().

Versioning Package

The intend of package is designed to simplify and resolve versioning problems that can occur using different versions of same script files.

Issues with Versioning

Suppose you have developed a library called "NiceWidgets.js" which requires a particular third party xml library. Assume that NiceWidgets version 1.0, reference a particular version of the xml library say "MyXmlLib v2.3.2.js". The clients of "NiceWidgets.js" use this in their applications with no issues. You release "NiceWidgets v2.0.js" which actually uses "MyXmlLib v2.6.js". In a situation like one of your client who is developing a web site using "NiceWidgets.js", and now they want to use one new client side control introduced in "NiceWidgets v2.0.js". They do not immetiately want to migrate into "NiceWidgets v2.0.js" due to some breaking changes introduced in version 2.0. For them, they have to use version 2.0 in one of their page. But your library should load correct version of "MyXmlLib" because in the client side, they may have both "MyXmlLib v2.3.2.js" and "MyXmlLib v2.6.js".

Specifying Version

For resolving these kind of versioning issues, Humax introduces versioning for packages. You can specify the version information in the Humax.declarePackage(),

Humax.declarePackage("Husmoh.NiceWidgets", "1.0");

Discipline #8. Humax recommends that the version information would be in <major>[.minor[.revision]] format.

Requesting Package Version

The second optional parameter of require() method allows you to specify which version of the package you require.

Humax.require("MyXmlLib", "2.3.2");

The above command requests to load version 2.3.2 of MyXmlLib.

Requesting Version by Expression

You can specify relational expression in the version argument to load a version in the given range, for example, your library requires MyXmlLib version greather than 2.3.2. Then you can specify

Humax.require("MyXmlLib", "v>2.3.2");

The expression should start with letter "v" and has any one of the relational operator <, <=, >, >= and =.

File Name Pattern for versioned Package

Different version of same package cannot share same file name which is one of the very basic standard across all operating system. Humax do not recommend to maintain different version of same package under different directory as followed in .NET global assemblies. Instead, if you plan to develop and adopt package version, Humax recommends the following decipline.

Discipline #9. The file name pattern of versioned package should be in the format <package name>_v<major>[.minor[.revision]].js.

Based on the decipline #9, the file name of package "MyXmlLib v2.3.2" should be "MyXmlLib_v2.3.2.js".

You can use "MyXmlLib.js" as file name for version 1.0 or 0.1 of the package which will be based on your implementation strategy.

Loading non-Humax standard script files

If you want to adopt non-Humax standard script files as Humax package with versioning feature, you can use packages option in Humax.AppConfig. For example,

Humax.AppConfig.packages = 
[
	{name:"Husmoh.NiceWidgets", version:"0.9.1", file:"NiceWidgets.js"},
	{name:"MyOtherXmlLib", version:"2.5.6", file:"myotherxmllib 2.5.6213.js"},
	{name:"SomeValidatorScript", version:"", file:"some_validator_script.js"} 
];
		

Humax automatically verifies the version details and load the relevant script file. For example, you have declared the packages in the AppConfig, and one of your script file requires MyOtherXmlLib package with version greater than 2.0, Humax loads "myotherxmllib 2.5.6213.js".

For more details or your contribution in Humax web framework, visit http://humax.sourceforge.net or
write me to udooz@hotmail.com.

Comments