repos / neovimcraft

website that makes it easy to find neovim plugins
git clone https://github.com/neurosnap/neovimcraft.git

commit
b70433e
parent
c7e7ed7
author
Eric Bower
date
2023-08-16 14:14:23 +0000 UTC
refactor: use `./public` dir for static outdir

refactor: deno deps
refactor: deployment
8 files changed,  +43, -33
M .github/workflows/deploy.yml
+6, -1
 1@@ -21,13 +21,18 @@ jobs:
 2     - run: make build
 3     - run: cp ./data/db.json ./static/db.json
 4 
 5+    - name: Set outputs
 6+      id: vars
 7+      run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
 8+
 9     - name: upload to pgs
10       uses: 'picosh/pgs-action@main'
11       with:
12         user: erock
13         key: ${{ secrets.PRIVATE_KEY }}
14         src: './static/*'
15-        project: neovimcraft
16+        project: "neovimcraft-${{ steps.vars.outputs.sha_short }}"
17+        promote: "neovimcraft"
18 
19     - name: Create Pull Request
20       uses: peter-evans/create-pull-request@v4
M .gitignore
+1, -0
1@@ -21,3 +21,4 @@ static/about/
2 static/created/
3 static/updated/
4 static/c/
5+public/
M Makefile
+8, -9
 1@@ -1,3 +1,6 @@
 2+REV=$(shell git rev-parse --short HEAD)
 3+PROJECT="neovimcraft-$(REV)"
 4+
 5 dev:
 6 	deno run --allow-read --allow-net src/dev.ts
 7 .PHONY: dev
 8@@ -38,22 +41,18 @@ scrape: download patch process html
 9 .PHONY: scrape
