node-pluginsmanager 3.4.0 → 3.5.0

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.
@@ -30,6 +30,7 @@ const gitInstall_1 = __importDefault(require("./cmd/git/gitInstall"));
30
30
  const gitUpdate_1 = __importDefault(require("./cmd/git/gitUpdate"));
31
31
  // npm
32
32
  const npmInstall_1 = __importDefault(require("./cmd/npm/npmInstall"));
33
+ const npmBuild_1 = __importDefault(require("./cmd/npm/npmBuild"));
33
34
  const npmUpdate_1 = __importDefault(require("./cmd/npm/npmUpdate"));
34
35
  // consts
35
36
  const DEFAULT_PLUGINS_DIRECTORY = (0, node_path_1.join)((0, node_os_1.homedir)(), "node-pluginsmanager-plugins");
@@ -288,21 +289,56 @@ class PluginsManager extends node_events_1.default {
288
289
  // check if plugin directory is created
289
290
  }).then(() => {
290
291
  return (0, isDirectory_1.default)(directory).then((isPluginADirectory) => {
291
- return !isPluginADirectory ? Promise.reject(new Error("\"" + repo + "\" plugin directory is not created")) : Promise.resolve();
292
+ if (!isPluginADirectory) {
293
+ throw new Error("\"" + repo + "\" plugin directory is not created");
294
+ }
292
295
  });
293
- // check if plugin has a valid package.json
294
- }).then(() => {
295
- return (0, isFile_1.default)((0, node_path_1.join)(directory, "package.json")).then((isPluginAPackageFile) => {
296
- return !isPluginAPackageFile ? Promise.reject(new Error("\"" + repo + "\" plugin has no valid package.json")) : Promise.resolve();
297
- });
298
- // install dependencies if needed
296
+ // work around package.json
299
297
  }).then(() => {
300
- return (0, promises_1.readFile)((0, node_path_1.join)(directory, "package.json"), "utf-8").then((content) => {
301
- return JSON.parse(content);
302
- }).then(({ dependencies }) => {
303
- return "object" !== typeof dependencies || null === dependencies || 0 >= Object.keys(dependencies).length
304
- ? Promise.resolve()
305
- : (0, npmInstall_1.default)(directory);
298
+ const packageFile = (0, node_path_1.join)(directory, "package.json");
299
+ // check if plugin has a valid package.json
300
+ return (0, isFile_1.default)(packageFile).then((isPluginAPackageFile) => {
301
+ if (!isPluginAPackageFile) {
302
+ throw new Error("\"" + repo + "\" plugin has no valid package.json");
303
+ }
304
+ // read package.json and parse it
305
+ }).then(() => {
306
+ return (0, promises_1.readFile)(packageFile, "utf-8").then((content) => {
307
+ return JSON.parse(content);
308
+ });
309
+ }).then((packageData) => {
310
+ // check if the plugin has a valid entry point
311
+ if ("string" !== typeof packageData.main || "" === packageData.main.trim()) {
312
+ throw new Error("\"" + repo + "\" plugin has no valid entry point");
313
+ }
314
+ const entryPoint = (0, node_path_1.join)(directory, packageData.main);
315
+ // check if the plugin is builded (build it if needed)
316
+ return (0, isFile_1.default)(entryPoint).then((isEntryPointAFile) => {
317
+ // already built, no need to build it
318
+ if (isEntryPointAFile) {
319
+ return Promise.resolve();
320
+ }
321
+ // check if the plugin has a build script
322
+ if ("object" !== typeof packageData.scripts || null === packageData.scripts || 0 >= Object.keys(packageData.scripts).length) {
323
+ throw new Error("\"" + repo + "\" plugin has no scripts registered");
324
+ }
325
+ const scripts = packageData.scripts;
326
+ if ("string" !== typeof scripts.build || "" === scripts.build.trim()) {
327
+ throw new Error("\"" + repo + "\" plugin has no build script registered");
328
+ }
329
+ // install plugin with dependencies
330
+ return (0, npmInstall_1.default)(directory, true).then(() => {
331
+ return (0, npmBuild_1.default)(directory);
332
+ // remove dev dependencies
333
+ }).then(() => {
334
+ return (0, rmdirp_1.default)((0, node_path_1.join)(directory, "node_modules"));
335
+ });
336
+ }).then(() => {
337
+ if ("object" !== typeof packageData.dependencies || null === packageData.dependencies || 0 >= Object.keys(packageData.dependencies).length) {
338
+ return Promise.resolve();
339
+ }
340
+ return (0, npmInstall_1.default)(directory);
341
+ });
306
342
  });
307
343
  // create plugin
308
344
  }).then(() => {
@@ -0,0 +1 @@
1
+ export default function npmBuild(directory: string): Promise<void>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // deps
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.default = npmBuild;
8
+ // locals
9
+ const cmd_1 = __importDefault(require("../cmd"));
10
+ // module
11
+ function npmBuild(directory) {
12
+ return (0, cmd_1.default)(directory, "npm", ["run", "build"]);
13
+ }
@@ -1 +1 @@
1
- export default function npmInstall(directory: string): Promise<void>;
1
+ export default function npmInstall(directory: string, isBuildMode?: boolean): Promise<void>;
@@ -8,10 +8,9 @@ exports.default = npmInstall;
8
8
  // locals
9
9
  const cmd_1 = __importDefault(require("../cmd"));
10
10
  // module
11
- function npmInstall(directory) {
11
+ function npmInstall(directory, isBuildMode = false) {
12
12
  return (0, cmd_1.default)(directory, "npm", [
13
13
  "install",
14
- "--omit=dev",
15
- "--no-optional"
14
+ ...(isBuildMode ? ["--no-optional"] : ["--omit=dev", "--no-optional"])
16
15
  ]);
17
16
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "node-pluginsmanager",
4
- "version": "3.4.0",
4
+ "version": "3.5.0",
5
5
  "description": "A plugins manager.",
6
6
 
7
7
  "type": "commonjs",
@@ -52,14 +52,14 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/express": "5.0.6",
55
- "@types/node": "25.9.1",
55
+ "@types/node": "25.9.2",
56
56
  "@types/socket.io": "3.0.2",
57
57
  "@types/ws": "8.18.1",
58
58
  "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
59
59
  "express": "5.2.1",
60
60
  "husky": "9.1.7",
61
61
  "mocha": "11.7.6",
62
- "node-pluginsmanager-plugin": "7.3.0",
62
+ "node-pluginsmanager-plugin": "7.3.2",
63
63
  "nyc": "18.0.0",
64
64
  "proxyquire": "2.1.3",
65
65
  "rimraf": "6.1.3",