node-confmanager 1.8.1 → 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) 2022, 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,15 +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
- if (!nextArgs.length) {
71
- this.set(key, []);
72
- }
73
- else {
70
+ if (nextArgs.length) {
74
71
  const endArrayArgs = nextArgs.findIndex((a) => {
75
- return a.startsWith("--") ||
76
- (a.startsWith("-") && !!this.shortcuts[a.slice(1)]);
72
+ return a.startsWith("--")
73
+ || (a.startsWith("-") && !!this.shortcuts[a.slice(1)]);
77
74
  });
78
75
  const values = 0 < endArrayArgs ? nextArgs.slice(0, endArrayArgs) : nextArgs;
79
76
  if (1 === values.length && values[0].startsWith("[") && values[0].endsWith("]")) {
@@ -126,7 +123,7 @@ class ConfManager extends NodeContainerPattern {
126
123
  }
127
124
  }
128
125
  else {
129
- return (0, promises_1.readFile)(this.filePath, "utf8").then((content) => {
126
+ return (0, promises_1.readFile)(this.filePath, "utf-8").then((content) => {
130
127
  return JSON.parse(content);
131
128
  }).then((data) => {
132
129
  for (const key in data) {
@@ -148,9 +145,9 @@ class ConfManager extends NodeContainerPattern {
148
145
  this.forEach((value, key) => {
149
146
  objects[key] = value;
150
147
  });
151
- return this.spaces ?
152
- (0, promises_1.writeFile)(this.filePath, JSON.stringify(objects, undefined, 2), "utf8") :
153
- (0, promises_1.writeFile)(this.filePath, JSON.stringify(objects), "utf8");
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");
154
151
  });
155
152
  }
156
153
  // bind a shortcut for commandline
@@ -161,4 +158,3 @@ class ConfManager extends NodeContainerPattern {
161
158
  }
162
159
  }
163
160
  exports.default = ConfManager;
164
- ;
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,84 +1,94 @@
1
- {
2
- "name": "node-confmanager",
3
- "version": "1.8.1",
4
- "description": "A configuration manager",
5
-
6
- "type": "commonjs",
7
- "typings": "./lib/cjs/main.d.cts",
8
- "main": "./lib/cjs/main.cjs",
9
-
10
- "exports": {
11
- ".": {
12
- "require": {
13
- "types": "./lib/cjs/main.d.cts",
14
- "default": "./lib/cjs/main.cjs"
15
- }
16
- }
17
- },
18
-
19
- "scripts": {
20
-
21
- "build": "npx tsc --project \"./tsconfig.json\"",
22
-
23
- "lint": "npx eslint ./test/**/*.js",
24
- "check-requires": "npx used-deps-analyzer \"./package.json\" \"./src\" --no-dev --overkill \"fs-extra\" \"node-promfs\"",
25
- "check-updates": "npx check-version-modules",
26
- "unit-tests": "npm run build && npx nyc --reporter=html --reporter=text mocha",
27
-
28
- "tests": "npm run-script lint && npm run check-requires && npm run-script check-updates && npm run-script unit-tests",
29
- "ci": "npm run-script tests && npx nyc report --reporter=text-lcov | coveralls"
30
-
31
- },
32
-
33
- "files": [
34
- "/lib"
35
- ],
36
-
37
- "husky": {
38
- "hooks": {
39
- "pre-push": "npm run-script tests"
40
- }
41
- },
42
- "repository": {
43
- "type": "git",
44
- "url": "git://github.com/Psychopoulet/node-confmanager.git"
45
- },
46
- "keywords": [
47
- "node",
48
- "conf",
49
- "config",
50
- "configuration",
51
- "manage",
52
- "save",
53
- "load",
54
- "Map",
55
- "recursive",
56
- "skeleton",
57
- "structure",
58
- "pattern",
59
- "container"
60
- ],
61
- "author": "Sébastien VIDAL",
62
- "license": "ISC",
63
- "bugs": {
64
- "url": "https://github.com/Psychopoulet/node-confmanager/issues"
65
- },
66
- "dependencies": {
67
- "node-containerpattern": "1.7.5"
68
- },
69
- "devDependencies": {
70
- "@types/node": "20.5.0",
71
- "check-version-modules": "1.3.5",
72
- "coveralls": "3.1.1",
73
- "eslint": "8.47.0",
74
- "husky": "8.0.3",
75
- "mocha": "10.2.0",
76
- "nyc": "15.1.0",
77
- "typescript": "5.1.6",
78
- "used-deps-analyzer": "0.1.2"
79
- },
80
- "homepage": "https://github.com/Psychopoulet/node-confmanager#readme",
81
- "engines": {
82
- "node": ">=16.0.0"
83
- }
84
- }
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
+ }