@tonk/cli 0.3.3 → 0.4.0
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 +15 -202
- package/bin/tonk.js +36 -1
- package/package.json +23 -89
- package/dist/commands/auth.d.ts +0 -3
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js +0 -184
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/create.d.ts +0 -3
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js +0 -55
- package/dist/commands/create.js.map +0 -1
- package/dist/commands/delete.d.ts +0 -3
- package/dist/commands/delete.d.ts.map +0 -1
- package/dist/commands/delete.js +0 -67
- package/dist/commands/delete.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 -336
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/hello/index.d.ts +0 -3
- package/dist/commands/hello/index.d.ts.map +0 -1
- package/dist/commands/hello/index.js +0 -296
- package/dist/commands/hello/index.js.map +0 -1
- package/dist/commands/hello.d.ts +0 -3
- package/dist/commands/hello.d.ts.map +0 -1
- package/dist/commands/hello.js +0 -83
- package/dist/commands/hello.js.map +0 -1
- package/dist/commands/init.d.ts +0 -3
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -137
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/kill.d.ts +0 -3
- package/dist/commands/kill.d.ts.map +0 -1
- package/dist/commands/kill.js +0 -66
- package/dist/commands/kill.js.map +0 -1
- package/dist/commands/ls.d.ts +0 -3
- package/dist/commands/ls.d.ts.map +0 -1
- package/dist/commands/ls.js +0 -52
- package/dist/commands/ls.js.map +0 -1
- package/dist/commands/proxy.d.ts +0 -3
- package/dist/commands/proxy.d.ts.map +0 -1
- package/dist/commands/proxy.js +0 -86
- package/dist/commands/proxy.js.map +0 -1
- package/dist/commands/ps.d.ts +0 -3
- package/dist/commands/ps.d.ts.map +0 -1
- package/dist/commands/ps.js +0 -56
- package/dist/commands/ps.js.map +0 -1
- package/dist/commands/push.d.ts +0 -3
- package/dist/commands/push.d.ts.map +0 -1
- package/dist/commands/push.js +0 -238
- package/dist/commands/push.js.map +0 -1
- package/dist/commands/server.d.ts +0 -3
- package/dist/commands/server.d.ts.map +0 -1
- package/dist/commands/server.js +0 -676
- package/dist/commands/server.js.map +0 -1
- package/dist/commands/start.d.ts +0 -3
- package/dist/commands/start.d.ts.map +0 -1
- package/dist/commands/start.js +0 -82
- package/dist/commands/start.js.map +0 -1
- package/dist/commands/worker/commands.d.ts +0 -42
- package/dist/commands/worker/commands.d.ts.map +0 -1
- package/dist/commands/worker/commands.js +0 -968
- package/dist/commands/worker/commands.js.map +0 -1
- package/dist/commands/worker/index.d.ts +0 -7
- package/dist/commands/worker/index.d.ts.map +0 -1
- package/dist/commands/worker/index.js +0 -30
- package/dist/commands/worker/index.js.map +0 -1
- package/dist/commands/worker/utils/config.d.ts +0 -26
- package/dist/commands/worker/utils/config.d.ts.map +0 -1
- package/dist/commands/worker/utils/config.js +0 -197
- package/dist/commands/worker/utils/config.js.map +0 -1
- package/dist/commands/worker/utils/display.d.ts +0 -6
- package/dist/commands/worker/utils/display.d.ts.map +0 -1
- package/dist/commands/worker/utils/display.js +0 -32
- package/dist/commands/worker/utils/display.js.map +0 -1
- package/dist/commands/worker/utils/finder.d.ts +0 -12
- package/dist/commands/worker/utils/finder.d.ts.map +0 -1
- package/dist/commands/worker/utils/finder.js +0 -60
- package/dist/commands/worker/utils/finder.js.map +0 -1
- package/dist/config/environment.d.ts +0 -52
- package/dist/config/environment.d.ts.map +0 -1
- package/dist/config/environment.js +0 -83
- package/dist/config/environment.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/lib/tonkAuth.d.ts +0 -21
- package/dist/lib/tonkAuth.d.ts.map +0 -1
- package/dist/lib/tonkAuth.js +0 -140
- package/dist/lib/tonkAuth.js.map +0 -1
- package/dist/lib/workerManager.d.ts +0 -60
- package/dist/lib/workerManager.d.ts.map +0 -1
- package/dist/lib/workerManager.js +0 -417
- package/dist/lib/workerManager.js.map +0 -1
- package/dist/scripts/aws/create-key.sh +0 -20
- package/dist/scripts/aws/ec2-dns.sh +0 -20
- package/dist/scripts/aws/provision.sh +0 -93
- package/dist/tonk.d.ts +0 -2
- package/dist/tonk.d.ts.map +0 -1
- package/dist/tonk.js +0 -106
- package/dist/tonk.js.map +0 -1
- package/dist/types/worker.d.ts +0 -161
- package/dist/types/worker.d.ts.map +0 -1
- package/dist/types/worker.js +0 -7
- package/dist/types/worker.js.map +0 -1
- package/dist/types/workerConfig.d.ts +0 -164
- package/dist/types/workerConfig.d.ts.map +0 -1
- package/dist/types/workerConfig.js +0 -80
- package/dist/types/workerConfig.js.map +0 -1
- package/dist/utils/analytics.d.ts +0 -26
- package/dist/utils/analytics.d.ts.map +0 -1
- package/dist/utils/analytics.js +0 -218
- package/dist/utils/analytics.js.map +0 -1
- package/dist/utils/messages.d.ts +0 -6
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js +0 -18
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/serverUtils.d.ts +0 -5
- package/dist/utils/serverUtils.d.ts.map +0 -1
- package/dist/utils/serverUtils.js +0 -34
- package/dist/utils/serverUtils.js.map +0 -1
- package/dist/utils/version.d.ts +0 -2
- package/dist/utils/version.d.ts.map +0 -1
- package/dist/utils/version.js +0 -3
- package/dist/utils/version.js.map +0 -1
- package/scripts/aws/create-key.sh +0 -20
- package/scripts/aws/ec2-dns.sh +0 -20
- package/scripts/aws/provision.sh +0 -93
package/README.md
CHANGED
|
@@ -1,210 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tonk/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Tonk stack command line utility — `tonk`.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
npm install -g @tonk/cli
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Commands
|
|
12
|
-
|
|
13
|
-
### Create a new Tonk app
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
tonk create my-app
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Development
|
|
20
|
-
|
|
21
|
-
Run your Tonk app in development mode:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
tonk dev
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Serve
|
|
28
|
-
|
|
29
|
-
Serve your built Tonk app locally:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
tonk serve
|
|
33
|
-
```
|
|
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
|
-
|
|
110
|
-
### Configure AWS Deployment
|
|
111
|
-
|
|
112
|
-
Configure your AWS EC2 instance for deployment:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
# Interactive configuration (with existing instance)
|
|
116
|
-
tonk config
|
|
117
|
-
|
|
118
|
-
# Provision a new EC2 instance
|
|
119
|
-
tonk config --provision [--key-name my-key]
|
|
120
|
-
|
|
121
|
-
# Configure with existing EC2 instance
|
|
122
|
-
tonk config --instance ec2-xx-xx-xx-xx.compute-1.amazonaws.com --key ~/path/to/key.pem
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Options:
|
|
126
|
-
|
|
127
|
-
- `-i, --instance <address>` - EC2 instance address
|
|
128
|
-
- `-k, --key <path>` - Path to SSH key file
|
|
129
|
-
- `-u, --user <n>` - SSH username (default: ec2-user)
|
|
130
|
-
- `-p, --provision` - Provision a new EC2 instance
|
|
131
|
-
- `-n, --key-name <n>` - AWS key pair name (for provisioning)
|
|
132
|
-
|
|
133
|
-
### Deploy to AWS
|
|
134
|
-
|
|
135
|
-
Deploy your Tonk app to an EC2 instance:
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
tonk deploy
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Options:
|
|
142
|
-
|
|
143
|
-
- `-i, --instance <address>` - EC2 instance address
|
|
144
|
-
- `-k, --key <path>` - Path to SSH key file
|
|
145
|
-
- `-u, --user <n>` - SSH username (default: ec2-user)
|
|
146
|
-
- `-t, --token <token>` - Pinggy.io access token for public URL
|
|
147
|
-
- `-b, --backblaze` - Enable Backblaze B2 storage for document backup
|
|
148
|
-
- `-f, --filesystem` - Enable filesystem storage for document backup
|
|
149
|
-
|
|
150
|
-
#### Persistence Features
|
|
151
|
-
|
|
152
|
-
Tonk supports multiple options for persisting your documents:
|
|
153
|
-
|
|
154
|
-
1. **Backblaze B2 Storage**: Cloud-based backup for your documents
|
|
155
|
-
- Secure, scalable cloud storage
|
|
156
|
-
- Automatic synchronization at configurable intervals
|
|
157
|
-
- Requires a Backblaze B2 account with bucket and application keys
|
|
158
|
-
|
|
159
|
-
2. **Filesystem Storage**: Local file-based storage on your server
|
|
160
|
-
- Store documents directly on the server's filesystem
|
|
161
|
-
- Configurable storage path and sync intervals
|
|
162
|
-
- Automatic directory creation
|
|
163
|
-
|
|
164
|
-
3. **Dual Storage**: Use both Backblaze and filesystem storage
|
|
165
|
-
- Configure a primary storage option
|
|
166
|
-
- Automatic fallback to secondary storage
|
|
167
|
-
|
|
168
|
-
During deployment, you'll be guided through setting up your preferred storage options interactively
|
|
169
|
-
if not specified via command-line options.
|
|
170
|
-
|
|
171
|
-
## Development
|
|
172
|
-
|
|
173
|
-
1. Clone the repository
|
|
174
|
-
2. Install dependencies: `npm install`
|
|
175
|
-
3. Run the dev mode: `npm run dev`
|
|
176
|
-
|
|
177
|
-
## Troubleshooting
|
|
178
|
-
|
|
179
|
-
### Permission Denied Error During Installation
|
|
180
|
-
|
|
181
|
-
If you encounter a permission denied error when installing the Tonk CLI globally:
|
|
182
|
-
|
|
183
|
-
```bash
|
|
5
|
+
```sh
|
|
6
|
+
npx @tonk/cli --help
|
|
7
|
+
# or install globally
|
|
184
8
|
npm install -g @tonk/cli
|
|
185
|
-
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
This is a common npm issue on Unix systems. Here are several solutions:
|
|
189
|
-
|
|
190
|
-
#### Option 1: Fix npm permissions
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
|
|
9
|
+
tonk --help
|
|
194
10
|
```
|
|
195
11
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
mkdir ~/.npm-global
|
|
200
|
-
npm config set prefix '~/.npm-global'
|
|
201
|
-
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
|
|
202
|
-
source ~/.bashrc
|
|
203
|
-
npm install -g @tonk/cli
|
|
204
|
-
```
|
|
12
|
+
`@tonk/cli` is a thin launcher. The actual `tonk` program is a native
|
|
13
|
+
binary shipped in a per-platform package that npm installs automatically
|
|
14
|
+
for your OS and CPU:
|
|
205
15
|
|
|
206
|
-
|
|
16
|
+
| Platform | Package |
|
|
17
|
+
| ------------- | ------------------------- |
|
|
18
|
+
| macOS (arm64) | `@tonk/cli-darwin-arm64` |
|
|
19
|
+
| Linux (x64) | `@tonk/cli-linux-x64` |
|
|
207
20
|
|
|
208
|
-
|
|
21
|
+
More platforms coming soon.
|
|
209
22
|
|
|
210
|
-
|
|
23
|
+
Source: [`rust/tonk-cli`](https://github.com/tonk-labs/tonk/tree/main/rust/tonk-cli).
|
package/bin/tonk.js
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
// Thin launcher for the tonk CLI. The real program is a native Rust
|
|
5
|
+
// binary shipped in a per-platform package (@tonk/cli-<platform>-<arch>).
|
|
6
|
+
// npm installs only the package whose `os`/`cpu` match this host, so we
|
|
7
|
+
// resolve that one binary and exec it. esbuild, turbo, and swc all
|
|
8
|
+
// distribute their native binaries with this same require.resolve pattern.
|
|
9
|
+
const { spawnSync } = require("node:child_process");
|
|
10
|
+
|
|
11
|
+
function resolveBinary() {
|
|
12
|
+
const { platform, arch } = process;
|
|
13
|
+
const pkg = `@tonk/cli-${platform}-${arch}`;
|
|
14
|
+
const exe = platform === "win32" ? "tonk.exe" : "tonk";
|
|
15
|
+
try {
|
|
16
|
+
return require.resolve(`${pkg}/bin/${exe}`);
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bin = resolveBinary();
|
|
23
|
+
if (bin === null) {
|
|
24
|
+
console.error(
|
|
25
|
+
`@tonk/cli: no prebuilt tonk binary for ${process.platform}-${process.arch} yet.\n` +
|
|
26
|
+
"Supported today: darwin-arm64 and linux-x64. More platforms coming soon.",
|
|
27
|
+
);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
32
|
+
if (result.error) {
|
|
33
|
+
console.error(result.error.message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
// spawnSync sets `status` to null when the child was killed by a signal;
|
|
37
|
+
// map that to a non-zero exit so callers see the failure.
|
|
38
|
+
process.exit(typeof result.status === "number" ? result.status : 1);
|
package/package.json
CHANGED
|
@@ -1,102 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonk/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The Tonk stack command line utility",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
},
|
|
12
|
-
"typesVersions": {
|
|
13
|
-
"*": {
|
|
14
|
-
"index": [
|
|
15
|
-
"./dist/index.d.ts"
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"bin",
|
|
21
|
-
"dist",
|
|
22
|
-
"scripts"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsup && chmod +x ./dist/tonk.js && npm run copy-scripts",
|
|
26
|
-
"copy-scripts": "mkdir -p ./dist/scripts && cp -r ./scripts/* ./dist/scripts/",
|
|
27
|
-
"dev": "tsup --watch",
|
|
28
|
-
"clean": "rimraf dist",
|
|
29
|
-
"lint": "eslint src/**/*.ts",
|
|
30
|
-
"lint:fix": "eslint src/**/*.ts --fix",
|
|
31
|
-
"format": "prettier --write src/**/*.ts",
|
|
32
|
-
"format:check": "prettier --check src/**/*.ts",
|
|
33
|
-
"test": "vitest run",
|
|
34
|
-
"prepublishOnly": "npm run build",
|
|
35
|
-
"compile": "tsc",
|
|
36
|
-
"prepare": "npm run compile",
|
|
37
|
-
"pretest": "npm run compile",
|
|
38
|
-
"posttest": "npm run lint"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@tonk/server": "^0.3.0",
|
|
42
|
-
"@tonk/tonk-auth": "^0.2.2",
|
|
43
|
-
"chalk": "^5.3.0",
|
|
44
|
-
"cli-table3": "^0.6.5",
|
|
45
|
-
"commander": "^11.1.0",
|
|
46
|
-
"dotenv": "^17.0.1",
|
|
47
|
-
"env-paths": "^3.0.0",
|
|
48
|
-
"fastmcp": "^1.20.2",
|
|
49
|
-
"form-data-encoder": "^4.0.2",
|
|
50
|
-
"formdata-node": "^6.0.3",
|
|
51
|
-
"fs-extra": "^11.2.0",
|
|
52
|
-
"gradient-string": "^2.0.2",
|
|
53
|
-
"ink": "^5.2.0",
|
|
54
|
-
"inquirer": "^9.2.12",
|
|
55
|
-
"listr2": "^8.2.5",
|
|
56
|
-
"marked": "^15.0.7",
|
|
57
|
-
"node-fetch": "^3.3.2",
|
|
58
|
-
"open": "^10.1.0",
|
|
59
|
-
"ora": "^7.0.1",
|
|
60
|
-
"posthog-node": "^4.18.0",
|
|
61
|
-
"react": "18",
|
|
62
|
-
"tar": "^6.2.1",
|
|
63
|
-
"yaml": "^2.3.4",
|
|
64
|
-
"zod": "^3.24.2"
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@types/fs-extra": "^11.0.4",
|
|
68
|
-
"@types/gradient-string": "^1.1.5",
|
|
69
|
-
"@types/inquirer": "^9.0.7",
|
|
70
|
-
"@types/node": "^22.7.5",
|
|
71
|
-
"@types/node-fetch": "^2.6.9",
|
|
72
|
-
"@types/react": "18",
|
|
73
|
-
"@types/tar": "^6.1.11",
|
|
74
|
-
"rimraf": "^5.0.5",
|
|
75
|
-
"tsup": "^8.0.1",
|
|
76
|
-
"typescript": "^5.6.3",
|
|
77
|
-
"vitest": "^1.0.4"
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "The Tonk stack command line utility.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/tonk-labs/tonk#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/tonk-labs/tonk.git",
|
|
10
|
+
"directory": "rust/tonk-cli"
|
|
78
11
|
},
|
|
79
|
-
"
|
|
80
|
-
"
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/tonk-labs/tonk/issues"
|
|
81
14
|
},
|
|
82
15
|
"keywords": [
|
|
83
16
|
"cli",
|
|
84
17
|
"ai",
|
|
85
18
|
"crdt",
|
|
86
|
-
"local-first"
|
|
19
|
+
"local-first",
|
|
20
|
+
"tonk"
|
|
87
21
|
],
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
"repository": {
|
|
91
|
-
"type": "git",
|
|
92
|
-
"url": "https://github.com/tonk-labs/tonk.git",
|
|
93
|
-
"directory": "packages/cli"
|
|
22
|
+
"bin": {
|
|
23
|
+
"tonk": "bin/tonk.js"
|
|
94
24
|
},
|
|
95
|
-
"
|
|
96
|
-
"
|
|
25
|
+
"files": [
|
|
26
|
+
"bin",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
97
31
|
},
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
"
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"@tonk/cli-darwin-arm64": "0.4.0",
|
|
34
|
+
"@tonk/cli-linux-x64": "0.4.0"
|
|
101
35
|
}
|
|
102
36
|
}
|
package/dist/commands/auth.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC,eAAO,MAAM,WAAW,SAMpB,CAAC"}
|
package/dist/commands/auth.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { trackCommand, trackCommandError, trackCommandSuccess, } from '../utils/analytics.js';
|
|
4
|
-
// Lazy-load tonkAuth to prevent initialization on import
|
|
5
|
-
async function getTonkAuth() {
|
|
6
|
-
const { tonkAuth } = await import('../lib/tonkAuth.js');
|
|
7
|
-
return tonkAuth;
|
|
8
|
-
}
|
|
9
|
-
const getAuthDescription = async () => {
|
|
10
|
-
try {
|
|
11
|
-
const tonkAuth = await getTonkAuth();
|
|
12
|
-
if (!tonkAuth.isReady)
|
|
13
|
-
return 'Log in to your Tonk account';
|
|
14
|
-
if (tonkAuth.isSignedIn && tonkAuth.activeSubscription)
|
|
15
|
-
return '🚀 You have an active subscription!';
|
|
16
|
-
if (tonkAuth.isSignedIn)
|
|
17
|
-
return `🌈 You're signed in to Tonk as ${tonkAuth.friendlyName}`;
|
|
18
|
-
return 'Log in to your Tonk account';
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return 'Log in to your Tonk account';
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
export const authCommand = new Command('auth')
|
|
25
|
-
.description('Manage your Tonk authentication')
|
|
26
|
-
.action(async () => {
|
|
27
|
-
// Update description dynamically when auth command is actually used
|
|
28
|
-
authCommand.description(await getAuthDescription());
|
|
29
|
-
authCommand.help();
|
|
30
|
-
});
|
|
31
|
-
authCommand
|
|
32
|
-
.command('login')
|
|
33
|
-
.description('Login to your Tonk account')
|
|
34
|
-
.action(async () => {
|
|
35
|
-
const startTime = Date.now();
|
|
36
|
-
let tonkAuth = null;
|
|
37
|
-
try {
|
|
38
|
-
trackCommand('auth-login', {});
|
|
39
|
-
tonkAuth = await getTonkAuth();
|
|
40
|
-
await tonkAuth.ensureReady();
|
|
41
|
-
if (tonkAuth.isSignedIn) {
|
|
42
|
-
console.log(`💌 Welcome back ${tonkAuth.friendlyName}, you're ready to Tonk!`);
|
|
43
|
-
const duration = Date.now() - startTime;
|
|
44
|
-
trackCommandSuccess('auth-login', duration, {
|
|
45
|
-
wasAlreadySignedIn: true,
|
|
46
|
-
hasActiveSubscription: tonkAuth.activeSubscription,
|
|
47
|
-
userName: tonkAuth.friendlyName,
|
|
48
|
-
});
|
|
49
|
-
await tonkAuth.destroy();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
console.log("\n🗺️ Great, let's sign you in using your browser!");
|
|
53
|
-
const res = await tonkAuth.login();
|
|
54
|
-
if (!res.ok) {
|
|
55
|
-
const duration = Date.now() - startTime;
|
|
56
|
-
trackCommandError('auth-login', new Error(res.error || 'Unknown login error'), duration, {
|
|
57
|
-
wasAlreadySignedIn: false,
|
|
58
|
-
errorType: 'login_failed',
|
|
59
|
-
});
|
|
60
|
-
console.error(chalk.red(`Failed to login to Tonk: ${res.error || 'Unknown error'}`));
|
|
61
|
-
await tonkAuth.destroy();
|
|
62
|
-
process.exitCode = 1;
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
console.log(`💌 YAAY! Good to have you ${tonkAuth.friendlyName}!`);
|
|
66
|
-
const duration = Date.now() - startTime;
|
|
67
|
-
trackCommandSuccess('auth-login', duration, {
|
|
68
|
-
wasAlreadySignedIn: false,
|
|
69
|
-
hasActiveSubscription: tonkAuth.activeSubscription,
|
|
70
|
-
userName: tonkAuth.friendlyName,
|
|
71
|
-
});
|
|
72
|
-
await tonkAuth.destroy();
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
const duration = Date.now() - startTime;
|
|
76
|
-
trackCommandError('auth-login', error, duration, {
|
|
77
|
-
errorType: 'unexpected_error',
|
|
78
|
-
});
|
|
79
|
-
console.error(chalk.red('An unexpected error occurred during login:'), error);
|
|
80
|
-
if (tonkAuth) {
|
|
81
|
-
await tonkAuth.destroy();
|
|
82
|
-
}
|
|
83
|
-
process.exitCode = 1;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
authCommand
|
|
87
|
-
.command('logout')
|
|
88
|
-
.description('Logout from your Tonk account')
|
|
89
|
-
.action(async () => {
|
|
90
|
-
const startTime = Date.now();
|
|
91
|
-
let tonkAuth = null;
|
|
92
|
-
try {
|
|
93
|
-
trackCommand('auth-logout', {});
|
|
94
|
-
tonkAuth = await getTonkAuth();
|
|
95
|
-
await tonkAuth.ensureReady();
|
|
96
|
-
if (!tonkAuth.isSignedIn) {
|
|
97
|
-
console.log(`💌 You're already signed out of Tonk`);
|
|
98
|
-
const duration = Date.now() - startTime;
|
|
99
|
-
trackCommandSuccess('auth-logout', duration, {
|
|
100
|
-
wasAlreadySignedOut: true,
|
|
101
|
-
});
|
|
102
|
-
await tonkAuth.destroy();
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const name = tonkAuth.friendlyName;
|
|
106
|
-
const hadActiveSubscription = tonkAuth.activeSubscription;
|
|
107
|
-
const res = await tonkAuth.logout();
|
|
108
|
-
if (!res.ok) {
|
|
109
|
-
const duration = Date.now() - startTime;
|
|
110
|
-
trackCommandError('auth-logout', new Error(res.error || 'Unknown logout error'), duration, {
|
|
111
|
-
wasSignedIn: true,
|
|
112
|
-
userName: name,
|
|
113
|
-
hadActiveSubscription,
|
|
114
|
-
errorType: 'logout_failed',
|
|
115
|
-
});
|
|
116
|
-
console.error(chalk.red(`Failed to logout from Tonk: ${res.error || 'Unknown error'}`));
|
|
117
|
-
await tonkAuth.destroy();
|
|
118
|
-
process.exitCode = 1;
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
console.log(`👋❤️😮💨 Ciao ${name}`);
|
|
122
|
-
const duration = Date.now() - startTime;
|
|
123
|
-
trackCommandSuccess('auth-logout', duration, {
|
|
124
|
-
wasAlreadySignedOut: false,
|
|
125
|
-
userName: name,
|
|
126
|
-
hadActiveSubscription,
|
|
127
|
-
});
|
|
128
|
-
await tonkAuth.destroy();
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
const duration = Date.now() - startTime;
|
|
132
|
-
trackCommandError('auth-logout', error, duration, {
|
|
133
|
-
errorType: 'unexpected_error',
|
|
134
|
-
});
|
|
135
|
-
console.error(chalk.red('An unexpected error occurred during logout:'), error);
|
|
136
|
-
if (tonkAuth) {
|
|
137
|
-
await tonkAuth.destroy();
|
|
138
|
-
}
|
|
139
|
-
process.exitCode = 1;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
authCommand
|
|
143
|
-
.command('status')
|
|
144
|
-
.description('Show your authentication status')
|
|
145
|
-
.action(async () => {
|
|
146
|
-
const startTime = Date.now();
|
|
147
|
-
let tonkAuth = null;
|
|
148
|
-
try {
|
|
149
|
-
trackCommand('auth-status', {});
|
|
150
|
-
tonkAuth = await getTonkAuth();
|
|
151
|
-
await tonkAuth.ensureReady();
|
|
152
|
-
if (tonkAuth.isSignedIn) {
|
|
153
|
-
console.log(`✅ Signed in as ${tonkAuth.friendlyName}`);
|
|
154
|
-
console.log(`📦 Subscription: ${tonkAuth.activeSubscription ? 'Active' : 'Inactive'}`);
|
|
155
|
-
const duration = Date.now() - startTime;
|
|
156
|
-
trackCommandSuccess('auth-status', duration, {
|
|
157
|
-
isSignedIn: true,
|
|
158
|
-
hasActiveSubscription: tonkAuth.activeSubscription,
|
|
159
|
-
userName: tonkAuth.friendlyName,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
console.log('❌ Not signed in');
|
|
164
|
-
const duration = Date.now() - startTime;
|
|
165
|
-
trackCommandSuccess('auth-status', duration, {
|
|
166
|
-
isSignedIn: false,
|
|
167
|
-
hasActiveSubscription: false,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
await tonkAuth.destroy();
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
const duration = Date.now() - startTime;
|
|
174
|
-
trackCommandError('auth-status', error, duration, {
|
|
175
|
-
errorType: 'unexpected_error',
|
|
176
|
-
});
|
|
177
|
-
console.error(chalk.red('An unexpected error occurred while checking status:'), error);
|
|
178
|
-
if (tonkAuth) {
|
|
179
|
-
await tonkAuth.destroy();
|
|
180
|
-
}
|
|
181
|
-
process.exitCode = 1;
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM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,CAAC,kBAAkB;gBAClD,QAAQ,EAAE,QAAQ,CAAC,YAAY;aAChC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;YAE/B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,EAAE;gBAC3C,UAAU,EAAE,KAAK;gBACjB,qBAAqB,EAAE,KAAK;aAC7B,CAAC,CAAC;QACL,CAAC;QAED,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QACxC,iBAAiB,CAAC,aAAa,EAAE,KAAc,EAAE,QAAQ,EAAE;YACzD,SAAS,EAAE,kBAAkB;SAC9B,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAAC,qDAAqD,CAAC,EAChE,KAAK,CACN,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,eAAO,MAAM,aAAa,SAuDtB,CAAC"}
|
package/dist/commands/create.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import child_process from 'child_process';
|
|
3
|
-
import { trackCommand, trackCommandError, trackCommandSuccess, shutdownAnalytics, } from '../utils/analytics.js';
|
|
4
|
-
export const createCommand = new Command('create')
|
|
5
|
-
.description('Create a new tonk application or component')
|
|
6
|
-
.option('-i, --init', 'initialize in the folder')
|
|
7
|
-
.action(async (options) => {
|
|
8
|
-
const startTime = Date.now();
|
|
9
|
-
try {
|
|
10
|
-
trackCommand('create', { init: options.init });
|
|
11
|
-
// Build the command with any passed options
|
|
12
|
-
const createCommand = `npx @tonk/create ${options.init ? '-i' : ''}`;
|
|
13
|
-
console.log(createCommand);
|
|
14
|
-
// Execute the create package
|
|
15
|
-
child_process.execSync(createCommand, {
|
|
16
|
-
stdio: 'inherit',
|
|
17
|
-
env: { ...process.env },
|
|
18
|
-
});
|
|
19
|
-
const duration = Date.now() - startTime;
|
|
20
|
-
trackCommandSuccess('create', duration, {
|
|
21
|
-
init: options.init,
|
|
22
|
-
command: createCommand,
|
|
23
|
-
});
|
|
24
|
-
await shutdownAnalytics();
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
const duration = Date.now() - startTime;
|
|
28
|
-
// Enhanced error context
|
|
29
|
-
let errorType = 'unknown_error';
|
|
30
|
-
if (error instanceof Error) {
|
|
31
|
-
if (error.message.includes('ENOENT')) {
|
|
32
|
-
errorType = 'command_not_found';
|
|
33
|
-
}
|
|
34
|
-
else if (error.message.includes('EACCES')) {
|
|
35
|
-
errorType = 'permission_denied';
|
|
36
|
-
}
|
|
37
|
-
else if (error.message.includes('NETWORK')) {
|
|
38
|
-
errorType = 'network_error';
|
|
39
|
-
}
|
|
40
|
-
else if (error.message.includes('npm')) {
|
|
41
|
-
errorType = 'npm_error';
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
trackCommandError('create', error, duration, {
|
|
45
|
-
init: options.init,
|
|
46
|
-
command: createCommand,
|
|
47
|
-
errorType,
|
|
48
|
-
exitCode: error.status || error.code,
|
|
49
|
-
});
|
|
50
|
-
console.error('Failed to generate Tonk code:', error);
|
|
51
|
-
await shutdownAnalytics();
|
|
52
|
-
process.exitCode = 1;
|
|
53
|
-
}
|
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