vslides 1.0.8 → 1.0.9

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 +134 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3333,6 +3333,23 @@ async function deploy(slug, token) {
3333
3333
  body: JSON.stringify({})
3334
3334
  });
3335
3335
  }
3336
+ async function getPresentations(cliAuthToken) {
3337
+ return request("/api/presentations", {
3338
+ headers: {
3339
+ "X-CLI-Auth-Token": cliAuthToken
3340
+ }
3341
+ });
3342
+ }
3343
+ async function reconnectSession(slug, cliAuthToken) {
3344
+ return request(`/api/session/${slug}/reconnect`, {
3345
+ method: "POST",
3346
+ headers: {
3347
+ "X-CLI-Auth-Token": cliAuthToken,
3348
+ "Content-Type": "application/json"
3349
+ },
3350
+ body: JSON.stringify({})
3351
+ });
3352
+ }
3336
3353
 
3337
3354
  // src/lib/config.ts
3338
3355
  var import_node_fs2 = require("node:fs");
@@ -3354,6 +3371,9 @@ function getSlidesPath() {
3354
3371
  function getUpstreamPath() {
3355
3372
  return (0, import_node_path2.join)(process.cwd(), UPSTREAM_FILE);
3356
3373
  }
3374
+ function configExists() {
3375
+ return (0, import_node_fs2.existsSync)(getConfigPath());
3376
+ }
3357
3377
  function readConfig() {
3358
3378
  const path = getConfigPath();
3359
3379
  if (!(0, import_node_fs2.existsSync)(path)) {
@@ -3680,6 +3700,118 @@ async function share() {
3680
3700
  info("4. Run: vslides get");
3681
3701
  }
3682
3702
 
3703
+ // src/commands/list.ts
3704
+ async function list() {
3705
+ const auth = getCachedAuth();
3706
+ if (!auth) {
3707
+ error("Not logged in");
3708
+ instructions(["Run `vslides login` to authenticate"]);
3709
+ process.exit(ExitCode.AuthRequired);
3710
+ }
3711
+ if (!isAuthValid(auth)) {
3712
+ error("Login expired");
3713
+ instructions(["Run `vslides login` to re-authenticate"]);
3714
+ process.exit(ExitCode.AuthRequired);
3715
+ }
3716
+ const result = await getPresentations(auth.token);
3717
+ if (!result.ok) {
3718
+ if (result.status === 401) {
3719
+ error("Authentication failed");
3720
+ instructions(["Run `vslides login` to re-authenticate"]);
3721
+ process.exit(ExitCode.AuthRequired);
3722
+ }
3723
+ error(`Failed to fetch presentations: ${JSON.stringify(result.data)}`);
3724
+ process.exit(ExitCode.NetworkError);
3725
+ }
3726
+ const { presentations } = result.data;
3727
+ if (presentations.length === 0) {
3728
+ info("No presentations found");
3729
+ instructions(["Run `vslides init` to create a new presentation"]);
3730
+ return;
3731
+ }
3732
+ const formatDate = (timestamp) => {
3733
+ const date = new Date(timestamp);
3734
+ return date.toLocaleDateString("en-US", {
3735
+ month: "short",
3736
+ day: "numeric",
3737
+ year: "numeric"
3738
+ });
3739
+ };
3740
+ const baseUrl = getBaseUrl();
3741
+ const headers = ["TITLE", "SLUG", "CREATED", "PREVIEW"];
3742
+ const rows = presentations.map((p) => [
3743
+ p.title.length > 30 ? p.title.substring(0, 27) + "..." : p.title,
3744
+ p.slug,
3745
+ formatDate(p.createdAt),
3746
+ `${baseUrl}${p.url}`
3747
+ ]);
3748
+ table(headers, rows);
3749
+ }
3750
+
3751
+ // src/commands/clone.ts
3752
+ async function clone(slug) {
3753
+ if (configExists()) {
3754
+ error("This directory already has a .vslides.json file");
3755
+ instructions([
3756
+ "Remove .vslides.json to clone a different presentation",
3757
+ "Or use a different directory"
3758
+ ]);
3759
+ process.exit(ExitCode.ValidationError);
3760
+ }
3761
+ const auth = getCachedAuth();
3762
+ if (!auth) {
3763
+ error("Not logged in");
3764
+ instructions(["Run `vslides login` to authenticate"]);
3765
+ process.exit(ExitCode.AuthRequired);
3766
+ }
3767
+ if (!isAuthValid(auth)) {
3768
+ error("Login expired");
3769
+ instructions(["Run `vslides login` to re-authenticate"]);
3770
+ process.exit(ExitCode.AuthRequired);
3771
+ }
3772
+ const result = await reconnectSession(slug, auth.token);
3773
+ if (!result.ok) {
3774
+ if (result.status === 401) {
3775
+ error("Authentication failed");
3776
+ instructions(["Run `vslides login` to re-authenticate"]);
3777
+ process.exit(ExitCode.AuthRequired);
3778
+ }
3779
+ if (result.status === 403) {
3780
+ error("You do not own this presentation");
3781
+ instructions(["You can only clone your own presentations"]);
3782
+ process.exit(ExitCode.AuthRequired);
3783
+ }
3784
+ if (result.status === 404) {
3785
+ error(`Presentation not found: ${slug}`);
3786
+ instructions(["Run `vslides list` to see your presentations"]);
3787
+ process.exit(ExitCode.ValidationError);
3788
+ }
3789
+ error(`Failed to reconnect: ${JSON.stringify(result.data)}`);
3790
+ process.exit(ExitCode.NetworkError);
3791
+ }
3792
+ const { pollSecret, token, previewUrl } = result.data;
3793
+ const baseUrl = getBaseUrl();
3794
+ writeConfig({
3795
+ slug,
3796
+ pollSecret,
3797
+ token,
3798
+ previewUrl: `${baseUrl}${previewUrl}`
3799
+ });
3800
+ const slidesResult = await getSlides(slug, token);
3801
+ if (slidesResult.ok) {
3802
+ const { markdown, version } = slidesResult.data;
3803
+ writeSlides(markdown);
3804
+ updateConfig({ version });
3805
+ success(`Cloned presentation: ${slug}`);
3806
+ info(`Downloaded slides.md (version ${version})`);
3807
+ } else {
3808
+ success(`Cloned presentation: ${slug}`);
3809
+ info("Session is not running - slides.md not downloaded");
3810
+ instructions(["Run `vslides check --wait` to start the session", "Then run `vslides get` to download slides"]);
3811
+ }
3812
+ url("PREVIEW_URL", `${baseUrl}${previewUrl}`);
3813
+ }
3814
+
3683
3815
  // src/commands/preview.ts
3684
3816
  var import_node_child_process = require("node:child_process");
3685
3817
  async function preview(options = {}) {
@@ -4236,6 +4368,8 @@ program.command("init").description("Create a new session").action(wrapCommand(i
4236
4368
  program.command("check").description("Check session status").option("--wait", "Poll until running (60s timeout)").action(wrapCommand((options) => check(options)));
4237
4369
  program.command("join <url>").description("Join a shared session").action(wrapCommand(join3));
4238
4370
  program.command("share").description("Get join URL for collaborators").action(wrapCommand(share));
4371
+ program.command("list").description("List all your presentations").action(wrapCommand(list));
4372
+ program.command("clone <slug>").description("Set up an existing presentation in current directory").action(wrapCommand(clone));
4239
4373
  program.command("preview").description("Print or open the preview URL").option("--open", "Open in browser").action(wrapCommand((options) => preview(options)));
4240
4374
  program.command("guide").description("Print the slide layout guide").option("--refresh", "Force fresh fetch").action(wrapCommand((options) => guide(options)));
4241
4375
  program.command("get").description("Download current slides from server").action(wrapCommand(get));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vslides",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "CLI for Vercel Slides API",
5
5
  "license": "MIT",
6
6
  "author": "Vercel",