From cc15d358489e2fc4683ba12d876dc08a19fae0f4 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Thu, 25 Feb 2016 11:54:46 -0800 Subject: [PATCH] fix(plugin): better errors if plugins are malformed Fixed read assets --- .../assets/InMessage-Read@1x.png | Bin 0 -> 1383 bytes .../assets/InMessage-Read@2x.png | Bin 0 -> 1941 bytes .../lib/open-tracking-message-status.jsx | 3 ++- .../plugins/lib/packages-store.coffee | 18 ++++++++--------- src/package-manager.coffee | 19 ++++++++++++++++++ 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 internal_packages/open-tracking/assets/InMessage-Read@1x.png create mode 100644 internal_packages/open-tracking/assets/InMessage-Read@2x.png diff --git a/internal_packages/open-tracking/assets/InMessage-Read@1x.png b/internal_packages/open-tracking/assets/InMessage-Read@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..0ed393ff1ac8e306ab0698c1cb54cae380997a41 GIT binary patch literal 1383 zcmaJ>eM}o=7_XZ;K135Y4Fj3Sfe9qN-dC^fU8q2N?dY(q6p%((m4_k1U zV1$X;bRl!7Y}0Ih5Ht(uKkAkcaUgD(CCW0L3V&eYqL_uKG21fnEl}JaWS88%@B6&Z z?|FXD*9`<}cIRZ}WtmK-9A6b5gzNUyn{hw<>H*sCPa0pgQ| zRuBY&)Yb7dC^MP1_DAbOM#%pZC#teVNak%nRgJJIO?kJ@Q*>HRHC@hK)<5jU!28!Y1ohZDqNKuJnXf{IAjtE8rn}As* zn!>^i>A(nJ6CIQk2?HyewzC=D&D$I7d3Vp9*`MY8{w+;kD)$3I?mhOT;n`)@>HdRC1?$xRzC4NDSDk))Us!(fj^FWV2 z2PChq%E)S_x#%V=BBT}A!nBCNmBp-rL}Fo*vSSn}+9Os#0a1|9b-Z*(2G=?jN?;^f znh-~XBQ_gtXEBJDFp`8jffB4(L}CR8O)i@FJmab=%^n{-+EkLCUppB5_UOzL z*-x8`e+ZRiGQR|4-;ZepL$1$aFE{Uh%T-)j>dIZIyR<_z&za4~Z~pzw@jp-ebM9B? z2bX?ZPMUl7+p0}JF62CF{k?hl%G>>Bspx^i7o%#N?*Bt!B&DoG+er(_w?A+n1=3!6l z0_v?aU-gdEbnNTt%iaB0+30YS*!gMSmy)f|d*aAG&(9TGM~%@;ZpSt+aWG%T_bytl zU%ocQP6xKcZ*U!ll*_Zycdu-DJ@Rb)bi+lwQOq09Bkp^lg030wF9NqtZGXJtWBZYb z>gNw;y?1hin_g`2%ufxTR2K5(+bj3p{=6rHFs%%=JiM!^VOQ$c=kwI?XIw2W{s)|x B;!pqp literal 0 HcmV?d00001 diff --git a/internal_packages/open-tracking/assets/InMessage-Read@2x.png b/internal_packages/open-tracking/assets/InMessage-Read@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..db241f088f089e65c5971f03ea803afabb14de70 GIT binary patch literal 1941 zcmeAS@N?(olHy`uVBq!ia0vp^Y9P$P1|(P5zFY^SBuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFjr)TM3hAM`dB6B=jtVb)aX^@765fKFxc2v6eK2Rr0UTq__OB&@Hb09I0xZL0)vRD^GUf^&XRs)DJWnQpRynYn_wrJkXw zxw(nCj)IYap{c%svA(f^u92~oiGh`gkpdJb0c|TvNwW%aaf8|g1^l#~=$>Fbx5 zm+O@q>*W`v>l<2HTIw4Z=^Gj80#)c1SLT%@R_NvxE5l51Ni9w;$}A|!%+FH*nV6WA zUs__T1av9H3%LcpzHo!{ilG4o3^M(S!~%UoJp=vRT#&!Os*6j4QW4I;s=7F&vLIDI zD784hv?v)EA8E=k&A_n3ZxKi#&^1>6MVY`zNz8G{PcF?(%`5SAu~h=f=%r+)SeY7I zrWqSsr0E)`nkDL*q!=6NCYc&q=o+M&C0iJ!q$Q=ASi;P~rr+7c%)-gc+|k9v(8bWu z)zre&(#grx)WX2P(cIA4&=jWEGq1QLF)uk4W_KpgZm3>Myn3yii&7Iy@{2<9^K)RS zARr^ZB)>Q#zd*s+864{h8or6inRy^VO;A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/open-tracking-message-status.jsx b/internal_packages/open-tracking/lib/open-tracking-message-status.jsx index 556e57a2f..4b38bb59a 100644 --- a/internal_packages/open-tracking/lib/open-tracking-message-status.jsx +++ b/internal_packages/open-tracking/lib/open-tracking-message-status.jsx @@ -37,7 +37,8 @@ export default class OpenTrackingMessageStatus extends React.Component { return ( ); } diff --git a/internal_packages/plugins/lib/packages-store.coffee b/internal_packages/plugins/lib/packages-store.coffee index 3f5838ed1..1e1ab4aa6 100644 --- a/internal_packages/plugins/lib/packages-store.coffee +++ b/internal_packages/plugins/lib/packages-store.coffee @@ -173,15 +173,13 @@ PackagesStore = Reflux.createStore properties: ['openDirectory'] , (filenames) => return if not filenames or filenames.length is 0 - NylasEnv.packages.installPackageFromPath filenames[0], (err, packageTargetDir) => + NylasEnv.packages.installPackageFromPath filenames[0], (err) => return if err packageName = path.basename(filenames[0]) msg = "#{packageName} has been installed and enabled. No need to \ restart! If you don't see the package loaded, check the \ console for errors." - @_displayMessage("Package installed", msg) - if packageTargetDir - shell.showItemInFolder(packageTargetDir) + @_displayMessage("Plugin installed 🎉", msg) _onCreatePackage: -> if not NylasEnv.inDevMode() @@ -210,19 +208,19 @@ PackagesStore = Reflux.createStore packageName = path.basename(packageDir) if not packageDir.startsWith(packagesDir) - return @_displayMessage('Invalid package location', 'Sorry, you must - create packages in the packages folder.') + return @_displayMessage('Invalid plugin location', 'Sorry, you must + create plugins in the packages folder.') if NylasEnv.packages.resolvePackagePath(packageName) - return @_displayMessage('Invalid package name', 'Sorry, you must - give your package a unqiue name.') + return @_displayMessage('Invalid plugin name', 'Sorry, you must + give your plugin a unqiue name.') if packageName.indexOf(' ') isnt -1 - return @_displayMessage('Invalid package name', 'Sorry, package names + return @_displayMessage('Invalid plugin name', 'Sorry, plugin names cannot contain spaces.') fs.mkdir packageDir, (err) => - return @_displayMessage('Could not create package', err.toString()) if err + return @_displayMessage('Could not create plugin', err.toString()) if err {resourcePath} = NylasEnv.getLoadSettings() packageTemplatePath = path.join(resourcePath, 'static', 'package-template') diff --git a/src/package-manager.coffee b/src/package-manager.coffee index 227d755ec..1be4f5b16 100644 --- a/src/package-manager.coffee +++ b/src/package-manager.coffee @@ -6,6 +6,7 @@ EmitterMixin = require('emissary').Emitter fs = require 'fs-plus' Q = require 'q' Grim = require 'grim' +CSON = require 'season' ServiceHub = require 'service-hub' Package = require './package' @@ -338,6 +339,8 @@ class PackageManager dialog = require('remote').require('dialog') shell = require('shell') + return unless @verifyValidPackage(packageSourceDir, callback) + packagesDir = path.join(NylasEnv.getConfigDirPath(), 'packages') packageName = path.basename(packageSourceDir) packageTargetDir = path.join(packagesDir, packageName) @@ -376,6 +379,22 @@ class PackageManager @activatePackage(packageName) callback(null, packageTargetDir) + verifyValidPackage: (packageSourceDir, callback) -> + if CSON.resolve(path.join(packageSourceDir, 'package')) + return true + else + errMsg = "The folder you selected doesn't look like a valid N1 plugin. All N1 plugins must have a package.json file in the top level of the folder. Check the contents of #{packageSourceDir} and try again" + + dialog = require('remote').require('dialog') + dialog.showMessageBox({ + type: 'warning' + buttons: ['OK'] + title: 'Not a valid plugin folder' + message: errMsg + }) + + callback(errMsg) + return false ### Section: Private ###