natureco-cli 2.23.30 → 2.23.32
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/natureco.js +178 -167
- package/package.json +1 -1
- package/src/commands/acp.js +39 -0
- package/src/commands/admin-rpc.js +83 -0
- package/src/commands/agent.js +214 -23
- package/src/commands/agents.js +114 -30
- package/src/commands/approvals.js +172 -11
- package/src/commands/ask.js +1 -1
- package/src/commands/browser.js +815 -0
- package/src/commands/capability.js +195 -22
- package/src/commands/channels.js +422 -267
- package/src/commands/chat.js +5 -8
- package/src/commands/clawbot.js +19 -0
- package/src/commands/code.js +3 -2
- package/src/commands/commitments.js +125 -9
- package/src/commands/completion.js +40 -32
- package/src/commands/config.js +228 -30
- package/src/commands/configure.js +84 -67
- package/src/commands/cron.js +239 -19
- package/src/commands/daemon.js +34 -4
- package/src/commands/dashboard.js +47 -374
- package/src/commands/devices.js +53 -26
- package/src/commands/directory.js +146 -14
- package/src/commands/dns.js +148 -10
- package/src/commands/docs.js +119 -26
- package/src/commands/doctor.js +143 -492
- package/src/commands/exec-policy.js +57 -48
- package/src/commands/gateway.js +492 -249
- package/src/commands/health.js +141 -11
- package/src/commands/help.js +24 -25
- package/src/commands/hooks.js +141 -87
- package/src/commands/infer.js +1442 -41
- package/src/commands/logs.js +122 -99
- package/src/commands/mcp.js +121 -309
- package/src/commands/memory.js +128 -0
- package/src/commands/message.js +720 -140
- package/src/commands/models.js +39 -1
- package/src/commands/node.js +77 -77
- package/src/commands/nodes.js +278 -22
- package/src/commands/onboard.js +115 -56
- package/src/commands/pairing.js +108 -107
- package/src/commands/path.js +206 -0
- package/src/commands/plugins.js +35 -1
- package/src/commands/proxy.js +159 -8
- package/src/commands/qr.js +55 -13
- package/src/commands/reset.js +101 -94
- package/src/commands/secrets.js +104 -21
- package/src/commands/sessions.js +110 -51
- package/src/commands/setup.js +229 -649
- package/src/commands/skills.js +67 -1
- package/src/commands/status.js +101 -127
- package/src/commands/tasks.js +208 -100
- package/src/commands/terminal.js +130 -12
- package/src/commands/transcripts.js +24 -1
- package/src/commands/tui.js +41 -0
- package/src/commands/uninstall.js +73 -92
- package/src/commands/update.js +146 -91
- package/src/commands/web-fetch.js +34 -0
- package/src/commands/webhooks.js +58 -66
- package/src/commands/wiki.js +783 -0
- package/src/utils/agents-md.js +85 -0
- package/src/utils/api.js +40 -41
- package/src/utils/format.js +144 -0
- package/src/utils/headless.js +2 -1
- package/src/utils/parallel-tools.js +106 -0
- package/src/utils/sub-agent.js +148 -0
- package/src/utils/token-budget.js +304 -0
- package/src/utils/tool-runner.js +7 -5
- package/src/utils/web-fetch.js +107 -0
package/src/commands/proxy.js
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const http = require('http');
|
|
3
3
|
const https = require('https');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const os = require('os');
|
|
4
7
|
const { URL } = require('url');
|
|
5
8
|
|
|
9
|
+
const PROXY_STATE_FILE = path.join(os.homedir(), '.natureco', 'proxy-state.json');
|
|
10
|
+
|
|
11
|
+
function getState() {
|
|
12
|
+
if (!fs.existsSync(PROXY_STATE_FILE)) {
|
|
13
|
+
return { coverage: {}, sessions: [], blobCache: {}, queryLogs: [] };
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(fs.readFileSync(PROXY_STATE_FILE, 'utf8'));
|
|
17
|
+
} catch {
|
|
18
|
+
return { coverage: {}, sessions: [], blobCache: {}, queryLogs: [] };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function saveState(state) {
|
|
23
|
+
const dir = path.dirname(PROXY_STATE_FILE);
|
|
24
|
+
if (!fs.existsSync(dir)) {
|
|
25
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
fs.writeFileSync(PROXY_STATE_FILE, JSON.stringify(state, null, 2), 'utf8');
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
let proxyInstance = null;
|
|
7
31
|
let captured = [];
|
|
8
32
|
let forwardUrl = null;
|
|
@@ -15,9 +39,15 @@ function proxy(args) {
|
|
|
15
39
|
if (action === 'stop') return stopProxy();
|
|
16
40
|
if (action === 'capture') return showCapture();
|
|
17
41
|
if (action === 'clear') return clearCapture();
|
|
42
|
+
if (action === 'run') return cmdRun();
|
|
43
|
+
if (action === 'coverage') return cmdCoverage();
|
|
44
|
+
if (action === 'sessions') return cmdSessions();
|
|
45
|
+
if (action === 'query') return cmdQuery(params[0]);
|
|
46
|
+
if (action === 'blob') return cmdBlob(params[0]);
|
|
47
|
+
if (action === 'purge') return cmdPurge();
|
|
18
48
|
|
|
19
49
|
console.log(chalk.red(`\n ❌ Bilinmeyen komut: ${action}\n`));
|
|
20
|
-
console.log(chalk.gray(' Kullanım: natureco proxy [status|start|stop|capture|clear]\n'));
|
|
50
|
+
console.log(chalk.gray(' Kullanım: natureco proxy [status|start|stop|capture|clear|run|coverage|sessions|query|blob|purge]\n'));
|
|
21
51
|
process.exit(1);
|
|
22
52
|
}
|
|
23
53
|
|
|
@@ -30,13 +60,18 @@ function statusProxy() {
|
|
|
30
60
|
console.log(` ${chalk.white('Forward:')} ${forwardUrl ? chalk.cyan(forwardUrl) : chalk.gray('(none)')}`);
|
|
31
61
|
console.log(` ${chalk.white('Captured:')} ${captured.length} request(s)`);
|
|
32
62
|
}
|
|
33
|
-
console.log(chalk.gray('\n
|
|
34
|
-
console.log(chalk.gray('
|
|
35
|
-
console.log(chalk.gray('
|
|
36
|
-
console.log(chalk.gray('
|
|
37
|
-
console.log(chalk.gray('
|
|
38
|
-
console.log(chalk.gray('
|
|
39
|
-
console.log(chalk.gray('
|
|
63
|
+
console.log(chalk.gray('\n Commands:'));
|
|
64
|
+
console.log(chalk.gray(' status Show proxy status'));
|
|
65
|
+
console.log(chalk.gray(' start [port] [--forward <url>] Start proxy server'));
|
|
66
|
+
console.log(chalk.gray(' stop Stop proxy server'));
|
|
67
|
+
console.log(chalk.gray(' capture Show captured requests'));
|
|
68
|
+
console.log(chalk.gray(' clear Clear captured requests'));
|
|
69
|
+
console.log(chalk.gray(' run Run proxy (stub)'));
|
|
70
|
+
console.log(chalk.gray(' coverage Show proxy coverage stats'));
|
|
71
|
+
console.log(chalk.gray(' sessions List proxy sessions'));
|
|
72
|
+
console.log(chalk.gray(' query <pattern> Query proxy logs'));
|
|
73
|
+
console.log(chalk.gray(' blob <hash> Get blob by hash'));
|
|
74
|
+
console.log(chalk.gray(' purge Purge proxy cache'));
|
|
40
75
|
console.log();
|
|
41
76
|
}
|
|
42
77
|
|
|
@@ -152,4 +187,120 @@ function clearCapture() {
|
|
|
152
187
|
console.log(chalk.gray('\n 🗑️ Captured requests cleared\n'));
|
|
153
188
|
}
|
|
154
189
|
|
|
190
|
+
function cmdRun() {
|
|
191
|
+
console.log(chalk.green('\n ▶️ Proxy run would start proxy server\n'));
|
|
192
|
+
console.log(chalk.gray(' (Stub — implement actual proxy server startup here)\n'));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function cmdCoverage() {
|
|
196
|
+
const state = getState();
|
|
197
|
+
|
|
198
|
+
console.log(chalk.cyan('\n 📊 Proxy Coverage Stats\n'));
|
|
199
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
200
|
+
|
|
201
|
+
const coverage = state.coverage || {};
|
|
202
|
+
const keys = Object.keys(coverage);
|
|
203
|
+
|
|
204
|
+
if (keys.length === 0) {
|
|
205
|
+
console.log(chalk.gray(' No coverage data recorded yet.\n'));
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
for (const key of keys) {
|
|
210
|
+
const c = coverage[key];
|
|
211
|
+
console.log(chalk.white(` ${key}`));
|
|
212
|
+
console.log(chalk.gray(` Count: ${c.count || 0}`));
|
|
213
|
+
if (c.lastSeen) console.log(chalk.gray(` Last seen: ${c.lastSeen}`));
|
|
214
|
+
if (c.avgResponseTime) console.log(chalk.gray(` Avg response time: ${c.avgResponseTime}ms`));
|
|
215
|
+
console.log();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function cmdSessions() {
|
|
220
|
+
const state = getState();
|
|
221
|
+
|
|
222
|
+
console.log(chalk.cyan('\n 🔌 Proxy Sessions\n'));
|
|
223
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
224
|
+
|
|
225
|
+
const sessions = state.sessions || [];
|
|
226
|
+
|
|
227
|
+
if (sessions.length === 0) {
|
|
228
|
+
console.log(chalk.gray(' No sessions recorded.\n'));
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
for (const s of sessions) {
|
|
233
|
+
console.log(chalk.white(` [${s.id}]`), chalk.gray(`${s.host || 'unknown'} — ${s.started || '?'}`));
|
|
234
|
+
}
|
|
235
|
+
console.log();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function cmdQuery(pattern) {
|
|
239
|
+
const state = getState();
|
|
240
|
+
|
|
241
|
+
if (!pattern) {
|
|
242
|
+
console.log(chalk.red('\n ❌ Query pattern is required.\n'));
|
|
243
|
+
console.log(chalk.gray(' Usage: natureco proxy query <pattern>\n'));
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
console.log(chalk.cyan(`\n 🔎 Proxy Logs matching: ${pattern}\n`));
|
|
248
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
249
|
+
|
|
250
|
+
const logs = state.queryLogs || [];
|
|
251
|
+
const matching = logs.filter(l =>
|
|
252
|
+
(l.url && l.url.includes(pattern)) ||
|
|
253
|
+
(l.method && l.method.includes(pattern)) ||
|
|
254
|
+
(l.body && l.body.includes(pattern))
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
if (matching.length === 0) {
|
|
258
|
+
console.log(chalk.gray(' No matching logs found.\n'));
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
for (const log of matching.slice(-20)) {
|
|
263
|
+
console.log(` ${chalk.gray(`[${log.id}]`)} ${chalk.cyan(log.method)} ${chalk.white(log.url)}`);
|
|
264
|
+
}
|
|
265
|
+
console.log(chalk.gray(` Showing ${Math.min(matching.length, 20)} of ${matching.length} result(s)\n`));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function cmdBlob(hash) {
|
|
269
|
+
const state = getState();
|
|
270
|
+
|
|
271
|
+
if (!hash) {
|
|
272
|
+
console.log(chalk.red('\n ❌ Blob hash is required.\n'));
|
|
273
|
+
console.log(chalk.gray(' Usage: natureco proxy blob <hash>\n'));
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const blobCache = state.blobCache || {};
|
|
278
|
+
const blob = blobCache[hash];
|
|
279
|
+
|
|
280
|
+
if (!blob) {
|
|
281
|
+
console.log(chalk.yellow(`\n ⚠️ Blob not found: ${hash}\n`));
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
console.log(chalk.cyan('\n 💾 Blob\n'));
|
|
286
|
+
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
287
|
+
console.log(chalk.white(` Hash: ${hash}`));
|
|
288
|
+
console.log(chalk.white(` Size: ${blob.size || 'unknown'} bytes`));
|
|
289
|
+
console.log(chalk.white(` Type: ${blob.type || 'unknown'}`));
|
|
290
|
+
console.log(chalk.white(` Cached: ${blob.cached || 'unknown'}`));
|
|
291
|
+
console.log(chalk.gray(' (Stub — actual blob retrieval requires blob storage backend)\n'));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function cmdPurge() {
|
|
295
|
+
const state = getState();
|
|
296
|
+
|
|
297
|
+
state.coverage = {};
|
|
298
|
+
state.sessions = [];
|
|
299
|
+
state.blobCache = {};
|
|
300
|
+
state.queryLogs = [];
|
|
301
|
+
saveState(state);
|
|
302
|
+
|
|
303
|
+
console.log(chalk.green('\n 🧹 Proxy cache purged\n'));
|
|
304
|
+
}
|
|
305
|
+
|
|
155
306
|
module.exports = proxy;
|
package/src/commands/qr.js
CHANGED
|
@@ -1,28 +1,70 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const crypto = require('crypto');
|
|
3
|
+
const qrcode = require('qrcode-terminal');
|
|
3
4
|
|
|
4
5
|
function qr(args) {
|
|
5
|
-
const
|
|
6
|
+
const [action, ...params] = args || [];
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
if (!action || action === 'show') return showQR(params.join(' '));
|
|
9
|
+
if (action === 'generate') return generateQR(params.join(' '));
|
|
10
|
+
if (action === 'verify') return verifyCode(params[0]);
|
|
11
|
+
|
|
12
|
+
console.log(chalk.cyan('\n 📱 QR Code\n'));
|
|
8
13
|
console.log(chalk.gray(' ' + '─'.repeat(48)));
|
|
9
14
|
|
|
10
15
|
const code = crypto.randomBytes(4).toString('hex').toUpperCase();
|
|
16
|
+
const data = JSON.stringify({ id: crypto.randomBytes(8).toString('hex'), code, timestamp: Date.now() });
|
|
11
17
|
const expiresAt = new Date(Date.now() + 15 * 60 * 1000);
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
qrcode.generate(data, { small: true }, qrCode => {
|
|
20
|
+
console.log(qrCode);
|
|
21
|
+
console.log(` ${chalk.white('Pairing Code:')} ${chalk.bold.yellow(code)}`);
|
|
22
|
+
console.log(` ${chalk.white('Expires:')} ${chalk.gray(expiresAt.toLocaleString())}`);
|
|
23
|
+
console.log();
|
|
24
|
+
console.log(chalk.gray(' To pair a device, run on the device:'));
|
|
25
|
+
console.log(chalk.cyan(' natureco device-pair verify ') + chalk.yellow(code));
|
|
26
|
+
console.log();
|
|
27
|
+
console.log(chalk.gray(' Or scan the QR code with the NatureCo mobile app.'));
|
|
28
|
+
console.log();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function showQR(data) {
|
|
33
|
+
const content = data || JSON.stringify({
|
|
34
|
+
id: crypto.randomBytes(8).toString('hex'),
|
|
35
|
+
timestamp: Date.now(),
|
|
36
|
+
type: 'pairing',
|
|
37
|
+
version: 1,
|
|
38
|
+
});
|
|
39
|
+
console.log(chalk.cyan('\n 📱 QR Code\n'));
|
|
40
|
+
qrcode.generate(content, { small: true }, qrCode => {
|
|
41
|
+
console.log(qrCode);
|
|
42
|
+
if (data) {
|
|
43
|
+
console.log(` ${chalk.gray('Data:')} ${chalk.white(data.substring(0, 80))}`);
|
|
44
|
+
}
|
|
45
|
+
console.log();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function generateQR(text) {
|
|
50
|
+
if (!text) {
|
|
51
|
+
console.log(chalk.red('\n ❌ QR için veri gerekli\n'));
|
|
52
|
+
console.log(chalk.gray(' Örnek: natureco qr generate "https://natureco.me/pair?code=ABC"\n'));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
console.log(chalk.cyan('\n 📱 QR: ') + chalk.white(text) + '\n');
|
|
56
|
+
qrcode.generate(text, { small: false }, qrCode => {
|
|
57
|
+
console.log(qrCode);
|
|
58
|
+
console.log();
|
|
59
|
+
});
|
|
21
60
|
}
|
|
22
61
|
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
62
|
+
function verifyCode(code) {
|
|
63
|
+
if (!code) {
|
|
64
|
+
console.log(chalk.red('\n ❌ Kod gerekli\n'));
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
console.log(chalk.cyan('\n ✅ Pairing code verified: ') + chalk.bold.yellow(code) + '\n');
|
|
26
68
|
}
|
|
27
69
|
|
|
28
70
|
module.exports = qr;
|
package/src/commands/reset.js
CHANGED
|
@@ -1,94 +1,101 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const readline = require('readline');
|
|
6
|
+
|
|
7
|
+
const BASE_DIR = path.join(os.homedir(), '.natureco');
|
|
8
|
+
const CONFIG_FILE = path.join(BASE_DIR, 'config.json');
|
|
9
|
+
const WORKSPACE_DIR = path.join(BASE_DIR, 'workspace');
|
|
10
|
+
|
|
11
|
+
function rlQuestion(query) {
|
|
12
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
13
|
+
return new Promise(resolve => {
|
|
14
|
+
rl.question(query, answer => { rl.close(); resolve(answer.trim().toLowerCase()); });
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function reset(params) {
|
|
19
|
+
try {
|
|
20
|
+
const [action] = params || [];
|
|
21
|
+
|
|
22
|
+
if (!action || action === 'list') return cmdList();
|
|
23
|
+
if (action === 'config') return await cmdConfig();
|
|
24
|
+
if (action === 'workspace') return await cmdWorkspace();
|
|
25
|
+
if (action === 'all') return await cmdAll();
|
|
26
|
+
|
|
27
|
+
console.log(chalk.red(`\n Unknown reset action: ${action}\n`));
|
|
28
|
+
console.log(chalk.gray(' Usage: natureco reset [config|workspace|all|list]\n'));
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.log(chalk.red(`\n Reset error: ${err.message}\n`));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function cmdList() {
|
|
35
|
+
console.log(chalk.cyan('\n Reset — What Would Be Removed\n'));
|
|
36
|
+
|
|
37
|
+
if (fs.existsSync(CONFIG_FILE)) console.log(chalk.gray(' • ') + chalk.white('Config file') + chalk.gray(' (' + CONFIG_FILE + ')'));
|
|
38
|
+
else console.log(chalk.gray(' • Config file — ') + chalk.gray('not found'));
|
|
39
|
+
|
|
40
|
+
if (fs.existsSync(WORKSPACE_DIR)) console.log(chalk.gray(' • ') + chalk.white('Workspace directory') + chalk.gray(' (' + WORKSPACE_DIR + ')'));
|
|
41
|
+
else console.log(chalk.gray(' • Workspace directory — ') + chalk.gray('not found'));
|
|
42
|
+
|
|
43
|
+
if (fs.existsSync(BASE_DIR)) {
|
|
44
|
+
const entries = fs.readdirSync(BASE_DIR);
|
|
45
|
+
console.log(chalk.gray(' • ') + chalk.white('~/.natureco/') + chalk.gray(' (' + entries.length + ' entries)'));
|
|
46
|
+
} else {
|
|
47
|
+
console.log(chalk.gray(' • ~/.natureco/ — ') + chalk.gray('not found'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log('');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function cmdConfig() {
|
|
54
|
+
if (!fs.existsSync(CONFIG_FILE)) {
|
|
55
|
+
console.log(chalk.yellow('\n No config file to remove.\n'));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const answer = await rlQuestion(chalk.yellow(' Remove config file? [y/N]: '));
|
|
60
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
61
|
+
console.log(chalk.gray('\n Cancelled.\n'));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fs.unlinkSync(CONFIG_FILE);
|
|
66
|
+
console.log(chalk.green('\n Config file removed.\n'));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function cmdWorkspace() {
|
|
70
|
+
if (!fs.existsSync(WORKSPACE_DIR)) {
|
|
71
|
+
console.log(chalk.yellow('\n No workspace directory to remove.\n'));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const answer = await rlQuestion(chalk.yellow(' Remove workspace directory? [y/N]: '));
|
|
76
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
77
|
+
console.log(chalk.gray('\n Cancelled.\n'));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
fs.rmSync(WORKSPACE_DIR, { recursive: true, force: true });
|
|
82
|
+
console.log(chalk.green('\n Workspace directory removed.\n'));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function cmdAll() {
|
|
86
|
+
if (!fs.existsSync(BASE_DIR)) {
|
|
87
|
+
console.log(chalk.yellow('\n Nothing to remove — ~/.natureco does not exist.\n'));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const answer = await rlQuestion(chalk.red(' Remove ALL NatureCo state (~/.natureco)? [y/N]: '));
|
|
92
|
+
if (answer !== 'y' && answer !== 'yes') {
|
|
93
|
+
console.log(chalk.gray('\n Cancelled.\n'));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fs.rmSync(BASE_DIR, { recursive: true, force: true });
|
|
98
|
+
console.log(chalk.green('\n All NatureCo state removed.\n'));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = reset;
|