timconspicuous.neocities.org

Tangled workflow

+58 -15
+1 -1
.gitignore
··· 1 1 _cache 2 2 public/ 3 3 deno.lock 4 - env 4 + .env
+19
.tangled/workflow/deploy.yaml
··· 1 + engine: nixery 2 + 3 + when: 4 + - event: ["push", "pull_request"] 5 + branch: ["main"] 6 + 7 + dependencies: 8 + nixpkgs: 9 + - deno 10 + 11 + steps: 12 + # deploy.ts will push the "./public" directory to Neocities 13 + # if you are committing those files, skip the build step 14 + - name: Build step 15 + command: | 16 + deno task build 17 + - name: Deploy to Neocities 18 + command: | 19 + deno run --allow-net --allow-read --allow-env deploy.ts
+7 -14
deno.json
··· 1 1 { 2 2 "imports": { 3 + "async-neocities": "npm:async-neocities@^4.1.2", 3 4 "lume/": "https://deno.land/x/lume@v3.0.8/", 4 5 "lume/cms/": "https://cdn.jsdelivr.net/gh/lumeland/cms@0.12.5/", 5 6 "lume/jsx-runtime": "https://deno.land/x/ssx@v0.1.12/jsx-runtime.ts" ··· 7 8 "tasks": { 8 9 "lume": "echo \"import 'lume/cli.ts'\" | deno run -A -", 9 10 "build": "deno task lume", 10 - "serve": "deno task lume -s" 11 + "serve": "deno task lume -s", 12 + "deploy": "deno run --allow-net --allow-read --allow-env deploy.ts" 11 13 }, 12 14 "compilerOptions": { 13 - "types": [ 14 - "lume/types.ts" 15 - ], 15 + "types": ["lume/types.ts"], 16 16 "jsx": "react-jsx", 17 17 "jsxImportSource": "lume" 18 18 }, 19 - "exclude": [ 20 - "./public" 21 - ], 19 + "exclude": ["./public"], 22 20 "fmt": { 23 21 "useTabs": true, 24 22 "indentWidth": 4 25 23 }, 26 - "unstable": [ 27 - "temporal", 28 - "fmt-component" 29 - ], 24 + "unstable": ["temporal", "fmt-component"], 30 25 "lint": { 31 - "plugins": [ 32 - "https://deno.land/x/lume@v3.0.8/lint.ts" 33 - ] 26 + "plugins": ["https://deno.land/x/lume@v3.0.8/lint.ts"] 34 27 } 35 28 }
+31
deploy.ts
··· 1 + // Helper script to deploy the files to Neocities 2 + import { NeocitiesAPIClient } from "npm:async-neocities"; 3 + import { load } from "jsr:@std/dotenv"; 4 + 5 + await load({ export: true }); 6 + 7 + // Get credentials from environment 8 + const siteName = Deno.env.get("NEOCITIES_SITE_NAME"); 9 + const password = Deno.env.get("NEOCITIES_PASSWORD"); 10 + 11 + if (!siteName || !password) { 12 + throw new Error( 13 + "Please set NEOCITIES_SITE_NAME and NEOCITIES_PASSWORD environment variables.", 14 + ); 15 + } 16 + 17 + const apiKeyResponse = await NeocitiesAPIClient.getKey({ 18 + siteName: siteName, 19 + ownerPassword: [password], 20 + }); 21 + 22 + const client = new NeocitiesAPIClient(apiKeyResponse.api_key); 23 + 24 + // Deploy the site 25 + await client.deploy({ 26 + directory: "./public", 27 + cleanup: true, // Delete orphaned files 28 + includeUnsupportedFiles: false, // Upload unsupported files (paid feature) 29 + }); 30 + 31 + console.log("Successfully deployed to Neocities!");