From 0212f49c83a9eec9fd777bd0d8f3f98af9d5d5e9 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Tue, 19 Jul 2016 01:17:21 -0300 Subject: [PATCH] Close #1061. Help Debug Editor command creates Gist (no Clipboard) --- ISSUE_TEMPLATE.md | 25 +++------ docs/troubleshooting.md | 12 ++++- .../javascript/expected/test.js | 2 +- .../javascript/original/test.js | 2 +- package.json | 4 +- src/beautify.coffee | 53 +++++++++++++++---- 6 files changed, 65 insertions(+), 33 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 583399c..fbc892e 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,8 +1,8 @@ -### Description +# Description The results of beautification are not what I expect. -### Expected Results +# Expected Results The beautified code should have looked like: @@ -10,33 +10,20 @@ The beautified code should have looked like: ``` -### Steps to Reproduce +# Steps to Reproduce 1. Add code to Atom editor 2. Run command `Atom Beautify: Beautify Editor` 3. This beautified code does not look right! -### Debug +# Debug -Here is a link to the `debug.md` Gist: https://gist.github.com/... - -#### How to create `debug.md` Gist - -Note that this will include a copy of your code. -If your code is private, please create a different sample of code that reproduces the problem. - -1. In the Atom [command-palette](https://atom.io/packages/command-palette), -search for and run the command `Atom Beautify: Help Debug Editor`. -The debugging results will be copied to your clipboard. -2. Create a new Gist at https://gist.github.com/ -3. Create a file in your new Gist called `debug.md`. -4. Paste your debugging results from Atom beautify into `debug.md` file in your Gist. -5. Add a link to your Gist in your new Issue. +Here is a link to the `debug.md` Gist: # Checklist - [ ] I have tried uninstalling and reinstalling Atom Beautify to ensure it installed properly - [ ] I have reloaded (or restarted) Atom to ensure it is not a caching issue -- [ ] Searched for existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues +- [ ] Searched for existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues so I know this is not a duplicate issue - [ ] Generated debugging information and added link for `debug.md` Gist to this issue diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 88566ef..d0bdc8b 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -1,4 +1,14 @@ # Troubleshooting -Coming soon. +## How to create `debug.md` Gist +Note that this will include a copy of your code. +If your code is private, please create a different sample of code that reproduces the problem. + +1. In the Atom [command-palette](https://atom.io/packages/command-palette), +search for and run the command `Atom Beautify: Help Debug Editor`. +The debugging results will be copied to your clipboard. +2. Create a new Gist at https://gist.github.com/ +3. Create a file in your new Gist called `debug.md`. +4. Paste your debugging results from Atom beautify into `debug.md` file in your Gist. +5. Add a link to your Gist in your new Issue. diff --git a/examples/nested-jsbeautifyrc/javascript/expected/test.js b/examples/nested-jsbeautifyrc/javascript/expected/test.js index 3e097da..a9ec7a8 100644 --- a/examples/nested-jsbeautifyrc/javascript/expected/test.js +++ b/examples/nested-jsbeautifyrc/javascript/expected/test.js @@ -1,3 +1,3 @@ -function hell() { +function hello() { console.log('world'); } \ No newline at end of file diff --git a/examples/nested-jsbeautifyrc/javascript/original/test.js b/examples/nested-jsbeautifyrc/javascript/original/test.js index 068dc1b..5839d6e 100644 --- a/examples/nested-jsbeautifyrc/javascript/original/test.js +++ b/examples/nested-jsbeautifyrc/javascript/original/test.js @@ -1,3 +1,3 @@ -function hell() { +function hello() { console.log('world'); } diff --git a/package.json b/package.json index fa96488..fc9a404 100644 --- a/package.json +++ b/package.json @@ -114,6 +114,7 @@ "expand-home-dir": "0.0.3", "extend": "^3.0.0", "gherkin": "2.12.2", + "github": "^2.2.0", "handlebars": "^4.0.2", "js-beautify": "^1.6.3", "jscs": "^3.0.7", @@ -122,6 +123,7 @@ "marko-prettyprint": "^1.1.8", "node-dir": "^0.1.15", "node-uuid": "^1.4.3", + "open": "0.0.5", "prettydiff": "^1.16.27", "pug-beautify": "^0.1.1", "remark": "^4.2.2", @@ -268,4 +270,4 @@ "lint": "coffeelint src/ spec/", "code-docs": "codo && open docs/code/index.html" } -} \ No newline at end of file +} diff --git a/src/beautify.coffee b/src/beautify.coffee index 6930917..3589537 100644 --- a/src/beautify.coffee +++ b/src/beautify.coffee @@ -282,6 +282,11 @@ beautifyDirectory = ({target}) -> debug = () -> + open = require("open") + fs ?= require "fs" + GitHubApi = require("github") + github = new GitHubApi() + plugin.checkUnsupportedOptions() # Get current editor @@ -297,8 +302,11 @@ debug = () -> if not editor? return confirm("Active Editor not found.\n" + "Please select a Text Editor first to beautify.") - return unless confirm('Are you ready to debug Atom Beautify?\n\n' + - 'Warning: This will change your current clipboard contents.') + return unless confirm('Are you ready to debug Atom Beautify?\n\n'+ + 'Warning: This will create an anonymous Gist on GitHub (publically accessible and cannot be easily deleted) '+ + 'containing the contents of your active Text Editor.\n'+ + 'Be sure to delete any private text from your active Text Editor before continuing '+ + 'to ensure you are not sharing undesirable private information.') debugInfo = "" headers = [] tocEl = "" @@ -465,14 +473,39 @@ debug = () -> debugInfo = debugInfo.replace(tocEl, toc) # Save to clipboard - atom.clipboard.write(debugInfo) - confirm('Atom Beautify debugging information is now in your clipboard.\n' + - 'You can now paste this into an Issue you are reporting here\n' + - 'https://github.com/Glavin001/atom-beautify/issues/\n\n' + - 'Please follow the contribution guidelines found at\n' + - 'https://github.com/Glavin001/atom-beautify/blob/master/CONTRIBUTING.md\n\n' + - 'Warning: Be sure to look over the debug info before you send it, '+ - 'to ensure you are not sharing undesirable private information.' + # atom.clipboard.write(debugInfo) + github.gists.create({ + files: { + "debug.md": { + "content": debugInfo + } + }, + public: true, + description: "Atom-Beautify debugging information" + }, (err, res) -> + # console.log(err, res) + if err + confirm("An error occurred when creating the Gist: "+err) + else + gistUrl = res.html_url + # Create Gist + open(gistUrl) + confirm("Your Atom Beautify debugging information can be found in the public Gist:\n#{res.html_url}\n\n" + + # 'You can now paste this into an Issue you are reporting here\n' + + # 'https://github.com/Glavin001/atom-beautify/issues/\n\n' + + # 'Please follow the contribution guidelines found at\n' + + # 'https://github.com/Glavin001/atom-beautify/blob/master/CONTRIBUTING.md\n\n' + + 'Warning: Be sure to look over the debug info before you send it '+ + 'to ensure you are not sharing undesirable private information.\n\n'+ + 'If you want to delete this anonymous Gist read\n'+ + 'https://help.github.com/articles/deleting-an-anonymous-gist/' + ) + # Create GitHub Issue + return unless confirm("Would you like to create a new Issue on GitHub now?") + issueTemplate = fs.readFileSync(path.resolve(__dirname, "../ISSUE_TEMPLATE.md")).toString() + body = issueTemplate.replace("", gistUrl)#.replace("", text) + open("https://github.com/Glavin001/atom-beautify/issues/new?body=#{encodeURIComponent(body)}") + ) try beautifier.beautify(text, allOptions, grammarName, filePath)