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/lib/main.js CHANGED
@@ -1,218 +1,218 @@
1
- /*
2
- eslint class-methods-use-this: 0
3
- */
4
-
5
- "use strict";
6
-
7
- // deps
8
-
9
- // natives
10
- const { join } = require("path");
11
-
12
- // locals
13
- const isFile = require(join(__dirname, "isFile.js"));
14
- const isDirectory = require(join(__dirname, "isDirectory.js"));
15
- const readJSONFile = require(join(__dirname, "readJSONFile.js"));
16
-
17
- // module
18
-
19
- module.exports = class Plugin extends require("events") {
20
-
21
- constructor (directory) {
22
-
23
- super();
24
-
25
- // params
26
- this.directory = directory;
27
-
28
- // native
29
- this.authors = [];
30
- this.description = "";
31
- this.dependencies = {};
32
- this.devDependencies = {};
33
- this.engines = {
34
- "node": ">=6.0.0"
35
- };
36
- this.license = "MIT";
37
- this.main = "lib/main.js";
38
- this.name = "";
39
- this.scripts = {};
40
- this.version = "";
41
-
42
- // specifics
43
- this.designs = [];
44
- this.javascripts = [];
45
- this.templates = [];
46
-
47
- }
48
-
49
- // read
50
-
51
- loadDataFromPackageFile () {
52
-
53
- // check directory
54
- return isDirectory(this.directory).then((exists) => {
55
-
56
- return exists ? Promise.resolve() :
57
- Promise.reject(new Error("\"" + this.directory + "\" does not exist."));
58
-
59
- }).then(() => {
60
-
61
- const file = join(this.directory, "package.json");
62
-
63
- // check package.json
64
- return isFile(file).then((exists) => {
65
-
66
- return exists ? Promise.resolve() :
67
- Promise.reject(new Error("\"" + file + "\" does not exist."));
68
-
69
- // read package.json content
70
- }).then(() => {
71
-
72
- return readJSONFile(file);
73
-
74
- });
75
-
76
- // formate authors
77
- }).then((data) => {
78
-
79
- if (data.author) {
80
-
81
- if (data.authors) {
82
- this.authors = data.authors.slice(0);
83
- delete data.authors;
84
- }
85
- else {
86
- this.authors = [];
87
- }
88
-
89
- this.authors.push(data.author);
90
-
91
- delete data.author;
92
-
93
- }
94
-
95
- return Promise.resolve(data);
96
-
97
- // formate designs, javascripts & templates
98
- }).then((data) => {
99
-
100
- this.designs = [];
101
- if (data.designs) {
102
-
103
- if (data.designs instanceof Array && 0 < data.designs.length) {
104
-
105
- for (let i = 0, l = data.designs.length; i < l; ++i) {
106
- this.designs.push(join(this.directory, data.designs[i]));
107
- }
108
-
109
- }
110
-
111
- delete data.designs;
112
-
113
- }
114
-
115
- this.javascripts = [];
116
- if (data.javascripts) {
117
-
118
- if (data.javascripts instanceof Array && 0 < data.javascripts.length) {
119
-
120
- for (let i = 0, l = data.javascripts.length; i < l; ++i) {
121
- this.javascripts.push(join(this.directory, data.javascripts[i]));
122
- }
123
-
124
- }
125
-
126
- delete data.javascripts;
127
-
128
- }
129
-
130
- this.templates = [];
131
- if (data.templates) {
132
-
133
- if (data.templates instanceof Array && 0 < data.templates.length) {
134
-
135
- for (let i = 0, l = data.templates.length; i < l; ++i) {
136
- this.templates.push(join(this.directory, data.templates[i]));
137
- }
138
-
139
- }
140
-
141
- delete data.templates;
142
-
143
- }
144
-
145
- return Promise.resolve(data);
146
-
147
- // formate other data
148
- }).then((data) => {
149
-
150
- for (const key in data) {
151
-
152
- if (Object.prototype.hasOwnProperty.call(data, key)) {
153
- this[key] = data[key];
154
- }
155
-
156
- }
157
-
158
- return Promise.resolve();
159
-
160
- });
161
-
162
- }
163
-
164
- // load
165
-
166
- load () {
167
- return Promise.resolve();
168
- }
169
-
170
- unload (destroy = false) {
171
-
172
- return Promise.resolve().then(() => {
173
- this.removeAllListeners(); return Promise.resolve();
174
- }).then(() => {
175
-
176
- if (destroy) {
177
-
178
- // native
179
- this.authors = null;
180
- this.description = null;
181
- this.dependencies = null;
182
- this.devDependencies = null;
183
- this.engines = null;
184
- this.license = null;
185
- this.main = null;
186
- this.name = null;
187
- this.scripts = null;
188
- this.version = null;
189
-
190
- // specifics
191
- this.directory = null;
192
- this.designs = null;
193
- this.javascripts = null;
194
- this.templates = null;
195
-
196
- }
197
-
198
- return Promise.resolve();
199
-
200
- });
201
-
202
- }
203
-
204
- // write
205
-
206
- install () {
207
- return Promise.resolve();
208
- }
209
-
210
- update () {
211
- return Promise.resolve();
212
- }
213
-
214
- uninstall () {
215
- return Promise.resolve();
216
- }
217
-
218
- };
1
+ /*
2
+ eslint class-methods-use-this: 0
3
+ */
4
+
5
+ "use strict";
6
+
7
+ // deps
8
+
9
+ // natives
10
+ const { join } = require("path");
11
+
12
+ // locals
13
+ const isFile = require(join(__dirname, "isFile.js"));
14
+ const isDirectory = require(join(__dirname, "isDirectory.js"));
15
+ const readJSONFile = require(join(__dirname, "readJSONFile.js"));
16
+
17
+ // module
18
+
19
+ module.exports = class Plugin extends require("events") {
20
+
21
+ constructor (directory) {
22
+
23
+ super();
24
+
25
+ // params
26
+ this.directory = directory;
27
+
28
+ // native
29
+ this.authors = [];
30
+ this.description = "";
31
+ this.dependencies = {};
32
+ this.devDependencies = {};
33
+ this.engines = {
34
+ "node": ">=6.0.0"
35
+ };
36
+ this.license = "MIT";
37
+ this.main = "lib/main.js";
38
+ this.name = "";
39
+ this.scripts = {};
40
+ this.version = "";
41
+
42
+ // specifics
43
+ this.designs = [];
44
+ this.javascripts = [];
45
+ this.templates = [];
46
+
47
+ }
48
+
49
+ // read
50
+
51
+ loadDataFromPackageFile () {
52
+
53
+ // check directory
54
+ return isDirectory(this.directory).then((exists) => {
55
+
56
+ return exists ? Promise.resolve() :
57
+ Promise.reject(new Error("\"" + this.directory + "\" does not exist."));
58
+
59
+ }).then(() => {
60
+
61
+ const file = join(this.directory, "package.json");
62
+
63
+ // check package.json
64
+ return isFile(file).then((exists) => {
65
+
66
+ return exists ? Promise.resolve() :
67
+ Promise.reject(new Error("\"" + file + "\" does not exist."));
68
+
69
+ // read package.json content
70
+ }).then(() => {
71
+
72
+ return readJSONFile(file);
73
+
74
+ });
75
+
76
+ // formate authors
77
+ }).then((data) => {
78
+
79
+ if (data.author) {
80
+
81
+ if (data.authors) {
82
+ this.authors = data.authors.slice(0);
83
+ delete data.authors;
84
+ }
85
+ else {
86
+ this.authors = [];
87
+ }
88
+
89
+ this.authors.push(data.author);
90
+
91
+ delete data.author;
92
+
93
+ }
94
+
95
+ return Promise.resolve(data);
96
+
97
+ // formate designs, javascripts & templates
98
+ }).then((data) => {
99
+
100
+ this.designs = [];
101
+ if (data.designs) {
102
+
103
+ if (data.designs instanceof Array && 0 < data.designs.length) {
104
+
105
+ for (let i = 0, l = data.designs.length; i < l; ++i) {
106
+ this.designs.push(join(this.directory, data.designs[i]));
107
+ }
108
+
109
+ }
110
+
111
+ delete data.designs;
112
+
113
+ }
114
+
115
+ this.javascripts = [];
116
+ if (data.javascripts) {
117
+
118
+ if (data.javascripts instanceof Array && 0 < data.javascripts.length) {
119
+
120
+ for (let i = 0, l = data.javascripts.length; i < l; ++i) {
121
+ this.javascripts.push(join(this.directory, data.javascripts[i]));
122
+ }
123
+
124
+ }
125
+
126
+ delete data.javascripts;
127
+
128
+ }
129
+
130
+ this.templates = [];
131
+ if (data.templates) {
132
+
133
+ if (data.templates instanceof Array && 0 < data.templates.length) {
134
+
135
+ for (let i = 0, l = data.templates.length; i < l; ++i) {
136
+ this.templates.push(join(this.directory, data.templates[i]));
137
+ }
138
+
139
+ }
140
+
141
+ delete data.templates;
142
+
143
+ }
144
+
145
+ return Promise.resolve(data);
146
+
147
+ // formate other data
148
+ }).then((data) => {
149
+
150
+ for (const key in data) {
151
+
152
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
153
+ this[key] = data[key];
154
+ }
155
+
156
+ }
157
+
158
+ return Promise.resolve();
159
+
160
+ });
161
+
162
+ }
163
+
164
+ // load
165
+
166
+ load () {
167
+ return Promise.resolve();
168
+ }
169
+
170
+ unload (destroy = false) {
171
+
172
+ return Promise.resolve().then(() => {
173
+ this.removeAllListeners(); return Promise.resolve();
174
+ }).then(() => {
175
+
176
+ if (destroy) {
177
+
178
+ // native
179
+ this.authors = null;
180
+ this.description = null;
181
+ this.dependencies = null;
182
+ this.devDependencies = null;
183
+ this.engines = null;
184
+ this.license = null;
185
+ this.main = null;
186
+ this.name = null;
187
+ this.scripts = null;
188
+ this.version = null;
189
+
190
+ // specifics
191
+ this.directory = null;
192
+ this.designs = null;
193
+ this.javascripts = null;
194
+ this.templates = null;
195
+
196
+ }
197
+
198
+ return Promise.resolve();
199
+
200
+ });
201
+
202
+ }
203
+
204
+ // write
205
+
206
+ install () {
207
+ return Promise.resolve();
208
+ }
209
+
210
+ update () {
211
+ return Promise.resolve();
212
+ }
213
+
214
+ uninstall () {
215
+ return Promise.resolve();
216
+ }
217
+
218
+ };
@@ -1,32 +1,32 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
- const { readFile } = require("fs");
8
-
9
- // locals
10
- const isFile = require(join(__dirname, "isFile.js"));
11
-
12
- // module
13
-
14
- module.exports = function readJSONFile (file) {
15
-
16
- return isFile(file).then((exists) => {
17
-
18
- return !exists ?
19
- Promise.reject(new Error("The file does not exist")) :
20
- new Promise((resolve, reject) => {
21
-
22
- readFile(file, (err, content) => {
23
- return err ? reject(err) : resolve(content);
24
- });
25
-
26
- });
27
-
28
- }).then((content) => {
29
- return Promise.resolve(JSON.parse(content));
30
- });
31
-
32
- };
1
+ "use strict";
2
+
3
+ // deps
4
+
5
+ // natives
6
+ const { join } = require("path");
7
+ const { readFile } = require("fs");
8
+
9
+ // locals
10
+ const isFile = require(join(__dirname, "isFile.js"));
11
+
12
+ // module
13
+
14
+ module.exports = function readJSONFile (file) {
15
+
16
+ return isFile(file).then((exists) => {
17
+
18
+ return !exists ?
19
+ Promise.reject(new Error("The file does not exist")) :
20
+ new Promise((resolve, reject) => {
21
+
22
+ readFile(file, (err, content) => {
23
+ return err ? reject(err) : resolve(content);
24
+ });
25
+
26
+ });
27
+
28
+ }).then((content) => {
29
+ return Promise.resolve(JSON.parse(content));
30
+ });
31
+
32
+ };
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "name": "node-pluginsmanager-plugin",
3
- "version": "0.1.4",
4
- "description": "An abstract parent plugin for node-pluginsmanager",
5
- "main": "lib/main.js",
6
- "typings": "lib/index.d.ts",
7
- "scripts": {
8
- "lint": "npx eslint ./lib/**/*.js ./test/**/*.js",
9
- "check-updates": "npx check-version-modules",
10
- "unit-tests": "npx nyc --reporter=html --reporter=text mocha",
11
- "tests": "npm run-script lint && npm run-script check-updates && npm run-script unit-tests",
12
- "ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
13
- },
14
- "husky": {
15
- "hooks": {
16
- "pre-commit": "npm run-script lint",
17
- "pre-push": "npm run-script tests"
18
- }
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "git://github.com/Psychopoulet/node-pluginsmanager-plugin"
23
- },
24
- "keywords": [
25
- "plugin",
26
- "manage",
27
- "gestion"
28
- ],
29
- "author": "Sébastien VIDAL",
30
- "license": "ISC",
31
- "bugs": {
32
- "url": "https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues"
33
- },
34
- "dependencies": {},
35
- "devDependencies": {
36
- "@types/node": "12.0.2",
37
- "check-version-modules": "1.1.1",
38
- "coveralls": "3.0.3",
39
- "eslint": "5.16.0",
40
- "husky": "2.3.0",
41
- "mocha": "6.1.4",
42
- "nyc": "14.1.1"
43
- },
44
- "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
45
- "engines": {
46
- "node": ">=6.0.0"
47
- },
48
- "designs": [
49
- "styles/test.css"
50
- ],
51
- "javascripts": [
52
- "scripts/test.js"
53
- ],
54
- "templates": [
55
- "templates/test.html"
56
- ]
57
- }
1
+ {
2
+ "name": "node-pluginsmanager-plugin",
3
+ "version": "0.1.5",
4
+ "description": "An abstract parent plugin for node-pluginsmanager",
5
+ "main": "lib/main.js",
6
+ "typings": "lib/index.d.ts",
7
+ "scripts": {
8
+ "lint": "npx eslint ./lib/**/*.js ./test/**/*.js",
9
+ "check-updates": "npx check-version-modules",
10
+ "unit-tests": "npx nyc --reporter=html --reporter=text mocha",
11
+ "tests": "npm run-script lint && npm run-script check-updates && npm run-script unit-tests",
12
+ "ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
13
+ },
14
+ "husky": {
15
+ "hooks": {
16
+ "pre-commit": "npm run-script lint",
17
+ "pre-push": "npm run-script tests"
18
+ }
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git://github.com/Psychopoulet/node-pluginsmanager-plugin"
23
+ },
24
+ "keywords": [
25
+ "plugin",
26
+ "manage",
27
+ "gestion"
28
+ ],
29
+ "author": "Sébastien VIDAL",
30
+ "license": "ISC",
31
+ "bugs": {
32
+ "url": "https://github.com/Psychopoulet/node-pluginsmanager-plugin/issues"
33
+ },
34
+ "dependencies": {},
35
+ "devDependencies": {
36
+ "@types/node": "20.11.24",
37
+ "check-version-modules": "2.1.1",
38
+ "coveralls": "3.1.1",
39
+ "eslint": "8.57.0",
40
+ "husky": "9.0.11",
41
+ "mocha": "10.3.0",
42
+ "nyc": "15.1.0"
43
+ },
44
+ "homepage": "https://github.com/Psychopoulet/node-pluginsmanager-plugin#readme",
45
+ "engines": {
46
+ "node": ">=6.0.0"
47
+ },
48
+ "designs": [
49
+ "styles/test.css"
50
+ ],
51
+ "javascripts": [
52
+ "scripts/test.js"
53
+ ],
54
+ "templates": [
55
+ "templates/test.html"
56
+ ]
57
+ }