mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Merge branch 'stackblitz-labs:stable' into stable
This commit is contained in:
commit
1d8d00a23b
@ -1,5 +1,4 @@
|
|||||||
import { type ActionFunctionArgs, json } from '@remix-run/cloudflare';
|
import { type ActionFunctionArgs, json } from '@remix-run/cloudflare';
|
||||||
import crypto from 'crypto';
|
|
||||||
import type { NetlifySiteInfo } from '~/types/netlify';
|
import type { NetlifySiteInfo } from '~/types/netlify';
|
||||||
|
|
||||||
interface DeployRequestBody {
|
interface DeployRequestBody {
|
||||||
@ -8,6 +7,15 @@ interface DeployRequestBody {
|
|||||||
chatId: string;
|
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) {
|
export async function action({ request }: ActionFunctionArgs) {
|
||||||
try {
|
try {
|
||||||
const { siteId, files, token, chatId } = (await request.json()) as DeployRequestBody & { token: string };
|
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)) {
|
for (const [filePath, content] of Object.entries(files)) {
|
||||||
// Ensure file path starts with a forward slash
|
// Ensure file path starts with a forward slash
|
||||||
const normalizedPath = filePath.startsWith('/') ? filePath : '/' + filePath;
|
const normalizedPath = filePath.startsWith('/') ? filePath : '/' + filePath;
|
||||||
const hash = crypto.createHash('sha1').update(content).digest('hex');
|
const hash = await sha1(content);
|
||||||
fileDigests[normalizedPath] = hash;
|
fileDigests[normalizedPath] = hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,6 +93,26 @@ export default defineConfig((config) => {
|
|||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
format: 'esm',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
commonjsOptions: {
|
||||||
|
transformMixedEsModules: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
optimizeDeps: {
|
||||||
|
esbuildOptions: {
|
||||||
|
define: {
|
||||||
|
global: 'globalThis',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
buffer: 'vite-plugin-node-polyfills/polyfills/buffer',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
nodePolyfills({
|
nodePolyfills({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user