node-pluginsmanager-plugin 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,165 +1,165 @@
1
- # node-pluginsmanager-plugin
2
- An abstract parent plugin for node-pluginsmanager
3
-
4
- [![Build status](https://api.travis-ci.org/Psychopoulet/node-pluginsmanager-plugin.svg?branch=master)](https://travis-ci.org/Psychopoulet/node-pluginsmanager-plugin)
5
- [![Coverage status](https://coveralls.io/repos/github/Psychopoulet/node-pluginsmanager-plugin/badge.svg?branch=master)](https://coveralls.io/github/Psychopoulet/node-pluginsmanager-plugin)
6
- [![Dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin)
7
- [![Dev dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/dev-status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin?type=dev)
8
- [![Issues](https://img.shields.io/github/issues/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues)
9
- [![Pull requests](https://img.shields.io/github/issues-pr/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/pulls)
10
-
11
- ## Installation
12
-
13
- ```bash
14
- $ npm install node-pluginsmanager-plugin
15
- ```
16
-
17
- ## Features
18
-
19
- * create a inheritable parent for node-pluginsmanager's plugins
20
-
21
- ## Doc
22
-
23
- -- Attributes --
24
-
25
- * ``` authors: Array<string> ```
26
- * ``` description: string ```
27
- * ``` dependencies: object ```
28
- * ``` devDependencies: object ```
29
- * ``` engines: object ```
30
- * ``` license: string ```
31
- * ``` main: string ```
32
- * ``` name: string ```
33
- * ``` scripts: object ```
34
- * ``` version: string ```
35
-
36
- * ``` directory: string ``` current plugin directory
37
- * ``` designs: Array<string> ``` css files for this plugin (ex : "css/design.css")
38
- * ``` javascripts: Array<string> ``` js files for this plugin (ex : "scripts/controller.js")
39
- * ``` templates: Array<string> ``` html files for this plugin (ex : "templates/myPlugin.html")
40
-
41
- -- Constructor --
42
-
43
- * ``` constructor(directory : string) ```
44
-
45
- -- Methods --
46
-
47
- * ``` loadDataFromPackageFile(void): Promise<Plugin> ``` load all package data. automaticly add non-managed data to the plugin instance.
48
- * ``` load(): Promise<void> ``` init plugin (communications, crons, etc...). automatically called by "install" & "update" methods.
49
- * ``` unload(destroy = false : boolean): Promise<void> ``` release plugin (free sockets, stop tasks, etc...). "destroy" is use to force attributes destruction. automatically called by "uninstall" & "update" methods.
50
- * ``` install(): Promise<void> ``` process for specific plugin's installation (download ressources, files creations, etc...)
51
- * ``` update(): Promise<void> ``` process for specific plugin's update
52
- * ``` uninstall(): Promise<void> ``` process for specific plugin's removal (remove created files, etc...)
53
-
54
- ## Examples
55
-
56
- * package.json sample
57
-
58
- ```json
59
- {
60
- "authors": [ "Sébastien VIDAL" ],
61
- "dependencies": {
62
- "simpletts": "^1.3.0"
63
- },
64
- "designs": [ "design.css"],
65
- "description": "A test for simpleplugin",
66
- "javascripts": [ "javascript.js"],
67
- "license": "ISC",
68
- "main": "main.js",
69
- "name": "MyPlugin",
70
- "version": "0.0.2",
71
- "templates": [ "template.html" ],
72
- "core": false,
73
- "linuxOnly": true
74
- }
75
- ```
76
-
77
- * main.js sample
78
-
79
- ```javascript
80
- "use strict";
81
-
82
- class MyPlugin extends require('node-pluginsmanager-plugin') {
83
-
84
- load (data) {
85
-
86
- return super.load().then(() => {
87
-
88
- console.log("your working place");
89
- console.log("automatically called by \"install\" & \"update\" methods, create virtual ressources like array, sockets, etc...");
90
- console.log("optional data", data);
91
-
92
- return Promise.resolve();
93
-
94
- });
95
-
96
- }
97
-
98
- unload (data) {
99
-
100
- return super.unload().then(() => {
101
-
102
- console.log("your working place");
103
- console.log("automatically called by \"uninstall\" & \"update\" methods, close & release virtual ressources like array, sockets, etc...");
104
- console.log("optional data", data);
105
-
106
- return Promise.resolve();
107
-
108
- });
109
-
110
- }
111
-
112
- install (data) {
113
-
114
- return super.install().then(() => {
115
-
116
- console.log("your working place");
117
- console.log("create physical ressources like directories, files, etc...");
118
- console.log("optional data", data);
119
-
120
- return Promise.resolve();
121
-
122
- });
123
-
124
- }
125
-
126
- update (data) {
127
-
128
- return super.update().then(() => {
129
-
130
- console.log("your working place");
131
- console.log("update your ressources like sql database structure, etc...");
132
- console.log("optional data", data);
133
-
134
- return Promise.resolve();
135
-
136
- });
137
-
138
- }
139
-
140
- uninstall (data) {
141
-
142
- return super.uninstall().then(() => {
143
-
144
- console.log("your working place");
145
- console.log("remove all the created ressources like directories, files, etc...");
146
- console.log("optional data", data);
147
-
148
- return Promise.resolve();
149
-
150
- });
151
-
152
- }
153
-
154
- }
155
- ```
156
-
157
- ## Tests
158
-
159
- ```bash
160
- $ npm run-script tests
161
- ```
162
-
163
- ## License
164
-
165
- [ISC](LICENSE)
1
+ # node-pluginsmanager-plugin
2
+ An abstract parent plugin for node-pluginsmanager
3
+
4
+ [![Build status](https://api.travis-ci.org/Psychopoulet/node-pluginsmanager-plugin.svg?branch=master)](https://travis-ci.org/Psychopoulet/node-pluginsmanager-plugin)
5
+ [![Coverage status](https://coveralls.io/repos/github/Psychopoulet/node-pluginsmanager-plugin/badge.svg?branch=master)](https://coveralls.io/github/Psychopoulet/node-pluginsmanager-plugin)
6
+ [![Dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin)
7
+ [![Dev dependency status](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin/dev-status.svg)](https://david-dm.org/Psychopoulet/node-pluginsmanager-plugin?type=dev)
8
+ [![Issues](https://img.shields.io/github/issues/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues)
9
+ [![Pull requests](https://img.shields.io/github/issues-pr/Psychopoulet/node-pluginsmanager-plugin.svg)](https://github.com/Psychopoulet/node-pluginsmanager-plugin/pulls)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ $ npm install node-pluginsmanager-plugin
15
+ ```
16
+
17
+ ## Features
18
+
19
+ * create a inheritable parent for node-pluginsmanager's plugins
20
+
21
+ ## Doc
22
+
23
+ -- Attributes --
24
+
25
+ * ``` authors: Array<string> ```
26
+ * ``` description: string ```
27
+ * ``` dependencies: object ```
28
+ * ``` devDependencies: object ```
29
+ * ``` engines: object ```
30
+ * ``` license: string ```
31
+ * ``` main: string ```
32
+ * ``` name: string ```
33
+ * ``` scripts: object ```
34
+ * ``` version: string ```
35
+
36
+ * ``` directory: string ``` current plugin directory
37
+ * ``` designs: Array<string> ``` css files for this plugin (ex : "css/design.css")
38
+ * ``` javascripts: Array<string> ``` js files for this plugin (ex : "scripts/controller.js")
39
+ * ``` templates: Array<string> ``` html files for this plugin (ex : "templates/myPlugin.html")
40
+
41
+ -- Constructor --
42
+
43
+ * ``` constructor(directory : string) ```
44
+
45
+ -- Methods --
46
+
47
+ * ``` loadDataFromPackageFile(void): Promise<Plugin> ``` load all package data. automaticly add non-managed data to the plugin instance.
48
+ * ``` load(): Promise<void> ``` init plugin (communications, crons, etc...). automatically called by "install" & "update" methods.
49
+ * ``` unload(destroy = false : boolean): Promise<void> ``` release plugin (free sockets, stop tasks, etc...). "destroy" is use to force attributes destruction. automatically called by "uninstall" & "update" methods.
50
+ * ``` install(): Promise<void> ``` process for specific plugin's installation (download ressources, files creations, etc...)
51
+ * ``` update(): Promise<void> ``` process for specific plugin's update
52
+ * ``` uninstall(): Promise<void> ``` process for specific plugin's removal (remove created files, etc...)
53
+
54
+ ## Examples
55
+
56
+ * package.json sample
57
+
58
+ ```json
59
+ {
60
+ "authors": [ "Sébastien VIDAL" ],
61
+ "dependencies": {
62
+ "simpletts": "^1.3.0"
63
+ },
64
+ "designs": [ "design.css"],
65
+ "description": "A test for simpleplugin",
66
+ "javascripts": [ "javascript.js"],
67
+ "license": "ISC",
68
+ "main": "main.js",
69
+ "name": "MyPlugin",
70
+ "version": "0.0.2",
71
+ "templates": [ "template.html" ],
72
+ "core": false,
73
+ "linuxOnly": true
74
+ }
75
+ ```
76
+
77
+ * main.js sample
78
+
79
+ ```javascript
80
+ "use strict";
81
+
82
+ class MyPlugin extends require('node-pluginsmanager-plugin') {
83
+
84
+ load (data) {
85
+
86
+ return super.load().then(() => {
87
+
88
+ console.log("your working place");
89
+ console.log("automatically called by \"install\" & \"update\" methods, create virtual ressources like array, sockets, etc...");
90
+ console.log("optional data", data);
91
+
92
+ return Promise.resolve();
93
+
94
+ });
95
+
96
+ }
97
+
98
+ unload (data) {
99
+
100
+ return super.unload().then(() => {
101
+
102
+ console.log("your working place");
103
+ console.log("automatically called by \"uninstall\" & \"update\" methods, close & release virtual ressources like array, sockets, etc...");
104
+ console.log("optional data", data);
105
+
106
+ return Promise.resolve();
107
+
108
+ });
109
+
110
+ }
111
+
112
+ install (data) {
113
+
114
+ return super.install().then(() => {
115
+
116
+ console.log("your working place");
117
+ console.log("create physical ressources like directories, files, etc...");
118
+ console.log("optional data", data);
119
+
120
+ return Promise.resolve();
121
+
122
+ });
123
+
124
+ }
125
+
126
+ update (data) {
127
+
128
+ return super.update().then(() => {
129
+
130
+ console.log("your working place");
131
+ console.log("update your ressources like sql database structure, etc...");
132
+ console.log("optional data", data);
133
+
134
+ return Promise.resolve();
135
+
136
+ });
137
+
138
+ }
139
+
140
+ uninstall (data) {
141
+
142
+ return super.uninstall().then(() => {
143
+
144
+ console.log("your working place");
145
+ console.log("remove all the created ressources like directories, files, etc...");
146
+ console.log("optional data", data);
147
+
148
+ return Promise.resolve();
149
+
150
+ });
151
+
152
+ }
153
+
154
+ }
155
+ ```
156
+
157
+ ## Tests
158
+
159
+ ```bash
160
+ $ npm run-script tests
161
+ ```
162
+
163
+ ## License
164
+
165
+ [ISC](LICENSE)
package/lib/index.d.ts CHANGED
@@ -1,50 +1,50 @@
1
- /// <reference types="node" />
2
-
3
- declare module "node-pluginsmanager-plugin" {
4
-
5
- import Events from "events";
6
-
7
- class Plugin extends Events {
8
-
9
- // params
10
- public directory: string;
11
-
12
- // native
13
- public authors: Array<string>;
14
- public description: string;
15
- public dependencies: object;
16
- public devDependencies: object;
17
- public engines: object;
18
- public license: string;
19
- public main: string;
20
- public scripts: string;
21
- public name: string;
22
- public version: string;
23
-
24
- // specifics
25
- public designs: Array<string>;
26
- public javascripts: Array<string>;
27
- public templates: Array<string>;
28
-
29
- constructor (directory : string);
30
-
31
- // read
32
-
33
- public loadDataFromPackageFile(): Promise<void>;
34
-
35
- // load
36
-
37
- public load(): Promise<void>;
38
- public unload(destroy?: boolean): Promise<void>;
39
-
40
- // write
41
-
42
- public install(): Promise<void>;
43
- public update(): Promise<void>;
44
- public uninstall(): Promise<void>;
45
-
46
- }
47
-
48
- export = Plugin;
49
-
50
- }
1
+ /// <reference types="node" />
2
+
3
+ declare module "node-pluginsmanager-plugin-v1" {
4
+
5
+ import Events from "events";
6
+
7
+ class Plugin extends Events {
8
+
9
+ // params
10
+ public directory: string;
11
+
12
+ // native
13
+ public authors: Array<string>;
14
+ public description: string;
15
+ public dependencies: object;
16
+ public devDependencies: object;
17
+ public engines: object;
18
+ public license: string;
19
+ public main: string;
20
+ public scripts: string;
21
+ public name: string;
22
+ public version: string;
23
+
24
+ // specifics
25
+ public designs: Array<string>;
26
+ public javascripts: Array<string>;
27
+ public templates: Array<string>;
28
+
29
+ constructor (directory : string);
30
+
31
+ // read
32
+
33
+ public loadDataFromPackageFile(): Promise<void>;
34
+
35
+ // load
36
+
37
+ public load(): Promise<void>;
38
+ public unload(destroy?: boolean): Promise<void>;
39
+
40
+ // write
41
+
42
+ public install(): Promise<void>;
43
+ public update(): Promise<void>;
44
+ public uninstall(): Promise<void>;
45
+
46
+ }
47
+
48
+ export = Plugin;
49
+
50
+ }
@@ -1,34 +1,34 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { lstat } = require("fs");
7
-
8
- // module
9
-
10
- module.exports = function isdirectory (directory) {
11
-
12
- return new Promise((resolve, reject) => {
13
-
14
- if ("undefined" === typeof directory) {
15
- reject(new ReferenceError("missing \"directory\" argument"));
16
- }
17
- else if ("string" !== typeof directory) {
18
- reject(new TypeError("\"directory\" argument is not a string"));
19
- }
20
- else if ("" === directory.trim()) {
21
- reject(new Error("\"directory\" argument is empty"));
22
- }
23
-
24
- else {
25
-
26
- lstat(directory, (err, stats) => {
27
- return resolve(Boolean(!err && stats.isDirectory()));
28
- });
29
-
30
- }
31
-
32
- });
33
-
34
- };
1
+ "use strict";
2
+
3
+ // deps
4
+
5
+ // natives
6
+ const { lstat } = require("fs");
7
+
8
+ // module
9
+
10
+ module.exports = function isdirectory (directory) {
11
+
12
+ return new Promise((resolve, reject) => {
13
+
14
+ if ("undefined" === typeof directory) {
15
+ reject(new ReferenceError("missing \"directory\" argument"));
16
+ }
17
+ else if ("string" !== typeof directory) {
18
+ reject(new TypeError("\"directory\" argument is not a string"));
19
+ }
20
+ else if ("" === directory.trim()) {
21
+ reject(new Error("\"directory\" argument is empty"));
22
+ }
23
+
24
+ else {
25
+
26
+ lstat(directory, (err, stats) => {
27
+ return resolve(Boolean(!err && stats.isDirectory()));
28
+ });
29
+
30
+ }
31
+
32
+ });
33
+
34
+ };
package/lib/isFile.js CHANGED
@@ -1,34 +1,34 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { lstat } = require("fs");
7
-
8
- // module
9
-
10
- module.exports = function isFile (file) {
11
-
12
- return new Promise((resolve, reject) => {
13
-
14
- if ("undefined" === typeof file) {
15
- reject(new ReferenceError("missing \"file\" argument"));
16
- }
17
- else if ("string" !== typeof file) {
18
- reject(new TypeError("\"file\" argument is not a string"));
19
- }
20
- else if ("" === file.trim()) {
21
- reject(new Error("\"file\" argument is empty"));
22
- }
23
-
24
- else {
25
-
26
- lstat(file, (err, stats) => {
27
- return resolve(Boolean(!err && stats.isFile()));
28
- });
29
-
30
- }
31
-
32
- });
33
-
34
- };
1
+ "use strict";
2
+
3
+ // deps
4
+
5
+ // natives
6
+ const { lstat } = require("fs");
7
+
8
+ // module
9
+
10
+ module.exports = function isFile (file) {
11
+
12
+ return new Promise((resolve, reject) => {
13
+
14
+ if ("undefined" === typeof file) {
15
+ reject(new ReferenceError("missing \"file\" argument"));
16
+ }
17
+ else if ("string" !== typeof file) {
18
+ reject(new TypeError("\"file\" argument is not a string"));
19
+ }
20
+ else if ("" === file.trim()) {
21
+ reject(new Error("\"file\" argument is empty"));
22
+ }
23
+
24
+ else {
25
+
26
+ lstat(file, (err, stats) => {
27
+ return resolve(Boolean(!err && stats.isFile()));
28
+ });
29
+
30
+ }
31
+
32
+ });
33
+
34
+ };