@hapico/cli 0.0.16 → 0.0.17
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/bin/index.js +1 -1
- package/bin/utils/codemod/utils/path.mockup.js +84 -0
- package/bun.lock +6 -0
- package/dist/index.js +1 -1
- package/dist/utils/codemod/utils/path.mockup.js +84 -0
- package/index.ts +1 -1
- package/package.json +3 -1
- package/utils/codemod/index.tsx +1588 -0
- package/utils/codemod/utils/path.mockup.ts +97 -0
package/bin/index.js
CHANGED
|
@@ -244,7 +244,7 @@ class RoomState {
|
|
|
244
244
|
if (this.reconnectTimeout) {
|
|
245
245
|
clearTimeout(this.reconnectTimeout);
|
|
246
246
|
}
|
|
247
|
-
this.ws = new ws_1.WebSocket(`https://
|
|
247
|
+
this.ws = new ws_1.WebSocket(`https://ws2.myworkbeast.com/ws?room=${this.roomId}`);
|
|
248
248
|
this.ws.onopen = () => {
|
|
249
249
|
console.log(`Connected to room: ${this.roomId}`);
|
|
250
250
|
this.isConnected = true;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Path {
|
|
4
|
+
static normalizeSlashes(path) {
|
|
5
|
+
return path.replace(/\\/g, "/");
|
|
6
|
+
}
|
|
7
|
+
// Tương tự path.join()
|
|
8
|
+
static join(...paths) {
|
|
9
|
+
const normalizedPaths = paths
|
|
10
|
+
.filter((p) => p && typeof p === "string")
|
|
11
|
+
.map((p) => this.normalizeSlashes(p.trim()))
|
|
12
|
+
.map((p) => p.replace(/^\/+|\/+$/g, "")); // Loại bỏ slash đầu và cuối
|
|
13
|
+
return normalizedPaths.join("/");
|
|
14
|
+
}
|
|
15
|
+
// Tương tự path.resolve()
|
|
16
|
+
static resolve(...paths) {
|
|
17
|
+
let resolvedPath = "";
|
|
18
|
+
const segments = [];
|
|
19
|
+
paths
|
|
20
|
+
.filter((p) => p && typeof p === "string")
|
|
21
|
+
.map((p) => this.normalizeSlashes(p))
|
|
22
|
+
.forEach((path) => {
|
|
23
|
+
if (path.startsWith("/")) {
|
|
24
|
+
segments.length = 0; // Reset nếu gặp absolute path
|
|
25
|
+
segments.push(...path.split("/").filter(Boolean));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
segments.push(...path.split("/").filter(Boolean));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const resolvedSegments = [];
|
|
32
|
+
for (const segment of segments) {
|
|
33
|
+
if (segment === "..") {
|
|
34
|
+
resolvedSegments.pop();
|
|
35
|
+
}
|
|
36
|
+
else if (segment !== ".") {
|
|
37
|
+
resolvedSegments.push(segment);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
resolvedPath = resolvedSegments.join("/");
|
|
41
|
+
return resolvedPath.startsWith("/") ? `/${resolvedPath}` : resolvedPath;
|
|
42
|
+
}
|
|
43
|
+
// Tương tự path.basename()
|
|
44
|
+
static basename(path, ext) {
|
|
45
|
+
const normalized = this.normalizeSlashes(path);
|
|
46
|
+
const base = normalized.split("/").pop() || "";
|
|
47
|
+
return ext && base.endsWith(ext) ? base.slice(0, -ext.length) : base;
|
|
48
|
+
}
|
|
49
|
+
// Tương tự path.dirname()
|
|
50
|
+
static dirname(path) {
|
|
51
|
+
const normalized = this.normalizeSlashes(path);
|
|
52
|
+
const segments = normalized.split("/");
|
|
53
|
+
segments.pop();
|
|
54
|
+
return segments.join("/") || ".";
|
|
55
|
+
}
|
|
56
|
+
// Tương tự path.extname()
|
|
57
|
+
static extname(path) {
|
|
58
|
+
const base = this.basename(path);
|
|
59
|
+
const dotIndex = base.lastIndexOf(".");
|
|
60
|
+
return dotIndex > 0 ? base.slice(dotIndex) : "";
|
|
61
|
+
}
|
|
62
|
+
// Tương tự path.isAbsolute()
|
|
63
|
+
static isAbsolute(path) {
|
|
64
|
+
return this.normalizeSlashes(path).startsWith("/");
|
|
65
|
+
}
|
|
66
|
+
// Tương tự path.relative()
|
|
67
|
+
static relative(from, to) {
|
|
68
|
+
const fromParts = this.normalizeSlashes(from).split("/").filter(Boolean);
|
|
69
|
+
const toParts = this.normalizeSlashes(to).split("/").filter(Boolean);
|
|
70
|
+
// Tìm điểm chung
|
|
71
|
+
let i = 0;
|
|
72
|
+
while (i < fromParts.length &&
|
|
73
|
+
i < toParts.length &&
|
|
74
|
+
fromParts[i] === toParts[i]) {
|
|
75
|
+
i++;
|
|
76
|
+
}
|
|
77
|
+
// Tính số bước đi lên
|
|
78
|
+
const upCount = fromParts.length - i;
|
|
79
|
+
const up = Array(upCount).fill("..");
|
|
80
|
+
const remaining = toParts.slice(i);
|
|
81
|
+
return [...up, ...remaining].join("/") || ".";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.default = Path;
|
package/bun.lock
CHANGED
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
"lodash": "^4.17.21",
|
|
11
11
|
"open": "^10.2.0",
|
|
12
12
|
"ora": "^8.2.0",
|
|
13
|
+
"prettier": "^3.6.2",
|
|
13
14
|
"qrcode-terminal": "^0.12.0",
|
|
14
15
|
"unzipper": "^0.12.3",
|
|
16
|
+
"uuid": "^13.0.0",
|
|
15
17
|
"ws": "^8.18.3",
|
|
16
18
|
},
|
|
17
19
|
"devDependencies": {
|
|
@@ -165,6 +167,8 @@
|
|
|
165
167
|
|
|
166
168
|
"ora": ["ora@8.2.0", "", { "dependencies": { "chalk": "^5.3.0", "cli-cursor": "^5.0.0", "cli-spinners": "^2.9.2", "is-interactive": "^2.0.0", "is-unicode-supported": "^2.0.0", "log-symbols": "^6.0.0", "stdin-discarder": "^0.2.2", "string-width": "^7.2.0", "strip-ansi": "^7.1.0" } }, "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw=="],
|
|
167
169
|
|
|
170
|
+
"prettier": ["prettier@3.6.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],
|
|
171
|
+
|
|
168
172
|
"process-nextick-args": ["process-nextick-args@2.0.1", "", {}, "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="],
|
|
169
173
|
|
|
170
174
|
"proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
|
|
@@ -199,6 +203,8 @@
|
|
|
199
203
|
|
|
200
204
|
"util-deprecate": ["util-deprecate@1.0.2", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
|
|
201
205
|
|
|
206
|
+
"uuid": ["uuid@13.0.0", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w=="],
|
|
207
|
+
|
|
202
208
|
"ws": ["ws@8.18.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg=="],
|
|
203
209
|
|
|
204
210
|
"wsl-utils": ["wsl-utils@0.1.0", "", { "dependencies": { "is-wsl": "^3.1.0" } }, "sha512-h3Fbisa2nKGPxCpm89Hk33lBLsnaGBvctQopaBSOW/uIs6FTe1ATyAnKFJrzVs9vpGdsTe73WF3V4lIsk4Gacw=="],
|
package/dist/index.js
CHANGED
|
@@ -244,7 +244,7 @@ class RoomState {
|
|
|
244
244
|
if (this.reconnectTimeout) {
|
|
245
245
|
clearTimeout(this.reconnectTimeout);
|
|
246
246
|
}
|
|
247
|
-
this.ws = new ws_1.WebSocket(`https://
|
|
247
|
+
this.ws = new ws_1.WebSocket(`https://ws2.myworkbeast.com/ws?room=${this.roomId}`);
|
|
248
248
|
this.ws.onopen = () => {
|
|
249
249
|
console.log(`Connected to room: ${this.roomId}`);
|
|
250
250
|
this.isConnected = true;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Path {
|
|
4
|
+
static normalizeSlashes(path) {
|
|
5
|
+
return path.replace(/\\/g, "/");
|
|
6
|
+
}
|
|
7
|
+
// Tương tự path.join()
|
|
8
|
+
static join(...paths) {
|
|
9
|
+
const normalizedPaths = paths
|
|
10
|
+
.filter((p) => p && typeof p === "string")
|
|
11
|
+
.map((p) => this.normalizeSlashes(p.trim()))
|
|
12
|
+
.map((p) => p.replace(/^\/+|\/+$/g, "")); // Loại bỏ slash đầu và cuối
|
|
13
|
+
return normalizedPaths.join("/");
|
|
14
|
+
}
|
|
15
|
+
// Tương tự path.resolve()
|
|
16
|
+
static resolve(...paths) {
|
|
17
|
+
let resolvedPath = "";
|
|
18
|
+
const segments = [];
|
|
19
|
+
paths
|
|
20
|
+
.filter((p) => p && typeof p === "string")
|
|
21
|
+
.map((p) => this.normalizeSlashes(p))
|
|
22
|
+
.forEach((path) => {
|
|
23
|
+
if (path.startsWith("/")) {
|
|
24
|
+
segments.length = 0; // Reset nếu gặp absolute path
|
|
25
|
+
segments.push(...path.split("/").filter(Boolean));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
segments.push(...path.split("/").filter(Boolean));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const resolvedSegments = [];
|
|
32
|
+
for (const segment of segments) {
|
|
33
|
+
if (segment === "..") {
|
|
34
|
+
resolvedSegments.pop();
|
|
35
|
+
}
|
|
36
|
+
else if (segment !== ".") {
|
|
37
|
+
resolvedSegments.push(segment);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
resolvedPath = resolvedSegments.join("/");
|
|
41
|
+
return resolvedPath.startsWith("/") ? `/${resolvedPath}` : resolvedPath;
|
|
42
|
+
}
|
|
43
|
+
// Tương tự path.basename()
|
|
44
|
+
static basename(path, ext) {
|
|
45
|
+
const normalized = this.normalizeSlashes(path);
|
|
46
|
+
const base = normalized.split("/").pop() || "";
|
|
47
|
+
return ext && base.endsWith(ext) ? base.slice(0, -ext.length) : base;
|
|
48
|
+
}
|
|
49
|
+
// Tương tự path.dirname()
|
|
50
|
+
static dirname(path) {
|
|
51
|
+
const normalized = this.normalizeSlashes(path);
|
|
52
|
+
const segments = normalized.split("/");
|
|
53
|
+
segments.pop();
|
|
54
|
+
return segments.join("/") || ".";
|
|
55
|
+
}
|
|
56
|
+
// Tương tự path.extname()
|
|
57
|
+
static extname(path) {
|
|
58
|
+
const base = this.basename(path);
|
|
59
|
+
const dotIndex = base.lastIndexOf(".");
|
|
60
|
+
return dotIndex > 0 ? base.slice(dotIndex) : "";
|
|
61
|
+
}
|
|
62
|
+
// Tương tự path.isAbsolute()
|
|
63
|
+
static isAbsolute(path) {
|
|
64
|
+
return this.normalizeSlashes(path).startsWith("/");
|
|
65
|
+
}
|
|
66
|
+
// Tương tự path.relative()
|
|
67
|
+
static relative(from, to) {
|
|
68
|
+
const fromParts = this.normalizeSlashes(from).split("/").filter(Boolean);
|
|
69
|
+
const toParts = this.normalizeSlashes(to).split("/").filter(Boolean);
|
|
70
|
+
// Tìm điểm chung
|
|
71
|
+
let i = 0;
|
|
72
|
+
while (i < fromParts.length &&
|
|
73
|
+
i < toParts.length &&
|
|
74
|
+
fromParts[i] === toParts[i]) {
|
|
75
|
+
i++;
|
|
76
|
+
}
|
|
77
|
+
// Tính số bước đi lên
|
|
78
|
+
const upCount = fromParts.length - i;
|
|
79
|
+
const up = Array(upCount).fill("..");
|
|
80
|
+
const remaining = toParts.slice(i);
|
|
81
|
+
return [...up, ...remaining].join("/") || ".";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.default = Path;
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hapico/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "A simple CLI tool for project management",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -26,8 +26,10 @@
|
|
|
26
26
|
"lodash": "^4.17.21",
|
|
27
27
|
"open": "^10.2.0",
|
|
28
28
|
"ora": "^8.2.0",
|
|
29
|
+
"prettier": "^3.6.2",
|
|
29
30
|
"qrcode-terminal": "^0.12.0",
|
|
30
31
|
"unzipper": "^0.12.3",
|
|
32
|
+
"uuid": "^13.0.0",
|
|
31
33
|
"ws": "^8.18.3"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|