Browse code

Rework the folder-structure

Manuel Thalmann authored on 24/04/2018 15:21:29
Showing 50 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 import * as Path from "path";
2
-import Package from "./lib/Package";
3
-import RequiredPackageDescriptor from "./lib/RequiredPackageDescriptor";
2
+import Package from "./lib/PackageSystem/Package";
3
+import RequiredPackageDescriptor from "./lib/PackageSystem/RequiredPackageDescriptor";
4 4
 import StyleInstructionCollection from "./lib/Customization/StyleInstructionCollection";
5 5
 import UpdateInstructionCollection from "./lib/Automation/UpdateInstructionCollection";
6 6
 
... ...
@@ -1,5 +1,5 @@
1
-import EventListener from "../lib/EventListener";
2
-import EventListenersInstruction from "../lib/EventListenersInstruction";
1
+import EventListener from "../lib/Events/EventListener";
2
+import EventListenersInstruction from "../lib/Events/EventListenersInstruction";
3 3
 import WSCEnvironment from "../lib/WSCEnvironment";
4 4
 
5 5
 let eventListenersInstruction: EventListenersInstruction = new EventListenersInstruction({
... ...
@@ -1,4 +1,4 @@
1
-import Package from "../Package";
1
+import Package from "../PackageSystem/Package";
2 2
 import IInstruction from "./IInstruction";
3 3
 import Instruction from "./Instruction";
4 4
 
... ...
@@ -1,4 +1,4 @@
1
-import Package from "../Package";
1
+import Package from "../PackageSystem/Package";
2 2
 import { isNullOrUndefined } from "util";
3 3
 import IInstruction from "./IInstruction";
4 4
 
... ...
@@ -1,12 +1,12 @@
1 1
 import Instruction from "./Instruction";
2
-import Package from "../Package";
2
+import Package from "../PackageSystem/Package";
3 3
 import FilesInstruction from "../FilesInstruction";
4 4
 import Option from "../ControlPanel/Option";
5 5
 import OptionsInstruction from "../ControlPanel/OptionsInstruction";
6 6
 import SettingsNode from "../ControlPanel/SettingsNode";
7 7
 import TranslationNode from "../Globalization/TranslationNode";
8
-import EventListener from "../EventListener";
9
-import EventListenersInstruction from "../EventListenersInstruction";
8
+import EventListener from "../Events/EventListener";
9
+import EventListenersInstruction from "../Events/EventListenersInstruction";
10 10
 import TranslationsInstruction from "../Globalization/TranslationsInstruction";
11 11
 import Style from "../Customization/Style";
12 12
 import StyleInstruction from "../Customization/StyleInstruction";
... ...
@@ -1,6 +1,6 @@
1 1
 import Instruction from "./Instruction";
2 2
 import InstructionCollection from "./InstructionCollection";
3
-import Package from "../Package";
3
+import Package from "../PackageSystem/Package";
4 4
 
5 5
 /**
6 6
  * Represents a set of `InstructionCollection`s.
... ...
@@ -1,7 +1,7 @@
1 1
 import Instruction from "./Instruction";
2 2
 import InstructionCollection from "./InstructionCollection";
3 3
 import IUpdateInstructionCollection from "./IUpdateInstructionCollection";
4
-import Package from "../Package";
4
+import Package from "../PackageSystem/Package";
5 5
 
6 6
 /**
7 7
  * Represents a set of `Instruction`s for updating a package.
... ...
@@ -1,6 +1,6 @@
1 1
 import InstructionCollectionCollection from "./InstructionCollectionCollection";
2 2
 import UpdateInstructionCollection from "./UpdateInstructionCollection";
3
-import Package from "../Package";
3
+import Package from "../PackageSystem/Package";
4 4
 import Instruction from "./Instruction";
5 5
 
6 6
 /**
7 7
deleted file mode 100644
... ...
@@ -1,137 +0,0 @@
1
-import Localizable from "./GLobalization/Localizable";
2
-import Package from "./Package";
3
-import Person from "./Person";
4
-import { isNullOrUndefined } from "util";
5
-import IComponent from "./IComponent";
6
-
7
-/**
8
- * Represents a component for WoltLab Suite Core.
9
- */
10
-export default abstract class Component implements IComponent
11
-{
12
-    /**
13
-     * The name of the component.
14
-     */
15
-    private name: string = null;
16
-
17
-    /**
18
-     * The human-readable name of the component.
19
-     */
20
-    private displayName: Localizable = new Localizable();
21
-
22
-    /**
23
-     * The release-date of the component.
24
-     */
25
-    private date: Date = new Date();
26
-
27
-    /**
28
-     * The description of the component.
29
-     */
30
-    private description: Localizable = new Localizable();
31
-
32
-    /**
33
-     * The version of the component.
34
-     */
35
-    private version: string = require("../package.json").version;
36
-
37
-    /**
38
-     * The author of the component.
39
-     */
40
-    private author: Person = new Person({
41
-        Name: require("../package.json").author.name,
42
-        URL:  require("../package.json").author.url 
43
-    });
44
-
45
-    /**
46
-     * The license of the component.
47
-     */
48
-    private license: string = require("../package.json").license;
49
-
50
-    /**
51
-     * Initializes a new instance of the `Component` class.
52
-     */
53
-    protected constructor(options: IComponent)
54
-    {
55
-        this.name = options.Name;
56
-
57
-        if (!isNullOrUndefined(options.DisplayName))
58
-        {
59
-            Object.assign(this.DisplayName, options.DisplayName);
60
-        }
61
-
62
-        if (!isNullOrUndefined(options.Description))
63
-        {
64
-            Object.assign(this.description, options.Description);
65
-        }
66
-
67
-        if (!isNullOrUndefined(options.Version))
68
-        {
69
-            this.version = options.Version;
70
-        }
71
-
72
-        if (!isNullOrUndefined(options.Author))
73
-        {
74
-            this.Author.Name = options.Author.Name;
75
-
76
-            if (!isNullOrUndefined(options.Author.URL))
77
-            {
78
-                this.Author.URL = options.Author.URL;
79
-            }
80
-        }
81
-    }
82
-
83
-    public get Name(): string
84
-    {
85
-        return this.name;
86
-    }
87
-
88
-    public set Name(value: string)
89
-    {
90
-        this.name = value;
91
-    }
92
-
93
-    public get DisplayName(): Localizable
94
-    {
95
-        return this.displayName;
96
-    }
97
-
98
-    public get Date(): Date
99
-    {
100
-        return this.date;
101
-    }
102
-
103
-    public set Date(value: Date)
104
-    {
105
-        this.date = value;
106
-    }
107
-
108
-    public get Description(): Localizable
109
-    {
110
-        return this.description;
111
-    }
112
-
113
-    public get Version(): string
114
-    {
115
-        return this.version;
116
-    }
117
-
118
-    public set Version(value: string)
119
-    {
120
-        this.version = value;
121
-    }
122
-
123
-    public get Author(): Person
124
-    {
125
-        return this.author;
126
-    }
127
-
128
-    public get License(): string
129
-    {
130
-        return this.license;
131
-    }
132
-
133
-    public set License(value: string)
134
-    {
135
-        this.license = value;
136
-    }
137
-}
138 0
\ No newline at end of file
139 1
deleted file mode 100644
... ...
@@ -1,16 +0,0 @@
1
-import RequiredPackageDescriptor from "./RequiredPackageDescriptor";
2
-import IRequiredPackageDescriptor from "./IRequiredPackageDescriptor";
3
-
4
-/**
5
- * Provides an abstraction of a conflicting package.
6
- */
7
-export default class ConflictingPackageDescriptor extends RequiredPackageDescriptor
8
-{
9
-    /**
10
-     * Initializes a new instance of the `ConflictingPackageDescriptor`.
11
-     */
12
-    public constructor(options: IRequiredPackageDescriptor)
13
-    {
14
-        super(options);
15
-    }
16
-}
17 0
\ No newline at end of file
... ...
@@ -1,5 +1,5 @@
1
-import Component from "../Component";
2
-import IComponent from "../IComponent";
1
+import Component from "../PackageSystem/Component";
2
+import IComponent from "../PackageSystem/IComponent";
3 3
 
4 4
 /**
5 5
  * Represents a style-configuration.
... ...
@@ -1,5 +1,5 @@
1 1
 import * as FileSystem from "fs";
2
-import Component from "../Component";
2
+import Component from "../PackageSystem/Component";
3 3
 import Instruction from "../Automation/Instruction";
4 4
 import IStyle from "./IStyle";
5 5
 import StyleInstruction from "./StyleInstruction";
... ...
@@ -1,7 +1,7 @@
1 1
 import FileSystemInstruction from "../Automation/FileSystemInstruction";
2 2
 import Style from "./Style";
3 3
 import { isNullOrUndefined } from "util";
4
-import Package from "../Package";
4
+import Package from "../PackageSystem/Package";
5 5
 import IStyleInstruction from "./IStyleInstruction";
6 6
 
7 7
 /**
8 8
deleted file mode 100644
... ...
@@ -1,74 +0,0 @@
1
-import Listener from "./Listener";
2
-import { isNullOrUndefined } from "util";
3
-import IEventListener from "./IEventListener";
4
-
5
-/**
6
- * Represents the declaration of a PHP-class that should be executed when a specific event occurrs.
7
- * 
8
- * Please note that you have to provide your PHP-files using a `FilesInstruction`.
9
- */
10
-export default class EventListener extends Listener implements IEventListener
11
-{
12
-    /**
13
-     * The name of the class that invokes the event to subscribe to.
14
-     */
15
-    private className: string = "";
16
-
17
-    /**
18
-     * A value indicating whether classes that inherit `className` should be subscribed, too.
19
-     */
20
-    private inherit: boolean = false;
21
-
22
-    /**
23
-     * The name of the class that handles the subscribed event.
24
-     */
25
-    private eventHandlerClassName: string = "";
26
-
27
-    /**
28
-     * Initializes a new instance of the `EventListener` class.
29
-     */
30
-    public constructor(options: IEventListener)
31
-    {
32
-        super(options);
33
-
34
-        if (!isNullOrUndefined(options.ClassName))
35
-        {
36
-            this.className = options.ClassName;
37
-        }
38
-
39
-        if (!isNullOrUndefined(options.Inherit))
40
-        {
41
-            this.inherit = options.Inherit;
42
-        }
43
-    }
44
-
45
-    public get ClassName(): string
46
-    {
47
-        return this.className;
48
-    }
49
-
50
-    public set ClassName(value: string)
51
-    {
52
-        this.className = value;
53
-    }
54
-
55
-    public get Inherit(): boolean
56
-    {
57
-        return this.inherit;
58
-    }
59
-
60
-    public set Inherit(value: boolean)
61
-    {
62
-        this.inherit = value;
63
-    }
64
-
65
-    public get EventHandlerClassName(): string
66
-    {
67
-        return this.eventHandlerClassName;
68
-    }
69
-
70
-    public set EventHandlerClassName(value: string)
71
-    {
72
-        this.eventHandlerClassName = value;
73
-    }
74
-}
75 0
\ No newline at end of file
76 1
deleted file mode 100644
... ...
@@ -1,57 +0,0 @@
1
-import IEventListenersInstruction from "./IEventListenersInstruction";
2
-import Instruction from "./Automation/Instruction";
3
-import EventListener from "./EventListener";
4
-import FileInstruction from "./Automation/FileInstruction";
5
-import { isNullOrUndefined } from "util";
6
-
7
-/**
8
- * Represents an instruction that provides a set of event-listeners.
9
- */
10
-export default class EventListenersInstruction extends FileInstruction implements IEventListenersInstruction
11
-{
12
-    /**
13
-     * A set of names of event-listeners to delete.
14
-     */
15
-    private names: string[] = [];
16
-
17
-    /**
18
-     * The event-listeners provided by the instruction.
19
-     */
20
-    private eventListeners: EventListener[] = [];
21
-
22
-    /**
23
-     * Initializes a new instance of the `EventListenersInstruction` class.
24
-     */
25
-    public constructor(options: IEventListenersInstruction)
26
-    {
27
-        super(options);
28
-
29
-        if (isNullOrUndefined(this.FileName))
30
-        {
31
-            this.FileName = "eventListeners.xml";
32
-        }
33
-
34
-        if (!isNullOrUndefined(options.ObjectsToDelete))
35
-        {
36
-            this.names.push(...options.ObjectsToDelete);
37
-        }
38
-
39
-        if (!isNullOrUndefined(options.EventListeners))
40
-        {
41
-            this.eventListeners.push(...options.EventListeners);
42
-        }
43
-    }
44
-
45
-    public get EventListeners(): EventListener[]
46
-    {
47
-        return this.eventListeners;
48
-    }
49
-
50
-    /**
51
-     * Gets a set of names of event-listeners to delete.
52
-     */
53
-    public get ObjectsToDelete(): string[]
54
-    {
55
-        return this.names;
56
-    }
57
-}
58 0
\ No newline at end of file
59 1
new file mode 100644
... ...
@@ -0,0 +1,74 @@
1
+import Listener from "../Listener";
2
+import { isNullOrUndefined } from "util";
3
+import IEventListener from "./IEventListener";
4
+
5
+/**
6
+ * Represents the declaration of a PHP-class that should be executed when a specific event occurrs.
7
+ * 
8
+ * Please note that you have to provide your PHP-files using a `FilesInstruction`.
9
+ */
10
+export default class EventListener extends Listener implements IEventListener
11
+{
12
+    /**
13
+     * The name of the class that invokes the event to subscribe to.
14
+     */
15
+    private className: string = "";
16
+
17
+    /**
18
+     * A value indicating whether classes that inherit `className` should be subscribed, too.
19
+     */
20
+    private inherit: boolean = false;
21
+
22
+    /**
23
+     * The name of the class that handles the subscribed event.
24
+     */
25
+    private eventHandlerClassName: string = "";
26
+
27
+    /**
28
+     * Initializes a new instance of the `EventListener` class.
29
+     */
30
+    public constructor(options: IEventListener)
31
+    {
32
+        super(options);
33
+
34
+        if (!isNullOrUndefined(options.ClassName))
35
+        {
36
+            this.className = options.ClassName;
37
+        }
38
+
39
+        if (!isNullOrUndefined(options.Inherit))
40
+        {
41
+            this.inherit = options.Inherit;
42
+        }
43
+    }
44
+
45
+    public get ClassName(): string
46
+    {
47
+        return this.className;
48
+    }
49
+
50
+    public set ClassName(value: string)
51
+    {
52
+        this.className = value;
53
+    }
54
+
55
+    public get Inherit(): boolean
56
+    {
57
+        return this.inherit;
58
+    }
59
+
60
+    public set Inherit(value: boolean)
61
+    {
62
+        this.inherit = value;
63
+    }
64
+
65
+    public get EventHandlerClassName(): string
66
+    {
67
+        return this.eventHandlerClassName;
68
+    }
69
+
70
+    public set EventHandlerClassName(value: string)
71
+    {
72
+        this.eventHandlerClassName = value;
73
+    }
74
+}
0 75
\ No newline at end of file
1 76
new file mode 100644
... ...
@@ -0,0 +1,57 @@
1
+import IEventListenersInstruction from "./IEventListenersInstruction";
2
+import Instruction from "../Automation/Instruction";
3
+import EventListener from "./EventListener";
4
+import FileInstruction from "../Automation/FileInstruction";
5
+import { isNullOrUndefined } from "util";
6
+
7
+/**
8
+ * Represents an instruction that provides a set of event-listeners.
9
+ */
10
+export default class EventListenersInstruction extends FileInstruction implements IEventListenersInstruction
11
+{
12
+    /**
13
+     * A set of names of event-listeners to delete.
14
+     */
15
+    private names: string[] = [];
16
+
17
+    /**
18
+     * The event-listeners provided by the instruction.
19
+     */
20
+    private eventListeners: EventListener[] = [];
21
+
22
+    /**
23
+     * Initializes a new instance of the `EventListenersInstruction` class.
24
+     */
25
+    public constructor(options: IEventListenersInstruction)
26
+    {
27
+        super(options);
28
+
29
+        if (isNullOrUndefined(this.FileName))
30
+        {
31
+            this.FileName = "eventListeners.xml";
32
+        }
33
+
34
+        if (!isNullOrUndefined(options.ObjectsToDelete))
35
+        {
36
+            this.names.push(...options.ObjectsToDelete);
37
+        }
38
+
39
+        if (!isNullOrUndefined(options.EventListeners))
40
+        {
41
+            this.eventListeners.push(...options.EventListeners);
42
+        }
43
+    }
44
+
45
+    public get EventListeners(): EventListener[]
46
+    {
47
+        return this.eventListeners;
48
+    }
49
+
50
+    /**
51
+     * Gets a set of names of event-listeners to delete.
52
+     */
53
+    public get ObjectsToDelete(): string[]
54
+    {
55
+        return this.names;
56
+    }
57
+}
0 58
\ No newline at end of file
1 59
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+import IListener from "../IListener";
2
+
3
+/**
4
+ * Represents the declaration of a PHP-class that should be executed when a specific event occurrs.
5
+ * 
6
+ * Please note that you have to provide your PHP-files using a `FilesInstruction`.
7
+ */
8
+export default interface IEventListener extends IListener
9
+{
10
+    /**
11
+     * Gets or sets the name of the class that invokes the event to subscribe to.
12
+     */
13
+    ClassName: string;
14
+    
15
+    /**
16
+     * Gets or sets a value indicating whether classes that inherit `className` should be subscribed, too.
17
+     */
18
+    Inherit?: boolean;
19
+    
20
+    /**
21
+     * Gets or sets the name of the class that handles the subscribed event.
22
+     */
23
+    EventHandlerClassName: string;
24
+}
0 25
\ No newline at end of file
1 26
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+import IFileInstruction from "../Automation/IFileInstruction";
2
+import EventListener from "./EventListener";
3
+import IDeleteInstruction from "../Automation/IDeleteInstruction";
4
+
5
+/**
6
+ * Represents an instruction that provides a set of event-listeners.
7
+ */
8
+export default interface IEventListenersInstruction extends IFileInstruction, IDeleteInstruction
9
+{
10
+    /**
11
+     * Gets the event-listeners provided by the instruction.
12
+     */
13
+    EventListeners: EventListener[];
14
+}
0 15
\ No newline at end of file
1 16
deleted file mode 100644
... ...
@@ -1,40 +0,0 @@
1
-import IPerson from "./IPerson";
2
-import Localizable from "./GLobalization/Localizable";
3
-
4
-export default interface IComponent
5
-{
6
-    /**
7
-     * Gets the name of the component.
8
-     */
9
-    Name: string;
10
-
11
-    /**
12
-     * Gets the human-readable name of the component.
13
-     */
14
-    DisplayName?: Localizable;
15
-
16
-    /**
17
-     * Gets or sets the release-date of the component.
18
-     */
19
-    Date?: Date;
20
-
21
-    /**
22
-     * Gets the description of the component.
23
-     */
24
-    Description?: Localizable;
25
-
26
-    /**
27
-     * Gets the version of the component.
28
-     */
29
-    Version?: string;
30
-
31
-    /**
32
-     * Gets the author of the component.
33
-     */
34
-    Author?: IPerson;
35
-
36
-    /**
37
-     * Gets or sets the license of the component.
38
-     */
39
-    License?: string;
40
-}
41 0
\ No newline at end of file
42 1
deleted file mode 100644
... ...
@@ -1,24 +0,0 @@
1
-import IListener from "./IListener";
2
-
3
-/**
4
- * Represents the declaration of a PHP-class that should be executed when a specific event occurrs.
5
- * 
6
- * Please note that you have to provide your PHP-files using a `FilesInstruction`.
7
- */
8
-export default interface IEventListener extends IListener
9
-{
10
-    /**
11
-     * Gets or sets the name of the class that invokes the event to subscribe to.
12
-     */
13
-    ClassName: string;
14
-    
15
-    /**
16
-     * Gets or sets a value indicating whether classes that inherit `className` should be subscribed, too.
17
-     */
18
-    Inherit?: boolean;
19
-    
20
-    /**
21
-     * Gets or sets the name of the class that handles the subscribed event.
22
-     */
23
-    EventHandlerClassName: string;
24
-}
25 0
\ No newline at end of file
26 1
deleted file mode 100644
... ...
@@ -1,14 +0,0 @@
1
-import IFileInstruction from "./Automation/IFileInstruction";
2
-import EventListener from "./EventListener";
3
-import IDeleteInstruction from "./Automation/IDeleteInstruction";
4
-
5
-/**
6
- * Represents an instruction that provides a set of event-listeners.
7
- */
8
-export default interface IEventListenersInstruction extends IFileInstruction, IDeleteInstruction
9
-{
10
-    /**
11
-     * Gets the event-listeners provided by the instruction.
12
-     */
13
-    EventListeners: EventListener[];
14
-}
15 0
\ No newline at end of file
16 1
deleted file mode 100644
... ...
@@ -1,14 +0,0 @@
1
-import IPackageDescriptor from "./IPackageDescriptor";
2
-
3
-/**
4
- * Provides an abstraction of an optional package.
5
- * 
6
- * Keep in mind to provide the optional package using `Package.AdditionalFiles`.
7
- */
8
-export default interface IOptionalPackageDescriptor extends IPackageDescriptor
9
-{
10
-    /**
11
-     * Gets or sets the path to the path to the package.
12
-     */
13
-    FileName: string;
14
-}
15 0
\ No newline at end of file
16 1
deleted file mode 100644
... ...
@@ -1,48 +0,0 @@
1
-import FileSystemInstruction from "./Automation/FileSystemInstruction";
2
-import IComponent from "./IComponent";
3
-import Instruction from "./Automation/Instruction";
4
-import IUpdateInstructionCollection from "./Automation/IUpdateInstructionCollection";
5
-import OptionalPackageDescriptor from "./OptionalPackageDescriptor";
6
-import RequiredPackageDescriptor from "./RequiredPackageDescriptor";
7
-import ConflictingPackageDescriptor from "./ConflictingPackageDescriptor";
8
-
9
-/**
10
- * Represents a package for WoltLab Suite Core.
11
- */
12
-export default interface IPackage extends IComponent
13
-{
14
-    /**
15
-     * Gets or sets the identifier of the package.
16
-     */
17
-    Identifier: string;
18
-    
19
-    /**
20
-     * Gets or sets the instructions which is used for installing the packge.
21
-     */
22
-    InstallInstructions: Instruction[];
23
-    
24
-    /**
25
-     * Gets a set of instructions for updating the package.
26
-     */
27
-    UpdateInstructions?: IUpdateInstructionCollection<Instruction>[];
28
-
29
-    /**
30
-     * Gets additional files which are copied to the package.
31
-     */
32
-    AdditionalFiles?: FileSystemInstruction[];
33
-
34
-    /**
35
-     * Gets the packages which are required for installing this package.
36
-     */
37
-    RequiredPackages?: RequiredPackageDescriptor[];
38
-
39
-    /**
40
-     * Gets the optional packages provided by this package.
41
-     */
42
-    OptionalPackages?: OptionalPackageDescriptor[];
43
-
44
-    /**
45
-     * Gets the packages which are conflicting with this package.
46
-     */
47
-    ConflictingPackages?: ConflictingPackageDescriptor[];
48
-}
49 0
\ No newline at end of file
50 1
deleted file mode 100644
... ...
@@ -1,10 +0,0 @@
1
-/**
2
- * Provides an abstraction of a package.
3
- */
4
-export default interface IPackageDescriptor
5
-{
6
-    /**
7
-     * Gets or sets the identifier of the package.
8
-     */
9
-    Identifier: string;
10
-}
11 0
\ No newline at end of file
12 1
deleted file mode 100644
... ...
@@ -1,15 +0,0 @@
1
-/**
2
- * Represents a person.
3
- */
4
-export default interface IPerson
5
-{
6
-    /**
7
-     * Gets or sets the name of the person.
8
-     */
9
-    Name: string;
10
-
11
-    /**
12
-     * Gets or sets the url to the homepage of the person.
13
-     */
14
-    URL?: string;
15
-}
16 0
\ No newline at end of file
17 1
deleted file mode 100644
... ...
@@ -1,12 +0,0 @@
1
-import IPackageDescriptor from "./IPackageDescriptor";
2
-
3
-/**
4
- * Provides an abstraction of a required package.
5
- */
6
-export default interface IRequiredPackageDescriptor extends IPackageDescriptor
7
-{
8
-    /**
9
-     * Gets or sets the minimal version the package must have.
10
-     */
11
-    MinVersion: string;
12
-}
13 0
\ No newline at end of file
14 1
deleted file mode 100644
... ...
@@ -1,271 +0,0 @@
1
-import * as FileSystem from "fs-extra";
2
-import * as Path from "path";
3
-import * as memFs from "mem-fs";
4
-import * as memFsEditor from "mem-fs-editor";
5
-import InstructionCollection from "./Automation/InstructionCollection";
6
-import BBCodesInstruction from "./Customization/BBCodesInstruction";
7
-import Compiler from "./Compiler";
8
-import FilesInstruction from "./FilesInstruction";
9
-import OptionsInstruction from "./ControlPanel/OptionsInstruction";
10
-import TranslationsInstruction from "./Globalization/TranslationsInstruction";
11
-import EventListenersInstruction from "./EventListenersInstruction";
12
-import StyleInstruction from "./Customization/StyleInstruction";
13
-import TemplateListenersInstruction from "./Customization/TemplateListenersInstruction";
14
-import EmojisInstruction from "./Customization/EmojisInstruction";
15
-import Instruction from "./Automation/Instruction";
16
-const MemFileSystem = memFsEditor.create(memFs.create());
17
-
18
-/**
19
- * Provides the functionality to compile an `InstructionCollection`.
20
- */
21
-export default class InstructionCollectionCompiler extends Compiler<InstructionCollection<Instruction>>
22
-{
23
-    /**
24
-     * The path to save compiled styles to.
25
-     */
26
-    private stylesPath: string;
27
-
28
-    /**
29
-     * The path to save compiled components to.
30
-     */
31
-    private componentsPath: string;
32
-
33
-    /**
34
-     * Initializes a new instance of the `InstructionCollectionCompiler`.
35
-     * 
36
-     * @param instructionCollection
37
-     * The `InstructionCollection` which is to be compiled.
38
-     * 
39
-     * @param destinationPath
40
-     * The path to save the compiled instructions to.
41
-     * 
42
-     * @param stylesPath
43
-     * The path to save compiled styles to.
44
-     * 
45
-     * @param componentsPath
46
-     * The path to save compiled components to.
47
-     */
48
-    public constructor(instructionCollection: InstructionCollection<Instruction>, destinationPath: string = "obj", stylesPath: string = "styles", componentsPath: string = "components")
49
-    {
50
-        super(instructionCollection, destinationPath);
51
-        this.stylesPath = stylesPath;
52
-        this.componentsPath = componentsPath;
53
-    }
54
-
55
-    /**
56
-     * Compiles the instruction-collection.
57
-     */
58
-    protected async Compile()
59
-    {
60
-        for (let instruction of this.Item)
61
-        {
62
-            if (instruction instanceof FilesInstruction)
63
-            {
64
-                let filesGenerator = memFsEditor.create(memFs.create());
65
-                filesGenerator.copyTpl(instruction.SourceRoot, this.MakeTempPath(instruction.SourceRoot), instruction.Package);
66
-
67
-                await new Promise((resolve) =>
68
-                {
69
-                    filesGenerator.commit([], () => {
70
-                        resolve();
71
-                    });
72
-                });
73
-
74
-                this.Compress(this.MakeTempPath(instruction.SourceRoot), this.MakeDestinationPath(instruction.FileName));
75
-                await FileSystem.remove(this.MakeTempPath(instruction.SourceRoot));
76
-            }
77
-            else if (instruction instanceof OptionsInstruction)
78
-            {
79
-                MemFileSystem.copyTpl(this.MakeTemplatePath("options.xml"), this.MakeComponentsPath(instruction.FileName), { Instruction: instruction });
80
-                {
81
-                    let locales: string[] = [];
82
-
83
-                    for (let translationNode of instruction.TranslationNodes)
84
-                    {
85
-                        for (let translation of translationNode.GetTranslations())
86
-                        {
87
-                            for (let locale in translation.Translations)
88
-                            {
89
-                                if (!locales.includes(locale))
90
-                                {
91
-                                    locales.push(locale);
92
-                                }
93
-                            }
94
-                        }
95
-                    }
96
-
97
-                    for (let locale of locales)
98
-                    {
99
-                        MemFileSystem.copyTpl(
100
-                            this.MakeTemplatePath("language.xml"),
101
-                            this.MakeComponentsPath(instruction.TranslationsDirectory, locale + ".xml"),
102
-                            { Instruction: instruction, Locale: locale });
103
-                    }
104
-                }
105
-            }
106
-            else if (instruction instanceof TranslationsInstruction)
107
-            {
108
-                let locales: string[] = [];
109
-
110
-                for (let translationNode of instruction.TranslationNodes)
111
-                {
112
-                    for (let translation of translationNode.GetTranslations())
113
-                    {
114
-                        for (let locale in translation.Translations)
115
-                        {
116
-                            if (!locales.includes(locale))
117
-                            {
118
-                                locales.push(locale);
119
-                            }
120
-                        }
121
-                    }
122
-                }
123
-
124
-                for (let locale of locales)
125
-                {
126
-                    MemFileSystem.copyTpl(
127
-                        this.MakeTemplatePath("language.xml"),
128
-                        this.MakeComponentsPath(instruction.FileName, locale + ".xml"),
129
-                        { Instruction: instruction, Locale: locale });
130
-                }
131
-            }
132
-            else if (instruction instanceof EventListenersInstruction)
133
-            {
134
-                MemFileSystem.copyTpl(this.MakeTemplatePath("eventListeners.xml"), this.MakeComponentsPath(instruction.FileName), { Instruction: instruction });
135
-            }
136
-            else if (instruction instanceof StyleInstruction)
137
-            {
138
-                let style = instruction.Style;
139
-                let styleGenerator = memFsEditor.create(memFs.create());
140
-
141
-                styleGenerator.copyTpl(
142
-                    this.MakeTemplatePath("style", "style.xml"),
143
-                    this.MakeStylesTempPath(instruction.Style.Name, "style.xml"),
144
-                    { Instruction: instruction });
145
-                styleGenerator.copyTpl(
146
-                    this.MakeTemplatePath("style", "variables.xml"),
147
-                    this.MakeStylesTempPath(style.Name, "variables.xml"),
148
-                    { Instruction: instruction });
149
-                
150
-                await new Promise((resolve) =>
151
-                {
152
-                    styleGenerator.commit([], () =>
153
-                    {
154
-                        resolve();
155
-                    });
156
-                });
157
-
158
-                if (style.ImagesRoot)
159
-                {
160
-                    let imagesGenerator = memFsEditor.create(memFs.create());
161
-                    imagesGenerator.copyTpl(Path.join(instruction.SourceRoot, style.ImagesRoot), this.MakeStylesTempPath(style.Name, "images"), instruction.Package);
162
-
163
-                    await new Promise((resolve) =>
164
-                    {
165
-                        imagesGenerator.commit([], () =>
166
-                        {
167
-                            resolve();
168
-                        });
169
-                    });
170
-
171
-                    this.Compress(this.MakeStylesTempPath(style.Name, "images"), this.MakeStylesTempPath(style.Name, "images.tar"));
172
-                    await FileSystem.remove(this.MakeStylesTempPath(style.Name, "images"));
173
-                }
174
-
175
-                await this.Compress(this.MakeStylesTempPath(style.Name), this.MakeStylesPath(instruction.FileName));
176
-            }
177
-            else if (instruction instanceof TemplateListenersInstruction)
178
-            {
179
-                MemFileSystem.copyTpl(
180
-                    this.MakeTemplatePath("templateListeners.xml"),
181
-                    this.MakeComponentsPath(instruction.FileName),
182
-                    { Instruction: instruction });
183
-            }
184
-            else if (instruction instanceof EmojisInstruction)
185
-            {
186
-                MemFileSystem.copyTpl(this.MakeTemplatePath("emojis.xml"), this.MakeComponentsPath(instruction.FileName), { Instruction: instruction });
187
-            }
188
-            else if (instruction instanceof BBCodesInstruction)
189
-            {
190
-                MemFileSystem.copyTpl(this.MakeTemplatePath("bbcodes.xml"), this.MakeComponentsPath(instruction.FileName), { Instruction: instruction });
191
-                {
192
-                    let locales: string[] = [];
193
-
194
-                    for (let translationNode of instruction.TranslationNodes)
195
-                    {
196
-                        for (let translation of translationNode.GetTranslations())
197
-                        {
198
-                            for (let locale in translation.Translations)
199
-                            {
200
-                                if (!locales.includes(locale))
201
-                                {
202
-                                    locales.push(locale);
203
-                                }
204
-                            }
205
-                        }
206
-                    }
207
-
208
-                    for (let locale of locales)
209
-                    {
210
-                        MemFileSystem.copyTpl(
211
-                            this.MakeTemplatePath("language.xml"),
212
-                            this.MakeComponentsPath(instruction.TranslationsDirectory, locale + ".xml"),
213
-                            { Instruction: instruction, Locale: locale });
214
-                    }
215
-                }
216
-            }
217
-        }
218
-
219
-        await new Promise((resolve) =>
220
-        {
221
-            MemFileSystem.commit([], () =>
222
-            {
223
-                resolve();
224
-            });
225
-        });
226
-    }
227
-
228
-    /**
229
-     * Joins the paths and returns the path contained by the template-folder.
230
-     * 
231
-     * @param path
232
-     * The path that is to be joined.
233
-     */
234
-    protected MakeDestinationPath(...path: string[]): string
235
-    {
236
-        return super.MakeDestinationPath("package", this.Item.Destination, ...path);
237
-    }
238
-
239
-    /**
240
-     * Joins the paths and returns the path contained by the temporar styles-folder.
241
-     * 
242
-     * @param path
243
-     * The path that is to be joined.
244
-     */
245
-    protected MakeStylesTempPath(...path: string[]): string
246
-    {
247
-        return super.MakeDestinationPath("styles", ...path);
248
-    }
249
-
250
-    /**
251
-     * Joins the paths and returns the path contained by the styles-folder.
252
-     * 
253
-     * @param path
254
-     * The path that is to be joined.
255
-     */
256
-    protected MakeStylesPath(...path: string[]): string
257
-    {
258
-        return this.MakeDestinationPath(this.stylesPath, ...path);
259
-    }
260
-
261
-    /**
262
-     * Joins the paths and returns the path contained by the components-folder.
263
-     * 
264
-     * @param path
265
-     * The path that is to be joined.
266
-     */
267
-    protected MakeComponentsPath(...path: string[]): string
268
-    {
269
-        return this.MakeDestinationPath(this.componentsPath, ...path);
270
-    }
271
-}
272 0
\ No newline at end of file
273 1
deleted file mode 100644
... ...
@@ -1,33 +0,0 @@
1
-import PackageDescriptor from "./PackageDescriptor";
2
-import IOptionalPackageDescriptor from "./IOptionalPackageDescriptor";
3
-
4
-/**
5
- * Provides an abstraction of an optional package.
6
- *
7
- * Keep in mind to provide the optional package using `Package.AdditionalFiles`.
8
- */
9
-export default class OptionalPackageDescriptor extends PackageDescriptor implements IOptionalPackageDescriptor
10
-{
11
-    /**
12
-     * The path to the path to the package.
13
-     */
14
-    private fileName: string;
15
-
16
-    /**
17
-     * Initializes a new instance of the `OptionalPackageDescriptor` class.
18
-     */
19
-    public constructor(options: IOptionalPackageDescriptor)
20
-    {
21
-        super(options);
22
-    }
23
-
24
-    public get FileName(): string
25
-    {
26
-        return this.fileName;
27
-    }
28
-
29
-    public set FileName(value: string)
30
-    {
31
-        this.fileName = value;
32
-    }
33
-}
34 0
\ No newline at end of file
35 1
deleted file mode 100644
... ...
@@ -1,171 +0,0 @@
1
-import Component from "./Component";
2
-import TranslationNode from "./Globalization/TranslationNode";
3
-import InstructionCollection from "./Automation/InstructionCollection";
4
-import UpdatesCollection from "./Automation/UpdatesCollection";
5
-import Instruction from "./Automation/Instruction";
6
-import UpdateInstructionCollection from "./Automation/UpdateInstructionCollection";
7
-import { isNullOrUndefined } from "util";
8
-import IPackage from "./IPackage";
9
-import Option from "./ControlPanel/Option";
10
-import ErrorMessageNode from "./Globalization/ErrorMessageNode";
11
-import FilesInstruction from "./FilesInstruction";
12
-import FileSystemInstruction from "./Automation/FileSystemInstruction";
13
-import RequiredPackageDescriptor from "./RequiredPackageDescriptor";
14
-import OptionalPackageDescriptor from "./OptionalPackageDescriptor";
15
-import ConflictingPackageDescriptor from "./ConflictingPackageDescriptor";
16
-
17
-/**
18
- * Represents a package for WoltLab Suite Core.
19
- */
20
-export default class Package extends Component implements IPackage
21
-{
22
-    /**
23
-     * The identifier of the package.
24
-     */
25
-    private identifier: string = "";
26
-
27
-    /**
28
-     * The instructions which is used for installing the packge.
29
-     */
30
-    private installInstructions: InstructionCollection<Instruction> = new InstructionCollection(this);
31
-
32
-    /**
33
-     * A set of instructions for updating the package.
34
-     */
35
-    private updateInstructions: UpdateInstructionCollection<Instruction>[] = new UpdatesCollection(this);
36
-
37
-    /**
38
-     * Additional files which are copied to the package.
39
-     */
40
-    private additionalFiles: FileSystemInstruction[] = new InstructionCollection(this);
41
-
42
-    /**
43
-     * The packages which are required for installing this package.
44
-     */
45
-    private requiredPackages: RequiredPackageDescriptor[] = [];
46
-
47
-    /**
48
-     * Optional packages provided by this package.
49
-     */
50
-    private optionalPackages: OptionalPackageDescriptor[] = [];
51
-
52
-    /**
53
-     * The packages which are conflicting with this package.
54
-     */
55
-    private conflictingPackages: ConflictingPackageDescriptor[] = [];
56
-
57
-    /**
58
-     * Initializes a new instance of the `Package` class.
59
-     */
60
-    public constructor(options: IPackage)
61
-    {
62
-        super(options);
63
-        this.identifier = options.Identifier;
64
-
65
-        if (isNullOrUndefined(options.Date))
66
-        {
67
-            this.Date = new Date();
68
-        }
69
-
70
-        if (!isNullOrUndefined(options.InstallInstructions))
71
-        {
72
-            this.installInstructions.push(...options.InstallInstructions);
73
-        }
74
-
75
-        if (!isNullOrUndefined(options.UpdateInstructions))
76
-        {
77
-            for (let updateInstruction of options.UpdateInstructions)
78
-            {
79
-                let updateInstructionCollection = new UpdateInstructionCollection(this, updateInstruction.FromVersion);
80
-
81
-                if (!isNullOrUndefined(updateInstruction.Destination))
82
-                {
83
-                    updateInstructionCollection.Destination = updateInstruction.Destination;
84
-                }
85
-
86
-                for (let instruction of updateInstruction.Instructions)
87
-                {
88
-                    updateInstructionCollection.push(instruction);
89
-                }
90
-                
91
-                this.updateInstructions.push(updateInstructionCollection);
92
-            }
93
-        }
94
-
95
-        if (!isNullOrUndefined(options.AdditionalFiles))
96
-        {
97
-            this.additionalFiles.push(...options.AdditionalFiles);
98
-        }
99
-
100
-        if (!isNullOrUndefined(options.RequiredPackages))
101
-        {
102
-            this.requiredPackages.push(...options.RequiredPackages);
103
-        }
104
-
105
-        if (!isNullOrUndefined(options.OptionalPackages))
106
-        {
107
-            this.optionalPackages.push(...options.OptionalPackages);
108
-        }
109
-
110
-        if (!isNullOrUndefined(options.ConflictingPackages))
111
-        {
112
-            this.conflictingPackages.push(...options.ConflictingPackages);
113
-        }
114
-    }
115
-
116
-    public get Identifier(): string
117
-    {
118
-        return this.identifier;
119
-    }
120
-
121
-    public set Identifier(value: string)
122
-    {
123
-        this.identifier = value;
124
-    }
125
-
126
-    public get InstallInstructions(): InstructionCollection<Instruction>
127
-    {
128
-        return this.installInstructions;
129
-    }
130
-
131
-    public get UpdateInstructions(): UpdateInstructionCollection<Instruction>[]
132
-    {
133
-        return this.updateInstructions;
134
-    }
135
-
136
-    public get AdditionalFiles(): FileSystemInstruction[]
137
-    {
138
-        return this.additionalFiles;
139
-    }
140
-
141
-    public get RequiredPackages(): RequiredPackageDescriptor[]
142
-    {
143
-        return this.requiredPackages;
144
-    }
145
-
146
-    public get OptionalPackages(): OptionalPackageDescriptor[]
147
-    {
148
-        return this.optionalPackages;
149
-    }
150
-
151
-    public get ConflictingPackages(): ConflictingPackageDescriptor[]
152
-    {
153
-        return this.conflictingPackages;
154
-    }
155
-
156
-    /**
157
-     * Gets the options provided by this package.
158
-     */
159
-    public get Options(): { [id: string]: Option }
160
-    {
161
-        return this.InstallInstructions.Options;
162
-    }
163
-
164
-    /**
165
-     * Gets the error-messages provided by this package
166
-     */
167
-    public get ErrorMessages(): { [id: string]: ErrorMessageNode }
168
-    {
169
-        return this.InstallInstructions.ErrorMessages;
170
-    }
171
-}
172 0
\ No newline at end of file
173 1
deleted file mode 100644
... ...
@@ -1,130 +0,0 @@
1
-import * as Path from "path";
2
-import * as FileSystem from "fs-extra";
3
-import * as memFsEditor from "mem-fs-editor";
4
-import * as memFs from "mem-fs";
5
-import Compiler from "./Compiler";
6
-import FilesInstruction from "./FilesInstruction";
7
-import InstructionCollection from "./Automation/InstructionCollection";
8
-import InstructionCollectionCompiler from "./InstructionCollectionCompiler";
9
-import Package from "./Package";
10
-const MemFileSystem = memFsEditor.create(memFs.create());
11
-
12
-/**
13
- * Provides the functionality to compile packages.
14
- */
15
-export default class PackageCompiler extends Compiler<Package>
16
-{
17
-    /**
18
-     * The path to the directory which contains the source-files.
19
-     */
20
-    private sourcePath: string;
21
-
22
-    /**
23
-     * The path to save compiled styles to.
24
-     */
25
-    private stylesPath: string;
26
-
27
-    /**
28
-     * The path to save compiled components to.
29
-     */
30
-    private componentsPath: string;
31
-
32
-    /**
33
-     * 
34
-     * @param pkg 
35
-     * The package to compile.
36
-     * 
37
-     * @param sourcePath 
38
-     * The path to the directory which contains the source-files.
39
-     * 
40
-     * @param destinationPath
41
-     * The path to save the compiled item to.
42
-     * 
43
-     * @param stylesPath
44
-     * The path to save compiled styles to.
45
-     * 
46
-     * @param componentsPath
47
-     * The path to save compiled components to.
48
-     */
49
-    public constructor(pkg: Package, sourcePath: string = "obj", destinationPath: string = "bin", stylesPath: string = "styles", componentsPath: string = "components")
50
-    {
51
-        super(pkg, destinationPath);
52
-        this.sourcePath = sourcePath;
53
-        this.stylesPath = stylesPath;
54
-        this.componentsPath = componentsPath;
55
-    }
56
-
57
-    /**
58
-     * Gets the path to the directory which contains the source-files.
59
-     */
60
-    public get SourcePath(): string
61
-    {
62
-        return this.sourcePath;
63
-    }
64
-
65
-    /**
66
-     * Compiles the item.
67
-     */
68
-    protected async Compile()
69
-    {
70
-        await FileSystem.emptyDir(this.DestinationPath);
71
-        await FileSystem.emptyDir(this.sourcePath);
72
-
73
-        MemFileSystem.copyTpl(
74
-            this.MakeTemplatePath("package.xml"),
75
-            this.MakeSourcePath("package.xml"),
76
-            { Package: this.Item, StylesPath: this.stylesPath, ComponentsPath: this.componentsPath });
77
-        
78
-        if (this.Item.InstallInstructions.length > 0)
79
-        {
80
-            await new InstructionCollectionCompiler(
81
-                this.Item.InstallInstructions,
82
-                this.SourcePath,
83
-                this.stylesPath,
84
-                this.componentsPath).Execute();
85
-        }
86
-
87
-        for (let instructionCollection of this.Item.UpdateInstructions)
88
-        {
89
-            await new InstructionCollectionCompiler(
90
-                instructionCollection,
91
-                this.SourcePath,
92
-                this.stylesPath,
93
-                this.componentsPath).Execute();
94
-        }
95
-
96
-        for (let additionalFiles of this.Item.AdditionalFiles)
97
-        {
98
-            if (additionalFiles instanceof FilesInstruction)
99
-            {
100
-                MemFileSystem.copyTpl(additionalFiles.SourceRoot, this.MakeTempPath(additionalFiles.SourceRoot), this.Item);
101
-                this.Compress(this.MakeTempPath(additionalFiles.SourceRoot), this.MakeSourcePath(additionalFiles.FileName));
102
-            }
103
-            else
104
-            {
105
-                MemFileSystem.copyTpl(additionalFiles.SourceRoot, this.MakeSourcePath(additionalFiles.FileName), this.Item);
106
-            }
107
-        }
108
-
109
-        await new Promise((resolve) =>
110
-        {
111
-            MemFileSystem.commit([], () =>
112
-            {
113
-                resolve();
114
-            });
115
-        });
116
-
117
-        this.Compress(this.MakeSourcePath(), this.MakeDestinationPath(this.Item.Name + ".tar"));
118
-    }
119
-
120
-    /**
121
-     * Joins the paths and returns the path contained by the source-folder.
122
-     * 
123
-     * @param path
124
-     * The path that is to be joined.
125
-     */
126
-    protected MakeSourcePath(...path: string[]): string
127
-    {
128
-        return Path.join(this.sourcePath, "package", ...path);
129
-    }
130
-}
131 0
\ No newline at end of file
132 1
deleted file mode 100644
... ...
@@ -1,34 +0,0 @@
1