GitHub - kamicane/packager: builds packages using the package.yml MooTools syntax (original) (raw)

Packager

Packager is a PHP 5.2+ library to concatenate libraries split in multiple files in a single file. It automatically calculates dependancies. Packager requires a yml header syntax in every file, and a package.yml manifest file, as seen on the MooTools project.

Packager API

Constructor

The constructor of this class accepts either a path to a package or a list of path to packages. package.yml must not be included in the path.

Example

$pkg = new Packager("/Users/kamicane/Sites/mootools-core/");
$pkg = new Packager(array("/Users/kamicane/Sites/mootools-core/", "/Users/kamicane/Sites/mootools-more/"));

Adding a manifest

Working with files

Getters

Converters

Generators

Working with components

Converting to files

Generators

Class usage

Syntax

``` pkg=newPackager(‘pkg = new Packager(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.03148em;">k</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">n</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.13889em;">wP</span><span class="mord mathnormal">a</span><span class="mord mathnormal">c</span><span class="mord mathnormal">ka</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal" style="margin-right:0.02778em;">er</span><span class="mopen">(</span><span class="mord">‘</span></span></span></span>path_to_manifest);


### Example

[](#example-1)

$pkg = new Packager("/Users/kamicane/Sites/mootools-core/");

$pkg->write_from_components("/Users/kamicane/Sites/mootools.js", array('Type', 'Array'));


## Packager Command Line script

[](#packager-command-line-script)

The Packager command line script is your one-stop solution to build any of your packages at once. Works on unices.

### Syntax

[](#syntax-1)

./packager COMMAND +option1 argument1 argument2 +option2 argument1 argument2


* `COMMAND` a packager command _(required)_
* `+option` options for commands _(optional)_

### Commands

[](#commands)

* `register` registers a package. Creates a .packages.yml file in your home folder.
* `unregister` unregisters a package
* `list` list registered packages
* `build` builds a single file with the supplied packages / files / components

### Registering a Package

[](#registering-a-package)

#### Example

[](#example-2)

./packager register /Users/kamicane/mootools-core » the package Core has been registered


### Listing Packages

[](#listing-packages)

#### Example

[](#example-3)

./packager list » Core: /Users/kamicane/mootools-core


### Unregistering a Package

[](#unregistering-a-package)

#### Example

[](#example-4)

./packager unregister Core » the package Core has been unregistered


### Building Packages

[](#building-packages)

#### Examples

[](#examples)

./packager build Core/Type Core/Fx ART/ART.Element


Which is the same as...

./packager build +components Core/Type Core/Fx ART/ART.Element


Which builds the passed in components (and their dependancies) using your registered packages.

./packager build +files Core/Core Core/Fx ART/ART


This builds the passed in files (and their dependancies) using your registered packages.

Builds every component from ART, and their dependancies, using your registered packages.

./packager build SomePackage/SomeComponent +packages /Users/kamicane/Sites/some-package


Builds the selected components using your registered packages and a temporary package that resides in /Users/kamicane/Sites/some-package, without having to register it first.

./packager build SomePackage/SomeComponent -packages Core


Builds the selected components using your registered packages minus the package names you pass to -packages. This lets you build your components without dependancies.

./packager build ART/SomeComponent +use-only ART


Builds the selected components using only ART of your registered packages. This lets you build your components without dependancies.

./packager build SomePackage/SomeComponent +use-only +packages /Users/kamicane/Sites/some-package


Builds the selected components using none of your registered packages plus the passed in package, without registering it. This lets you build your components without dependancies.

./packager build +components ART/ART +files ART/ART.Base


You can mix components and files

./packager build Core/* > mootools.js

```

This is how you output to a file