From d1f30cb9e65607441aa5e01da880e52f76ee6a76 Mon Sep 17 00:00:00 2001 From: Marnel Mangrubang Date: Sun, 30 Jun 2019 20:40:59 -0700 Subject: [PATCH 1/2] Week 1 - Node ecosystem in class questions --- .gitignore | 1 + index.js | 15 +++++++++++++++ package-lock.json | 13 +++++++++++++ package.json | 24 ++++++++++++++++++++++++ readme.md | 32 ++++++++++++++++---------------- src/profile.js | 6 ++++++ 6 files changed, 75 insertions(+), 16 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..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..5fbe583 --- /dev/null +++ b/index.js @@ -0,0 +1,15 @@ +// console.log('Hello, Node!') +// +const profile = require('./src/profile.js') +console.log(profile.name + " - " + profile.birthdate) +// +// +// const path = require('path') +// console.log(path) +// console.log(path.resolve()) + +//path.resolve() returns a string +//path is an object that has many functions + +const moment = require('moment') +console.log(moment().format('MMMM Do YYYY, h:mm:ss a')); 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..d6c93b4 --- /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/delrosam/w1-node-ecosystem.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/delrosam/w1-node-ecosystem/issues" + }, + "homepage": "https://github.com/delrosam/w1-node-ecosystem#readme", + "dependencies": { + "moment": "^2.24.0" + } +} diff --git a/readme.md b/readme.md index ccca3f4..7fa4782 100644 --- a/readme.md +++ b/readme.md @@ -38,7 +38,7 @@ $ npm -v * **Question:** What is the difference between forking and cloning a repository as opposed to just cloning a repository? -* **Your Answer:** +* **Your Answer:** forking a git repository copies copies the repo, including all previous commits to another account and maintains the connection to the original repo, whereas cloning simply copies the repository from the current state of the repository. --- @@ -46,7 +46,7 @@ $ npm -v * **Question:** What does `npm init` do? How does the `-y` flag modify that command? -* **Your Answer:** +* **Your Answer:** `npm init` creates the package.json file for the project? Don't know what the -y flag does. --- @@ -54,7 +54,7 @@ $ npm -v * **Question:** What is the purpose of the following keys? "name", "scripts", "license" -* **Your Answer:** +* **Your Answer:** `name` is the name of the project. `scripts` are all the commands that can be ran in terminal to do run, start, test and debug the project. `license` is where the type of license the project will have. --- @@ -62,7 +62,7 @@ $ npm -v * **Question:** What is the purpose of the `.gitignore` file? What is the significance of a "dot-file?" -* **Your Answer:** +* **Your Answer:** `.gitignore` is a file that lists all other files or folders that you want git to ignore and not include in any of the commits. the dot makes the file hidden. --- @@ -70,15 +70,15 @@ $ npm -v * **Question:** From the command line, how can you run this file? -* **Your Answer:** +* **Your Answer:** `node index.js` --- - [ ] Run `npm test` from the command line -* **Question:** What happens and how is this related to what is in the `package.json` file? +* **Question:** What happens and how is this related to what is in the `package.json` file? -* **Your Answer:** +* **Your Answer:** we see an error when the command is run. the error message we see is the same message thats in the `package.json` file beside the `test` script. --- @@ -86,7 +86,7 @@ $ npm -v * **Question:** What will you enter on the command line to run that script? -* **Your Answer:** +* **Your Answer:** `npm start` --- @@ -94,7 +94,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:** by running `npm run my-file` --- @@ -111,11 +111,11 @@ $ npm -v * **Question:** What gets logged? Why? -* **Your Answer:** +* **Your Answer:** My name. * **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:** `module.exports` is an object. `require` is a function that is part of node. --- @@ -123,7 +123,7 @@ $ npm -v * **Question:** What are some ways you can solve this problem? -* **Your Answer:** +* **Your Answer:** placing both my name and birthday into an object and exporting that object. --- @@ -135,7 +135,7 @@ $ npm -v * **Question:** What is `path` and where does it come from? -* **Your Answer:** +* **Your Answer:** `path` is a module that can help determine directories and file paths. It comes as a part of node. --- @@ -143,7 +143,7 @@ $ npm -v * **Question:** What command can you run to install this package? -* **Your Answer:** +* **Your Answer:** `npm install moment --save` --- @@ -151,7 +151,7 @@ $ npm -v * **Question:** Do you need to use a `./` to require the package? Why or why not? -* **Your Answer:** +* **Your Answer:** No, you do not need to use `./` because its not a local file. --- @@ -160,4 +160,4 @@ $ npm -v #### Resources - [Node.js Built-In Modules](https://nodejs.org/dist/latest-v12.x/docs/api/) -- [NPM: Moment](https://www.npmjs.com/package/moment) \ No newline at end of file +- [NPM: Moment](https://www.npmjs.com/package/moment) diff --git a/src/profile.js b/src/profile.js new file mode 100644 index 0000000..b71a202 --- /dev/null +++ b/src/profile.js @@ -0,0 +1,6 @@ +var me = { + name: "Marnel Mangrubang", + birthdate: 'December 8' +} + +module.exports = me; From 527e7cfb8090ccaf5b903a0ff93b582758c20fc1 Mon Sep 17 00:00:00 2001 From: Marnel Mangrubang Date: Tue, 2 Jul 2019 09:50:41 -0700 Subject: [PATCH 2/2] Updated the answer to my readme file after notes from instructor --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 7fa4782..da3f81f 100644 --- a/readme.md +++ b/readme.md @@ -46,7 +46,7 @@ $ npm -v * **Question:** What does `npm init` do? How does the `-y` flag modify that command? -* **Your Answer:** `npm init` creates the package.json file for the project? Don't know what the -y flag does. +* **Your Answer:** `npm init` prompts you for values to put into the package.json file before it is created in your project folder. The `-y` flag simply creates the package.json for you with default values. --- @@ -111,7 +111,7 @@ $ npm -v * **Question:** What gets logged? Why? -* **Your Answer:** My name. +* **Your Answer:** My name. Because my name is being exported out of the profile.js and imported using the function `require` inside the index.js file. * **Question:** What is `module.exports` and what is its _type_ in JavaScript? What is `require` and what is its _type_ in JavaScript? @@ -123,7 +123,7 @@ $ npm -v * **Question:** What are some ways you can solve this problem? -* **Your Answer:** placing both my name and birthday into an object and exporting that object. +* **Your Answer:** Placing both my name and birthday into an object and exporting that object. ---