node-pluginsmanager 3.4.1 → 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");
@@ -306,19 +307,31 @@ class PluginsManager extends node_events_1.default {
306
307
  return JSON.parse(content);
307
308
  });
308
309
  }).then((packageData) => {
309
- const entryPoint = (0, node_path_1.join)(directory, packageData.main);
310
310
  // check if the plugin has a valid entry point
311
- return (0, isFile_1.default)(entryPoint).then((hasPluginEntryPoint) => {
312
- if (!hasPluginEntryPoint) {
313
- throw new Error("\"" + repo + "\" plugin has no 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();
314
320
  }
315
- // check if the plugin is builded
316
- // @TODO : "build installed plugin" feature to be implemented
317
- }).then(() => {
318
- return (0, isFile_1.default)(entryPoint).then((isEntryPointAFile) => {
319
- if (!isEntryPointAFile) {
320
- throw new Error("\"" + repo + "\" plugin entry point is not builded");
321
- }
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"));
322
335
  });
323
336
  }).then(() => {
324
337
  if ("object" !== typeof packageData.dependencies || null === packageData.dependencies || 0 >= Object.keys(packageData.dependencies).length) {
@@ -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.1",
4
+ "version": "3.5.0",
5
5
  "description": "A plugins manager.",
6
6
 
7
7
  "type": "commonjs",