1 | <a name="ExtensionBase"></a>
|
2 |
|
3 | ## ExtensionBase
|
4 | **Kind**: global class
|
5 | **Access**: public
|
6 |
|
7 | * [ExtensionBase](#ExtensionBase)
|
8 | * [new ExtensionBase()](#new_ExtensionBase_new)
|
9 | * [.extension:build()](#ExtensionBase.extension_build)
|
10 | * [.extension:test()](#ExtensionBase.extension_test)
|
11 | * [.extension:docs()](#ExtensionBase.extension_docs)
|
12 |
|
13 |
|
14 | * * *
|
15 |
|
16 | <a name="new_ExtensionBase_new"></a>
|
17 |
|
18 | ### new ExtensionBase()
|
19 | Represents an extension in the framework.
|
20 |
|
21 |
|
22 | * * *
|
23 |
|
24 | <a name="ExtensionBase.extension_build"></a>
|
25 |
|
26 | ### ExtensionBase.extension:build()
|
27 | Builds an extension using Babel with Rollup. The extension will be exported
|
28 | in ES and UMD module formats into a `dist` folder, with the following name
|
29 | format:
|
30 |
|
31 | ```
|
32 | dist/<package.name>.<format>.js
|
33 | ```
|
34 |
|
35 | In order for an extension to be buildable, it must contain the following
|
36 | configuration in its `package.json` file:
|
37 |
|
38 | ```json
|
39 | {
|
40 | "xethya": {
|
41 | "extensionName": "Module.Extension"
|
42 | }
|
43 | }
|
44 | ```
|
45 |
|
46 | This will export the extension into the `Xethya.Module.Extension` namespace.
|
47 | Any classes you define will live there.
|
48 |
|
49 | To register the task in your local Gulp file, add the following line:
|
50 |
|
51 | ```js
|
52 | require('xethya-extension-base/tasks/build');
|
53 | ```
|
54 |
|
55 | Then, use it with a globally-installed version of Gulp:
|
56 |
|
57 | ```bash
|
58 | gulp extension:build
|
59 | ```
|
60 |
|
61 | or add it to your `package.json` file as a `run script`:
|
62 |
|
63 | ```json
|
64 | {
|
65 | "scripts": {
|
66 | "build": "gulp extension:build"
|
67 | }
|
68 | }
|
69 | ```
|
70 |
|
71 | and then run it as:
|
72 |
|
73 | ```bash
|
74 | npm run build
|
75 | ```
|
76 |
|
77 | **Kind**: static method of [<code>ExtensionBase</code>](#ExtensionBase)
|
78 | **Access**: public
|
79 |
|
80 | * * *
|
81 |
|
82 | <a name="ExtensionBase.extension_test"></a>
|
83 |
|
84 | ### ExtensionBase.extension:test()
|
85 | Runs the extension's test suite. This will spawn a Karma server, hooked-up
|
86 | with Mocha, Chai and Sinon, using headless Chrome as browser.
|
87 |
|
88 | Test files must reside in the `test` folder, and use the `.spec.js` suffix.
|
89 | Tests can be written in ES6, without using `import`. The module you're testing
|
90 | is available globally under the `Xethya` namespace, as specified by
|
91 | `extension:build`.
|
92 |
|
93 | To register the task in your local Gulp file, add the following line:
|
94 |
|
95 | ```js
|
96 | require('xethya-extension-base/tasks/test');
|
97 | ```
|
98 |
|
99 | Then, use it with a globally-installed version of Gulp:
|
100 |
|
101 | ```bash
|
102 | gulp extension:test
|
103 | ```
|
104 |
|
105 | or add it to your `package.json` file as a `run script`:
|
106 |
|
107 | ```json
|
108 | {
|
109 | "scripts": {
|
110 | "test": "gulp extension:test"
|
111 | }
|
112 | }
|
113 | ```
|
114 |
|
115 | and then run it as:
|
116 |
|
117 | ```bash
|
118 | npm run test
|
119 | ```
|
120 |
|
121 | **Kind**: static method of [<code>ExtensionBase</code>](#ExtensionBase)
|
122 | **Access**: public
|
123 |
|
124 | * * *
|
125 |
|
126 | <a name="ExtensionBase.extension_docs"></a>
|
127 |
|
128 | ### ExtensionBase.extension:docs()
|
129 | Builds the extension's documentation. It'll scan any *.js files
|
130 | living in `src/` and create a `README.md` file in `src/`.
|
131 |
|
132 | Proper usage of JSDoc is required for this task to run correctly.
|
133 | `@module` declaration is mandatory.
|
134 |
|
135 | To register the task in your local Gulp file, add the following line:
|
136 |
|
137 | ```js
|
138 | require('xethya-extension-base/tasks/docs');
|
139 | ```
|
140 |
|
141 | Then, use it with a globally-installed version of Gulp:
|
142 |
|
143 | ```bash
|
144 | gulp extension:docs
|
145 | ```
|
146 |
|
147 | or add it to your `package.json` file as a `run script`:
|
148 |
|
149 | ```json
|
150 | {
|
151 | "scripts": {
|
152 | "test": "gulp extension:docs"
|
153 | }
|
154 | }
|
155 | ```
|
156 |
|
157 | and then run it as:
|
158 |
|
159 | ```bash
|
160 | npm run docs
|
161 | ```
|
162 |
|
163 | **Kind**: static method of [<code>ExtensionBase</code>](#ExtensionBase)
|
164 | **Access**: public
|
165 |
|
166 | * * *
|
167 |
|