node-pluginsmanager 3.8.2 → 3.8.4

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
@@ -18,7 +18,7 @@ A plugins manager
18
18
  ## Installation
19
19
 
20
20
  ```bash
21
- $ npm install node-pluginsmanager
21
+ $ bun add node-pluginsmanager
22
22
  ```
23
23
 
24
24
  ## Features
@@ -107,8 +107,8 @@ Rules:
107
107
  ```bash
108
108
  $ git clone git://github.com/Psychopoulet/node-pluginsmanager.git
109
109
  $ cd ./node-pluginsmanager
110
- $ npm install
111
- $ npm run-script tests
110
+ $ bun install
111
+ $ bun run tests
112
112
  ```
113
113
 
114
114
  ## License
@@ -33,9 +33,8 @@ const isGitUsed_1 = __importDefault(require("./cmd/isGitUsed"));
33
33
  const gitInstall_1 = __importDefault(require("./cmd/git/gitInstall"));
34
34
  const gitUpdate_1 = __importDefault(require("./cmd/git/gitUpdate"));
35
35
  // npm
36
- const npmInstall_1 = __importDefault(require("./cmd/npm/npmInstall"));
37
- const npmBuild_1 = __importDefault(require("./cmd/npm/npmBuild"));
38
- const npmUpdate_1 = __importDefault(require("./cmd/npm/npmUpdate"));
36
+ const install_1 = __importDefault(require("./cmd/packages/install"));
37
+ const build_1 = __importDefault(require("./cmd/packages/build"));
39
38
  // consts
40
39
  const DEFAULT_PLUGINS_DIRECTORY = (0, node_path_1.join)((0, node_os_1.homedir)(), "node-pluginsmanager-plugins");
41
40
  const DEFAULT_RESOURCES_DIRECTORY = (0, node_path_1.join)((0, node_os_1.homedir)(), "node-pluginsmanager-resources");
