-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (60 loc) · 1.62 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const { WatneyPlugin } = require('watney-app');
module.exports = class ExamplePlugin extends WatneyPlugin {
/**
* The ID for this plugin. Must be unique. Should be consistent with the module name.
*
* @readonly
* @static
*/
static get id() {
return 'example';
}
/**
* A description of the plugin.
*
* @readonly
* @static
*/
static get description() {
return 'An example Watney plugin.';
}
/**
* The CLI function for the plugin.
*
* Will be passed the Watney app and awaited when a user selects this plugin in the main CLI.
*
* @readonly
* @static
*/
static get cli() {
return require('./cli');
}
/**
* Create an instance of the plugin.
*
* @param {Object} config The config object from the Watney config for this plugin.
* Watney will look in its config for a property with the same name as the static `id`
* getter above (in this case, "example").
*/
constructor(config) {
super(config);
this.logger.log('Plugin has been constructed.');
}
/**
* Initialize the plugin.
*
* Time-intensive and other async operations that are required to set up the plugin,
* (e.g., authenticating and establishing other connections to APIs) go here.
*
* This will be awaited before scripts are run.
*
*/
async init() {
this.logger.log('Initializing our plugin!');
// Setting properties on the plugin object makes them available to scripts.
// For example:
// let { message } = app.plugins.get('example');
this.message = 'This message came from the example plugin.';
await super.init();
}
};