Package: datasette-publish-vercel
datasette-publish-vercelDatasette plugin for publishing data usingVercel.InstallationInstall this plugin in the same environment as Datasette.$ datasette install datasette-publish-vercelUsageFirst, install the Vercel CLI tool byfollowing their instructions.Runvercel loginto login to (or create) an account.Now you can usedatasette publish vercelto publish your data:datasette publish vercel my-database.db --project=my-databaseThe--projectargument is required - it specifies the project name that should be used for your deployment. This will be used as part of the deployment's URL.Other options--no-proddeploys to the project without updating the "production" URL alias to point to that new deployment. Without that option all deploys go directly to production.--debugenables the Vercel CLI debug output.--tokenallows you to pass a Now authentication token, rather than needing to first runnow loginto configure the tool. Tokens can be created in the Vercel web dashboard under Account Settings -> Tokens.--publicrunsvercel --publicto publish the application source code at/_srce.g.https://datasette-public.now.sh/_srcand make recent logs visible at/_logse.g.https://datasette-public.now.sh/_logs--generate-dir- by default this tool generates a new Vercel app in a temporary directory, deploys it and then deletes the directory. Use--generate-dir=my-appto output the generated application files to a new directory of your choice instead. You can then deploy it by runningvercelin that directory.--setting default_page_size 10- use this to set Datasette settings, as described inthe documentation. This is a replacement for the unsupported--extra-optionsoption.Full helpWarning:Some of these options are not yet implemented by this plugin. In particular, the following do not yet work:--extra-options- use--settingdescribed above instead.--plugin-secret--version-note$ datasette publish vercel --help

Usage: datasette publish vercel [OPTIONS] [FILES]...

  Publish to https://vercel.com/

Options:
  -m, --metadata FILENAME         Path to JSON/YAML file containing metadata to publish
  --extra-options TEXT            Extra options to pass to datasette serve
  --branch TEXT                   Install datasette from a GitHub branch e.g. main
  --template-dir DIRECTORY        Path to directory containing custom templates
  --plugins-dir DIRECTORY         Path to directory containing custom plugins
  --static MOUNT:DIRECTORY        Serve static files from this directory at /MOUNT/...
  --install TEXT                  Additional packages (e.g. plugins) to install
  --plugin-secret <TEXT TEXT TEXT>...
                                  Secrets to pass to plugins, e.g. --plugin-secret
                                  datasette-auth-github client_id xxx
  --version-note TEXT             Additional note to show on /-/versions
  --secret TEXT                   Secret used for signing secure values, such as signed
                                  cookies
  --title TEXT                    Title for metadata
  --license TEXT                  License label for metadata
  --license_url TEXT              License URL for metadata
  --source TEXT                   Source label for metadata
  --source_url TEXT               Source URL for metadata
  --about TEXT                    About label for metadata
  --about_url TEXT                About URL for metadata
  --token TEXT                    Auth token to use for deploy
  --project PROJECT               Vercel project name to use  [required]
  --scope TEXT                    Optional Vercel scope (e.g. a team name)
  --no-prod                       Don't deploy directly to production
  --debug                         Enable Vercel CLI debug output
  --public                        Publish source with Vercel CLI --public
  --generate-dir DIRECTORY        Output generated application files and stop without
                                  deploying
  --generate-vercel-json          Output generated vercel.json file and stop without
                                  deploying
  --vercel-json FILENAME          Custom vercel.json file to use instead of generating
                                  one
  --setting SETTING...            Setting, see docs.datasette.io/en/stable/settings.html
  --crossdb                       Enable cross-database SQL queries
  --help                          Show this message and exit.Using a customvercel.jsonfileIf you want to add additional redirects or similar to your Vercel configuration you may want to provide a customvercel.jsonfile.To do this, first generate a configuration file (without running a deploy) using the--generate-vercel-jsonoption:datasette publish vercel my-database.db \
  --project=my-database \
  --generate-vercel-json > vercel.jsonYou can now edit thevercel.jsonfile that this creates to add your custom options.Then run the deploy using:datasette publish vercel my-database.db \
  --project=my-database \
  --vercel-json=vercel.jsonSetting aDATASETTE_SECRETDatasette usesa secret stringfor purposes such as signing authentication cookies. This secret is reset when the server restarts, which will sign out any users who are authenticated using a signed cookie.You can avoid this by generating aDATASETTE_SECRETsecret string and setting that as aVercel environment variable. If you do this the secret will stay consistent and your users will not be signed out.Using this with GitHub ActionsThis plugin can be used together withGitHub Actionsto deploy Datasette instances automatically on new pushes to a repo, or on a schedule.The GitHub Actions runners already have the Vercel deployment tool installed. You'll need to create an API token for your account atvercel.com/account/tokens, and store that as a secret in your GitHub repository calledVERCEL_TOKEN.Make sure your workflow has installeddatasetteanddatasette-publish-vercelusingpip, then add the following step to your GitHub Actions workflow:- name: Deploy Datasette using Vercel
      env:
        VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
      run: |-
        datasette publish vercel mydb.db \
          --token $VERCEL_TOKEN \
          --project my-vercel-projectYou can see a full example of a workflow that uses Vercel in this wayin the simonw/til repository.