@hapico/cli 0.0.2 → 0.0.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/bin/index.js +35 -2
- package/bun.lock +25 -0
- package/dist/index.js +35 -2
- package/index.ts +40 -2
- package/package.json +6 -2
package/bin/index.js
CHANGED
|
@@ -385,8 +385,8 @@ commander_1.program
|
|
|
385
385
|
});
|
|
386
386
|
});
|
|
387
387
|
commander_1.program
|
|
388
|
-
.command("
|
|
389
|
-
.description("
|
|
388
|
+
.command("push")
|
|
389
|
+
.description("Push the project source code to the server")
|
|
390
390
|
.action(() => {
|
|
391
391
|
const token = getStoredToken();
|
|
392
392
|
if (!token) {
|
|
@@ -457,4 +457,37 @@ commander_1.program
|
|
|
457
457
|
fs.unlinkSync(TOKEN_FILE);
|
|
458
458
|
console.log("Logout successful!");
|
|
459
459
|
});
|
|
460
|
+
// Pull command to fetch the latest project files from the server
|
|
461
|
+
commander_1.program
|
|
462
|
+
.command("pull")
|
|
463
|
+
.description("Pull the latest project files from the server")
|
|
464
|
+
.action(async () => {
|
|
465
|
+
const token = getStoredToken();
|
|
466
|
+
if (!token) {
|
|
467
|
+
console.error("You need to login first. Use 'hapico login' command.");
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const pwd = process.cwd();
|
|
471
|
+
const projectId = getStoredProjectId(pwd);
|
|
472
|
+
if (!projectId) {
|
|
473
|
+
console.error("Project ID not found. Please ensure hapico.config.json exists in the project directory.");
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const apiSpinner = (0, ora_1.default)("Fetching latest project files...").start();
|
|
477
|
+
try {
|
|
478
|
+
const response = await axios_1.default.get(`https://base.myworkbeast.com/api/views/${projectId}`, {
|
|
479
|
+
headers: {
|
|
480
|
+
Authorization: `Bearer ${token}`,
|
|
481
|
+
"Content-Type": "application/json",
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
const files = response.data.files || [];
|
|
485
|
+
const fileManager = new FileManager(path.join(pwd, "src"));
|
|
486
|
+
fileManager.syncFiles(files);
|
|
487
|
+
apiSpinner.succeed("Project files updated successfully!");
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
apiSpinner.fail(`Error fetching project files: ${error.message}`);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
460
493
|
commander_1.program.parse(process.argv);
|
package/bun.lock
CHANGED
|
@@ -14,22 +14,47 @@
|
|
|
14
14
|
"ws": "^8.18.3",
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"@types/babel__standalone": "^7.1.9",
|
|
17
18
|
"@types/commander": "^2.12.5",
|
|
18
19
|
"@types/node": "^24.1.0",
|
|
20
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
19
21
|
"@types/unzipper": "^0.10.11",
|
|
22
|
+
"@types/ws": "^8.18.1",
|
|
20
23
|
"typescript": "^5.8.3",
|
|
21
24
|
},
|
|
22
25
|
},
|
|
23
26
|
},
|
|
24
27
|
"packages": {
|
|
28
|
+
"@babel/helper-string-parser": ["@babel/helper-string-parser@7.27.1", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
|
|
29
|
+
|
|
30
|
+
"@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.27.1", "", {}, "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow=="],
|
|
31
|
+
|
|
32
|
+
"@babel/parser": ["@babel/parser@7.28.0", "", { "dependencies": { "@babel/types": "^7.28.0" }, "bin": "./bin/babel-parser.js" }, "sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g=="],
|
|
33
|
+
|
|
25
34
|
"@babel/standalone": ["@babel/standalone@7.28.2", "", {}, "sha512-1kjA8XzBRN68HoDDYKP38bucHtxYWCIX8XdYwe1drRNUOjOVNt8EMy9jiE6UwaGFfU7NOHCG+C8KgBc9CR08nA=="],
|
|
26
35
|
|
|
36
|
+
"@babel/types": ["@babel/types@7.28.2", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ=="],
|
|
37
|
+
|
|
38
|
+
"@types/babel__core": ["@types/babel__core@7.20.5", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="],
|
|
39
|
+
|
|
40
|
+
"@types/babel__generator": ["@types/babel__generator@7.27.0", "", { "dependencies": { "@babel/types": "^7.0.0" } }, "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg=="],
|
|
41
|
+
|
|
42
|
+
"@types/babel__standalone": ["@types/babel__standalone@7.1.9", "", { "dependencies": { "@babel/parser": "^7.25.6", "@babel/types": "^7.25.6", "@types/babel__core": "^7.20.5", "@types/babel__generator": "^7.6.8", "@types/babel__template": "^7.4.4", "@types/babel__traverse": "^7.20.6" } }, "sha512-IcCNPLqpevUD7UpV8QB0uwQPOyoOKACFf0YtYWRHcmxcakaje4Q7dbG2+jMqxw/I8Zk0NHvEps66WwS7z/UaaA=="],
|
|
43
|
+
|
|
44
|
+
"@types/babel__template": ["@types/babel__template@7.4.4", "", { "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" } }, "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A=="],
|
|
45
|
+
|
|
46
|
+
"@types/babel__traverse": ["@types/babel__traverse@7.20.7", "", { "dependencies": { "@babel/types": "^7.20.7" } }, "sha512-dkO5fhS7+/oos4ciWxyEyjWe48zmG6wbCheo/G2ZnHx4fs3EU6YC6UM8rk56gAjNJ9P3MTH2jo5jb92/K6wbng=="],
|
|
47
|
+
|
|
27
48
|
"@types/commander": ["@types/commander@2.12.5", "", { "dependencies": { "commander": "*" } }, "sha512-YXGZ/rz+s57VbzcvEV9fUoXeJlBt5HaKu5iUheiIWNsJs23bz6AnRuRiZBRVBLYyPnixNvVnuzM5pSaxr8Yp/g=="],
|
|
28
49
|
|
|
29
50
|
"@types/node": ["@types/node@24.1.0", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w=="],
|
|
30
51
|
|
|
52
|
+
"@types/qrcode-terminal": ["@types/qrcode-terminal@0.12.2", "", {}, "sha512-v+RcIEJ+Uhd6ygSQ0u5YYY7ZM+la7GgPbs0V/7l/kFs2uO4S8BcIUEMoP7za4DNIqNnUD5npf0A/7kBhrCKG5Q=="],
|
|
53
|
+
|
|
31
54
|
"@types/unzipper": ["@types/unzipper@0.10.11", "", { "dependencies": { "@types/node": "*" } }, "sha512-D25im2zjyMCcgL9ag6N46+wbtJBnXIr7SI4zHf9eJD2Dw2tEB5e+p5MYkrxKIVRscs5QV0EhtU9rgXSPx90oJg=="],
|
|
32
55
|
|
|
56
|
+
"@types/ws": ["@types/ws@8.18.1", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
|
|
57
|
+
|
|
33
58
|
"ansi-regex": ["ansi-regex@6.1.0", "", {}, "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="],
|
|
34
59
|
|
|
35
60
|
"asynckit": ["asynckit@0.4.0", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
|
package/dist/index.js
CHANGED
|
@@ -385,8 +385,8 @@ commander_1.program
|
|
|
385
385
|
});
|
|
386
386
|
});
|
|
387
387
|
commander_1.program
|
|
388
|
-
.command("
|
|
389
|
-
.description("
|
|
388
|
+
.command("push")
|
|
389
|
+
.description("Push the project source code to the server")
|
|
390
390
|
.action(() => {
|
|
391
391
|
const token = getStoredToken();
|
|
392
392
|
if (!token) {
|
|
@@ -457,4 +457,37 @@ commander_1.program
|
|
|
457
457
|
fs.unlinkSync(TOKEN_FILE);
|
|
458
458
|
console.log("Logout successful!");
|
|
459
459
|
});
|
|
460
|
+
// Pull command to fetch the latest project files from the server
|
|
461
|
+
commander_1.program
|
|
462
|
+
.command("pull")
|
|
463
|
+
.description("Pull the latest project files from the server")
|
|
464
|
+
.action(async () => {
|
|
465
|
+
const token = getStoredToken();
|
|
466
|
+
if (!token) {
|
|
467
|
+
console.error("You need to login first. Use 'hapico login' command.");
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const pwd = process.cwd();
|
|
471
|
+
const projectId = getStoredProjectId(pwd);
|
|
472
|
+
if (!projectId) {
|
|
473
|
+
console.error("Project ID not found. Please ensure hapico.config.json exists in the project directory.");
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const apiSpinner = (0, ora_1.default)("Fetching latest project files...").start();
|
|
477
|
+
try {
|
|
478
|
+
const response = await axios_1.default.get(`https://base.myworkbeast.com/api/views/${projectId}`, {
|
|
479
|
+
headers: {
|
|
480
|
+
Authorization: `Bearer ${token}`,
|
|
481
|
+
"Content-Type": "application/json",
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
const files = response.data.files || [];
|
|
485
|
+
const fileManager = new FileManager(path.join(pwd, "src"));
|
|
486
|
+
fileManager.syncFiles(files);
|
|
487
|
+
apiSpinner.succeed("Project files updated successfully!");
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
apiSpinner.fail(`Error fetching project files: ${error.message}`);
|
|
491
|
+
}
|
|
492
|
+
});
|
|
460
493
|
commander_1.program.parse(process.argv);
|
package/index.ts
CHANGED
|
@@ -466,8 +466,8 @@ program
|
|
|
466
466
|
});
|
|
467
467
|
|
|
468
468
|
program
|
|
469
|
-
.command("
|
|
470
|
-
.description("
|
|
469
|
+
.command("push")
|
|
470
|
+
.description("Push the project source code to the server")
|
|
471
471
|
.action(() => {
|
|
472
472
|
const token = getStoredToken();
|
|
473
473
|
if (!token) {
|
|
@@ -550,4 +550,42 @@ program
|
|
|
550
550
|
console.log("Logout successful!");
|
|
551
551
|
});
|
|
552
552
|
|
|
553
|
+
// Pull command to fetch the latest project files from the server
|
|
554
|
+
program
|
|
555
|
+
.command("pull")
|
|
556
|
+
.description("Pull the latest project files from the server")
|
|
557
|
+
.action(async () => {
|
|
558
|
+
const token = getStoredToken();
|
|
559
|
+
if (!token) {
|
|
560
|
+
console.error("You need to login first. Use 'hapico login' command.");
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const pwd: string = process.cwd();
|
|
564
|
+
const projectId = getStoredProjectId(pwd);
|
|
565
|
+
if (!projectId) {
|
|
566
|
+
console.error(
|
|
567
|
+
"Project ID not found. Please ensure hapico.config.json exists in the project directory."
|
|
568
|
+
);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
const apiSpinner: Ora = ora("Fetching latest project files...").start();
|
|
572
|
+
try {
|
|
573
|
+
const response: ApiResponse = await axios.get(
|
|
574
|
+
`https://base.myworkbeast.com/api/views/${projectId}`,
|
|
575
|
+
{
|
|
576
|
+
headers: {
|
|
577
|
+
Authorization: `Bearer ${token}`,
|
|
578
|
+
"Content-Type": "application/json",
|
|
579
|
+
},
|
|
580
|
+
}
|
|
581
|
+
);
|
|
582
|
+
const files: FileContent[] = response.data.files || [];
|
|
583
|
+
const fileManager = new FileManager(path.join(pwd, "src"));
|
|
584
|
+
fileManager.syncFiles(files);
|
|
585
|
+
apiSpinner.succeed("Project files updated successfully!");
|
|
586
|
+
} catch (error) {
|
|
587
|
+
apiSpinner.fail(`Error fetching project files: ${(error as Error).message}`);
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
|
|
553
591
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hapico/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "A simple CLI tool for project management",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc && cp -r dist/* ./bin/",
|
|
11
|
-
"start": "node dist/index.js"
|
|
11
|
+
"start": "node dist/index.js",
|
|
12
|
+
"publish": "npm run build && npm publish --access public"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"cli",
|
|
@@ -28,9 +29,12 @@
|
|
|
28
29
|
"ws": "^8.18.3"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
32
|
+
"@types/babel__standalone": "^7.1.9",
|
|
31
33
|
"@types/commander": "^2.12.5",
|
|
32
34
|
"@types/node": "^24.1.0",
|
|
35
|
+
"@types/qrcode-terminal": "^0.12.2",
|
|
33
36
|
"@types/unzipper": "^0.10.11",
|
|
37
|
+
"@types/ws": "^8.18.1",
|
|
34
38
|
"typescript": "^5.8.3"
|
|
35
39
|
}
|
|
36
40
|
}
|