GithubHelp home page GithubHelp logo

gistup's Introduction

Gistup

Create a gist from the command line! Then just use git to update it.

For more, read the tutorial: Let’s Make a Block.

Installation

npm install -g gistup

The first time you run gistup, you’ll be prompted to create a GitHub personal access token. You can revoke the token in the future from your GitHub developer settings.

Usage

To upload all files in the current directory to your new gist:

gistup

If you just want to create a gist from a single file, try this instead:

gistup index.html

If you specify any options, such as a private gist, you must separate files from options with a double-dash (--) like this:

gistup --private -- index.html

If you want to update your gist later, just use git:

edit index.html
git commit -m 'Made some awesome changes.'
git push

Gistup works with binary files, too!

Arguments:

  • --description, -m - provide an optional description
  • --interactive, -i - request confirmation of every file before adding
  • --exclude, -x - skip files matching pattern; may use wildcards
  • --private, --no-public - make a secret gist
  • --open [url] - specify the URL to open after creating the gist
  • --no-open - don’t open the created gist in your web browser when done
  • --remote - specify the name of the git remote
  • --help - show some help
  • --version - print the current version of gistup

Gistup comes bundled with two helper programs: gistup-rename and gistup-open. Use gistup-rename "description of gist" to update the description of the gist in the current directory and gistup-open to open it for viewing in your default browser.

Troubleshooting

If you see the following error:

Error: Command failed: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

You probably need to generate your SSH keys for GitHub. These keys give you permission to git push to your repositories, including Gists.

If you’re unable to follow the first-time setup to create a personal access token, you can create a new access token by hand. The only required permission is "gist". You can then create a .gistup.json file in your home directory, with the following contents:

{
  "token": "0123456789012345678901234567890123456789"
}

Replace the numbers 0123456789… with your access token and save.

gistup's People

Contributors

1wheel avatar ajcrites avatar ecgan avatar joyrexus avatar mbostock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gistup's Issues

CLI option for browsing/opening existing gistup-generated gist

For your standard github repos you can use git browse to open/browse the repo's remote via Github's web interface. However, you can't use the browse subcommand to open gist-based repos (i.e., repos with remotes on gist.github.com).

I was expecting gistup's --open option to do this, but if you try running gistup --open in a directory that's already been gisted, you get ...

Reinitialized existing Git repository in /Users/jvoigt/Repos/gists/demo-gist/.git/
ERROR: the remote "origin" already exists.

Are you trying to run gistup in a directory that already has a git
repository?

Perhaps gistup could write a .gist.url file after initializing the gist's repo and look for this when the --open option is invoked?

FWIW, I'm currently using the following alias/hack for this purpose:

alias browse='open $(git config remote.origin.url | tr '\'':'\'' / | sed -e '\''s#git@#https://#'\'' -e '\''s/\.git$//'\'')'

If origin exists, throws error

Getting the error below.

The error seems to fail in "gitRemoteDoesNotExist", but the error is that the remote origin already exists.

/usr/local/lib/node_modules/gistup/bin/gistup:80
  if (error) throw error;
                   ^
Error: the remote "origin" already exists.
    at /usr/local/lib/node_modules/gistup/bin/gistup:154:82
    at ChildProcess.exithandler (child_process.js:538:7)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at maybeClose (child_process.js:638:16)
    at Socket.ChildProcess.spawn.stdin (child_process.js:825:11)
    at Socket.EventEmitter.emit (events.js:88:17)
    at Socket._destroy.destroyed (net.js:357:10)
    at process.startup.processNextTick.process._tickCallback (node.js:325:13)
    at process.startup.processMakeCallback.process._makeCallback (node.js:253:15)

README doesn't explain how to not add files to your repo

I made my repo first and then used gistup, but it added other files to my repo, and then made a commit, before posting a gist.

It was intuitive to me that if I had an existing git repo, it wouldn't add any files to my repo.

If there is an option for not adding any files, it's not in the README :(

Default ignore list

