@tonk/cli 0.1.14 → 0.2.1
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/README.md +84 -5
- package/dist/commands/hello/index.d.ts +3 -0
- package/dist/commands/hello/index.d.ts.map +1 -0
- package/dist/commands/hello/index.js +291 -0
- package/dist/commands/hello/index.js.map +1 -0
- package/dist/commands/hello.d.ts.map +1 -1
- package/dist/commands/hello.js +69 -6
- package/dist/commands/hello.js.map +1 -1
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +66 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/kill.d.ts +3 -0
- package/dist/commands/kill.d.ts.map +1 -0
- package/dist/commands/kill.js +38 -0
- package/dist/commands/kill.js.map +1 -0
- package/dist/commands/ls.d.ts +3 -0
- package/dist/commands/ls.d.ts.map +1 -0
- package/dist/commands/ls.js +31 -0
- package/dist/commands/ls.js.map +1 -0
- package/dist/commands/ps.d.ts +3 -0
- package/dist/commands/ps.d.ts.map +1 -0
- package/dist/commands/ps.js +34 -0
- package/dist/commands/ps.js.map +1 -0
- package/dist/commands/push.d.ts +3 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +150 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/start.d.ts +3 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +43 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/tonk.js +71 -12
- package/dist/tonk.js.map +1 -1
- package/package.json +12 -4
- package/dist/commands/config.d.ts +0 -3
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -338
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/deploy.d.ts +0 -3
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js +0 -460
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/dev.d.ts +0 -3
- package/dist/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev.js +0 -89
- package/dist/commands/dev.js.map +0 -1
- package/dist/commands/prettyPrint.d.ts +0 -3
- package/dist/commands/prettyPrint.d.ts.map +0 -1
- package/dist/commands/prettyPrint.js +0 -51
- package/dist/commands/prettyPrint.js.map +0 -1
- package/dist/commands/serve.d.ts +0 -3
- package/dist/commands/serve.d.ts.map +0 -1
- package/dist/commands/serve.js +0 -212
- package/dist/commands/serve.js.map +0 -1
- package/dist/lib/launchGUI.d.ts +0 -2
- package/dist/lib/launchGUI.d.ts.map +0 -1
- package/dist/lib/launchGUI.js +0 -175
- package/dist/lib/launchGUI.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Tonk CLI
|
|
2
2
|
|
|
3
|
-
Command line utilities for your Tonk network
|
|
3
|
+
Command line utilities for your Tonk network
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -32,6 +32,81 @@ Serve your built Tonk app locally:
|
|
|
32
32
|
tonk serve
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
### Bundle Management
|
|
36
|
+
|
|
37
|
+
Tonk supports managing application bundles through the following commands:
|
|
38
|
+
|
|
39
|
+
#### Push a bundle to the server
|
|
40
|
+
|
|
41
|
+
Package your dist folder and upload it to the Tonk server:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Push with defaults (from ./dist folder, using package name)
|
|
45
|
+
tonk push
|
|
46
|
+
|
|
47
|
+
# Push with custom options
|
|
48
|
+
tonk push -n my-bundle -d ./build -s
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Options:
|
|
52
|
+
|
|
53
|
+
- `-u, --url <url>` - URL of the Tonk server (default: http://localhost:7777)
|
|
54
|
+
- `-n, --name <name>` - Name for the bundle (defaults to directory name or package name)
|
|
55
|
+
- `-d, --dir <dir>` - Directory to bundle (defaults to ./dist)
|
|
56
|
+
- `-s, --start` - Start the bundle after upload
|
|
57
|
+
|
|
58
|
+
#### List available bundles
|
|
59
|
+
|
|
60
|
+
List all bundles available on the server:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
tonk ls
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Options:
|
|
67
|
+
|
|
68
|
+
- `-u, --url <url>` - URL of the Tonk server (default: http://localhost:7777)
|
|
69
|
+
|
|
70
|
+
#### List running bundle servers
|
|
71
|
+
|
|
72
|
+
Show all currently running bundle servers:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
tonk ps
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Options:
|
|
79
|
+
|
|
80
|
+
- `-u, --url <url>` - URL of the Tonk server (default: http://localhost:7777)
|
|
81
|
+
|
|
82
|
+
#### Start a bundle server
|
|
83
|
+
|
|
84
|
+
Start a bundle server for a specific bundle:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
tonk start my-bundle
|
|
88
|
+
|
|
89
|
+
# Specify a port
|
|
90
|
+
tonk start my-bundle -p 8080
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Options:
|
|
94
|
+
|
|
95
|
+
- `-u, --url <url>` - URL of the Tonk server (default: http://localhost:7777)
|
|
96
|
+
- `-p, --port <port>` - Port for the bundle server (optional)
|
|
97
|
+
|
|
98
|
+
#### Kill a running bundle server
|
|
99
|
+
|
|
100
|
+
Stop a running bundle server by its ID:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
tonk kill <server-id>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Options:
|
|
107
|
+
|
|
108
|
+
- `-u, --url <url>` - URL of the Tonk server (default: http://localhost:7777)
|
|
109
|
+
|
|
35
110
|
### Configure AWS Deployment
|
|
36
111
|
|
|
37
112
|
Configure your AWS EC2 instance for deployment:
|
|
@@ -48,11 +123,12 @@ tonk config --instance ec2-xx-xx-xx-xx.compute-1.amazonaws.com --key ~/path/to/k
|
|
|
48
123
|
```
|
|
49
124
|
|
|
50
125
|
Options:
|
|
126
|
+
|
|
51
127
|
- `-i, --instance <address>` - EC2 instance address
|
|
52
128
|
- `-k, --key <path>` - Path to SSH key file
|
|
53
|
-
- `-u, --user <
|
|
129
|
+
- `-u, --user <n>` - SSH username (default: ec2-user)
|
|
54
130
|
- `-p, --provision` - Provision a new EC2 instance
|
|
55
|
-
- `-n, --key-name <
|
|
131
|
+
- `-n, --key-name <n>` - AWS key pair name (for provisioning)
|
|
56
132
|
|
|
57
133
|
### Deploy to AWS
|
|
58
134
|
|
|
@@ -63,9 +139,10 @@ tonk deploy
|
|
|
63
139
|
```
|
|
64
140
|
|
|
65
141
|
Options:
|
|
142
|
+
|
|
66
143
|
- `-i, --instance <address>` - EC2 instance address
|
|
67
144
|
- `-k, --key <path>` - Path to SSH key file
|
|
68
|
-
- `-u, --user <
|
|
145
|
+
- `-u, --user <n>` - SSH username (default: ec2-user)
|
|
69
146
|
- `-t, --token <token>` - Pinggy.io access token for public URL
|
|
70
147
|
- `-b, --backblaze` - Enable Backblaze B2 storage for document backup
|
|
71
148
|
- `-f, --filesystem` - Enable filesystem storage for document backup
|
|
@@ -75,11 +152,13 @@ Options:
|
|
|
75
152
|
Tonk supports multiple options for persisting your documents:
|
|
76
153
|
|
|
77
154
|
1. **Backblaze B2 Storage**: Cloud-based backup for your documents
|
|
155
|
+
|
|
78
156
|
- Secure, scalable cloud storage
|
|
79
157
|
- Automatic synchronization at configurable intervals
|
|
80
158
|
- Requires a Backblaze B2 account with bucket and application keys
|
|
81
159
|
|
|
82
160
|
2. **Filesystem Storage**: Local file-based storage on your server
|
|
161
|
+
|
|
83
162
|
- Store documents directly on the server's filesystem
|
|
84
163
|
- Configurable storage path and sync intervals
|
|
85
164
|
- Automatic directory creation
|
|
@@ -94,7 +173,7 @@ During deployment, you'll be guided through setting up your preferred storage op
|
|
|
94
173
|
|
|
95
174
|
1. Clone the repository
|
|
96
175
|
2. Install dependencies: `npm install`
|
|
97
|
-
|
|
176
|
+
3. Run the dev mode: `npm run dev`
|
|
98
177
|
|
|
99
178
|
## License
|
|
100
179
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/hello/index.tsx"],"names":[],"mappings":"AA0ZA,QAAA,MAAM,oBAAoB,kBAQzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { render, Box, Text, useInput } from 'ink';
|
|
3
|
+
// Original ascii art for reference (using template literals to preserve exact spacing)
|
|
4
|
+
const ORIGINAL_ASCII = `
|
|
5
|
+
_____ U ___ u _ _ _ __
|
|
6
|
+
|_ " _| \\/"_ \\/ | \\ |"| |"|/ /
|
|
7
|
+
| | | | | |<| \\| |> | ' /
|
|
8
|
+
/| |\\.-,_| |_| |U| |\\ |u U/| . \\\\u
|
|
9
|
+
u |_|U \\_)-\\___/ |_| \\_| |_|\\_\\
|
|
10
|
+
_// \\\\_ \\\\ || \\\\,-.,-,>> \\\\,-.
|
|
11
|
+
(__) (__) (__) (_") (_/ \\.) (_/
|
|
12
|
+
`;
|
|
13
|
+
// T character frames (using template literals to preserve exact spacing)
|
|
14
|
+
const T_FRAMES = [
|
|
15
|
+
// Frame 0 - regular T
|
|
16
|
+
` _____
|
|
17
|
+
|_ " _|
|
|
18
|
+
| |
|
|
19
|
+
/| |\\
|
|
20
|
+
u |_| U
|
|
21
|
+
_// \\\\_
|
|
22
|
+
(__) (__) `,
|
|
23
|
+
// Frame 1 - T with right arm
|
|
24
|
+
` _____
|
|
25
|
+
|_ "_|
|
|
26
|
+
| |
|
|
27
|
+
/| |--u
|
|
28
|
+
u |_|
|
|
29
|
+
_// \\\\_
|
|
30
|
+
(__) (__) `,
|
|
31
|
+
// Frame 2 - T with left arm
|
|
32
|
+
` _____
|
|
33
|
+
|_" _|u
|
|
34
|
+
| | /
|
|
35
|
+
u--| |
|
|
36
|
+
|_|
|
|
37
|
+
_// \\\\_
|
|
38
|
+
(__) (__) `,
|
|
39
|
+
];
|
|
40
|
+
// O character frames (using template literals to preserve exact spacing)
|
|
41
|
+
const O_FRAMES = [
|
|
42
|
+
// Frame 0 - regular O
|
|
43
|
+
` U ___ u
|
|
44
|
+
\\/"_ \\/
|
|
45
|
+
| | | |
|
|
46
|
+
.-,_| |_| |
|
|
47
|
+
\\_)-\\___/
|
|
48
|
+
\\\\
|
|
49
|
+
(__) `,
|
|
50
|
+
// Frame 1 - O with arms
|
|
51
|
+
` ___
|
|
52
|
+
u—— / _"\\——u
|
|
53
|
+
| | | |
|
|
54
|
+
| |_| |
|
|
55
|
+
.-/,/\___/
|
|
56
|
+
\\_) ||
|
|
57
|
+
(__) `,
|
|
58
|
+
// Frame 2 - O with stretched legs
|
|
59
|
+
` ___
|
|
60
|
+
/"_ \\
|
|
61
|
+
/| | | |\\
|
|
62
|
+
u | |_| | u
|
|
63
|
+
\\___/
|
|
64
|
+
_// \\\\_
|
|
65
|
+
(__) (__) `,
|
|
66
|
+
];
|
|
67
|
+
// N character frames (using template literals to preserve exact spacing)
|
|
68
|
+
const N_FRAMES = [
|
|
69
|
+
// Frame 0 - regular N
|
|
70
|
+
` _ _
|
|
71
|
+
| \\ |"|
|
|
72
|
+
<| \\| |>
|
|
73
|
+
U| |\\ |u
|
|
74
|
+
|_| \\_|
|
|
75
|
+
|| \\\\,-.
|
|
76
|
+
(_") (_/ `,
|
|
77
|
+
// Frame 1 - N with different arms
|
|
78
|
+
` - -
|
|
79
|
+
| \\ |"|
|
|
80
|
+
<| \\| |>
|
|
81
|
+
U| |\\ |u
|
|
82
|
+
|_| \\_|
|
|
83
|
+
,-,>> ||
|
|
84
|
+
\\.) (_") `,
|
|
85
|
+
// Frame 2 - N with different legs
|
|
86
|
+
` _ _
|
|
87
|
+
| \\ |"|
|
|
88
|
+
<| \\| |>
|
|
89
|
+
U| |\\ |u
|
|
90
|
+
|_| \\_|
|
|
91
|
+
//,-,>>
|
|
92
|
+
(_")\\.) `,
|
|
93
|
+
];
|
|
94
|
+
// K character frames (using template literals to preserve exact spacing)
|
|
95
|
+
const K_FRAMES = [
|
|
96
|
+
// Frame 0 - regular K
|
|
97
|
+
` _ __
|
|
98
|
+
|"|/ /
|
|
99
|
+
| ' /
|
|
100
|
+
U/| . \\u
|
|
101
|
+
|_|\\_\\
|
|
102
|
+
|| \\\\,-.
|
|
103
|
+
(_") (_/ `,
|
|
104
|
+
// Frame 1 - K with arm
|
|
105
|
+
` _ _
|
|
106
|
+
|"|/ /
|
|
107
|
+
| ' /
|
|
108
|
+
U/| . \\—u
|
|
109
|
+
|_|\\_\\
|
|
110
|
+
|| ||
|
|
111
|
+
(_")(_") `,
|
|
112
|
+
// Frame 2 - K with legs
|
|
113
|
+
` _ __
|
|
114
|
+
|"|/ /
|
|
115
|
+
| ' /
|
|
116
|
+
U/| . \\u
|
|
117
|
+
|_|\\_\\
|
|
118
|
+
,-,> \\\\,-.
|
|
119
|
+
\\.) (_/ `,
|
|
120
|
+
// Frame 3 - K with all limbs
|
|
121
|
+
` _ __
|
|
122
|
+
u |"|/ /
|
|
123
|
+
\\| ' /_u
|
|
124
|
+
| . \\
|
|
125
|
+
|_|\\_\\
|
|
126
|
+
_//,-,>>
|
|
127
|
+
\\.) \\.) `,
|
|
128
|
+
];
|
|
129
|
+
// Star characters
|
|
130
|
+
const STAR_CHARS = '・。゜☆。・゜。・。゜☆。・゜★・。゜☆。・゜。・。゜☆。・゜☆。・゜☆。・゜☆。・゜';
|
|
131
|
+
// Animation configuration
|
|
132
|
+
const ANIMATION_CONFIG = {
|
|
133
|
+
// Time between frame changes during an animation sequence (milliseconds)
|
|
134
|
+
frameSpeed: 200,
|
|
135
|
+
// Number of frames to show in a sequence
|
|
136
|
+
sequenceLength: 3,
|
|
137
|
+
// Min and max time between animation sequences (milliseconds)
|
|
138
|
+
minPauseBetweenSequences: 1000,
|
|
139
|
+
maxPauseBetweenSequences: 3000,
|
|
140
|
+
};
|
|
141
|
+
// Welcome message component
|
|
142
|
+
const WelcomeMessage = () => {
|
|
143
|
+
return (React.createElement(Box, { flexDirection: "column", marginTop: 1, width: 80 },
|
|
144
|
+
React.createElement(Text, null,
|
|
145
|
+
React.createElement(Text, { bold: true, color: "green" }, "Hello Builder!")),
|
|
146
|
+
React.createElement(Box, { marginTop: 1 },
|
|
147
|
+
React.createElement(Text, null, "Thank you for choosing Tonk! We're thrilled to have you onboard and excited to see what we can build together.")),
|
|
148
|
+
React.createElement(Box, { marginTop: 2 },
|
|
149
|
+
React.createElement(Text, { bold: true, underline: true, color: "cyan" }, "Getting Started:")),
|
|
150
|
+
React.createElement(Box, { marginLeft: 2, marginTop: 1 },
|
|
151
|
+
React.createElement(Text, null,
|
|
152
|
+
"\u2022 Create a new Tonk project:",
|
|
153
|
+
' ',
|
|
154
|
+
React.createElement(Text, { bold: true, color: "yellow" }, "tonk create"))),
|
|
155
|
+
React.createElement(Box, { marginLeft: 2, marginTop: 1 },
|
|
156
|
+
React.createElement(Text, null, "\u2022 Open in your agentic editor and let the vibecode flow \uD83D\uDE0E")),
|
|
157
|
+
React.createElement(Box, { marginLeft: 2, marginTop: 1 },
|
|
158
|
+
React.createElement(Text, null,
|
|
159
|
+
"\u2022 Share your project:",
|
|
160
|
+
' ',
|
|
161
|
+
React.createElement(Text, { bold: true, color: "yellow" }, "tonk start"))),
|
|
162
|
+
React.createElement(Box, { marginLeft: 2, marginTop: 1 },
|
|
163
|
+
React.createElement(Text, null,
|
|
164
|
+
"\u2022 Read the documentation:",
|
|
165
|
+
' ',
|
|
166
|
+
React.createElement(Text, { bold: true, color: "blue" }, "https://tonk-labs.github.io/tonk/"))),
|
|
167
|
+
React.createElement(Box, { marginTop: 2 },
|
|
168
|
+
React.createElement(Text, { bold: true, underline: true, color: "cyan" }, "Community:")),
|
|
169
|
+
React.createElement(Box, { marginLeft: 2, marginTop: 1 },
|
|
170
|
+
React.createElement(Text, null,
|
|
171
|
+
"\u2022 Join our Telegram:",
|
|
172
|
+
' ',
|
|
173
|
+
React.createElement(Text, { bold: true, color: "blue" }, "https://t.me/+9W-4wDR9RcM2NWZk"))),
|
|
174
|
+
React.createElement(Box, { marginTop: 2 },
|
|
175
|
+
React.createElement(Text, null, "Our team would love to hear from you. If you need any assistance or have questions, please don't hesitate to reach out through our community channels.")),
|
|
176
|
+
React.createElement(Box, { marginTop: 1 },
|
|
177
|
+
React.createElement(Text, { bold: true, color: "green" }, "Happy building with Tonk!")),
|
|
178
|
+
React.createElement(Box, { marginTop: 1 },
|
|
179
|
+
React.createElement(Text, { color: "yellow" }, "(Press any key to exit)"))));
|
|
180
|
+
};
|
|
181
|
+
// Component for rendering animated ASCII art
|
|
182
|
+
const TonkAsciiAnimated = () => {
|
|
183
|
+
// States to track current frame for each letter
|
|
184
|
+
const [tFrame, setTFrame] = useState(0);
|
|
185
|
+
const [oFrame, setOFrame] = useState(0);
|
|
186
|
+
const [nFrame, setNFrame] = useState(0);
|
|
187
|
+
const [kFrame, setKFrame] = useState(0);
|
|
188
|
+
// Add state for exit handling
|
|
189
|
+
const [shouldExit, setShouldExit] = useState(false);
|
|
190
|
+
// Capture key input to exit
|
|
191
|
+
useInput((input, key) => {
|
|
192
|
+
setShouldExit(true);
|
|
193
|
+
});
|
|
194
|
+
// Exit effect
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
if (shouldExit) {
|
|
197
|
+
process.exit(0);
|
|
198
|
+
}
|
|
199
|
+
}, [shouldExit]);
|
|
200
|
+
// State for star characters
|
|
201
|
+
const [starIndex, setStarIndex] = useState(0);
|
|
202
|
+
// Helper to get random pause duration
|
|
203
|
+
const getRandomPause = () => {
|
|
204
|
+
return Math.floor(ANIMATION_CONFIG.minPauseBetweenSequences +
|
|
205
|
+
Math.random() *
|
|
206
|
+
(ANIMATION_CONFIG.maxPauseBetweenSequences -
|
|
207
|
+
ANIMATION_CONFIG.minPauseBetweenSequences));
|
|
208
|
+
};
|
|
209
|
+
// Animation function for the star border
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
const starInterval = setInterval(() => {
|
|
212
|
+
setStarIndex(prev => (prev + 1) % STAR_CHARS.length);
|
|
213
|
+
}, 500);
|
|
214
|
+
return () => clearInterval(starInterval);
|
|
215
|
+
}, []);
|
|
216
|
+
// Animation function for a letter
|
|
217
|
+
const animateCharacter = (setFrame, maxFrames, animatingRef) => {
|
|
218
|
+
// Don't start a new animation if one is already running
|
|
219
|
+
if (animatingRef.current)
|
|
220
|
+
return;
|
|
221
|
+
animatingRef.current = true;
|
|
222
|
+
let frameCount = 0;
|
|
223
|
+
// Start animation sequence
|
|
224
|
+
const sequenceInterval = setInterval(() => {
|
|
225
|
+
setFrame(prev => (prev + 1) % maxFrames);
|
|
226
|
+
frameCount++;
|
|
227
|
+
// End sequence after desired number of frames
|
|
228
|
+
if (frameCount >= ANIMATION_CONFIG.sequenceLength) {
|
|
229
|
+
clearInterval(sequenceInterval);
|
|
230
|
+
animatingRef.current = false;
|
|
231
|
+
// Schedule the next animation sequence after a random pause
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
animateCharacter(setFrame, maxFrames, animatingRef);
|
|
234
|
+
}, getRandomPause());
|
|
235
|
+
}
|
|
236
|
+
}, ANIMATION_CONFIG.frameSpeed);
|
|
237
|
+
};
|
|
238
|
+
// Animation references
|
|
239
|
+
const tAnimating = React.useRef(false);
|
|
240
|
+
const oAnimating = React.useRef(false);
|
|
241
|
+
const nAnimating = React.useRef(false);
|
|
242
|
+
const kAnimating = React.useRef(false);
|
|
243
|
+
// Start animations with delays
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
const tDelay = Math.random() * 1000;
|
|
246
|
+
const oDelay = Math.random() * 2000 + 300;
|
|
247
|
+
const nDelay = Math.random() * 1000 + 600;
|
|
248
|
+
const kDelay = Math.random() * 500 + 900;
|
|
249
|
+
// Initial animation sequences
|
|
250
|
+
const tTimeout = setTimeout(() => animateCharacter(setTFrame, T_FRAMES.length, tAnimating), tDelay);
|
|
251
|
+
const oTimeout = setTimeout(() => animateCharacter(setOFrame, O_FRAMES.length, oAnimating), oDelay);
|
|
252
|
+
const nTimeout = setTimeout(() => animateCharacter(setNFrame, N_FRAMES.length, nAnimating), nDelay);
|
|
253
|
+
const kTimeout = setTimeout(() => animateCharacter(setKFrame, K_FRAMES.length, kAnimating), kDelay);
|
|
254
|
+
// Cleanup timeouts on unmount
|
|
255
|
+
return () => {
|
|
256
|
+
clearTimeout(tTimeout);
|
|
257
|
+
clearTimeout(oTimeout);
|
|
258
|
+
clearTimeout(nTimeout);
|
|
259
|
+
clearTimeout(kTimeout);
|
|
260
|
+
};
|
|
261
|
+
}, []);
|
|
262
|
+
// Get rotated star border
|
|
263
|
+
const getStarBorder = () => {
|
|
264
|
+
return STAR_CHARS.slice(starIndex) + STAR_CHARS.slice(0, starIndex);
|
|
265
|
+
};
|
|
266
|
+
return (React.createElement(Box, { flexDirection: "column", alignItems: "flex-start" },
|
|
267
|
+
React.createElement(Text, null, getStarBorder()),
|
|
268
|
+
React.createElement(Box, { marginY: 1 },
|
|
269
|
+
React.createElement(Box, { flexDirection: "row" },
|
|
270
|
+
React.createElement(Box, { marginRight: 1 },
|
|
271
|
+
React.createElement(Text, { color: "green" }, T_FRAMES[tFrame])),
|
|
272
|
+
React.createElement(Box, { marginRight: 1 },
|
|
273
|
+
React.createElement(Text, { color: "magenta" }, O_FRAMES[oFrame])),
|
|
274
|
+
React.createElement(Box, { marginRight: 1 },
|
|
275
|
+
React.createElement(Text, { color: "cyan" }, N_FRAMES[nFrame])),
|
|
276
|
+
React.createElement(Box, null,
|
|
277
|
+
React.createElement(Text, { color: "yellow" }, K_FRAMES[kFrame])))),
|
|
278
|
+
React.createElement(Text, null, getStarBorder()),
|
|
279
|
+
React.createElement(WelcomeMessage, null)));
|
|
280
|
+
};
|
|
281
|
+
// Function to render the animation and return a function to stop it
|
|
282
|
+
const displayTonkAnimation = () => {
|
|
283
|
+
// Render the component using Ink
|
|
284
|
+
const { unmount } = render(React.createElement(TonkAsciiAnimated, null));
|
|
285
|
+
// Return a cleanup function
|
|
286
|
+
return () => {
|
|
287
|
+
unmount();
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
export default displayTonkAnimation;
|
|
291
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/hello/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AACjD,OAAO,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAC,MAAM,KAAK,CAAC;AAGhD,uFAAuF;AACvF,MAAM,cAAc,GAAG;;;;;;;;CAQtB,CAAC;AAEF,yEAAyE;AACzE,MAAM,QAAQ,GAAG;IACf,sBAAsB;IACtB;;;;;;iBAMe;IAEf,6BAA6B;IAC7B;;;;;;iBAMe;IAEf,4BAA4B;IAC5B;;;;;;kBAMgB;CACjB,CAAC;AAEF,yEAAyE;AACzE,MAAM,QAAQ,GAAG;IACf,sBAAsB;IACtB;;;;;;eAMa;IAEb,wBAAwB;IACxB;;;;;;gBAMc;IAEd,kCAAkC;IAClC;;;;;;cAMY;CACb,CAAC;AAEF,yEAAyE;AACzE,MAAM,QAAQ,GAAG;IACf,sBAAsB;IACtB;;;;;;eAMa;IAEb,kCAAkC;IAClC;;;;;;gBAMc;IAEd,kCAAkC;IAClC;;;;;;gBAMc;CACf,CAAC;AAEF,yEAAyE;AACzE,MAAM,QAAQ,GAAG;IACf,sBAAsB;IACtB;;;;;;cAMY;IAEZ,uBAAuB;IACvB;;;;;;YAMU;IAEV,wBAAwB;IACxB;;;;;;cAMY;IAEZ,6BAA6B;IAC7B;;;;;;cAMY;CACb,CAAC;AAEF,kBAAkB;AAClB,MAAM,UAAU,GACd,6CAA6C,CAAC;AAEhD,0BAA0B;AAC1B,MAAM,gBAAgB,GAAG;IACvB,yEAAyE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C,KAAK,EAAC,SAAS,IAAE,QAAQ,CAAC,MAAM,CAAC,CAAQ,CAC3C;gBAGN,oBAAC,GAAG,IAAC,WAAW,EAAE,CAAC;oBACjB,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,IAAE,QAAQ,CAAC,MAAM,CAAC,CAAQ,CACxC;gBAGN,oBAAC,GAAG;oBACF,oBAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,IAAE,QAAQ,CAAC,MAAM,CAAC,CAAQ,CAC1C,CACF,CACF;QAGN,oBAAC,IAAI,QAAE,aAAa,EAAE,CAAQ;QAG9B,oBAAC,cAAc,OAAG,CACd,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,oEAAoE;AACpE,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAChC,iCAAiC;IACjC,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,CAAC,oBAAC,iBAAiB,OAAG,CAAC,CAAC;IAEhD,4BAA4B;IAC5B,OAAO,GAAG,EAAE;QACV,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hello.d.ts","sourceRoot":"","sources":["../../src/commands/hello.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hello.d.ts","sourceRoot":"","sources":["../../src/commands/hello.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAWlC,eAAO,MAAM,YAAY,SAsErB,CAAC"}
|
package/dist/commands/hello.js
CHANGED
|
@@ -1,10 +1,73 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
1
|
import { Command } from 'commander';
|
|
3
|
-
import
|
|
2
|
+
import displayTonkAnimation from './hello/index.js';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import envPaths from 'env-paths';
|
|
6
|
+
import { exec } from 'child_process';
|
|
7
|
+
import { promisify } from 'util';
|
|
8
|
+
const execAsync = promisify(exec);
|
|
4
9
|
export const helloCommand = new Command('hello')
|
|
5
|
-
.description('
|
|
6
|
-
.action(() => {
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
.description('Say hello to start and launch the tonk daemon')
|
|
11
|
+
.action(async (options) => {
|
|
12
|
+
try {
|
|
13
|
+
// Check if pm2 is installed
|
|
14
|
+
let pm2Exists = false;
|
|
15
|
+
try {
|
|
16
|
+
await execAsync('pm2 --version');
|
|
17
|
+
pm2Exists = true;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
// pm2 is not installed or not in PATH
|
|
21
|
+
console.log(chalk.yellow('PM2 is required to run the tonk daemon.'));
|
|
22
|
+
const { installPm2 } = await inquirer.prompt([
|
|
23
|
+
{
|
|
24
|
+
type: 'confirm',
|
|
25
|
+
name: 'installPm2',
|
|
26
|
+
message: 'Would you like to install PM2?',
|
|
27
|
+
default: true,
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
if (installPm2) {
|
|
31
|
+
console.log(chalk.blue('Installing PM2...'));
|
|
32
|
+
await execAsync('npm install -g pm2');
|
|
33
|
+
pm2Exists = true;
|
|
34
|
+
console.log(chalk.green('PM2 installed successfully.'));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log(chalk.red('PM2 is required to run the tonk daemon. Exiting.'));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (pm2Exists) {
|
|
42
|
+
console.log(chalk.blue('Starting tonk daemon with PM2...'));
|
|
43
|
+
try {
|
|
44
|
+
// Check if tonk process is already running in PM2
|
|
45
|
+
const { stdout } = await execAsync('pm2 list');
|
|
46
|
+
if (stdout.includes('tonkserver')) {
|
|
47
|
+
console.log(chalk.yellow('Tonk daemon is already running. Restarting...'));
|
|
48
|
+
await execAsync('pm2 restart tonkserver');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// Start the tonk daemon with PM2
|
|
52
|
+
await execAsync('pm2 start tonk --name tonkserver -- -d');
|
|
53
|
+
}
|
|
54
|
+
console.log(chalk.green('Tonk daemon started successfully!'));
|
|
55
|
+
const paths = envPaths('tonk', { suffix: '' });
|
|
56
|
+
const tonkHome = paths.data;
|
|
57
|
+
// Pretty print the Tonk home location
|
|
58
|
+
console.log(chalk.cyan('🏠 Tonk Home:'), chalk.bold.green(tonkHome));
|
|
59
|
+
// Display the welcome animation
|
|
60
|
+
displayTonkAnimation();
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error(chalk.red('Failed to start tonk daemon:'), error);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error(chalk.red('An error occurred:'), error);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
9
72
|
});
|
|
10
73
|
//# sourceMappingURL=hello.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hello.js","sourceRoot":"","sources":["../../src/commands/hello.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"hello.js","sourceRoot":"","sources":["../../src/commands/hello.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,oBAAoB,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAE/B,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,YAAY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.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAkDlC,eAAO,MAAM,WAAW,SA+BpB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a package path by checking both local development and global installation paths
|
|
7
|
+
* @param relativePath Path relative to the package root
|
|
8
|
+
* @returns Resolved absolute path to the requested file/directory
|
|
9
|
+
*/
|
|
10
|
+
async function resolvePackagePath(relativePath) {
|
|
11
|
+
try {
|
|
12
|
+
// For ESM, get the directory name using import.meta.url
|
|
13
|
+
const moduleUrl = import.meta.url;
|
|
14
|
+
const moduleDirPath = path.dirname(fileURLToPath(moduleUrl));
|
|
15
|
+
// Try local development path first
|
|
16
|
+
const localPath = path.resolve(moduleDirPath, '..', relativePath);
|
|
17
|
+
if (await fs.pathExists(localPath)) {
|
|
18
|
+
return localPath;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// If local path doesn't exist, try global node_modules
|
|
22
|
+
const { execSync } = await import('child_process');
|
|
23
|
+
const globalNodeModules = execSync('npm root -g').toString().trim();
|
|
24
|
+
// Look for the package in global node_modules
|
|
25
|
+
const globalPath = path.join(globalNodeModules, '@tonk/create', relativePath);
|
|
26
|
+
if (await fs.pathExists(globalPath)) {
|
|
27
|
+
return globalPath;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new Error(`Could not locate ${relativePath} in local or global paths`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error(`Error resolving path ${relativePath}:`, error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export const initCommand = new Command('init')
|
|
40
|
+
.description('Create a new Tonk repo')
|
|
41
|
+
.argument('[<directory>]', 'optionally creates a directory and initializes the tonk repo in that directory')
|
|
42
|
+
.action(async (dirPath) => {
|
|
43
|
+
const cwd = process.cwd();
|
|
44
|
+
const templatePath = await resolvePackagePath(`template`);
|
|
45
|
+
const target = dirPath ? path.join(cwd, dirPath) : cwd;
|
|
46
|
+
if (dirPath) {
|
|
47
|
+
await fs.mkdir(target);
|
|
48
|
+
}
|
|
49
|
+
await fs.copy(templatePath, target, {
|
|
50
|
+
filter: (src) => {
|
|
51
|
+
// Get the relative path from the template directory
|
|
52
|
+
const relativePath = path.relative(templatePath, src);
|
|
53
|
+
// Only filter out node_modules and .git within the template
|
|
54
|
+
const shouldCopy = !relativePath
|
|
55
|
+
.split(path.sep)
|
|
56
|
+
.some(part => part === 'node_modules' || part === '.git');
|
|
57
|
+
if (!shouldCopy) {
|
|
58
|
+
console.log(`Skipping: ${relativePath}`);
|
|
59
|
+
}
|
|
60
|
+
return shouldCopy;
|
|
61
|
+
},
|
|
62
|
+
overwrite: true,
|
|
63
|
+
errorOnExist: false,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAGlC;;;;GAIG;AACH,KAAK,UAAU,kBAAkB,CAAC,YAAoB;IACpD,IAAI,CAAC;QACH,wDAAwD;QACxD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QAClC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CA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