@ix-xs/node-comfort 1.0.3 → 1.0.5
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/index.js +12 -14
- package/package.json +17 -17
- package/src/checker.js +76 -0
- package/src/cli.js +86 -0
- package/{core/FS.js → src/fs.js} +121 -230
- package/src/localStorage.js +242 -0
- package/{core/Logger.js → src/logger.js} +23 -97
- package/src/utils.js +225 -0
- package/tsconfig.json +1 -1
- package/types/index.d.ts +73 -50
- package/types/src/checker.d.ts +49 -0
- package/types/src/checker.d.ts.map +1 -0
- package/types/src/cli.d.ts +26 -0
- package/types/src/cli.d.ts.map +1 -0
- package/types/src/fs.d.ts +210 -0
- package/types/src/fs.d.ts.map +1 -0
- package/types/src/localStorage.d.ts +97 -0
- package/types/src/localStorage.d.ts.map +1 -0
- package/types/src/logger.d.ts +132 -0
- package/types/src/logger.d.ts.map +1 -0
- package/types/src/utils.d.ts +92 -0
- package/types/src/utils.d.ts.map +1 -0
- package/core/CLI.js +0 -95
- package/core/Checker.js +0 -127
- package/core/Stepper.js +0 -115
- package/core/Storage.js +0 -348
- package/core/Utils.js +0 -206
- package/types/core/CLI.d.ts +0 -25
- package/types/core/CLI.d.ts.map +0 -1
- package/types/core/Checker.d.ts +0 -73
- package/types/core/Checker.d.ts.map +0 -1
- package/types/core/FS.d.ts +0 -211
- package/types/core/FS.d.ts.map +0 -1
- package/types/core/Logger.d.ts +0 -253
- package/types/core/Logger.d.ts.map +0 -1
- package/types/core/Stepper.d.ts +0 -49
- package/types/core/Stepper.d.ts.map +0 -1
- package/types/core/Storage.d.ts +0 -111
- package/types/core/Storage.d.ts.map +0 -1
- package/types/core/Utils.d.ts +0 -55
- package/types/core/Utils.d.ts.map +0 -1
package/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const Utils = require("./core/Utils");
|
|
1
|
+
const checker = require("./src/checker");
|
|
2
|
+
const cli = require("./src/cli");
|
|
3
|
+
const fs = require("./src/fs");
|
|
4
|
+
const localStorage = require("./src/localStorage");
|
|
5
|
+
const logger = require("./src/logger");
|
|
6
|
+
const utils = require("./src/utils");
|
|
8
7
|
|
|
9
8
|
module.exports = {
|
|
10
|
-
...
|
|
11
|
-
...
|
|
12
|
-
|
|
13
|
-
...
|
|
14
|
-
...
|
|
15
|
-
...
|
|
16
|
-
...Utils,
|
|
9
|
+
...checker,
|
|
10
|
+
...cli,
|
|
11
|
+
...fs,
|
|
12
|
+
...localStorage,
|
|
13
|
+
...logger,
|
|
14
|
+
...utils,
|
|
17
15
|
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
2
|
+
"name": "@ix-xs/node-comfort",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"type": "commonjs",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^25.2.0",
|
|
16
|
+
"typescript": "^5.9.3"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/checker.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const { types } = require("node:util");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
/**
|
|
5
|
+
* @param {*} value
|
|
6
|
+
*/
|
|
7
|
+
isArray(value) {
|
|
8
|
+
return Array.isArray(value);
|
|
9
|
+
},
|
|
10
|
+
/**
|
|
11
|
+
* @param {*} value
|
|
12
|
+
*/
|
|
13
|
+
isNumber(value) {
|
|
14
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* @param {*} value
|
|
18
|
+
*/
|
|
19
|
+
isFunction(value) {
|
|
20
|
+
return typeof value === "function";
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* @param {*} value
|
|
24
|
+
*/
|
|
25
|
+
isObject(value) {
|
|
26
|
+
return typeof value === "object" && value !== null;
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* @param {*} value
|
|
30
|
+
*/
|
|
31
|
+
isBoolean(value) {
|
|
32
|
+
return typeof value === "boolean";
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* @param {*} value
|
|
36
|
+
*/
|
|
37
|
+
isString(value) {
|
|
38
|
+
return typeof value === "string";
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* @param {*} value
|
|
42
|
+
*/
|
|
43
|
+
isUndefined(value) {
|
|
44
|
+
return typeof value === "undefined";
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* @param {*} value
|
|
48
|
+
*/
|
|
49
|
+
isNull(value) {
|
|
50
|
+
return value === null;
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* @param {*} value
|
|
54
|
+
*/
|
|
55
|
+
isDate(value) {
|
|
56
|
+
return types.isDate(value);
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* @param {*} value
|
|
60
|
+
*/
|
|
61
|
+
isMap(value) {
|
|
62
|
+
return types.isMap(value);
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* @param {*} value
|
|
66
|
+
*/
|
|
67
|
+
isSet(value) {
|
|
68
|
+
return types.isSet(value);
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* @param {*} value
|
|
72
|
+
*/
|
|
73
|
+
isError(value) {
|
|
74
|
+
return types.isNativeError(value);
|
|
75
|
+
},
|
|
76
|
+
};
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const { execSync, spawn } = require("node:child_process");
|
|
2
|
+
const EventEmitter = require("node:events");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
exec(command) {
|
|
6
|
+
return execSync(command, {
|
|
7
|
+
shell: true,
|
|
8
|
+
stdio: "pipe",
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
stream: class {
|
|
12
|
+
#processus;
|
|
13
|
+
#events = new EventEmitter();
|
|
14
|
+
|
|
15
|
+
constructor(command, args) {
|
|
16
|
+
this.#processus = spawn(command, args, {
|
|
17
|
+
shell: true,
|
|
18
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
this.#processus.stdout.on("data", (data) => {
|
|
22
|
+
this.#events.emit("data", data.toString());
|
|
23
|
+
});
|
|
24
|
+
this.#processus.stderr.on("data", (data) => {
|
|
25
|
+
this.#events.emit("data", data.toString());
|
|
26
|
+
});
|
|
27
|
+
this.#processus.on("error", (error) => {
|
|
28
|
+
this.#events.emit("error", error);
|
|
29
|
+
});
|
|
30
|
+
this.#processus.on("exit", async (code, signal) => {
|
|
31
|
+
await this.stop();
|
|
32
|
+
});
|
|
33
|
+
this.#processus.on("close", (code, signal) => {
|
|
34
|
+
this.#events.emit("stopped", code, signal);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {"error"|"data"|"stopped"} EventName
|
|
40
|
+
* @typedef {{
|
|
41
|
+
* error: (error: Error) => void|Promise<void>,
|
|
42
|
+
* data: (chunk: string) => void|Promise<void>,
|
|
43
|
+
* stopped: (code: number|null, signal: keyof import("node:child_process").ChildProcessEventMap) => void|Promise<void>,
|
|
44
|
+
* }} EventHandler
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* @template {EventName} E
|
|
48
|
+
* @param {E} event
|
|
49
|
+
* @param {EventHandler[E]} handler
|
|
50
|
+
*/
|
|
51
|
+
on(event, handler) {
|
|
52
|
+
this.#events.on(event, handler);
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async stop() {
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
if (!this.#processus || this.#processus.killed) {
|
|
59
|
+
this.#processus = null;
|
|
60
|
+
return resolve();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let resolved = false;
|
|
64
|
+
|
|
65
|
+
const done = () => {
|
|
66
|
+
if (!resolved) {
|
|
67
|
+
resolved = true;
|
|
68
|
+
this.#processus = null;
|
|
69
|
+
resolve();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
this.#processus.once("exit", done);
|
|
74
|
+
|
|
75
|
+
this.#processus.kill("SIGTERM");
|
|
76
|
+
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
if (this.#processus && !this.#processus.killed && !resolved) {
|
|
79
|
+
this.#processus.kill("SIGKILL");
|
|
80
|
+
}
|
|
81
|
+
done();
|
|
82
|
+
}, 5000);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
};
|