10 
11 clean:
12-	rm -f static/*.html
13-	rm -rf static/plugin
14-	rm -rf static/about
15-	rm -rf static/created
16-	rm -rf static/updated
17-	rm -rf static/c
18+	rm -rf ./public
19+	mkdir ./public
20 .PHONY: clean
21 
22 build: clean
23 	deno run --allow-write src/scripts/static.ts
24+	cp ./static/* ./public
25 .PHONY: build
26 
27 upload:
28-	gsutil -m rm -r gs://neovimcraft.com/*
29-	gsutil -m -h 'Cache-Control:private, max-age=0, no-transform' rsync -r ./static gs://neovimcraft.com
30-	gsutil -m -h 'Cache-Control:private, max-age=0, no-transform' cp ./data/db.json gs://neovimcraft.com/db.json
31+	scp -r ./public/* erock@pgs.sh:/$(PROJECT)
32+	ssh erock@pgs.sh neovimcraft link $(PROJECT)
33 .PHONY: upload
34 
35 deploy: scrape build upload
M data/resources-config.json
+12, -6
 1@@ -291,6 +291,18 @@
 2         "nvim-lua"
 3       ]
 4     },
 5+    {
 6+      "type": "github",
 7+      "username": "crivotz",
 8+      "repo": "nv-ide",
 9+      "tags": [
10+        "lua",
11+        "neovim",
12+        "neovim-configuration",
13+        "nvim-compe",
14+        "vim-plugins"
15+      ]
16+    },
17     {
18       "type": "github",
19       "username": "ctaylo21",
20@@ -1067,12 +1079,6 @@
21         "zsh"
22       ]
23     },
24-    {
25-      "type": "github",
26-      "username": "rsdlt",
27-      "repo": "nvim-config-files",
28-      "tags": []
29-    },
30     {
31       "type": "github",
32       "username": "sharksforarms",
M deno.json
+2, -6
 1@@ -1,16 +1,12 @@
 2 {
 3   "lint": {
 4-    "files": {
 5-      "include": ["src/"]
 6-    },
 7+    "include": ["src/"]
 8     "rules": {
 9       "tags": ["recommended"],
10       "exclude": ["no-explicit-any"]
11     }
12   },
13   "fmt": {
14-    "files": {
15-      "include": ["src/"]
16-    }
17+    "include": ["src/"]
18   }
19 }
M src/deps.ts
+1, -0
1@@ -1,3 +1,4 @@
2 export { marked } from "npm:marked";
3 export { encode } from "https://deno.land/std@0.166.0/encoding/base64.ts";
4 export { dirname } from "https://deno.land/std@0.166.0/path/mod.ts";
5+export { Application } from "https://deno.land/x/oak@v12.6.0/mod.ts";
M src/dev.ts
+2, -2
 1@@ -1,11 +1,11 @@
 2-import { Application } from "https://deno.land/x/oak/mod.ts";
 3+import { Application } from "./deps.ts";
 4 
 5 const app = new Application();
 6 
 7 app.use(async (context, next) => {
 8   try {
 9     await context.send({
10-      root: `${Deno.cwd()}/static`,
11+      root: `${Deno.cwd()}/public`,
12       index: "index.html",
13     });
14   } catch {
M src/scripts/static.ts
+11, -9
 1@@ -8,6 +8,8 @@ import { derivePluginData } from "../plugin-data.ts";
 2 import type { Plugin, PluginData, PluginMap, Tag, TagMap } from "../types.ts";
 3 import { getResourceId } from "../entities.ts";
 4 
 5+const OUTDIR = "./public";
 6+
 7 async function createFile(fname: string, data: string) {
 8   await Deno.mkdir(dirname(fname), { recursive: true });
 9   await Deno.writeTextFile(fname, data);
10@@ -594,17 +596,17 @@ const createPluginPage = (plugin: Plugin, tags: Tag[], html: string) => {
11 
12 async function render(data: PluginData, htmlData: { [key: string]: string }) {
13   const files = [
14-    createFile("./static/index.html", createSearchPage(data, "stars")),
15+    createFile(`${OUTDIR}/index.html`, createSearchPage(data, "stars")),
16     createFile(
17-      "./static/created/index.html",
18+      `${OUTDIR}/created/index.html`,
19       createSearchPage(data, "createdAt"),
20     ),
21     createFile(
22-      "./static/updated/index.html",
23+      `${OUTDIR}/updated/index.html`,
24       createSearchPage(data, "updatedAt"),
25     ),
26 
27-    createFile("./static/about/index.html", createAboutPage()),
28+    createFile(`${OUTDIR}/about/index.html`, createAboutPage()),
29   ];
30 
31   data.plugins.forEach((plugin) => {
32@@ -612,7 +614,7 @@ async function render(data: PluginData, htmlData: { [key: string]: string }) {
33     const id = getResourceId(plugin);
34     const html = htmlData[id] || "";
35     const fname =
36-      `./static/plugin/${plugin.username}/${plugin.repo}/index.html`;
37+      `${OUTDIR}/plugin/${plugin.username}/${plugin.repo}/index.html`;
38     const page = createPluginPage(plugin, tags, html);
39     files.push(createFile(fname, page));
40   });
41@@ -626,15 +628,15 @@ async function renderConfig(
42 ) {
43   const files = [
44     createFile(
45-      "./static/c/index.html",
46+      `${OUTDIR}/c/index.html`,
47       createSearchConfigPage(data, "stars"),
48     ),
49     createFile(
50-      "./static/c/created/index.html",
51+      `${OUTDIR}/c/created/index.html`,
52       createSearchConfigPage(data, "createdAt"),
53     ),
54     createFile(
55-      "./static/c/updated/index.html",
56+      `${OUTDIR}/c/updated/index.html`,
57       createSearchConfigPage(data, "updatedAt"),
58     ),
59   ];
60@@ -644,7 +646,7 @@ async function renderConfig(
61     const id = getResourceId(plugin);
62     const html = htmlData[id] || "";
63     const fname =
64-      `./static/plugin/${plugin.username}/${plugin.repo}/index.html`;
65+      `${OUTDIR}/plugin/${plugin.username}/${plugin.repo}/index.html`;
66     const page = createPluginPage(plugin, tags, html);
67     files.push(createFile(fname, page));
68   });