File tree Expand file tree Collapse file tree 4 files changed +16
-26
lines changed
pages/Dashboard/Content/SandboxGrid Expand file tree Collapse file tree 4 files changed +16
-26
lines changed Original file line number Diff line number Diff line change 11import { Sandbox } from '@codesandbox/common/lib/types' ;
22import JSZip from 'jszip' ;
3- import { createZip , BLOB_ID } from '../zip/create- zip' ;
3+ import zip from '../zip' ;
44
5+ const BLOB_ID = 'blob-url://' ;
56export default async function deploy ( sandbox : Sandbox ) {
67 // We first get the zip file, this is what we essentially need to have deployed.
78 // So we convert it to an API request that ZEIT will understand
8- const zipFile = await createZip (
9- sandbox ,
10- sandbox . modules ,
11- sandbox . directories ,
12- false ,
13- true
14- ) ;
9+ const zipFile = await zip . create ( sandbox ) ;
1510
1611 if ( ! zipFile ) {
1712 return null ;
1813 }
1914
2015 const contents = await JSZip . loadAsync ( zipFile ) ;
21-
2216 const apiData = { sandbox : [ ] } ;
23- const filePaths = Object . keys ( contents . files ) ;
17+ const filePaths = Object . keys ( contents ) ;
2418 for ( let i = 0 ; i < filePaths . length ; i += 1 ) {
2519 const filePath = filePaths [ i ] ;
26- const file = contents . files [ filePath ] ;
20+ const file = contents [ filePath ] ;
2721
2822 if ( ! file . dir ) {
2923 let content = await file . async ( 'text' ) ; // eslint-disable-line no-await-in-loop
Original file line number Diff line number Diff line change @@ -12,18 +12,19 @@ const getFile = async (id: string) => {
1212 responseType : 'arraybuffer' ,
1313 } ) ;
1414
15- return file . data ;
15+ const blob = new Blob ( [ file . data ] , {
16+ type : 'application/zip' ,
17+ } ) ;
18+
19+ return blob ;
1620} ;
1721
1822export default {
19- create ( { id } , { id : string } ) {
23+ create ( { id } : { id : string } ) {
2024 return getFile ( id ) ;
2125 } ,
2226 async download ( { title, id } : { title : string ; id : string } ) {
2327 const file = await getFile ( id ) ;
24- const blob = new Blob ( [ file ] , {
25- type : 'application/zip' ,
26- } ) ;
27- saveAs ( blob , `${ title || id } .zip` ) ;
28+ saveAs ( file , `${ title || id } .zip` ) ;
2829 } ,
2930} ;
Original file line number Diff line number Diff line change @@ -24,10 +24,7 @@ export const deployWithNetlify: AsyncAction = async ({
2424 const zip = await effects . zip . create ( state . editor . currentSandbox ) ;
2525
2626 try {
27- const id = await effects . netlify . deploy (
28- zip . file ,
29- state . editor . currentSandbox
30- ) ;
27+ const id = await effects . netlify . deploy ( zip , state . editor . currentSandbox ) ;
3128 state . deployment . deploying = false ;
3229
3330 await actions . deployment . getNetlifyDeploys ( ) ;
@@ -95,7 +92,7 @@ export const deployClicked: AsyncAction = async ({
9592 try {
9693 state . deployment . deploying = true ;
9794 const zip = await effects . zip . create ( state . editor . currentSandbox ) ;
98- const contents = await effects . jsZip . loadAsync ( zip . file ) ;
95+ const contents = await effects . jsZip . loadAsync ( zip ) ;
9996 state . deployment . url = await effects . zeit . deploy (
10097 contents ,
10198 state . editor . currentSandbox
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import track from '@codesandbox/common/lib/utils/analytics';
66import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name' ;
77import { protocolAndHost } from '@codesandbox/common/lib/utils/url-generator' ;
88import { makeTemplates } from 'app/components/CreateNewSandbox/queries' ;
9- import downloadZip from 'app/overmind/effects/zip/create- zip' ;
9+ import zip from 'app/overmind/effects/zip' ;
1010import { formatDistanceToNow } from 'date-fns' ;
1111import { zonedTimeToUtc } from 'date-fns-tz' ;
1212import { camelizeKeys } from 'humps' ;
@@ -231,9 +231,7 @@ class SandboxGridComponent extends React.Component<
231231 const sandboxes = await Promise . all (
232232 sandboxIds . map ( s => this . getSandbox ( s ) )
233233 ) ;
234- return Promise . all (
235- sandboxes . map ( s => downloadZip ( s , s . modules , s . directories ) )
236- ) ;
234+ return Promise . all ( sandboxes . map ( s => zip . download ( s ) ) ) ;
237235 } ;
238236
239237 forkSandbox = id => {
You can’t perform that action at this time.
0 commit comments