plexmint 0.2.2 → 0.2.4

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.
Files changed (2) hide show
  1. package/dist/index.js +52 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -190,6 +190,13 @@ var PlexMintApiError = class extends Error {
190
190
  };
191
191
 
192
192
  // src/commands/setup.ts
193
+ function suggestTicker(name) {
194
+ const parts = name.trim().toUpperCase().split(/\s+/);
195
+ if (parts.length >= 2) {
196
+ return (parts[0].slice(0, 2) + parts[1].slice(0, 2)).slice(0, 4);
197
+ }
198
+ return parts[0].slice(0, 4);
199
+ }
193
200
  async function setupCommand() {
194
201
  console.log("");
195
202
  console.log(mintBold(" PlexMint Setup"));
@@ -234,49 +241,67 @@ async function setupCommand() {
234
241
  }
235
242
  console.log(chalk2.red(" Passwords do not match. Try again.\n"));
236
243
  }
244
+ const suggested = suggestTicker(name);
237
245
  const { tickerPrefix } = await inquirer.prompt([
238
246
  {
239
247
  type: "input",
240
248
  name: "tickerPrefix",
241
- message: "Ticker prefix (2-5 uppercase letters, e.g. NUE):",
249
+ message: `Ticker prefix (2-5 uppercase letters, e.g. ${suggested}):`,
250
+ default: suggested,
242
251
  transformer: (v) => v.toUpperCase(),
243
252
  validate: (v) => /^[A-Z]{2,5}$/i.test(v.trim()) || "Enter 2-5 letters (e.g. NUE, ACME)."
244
253
  }
245
254
  ]);
246
- const answers = { name, email, password, tickerPrefix };
247
255
  const spinner = ora("Creating your account...").start();
248
256
  try {
249
257
  const client = new PlexMintClient();
250
258
  await client.register({
251
- name: answers.name.trim(),
252
- email: answers.email.trim().toLowerCase(),
253
- password: answers.password,
254
- tickerPrefix: answers.tickerPrefix.trim().toUpperCase()
259
+ name: name.trim(),
260
+ email: email.trim().toLowerCase(),
261
+ password,
262
+ tickerPrefix: tickerPrefix.trim().toUpperCase()
255
263
  });
256
264
  spinner.succeed("Account created! Check your email for a verification code.");
257
- console.log("");
258
- const { code } = await inquirer.prompt([
259
- {
260
- type: "input",
261
- name: "code",
262
- message: "Enter 6-digit verification code:",
263
- validate: (v) => /^\d{6}$/.test(v.trim()) || "Enter the 6-digit code from your email."
264
- }
265
- ]);
266
- const verifySpinner = ora("Verifying...").start();
265
+ } catch (error) {
266
+ spinner.fail("Registration failed.");
267
+ if (error instanceof PlexMintApiError) {
268
+ console.error(chalk2.red(`
269
+ Error: ${error.message}
270
+ `));
271
+ } else {
272
+ console.error(chalk2.red("\n Connection error. Is plexmint.com reachable?\n"));
273
+ }
274
+ process.exit(1);
275
+ }
276
+ console.log("");
277
+ const { code } = await inquirer.prompt([
278
+ {
279
+ type: "input",
280
+ name: "code",
281
+ message: "Enter 6-digit verification code:",
282
+ validate: (v) => /^\d{6}$/.test(v.trim()) || "Enter the 6-digit code from your email."
283
+ }
284
+ ]);
285
+ const verifySpinner = ora("Verifying...").start();
286
+ try {
287
+ const client = new PlexMintClient();
267
288
  const result = await client.verify(
268
- answers.email.trim().toLowerCase(),
289
+ email.trim().toLowerCase(),
269
290
  code.trim()
270
291
  );
271
- verifySpinner.stop();
272
- const { apiKey, user } = result.data;
273
- setAuth(apiKey, user.email, user.name);
292
+ verifySpinner.succeed("Email verified!");
293
+ const apiKey = result.data.apiKey;
294
+ const user = result.data.user;
295
+ const userName = user?.name ?? name.trim();
296
+ const userEmail = user?.email ?? email.trim().toLowerCase();
297
+ const userTicker = user?.tickerPrefix ?? tickerPrefix.trim().toUpperCase();
298
+ setAuth(apiKey, userEmail, userName);
274
299
  console.log("");
275
300
  console.log(mint(" \u2713 ") + chalk2.bold("Account verified!"));
276
301
  console.log("");
277
- console.log(chalk2.gray(" Name: ") + chalk2.white(user.name));
278
- console.log(chalk2.gray(" Email: ") + chalk2.white(user.email));
279
- console.log(chalk2.gray(" Ticker Prefix: ") + chalk2.white(user.tickerPrefix));
302
+ console.log(chalk2.gray(" Name: ") + chalk2.white(userName));
303
+ console.log(chalk2.gray(" Email: ") + chalk2.white(userEmail));
304
+ console.log(chalk2.gray(" Ticker Prefix: ") + chalk2.white(userTicker));
280
305
  console.log(chalk2.gray(" API Key: ") + chalk2.white(apiKey));
281
306
  console.log(chalk2.gray(" Config: ") + chalk2.white(getConfigPath()));
282
307
  console.log("");
@@ -285,15 +310,13 @@ async function setupCommand() {
285
310
  );
286
311
  console.log("");
287
312
  } catch (error) {
288
- spinner.stop();
313
+ verifySpinner.fail("Verification failed.");
289
314
  if (error instanceof PlexMintApiError) {
290
315
  console.error(chalk2.red(`
291
- Error: ${error.message}
292
- `));
316
+ Error: ${error.message}`));
317
+ console.error(chalk2.gray(" You can try again: plexmint login\n"));
293
318
  } else {
294
- console.error(
295
- chalk2.red("\n Connection error. Is plexmint.com reachable?\n")
296
- );
319
+ console.error(chalk2.red("\n Connection error. Is plexmint.com reachable?\n"));
297
320
  }
298
321
  process.exit(1);
299
322
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plexmint",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "PlexMint CLI — Browse, buy, and manage AI prompts from your terminal",
5
5
  "type": "module",
6
6
  "bin": {