-
Notifications
You must be signed in to change notification settings - Fork 1
01. Setting up your app
Get to know your command line (Terminal or iTerm work well for me). When you enter ls, you should see a list of files. If you're on Windows, this command is dir.
Choose a text editor - some people use applications like Sublime Text, Eclipse, Atom from GitHub, and Visual Studio Code from Microsoft. Others use vim, emacs, Notepad++, etc. If you haven't edited code before, you should spend some time finding an application with syntax highlighting. If someone is helping you learn to code, they might recommend an application which they can help you use.
Use mkdir 1batchapp to create a sub-folder called 1batchapp, and cd 1batchapp to enter into it. When you enter ls, it should be empty.
git init starts creating a history of changes to this directory. You can use this to push your changes up to GitHub or run your server on a cloud host such as Heroku. If you are running git for the first time, it will ask you to run config commands to set your name and e-mail address. Do those steps now.
Create a .gitignore file now, too. This file is just a line-by-line list of files which you do not want git to track, publish on GitHub, etc. along with your source code. For NodeJS servers, your file might look like this:
.DS_Store
node_modules
.env
*.log
The first line prevents a Mac's metadata files, .DS_Store, from being added to your project.
When your app requires NodeJS modules, they get installed inside of the node_modules folder, and you don't want to include these in your own source code. If someone gets a copy of your code, they'll run npm install and download those modules to their own computer.
.env and any file ending with .log are not included because these could include secret passwords and debugging information which doesn't need to be public.
npm init helps you create a package.json file which holds the name, version, and software requirements for your package. Here's how I would answer these questions for 1batchapp:
name: (1batchapp) - npm sees that the folder is named "1batchapp" and assumes that I want to use the same name for my module. If that's correct, I can just press Enter. But I want to rename it "sampleapp", so I type that and press Enter.
version: (1.0.0) - NodeJS modules use a three-number versioning system known as semver. There is a lot of programming politics and philosophy about how to use semver, and it isn't an exact science. For your own purposes, while you are beta-testing, you might want to indicate that by starting with a 0 and making a version like 0.0.1 or 0.1.1
description: - write what you want users to see on this module's description
entry point: (index.js) - if you are writing a reusable module, where people can send information in and out, this could be important. Use app.js where you are creating the server
test command: - we are going to use the mocha testing framework, so enter mocha
git repository: - if you have a project page on GitHub, GitLab, BitBucket, etc, you can enter an HTTPS URL here such as https://github.com/mapmeld/1batch.git. If you don't have the git repo yet, that's OK. Leave it blank.
keywords: - write keywords to help users find this module
author: - I typically write my name and e-mail like this: Nick Doiron email@example.com
license: (ISC) - there are several different open source software licenses, which you can read more about at ChooseALicense.com. I use "MIT" on most modules.
You can always go back and change package.json using your text editor.