From d2e7578b2f32dadc82dc52ffb5e1bbd719b221ec Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 09:43:22 +0100 Subject: [PATCH 01/18] better error message --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 5d6bdada62..790add9b69 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -587,7 +587,9 @@ export const FileExplorer = (props: FileExplorerProps) => { fn: () => {} }) } 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', fn: async () => {} }, null) From f93f459cdb684b038cec0a6acac47aacfc11ea98 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 09:44:02 +0100 Subject: [PATCH 02/18] add the entire project to gist --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 790add9b69..51d92ac594 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -1077,7 +1077,13 @@ function packageFiles (filesProvider, directory, callback) { cb() }) } - }, (error) => { + }, async (error) => { + try { + const json = await filesProvider.copyFolderToJson(directory) + ret['project.json'] = { content: JSON.stringify(json, null, '\t') } + } catch (e) { + console.log(e) + } callback(error, ret) }) } From 36de70d3f78f49d908b18feacd42b8b5a026adb7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:06:28 +0100 Subject: [PATCH 03/18] make sure workspace provider is removing the uneeded part of the paths --- apps/remix-ide/src/app/files/fileProvider.js | 15 ++++++++++++--- .../src/app/files/workspaceFileProvider.js | 7 +++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index adc5840dfd..70dbdc7aca 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -196,11 +196,11 @@ class FileProvider { } /** - * copy the folder recursively + * copy the folder recursively (internal use) * @param {string} path is the folder to be copied over * @param {string} destination is the destination folder */ - copyFolderToJson (path) { + _copyFolderToJsonInternal (path) { return new Promise((resolve, reject) => { const json = {} path = this.removePrefix(path) @@ -212,7 +212,7 @@ class FileProvider { const file = {} const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` if (window.remixFileSystem.statSync(curPath).isDirectory()) { - file.children = await this.copyFolderToJson(curPath) + file.children = await this._copyFolderToJsonInternal(curPath) } else { file.content = window.remixFileSystem.readFileSync(curPath, 'utf8') } @@ -228,6 +228,15 @@ class FileProvider { }) } + /** + * copy the folder recursively + * @param {string} path is the folder to be copied over + * @param {string} destination is the destination folder + */ + copyFolderToJson (path) { + return this._copyFolderToJsonInternal(path) + } + removeFile (path) { path = this.removePrefix(path) if (window.remixFileSystem.existsSync(path) && !window.remixFileSystem.statSync(path).isDirectory()) { diff --git a/apps/remix-ide/src/app/files/workspaceFileProvider.js b/apps/remix-ide/src/app/files/workspaceFileProvider.js index 8522f5ff4c..91f3227fbd 100644 --- a/apps/remix-ide/src/app/files/workspaceFileProvider.js +++ b/apps/remix-ide/src/app/files/workspaceFileProvider.js @@ -48,6 +48,13 @@ class WorkspaceFileProvider extends FileProvider { }) } + async copyFolderToJson (directory) { + let json = await super._copyFolderToJsonInternal(directory) + const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g'); + json = JSON.stringify(json).replace(regex, '') + return JSON.parse(json) + } + _normalizePath (path) { if (!this.workspace) throw new Error('No workspace has been opened.') return path.replace(this.workspacesPath + '/' + this.workspace + '/', '') From 8407abb5cdea68fc32eec6f77fb75c26db3f1882 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:11:54 +0100 Subject: [PATCH 04/18] update message --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 51d92ac594..7bdb3e3251 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -559,7 +559,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } 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? This also add an entry named 'project.json' which include all the folders and files.`, { label: 'OK', fn: toGist }, { From b9ec8f4fcbd0453dd189a8dd27f02cb5d9cee90c Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 09:43:22 +0100 Subject: [PATCH 05/18] better error message --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 5d6bdada62..790add9b69 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -587,7 +587,9 @@ export const FileExplorer = (props: FileExplorerProps) => { fn: () => {} }) } 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', fn: async () => {} }, null) From b6f2a0423c8d1d853f654fd511dc6cd2ccd39137 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 09:44:02 +0100 Subject: [PATCH 06/18] add the entire project to gist --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 790add9b69..51d92ac594 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -1077,7 +1077,13 @@ function packageFiles (filesProvider, directory, callback) { cb() }) } - }, (error) => { + }, async (error) => { + try { + const json = await filesProvider.copyFolderToJson(directory) + ret['project.json'] = { content: JSON.stringify(json, null, '\t') } + } catch (e) { + console.log(e) + } callback(error, ret) }) } From 5e12a5ccb8d0b1eb8d1d5c936d523ed3cd369137 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:06:28 +0100 Subject: [PATCH 07/18] make sure workspace provider is removing the uneeded part of the paths --- apps/remix-ide/src/app/files/fileProvider.js | 15 ++++++++++++--- .../src/app/files/workspaceFileProvider.js | 7 +++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index adc5840dfd..70dbdc7aca 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -196,11 +196,11 @@ class FileProvider { } /** - * copy the folder recursively + * copy the folder recursively (internal use) * @param {string} path is the folder to be copied over * @param {string} destination is the destination folder */ - copyFolderToJson (path) { + _copyFolderToJsonInternal (path) { return new Promise((resolve, reject) => { const json = {} path = this.removePrefix(path) @@ -212,7 +212,7 @@ class FileProvider { const file = {} const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` if (window.remixFileSystem.statSync(curPath).isDirectory()) { - file.children = await this.copyFolderToJson(curPath) + file.children = await this._copyFolderToJsonInternal(curPath) } else { file.content = window.remixFileSystem.readFileSync(curPath, 'utf8') } @@ -228,6 +228,15 @@ class FileProvider { }) } + /** + * copy the folder recursively + * @param {string} path is the folder to be copied over + * @param {string} destination is the destination folder + */ + copyFolderToJson (path) { + return this._copyFolderToJsonInternal(path) + } + removeFile (path) { path = this.removePrefix(path) if (window.remixFileSystem.existsSync(path) && !window.remixFileSystem.statSync(path).isDirectory()) { diff --git a/apps/remix-ide/src/app/files/workspaceFileProvider.js b/apps/remix-ide/src/app/files/workspaceFileProvider.js index 8522f5ff4c..91f3227fbd 100644 --- a/apps/remix-ide/src/app/files/workspaceFileProvider.js +++ b/apps/remix-ide/src/app/files/workspaceFileProvider.js @@ -48,6 +48,13 @@ class WorkspaceFileProvider extends FileProvider { }) } + async copyFolderToJson (directory) { + let json = await super._copyFolderToJsonInternal(directory) + const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g'); + json = JSON.stringify(json).replace(regex, '') + return JSON.parse(json) + } + _normalizePath (path) { if (!this.workspace) throw new Error('No workspace has been opened.') return path.replace(this.workspacesPath + '/' + this.workspace + '/', '') From e0fa3c5b206484a28ebdef0c1d64b57f570923e0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:11:54 +0100 Subject: [PATCH 08/18] update message --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 51d92ac594..7bdb3e3251 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -559,7 +559,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } 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? This also add an entry named 'project.json' which include all the folders and files.`, { label: 'OK', fn: toGist }, { From 15b47280ee57bc5c17679bda1346a1808d182479 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:30:59 +0100 Subject: [PATCH 09/18] linting --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 7bdb3e3251..fed5580a7c 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -1080,7 +1080,7 @@ function packageFiles (filesProvider, directory, callback) { }, async (error) => { try { const json = await filesProvider.copyFolderToJson(directory) - ret['project.json'] = { content: JSON.stringify(json, null, '\t') } + ret['project.json'] = { content: JSON.stringify(json, null, '\t') } } catch (e) { console.log(e) } From c512803685e20de523671fb1f4858e5b6d25d9a7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 11:20:34 +0100 Subject: [PATCH 10/18] copy all the files / folders to gist --- apps/remix-ide/src/app/files/fileProvider.js | 15 ++++--- .../src/app/files/workspaceFileProvider.js | 7 ++- .../file-explorer/src/lib/file-explorer.tsx | 43 ++++++------------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 70dbdc7aca..3a2e85abd8 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -198,9 +198,10 @@ class FileProvider { /** * copy the folder recursively (internal use) * @param {string} path is the folder to be copied over - * @param {string} destination is the destination folder + * @param {Function} visitFile is a function called for each visited files */ - _copyFolderToJsonInternal (path) { + _copyFolderToJsonInternal (path, visitFile) { + visitFile = visitFile || (() => {}) return new Promise((resolve, reject) => { const json = {} path = this.removePrefix(path) @@ -212,9 +213,10 @@ class FileProvider { const file = {} const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` if (window.remixFileSystem.statSync(curPath).isDirectory()) { - file.children = await this._copyFolderToJsonInternal(curPath) + file.children = await this._copyFolderToJsonInternal(curPath, visitFile) } else { file.content = window.remixFileSystem.readFileSync(curPath, 'utf8') + visitFile({ path: curPath, content: file.content }) } json[curPath] = file }) @@ -231,10 +233,11 @@ class FileProvider { /** * copy the folder recursively * @param {string} path is the folder to be copied over - * @param {string} destination is the destination folder + * @param {Function} visitFile is a function called for each visited files */ - copyFolderToJson (path) { - return this._copyFolderToJsonInternal(path) + copyFolderToJson (path, visitFile) { + visitFile = visitFile || (() => {}) + return this._copyFolderToJsonInternal(path, visitFile) } removeFile (path) { diff --git a/apps/remix-ide/src/app/files/workspaceFileProvider.js b/apps/remix-ide/src/app/files/workspaceFileProvider.js index 91f3227fbd..cc7368e0e2 100644 --- a/apps/remix-ide/src/app/files/workspaceFileProvider.js +++ b/apps/remix-ide/src/app/files/workspaceFileProvider.js @@ -48,9 +48,12 @@ class WorkspaceFileProvider extends FileProvider { }) } - async copyFolderToJson (directory) { - let json = await super._copyFolderToJsonInternal(directory) + async copyFolderToJson (directory, visitFile) { + visitFile = visitFile || (() => {}) const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g'); + let json = await super._copyFolderToJsonInternal(directory, ({ path, content }) => { + visitFile({ path: path.replace(regex, ''), content }) + }) json = JSON.stringify(json).replace(regex, '') return JSON.parse(json) } diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index bb2f513d10..729da26097 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -559,7 +559,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } 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? This also add an entry named 'project.json' which include all the folders and files.`, { + 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', fn: toGist }, { @@ -1059,35 +1059,20 @@ export const FileExplorer = (props: FileExplorerProps) => { export default FileExplorer -function packageFiles (filesProvider, directory, callback) { +async function packageFiles (filesProvider, directory, callback) { const ret = {} - filesProvider.resolveDirectory(directory, (error, files) => { - if (error) callback(error) - else { - async.eachSeries(Object.keys(files), (path, cb) => { - if (filesProvider.isDirectory(path)) { - cb() - } else { - filesProvider.get(path, (error, content) => { - if (error) return cb(error) - if (/^\s+$/.test(content) || !content.length) { - content = '// this line is added to create a gist. Empty file is not allowed.' - } - ret[path] = { content } - cb() - }) - } - }, async (error) => { - try { - const json = await filesProvider.copyFolderToJson(directory) - ret['project.json'] = { content: JSON.stringify(json, null, '\t') } - } catch (e) { - console.log(e) - } - callback(error, ret) - }) - } - }) + try { + await filesProvider.copyFolderToJson(directory, ({ path, content }) => { + if (/^\s+$/.test(content) || !content.length) { + content = '// this line is added to create a gist. Empty file is not allowed.' + } + path = path.replace(/\//g, '...') + ret[path] = { content } + }) + callback(null, ret) + } catch (e) { + return callback(e) + } } function joinPath (...paths) { From dd14a57284922010b14d07044c0ed22ce59a4bfe Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 09:43:22 +0100 Subject: [PATCH 11/18] better error message --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 5d6bdada62..790add9b69 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -587,7 +587,9 @@ export const FileExplorer = (props: FileExplorerProps) => { fn: () => {} }) } 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', fn: async () => {} }, null) From e4edff29408588ebc458d633fbe8e726ccabcfb3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 09:44:02 +0100 Subject: [PATCH 12/18] add the entire project to gist --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 790add9b69..51d92ac594 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -1077,7 +1077,13 @@ function packageFiles (filesProvider, directory, callback) { cb() }) } - }, (error) => { + }, async (error) => { + try { + const json = await filesProvider.copyFolderToJson(directory) + ret['project.json'] = { content: JSON.stringify(json, null, '\t') } + } catch (e) { + console.log(e) + } callback(error, ret) }) } From 7670a406108c4db9739a305b69ce3bc584a066d5 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:06:28 +0100 Subject: [PATCH 13/18] make sure workspace provider is removing the uneeded part of the paths --- apps/remix-ide/src/app/files/fileProvider.js | 15 ++++++++++++--- .../src/app/files/workspaceFileProvider.js | 7 +++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index adc5840dfd..70dbdc7aca 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -196,11 +196,11 @@ class FileProvider { } /** - * copy the folder recursively + * copy the folder recursively (internal use) * @param {string} path is the folder to be copied over * @param {string} destination is the destination folder */ - copyFolderToJson (path) { + _copyFolderToJsonInternal (path) { return new Promise((resolve, reject) => { const json = {} path = this.removePrefix(path) @@ -212,7 +212,7 @@ class FileProvider { const file = {} const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}` if (window.remixFileSystem.statSync(curPath).isDirectory()) { - file.children = await this.copyFolderToJson(curPath) + file.children = await this._copyFolderToJsonInternal(curPath) } else { file.content = window.remixFileSystem.readFileSync(curPath, 'utf8') } @@ -228,6 +228,15 @@ class FileProvider { }) } + /** + * copy the folder recursively + * @param {string} path is the folder to be copied over + * @param {string} destination is the destination folder + */ + copyFolderToJson (path) { + return this._copyFolderToJsonInternal(path) + } + removeFile (path) { path = this.removePrefix(path) if (window.remixFileSystem.existsSync(path) && !window.remixFileSystem.statSync(path).isDirectory()) { diff --git a/apps/remix-ide/src/app/files/workspaceFileProvider.js b/apps/remix-ide/src/app/files/workspaceFileProvider.js index 8522f5ff4c..91f3227fbd 100644 --- a/apps/remix-ide/src/app/files/workspaceFileProvider.js +++ b/apps/remix-ide/src/app/files/workspaceFileProvider.js @@ -48,6 +48,13 @@ class WorkspaceFileProvider extends FileProvider { }) } + async copyFolderToJson (directory) { + let json = await super._copyFolderToJsonInternal(directory) + const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g'); + json = JSON.stringify(json).replace(regex, '') + return JSON.parse(json) + } + _normalizePath (path) { if (!this.workspace) throw new Error('No workspace has been opened.') return path.replace(this.workspacesPath + '/' + this.workspace + '/', '') From 7525bd339490b68adfa24d56a342a26c9511ea32 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:11:54 +0100 Subject: [PATCH 14/18] update message --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 51d92ac594..7bdb3e3251 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -559,7 +559,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } 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? This also add an entry named 'project.json' which include all the folders and files.`, { label: 'OK', fn: toGist }, { From 9b9c48a494f93be922f7434e5e535246d069a3e3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 10:30:59 +0100 Subject: [PATCH 15/18] linting --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 7bdb3e3251..fed5580a7c 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -1080,7 +1080,7 @@ function packageFiles (filesProvider, directory, callback) { }, async (error) => { try { const json = await filesProvider.copyFolderToJson(directory) - ret['project.json'] = { content: JSON.stringify(json, null, '\t') } + ret['project.json'] = { content: JSON.stringify(json, null, '\t') } } catch (e) { console.log(e) } From cb38ae7c94ea8c719158445df68e564d31bed950 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 11:41:29 +0100 Subject: [PATCH 16/18] linting --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 729da26097..60176dcd2d 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -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 { ModalDialog } from '@remix-ui/modal-dialog' // eslint-disable-line import { Toaster } from '@remix-ui/toaster' // eslint-disable-line -import * as async from 'async' import Gists from 'gists' import { FileExplorerMenu } from './file-explorer-menu' // eslint-disable-line import { FileExplorerContextMenu } from './file-explorer-context-menu' // eslint-disable-line From b3d8ab25c8406be0289b71740d2e9b41c31490b2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 12:18:30 +0100 Subject: [PATCH 17/18] linting --- libs/remix-ui/file-explorer/src/lib/file-explorer.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx index 3dbe6b64cb..60176dcd2d 100644 --- a/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx +++ b/libs/remix-ui/file-explorer/src/lib/file-explorer.tsx @@ -558,11 +558,7 @@ export const FileExplorer = (props: FileExplorerProps) => { } const publishToGist = () => { -<<<<<<< HEAD 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?`, { -======= - 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? This also add an entry named 'project.json' which include all the folders and files.`, { ->>>>>>> 9b9c48a494f93be922f7434e5e535246d069a3e3 label: 'OK', fn: toGist }, { From 36f0b441b4ac66aadce3fe1544f7be15ec3abd86 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 17 Mar 2021 13:02:22 +0100 Subject: [PATCH 18/18] linting --- apps/remix-ide/src/app/files/fileProvider.js | 2 +- apps/remix-ide/src/app/files/workspaceFileProvider.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 3a2e85abd8..20a7135c12 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -200,7 +200,7 @@ class FileProvider { * @param {string} path is the folder to be copied over * @param {Function} visitFile is a function called for each visited files */ - _copyFolderToJsonInternal (path, visitFile) { + _copyFolderToJsonInternal (path, visitFile) { visitFile = visitFile || (() => {}) return new Promise((resolve, reject) => { const json = {} diff --git a/apps/remix-ide/src/app/files/workspaceFileProvider.js b/apps/remix-ide/src/app/files/workspaceFileProvider.js index cc7368e0e2..2b1a795d0b 100644 --- a/apps/remix-ide/src/app/files/workspaceFileProvider.js +++ b/apps/remix-ide/src/app/files/workspaceFileProvider.js @@ -50,10 +50,10 @@ class WorkspaceFileProvider extends FileProvider { async copyFolderToJson (directory, visitFile) { visitFile = visitFile || (() => {}) - const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g'); + const regex = new RegExp(`.workspaces/${this.workspace}/`, 'g') let json = await super._copyFolderToJsonInternal(directory, ({ path, content }) => { visitFile({ path: path.replace(regex, ''), content }) - }) + }) json = JSON.stringify(json).replace(regex, '') return JSON.parse(json) }