plexmint 0.2.2 → 0.2.3

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 +43 -24
  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,41 +241,55 @@ 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();
292
+ verifySpinner.succeed("Email verified!");
272
293
  const { apiKey, user } = result.data;
273
294
  setAuth(apiKey, user.email, user.name);
274
295
  console.log("");
@@ -285,15 +306,13 @@ async function setupCommand() {
285
306
  );
286
307
  console.log("");
287
308
  } catch (error) {
288
- spinner.stop();
309
+ verifySpinner.fail("Verification failed.");
289
310
  if (error instanceof PlexMintApiError) {
290
311
  console.error(chalk2.red(`
291
- Error: ${error.message}
292
- `));
312
+ Error: ${error.message}`));
313
+ console.error(chalk2.gray(" You can try again: plexmint login\n"));
293
314
  } else {
294
- console.error(
295
- chalk2.red("\n Connection error. Is plexmint.com reachable?\n")
296
- );
315
+ console.error(chalk2.red("\n Connection error. Is plexmint.com reachable?\n"));
297
316
  }
298
317
  process.exit(1);
299
318
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plexmint",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "PlexMint CLI — Browse, buy, and manage AI prompts from your terminal",
5
5
  "type": "module",
6
6
  "bin": {