{"_id":"@arnaudmagonette/holidates","_rev":"1-f5abdb8b35422b83ac0b056dee47722b","name":"@arnaudmagonette/holidates","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@arnaudmagonette/holidates","version":"1.0.0","description":"> Our first tool, with Node.JS","main":"index.js","dependencies":{"axios":"^0.19.2","chalk":"^4.0.0","country-list":"^2.2.0","figlet":"^1.4.0"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/arnaudmagonette/node-CLI.git"},"keywords":[],"author":{"name":"Arnaud Magonette"},"license":"ISC","bugs":{"url":"https://github.com/arnaudmagonette/node-CLI/issues"},"homepage":"https://github.com/arnaudmagonette/node-CLI#readme","bin":{"holidates":"index.js"},"gitHead":"74b6e4bb501e1e5a532687461adf94c60ea6b033","_id":"@arnaudmagonette/holidates@1.0.0","_nodeVersion":"14.2.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-dUjrSCp49Zlws+zhEc58HARJU4/kNCKX9eDUBiJfXYLxGouTG4wLK9z6c9S85LDdq4eLkL8eJEavza2HZTHaHw==","shasum":"f21313f21f5f88593f0507ed315e83038294dde9","tarball":"https://registry.npmjs.org/@arnaudmagonette/holidates/-/holidates-1.0.0.tgz","fileCount":3,"unpackedSize":9698,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJetXFhCRA9TVsSAnZWagAAcKgP/RcKU36V+iFmk2ykGIbh\nrN5wbTIu0gJlGXyodwTcsXqmBGDKs+CN/EJlg+VR+I5uS8NIBHIs5JYuPfc8\n9nWToSmaBfftsOq7eH0oSPGwLyLh1oxP0kZTaA67EioY1qbJDWRDxdT+aXv7\nAelyN6vWAe92oPPx14YgxdUk57jPGv0x8T7nbv8ULB2YPOL1xobWPLczWtN6\nl23uhjWpsQx+dw1P/Fo5vg0cH3Cpo7YXzYLftKv825TsCU/cQoSGk0NMtpdM\ngWqsFW/Ue6Ojz+aGMV/TN2IrpkRs16WaLYgSa1uOjHQ7oieb47XNsHUyurfj\n/pV17ndz+X1HOATcDz8IxVG6GZ6UDw9PEHXV1w6oWPUYVInaHNRwbMT/Cmf8\nOcDBqOcJStATApKg/R/32j6bbWKjDaYL91q/hsQeWCaPABvIGf+Pmg+XWUGA\nJUCpo/zT5OMK7BSUnL/Feu9dzREJzsDTfWT9dEmEl2GRZQoNfcT/XmtJh7z5\nP9FO3Jd62pa2/VkBLWbvEmzFRPiRWx7YrNdVDQpO8NGPHB9cUUxsd5mOrWB5\nIE6whG2d+AFDkm9s07Rim9nVYDxIjcUessnMQOlJcEolHrkgOO4IYqShzv4q\nGI8JnwbEi9P40n5z3QMRqpiyv5cQsbhcO4Cif/Nog8SNBHvZbD8LyLDGhgH0\nYmr4\r\n=GdPH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdJNrnIvbyAi1HBV2FTlCe1JGZn0deevTpfgZYMbqcQwIhAKmRVFQaGq+SCUXFa8Yl1RbY+Yc74yDc/TpQalURTAxF"}]},"maintainers":[{"name":"arnaudmagonette","email":"arnaud.magonette@gmail.com"}],"_npmUser":{"name":"arnaudmagonette","email":"arnaud.magonette@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/holidates_1.0.0_1588949344716_0.2911716769669015"},"_hasShrinkwrap":false}},"time":{"created":"2020-05-08T14:49:04.674Z","1.0.0":"2020-05-08T14:49:04.830Z","modified":"2022-04-04T15:33:41.777Z"},"maintainers":[{"name":"arnaudmagonette","email":"arnaud.magonette@gmail.com"}],"description":"> Our first tool, with Node.JS","homepage":"https://github.com/arnaudmagonette/node-CLI#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/arnaudmagonette/node-CLI.git"},"author":{"name":"Arnaud Magonette"},"bugs":{"url":"https://github.com/arnaudmagonette/node-CLI/issues"},"license":"ISC","readme":"# Node.JS: CLI\n\n> Our first tool, with Node.JS\n\n- Type of challenge: **learning**\n- Repository : **`***-CLI`** (name as you want with CLI)\n- Deadline : **08/05/2020 5:00 pm**\n- Team : **solo**\n- Submission : When the tool is published on npm, simply send us **the page of your npm package**.\n\n## About Node.JS\n\nYou may already know it: **javascript** is a programmation language executed in a *web browser*, which has an *engine* to run this language.  \n**Node.JS** (or just \"*node*\", if you want to be *the cool guy in the room*) is a *runtime* to execute javascript *outside* of a browser: it includes an engine (*v8*, the javascript engine of webkit/chrome) to run the langage, some librairies to interact with the system (manipulating files, executing sub-programs, etc…), and use a _module_ structure, which depends on [**npm**](https://www.npmjs.com), a registry with more than one million packages (as for november 2019), created and maintained by the community.\n\n### *Nearly* everywhere?\n\nAltough **Node.JS** is mainly used for *back-end* (where it competes with PHP, Java or Ruby), node allows us to write programs for command line, mobile apps (with [ReactNative](https://facebook.github.io/react-native/), for instance), desktop apps (with [Electron](https://electronjs.org/), used to built apps like the [Atom editor](https://atom.io), and [many more](https://electronjs.org/apps)), robotics (with tools like [Johnny-Five](http://johnny-five.io/)) or even IOT (with optimized runtimes like [Node-RED](https://nodered.org/)).\n\n## Our first Node.JS program\n\nTo discover *node*, we will start by coding a small command-line tool.\n\nIt will be simple, allowing you to discover node, npm and their module architecture.\n\nJust this once, I will *kinda* guide you through the process.\n\n> ☝️ **NOTE:** we will not need Docker for the first (and fast) project - we will work locally\n\n### 1. Install Node.JS & npm\n\nYou should already have node installed on your machine, since we used it for javascript exercises series at the beginning of our BeCode adventures.  \nBut if you need to, simply go to [the official Node.JS website](https://nodejs.org/en/) and follow the instructions (for Ubuntu/Debian, the [instructions are here](https://github.com/nodesource/distributions/blob/master/README.md)).\n\n> 👉 Install at least version `12.x.y` (version `10` is fine too, but, hey, it's 2020!)\n\n### 2. Create the project workspace\n\nCreate a github repository for the project, and use the command `npm init` to initialize the project.\n\n> ☝️ **NOTE:** for the question about the *entry point*, let the default answer, \"index.js\"\n\n### 3. Your first script\n\nCreate a `index.js` file at the root of the repository, and add the following line to it:\n\n```javascript\nconsole.log(\"Hello, Node.JS!\");\n```\n\nThen, enter the following command in the terminal:\n\n\t$ node .\n\t\n[Congrats!](https://pics.awwmemes.com/people-write-congrats-because-they-cant-spell-congrajlashins-38832971.png) You've created your first Node.JS script!\n\n### 4. Going further…\n\nNow, I will let you experiment and dig further, with a complete statement.\n\nYou will code a command line tool that will take a *country name* as *parameter*, like this:\n\n\t$ myNodeCLITool Belgium\n\t\nThe tool will verify that the parameter is a *well-formatted* country name, transform it onto a *two-letters country code*, then perform an HTTP request to the API of the [**nager.date**](https://date.nager.at/) service, like [explained here](https://date.nager.at/Api).  \nYou will show the results (a list of holidays dates **for the current year**) in a *readable* way in the terminal.\n\n> 👉 **NOTE:** when I say \"*for the current year*\", it means \"*retrieve the current year*\", not hardcoding `2020` somewhere in the code. 😅\n\n> ⚠️ **WARNING:** your script will be executed in a specific context. For these kind of command line tools, it's recommanded to add the following line at the top of your *entry point* (here, your `index.js` file):\n\n\t#!/usr/bin/env node\n\t\n> 🤓 This line, at the top of an executable file, is called the [**shebang**](https://en.wikipedia.org/wiki/Shebang_(Unix))\n\nAs result, you will have a tool to get the holidays of the current year for the given country. Always useful.\n\n#### `npm` packages to use\n\nThere's *a lot* of packages on [npm](https://www.npmjs.com), including some doing *exactly* what I ask you to do.  \nThat's not the point, obviously.\n\nBut to save you some trouble losing yourselves in this big pile of possibilities, I recommand you to use the following packages:\n\n- [`country-list`](https://www.npmjs.com/package/country-list), to convert the country name onto a country code\n- [`axios`](https://www.npmjs.com/package/axios), to perform HTTP requests\n\n##### even further…\n\nFor those of you wanting to make your tool *pretty* (and add more challenge), you can dig around the following packages:\n\n- [`ora`](https://www.npmjs.com/package/ora), to show a *spinner* (loading animation) while your request is pending\n- [`chalk`](https://www.npmjs.com/package/chalk), to add some colors in your terminal\n- [`figlet`](https://www.npmjs.com/package/figlet), add some *style* to your terminal\n\nYou can also handle a *second parameter*, asking the year to show the corresponding holidays (if the parameter is missing, stick to the default behavior of looking for the current year).\n\n### 5. Testing your tool / Prepare for publication\n\nYou've been able to test your program all along the development process, but in a perfect world, it will be cool to give it a name, like `holidates`, to be able to execute it like this in a terminal:\n\n\t$ holidates Belgium\n\t\nTo do so, you'll need to document about the [`bin` property](https://docs.npmjs.com/files/package.json#bin) of the `package.json` file.  \nYou can also use the [`npm link`](https://docs.npmjs.com/cli/link) command to test your program locally before publishing it.\n\n### 6. Publish on npm\n\nPublishing on npm is free, but you need to [create an account](https://www.npmjs.com/signup).\n\nThen, before publishing your package, there's three important steps to follow:\n\n#### 6.1. Choose a name for your package\n\nYou're free to name your package freely.  \nBut with *more than 1 million packages* on the npm registry, there's change the name you choose is already in use.  \n*Don't cry!* We can *scope* your package with your npm account's name. In your `package.json` file, prefix the `name` property with `@yournpmlogin/`, like this:\n\n```json\n{\n  \"name\": \"@leny/holidates\"\n}\n```\n\nYou will then be able to publish your package without problem, even if the name is already in use.\n\n#### 6.2. Complete your README.md file\n\nThe content of your `README.md` file will be displayed as the presentation of your package on npm. Explain how your package work, how to install and use it. Get inspiration from other well-known packages.\n\n> 🇬🇧 **IMPORTANT:** write your README in **english**!\n\n#### 6.3. Update the version number\n\nThe first version of your package can be `1.0.0`, `0.1.0` or `0.0.1`, it's up to you.\n\nBut keep in mind that when you will update your package and publish a new version, you'll need to follow the rules of [semantic versionning (*aka* semver)](https://semver.org).\n\n##### Publish\n\nFinally, to publish on npm, simply use the following command:\n\n\t$ npm publish --access public\n\n* * *\n\nGood luck!","readmeFilename":"README.md"}