clippy-test 1.0.0 → 1.0.2

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/clippy.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // Simple flag handler and launcher for the compiled CLI
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
+ import os from 'os';
5
6
  import { fileURLToPath } from 'url';
6
7
 
7
8
  const __filename = fileURLToPath(import.meta.url);
@@ -25,6 +26,62 @@ Flags:
25
26
  `);
26
27
  };
27
28
 
29
+ // --- Paths and config helpers ---
30
+ const HOME_DIR = os.homedir();
31
+ const CLIPPY_DIR = path.join(HOME_DIR, '.clippy');
32
+ const CONFIG_PATH = path.join(CLIPPY_DIR, 'config');
33
+ const CONFIG_TEMPLATE = `# Clippy Configuration File\n#\n# Place your Clippy API key here.\n# You can get a key from Clippy Web Studio.\n#\nAPI_KEY=\n`;
34
+
35
+ function ensureConfigDir() {
36
+ if (!fs.existsSync(CLIPPY_DIR)) {
37
+ fs.mkdirSync(CLIPPY_DIR, { recursive: true });
38
+ console.log(`✅ Created configuration directory: ${CLIPPY_DIR}`);
39
+ }
40
+ }
41
+
42
+ function handleInit() {
43
+ if (fs.existsSync(CONFIG_PATH)) {
44
+ console.warn(`\n⚠️ Warning: Clippy configuration already exists.\nPath: ${CONFIG_PATH}\nIf you need to re-initialize, please delete the file first.\n`);
45
+ process.exit(0);
46
+ }
47
+ try {
48
+ ensureConfigDir();
49
+ fs.writeFileSync(CONFIG_PATH, CONFIG_TEMPLATE, 'utf8');
50
+ console.log(`\n🎉 Successfully initialized Clippy!\nConfiguration file created at: ${CONFIG_PATH}\n\nPlease edit this file and add your CLIPPY API KEY:\nAPI_KEY=<YOUR_CLIPPY_API_KEY>\n\nThen run: clippy <your command here>\n(e.g., clippy npm run dev)\n`);
51
+ process.exit(0);
52
+ } catch (err) {
53
+ console.error(`\n❌ Error initializing Clippy:`, err);
54
+ process.exit(1);
55
+ }
56
+ }
57
+
58
+ function handleLogin(authKey) {
59
+ if (!authKey || typeof authKey !== 'string' || !authKey.trim()) {
60
+ console.error('\n❌ Usage: clippy login <your-auth-key>');
61
+ process.exit(1);
62
+ }
63
+ try {
64
+ ensureConfigDir();
65
+ let contents = '';
66
+ if (fs.existsSync(CONFIG_PATH)) {
67
+ contents = fs.readFileSync(CONFIG_PATH, 'utf8');
68
+ if (/^API_KEY\s*=\s*.*/m.test(contents)) {
69
+ contents = contents.replace(/^API_KEY\s*=\s*.*/m, `API_KEY=${authKey}`);
70
+ } else {
71
+ contents = `${contents.trim()}\nAPI_KEY=${authKey}\n`;
72
+ }
73
+ } else {
74
+ contents = `API_KEY=${authKey}\n`;
75
+ }
76
+ fs.writeFileSync(CONFIG_PATH, contents, 'utf8');
77
+ console.log('✅ Auth key saved.');
78
+ process.exit(0);
79
+ } catch (err) {
80
+ console.error('❌ Failed to save auth key:', err);
81
+ process.exit(1);
82
+ }
83
+ }
84
+
28
85
  if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
29
86
  printHelp();
30
87
  process.exit(0);
@@ -35,6 +92,15 @@ if (args.includes('--version') || args.includes('-v')) {
35
92
  process.exit(0);
36
93
  }
37
94
 
95
+ // Commands
96
+ const command = args[0];
97
+ if (command === 'init') {
98
+ handleInit();
99
+ }
100
+ if (command === 'login') {
101
+ handleLogin(args[1]);
102
+ }
103
+
38
104
  // Defer to compiled app (index bootstraps the TUI / routing)
39
105
  import('../dist/index.js').catch((err) => {
40
106
  console.error(err);
package/dist/config.js CHANGED
@@ -5,7 +5,7 @@ export const config = {
5
5
  redis_password: process.env.REDIS_PASSWORD || "",
6
6
  redis_host: process.env.REDIS_HOST || "",
7
7
  redis_port: process.env.REDIS_PORT || "25061",
8
- websocket_url: process.env.WEB_SOCKET_URL || "",
8
+ websocket_url: process.env.WEB_SOCKET_URL || "wss://prod.revise.network/clippy/ws",
9
9
  auth_key: process.env.AUTH_KEY || "",
10
10
  api_base_url: process.env.API_BASE_URL || "https://prod.revise.network/clippy/api",
11
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,SAAS;IACvD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;IAChD,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE;IACxC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO;IAC7C,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;IAC/C,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE;IACpC,YAAY,EACV,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,wCAAwC;CACvE,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,SAAS;IACvD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;IAChD,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAE;IACxC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,OAAO;IAC7C,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,qCAAqC;IAClF,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE;IACpC,YAAY,EACV,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,wCAAwC;CACvE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clippy-test",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "clippy": "bin/clippy.js"