node-confmanager 1.8.2 → 1.9.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.
package/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright (c) 2023, Sébastien Vidal
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any
4
- purpose with or without fee is hereby granted, provided that the above
5
- copyright notice and this permission notice appear in all copies.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ Copyright (c) 2024, Sébastien Vidal
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -2,9 +2,7 @@ import NodeContainerPattern = require("node-containerpattern");
2
2
  export default class ConfManager extends NodeContainerPattern {
3
3
  filePath: string;
4
4
  spaces: boolean;
5
- shortcuts: {
6
- [key: string]: string;
7
- };
5
+ shortcuts: Record<string, string>;
8
6
  constructor(filePath: string, spaces?: boolean, recursionSeparator?: string);
9
7
  private _loadFromConsole;
10
8
  clear(): void;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
+ // deps
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
5
  };
5
6
  Object.defineProperty(exports, "__esModule", { value: true });
6
- // deps
7
7
  // natives
8
8
  const node_path_1 = require("node:path");
9
9
  const promises_1 = require("node:fs/promises");
@@ -65,12 +65,12 @@ class ConfManager extends NodeContainerPattern {
65
65
  throw new ReferenceError("Missing value for \"" + argument + "\" key (next argument is a valid shortcut)");
66
66
  }
67
67
  // array
68
- else if (this.skeletons[key] && "array" === this.skeletons[key]) {
68
+ else if ("undefined" !== typeof this.skeletons[key] && "array" === this.skeletons[key]) {
69
69
  const nextArgs = args.slice(i + 1, args.length);
70
70
  if (nextArgs.length) {
71
71
  const endArrayArgs = nextArgs.findIndex((a) => {
72
- return a.startsWith("--") ||
73
- (a.startsWith("-") && !!this.shortcuts[a.slice(1)]);
72
+ return a.startsWith("--")
73
+ || (a.startsWith("-") && !!this.shortcuts[a.slice(1)]);
74
74
  });
75
75
  const values = 0 < endArrayArgs ? nextArgs.slice(0, endArrayArgs) : nextArgs;
76
76
  if (1 === values.length && values[0].startsWith("[") && values[0].endsWith("]")) {
@@ -145,9 +145,9 @@ class ConfManager extends NodeContainerPattern {
145
145
  this.forEach((value, key) => {
146
146
  objects[key] = value;
147
147
  });
148
- return this.spaces ?
149
- (0, promises_1.writeFile)(this.filePath, JSON.stringify(objects, undefined, 2), "utf-8") :
150
- (0, promises_1.writeFile)(this.filePath, JSON.stringify(objects), "utf-8");
148
+ return this.spaces
149
+ ? (0, promises_1.writeFile)(this.filePath, JSON.stringify(objects, undefined, 2), "utf-8")
150
+ : (0, promises_1.writeFile)(this.filePath, JSON.stringify(objects), "utf-8");
151
151
  });
152
152
  }
153
153
  // bind a shortcut for commandline
@@ -158,4 +158,3 @@ class ConfManager extends NodeContainerPattern {
158
158
  }
159
159
  }
160
160
  exports.default = ConfManager;
161
- ;
package/lib/cjs/main.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
+ // deps
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
5
  };
5
- // deps
6
6
  // locals
7
7
  const NodeConfManager_1 = __importDefault(require("./NodeConfManager"));
