From ec879c8e9c80b6914696c9e788fd975f21fc3199 Mon Sep 17 00:00:00 2001 From: Somanath Krishnaswamy Date: Sat, 29 Jun 2019 22:56:33 -0700 Subject: [PATCH] Initial commit with class notes --- .gitignore | 1 + index.js | 11 +++++++++++ package-lock.json | 13 +++++++++++++ package.json | 24 ++++++++++++++++++++++++ readme.md | 32 +++++++++++++++++++------------- src/profile.js | 3 +++ 6 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/profile.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b878d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..4073a34 --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +console.log('Hello World'); + +const profile = require('./src/profile.js') +console.log(profile) + +const path = require('path') +console.log(path.resolve()) + +const moment = require('moment') +console.log(moment().format('MMMM Do YYYY, h:mm:ss a')); +console.log( moment().calendar()); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f2886cb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "w1-node-ecosystem", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "moment": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", + "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..5dcd602 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "w1-node-ecosystem", + "version": "1.0.0", + "description": "Welcome to JSCRIPT 400 - Server Side Development with JavaScript", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Somanath1786/w1-node-ecosystem.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/Somanath1786/w1-node-ecosystem/issues" + }, + "homepage": "https://github.com/Somanath1786/w1-node-ecosystem#readme", + "dependencies": { + "moment": "^2.24.0" + } +} diff --git a/readme.md b/readme.md index ccca3f4..26f9f7d 100644 --- a/readme.md +++ b/readme.md @@ -39,6 +39,7 @@ $ npm -v * **Question:** What is the difference between forking and cloning a repository as opposed to just cloning a repository? * **Your Answer:** +Forking creates a separate copy of the whole repo under a different user, where as cloning is just making a copy, if it is done without forking, it just means that you would like to work on it separately --- @@ -46,7 +47,8 @@ $ npm -v * **Question:** What does `npm init` do? How does the `-y` flag modify that command? -* **Your Answer:** +* **Your Answer:** Creates a pacakage.json file and then outputs the same. The -y flag says yes to all +the questions. --- @@ -54,7 +56,10 @@ $ npm -v * **Question:** What is the purpose of the following keys? "name", "scripts", "license" -* **Your Answer:** +* **Your Answer:** name = name of your project +scripts = scripts that are used as a part of any commands that you would run from your command line +It can be npm commands , react commands etc etc +licesne = open source licsense or any other custom licesnse that you want to use for your application --- @@ -62,7 +67,7 @@ $ npm -v * **Question:** What is the purpose of the `.gitignore` file? What is the significance of a "dot-file?" -* **Your Answer:** +* **Your Answer:** Used to store stuff that is not uploaded. Usually used to store API Keys etc, basically private stuff --- @@ -70,7 +75,7 @@ $ npm -v * **Question:** From the command line, how can you run this file? -* **Your Answer:** +* **Your Answer:** Node index.js will run this file --- @@ -78,7 +83,7 @@ $ npm -v * **Question:** What happens and how is this related to what is in the `package.json` file? -* **Your Answer:** +* **Your Answer:** No test specified error is thrown and it outputs/echos the details in the pacakge.json file --- @@ -86,7 +91,7 @@ $ npm -v * **Question:** What will you enter on the command line to run that script? -* **Your Answer:** +* **Your Answer:** npm start --- @@ -94,7 +99,7 @@ $ npm -v * **Question:** The same pattern will not work to try and run this script. How can you successfully get this script to run? -* **Your Answer:** +* **Your Answer:** npm run my-file if we are using standard npm commands we dont need run, else we need to specify run --- @@ -111,11 +116,11 @@ $ npm -v * **Question:** What gets logged? Why? -* **Your Answer:** +* **Your Answer:** Hello World is logged first followed by my name. Exported the code from outside of index.js and pulled in the code into index.js and executed the same * **Question:** What is `module.exports` and what is its _type_ in JavaScript? What is `require` and what is its _type_ in JavaScript? -* **Your Answer:** +* **Your Answer:** require is a function type and module.exports is a special object --- @@ -123,7 +128,7 @@ $ npm -v * **Question:** What are some ways you can solve this problem? -* **Your Answer:** +* **Your Answer:** Package everything you need into an object and export/import the same --- @@ -135,7 +140,7 @@ $ npm -v * **Question:** What is `path` and where does it come from? -* **Your Answer:** +* **Your Answer:** Path comes with node. since there is no ./ it is not something we created but something that comes as a module built in with node --- @@ -143,7 +148,7 @@ $ npm -v * **Question:** What command can you run to install this package? -* **Your Answer:** +* **Your Answer:** npm install moment --- @@ -151,7 +156,8 @@ $ npm -v * **Question:** Do you need to use a `./` to require the package? Why or why not? -* **Your Answer:** +* **Your Answer:** Since this is not a file we dont need ./. Since we are using a package we dont need +to use ./ --- diff --git a/src/profile.js b/src/profile.js new file mode 100644 index 0000000..332c25b --- /dev/null +++ b/src/profile.js @@ -0,0 +1,3 @@ +const name = 'Soma' +const birthday = 'Feb 17th' +module.exports ={name, birthday} \ No newline at end of file