@clawcard/cli 0.1.0 → 0.1.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/setup.mjs +23 -37
- package/package.json +1 -1
package/bin/setup.mjs
CHANGED
|
@@ -6,10 +6,9 @@ import { homedir } from "os";
|
|
|
6
6
|
|
|
7
7
|
const OPENCLAW_DIR = join(homedir(), ".openclaw");
|
|
8
8
|
const SKILLS_DIR = join(OPENCLAW_DIR, "skills", "clawcard");
|
|
9
|
-
const CONFIG_PATH = join(OPENCLAW_DIR, "openclaw.json");
|
|
10
9
|
const SKILL_PATH = join(SKILLS_DIR, "SKILL.md");
|
|
11
10
|
|
|
12
|
-
const DEFAULT_BASE_URL = "https://clawcard.sh";
|
|
11
|
+
const DEFAULT_BASE_URL = "https://www.clawcard.sh";
|
|
13
12
|
|
|
14
13
|
const SKILL_MD = `---
|
|
15
14
|
name: clawcard
|
|
@@ -23,7 +22,7 @@ You have access to ClawCard — a platform that gives you a real email address,
|
|
|
23
22
|
|
|
24
23
|
## Getting Started
|
|
25
24
|
|
|
26
|
-
Base URL: $CLAWCARD_BASE_URL (default: https://clawcard.sh)
|
|
25
|
+
Base URL: $CLAWCARD_BASE_URL (default: https://www.clawcard.sh)
|
|
27
26
|
Auth header: Authorization: Bearer $CLAWCARD_API_KEY
|
|
28
27
|
|
|
29
28
|
**Step 1: Discover your identity.** Call GET /api/me first — it returns your keyId, email, phone, and budget. Use the keyId for all other endpoints.
|
|
@@ -133,18 +132,6 @@ function error(msg) {
|
|
|
133
132
|
console.error(` \x1b[31m✗\x1b[0m ${msg}`);
|
|
134
133
|
}
|
|
135
134
|
|
|
136
|
-
function readJson(path) {
|
|
137
|
-
try {
|
|
138
|
-
return JSON.parse(readFileSync(path, "utf-8"));
|
|
139
|
-
} catch {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function writeJson(path, data) {
|
|
145
|
-
writeFileSync(path, JSON.stringify(data, null, 2) + "\n");
|
|
146
|
-
}
|
|
147
|
-
|
|
148
135
|
// ── Main ─────────────────────────────────────────────────────────
|
|
149
136
|
|
|
150
137
|
const args = process.argv.slice(2);
|
|
@@ -182,33 +169,32 @@ mkdirSync(SKILLS_DIR, { recursive: true });
|
|
|
182
169
|
writeFileSync(SKILL_PATH, SKILL_MD);
|
|
183
170
|
success(`Skill written to ${SKILL_PATH}`);
|
|
184
171
|
|
|
185
|
-
// 2.
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
172
|
+
// 2. Write env vars to ~/.openclaw/.env
|
|
173
|
+
const ENV_PATH = join(OPENCLAW_DIR, ".env");
|
|
174
|
+
let envContent = "";
|
|
175
|
+
try {
|
|
176
|
+
envContent = readFileSync(ENV_PATH, "utf-8");
|
|
177
|
+
} catch {
|
|
178
|
+
// .env doesn't exist yet, that's fine
|
|
190
179
|
}
|
|
191
180
|
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
|
|
181
|
+
// Update or append each var
|
|
182
|
+
const envVars = {
|
|
183
|
+
CLAWCARD_API_KEY: apiKey,
|
|
184
|
+
CLAWCARD_BASE_URL: baseUrl,
|
|
185
|
+
};
|
|
195
186
|
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
187
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
188
|
+
const regex = new RegExp(`^${key}=.*$`, "m");
|
|
189
|
+
if (regex.test(envContent)) {
|
|
190
|
+
envContent = envContent.replace(regex, `${key}=${value}`);
|
|
191
|
+
} else {
|
|
192
|
+
envContent = envContent.trimEnd() + `\n${key}=${value}\n`;
|
|
193
|
+
}
|
|
199
194
|
}
|
|
200
195
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
env: {
|
|
204
|
-
...(existing?.env || {}),
|
|
205
|
-
CLAWCARD_API_KEY: apiKey,
|
|
206
|
-
CLAWCARD_BASE_URL: baseUrl,
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
writeJson(CONFIG_PATH, config);
|
|
211
|
-
success(`Config updated in ${CONFIG_PATH}`);
|
|
196
|
+
writeFileSync(ENV_PATH, envContent);
|
|
197
|
+
success(`Credentials written to ${ENV_PATH}`);
|
|
212
198
|
|
|
213
199
|
// 3. Done
|
|
214
200
|
console.log();
|