8
8
  module.exports = NodeConfManager_1.default;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  // module
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  function checkShortcut(key, shortkey) {
5
5
  if ("undefined" === typeof key) {
6
6
  throw new ReferenceError("Missing \"key\" parameter");
@@ -28,4 +28,3 @@ function checkShortcut(key, shortkey) {
28
28
  }
29
29
  }
30
30
  exports.default = checkShortcut;
31
- ;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  // module
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  function clone(from) {
5
5
  if (from && "object" === typeof from) {
6
6
  if (Object === from.constructor) {
7
7
  return Object.assign({}, from);
8
8
  }
9
- else if (Array === from.constructor) {
9
+ else if (Array.isArray(from)) {
10
10
  return [...from];
11
11
  }
12
12
  else {
@@ -18,4 +18,3 @@ function clone(from) {
18
18
  }
19
19
  }
20
20
  exports.default = clone;
21
- ;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  // deps
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  // natives
5
5
  const node_fs_1 = require("node:fs");
6
6
  // module
@@ -23,4 +23,3 @@ function isFile(file) {
23
23
  });
24
24
  }
25
25
  exports.default = isFile;
26
- ;
package/package.json CHANGED
@@ -1,89 +1,94 @@
1
- {
2
-
3
- "name": "node-confmanager",
4
- "version": "1.8.2",
5
- "description": "A configuration manager",
6
-
7
- "type": "commonjs",
8
- "typings": "./lib/cjs/main.d.cts",
9
- "main": "./lib/cjs/main.cjs",
10
-
11
- "exports": {
12
- ".": {
13
- "require": {
14
- "types": "./lib/cjs/main.d.cts",
15
- "default": "./lib/cjs/main.cjs"
16
- }
17
- }
18
- },
19
-
20
- "scripts": {
21
-
22
- "build": "node ./removeOldBuild.js && npx tsc --project \"./tsconfig.json\"",
23
-
24
- "lint": "npx eslint ./test/**/*.js",
25
- "check-requires": "npx used-deps-analyzer \"./package.json\" \"./src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
26
- "check-updates": "npx check-version-modules",
27
- "unit-tests": "npm run build && npx nyc --reporter=html --reporter=text mocha",
28
-
29
- "tests": "npm run-script lint && npm run check-requires && npm run-script check-updates && npm run-script unit-tests",
30
- "ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
31
-
32
- },
33
-
34
- "files": [
35
- "/lib"
36
- ],
37
- "engines": {
38
- "node": ">=16.0.0"
39
- },
40
-
41
- "dependencies": {
42
- "node-containerpattern": "1.7.6"
43
- },
44
- "devDependencies": {
45
- "@types/node": "20.8.2",
46
- "check-version-modules": "2.0.0",
47
- "coveralls": "3.1.1",
48
- "eslint": "8.50.0",
49
- "husky": "8.0.3",
50
- "mocha": "10.2.0",
51
- "nyc": "15.1.0",
52
- "typescript": "5.2.2",
53
- "used-deps-analyzer": "0.1.8"
54
- },
55
- "optionalDependencies": {},
56
-
57
- "husky": {
58
- "hooks": {
59
- "pre-push": "npm run-script tests"
60
- }
61
- },
62
- "keywords": [
63
- "node",
64
- "conf",
65
- "config",
66
- "configuration",
67
- "manage",
68
- "save",
69
- "load",
70
- "Map",
71
- "recursive",
72
- "skeleton",
73
- "structure",
74
- "pattern",
75
- "container"
76
- ],
77
- "author": "Sébastien VIDAL",
78
- "license": "ISC",
79
-
80
- "homepage": "https://github.com/Psychopoulet/node-confmanager#readme",
81
- "repository": {
82
- "type": "git",
83
- "url": "git://github.com/Psychopoulet/node-confmanager.git"
84
- },
85
- "bugs": {
86
- "url": "https://github.com/Psychopoulet/node-confmanager/issues"
87
- }
88
-
89
- }
1
+ {
2
+
3
+ "name": "node-confmanager",
4
+ "version": "1.9.0",
5
+ "description": "A configuration manager",
6
+
7
+ "type": "commonjs",
8
+ "typings": "./lib/cjs/main.d.cts",
9
+ "main": "./lib/cjs/main.cjs",
10
+
11
+ "exports": {
12
+ ".": {
13
+ "require": {
14
+ "types": "./lib/cjs/main.d.cts",
15
+ "default": "./lib/cjs/main.cjs"
16
+ }
17
+ }
18
+ },
19
+
20
+ "scripts": {
21
+
22
+ "prepare": "npx husky install",
23
+
24
+ "clean": "npx rimraf lib",
25
+ "build": "npm run-script clean && npx tsc --project \"./tsconfig.json\"",
26
+
27
+ "lint": "npx eslint --config .eslintrc-src.js --ext .cts,.ts ./src/**/* && npx eslint --config .eslintrc-tests.js ./test/**/*.js",
28
+ "check-requires": "npx used-deps-analyzer \"./package.json\" \"./src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
29
+ "check-updates": "npx check-version-modules",
30
+ "unit-tests": "npm run build && npx nyc --reporter=html --reporter=text mocha",
31
+
32
+ "tests": "npm run-script lint && npm run check-requires && npm run-script check-updates && npm run-script unit-tests"
33
+
34
+ },
35
+
36
+ "files": [
37
+ "/bin",
38
+ "/lib",
39
+ "/public"
40
+ ],
41
+ "engines": {
42
+ "node": ">=16.0.0"
43
+ },
44
+
45
+ "dependencies": {
46
+ "node-containerpattern": "1.8.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "20.11.0",
50
+ "check-version-modules": "2.0.0",
51
+ "colors": "1.4.0",
52
+ "eslint-plugin-personnallinter": "git+ssh://git@github.com/Psychopoulet/eslint-plugin-personnallinter",
53
+ "husky": "8.0.3",
54
+ "mocha": "10.2.0",
55
+ "nyc": "15.1.0",
56
+ "rimraf": "5.0.5",
57
+ "typescript": "5.3.3",
58
+ "used-deps-analyzer": "0.1.8"
59
+ },
60
+ "optionalDependencies": {},
61
+
62
+ "husky": {
63
+ "hooks": {
64
+ "pre-push": "npm run-script tests"
65
+ }
66
+ },
67
+ "keywords": [
68
+ "node",
69
+ "conf",
70
+ "config",
71
+ "configuration",
72
+ "manage",
73
+ "save",
74
+ "load",
75
+ "Map",
76
+ "recursive",
77
+ "skeleton",
78
+ "structure",
79
+ "pattern",
80
+ "container"
81
+ ],
82
+ "author": "Sébastien VIDAL",
83
+ "license": "ISC",
84
+
85
+ "homepage": "https://github.com/Psychopoulet/node-confmanager#readme",
86
+ "repository": {
87
+ "type": "git",
88
+ "url": "git://github.com/Psychopoulet/node-confmanager.git"
89
+ },
90
+ "bugs": {
91
+ "url": "https://github.com/Psychopoulet/node-confmanager/issues"
92
+ }
93
+
94
+ }