Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d3fb1d7de | ||
|
|
c1474d85e5 | ||
|
|
3779000ec5 | ||
|
|
9c0e898d17 | ||
|
|
dee7fb0545 | ||
|
|
0e31267078 | ||
|
|
332edd3d98 | ||
|
|
7045646b1a | ||
|
|
eb4aa68581 | ||
|
|
73710da501 | ||
|
|
a87eae2119 | ||
|
|
ecf3cad189 | ||
|
|
be7a754a74 | ||
|
|
2a585ab5ea | ||
|
|
eac1933094 | ||
|
|
c36ab43dcc |
@@ -1,5 +1,4 @@
|
||||
import { type ActionFunctionArgs, json } from '@remix-run/cloudflare';
|
||||
import crypto from 'crypto';
|
||||
import type { NetlifySiteInfo } from '~/types/netlify';
|
||||
|
||||
interface DeployRequestBody {
|
||||
@@ -8,6 +7,15 @@ interface DeployRequestBody {
|
||||
chatId: string;
|
||||
}
|
||||
|
||||
async function sha1(message: string) {
|
||||
const msgBuffer = new TextEncoder().encode(message);
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-1', msgBuffer);
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
|
||||
|
||||
return hashHex;
|
||||
}
|
||||
|
||||
export async function action({ request }: ActionFunctionArgs) {
|
||||
try {
|
||||
const { siteId, files, token, chatId } = (await request.json()) as DeployRequestBody & { token: string };
|
||||
@@ -104,7 +112,7 @@ export async function action({ request }: ActionFunctionArgs) {
|
||||
for (const [filePath, content] of Object.entries(files)) {
|
||||
// Ensure file path starts with a forward slash
|
||||
const normalizedPath = filePath.startsWith('/') ? filePath : '/' + filePath;
|
||||
const hash = crypto.createHash('sha1').update(content).digest('hex');
|
||||
const hash = await sha1(content);
|
||||
fileDigests[normalizedPath] = hash;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,26 @@ export default defineConfig((config) => {
|
||||
},
|
||||
build: {
|
||||
target: 'esnext',
|
||||
rollupOptions: {
|
||||
output: {
|
||||
format: 'esm',
|
||||
},
|
||||
},
|
||||
commonjsOptions: {
|
||||
transformMixedEsModules: true,
|
||||
},
|
||||
},
|
||||
optimizeDeps: {
|
||||
esbuildOptions: {
|
||||
define: {
|
||||
global: 'globalThis',
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
buffer: 'vite-plugin-node-polyfills/polyfills/buffer',
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
nodePolyfills({
|
||||
|
||||
Reference in New Issue
Block a user