UNPKG

3.33 kBMarkdownView Raw
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()
19Represents an extension in the framework.
20
21
22* * *
23
24<a name="ExtensionBase.extension_build"></a>
25
26### ExtensionBase.extension:build()
27Builds an extension using Babel with Rollup. The extension will be exported
28in ES and UMD module formats into a `dist` folder, with the following name
29format:
30
31```
32 dist/<package.name>.<format>.js
33```
34
35In order for an extension to be buildable, it must contain the following
36configuration in its `package.json` file:
37
38```json
39{
40 "xethya": {
41 "extensionName": "Module.Extension"
42 }
43}
44```
45
46This will export the extension into the `Xethya.Module.Extension` namespace.
47Any classes you define will live there.
48
49To register the task in your local Gulp file, add the following line:
50
51```js
52require('xethya-extension-base/tasks/build');
53```
54
55Then, use it with a globally-installed version of Gulp:
56
57```bash
58gulp extension:build
59```
60
61or 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
71and then run it as:
72
73```bash
74npm 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()
85Runs the extension's test suite. This will spawn a Karma server, hooked-up
86with Mocha, Chai and Sinon, using headless Chrome as browser.
87
88Test files must reside in the `test` folder, and use the `.spec.js` suffix.
89Tests can be written in ES6, without using `import`. The module you're testing
90is available globally under the `Xethya` namespace, as specified by
91`extension:build`.
92
93To register the task in your local Gulp file, add the following line:
94
95```js
96require('xethya-extension-base/tasks/test');
97```
98
99Then, use it with a globally-installed version of Gulp:
100
101```bash
102gulp extension:test
103```
104
105or 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
115and then run it as:
116
117```bash
118npm 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()
129Builds the extension's documentation. It'll scan any *.js files
130living in `src/` and create a `README.md` file in `src/`.
131
132Proper usage of JSDoc is required for this task to run correctly.
133`@module` declaration is mandatory.
134
135To register the task in your local Gulp file, add the following line:
136
137```js
138require('xethya-extension-base/tasks/docs');
139```
140
141Then, use it with a globally-installed version of Gulp:
142
143```bash
144gulp extension:docs
145```
146
147or 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
157and then run it as:
158
159```bash
160npm run docs
161```
162
163**Kind**: static method of [<code>ExtensionBase</code>](#ExtensionBase)
164**Access**: public
165
166* * *
167