From fae5b228710e3f400cadfe9e81fad82ada1e62fb Mon Sep 17 00:00:00 2001 From: Justin Stayton Date: Mon, 13 Nov 2023 10:36:34 -0500 Subject: [PATCH] Initial commit --- .gitattributes | 1 + .gitignore | 5 +++ LICENSE | 20 +++++++++++ README.md | 87 +++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 31 +++++++++++++++++ package.json | 23 +++++++++++++ render.yaml | 6 ++++ src/links.json | 5 +++ suri.config.json | 3 ++ 9 files changed, 181 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 render.yaml create mode 100644 src/links.json create mode 100644 suri.config.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9c9b501 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# npm +/node_modules + +# Suri +/build diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3231767 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) 2024 Justin Stayton + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..49b1146 --- /dev/null +++ b/README.md @@ -0,0 +1,87 @@ +

+ Suri +

+ +

+ Your own short links as an easily deployed static site on Render +

+ +You're viewing a template repository tailored for deploying Suri to +[Render](https://render.com/). Head over to +[the main repository](https://github.com/surishortlink/suri) to learn more about +Suri, including additional deployment options. + +## Setup: Step By Step + +1. Hit the "Use this template" button above and then "Create a new repository". + Fill in the required details to create a new repository based on this one. +2. On the [Render Dashboard](https://dashboard.render.com/), create a new + Blueprint. +3. Connect or re-configure your GitHub account to grant access to your new + repository. Select that repository and hit "Connect". +4. Give the Blueprint a name, such as "Suri". The `main` branch should already + be selected. Hit "Apply" to begin the initial build and deploy. + +### Auto-Deploy + +Any commits to the `main` branch of your new repository will trigger a new build +and deploy. You can change this by going to the "Settings" of your `suri` +service and editing the "Branch" and "Auto-Deploy" options. + +### Custom Domain + +To use a custom domain, follow Render's guide: +[Custom Domains](https://docs.render.com/custom-domains). + +## How It Works + +### Manage Links + +At the heart of Suri is the [`links.json`](src/links.json) file, located in the +`src` directory, where you manage your links. All of the template repositories +include this file seeded with a few examples: + +```json +{ + "/": "https://www.youtube.com/watch?v=CsHiG-43Fzg", + "1": "https://fee.org/articles/the-use-of-knowledge-in-society/", + "gh": "https://github.com/surishortlink/suri" +} +``` + +It couldn't be simpler: the key is the "short link" path that gets redirected, +and the value is the target URL. Keys can be as short or as long as you want, +using whatever mixture of characters you want. `/` is a special entry for +redirecting the root path. + +### Build Static Site + +Suri ships with a `suri` executable file that generates the static site from the +`links.json` file. The static site is output to a directory named `build`. + +All of the template repositories are configured with a `build` script that +invokes this executable, making the command you run simple: + +```bash +npm run build +``` + +When you make a change to the `links.json` file, simply re-run this command to +re-generate the static site, which can then be re-deployed. This template +repository is configured to do this automatically. + +### Config + +Configuration is handled through the [`suri.config.json`](suri.config.json) file +in the root directory. There is only one option at this point: + +| Option | Description | Type | Default | +| ------ | ------------------------------------------------------------------ | ------- | ------- | +| `js` | Whether to redirect with JavaScript instead of a `` refresh. | Boolean | `false` | + +### Public Directory + +Finally, any files in the `public` directory will be copied over to the `build` +directory without modification when the static site is built. This can be useful +for files like `favicon.ico` or `robots.txt` (that said, Suri provides sensible +defaults for both). diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..d574902 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,31 @@ +{ + "name": "@surishortlink/deploy-render", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@surishortlink/deploy-render", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "@surishortlink/suri": "^1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@surishortlink/suri": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@surishortlink/suri/-/suri-1.0.0.tgz", + "integrity": "sha512-iPp4OaZviA7HQqbOfhEMk6cRP7yl7+NDiuGEPBLS4SRF5+iNFJRwmPACBJ9TvHMZDH6Jus0XQsRnq6JBIPpFqw==", + "dev": true, + "bin": { + "suri": "bin/suri.js" + }, + "engines": { + "node": ">=18" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..a5c2702 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "@surishortlink/deploy-render", + "version": "1.0.0", + "private": true, + "type": "module", + "description": "A template repository tailored for deploying Suri to Render", + "homepage": "https://github.com/surishortlink/suri-deploy-render#readme", + "bugs": "https://github.com/surishortlink/suri-deploy-render/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/surishortlink/suri-deploy-render.git" + }, + "scripts": { + "build": "suri" + }, + "devDependencies": { + "@surishortlink/suri": "^1" + }, + "engines": { + "node": ">=18" + } +} diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..bd3c997 --- /dev/null +++ b/render.yaml @@ -0,0 +1,6 @@ +services: + - type: web + name: suri + runtime: static + buildCommand: npm run build + staticPublishPath: ./build diff --git a/src/links.json b/src/links.json new file mode 100644 index 0000000..fcb8fc9 --- /dev/null +++ b/src/links.json @@ -0,0 +1,5 @@ +{ + "/": "https://www.youtube.com/watch?v=CsHiG-43Fzg", + "1": "https://fee.org/articles/the-use-of-knowledge-in-society/", + "gh": "https://github.com/surishortlink/suri" +} diff --git a/suri.config.json b/suri.config.json new file mode 100644 index 0000000..d8351c5 --- /dev/null +++ b/suri.config.json @@ -0,0 +1,3 @@ +{ + "js": false +}