This is such a great tool. Is there an easy way to tell gistup to always ignore certain files, e.g. .DS_Store?

How to change gist name in terminal?

How to change a gist name (or gist description) in terminal?
When use gist up, the name (or ID) is automatically created (e.g. a7153f66879a11baaabb) and
the block name in bl.ock.org is also set to that code, before changing the gist description manually in the web.

I know this question may not be written in issue tab.

Getting Error: invalid gist id: undefined

When trying to use the module (v 0.0.10) I get this error:

/usr/local/lib/node_modules/gistup/bin/gistup:85
    throw error;
          ^
Error: invalid gist id: undefined
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/gistup/bin/gistup:248:69)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)  

How can I fix this?

Default ignore files (feature request)

This is more a feature request.
Would it be possible to set some basic ignore files in .gistup.json?
On Mac the .DS_Store gets added to the version control.
I added an alias to my .bash_profile to create a .gitignore file in the folder

alias gistup='echo ".DS_Store" > .gitignore;gistup'

but that makes the naming of the gist ugly (see the image)
screenshot

I could remove the .DS_Store with an alias, but I think everybody else on Mac will have the same problem.

Option to sign the initial commit?

It would be nice to include the ability to gpg sign the initial gist commit. Something equivalent to git commit -S -m 'initial commit'.

gistup will not upload file

the .gistup.json file is in my home directory with correct api key. I set it up with rights to gist.

Here is the error message I get:

$ gistup test_v1.yaml 
Initialized empty Git repository in /home/garret/projects/webmap/server/tangram_styles/.git/
[master (root-commit) 48671ed] Initial gistup commit.
 1 file changed, 5597 insertions(+)
 create mode 100644 fpdcc_v1.yaml
gist 2162c96304134b437f79ef4d7f9a644a created!
https://gist.github.com/2162c96304134b437f79ef4d7f9a644a
/home/garret/.nvm/versions/node/v7.7.3/lib/node_modules/gistup/lib/gistup/unless.js:11
    throw error;
    ^

Error: Command failed: git push -fu 'origin' master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at ChildProcess.exithandler (child_process.js:210:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Any thoughts on what might be wrong?

UserError is not defined

Hello!

I'm currently trying to set up gistup and it is returning this error after I input a personal access token:

node:internal/readline/emitKeypressEvents:74
throw err;
^

ReferenceError: UserError is not defined
at /Users/janicechen/.nvm/versions/node/v17.1.0/lib/node_modules/gistup/lib/gistup/get-settings.js:57:73
at Interface.[_onLine] [as _onLine] (node:internal/readline/interface:387:7)
at Interface.[_line] [as _line] (node:internal/readline/interface:793:18)
at Interface.[_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1105:22)
at ReadStream.onkeypress (node:internal/readline/interface:240:20)
at ReadStream.emit (node:events:390:28)
at emitKeys (node:internal/readline/utils:358:14)
at emitKeys.next ()
at ReadStream.onData (node:internal/readline/emitKeypressEvents:64:36)
at ReadStream.emit (node:events:390:28)

Node.js v17.1.0

Error on initialization if I am already tracking in git

This is super cool, but it throws and error if I am already tracking the repo. I could copy, remove the .git and call from an untracked folder, but is there a way to do it via gistup?

/usr/local/lib/node_modules/gistup/bin/gistup:76
  if (error) throw error;
                   ^
Error: the remote "origin" already exists.
    at /usr/local/lib/node_modules/gistup/bin/gistup:150:79
    at ChildProcess.exithandler (child_process.js:635:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

Getting an Unknown Encoding Error

After I enter my access token in my terminal, I am greeted by the following error

buffer.js:382
      throw new Error('Unknown encoding');
            ^
Error: Unknown encoding
    at Buffer.write (buffer.js:382:13)
    at new Buffer (buffer.js:261:26)
    at Object.fs.writeFileSync (fs.js:758:12)
    at /usr/local/lib/node_modules/gistup/bin/gistup:75:12
    at Interface._onLine (readline.js:198:5)
    at Interface._line (readline.js:518:8)
    at Interface._ttyWrite (readline.js:736:14)
    at ReadStream.onkeypress (readline.js:97:10)
    at ReadStream.EventEmitter.emit (events.js:126:20)
    at emitKey (readline.js:1058:12)

Am I doing something wrong?

Store defaults in ~/.gistup.json.

Would be nice if you could store default settings in ~/.gistup.json. For example, maybe

{
  "defaults": {
    "private": true
  }
}

would create private gists by default.

Fails to push files to remote origin

Hello! I've been trying to use gistup on my new computer and I'm fairly sure I've set everything up right...but after it says the gist has been created, it throws this error and doesn't push any of my files. I end up having an "empty" gist with just a .gistup file in it.

I can't figure this out and I'm not sure how to ask this in a way that can help you help me! What other information do you need?

Thank you,
Janice

gist eecafd72e2b8eaf5db1edfdc7c7339db created!
https://gist.github.com/eecafd72e2b8eaf5db1edfdc7c7339db
/Users/f002bjt/.nvm/versions/node/v15.2.1/lib/node_modules/gistup/lib/gistup/unless.js:11
    throw error;
    ^

Error: Command failed: git push -fu 'origin' main
error: src refspec main does not match any
error: failed to push some refs to '[email protected]:eecafd72e2b8eaf5db1edfdc7c7339db.git'

    at ChildProcess.exithandler (node:child_process:309:12)
    at ChildProcess.emit (node:events:329:20)
    at maybeClose (node:internal/child_process:1055:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: "git push -fu 'origin' main"
}

gist.github.com SSH timeout

Gistup throws the following error when initializing a new gist:

Initialized empty Git repository in ~/example_01/.git/
[master (root-commit) SHA] Initial gistup commit.
 1 file changed, 308 insertions(+)
 create mode 100644 file.py
gist GIST_ID created!
https://gist.github.com/GIST_ID
~/.npm-global/lib/node_modules/gistup/lib/gistup/unless.js:11
    throw error;
    ^

Error: Command failed: git push -fu 'origin' master
ssh: connect to host gist.github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at ChildProcess.exithandler (child_process.js:294:12)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

Is suspect GitHub services might be the problem, since tcptraceroute gist.github.com 22 eventually times out before reaching the destination.

Is it possible to use HTTPS over SSH in gistup or would you be interested in implementing it?

Similar issue found here: https://stackoverflow.com/questions/60740289/ssh-connect-to-host-gist-github-com-port-22-operation-timed-out-fatal-could-n

instructions missing something

Sorry, wasn't sure what to title this. Not super important.

When you press any key to continue, your web browser will open.
Please login (if needed) and fill out the resulting form to create
an access token. When you’re done, copy the access token to the
clipboard and paste it back into the terminal.

[msg about pressing any key etc]

The msg above, which i can't recall exactly, will change to "Enter personal access token:" only after one closes their browser. Otherwise, it seems as if gistup has hung up. Once i clued in and closed the browser everything was fine. I thought that part should be made clear.

Thanks a bunch for the cool tool. And every other one you've created.

error: pathspec 'gistup' did not match any file(s) known to git

Hi,

I've followed the "Let's Make a Block" tutorial and gotten stuck trying to run gistup. I've pasted the error below, which isn't addressed in your gistup troubleshooting section. At first I thought it might be a git configuration issue, but it looks like I've not set up my path variables correctly for npm-installed programs to run. Will check that first.

Thank you.

c:\Users\username\AppData\Roaming\npm\node_modules\gistup\lib\gistup\unless.js:11
    throw error;
          ^
Error: Command failed: error: pathspec 'gistup' did not match any file(s) known to git.
error: pathspec 'commit.'' did not match any file(s) known to git.

    at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)

ERROR: the remote "origin" looks funny.

When I first launched gistup and tried to get a personal access token, I got the following error message.

ERROR: the remote "origin" looks funny.
I was expecting something like

  [email protected]:123456789.git

but instead the remote URL is

  https://gist.github.com/suewonjp/6cb1c64274069a60286972085e234696.git

so I’m giving up. Sorry.

What do you think I am missing?

Documentation errata

In the Usage section of the Readme this sentence has a few words scrambled:
If you any specify options...

I should [probably] be "If you specify any options..."

Error on initialization

Maybe it's cause I'm on Ubuntu, not sure how this stuff operates on OS X:

Press any key to open GitHub… 
/usr/local/lib/node_modules/gistup/bin/gistup:63
      if (error) throw error;
                       ^
Error: Command failed: Couldn't get a file descriptor referring to the console

at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

One workaround would be to allow an auth token to be given over the command line, as an option.

Gistup conflict with Git-stats?

Context

My gistup was working so well to automate my bl.ocks and gists from the cli. But recently it started giving me errors, no longer works, and now I'm trying to figure out why.

Process

I made a test directory to illustrate this, cd'd into it and typed this into terminal:

$ gistup --public -m 'Testing stuff'

Expected result

Gistup creates my gist, with success, I tab to Chrome, rename the public gist and it populates on blocks momentarily.

Current result

Reinitialized existing Git repository in /Users/aurelia/Code/2015/gist-test/.git/
error Error: Invalid url field. This commit is not recorded into the git-stats history since you haven't added the remote url. You can import the previous commits using the git-stats-importer tool.

/usr/local/lib/node_modules/gistup/lib/gistup/unless.js:11
    throw error;
          ^
Error: git commit failed.
    at /usr/local/lib/node_modules/gistup/bin/gistup:152:65
    at ChildProcess.exithandler (child_process.js:646:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)

Possible Issues

I'm on the same machine, same setup, same Github account as always, not pushing anything abnormal. All should be working.

I installed git-stats a while back, circa the same time my gistup started failing; since it's cited in the error message, I wonder whether there's a conflict between the two (gistup <> gitstats)? There are no errors related to gistups in the git-stats repo.

Or maybe this is an error that someone has seen before and can help me debug/+1?

Thanks!

.DS_Store ruins everything

I had a .DS_Store file in my directory, which cause gistup to fail. Removing the file fixed the problem..

npm-docs $ gistup

/Users/zeke/.nvm/v0.10.26/lib/node_modules/gistup/bin/gistup:128
        if (error) throw error;
                         ^
Error: Command failed: The following paths are ignored by one of your .gitignore files:
.DS_Store
Use -f if you really want to add them.
fatal: no files added

    at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

gistup fails when local default branch doesn't match `main`

github has changed the default branch name of new gists to main. On my local machine, new repositories name new branches master (as is currently the default).

Since these don't match, I get the following error:

Error: Command failed: git push -fu 'origin' main
error: src refspec main does not match any
error: failed to push some refs to 'gist.github.com:227fc9570dad5bacc46e21eed19985f8.git'

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1047:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: "git push -fu 'origin' main"
}

I was able to recover by running

git branch -m main
git push -fu origin main

Git Bash on Windows 10 - TypeError: process.stdin.setRawMode is not a function

Would be nice to support Git Bash on Windows

$ gistup -m "WebVR Experiment"
Welcome to GISTUP!

Since this is your first time using gistup, we need to create a
GitHub personal access token to grant gistup permission to create
gists on your behalf. You’ll only have to do this once, and you
can easily revoke this token in the future if desired.

When you press any key to continue, your web browser will open.
Please login (if needed) and fill out the resulting form to create
an access token. When you’re done, copy the access token to the
clipboard and paste it back into the terminal.

Press any key to open GitHub… C:\Users\m\AppData\Roaming\npm\node_modules\gistup\lib\gistup\get-settings.js:37
      process.stdin.setRawMode(true);
                    ^

TypeError: process.stdin.setRawMode is not a function
    at ReadFileContext.callback (C:\Users\m\AppData\Roaming\npm\node_modules\gistup\lib\gistup\get-settings.js:37:21)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.