@hapico/cli 0.0.11 → 0.0.12
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 +12 -6
- package/dist/index.js +12 -6
- package/index.ts +15 -6
- package/package.json +2 -1
package/bin/index.js
CHANGED
|
@@ -48,9 +48,11 @@ const ws_1 = require("ws");
|
|
|
48
48
|
const Babel = __importStar(require("@babel/standalone"));
|
|
49
49
|
const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
|
|
50
50
|
const open_1 = __importDefault(require("open"));
|
|
51
|
+
const crypto_1 = require("crypto");
|
|
51
52
|
// Directory to store the token and project config
|
|
52
53
|
const CONFIG_DIR = path.join(process.env.HOME || process.env.USERPROFILE || ".", ".hapico");
|
|
53
54
|
const TOKEN_FILE = path.join(CONFIG_DIR, "auth_token.json");
|
|
55
|
+
const connected = (0, ora_1.default)("Connected to WebSocket server");
|
|
54
56
|
// Ensure config directory exists
|
|
55
57
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
56
58
|
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
@@ -244,13 +246,13 @@ class RoomState {
|
|
|
244
246
|
this.isConnected = true;
|
|
245
247
|
this.reconnectAttempts = 0;
|
|
246
248
|
onConnected === null || onConnected === void 0 ? void 0 : onConnected();
|
|
249
|
+
connected.succeed(`Connected to WebSocket server`);
|
|
247
250
|
});
|
|
248
251
|
this.ws.on("close", () => {
|
|
249
252
|
this.isConnected = false;
|
|
250
253
|
this.reconnectAttempts++;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.reconnectTimeout = setTimeout(() => this.connect(), delay);
|
|
254
|
+
connected.start(`Retry connection...`);
|
|
255
|
+
this.connect();
|
|
254
256
|
});
|
|
255
257
|
this.ws.on("message", (data) => {
|
|
256
258
|
try {
|
|
@@ -298,7 +300,7 @@ class RoomState {
|
|
|
298
300
|
return this.isConnected;
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
|
-
commander_1.program.version("0.0.
|
|
303
|
+
commander_1.program.version("0.0.12").description("Hapico CLI for project management");
|
|
302
304
|
commander_1.program
|
|
303
305
|
.command("clone <id>")
|
|
304
306
|
.description("Clone a project by ID")
|
|
@@ -371,12 +373,16 @@ commander_1.program
|
|
|
371
373
|
devSpinner.fail("Source directory 'src' does not exist. Please clone a project first.");
|
|
372
374
|
return;
|
|
373
375
|
}
|
|
374
|
-
const projectId =
|
|
376
|
+
const projectId = JSON.stringify({
|
|
377
|
+
id: (0, crypto_1.randomUUID)(),
|
|
378
|
+
createdAt: new Date().toISOString(),
|
|
379
|
+
viewId: getStoredProjectId(pwd),
|
|
380
|
+
});
|
|
375
381
|
if (!projectId) {
|
|
376
382
|
devSpinner.fail("Project ID not found. Please ensure hapico.config.json exists in the project directory.");
|
|
377
383
|
return;
|
|
378
384
|
}
|
|
379
|
-
console.log(`Connecting to WebSocket server
|
|
385
|
+
console.log(`Connecting to WebSocket server`);
|
|
380
386
|
const room = new RoomState(`view_${projectId}`);
|
|
381
387
|
room.connect(async () => {
|
|
382
388
|
devSpinner.succeed("Project started in development mode!");
|
package/dist/index.js
CHANGED
|
@@ -48,9 +48,11 @@ const ws_1 = require("ws");
|
|
|
48
48
|
const Babel = __importStar(require("@babel/standalone"));
|
|
49
49
|
const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
|
|
50
50
|
const open_1 = __importDefault(require("open"));
|
|
51
|
+
const crypto_1 = require("crypto");
|
|
51
52
|
// Directory to store the token and project config
|
|
52
53
|
const CONFIG_DIR = path.join(process.env.HOME || process.env.USERPROFILE || ".", ".hapico");
|
|
53
54
|
const TOKEN_FILE = path.join(CONFIG_DIR, "auth_token.json");
|
|
55
|
+
const connected = (0, ora_1.default)("Connected to WebSocket server");
|
|
54
56
|
// Ensure config directory exists
|
|
55
57
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
56
58
|
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
@@ -244,13 +246,13 @@ class RoomState {
|
|
|
244
246
|
this.isConnected = true;
|
|
245
247
|
this.reconnectAttempts = 0;
|
|
246
248
|
onConnected === null || onConnected === void 0 ? void 0 : onConnected();
|
|
249
|
+
connected.succeed(`Connected to WebSocket server`);
|
|
247
250
|
});
|
|
248
251
|
this.ws.on("close", () => {
|
|
249
252
|
this.isConnected = false;
|
|
250
253
|
this.reconnectAttempts++;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.reconnectTimeout = setTimeout(() => this.connect(), delay);
|
|
254
|
+
connected.start(`Retry connection...`);
|
|
255
|
+
this.connect();
|
|
254
256
|
});
|
|
255
257
|
this.ws.on("message", (data) => {
|
|
256
258
|
try {
|
|
@@ -298,7 +300,7 @@ class RoomState {
|
|
|
298
300
|
return this.isConnected;
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
|
-
commander_1.program.version("0.0.
|
|
303
|
+
commander_1.program.version("0.0.12").description("Hapico CLI for project management");
|
|
302
304
|
commander_1.program
|
|
303
305
|
.command("clone <id>")
|
|
304
306
|
.description("Clone a project by ID")
|
|
@@ -371,12 +373,16 @@ commander_1.program
|
|
|
371
373
|
devSpinner.fail("Source directory 'src' does not exist. Please clone a project first.");
|
|
372
374
|
return;
|
|
373
375
|
}
|
|
374
|
-
const projectId =
|
|
376
|
+
const projectId = JSON.stringify({
|
|
377
|
+
id: (0, crypto_1.randomUUID)(),
|
|
378
|
+
createdAt: new Date().toISOString(),
|
|
379
|
+
viewId: getStoredProjectId(pwd),
|
|
380
|
+
});
|
|
375
381
|
if (!projectId) {
|
|
376
382
|
devSpinner.fail("Project ID not found. Please ensure hapico.config.json exists in the project directory.");
|
|
377
383
|
return;
|
|
378
384
|
}
|
|
379
|
-
console.log(`Connecting to WebSocket server
|
|
385
|
+
console.log(`Connecting to WebSocket server`);
|
|
380
386
|
const room = new RoomState(`view_${projectId}`);
|
|
381
387
|
room.connect(async () => {
|
|
382
388
|
devSpinner.succeed("Project started in development mode!");
|
package/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { WebSocket } from "ws";
|
|
|
10
10
|
import * as Babel from "@babel/standalone";
|
|
11
11
|
import QRCode from "qrcode-terminal";
|
|
12
12
|
import open from "open";
|
|
13
|
+
import { randomUUID } from "crypto";
|
|
13
14
|
|
|
14
15
|
// Directory to store the token and project config
|
|
15
16
|
const CONFIG_DIR = path.join(
|
|
@@ -18,6 +19,8 @@ const CONFIG_DIR = path.join(
|
|
|
18
19
|
);
|
|
19
20
|
const TOKEN_FILE = path.join(CONFIG_DIR, "auth_token.json");
|
|
20
21
|
|
|
22
|
+
const connected = ora("Connected to WebSocket server");
|
|
23
|
+
|
|
21
24
|
// Ensure config directory exists
|
|
22
25
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
23
26
|
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
@@ -282,16 +285,18 @@ class RoomState {
|
|
|
282
285
|
this.isConnected = true;
|
|
283
286
|
this.reconnectAttempts = 0;
|
|
284
287
|
onConnected?.();
|
|
288
|
+
connected.succeed(`Connected to WebSocket server`);
|
|
285
289
|
});
|
|
286
290
|
|
|
287
291
|
this.ws.on("close", () => {
|
|
288
292
|
this.isConnected = false;
|
|
289
293
|
|
|
290
294
|
this.reconnectAttempts++;
|
|
291
|
-
|
|
292
|
-
|
|
295
|
+
connected.start(
|
|
296
|
+
`Retry connection...`
|
|
297
|
+
);
|
|
293
298
|
|
|
294
|
-
this.
|
|
299
|
+
this.connect();
|
|
295
300
|
});
|
|
296
301
|
|
|
297
302
|
this.ws.on("message", (data: Buffer) => {
|
|
@@ -345,7 +350,7 @@ class RoomState {
|
|
|
345
350
|
}
|
|
346
351
|
}
|
|
347
352
|
|
|
348
|
-
program.version("0.0.
|
|
353
|
+
program.version("0.0.12").description("Hapico CLI for project management");
|
|
349
354
|
|
|
350
355
|
program
|
|
351
356
|
.command("clone <id>")
|
|
@@ -441,14 +446,18 @@ program
|
|
|
441
446
|
);
|
|
442
447
|
return;
|
|
443
448
|
}
|
|
444
|
-
const projectId =
|
|
449
|
+
const projectId = JSON.stringify({
|
|
450
|
+
id: randomUUID(),
|
|
451
|
+
createdAt: new Date().toISOString(),
|
|
452
|
+
viewId: getStoredProjectId(pwd),
|
|
453
|
+
});
|
|
445
454
|
if (!projectId) {
|
|
446
455
|
devSpinner.fail(
|
|
447
456
|
"Project ID not found. Please ensure hapico.config.json exists in the project directory."
|
|
448
457
|
);
|
|
449
458
|
return;
|
|
450
459
|
}
|
|
451
|
-
console.log(`Connecting to WebSocket server
|
|
460
|
+
console.log(`Connecting to WebSocket server`);
|
|
452
461
|
const room = new RoomState(`view_${projectId}`);
|
|
453
462
|
|
|
454
463
|
room.connect(async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hapico/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "A simple CLI tool for project management",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc && cp -r dist/* ./bin/",
|
|
11
11
|
"start": "node dist/index.js",
|
|
12
|
+
"dev": "npm run build && bun link @hapico/cli",
|
|
12
13
|
"pub": "npm run build && npm publish --access public"
|
|
13
14
|
},
|
|
14
15
|
"keywords": [
|