protected override void OnUpdate(CommandInfo info) { try { if (IdeApp.ProjectOperations.CurrentSelectedItem is ProjectFolder currentFolder && currentFolder.IsDocumentDirectoryBundle() ) { var manifestFilePath = Path.Combine(currentFolder.Path.FullPath, FigmaBundle.ManifestFileName); if (!File.Exists(manifestFilePath)) { throw new FileNotFoundException(manifestFilePath); } var manifest = FigmaManifest.FromFilePath(manifestFilePath); if (manifest.FileId != null) { info.Visible = info.Enabled = true; return; } } ; } catch (Exception ex) { Console.WriteLine(ex); } info.Visible = info.Enabled = false; }
protected override void OnRun() { if (IdeApp.ProjectOperations.CurrentSelectedItem is ProjectFolder currentFolder) { try { var manifestFilePath = Path.Combine(currentFolder.Path.FullPath, FigmaBundle.ManifestFileName); var manifest = FigmaManifest.FromFilePath(manifestFilePath); if (manifest.FileId != null) { IdeServices.DesktopService.ShowUrl(string.Format(figmaUrl, manifest.FileId)); return; } } catch (Exception ex) { LoggingService.LogInternalError(ex); } } }
public void ManifestTest() { var DocumentUrl = "https://www.figma.com/file/fKugSkFGdwOF4vDsPGnJee/"; var RemoteApiVersion = "1.1"; var DocumentVersion = "0.3"; var dateNow = DateTime.Now; var manifest = new FigmaManifest() { Date = dateNow, FileId = DocumentUrl, DocumentVersion = DocumentVersion, RemoteApiVersion = RemoteApiVersion, }; var builder = new StringBuilder(); manifest.ToComment(builder); Assert.IsNotEmpty(builder.ToString()); var tempDirectory = Path.GetTempPath(); var file = Path.Combine(tempDirectory, "manifest"); if (File.Exists(file)) { File.Delete(file); } manifest.Save(file); var copy = FigmaManifest.FromFilePath(file); Assert.AreEqual(copy.DocumentVersion, manifest.DocumentVersion); Assert.AreEqual(copy.Date, manifest.Date); Assert.AreEqual(copy.FileId, manifest.FileId); Assert.AreEqual(copy.RemoteApiVersion, manifest.RemoteApiVersion); if (File.Exists(file)) { File.Delete(file); } }