woltlab-compiler
Version:
A compiler for WoltLab-Package Archives and WoltLab-Package Components
155 lines • 5.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const Component_1 = require("./Component");
const ConflictingPackageDescriptor_1 = require("./ConflictingPackageDescriptor");
const FileDescriptor_1 = require("./FileDescriptor");
const InstructionSet_1 = require("./Instructions/InstructionSet");
const UpdateInstructionSet_1 = require("./Instructions/UpdateInstructionSet");
const OptionalPackageDescriptor_1 = require("./OptionalPackageDescriptor");
const Person_1 = require("./Person");
const RequiredPackageDescriptor_1 = require("./RequiredPackageDescriptor");
/**
* Represents an extension-package.
*/
class Package extends Component_1.Component {
/**
* Initializes a new instance of the `Package` class.
*/
constructor(options) {
super({
Name: options.Name,
DisplayName: options.DisplayName,
Version: options.Version,
Author: options.Author || new Person_1.Person({
Name: null
}),
CreationDate: options.CreationDate,
Description: options.Description,
License: options.License
});
/**
* A set of files which will be added to the package.
*/
this.additionalFiles = [];
/**
* A set of packages which are required by this package.
*/
this.requiredPackages = [];
/**
* A set of packages which cause a conflict with this package.
*/
this.conflictingPackages = [];
/**
* A set of packages which can be installed additionally.
*/
this.optionalPackages = [];
/**
* A set of instructions for installing the package.
*/
this.installSet = new InstructionSet_1.InstructionSet(this);
/**
* A set of instructions to execute when updating from a specific version.
*/
this.updateSets = [];
this.Identifier = options.Identifier;
if (!util_1.isNullOrUndefined(options.AdditionalFiles)) {
for (let additionalFile of options.AdditionalFiles) {
this.AdditionalFiles.push(new FileDescriptor_1.FileDescriptor(additionalFile));
}
}
if (!util_1.isNullOrUndefined(options.RequiredPackages)) {
for (let requiredPackage of options.RequiredPackages) {
this.RequiredPackages.push(new RequiredPackageDescriptor_1.RequiredPackageDescriptor(requiredPackage));
}
}
if (!util_1.isNullOrUndefined(options.ConflictingPackages)) {
for (let conflictingPackage of options.ConflictingPackages) {
this.ConflictingPackages.push(new ConflictingPackageDescriptor_1.ConflictingPackageDescriptor(conflictingPackage));
}
}
if (!util_1.isNullOrUndefined(options.OptionalPackages)) {
for (let optionalPackage of options.OptionalPackages) {
this.OptionalPackages.push(new OptionalPackageDescriptor_1.OptionalPackageDescriptor(optionalPackage));
}
}
this.InstallSet.push(...options.InstallSet.Instructions);
if (!util_1.isNullOrUndefined(options.InstallSet.Directory)) {
this.InstallSet.Directory = options.InstallSet.Directory;
}
if (!util_1.isNullOrUndefined(options.UpdateSets)) {
for (let updateSet of options.UpdateSets) {
let updateInstructionSet = new UpdateInstructionSet_1.UpdateInstructionSet(this, updateSet.FromVersion);
if (!util_1.isNullOrUndefined(updateSet.Directory)) {
updateInstructionSet.Directory = updateSet.Directory;
}
updateInstructionSet.push(...updateSet.Instructions);
this.UpdateSets.push(updateInstructionSet);
}
}
}
/**
* Gets or sets the identifier of the package.
*/
get Identifier() {
return this.identifier;
}
set Identifier(value) {
this.identifier = value;
}
/**
* Gets a set of files which will be added to the package.
*/
get AdditionalFiles() {
return this.additionalFiles;
}
/**
* Gets a set of packages which are required by this package.
*/
get RequiredPackages() {
return this.requiredPackages;
}
/**
* Gets a set of packages which cause a conflict with this package.
*/
get ConflictingPackages() {
return this.conflictingPackages;
}
/**
* Gets a set of packages which can be installed additionally.
*/
get OptionalPackages() {
return this.optionalPackages;
}
/**
* Gets a set of instructions for installing the package.
*/
get InstallSet() {
return this.installSet;
}
/**
* Gets a set of instructions to execute when updating from a specific version.
*/
get UpdateSets() {
return this.updateSets;
}
/**
* Looks for an object with the specified id.
*
* @param id
* The id of the object to get.
*
* @returns
* The object with the specified id.
*/
GetObjectByID(id) {
for (let instruction of this.InstallSet) {
let objects = instruction.ObjectsByID;
if (id in objects) {
return objects[id];
}
}
}
}
exports.Package = Package;
//# sourceMappingURL=Package.js.map