vslides 1.0.6 → 1.0.7

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/cli.js +56 -46
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3471,10 +3471,10 @@ var ExitCode = {
3471
3471
 
3472
3472
  // src/commands/init.ts
3473
3473
  var STARTER_SLIDES = `---
3474
+ theme: ./
3474
3475
  title: My Presentation
3475
- ---
3476
-
3477
- ---
3476
+ footerLogo: wordmark
3477
+ footerTitle: true
3478
3478
  layout: 1-title
3479
3479
  variant: title
3480
3480
  ---
@@ -3510,49 +3510,22 @@ async function init() {
3510
3510
  return;
3511
3511
  }
3512
3512
  const cachedAuth = getCachedAuth();
3513
- if (cachedAuth && isAuthValid(cachedAuth)) {
3514
- const result2 = await createSession({ cliAuthToken: cachedAuth.token });
3515
- if (result2.ok && result2.data.authenticated && result2.data.token) {
3516
- const { slug: slug2, pollSecret: pollSecret2, previewUrl: previewUrl2, token } = result2.data;
3517
- writeConfig({
3518
- slug: slug2,
3519
- pollSecret: pollSecret2,
3520
- previewUrl: previewUrl2,
3521
- token
3522
- });
3523
- try {
3524
- const guideResult = await getGuide();
3525
- if (guideResult.ok && typeof guideResult.data === "string") {
3526
- writeGuide(guideResult.data);
3527
- }
3528
- } catch {
3529
- }
3530
- if (!slidesExist()) {
3531
- writeSlides(STARTER_SLIDES);
3532
- info("Created slides.md with starter template");
3533
- }
3534
- success(`Authenticated as ${cachedAuth.email}`);
3535
- url("PREVIEW_URL", previewUrl2);
3536
- newline();
3537
- info("Sandbox is starting in the background.");
3538
- instructions([
3539
- "Run: vslides check --wait (wait for sandbox to be ready)",
3540
- "Run: vslides push (upload your slides)"
3541
- ]);
3542
- return;
3543
- }
3544
- clearCLIAuth();
3513
+ if (!cachedAuth || !isAuthValid(cachedAuth)) {
3514
+ error("Not authenticated. Run `vslides login` to log in.");
3515
+ process.exit(ExitCode.AuthRequired);
3545
3516
  }
3546
- const result = await createSession();
3547
- if (!result.ok) {
3548
- error(`Failed to create session: ${JSON.stringify(result.data)}`);
3549
- process.exit(ExitCode.NetworkError);
3517
+ const result = await createSession({ cliAuthToken: cachedAuth.token });
3518
+ if (!result.ok || !result.data.authenticated || !result.data.token) {
3519
+ clearCLIAuth();
3520
+ error("Not authenticated. Run `vslides login` to log in.");
3521
+ process.exit(ExitCode.AuthRequired);
3550
3522
  }
3551
- const { slug, pollSecret, verifyUrl, previewUrl } = result.data;
3523
+ const { slug, pollSecret, previewUrl, token } = result.data;
3552
3524
  writeConfig({
3553
3525
  slug,
3554
3526
  pollSecret,
3555
- previewUrl
3527
+ previewUrl,
3528
+ token
3556
3529
  });
3557
3530
  try {
3558
3531
  const guideResult = await getGuide();
@@ -3565,12 +3538,13 @@ async function init() {
3565
3538
  writeSlides(STARTER_SLIDES);
3566
3539
  info("Created slides.md with starter template");
3567
3540
  }
3568
- const authUrlWithCli = `${verifyUrl}?cliAuth=true`;
3569
- url("AUTH_URL", authUrlWithCli);
3541
+ url("SESSION", slug);
3542
+ info("CONFIG: .vslides.json created");
3543
+ url("USER", cachedAuth.email);
3570
3544
  url("PREVIEW_URL", previewUrl);
3571
3545
  instructions([
3572
- "Run in background: vslides check --wait &",
3573
- "Open the AUTH_URL to authenticate"
3546
+ "Run: vslides check --wait (wait for sandbox to be ready)",
3547
+ "Run: vslides push (upload your slides)"
3574
3548
  ]);
3575
3549
  }
3576
3550
 
@@ -3590,7 +3564,7 @@ async function check(options = {}) {
3590
3564
  error(`Failed to check session: ${JSON.stringify(result.data)}`);
3591
3565
  process.exit(ExitCode.NetworkError);
3592
3566
  }
3593
- const { status: sessionStatus, token, cliAuthToken } = result.data;
3567
+ const { status: sessionStatus, token, cliAuthToken, expiresAt } = result.data;
3594
3568
  if (sessionStatus === "running") {
3595
3569
  if (token) {
3596
3570
  updateConfig({ token });
@@ -3606,6 +3580,31 @@ async function check(options = {}) {
3606
3580
  }
3607
3581
  }
3608
3582
  status("running");
3583
+ url("SESSION", slug);
3584
+ const cachedAuth = getCachedAuth();
3585
+ if (cachedAuth?.email) {
3586
+ url("USER", cachedAuth.email);
3587
+ }
3588
+ const sessionToken = token || cfg.token;
3589
+ if (sessionToken) {
3590
+ try {
3591
+ const slidesResult = await getSlides(slug, sessionToken);
3592
+ if (slidesResult.ok && slidesResult.data.version !== void 0) {
3593
+ url("VERSION", String(slidesResult.data.version));
3594
+ }
3595
+ } catch {
3596
+ }
3597
+ }
3598
+ const previewUrl = cfg.previewUrl || `${getBaseUrl()}/slides/${slug}`;
3599
+ url("PREVIEW_URL", previewUrl);
3600
+ if (expiresAt) {
3601
+ const expiresDate = new Date(expiresAt);
3602
+ const now = Date.now();
3603
+ const remainingMs = expiresAt - now;
3604
+ const remainingMins = Math.max(0, Math.floor(remainingMs / 6e4));
3605
+ const dateStr = expiresDate.toISOString().slice(0, 16).replace("T", " ");
3606
+ url("EXPIRES", `${dateStr} (${remainingMins} min remaining)`);
3607
+ }
3609
3608
  process.exit(ExitCode.Success);
3610
3609
  }
3611
3610
  if (!options.wait) {
@@ -3890,10 +3889,16 @@ async function push(options = {}) {
3890
3889
  process.exit(ExitCode.NetworkError);
3891
3890
  }
3892
3891
  const pushResult = result.data;
3892
+ const cfg_updated = readConfig();
3893
3893
  if (pushResult.version !== void 0) {
3894
3894
  updateConfig({ version: pushResult.version });
3895
3895
  }
3896
3896
  success(`Version ${pushResult.version} saved`);
3897
+ if (pushResult.previewUrl) {
3898
+ url("PREVIEW_URL", pushResult.previewUrl);
3899
+ } else if (cfg_updated?.previewUrl) {
3900
+ url("PREVIEW_URL", cfg_updated.previewUrl);
3901
+ }
3897
3902
  }
3898
3903
 
3899
3904
  // src/commands/sync.ts
@@ -3981,6 +3986,11 @@ async function sync() {
3981
3986
  updateConfig({ version: pushResult.version });
3982
3987
  }
3983
3988
  success(`Version ${pushResult.version} saved`);
3989
+ if (pushResult.previewUrl) {
3990
+ url("PREVIEW_URL", pushResult.previewUrl);
3991
+ } else if (cfg.previewUrl) {
3992
+ url("PREVIEW_URL", cfg.previewUrl);
3993
+ }
3984
3994
  }
3985
3995
 
3986
3996
  // src/commands/upload.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vslides",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "CLI for Vercel Slides API",
5
5
  "license": "MIT",
6
6
  "author": "Vercel",