-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
647622f
commit c03d333
Showing
8 changed files
with
93 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/target/ | ||
/.env | ||
/styles/ | ||
/public/styles/ | ||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { createClient } from "@supabase/supabase-js"; | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import process from "node:process"; | ||
|
||
// Create a single supabase client for interacting with your database | ||
const url = "https://ryvsflpspddwwacxrnst.supabase.co"; | ||
|
||
const supabase = createClient(url, process.env.PROD_SUPABASE_SERVICE_ROLE_KEY); | ||
|
||
await supabase.storage | ||
.createBucket("assets", { | ||
public: true, | ||
}) | ||
.then(console.log); | ||
|
||
await supabase.storage | ||
.from("assets") | ||
.remove(["styles/index.css"]) | ||
.then(console.log); | ||
uploadDir("public"); | ||
|
||
function uploadDir(dir) { | ||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { | ||
if (entry.isDirectory()) { | ||
uploadDir(path.join(dir, entry.name)); | ||
} else { | ||
let filePath = path.join(entry.parentPath, entry.name); | ||
let contents = fs.readFileSync(filePath); | ||
const uploaded = supabase.storage | ||
.from("assets") | ||
.upload(filePath.substring(7), contents, { | ||
contentType: mimeType(filePath), | ||
}); | ||
if (filePath.endsWith(".css")) { | ||
console.log(uploaded); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function mimeType(fileName) { | ||
const ext = path.extname(fileName); | ||
switch (ext) { | ||
case ".txt": | ||
return "text/plain;charset=UTF-8"; | ||
case ".css": | ||
return "text/css;charset=UTF-8"; | ||
case ".mp3": | ||
return "audio/mpeg"; | ||
case ".wav": | ||
return "audio/wav"; | ||
case ".png": | ||
return "image/x-png"; | ||
case ".jpeg": | ||
return "image/jpeg"; | ||
case ".jpg": | ||
return "image/jpeg"; | ||
case ".pdf": | ||
return "application/pdf"; | ||
case ".js": | ||
return "application/javascript"; | ||
default: | ||
throw new Error(`Unexpected file ext: ${ext}`); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.