@ -3,7 +3,6 @@ import React, { useEffect, useState, useRef } from 'react' // eslint-disable-lin
import { TreeView , TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
import { TreeView , TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
import { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import { Toaster } from '@remix-ui/toaster' // eslint-disable-line
import * as async from 'async'
import Gists from 'gists'
import Gists from 'gists'
import { FileExplorerMenu } from './file-explorer-menu' // eslint-disable-line
import { FileExplorerMenu } from './file-explorer-menu' // eslint-disable-line
import { FileExplorerContextMenu } from './file-explorer-context-menu' // eslint-disable-line
import { FileExplorerContextMenu } from './file-explorer-context-menu' // eslint-disable-line
@ -559,7 +558,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const publishToGist = ( ) = > {
const publishToGist = ( ) = > {
modal ( 'Create a public gist' , ` Are you sure you want to anonymously publish all your files in the ${ name } workspace as a public gist on github.com? Note: this will not include directories. ` , {
modal ( 'Create a public gist' , ` Are you sure you want to anonymously publish all your files in the ${ name } workspace as a public gist on github.com? ` , {
label : 'OK' ,
label : 'OK' ,
fn : toGist
fn : toGist
} , {
} , {
@ -587,7 +586,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
fn : ( ) = > { }
fn : ( ) = > { }
} )
} )
} else {
} else {
modal ( 'Publish to gist Failed' , data . message + ' ' + data . documentation_url + ' ' + JSON . stringify ( data . errors , null , '\t' ) , {
const error = JSON . stringify ( data . errors , null , '\t' ) || ''
const message = data . message === 'Not Found' ? data . message + '. Please make sure the API token has right to create a gist.' : data . message
modal ( 'Publish to gist Failed' , message + ' ' + data . documentation_url + ' ' + error , {
label : 'Close' ,
label : 'Close' ,
fn : async ( ) = > { }
fn : async ( ) = > { }
} , null )
} , null )
@ -1057,29 +1058,20 @@ export const FileExplorer = (props: FileExplorerProps) => {
export default FileExplorer
export default FileExplorer
function packageFiles ( filesProvider , directory , callback ) {
async function packageFiles ( filesProvider , directory , callback ) {
const ret = { }
const ret = { }
filesProvider . resolveDirectory ( directory , ( error , files ) = > {
try {
if ( error ) callback ( error )
await filesProvider . copyFolderToJson ( directory , ( { path , content } ) = > {
else {
if ( /^\s+$/ . test ( content ) || ! content . length ) {
async . eachSeries ( Object . keys ( files ) , ( path , cb ) = > {
content = '// this line is added to create a gist. Empty file is not allowed.'
if ( filesProvider . isDirectory ( path ) ) {
}
cb ( )
path = path . replace ( /\//g , '...' )
} else {
ret [ path ] = { content }
filesProvider . get ( path , ( error , content ) = > {
} )
if ( error ) return cb ( error )
callback ( null , ret )
if ( /^\s+$/ . test ( content ) || ! content . length ) {
} catch ( e ) {
content = '// this line is added to create a gist. Empty file is not allowed.'
return callback ( e )
}
}
ret [ path ] = { content }
cb ( )
} )
}
} , ( error ) = > {
callback ( error , ret )
} )
}
} )
}
}
function joinPath ( . . . paths ) {
function joinPath ( . . . paths ) {