@@ -417,11 +416,11 @@ class PluginsManager extends node_events_1.default {
417
416
  this._logger?.("info", "Installing dev dependencies...", false, pluginName);
418
417
  this.emit("installing", pluginName, 3, MAX_INSTALL_STEPS, "Installing dev dependencies...");
419
418
  // install plugin with dependencies
420
- return (0, npmInstall_1.default)(directory, true).then(() => {
419
+ return (0, install_1.default)(directory, true).then(() => {
421
420
  this._logger?.("success", "Plugin installed successfully", false, pluginName);
422
421
  this._logger?.("info", "Building plugin...", false, pluginName);
423
422
  this.emit("installing", pluginName, 4, MAX_INSTALL_STEPS, "Building plugin...");
424
- return (0, npmBuild_1.default)(directory);
423
+ return (0, build_1.default)(directory);
425
424
  // remove dev dependencies
426
425
  }).then(() => {
427
426
  this._logger?.("debug", "Removing dev dependencies...", false, pluginName);
@@ -436,7 +435,7 @@ class PluginsManager extends node_events_1.default {
436
435
  }
437
436
  this._logger?.("debug", "Installing plugin dependencies...", false, pluginName);
438
437
  this.emit("installing", pluginName, 6, MAX_INSTALL_STEPS, "Installing plugin dependencies...");
439
- return (0, npmInstall_1.default)(directory).then(() => {
438
+ return (0, install_1.default)(directory).then(() => {
440
439
  this._logger?.("success", "Dependencies installed successfully", false, pluginName);
441
440
  });
442
441
  });
@@ -609,7 +608,7 @@ class PluginsManager extends node_events_1.default {
609
608
  return Promise.resolve().then(() => {
610
609
  this._logger?.("debug", "Updating dependencies...", false, pluginName);
611
610
  this.emit("updating", pluginName, 5, MAX_UPDATE_STEPS, "Updating dependencies...");
612
- return !_plugin.dependencies ? Promise.resolve() : (0, npmUpdate_1.default)(directory);
611
+ return !_plugin.dependencies ? Promise.resolve() : (0, install_1.default)(directory);
613
612
  }).then(() => {
614
613
  this._logger?.("debug", "Executing plugin update script...", false, pluginName);
615
614
  this.emit("updating", pluginName, 6, MAX_UPDATE_STEPS, "Executing plugin update script...");
@@ -0,0 +1 @@
1
+ export default function packagesBuild(directory: string): Promise<void>;
@@ -0,0 +1,31 @@
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 = packagesBuild;
8
+ // locals
9
+ const getPackageManagerByName_1 = __importDefault(require("./tools/getPackageManagerByName"));
10
+ const hasBuildScripts_1 = __importDefault(require("./tools/hasBuildScripts"));
11
+ const cmd_1 = __importDefault(require("../cmd"));
12
+ // module
13
+ async function packagesBuild(directory) {
14
+ const packageManagerName = await (0, getPackageManagerByName_1.default)();
15
+ return (0, hasBuildScripts_1.default)(directory).then((buildScripts) => {
16
+ if (buildScripts.buildBack) {
17
+ return (0, cmd_1.default)(directory, packageManagerName, [
18
+ "run",
19
+ "build-back"
20
+ ]);
21
+ }
22
+ if (buildScripts.build) {
23
+ return (0, cmd_1.default)(directory, packageManagerName, [
24
+ "run",
25
+ "build"
26
+ ]);
27
+ }
28
+ // no need to build
29
+ return Promise.resolve();
30
+ });
31
+ }
@@ -0,0 +1 @@
1
+ export default function packagesInstall(directory: string, isDev?: boolean): Promise<void>;
@@ -0,0 +1,40 @@
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 = packagesInstall;
8
+ // locals
9
+ const getPackageManagerByName_1 = __importDefault(require("./tools/getPackageManagerByName"));
10
+ const hasInstallScripts_1 = __importDefault(require("./tools/hasInstallScripts"));
11
+ const cmd_1 = __importDefault(require("../cmd"));
12
+ // module
13
+ async function packagesInstall(directory, isDev = false) {
14
+ const packageManagerName = await (0, getPackageManagerByName_1.default)();
15
+ return (0, hasInstallScripts_1.default)(directory).then((installScripts) => {
16
+ if (installScripts.installDev && isDev) {
17
+ return (0, cmd_1.default)(directory, packageManagerName, [
18
+ "run",
19
+ "install-dev"
20
+ ]);
21
+ }
22
+ if (installScripts.installProd && !isDev) {
23
+ return (0, cmd_1.default)(directory, packageManagerName, [
24
+ "run",
25
+ "install-prod"
26
+ ]);
27
+ }
28
+ const flags = isDev ? ["--omit=optional"] : ["--omit=dev", "--omit=optional"];
29
+ return (0, cmd_1.default)(directory, packageManagerName, [
30
+ "install",
31
+ ...flags
32
+ ]).then(() => {
33
+ return (0, cmd_1.default)(directory, packageManagerName, [
34
+ "audit",
35
+ "fix",
36
+ ...flags
37
+ ]);
38
+ });
39
+ });
40
+ }
@@ -0,0 +1,2 @@
1
+ export type PackageManagerName = "bun" | "pnpn" | "yarn" | "npm";
2
+ export default function getPackageManagerByName(): Promise<PackageManagerName>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // deps
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.default = getPackageManagerByName;
5
+ // natives
6
+ const node_child_process_1 = require("node:child_process");
7
+ // private
8
+ // attributes
9
+ let _packageManagerNamePromise = null;
10
+ // methods
11
+ async function _getPackageManagerVersionByName(packageManagerName) {
12
+ return new Promise((resolve, reject) => {
13
+ (0, node_child_process_1.exec)(packageManagerName + " --version", (error, stdout, stderr) => {
14
+ if (error || 0 < stderr.length) {
15
+ return reject(new Error("Failed to get package manager version"));
16
+ }
17
+ return resolve(stdout.trim());
18
+ });
19
+ });
20
+ }
21
+ async function _checkPackageManagerByName(packageManagerName) {
22
+ return _getPackageManagerVersionByName(packageManagerName).then(() => {
23
+ return true;
24
+ }).catch(() => {
25
+ return false;
26
+ });
27
+ }
28
+ async function _resolvePackageManagerName() {
29
+ if (await _checkPackageManagerByName("bun")) {
30
+ return "bun";
31
+ }
32
+ if (await _checkPackageManagerByName("pnpn")) {
33
+ return "pnpn";
34
+ }
35
+ if (await _checkPackageManagerByName("yarn")) {
36
+ return "yarn";
37
+ }
38
+ if (await _checkPackageManagerByName("npm")) {
39
+ return "npm";
40
+ }
41
+ throw new Error("No package manager found");
42
+ }
43
+ // module
44
+ function getPackageManagerByName() {
45
+ if ("string" === typeof _packageManagerNamePromise) {
46
+ return _packageManagerNamePromise;
47
+ }
48
+ const packageManagerNamePromise = _resolvePackageManagerName().catch((error) => {
49
+ _packageManagerNamePromise = null;
50
+ throw error;
51
+ });
52
+ _packageManagerNamePromise = packageManagerNamePromise;
53
+ return packageManagerNamePromise;
54
+ }
@@ -0,0 +1,5 @@
1
+ export interface HasBuildScripts {
2
+ "buildBack": boolean;
3
+ "build": boolean;
4
+ }
5
+ export default function hasBuildScripts(packageDirectory: string): Promise<HasBuildScripts>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ // deps
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.default = hasBuildScripts;
5
+ // natives
6
+ const promises_1 = require("node:fs/promises");
7
+ const node_path_1 = require("node:path");
8
+ // module
9
+ function hasBuildScripts(packageDirectory) {
10
+ return (0, promises_1.readFile)((0, node_path_1.join)(packageDirectory, "package.json"), "utf-8").then((content) => {
11
+ const packageData = JSON.parse(content);
12
+ if ("object" !== typeof packageData.scripts || null === packageData.scripts) {
13
+ return {
14
+ "buildBack": false,
15
+ "build": false
16
+ };
17
+ }
18
+ const scripts = packageData.scripts;
19
+ return {
20
+ "buildBack": "string" === typeof scripts["build-back"] && "" !== scripts["build-back"].trim(),
21
+ "build": "string" === typeof scripts.build && "" !== scripts.build.trim()
22
+ };
23
+ });
24
+ }
@@ -0,0 +1,5 @@
1
+ export interface HasInstallScripts {
2
+ "installDev": boolean;
3
+ "installProd": boolean;
4
+ }
5
+ export default function hasInstallScripts(packageDirectory: string): Promise<HasInstallScripts>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ // deps
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.default = hasInstallScripts;
5
+ // natives
6
+ const promises_1 = require("node:fs/promises");
7
+ const node_path_1 = require("node:path");
8
+ // module
9
+ function hasInstallScripts(packageDirectory) {
10
+ return (0, promises_1.readFile)((0, node_path_1.join)(packageDirectory, "package.json"), "utf-8").then((content) => {
11
+ const packageData = JSON.parse(content);
12
+ if ("object" !== typeof packageData.scripts || null === packageData.scripts) {
13
+ return {
14
+ "installDev": false,
15
+ "installProd": false
16
+ };
17
+ }
18
+ const scripts = packageData.scripts;
19
+ return {
20
+ "installDev": "string" === typeof scripts["install-dev"] && "" !== scripts["install-dev"].trim(),
21
+ "installProd": "string" === typeof scripts["install-prod"] && "" !== scripts["install-prod"].trim()
22
+ };
23
+ });
24
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "node-pluginsmanager",
4
- "version": "3.8.2",
4
+ "version": "3.8.4",
5
5
  "description": "A plugins manager.",
6
6
 
7
7
  "type": "commonjs",
@@ -19,59 +19,60 @@
19
19
 
20
20
  "scripts": {
21
21
 
22
- "install-prod": "npm install --omit=dev --omit=optional && npm audit fix --omit=dev --omit=optional",
23
- "install-dev": "npm install --allow-git=root && npm audit fix --allow-git=root && npx husky",
22
+ "install-prod": "bun install --production",
23
+ "install-dev": "bun install && bunx husky",
24
24
 
25
- "lint-back": "npx eslint --config .eslintrc-back.js --ext .ts,.cts,.mts ./lib/src/**/*",
26
- "lint-tests": "npx eslint --config .eslintrc-tests.js --ext .js,.cjs,.mjs ./test/**/*.js",
27
- "lint": "npm run lint-back && npm run lint-tests",
25
+ "lint-back": "bunx eslint --config .eslintrc-back.js --ext .ts,.cts,.mts \"./lib/src/**/*\"",
26
+ "lint-tests": "bunx eslint --config .eslintrc-tests.js --ext .js,.cjs,.mjs \"./test/**/*.js\"",
27
+ "lint": "bun run lint-back && bun run lint-tests",
28
28
 
29
- "clean-back": "npx rimraf ./lib/cjs",
30
- "clean": "npm run clean-back",
29
+ "clean-back": "bunx rimraf ./lib/cjs",
30
+ "clean": "bun run clean-back",
31
31
 
32
- "build-back": "npm run clean-back && npx tsc --project ./tsconfig.json",
33
- "build": "npm run build-back",
32
+ "build-back": "bun run clean-back && bunx tsc --project ./tsconfig.json",
33
+ "build": "bun run build-back",
34
34
 
35
- "check-node-engine": "npx check-node-engine",
36
- "check-requires": "npx used-deps-analyzer ./package.json ./lib/src --no-dev",
37
- "check-updates": "npx check-version-modules --no-fail-at-major --fail-at-minor --fail-at-patch",
38
- "unit-tests": "npx c8 --reporter=text-summary --all --include \"lib/src/**/*.ts\" --include \"lib/src/**/*.cts\" --extension .ts --extension .cts --check-coverage --statements 95 --branches 95 --functions 95 --lines 95 mocha --require ./test/register.js",
39
- "unit-tests-local": "npx c8 --reporter=html --reporter=text --all --include \"lib/src/**/*.ts\" --include \"lib/src/**/*.cts\" --extension .ts --extension .cts mocha --require ./test/register.js",
35
+ "check-node-engine": "bunx check-node-engine",
36
+ "check-requires": "bunx used-deps-analyzer ./package.json ./lib/src --no-dev",
37
+ "check-updates": "bunx check-version-modules --no-fail-at-major --fail-at-minor --fail-at-patch",
38
+ "unit-tests": "bun test --conditions=require --coverage --timeout 10000",
39
+ "unit-tests-local": "bun test --conditions=require --coverage --coverage-reporter=text --timeout 10000",
40
40
 
41
- "tests": "npm run lint && npm run check-node-engine && npm run check-requires && npm run check-updates && npm run build && npm run unit-tests"
41
+ "tests": "bun run lint && bun run check-node-engine && bun run check-requires && bun run check-updates && bun run build && bun run unit-tests"
42
42
 
43
43
  },
44
44
 
45
45
  "files": [
46
46
  "/lib/cjs"
47
47
  ],
48
+ "packageManager": "bun@1.4.5",
48
49
  "engines": {
49
- "node": ">=24.22.2"
50
+ "node": ">=24.22.3",
51
+ "bun": ">=1.4.5"
50
52
  },
51
53
 
52
54
  "dependencies": {
53
- "check-node-engine": "1.2.1",
54
- "check-version-modules": "2.5.2",
55
+ "check-node-engine": "1.2.2",
56
+ "check-version-modules": "2.5.3",
55
57
  "semver": "7.8.6"
56
58
  },
57
59
  "devDependencies": {
58
60
  "@types/express": "5.0.6",
59
- "@types/node": "26.6.6",
61
+ "@types/node": "26.6.11",
60
62
  "@types/semver": "7.8.0",
61
63
  "@types/socket.io": "3.0.2",
62
64
  "@types/ws": "8.18.2",
63
- "c8": "12.0.0",
65
+ "ajv": "8.20.0",
64
66
  "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
65
67
  "express": "5.3.0",
66
68
  "husky": "9.1.7",
67
- "mocha": "12.0.3",
68
69
  "node-pluginsmanager-plugin": "7.4.5",
69
70
  "proxyquire": "2.1.3",
70
- "rimraf": "6.1.3",
71
+ "rimraf": "6.1.4",
71
72
  "socket.io": "4.8.4",
72
73
  "typescript": "6.0.3",
73
- "used-deps-analyzer": "0.4.1",
74
- "ws": "8.22.1"
74
+ "used-deps-analyzer": "0.4.2",
75
+ "ws": "8.23.1"
75
76
  },
76
77
  "overrides": {
77
78
  "glob": "14.0.3",
@@ -1 +0,0 @@
1
- export default function npmBuild(directory: string): Promise<void>;
@@ -1,13 +0,0 @@
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 +0,0 @@
1
- export default function npmInstall(directory: string, isBuildMode?: boolean): Promise<void>;
@@ -1,49 +0,0 @@
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 = npmInstall;
8
- // natives
9
- const promises_1 = require("node:fs/promises");
10
- const node_path_1 = require("node:path");
11
- // locals
12
- const cmd_1 = __importDefault(require("../cmd"));
13
- // private
14
- // methods
15
- function _hasInstallScripts(packageData) {
16
- if ("object" !== typeof packageData.scripts || null === packageData.scripts) {
17
- return false;
18
- }
19
- const scripts = packageData.scripts;
20
- const installDev = scripts["install-dev"];
21
- const installProd = scripts["install-prod"];
22
- if ("string" !== typeof installDev || "string" !== typeof installProd) {
23
- return false;
24
- }
25
- return "" !== installDev.trim() && "" !== installProd.trim();
26
- }
27
- // module
28
- function npmInstall(directory, isBuildMode = false) {
29
- return (0, promises_1.readFile)((0, node_path_1.join)(directory, "package.json"), "utf-8").then((content) => {
30
- const packageData = JSON.parse(content);
31
- if (_hasInstallScripts(packageData)) {
32
- return (0, cmd_1.default)(directory, "npm", [
33
- "run",
34
- isBuildMode ? "install-dev" : "install-prod"
35
- ]);
36
- }
37
- const flags = isBuildMode ? ["--omit=optional"] : ["--omit=dev", "--omit=optional"];
38
- return (0, cmd_1.default)(directory, "npm", [
39
- "install",
40
- ...flags
41
- ]).then(() => {
42
- return (0, cmd_1.default)(directory, "npm", [
43
- "audit",
44
- "fix",
45
- ...flags
46
- ]);
47
- });
48
- });
49
- }
@@ -1 +0,0 @@
1
- export default function npmUpdate(directory: string): Promise<void>;
@@ -1,17 +0,0 @@
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 = npmUpdate;
8
- // locals
9
- const cmd_1 = __importDefault(require("../cmd"));
10
- // module
11
- function npmUpdate(directory) {
12
- return (0, cmd_1.default)(directory, "npm", [
13
- "update",
14
- "--omit=dev",
15
- "--omit=optional"
16
- ]);
17
- }