Skip to content

Commit dfbc9b6

Browse files
committed
deploy: bd41e8d
1 parent c3d6f1d commit dfbc9b6

96 files changed

Lines changed: 854 additions & 610 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎assets/default-project/en.zip‎

0 Bytes
Binary file not shown.

‎assets/sample-projects/HTML5.zip‎

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

‎assets/sample-projects/explore.zip‎

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

‎config.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"extension_url": "https://s3.amazonaws.com/extend.brackets/{0}/{0}-{1}.zip",
2020
"extension_store_url": "https://store.core.ai/src/",
2121
"linting.enabled_by_default": true,
22-
"build_timestamp": "2022-06-30T10:30:55.948Z",
22+
"build_timestamp": "2022-07-02T08:10:33.817Z",
2323
"googleAnalyticsID": "G-FP5S9BKDSJ",
2424
"mixPanelID": "a7e08ffd43c37767c29b13df1d2e6c62",
2525
"coreAnalyticsID": "phoenix",

‎extensions/default/Phoenix-live-preview/utils.js‎

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,27 @@ define(function (require, exports, module) {
6565
}
6666

6767
async function _getDefaultPreviewDetails() {
68-
return new Promise(async (resolve)=>{
69-
let projectRoot = ProjectManager.getProjectRoot().fullPath;
70-
const projectRootUrl = `${window.fsServerUrl}${projectRoot}`;
71-
let indexFiles = ['index.html', "index.htm"];
72-
for(let indexFile of indexFiles){
73-
let file = FileSystem.getFileForPath(`${projectRoot}${indexFile}`);
74-
if(await file.existsAsync()){
75-
const relativePath = path.relative(projectRoot, file.fullPath);
76-
resolve({
77-
URL: `${projectRootUrl}${relativePath}`,
78-
filePath: relativePath
79-
});
80-
return;
68+
return new Promise(async (resolve, reject)=>{ // eslint-disable-line
69+
// async is explicitly caught
70+
try{
71+
let projectRoot = ProjectManager.getProjectRoot().fullPath;
72+
const projectRootUrl = `${window.fsServerUrl}${projectRoot}`;
73+
let indexFiles = ['index.html', "index.htm"];
74+
for(let indexFile of indexFiles){
75+
let file = FileSystem.getFileForPath(`${projectRoot}${indexFile}`);
76+
if(await file.existsAsync()){
77+
const relativePath = path.relative(projectRoot, file.fullPath);
78+
resolve({
79+
URL: `${projectRootUrl}${relativePath}`,
80+
filePath: relativePath
81+
});
82+
return;
83+
}
8184
}
85+
resolve({URL: getNoPreviewURL()});
86+
} catch (e) {
87+
reject(e);
8288
}
83-
resolve({URL: getNoPreviewURL()});
8489
});
8590
}
8691

@@ -90,30 +95,35 @@ define(function (require, exports, module) {
9095
* @return {Promise<*>}
9196
*/
9297
async function getPreviewDetails() {
93-
return new Promise(async (resolve)=>{
94-
const projectRoot = ProjectManager.getProjectRoot().fullPath;
95-
const projectRootUrl = `${window.fsServerUrl}${projectRoot}`;
96-
const currentDocument = DocumentManager.getCurrentDocument();
97-
const currentFile = currentDocument? currentDocument.file : ProjectManager.getSelectedItem();
98-
if(currentFile){
99-
let fullPath = currentFile.fullPath;
100-
let httpFilePath = null;
101-
if(fullPath.startsWith("http://") || fullPath.startsWith("https://")){
102-
httpFilePath = fullPath;
103-
}
104-
if(_isPreviewableFile(fullPath)){
105-
const filePath = httpFilePath || path.relative(projectRoot, fullPath);
106-
resolve({
107-
URL: httpFilePath || `${projectRootUrl}${filePath}`,
108-
filePath: filePath,
109-
fullPath: fullPath,
110-
isMarkdownFile: _isMarkdownFile(fullPath)
111-
});
112-
} else {
113-
resolve({}); // not a previewable file
98+
return new Promise(async (resolve, reject)=>{ // eslint-disable-line
99+
// async is explicitly caught
100+
try {
101+
const projectRoot = ProjectManager.getProjectRoot().fullPath;
102+
const projectRootUrl = `${window.fsServerUrl}${projectRoot}`;
103+
const currentDocument = DocumentManager.getCurrentDocument();
104+
const currentFile = currentDocument? currentDocument.file : ProjectManager.getSelectedItem();
105+
if(currentFile){
106+
let fullPath = currentFile.fullPath;
107+
let httpFilePath = null;
108+
if(fullPath.startsWith("http://") || fullPath.startsWith("https://")){
109+
httpFilePath = fullPath;
110+
}
111+
if(_isPreviewableFile(fullPath)){
112+
const filePath = httpFilePath || path.relative(projectRoot, fullPath);
113+
resolve({
114+
URL: httpFilePath || `${projectRootUrl}${filePath}`,
115+
filePath: filePath,
116+
fullPath: fullPath,
117+
isMarkdownFile: _isMarkdownFile(fullPath)
118+
});
119+
} else {
120+
resolve({}); // not a previewable file
121+
}
114122
}
123+
resolve(await _getDefaultPreviewDetails());
124+
}catch (e) {
125+
reject(e);
115126
}
116-
resolve(await _getDefaultPreviewDetails());
117127
});
118128
}
119129

‎extensions/default/Phoenix/new-project.js‎

Lines changed: 88 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ define(function (require, exports, module) {
143143
}
144144

145145
async function _validateProjectFolder(projectPath) {
146-
return new Promise(async (resolve, reject)=>{
146+
return new Promise((resolve, reject)=>{
147147
let dir = FileSystem.getDirectoryForPath(projectPath);
148148
let displayPath = projectPath.replace(Phoenix.VFS.getMountDir(), "");
149149
if(!dir){
@@ -177,45 +177,54 @@ define(function (require, exports, module) {
177177
}
178178

179179
async function _findFreeFolderName(basePath) {
180-
return new Promise(async (resolve, reject)=>{
181-
for(let i=0; i< MAX_DEDUPE_COUNT; i++){
182-
let newPath = `${basePath}-${i}`;
183-
let exists = await window.Phoenix.VFS.existsAsync(newPath);
184-
if(!exists){
185-
await window.Phoenix.VFS.ensureExistsDirAsync(newPath);
186-
resolve(newPath);
187-
return;
180+
return new Promise(async (resolve, reject)=>{ // eslint-disable-line
181+
try {
182+
for(let i=0; i< MAX_DEDUPE_COUNT; i++){
183+
let newPath = `${basePath}-${i}`;
184+
let exists = await window.Phoenix.VFS.existsAsync(newPath);
185+
if(!exists){
186+
await window.Phoenix.VFS.ensureExistsDirAsync(newPath);
187+
resolve(newPath);
188+
return;
189+
}
188190
}
191+
reject();
192+
} catch (e) {
193+
reject(e);
189194
}
190-
reject();
191195
});
192196
}
193197

194198
async function alreadyExists(suggestedProjectName) {
195199
let projectPath = `${ProjectManager.getLocalProjectsPath()}${suggestedProjectName}`; // try suggested path first
196-
return await window.Phoenix.VFS.existsAsync(projectPath);
200+
return window.Phoenix.VFS.existsAsync(projectPath);
197201
}
198202

199203
async function _getSuggestedProjectDir(suggestedProjectName) {
200-
return new Promise(async (resolve, reject)=>{
201-
let projectPath = `${ProjectManager.getLocalProjectsPath()}${suggestedProjectName}`; // try suggested path first
202-
let exists = await window.Phoenix.VFS.existsAsync(projectPath);
203-
if(!exists){
204-
resolve(projectPath);
205-
return;
206-
}
207-
_showReplaceKeepProjectConfirmDialogue(suggestedProjectName).done(function (id) {
208-
if (id === Dialogs.DIALOG_BTN_OK) {
204+
return new Promise(async (resolve, reject)=>{ // eslint-disable-line
205+
try{
206+
// try suggested path first
207+
let projectPath = `${ProjectManager.getLocalProjectsPath()}${suggestedProjectName}`;
208+
let exists = await window.Phoenix.VFS.existsAsync(projectPath);
209+
if(!exists){
209210
resolve(projectPath);
210211
return;
211-
} else if(id === Dialogs.DIALOG_BTN_CANCEL){
212-
reject();
213-
return;
214212
}
215-
_findFreeFolderName(projectPath)
216-
.then(projectPath=>resolve(projectPath))
217-
.catch(reject);
218-
});
213+
_showReplaceKeepProjectConfirmDialogue(suggestedProjectName).done(function (id) {
214+
if (id === Dialogs.DIALOG_BTN_OK) {
215+
resolve(projectPath);
216+
return;
217+
} else if(id === Dialogs.DIALOG_BTN_CANCEL){
218+
reject();
219+
return;
220+
}
221+
_findFreeFolderName(projectPath)
222+
.then(projectPath=>resolve(projectPath))
223+
.catch(reject);
224+
});
225+
} catch (e) {
226+
reject(e);
227+
}
219228
});
220229
}
221230

@@ -267,55 +276,61 @@ define(function (require, exports, module) {
267276
* @returns {Promise<void>}
268277
*/
269278
async function downloadAndOpenProject(downloadURL, projectPath, suggestedProjectName, flattenFirstLevelInZip) {
270-
return new Promise(async (resolve, reject)=>{
271-
// if project path is null, create one in default folder
272-
if(!projectPath){
273-
projectPath = await _getSuggestedProjectDir(suggestedProjectName);
274-
} else {
275-
await _validateProjectFolder(projectPath);
276-
}
277-
console.log(`downloadAndOpenProject ${suggestedProjectName} from URL: ${downloadURL} to: ${projectPath}`);
278-
279-
downloadCancelled = false;
280-
_showCreateProjectDialogue(Strings.SETTING_UP_PROJECT, Strings.DOWNLOADING).done(function (id) {
281-
if (id === Dialogs.DIALOG_BTN_CANCEL) {
282-
downloadCancelled = true;
279+
return new Promise(async (resolve, reject)=>{ // eslint-disable-line
280+
try {
281+
// if project path is null, create one in default folder
282+
if(!projectPath){
283+
projectPath = await _getSuggestedProjectDir(suggestedProjectName);
284+
} else {
285+
await _validateProjectFolder(projectPath);
283286
}
284-
});
285-
window.JSZipUtils.getBinaryContent(downloadURL, {
286-
callback: async function(err, data) {
287-
if(downloadCancelled){
288-
reject();
289-
} else if(err) {
290-
console.error("could not load phoenix default project from zip file!", err);
291-
_closeCreateProjectDialogue();
292-
showErrorDialogue(Strings.DOWNLOAD_FAILED, Strings.DOWNLOAD_FAILED_MESSAGE);
293-
reject();
294-
} else {
295-
_unzipProject(data, projectPath, flattenFirstLevelInZip)
296-
.then(()=>{
297-
_closeCreateProjectDialogue();
298-
ProjectManager.openProject(projectPath)
299-
.then(resolve)
300-
.fail(reject);
301-
console.log("Project Setup complete: ", projectPath);
302-
})
303-
.catch(()=>{
304-
_closeCreateProjectDialogue();
305-
showErrorDialogue(Strings.ERROR_LOADING_PROJECT, Strings.UNZIP_FAILED);
306-
reject();
307-
});
287+
console.log(
288+
`downloadAndOpenProject ${suggestedProjectName} from URL: ${downloadURL} to: ${projectPath}`);
289+
290+
downloadCancelled = false;
291+
_showCreateProjectDialogue(Strings.SETTING_UP_PROJECT, Strings.DOWNLOADING).done(function (id) {
292+
if (id === Dialogs.DIALOG_BTN_CANCEL) {
293+
downloadCancelled = true;
308294
}
309-
},
310-
progress: function (status){
311-
if(status.percent > 0){
312-
_updateCreateProjectDialogueMessage(`${Strings.DOWNLOADING} ${Math.round(status.percent)}%`);
295+
});
296+
window.JSZipUtils.getBinaryContent(downloadURL, {
297+
callback: async function(err, data) {
298+
if(downloadCancelled){
299+
reject();
300+
} else if(err) {
301+
console.error("could not load phoenix default project from zip file!", err);
302+
_closeCreateProjectDialogue();
303+
showErrorDialogue(Strings.DOWNLOAD_FAILED, Strings.DOWNLOAD_FAILED_MESSAGE);
304+
reject();
305+
} else {
306+
_unzipProject(data, projectPath, flattenFirstLevelInZip)
307+
.then(()=>{
308+
_closeCreateProjectDialogue();
309+
ProjectManager.openProject(projectPath)
310+
.then(resolve)
311+
.fail(reject);
312+
console.log("Project Setup complete: ", projectPath);
313+
})
314+
.catch(()=>{
315+
_closeCreateProjectDialogue();
316+
showErrorDialogue(Strings.ERROR_LOADING_PROJECT, Strings.UNZIP_FAILED);
317+
reject();
318+
});
319+
}
320+
},
321+
progress: function (status){
322+
if(status.percent > 0){
323+
_updateCreateProjectDialogueMessage(
324+
`${Strings.DOWNLOADING} ${Math.round(status.percent)}%`);
325+
}
326+
},
327+
abortCheck: function (){
328+
return downloadCancelled;
313329
}
314-
},
315-
abortCheck: function (){
316-
return downloadCancelled;
317-
}
318-
});
330+
});
331+
} catch (e) {
332+
reject(e);
333+
}
319334
});
320335
}
321336

‎extensions/default/Phoenix/utils.js‎

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,34 @@ define(function (require, exports, module) {
3535
}
3636

3737
function _copyZippedItemToFS(path, item, destProjectDir, flattenFirstLevel) {
38-
return new Promise(async (resolve, reject) =>{
39-
let destPath = `${destProjectDir}${path}`;
40-
if(flattenFirstLevel){
41-
// contents/index.html to index.html
42-
let newPath = path.substr(path.indexOf("/") + 1);
43-
destPath = `${destProjectDir}${newPath}`;
44-
console.log(destPath);
45-
}
46-
if(item.dir){
47-
await _ensureExistsAsync(destPath);
48-
resolve(destPath);
49-
} else {
50-
await _ensureExistsAsync(window.path.dirname(destPath));
51-
item.async("uint8array").then(function (data) {
52-
window.fs.writeFile(destPath, Filer.Buffer.from(data), writeErr=>{
53-
if(writeErr){
54-
reject(writeErr);
55-
} else {
56-
resolve(destPath);
57-
}
38+
return new Promise(async (resolve, reject) =>{ // eslint-disable-line
39+
try {
40+
let destPath = `${destProjectDir}${path}`;
41+
if(flattenFirstLevel){
42+
// contents/index.html to index.html
43+
let newPath = path.substr(path.indexOf("/") + 1);
44+
destPath = `${destProjectDir}${newPath}`;
45+
console.log(destPath);
46+
}
47+
if(item.dir){
48+
await _ensureExistsAsync(destPath);
49+
resolve(destPath);
50+
} else {
51+
await _ensureExistsAsync(window.path.dirname(destPath));
52+
item.async("uint8array").then(function (data) {
53+
window.fs.writeFile(destPath, Filer.Buffer.from(data), writeErr=>{
54+
if(writeErr){
55+
reject(writeErr);
56+
} else {
57+
resolve(destPath);
58+
}
59+
});
60+
}).catch(error=>{
61+
reject(error);
5862
});
59-
}).catch(error=>{
60-
reject(error);
61-
});
63+
}
64+
} catch (e) {
65+
reject(e);
6266
}
6367
});
6468
}

0 commit comments

Comments
 (0)