Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
0429892c
Commit
0429892c
authored
Mar 24, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replicate folder
parent
e3bc26cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
fileProvider.js
apps/remix-ide/src/app/files/fileProvider.js
+9
-4
workspaceFileProvider.js
apps/remix-ide/src/app/files/workspaceFileProvider.js
+4
-1
landing-page.js
apps/remix-ide/src/app/ui/landing-page/landing-page.js
+2
-0
No files found.
apps/remix-ide/src/app/files/fileProvider.js
View file @
0429892c
...
@@ -199,21 +199,24 @@ class FileProvider {
...
@@ -199,21 +199,24 @@ class FileProvider {
* copy the folder recursively (internal use)
* copy the folder recursively (internal use)
* @param {string} path is the folder to be copied over
* @param {string} path is the folder to be copied over
* @param {Function} visitFile is a function called for each visited files
* @param {Function} visitFile is a function called for each visited files
* @param {Function} visitFolder is a function called for each visited folders
*/
*/
_copyFolderToJsonInternal
(
path
,
visitFile
)
{
_copyFolderToJsonInternal
(
path
,
visitFile
,
visitFolder
)
{
visitFile
=
visitFile
||
(()
=>
{})
visitFile
=
visitFile
||
(()
=>
{})
visitFolder
=
visitFolder
||
(()
=>
{})
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
json
=
{}
const
json
=
{}
path
=
this
.
removePrefix
(
path
)
path
=
this
.
removePrefix
(
path
)
if
(
window
.
remixFileSystem
.
existsSync
(
path
))
{
if
(
window
.
remixFileSystem
.
existsSync
(
path
))
{
try
{
try
{
const
items
=
window
.
remixFileSystem
.
readdirSync
(
path
)
const
items
=
window
.
remixFileSystem
.
readdirSync
(
path
)
visitFolder
({
path
})
if
(
items
.
length
!==
0
)
{
if
(
items
.
length
!==
0
)
{
items
.
forEach
(
async
(
item
,
index
)
=>
{
items
.
forEach
(
async
(
item
,
index
)
=>
{
const
file
=
{}
const
file
=
{}
const
curPath
=
`
${
path
}${
path
.
endsWith
(
'/'
)
?
''
:
'/'
}${
item
}
`
const
curPath
=
`
${
path
}${
path
.
endsWith
(
'/'
)
?
''
:
'/'
}${
item
}
`
if
(
window
.
remixFileSystem
.
statSync
(
curPath
).
isDirectory
())
{
if
(
window
.
remixFileSystem
.
statSync
(
curPath
).
isDirectory
())
{
file
.
children
=
await
this
.
_copyFolderToJsonInternal
(
curPath
,
visitFile
)
file
.
children
=
await
this
.
_copyFolderToJsonInternal
(
curPath
,
visitFile
,
visitFolder
)
}
else
{
}
else
{
file
.
content
=
window
.
remixFileSystem
.
readFileSync
(
curPath
,
'utf8'
)
file
.
content
=
window
.
remixFileSystem
.
readFileSync
(
curPath
,
'utf8'
)
visitFile
({
path
:
curPath
,
content
:
file
.
content
})
visitFile
({
path
:
curPath
,
content
:
file
.
content
})
...
@@ -234,10 +237,12 @@ class FileProvider {
...
@@ -234,10 +237,12 @@ class FileProvider {
* copy the folder recursively
* copy the folder recursively
* @param {string} path is the folder to be copied over
* @param {string} path is the folder to be copied over
* @param {Function} visitFile is a function called for each visited files
* @param {Function} visitFile is a function called for each visited files
* @param {Function} visitFolder is a function called for each visited folders
*/
*/
copyFolderToJson
(
path
,
visitFile
)
{
copyFolderToJson
(
path
,
visitFile
,
visitFolder
)
{
visitFile
=
visitFile
||
(()
=>
{})
visitFile
=
visitFile
||
(()
=>
{})
return
this
.
_copyFolderToJsonInternal
(
path
,
visitFile
)
visitFolder
=
visitFolder
||
(()
=>
{})
return
this
.
_copyFolderToJsonInternal
(
path
,
visitFile
,
visitFolder
)
}
}
removeFile
(
path
)
{
removeFile
(
path
)
{
...
...
apps/remix-ide/src/app/files/workspaceFileProvider.js
View file @
0429892c
...
@@ -48,11 +48,14 @@ class WorkspaceFileProvider extends FileProvider {
...
@@ -48,11 +48,14 @@ class WorkspaceFileProvider extends FileProvider {
})
})
}
}
async
copyFolderToJson
(
directory
,
visitFile
)
{
async
copyFolderToJson
(
directory
,
visitFile
,
visitFolder
)
{
visitFile
=
visitFile
||
(()
=>
{})
visitFile
=
visitFile
||
(()
=>
{})
visitFolder
=
visitFolder
||
(()
=>
{})
const
regex
=
new
RegExp
(
`.workspaces/
${
this
.
workspace
}
/`
,
'g'
)
const
regex
=
new
RegExp
(
`.workspaces/
${
this
.
workspace
}
/`
,
'g'
)
let
json
=
await
super
.
_copyFolderToJsonInternal
(
directory
,
({
path
,
content
})
=>
{
let
json
=
await
super
.
_copyFolderToJsonInternal
(
directory
,
({
path
,
content
})
=>
{
visitFile
({
path
:
path
.
replace
(
regex
,
''
),
content
})
visitFile
({
path
:
path
.
replace
(
regex
,
''
),
content
})
},({
path
})
=>
{
visitFolder
({
path
:
path
.
replace
(
regex
,
''
)
})
})
})
json
=
JSON
.
stringify
(
json
).
replace
(
regex
,
''
)
json
=
JSON
.
stringify
(
json
).
replace
(
regex
,
''
)
return
JSON
.
parse
(
json
)
return
JSON
.
parse
(
json
)
...
...
apps/remix-ide/src/app/ui/landing-page/landing-page.js
View file @
0429892c
...
@@ -327,6 +327,8 @@ export class LandingPage extends ViewPlugin {
...
@@ -327,6 +327,8 @@ export class LandingPage extends ViewPlugin {
const
zip
=
new
JSZip
()
const
zip
=
new
JSZip
()
await
fileProviders
.
browser
.
copyFolderToJson
(
'/'
,
({
path
,
content
})
=>
{
await
fileProviders
.
browser
.
copyFolderToJson
(
'/'
,
({
path
,
content
})
=>
{
zip
.
file
(
path
,
content
)
zip
.
file
(
path
,
content
)
},({
path
})
=>
{
zip
.
folder
(
path
)
})
})
zip
.
generateAsync
({
type
:
'blob'
}).
then
(
function
(
blob
)
{
zip
.
generateAsync
({
type
:
'blob'
}).
then
(
function
(
blob
)
{
saveAs
(
blob
,
'remixdbackup.zip'
)
saveAs
(
blob
,
'remixdbackup.zip'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment