![]() For this purpose, it’s better to use process.cwd: path. This means we’ll want the name of the directory we’re working in, not the directory where the application resides. This will work when we’re calling the application from the same directory (for example, using node index.js), but bear in mind that we’re going to be making our console application available globally. This sounds straightforward, but there are a couple of gotchas to take into consideration.įirstly, you might be tempted to use the fs module’s realpathSync method to get the current directory: path. check whether a directory exists (to determine whether the current folder is already a Git repository by looking for a folder named.get the current directory (to get a default repo name).inquirer.js - command-line user interaction.We’re going to create a lib folder where we’ll split our helper code into modules: touch - a tool for implementing the Unix touch command.simple-git - a tool for running Git commands in a Node.js application.- an implementation of one of GitHub’s authentication strategies.- a GitHub REST API client for Node.js.configstore - easily loads and saves config without you having to think about where and how.Īdditionally, we’ll also be using the following:.inquirer - creates interactive command-line user interface.clui - draws command-line tables, gauges and spinners.Here’s a complete list of the packages we’ll use specifically for developing on the command line: We’ll also be using minimist to parse command-line arguments. As well as providing a mechanism for asking questions, it also implements simple input controls: think radio buttons and checkboxes, but in the console. But we’re going to take advantage of a third-party package which adds a greater degree of sophistication - Inquirer. In terms of input and output, the low-level Readline Node.js module could be used to prompt the user and request input, and in simple cases is more than adequate. Just for fun, we’ll use figlet to create a fancy ASCII-based banner, and we’ll also use clear to clear the console. We’ll be looking at a couple of libraries for enhancing the display: chalk for colorizing the output and clui to add some additional visual components. You might be surprised by just how much you can do visually, while at the same time keeping it functional. Nevertheless, that doesn’t mean it has to be plain, ugly, monochrome text. One thing is for certain: in terms of appearance, the console will never have the sophistication of a graphical user interface. It might not save you hours, but it’ll remove some of the initial friction when starting a new project. gitignore file, add the contents of the folder and push it up to the remote repository. Then it will provide a simple interactive “wizard” for creating a. So what ginit will do is create a Git repository in the current folder, create a remote repository - we’ll be using GitHub for this - and then add it as a remote. ![]() Wouldn’t it be better if we could do all this from the command line, with no copy-pasting of Git URLs and such like? Nevertheless, these steps are pretty repetitive. There are often more steps involved, but we’ll stick to those for the purposes of our app. create a remote repository, for example on GitHub or Bitbucket - typically by leaving the command line and firing up a web browser. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |