NPM Packages and Monorepos | David Armendáriz | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

NPM Packages and Monorepos

teacher avatar David Armendáriz, #NeverStopLearning

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

40 Lessons (3h 44m)
    • 1. Introduction

      1:18
    • 2. The best tool out there: asdf

      8:47
    • 3. Creating the package.json

      3:03
    • 4. Configuring ESLint, Prettier and Typescript

      8:55
    • 5. Configuring Jest

      2:18
    • 6. Configuring tsconfig.json

      3:37
    • 7. Modifying the package.json

      5:33
    • 8. Implementing a method to convert from base N to decimal (part 1)

      8:14
    • 9. Implementing a method to convert from base N to decimal (part 2)

      4:56
    • 10. Implementing a method to convert from decimal to base N

      12:47
    • 11. Supporting decimals

      3:44
    • 12. Validations

      10:55
    • 13. A little correction to convertFromDecimalToBaseN method

      3:12
    • 14. Supporting decimals for convertFromDecimalToBaseN method

      11:02
    • 15. Yet more validations!

      12:18
    • 16. Adding a method to convert from base N to base M

      8:00
    • 17. Typedoc

      9:20
    • 18. Comments on Typedoc

      5:28
    • 19. Solving compatibility issues

      7:59
    • 20. Setting up the repo in Github

      4:01
    • 21. Changing the name of our package

      2:43
    • 22. Login to NPM

      1:26
    • 23. Publishing our package!

      3:36
    • 24. Installing our package locally

      3:59
    • 25. Implementation of the testing workflow

      5:55
    • 26. Implementing the deployment workflow

      5:49
    • 27. Deploying

      5:19
    • 28. Adding badges to our README

      4:15
    • 29. What's next?

      2:38
    • 30. Yarn Workspaces and monorepos

      6:38
    • 31. Advantages and disadvantages of monorepos

      7:05
    • 32. Creating organizations in Github and NPM

      4:19
    • 33. Setting up a Django project

      5:02
    • 34. Setting up a basic Express app

      6:23
    • 35. Setting up a basic common package

      4:26
    • 36. Creating the root repo

      3:45
    • 37. Leveraging local dev!

      4:06
    • 38. Understanding what changes in the root repo

      3:44
    • 39. Wrap up

      5:43
    • 40. End!

      1:30
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

184

Students

--

Projects

About This Class

In this course, we are going to deep dive in how to implement a NPM package with best practices. Sounds boring? Well, we are going to learn:

  • Typescript
  • Typedoc
  • ESLint, Prettier, Typescript, Jest and Husky configuration
  • Github Actions for CI/CD
  • Best practices FTW!

In the second part of this course, we are going to learn about monorepos:

  • Yarn workspaces
  • Monorepos: advantages vs disadvantages
  • Git submodules
  • NPM and Github organizations

Meet Your Teacher

Teacher Profile Image

David Armendáriz

#NeverStopLearning

Teacher

Hi! I am David Armendáriz and I am an ecuadorian mathematician. I like everything related to Data Science and also I like to apply my knowledge in this topic to software.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: Hi and welcome to this course. My name is that Lederman diaries and IMS, software engineer and mathematician. The title of this course is npm packages and ammonia rentals. So what are we going to learn? We're going to learn TypeScript. Type doc is LND, preacher hotkey. Jazz. Best-practices did have actions on Erebos, John workspaces, and good sub-models. So we're going to learn a lot in this course. What are the prerequisites? Well, all levels are accepted. All levels of experience are accepted. You only need to know the basics of JavaScript. Good. What to expect from this course. Understand why npm packages are so important for code reuse, advantages and disadvantages of monorail and how to tackle them. What is the structure of this course? The first part, we will build the base converter package that we will publish to the NPM registry. And in the second part, we're going to construct a sample project with John workspaces and modify it with kids of modules. So that's it for this course. I hope you enjoy it. See you in the next lecture. Bye bye. 2. The best tool out there: asdf: Hi and welcome back. So let us start the initial setup of our package. So I'm going to create a new directory called base converter. And I'm going to change directory to that base converter folder. And I'm going to open BSD code here. Okay? So first thing we need to do is to initialize our repo with getting it. And then we're going to create a.gitignore file because we're going to need it. Let's write node modules here before we forget. Okay, now I'm going to create a new file called nvm RC. So what is NVM or seen? Here? We're going to be able to specify the version of node that we are going to use in this project. So I am going to list the versions of note I have installed in my machine. So I have all of these versions installed in my machine. Okay, so yeah, you read that correct? I used these command gold AS Df. But what is a SDF? So AS df is one of the most useful tools out there for software development. As you can see here in the homepage, a SDF can manage multiple runtime versions with a single CLI tool. So we can manage every, every programming language do you imagine like Node, Ruby, elixir. In fact, I can list all of them by saying a ACF blogging, least old. So these are all the things that we can manage with ASD f. So you can see here, you can see here Cube CTL for Kubernetes. Let's see. We have also know des, obviously. We have OCaml. We have we have BHB, I think here, pitch bee barrel. Well, we have lots and lots of thing. I have installed these plugins. I have G-Cloud, I have goaling, I have mini cube NodeJS by readies, scaffold SQLite, but you can install any of those plug-ins. So if we go here to their official ducks and click on Get the start that then you can see that we can install any version of your blogging with these four steps. We have to install first ASD f, obviously, then you can add the blogging. For example, a is d f Plugging NodeJS. And then we're gonna install the version that you want. For example, 13.14. And you can then set a globally or locally the version of node.js. I'm going to hell, but first, you have to install a SDF. So a disclaimer, a ISAF is only available for Linux and Mac OS. So if you are on windows, you have two options, well, three options. The first one is to install a dual boot with a Linux distro destroy like Ubunto. The second option is to enable windows subsistent for Linux and upgrade it to Windows subsistence for Linux 2m. So you can search on Google, the official dogs of Microsoft on how to install Windows subsystem for Linux. I highly recommend it. And the third option is to only install nvm. So NVM stands for Node Version Manager. A SDF yeast just like nvm, but a SDF supports many, many other languages. Nbn just supports Node Version Manager. So Node Version Manager can also be installed in window, bus windows, but I think it's a little bit complicated. So I think the best option for you is to install Windows subsystem for links. Okay, so once you have installed a SDF, as I told you, is very easy to install a node version. So you have to first run this command, a SDF blogging as NodeJS. So I already have it added. So plugging named NodeJS already added is going to show. And then you can see the versions of no dS by saying a SDF list, all NodeJS. And here you can see all the versions self NodeJS available. For example, if you want to use version 15 4.0, then just say just to run this command, a SDF install NodeJS 15.4, and I already have it installed. So that's why I have no deaf 15 4.0 is all ready installed. Ok, so now we can run this command, a SDF local NodeJS 15.4. So as you can see, a dot tool dash versions file God created with a version of node.js. So this is the file that a SDF uses. Nvm, uses these nvm RC file, and asean uses these dual versions. Okay, but ASTM is a tool that not many people know, although it's really, really useful. So people are more accustomed to see these dot nvm RC file with ASD have we can steel use these nvm RC file, but we have to make something, we have to make some configuration. So into official ducks, you go to the spot where it says configuration and here environment variables. So here in these abosDF RC file, which is in your root directory. So if I open a new terminal, I'm going to find these ASD F RC file. You have to edit this file and say legacy version file is equal to yes. So by doing these Lille 10-inch than we can use these files like nvm, RC for node or dot by m dash version for Python, et cetera, et cetera. So I'm going to delete this tool versions and I'm going to specify the node version I want to use in this project to locally, which in my case is going to be 15.4. So if I type in my terminal here, knows minus v, I'm going to see Burson 15.4. So if you don't believe me, I have a another version of Node installed globally. So if I type node minus V0, you're going to see that I have globally enabled version 10.22. And here I have version 15, 4.0. Okay? So now that you know what ASD FES, I bet you, you're going to thank me later because this tool is really, really cool. Now we have a local version of note in our project. And let's continue in the next video by initializing our package.json file. So I hope you like this video. See you in the next one. Bye-bye. 3. Creating the package.json: Hi and welcome back. So now we have a local version of no death installed in our project. So you can install now yarn. We're going to use jargon in our project. So you can say npm, I'm in G darn. Or you can also install it locally if you want. But I used to install Jorn globally because, well, it's meant to use globally. So now I can see John in it. And I'm going to say dash y. Now I have these fault configuration. The name of my package is going to be based dash converter. So as this is going to be a book Public package, then I have to investigate. These name is already taken, so there's a high chance that this name is already taken. So I have, I might have to change it later. The version we're going to use semantic versioning version 1.0.0. The main file. I'm going to leave it like that. Index.js D author Well, my name and my email. So I think that either recognizes my name and my email because I have some configuration, some good credentials configuration enabled globally and the license MIT. So what is this license field? Well, you can go to the speech goal, just a licensed.com. And here you're going to see the different types of licenses. So for example, if I wanted simple and permissive, the MIT license is short and to the point, it lets people do almost anything they want with your project like making and distributing load source version. And they say Bible.NET Core and Rails uses the MIT license. So I think this is the correct one we want to use. So this is the text of the license and you can read more about it in this page. Okay, so we're going to stay with the license MIT. They can also say that these baggage just not going to be private. So we can specify also that field. And I think that we can also specify keywords. So as our bucket just going to be public keywords are very important. So I'm going to say converter, math, base numbers, whatever you want to put here. Okay, so that's everything for this video. Let's continue on the next one. Bye-bye. 4. Configuring ESLint, Prettier and Typescript: Hi and welcome back. So now let's add a type script. Yes, LND and prettier to the mix. So we're going to say Jar, add the minus z type of script. So now we have type script in our deaf dependencies, as you can see here, the subscript here in the gitignore. Let's add this John error, that log file because for example, if we made that typo and well, It's something that does not exist, then this jargon error, that log file is going to be created and we don't want that in our ripple. So now let's initialize step script with n px TSE dash, dash in it. So what does N'T Bx do? Well, it's going to search for us symbolic link here in these dustbin folder. So here we have these DSI and it's going to use these command here. So this is totally equivalent to this node modules that being just c dash dash in it. Instead of doing this, we can just simply say npm TSE dash, dash in it. Also, if we don't have this command in our bin folder, then np x is just going to download it, but without install it globally. Okay, so let's just run this command. And now this ts config file got generated and we're going to actually configure this in a later, in a later video. For now, let's configure Yes Lint. So let's at ES lint as a deaf dependency. Let's also at Type Script ES lint parser, which is the parser that is going to allow us link to link that script files. Type the script ES lint. Yes, linked plugging. Okay. So let's install these things. And in the meantime, let's create a WBS linked RC ab.js file. Okay, so let's configured this ES lint. So we're going to say module.exports. And we're going to say that the environment is known and that we also have just so we haven't installed just yet, but we're going to do it in a later video. So let's add that the parser is diaper script, Yes, Lint parser. And that the parser options, well, we can specify here the source type module. So we can use ES6 modules. And we are going to extend from plugging type of script. Yes, Lint recommended. So remember that we installed this type script. Yes, Lint is linked plugging. So this contains Yes Lint rules that are. Em, type script a specific. Also, if you want to specify your own rules, you can put them in these object. For now it's going to be an empty object. Okay, so now we're going to add prettier. So the core package, prettier. And we're going to also add Yes Lint conflict, grittier and ES lint, lugging prettier. So yes, leaned coffee prettier. So let me see here. Yes, leaned conflict preacher. He's going to disable some enslaved rules that might conflict with prettier and ES lean. Plugging in preacher is going to run prepare errors as if they were ES lint errors. Okay? So here, I'm just going to say, sorry, breed here. A slash, script e is linked. And also blogging. Pretty dear. Slash recommended. Ok. So now as you can see, this file has some RAD inside it. And in order to fix all of the ES lint errors automatically, well, we can go here to the command palette of BS code and say append settings, JSON. And here are my user settings or global settings. And the one that you are interested east, these one that says ES lint editor, that code actions unsafe. Source 0.5x, all dot ES lint, true? The source fix all markdown lead, true? Well, I included it because I also have an extension called mark down lint. He's This one. I highly recommend you to install it because it links your mark down files. Okay, so by having this, now we can fix Eastland problems on safe. But before doing that, let's create a prettier RC dot js file. And here we're going to specify our prettier configuration. So for example, I want to say, I want semicolons everywhere. I want trailing comma. In old places, I want single quotes. Single quotes, true, print with 120 characters and tab. We're off to. Okay, so just to be sure, reload your window because you can have a problem here. Okay, so now here, just save this file and as you can see, now we have single quotes. Now or no, our tub with these two. And, well, we didn't have actually any code yet, but we're going to have semi-colons and trailing commas. Okay? So if you didn't know what the trailing Collins, Well, it's just like having these comma here at the end. So why is this useful? Well, suppose you make something else. You include honor browser, true here. Okay? So if you don't have these comma at the end, then when you I'm make a pull request or something like that. Then in the pull request, it's going to show that these line also got a changed just because you added the comma. But if you already had the comma there, so the trailing comma, then this line is going to be unmodified. And in your pull request, you're going to see that only this thing here got changed, only this line got at it. Ok, so that's why trailing commas are useful. Semicolon, well, they are not required, but I like them to have them in my projects. Single quotes. They are like a convention. Mostly print with, well you can have 80, you can have 100, whatever you want and tab with while you are ready. So what does tap with? Two. Ok. So now that now we have everything configure, we have E as me and we have preached here. And another thing we need anything more. So I hope you liked this video. See you in the next one. Bye-bye. 5. Configuring Jest: Hi and welcome back. Now it's time to add just to the mix. So in order to add it, we're going to say, John. Well, obviously just types, just we're going to also need TS Just and Ts knows. Okay, so everything here is going to be installed. And in the meantime, let's create the just that config dot js file. Okay, so inside this just dot config dot js file. Well, we can already use type script here we want. So I'm going to use type script here. Here I'm going to export the fault, this object here. Collect copper etch from o are going to collect coverage from source, everything that ends with TS. And we are going to ignore that index file that we, obviously we haven't created yet. We are going to also specify coverage threats halt. We the global of branches, 100% functions, 100%, lines, 100%, statements, 100%. And we're going to try to have 100% coverage. Their roots. Well, we're going to say the root deer, which is our directory source slash source. So we're going to say, hey, just, you have to find that test inside this folder. The Press, It is going to be TS Just so we need this in-order or just work well with that script and test environment. We're going to say that it's notes. Okay, so I think that's everything we need for just so I hope you liked this video and see you in the next one. Bye-bye. 6. Configuring tsconfig.json: Hi and welcome back. So now it's time to configure type script. So remember that this ts config, that JSON file got generated when we around that command. And Bx, C dash, dash in it. And here we have lots and lots of options. Also we have here in these comments what they are useful for. If you don't understand something, you can always search in the script, official ducks. So I'm just going to delete everything here. And I already have these configuration here. So I'm just going to explain you what is everything inside these configuration. So the compiler options, as it says here, instructs that absolute compiler how to compile dot ds files. Target means that our compiled code is going to be written in JavaScript five or ES five or egg mass script five. Module specifies a module code generation, in our cases CommonJS. So here we have an example in the tab scrip official ducks. For example, these two lines of code are going to be compiled to this if we use CommonJS to DES, if we use AMD and to DC, we use AMD. So when we use node, we want to use common Yes. Declaration true means that we are going to generate the types, the corresponding dot d dot ts files. The outdoor air means that all of our compiled code is going to be inside these build folder is strict true means that we're going to enable the strict type checking options. So basically, I'm that type checking the ES module interrupt. Well, this is something that will allow us to import these default export. So for example, important moment from moment of you have used that moment JS library. Instead of in board everything as moment from moment. So if we say yes module interrupt falls, we're not going to be able to use this default. Imports. A skip list check means that we're going to skip that type checking of the declaration files. These force consistent casing in filenames. Well, sometimes, for example, if we have some file called filename that JS, There are some cases where we are going to be able to import something like this filename that JS. But type script is case sensitive when we talk about imports. So this option is going to force those consistent async in filenames include means that all of our taps grid code is going to be inside a source folder. We haven't grid a jet and exclude means well, don't include the tests in the final built. Okay, so that's everything we need. In the next video, we're going to add some scripts in R package JSON. So I hope you liked this video. We will see you in the next one. Bye-bye. 7. Modifying the package.json: Hi and welcome back. So now it's time to configure our package JSON. So first thing we're going to do is remember that inside these ts config, we said that the final build is going to be inside these build folder. So when people install our package, we only want them to be able to see that builds folder. We don't want them to be able to see the source code or these ES lint RC dot js files or these prettier files. Not because we distrust them, but because they are not useful for them. And they just increase the bundle size of node modules. Okay, so files is going to be equal to build, everything inside built. So this is going to tell that whenever someone installs or package, well, just include that bill folder. And also the package.json under read me are going to be included because, well, we cannot exclude them when someone installs R package. Okay. So that's one thing I wanted to do. The second thing, well, let's actually put these keywords at the end. Okay? Now let's put some scripts here. So inside these scripts, I'm going to say, well, check types is going to be equal to that ts, c dash, dash, no, Emmett. So whenever we write something inside the scripts, we don't need that Px. So we can simply say TIC because John is going to look at everything inside this bin folder. Also built is going to be on the TRC. Test is going to be only just I'm Test. Column coverage is going to give us the coverage with just dash, dash, clear cache. So we have to first clear cache and then yes, dash, dash coverage. And then Lint is going to be ES lint. What do we want to land? Well, everything inside our source folder that has this ds extension. Ok, so now we have all of these scripts. And whenever we want to commit something or push something, we want to run some of these commands. Okay? So first let me see. Ok, we have a comma here. So how do we achieve this? Well, we're going to install something called husky. So jarring pad minus D has Keep. And Husky is going to allow us to, to run commands before committing and before pushing. Okay. So we're going to create a file called costed that conflict ab.js. And here inside we're going to say module.exports, hooks of precommit. We want to run jarring check types. Jon leaned fix. Okay. And on PrEP Bush would we want to run Yarn test coverage. Okay, so those are the hooks. So before we commit something, we're going to check the types with Type Script, unlinked anything, and fix them if they are fixable. And before pushing, we're going to test if we, we have the coverage of 100%. And talking about coverage. Here we're going to put garbage because when we run the coverage, a folder called coverage gets created and we also don't want that to be included in our repple. Okay. So I think that is everything. When it yeah, we need something else. I I forgot. So here in the main Actually, the index.js file is going to be inside the Build folder. And also we're going to have some types. So types are going to be also insight bill folder and they're going to be indexed that d dot ts. That's, that, that's going to be our, our types. Okay, here we also, I'm going to put a description of R package. And I'm going to say a package to convert numbers from one base to another. Okay, so I think those are the things I wanted to include in the package, Jason. And I am pretty sure now that we can start writing some code. So I hope you liked this video. See you in the next one. Bye-bye. 8. Implementing a method to convert from base N to decimal (part 1): Hi and welcome back. So now it's time to write some code. So let's create taste source folder. And inside the source folder we're going to create her index.js file. Remember this is not going to be in our coverage. I'm going to create these base converter ab.js file and base converter dot dest dot ts. So we're going to take a test driven development approach. Okay, so first we're going to define our test and then we are going to ride the implementations. So here we're going to say export class base converter, my implementation right now. And here we're going to export base converter from vase converter. Okay, fine. Now, let's write some tests here. So we're going to save the scribe. And what I usually do here is two, put the name of the method I am going to test. So inside that base converter class, I'm going to have this method called convert from base n, two decimal. Okay? And inside here I'm going to put the describe blocks that describes the test. So when given a number in a base that is less than or equal to ten, are going to say, test, shoot, converted to decimal. Okay? And here I'm going to put a bunch of expected statements. So I'm going to say expect converter dot convert. Well the name of the method. And I'm going, I already have these test cases. So for example, 11011 base two is equal to 13. And I'm going to just copy and paste this things here. And here. I'm going to put more tests. One, 1-0, 1-1 is in base two is equal to 2712. 10 in base three is equal to 48 gates. So this converter is going to be an instance of the base converter class. And I'm going to put the, put it in the top of the file. I'm going to say let converter based converter. So looks like this code is not helping me to autumn for this. So I'm going to import it important base converter from base converter among going to say before all. We'll create an instance of this base converter class, base converter. And now I can use it in all of my tests. Ok, so here we're having that convert from, from base enter decimal does not exist, in fact lists, right? Let's sorrow runner tests with this dash, dash watch option. And as you can see, well, the tests are failing. So let's create the implementation of these methods. So I'm going to say convert from base n, two decimal. And I'm going to say number to convert. Okay? And this is going to be a string. Y is string. Well, because we convert from hexadecimal to decimal, and that is going to contain letters. Okay? So that's why we are first covering these cases where the number is in a base that is less than or equal to ten base from, which is the second argument is going to be a number. And this is going to return a number because a decimal is always going to be a number. We're, we're always sure that the decimal is not going to contain letters. Okay, so in order to convert from baseband to decimal, I'm going to give you an example here. So 1101, this is in binary. So we can convert this to a decimal by saying, OK, we're going to say two to the power three multiplied by this digit here. So because this is, this digit is in position three. So position and start from right to left and begins with 0. So this is position, sorry, at position 0, position one, position two, and position three. So we say two to the power of the position, which in this case is three multiplied by the digit which is one. And then we sum two to the power of the position, which is two multiplied by the digit, which in this case is one plus two to the power of the position multiplied by 0, which is the digit, plus two to the power of 0, which is the position, times the number. So this is equal to eight plus four plus 0 plus 0 plus one, and this is equal to 13. So suppose that this is not in binary, but in the string. So the only change we have to do is to replace two with 32, with 3232 or three. And that's all we have to do in order to convert from base and decimal. Ok, so let's start doing this. First. We're going to create a digit, sorry. So we're going to take advantage that the number to convert this string, so we can form a list from this string. And each element of this array is going to be the digit as a string. So number to convert. Okay? And we're going to say let position b equal two digits, array that length minus one. So this is a lead, but because it's not been changed, It's changing me these automatically to cost. So we're going to change it later. Lead result equal to 0. And now we're going to do a for loop. We're going to say forecast digit of digits array are going to say a result plus equal math. Bow. So this is the power function. And we're going to say base from physician and multiply by pars int digit. Okay? So now we have to say that this is let. And then we are going to decrement the value of position, so position minus, minus, and we're going to return the result. Okay, so I think this works because the test just passed. And yeah, I think this is working correctly. So in the next video, we are going to now cover the case when we have numbers that are EMBASE greater than ten. Okay? So I hope you like this video. See you in the next one. Bye-bye. 9. Implementing a method to convert from base N to decimal (part 2): Hi and welcome back. So in the last video we covered those cases where the base, the base is less than or equal to ten. Now let's creates some other cases where the base is greater than ten. So let's put describe when given a number in a base that is greater than ten. Okay? So I'm going to say the same shoe converted to decimal. Okay? And we're going to expect the converter dot convert from Bei sent decimal. And here I already have some test cases. One, A1 in base 11 is equal to 232. Let's repeat this thing. And here I'm going to say one B1 in base 14 is equal to 3.5.1. Abc in base 16 is going to be equal to this number here. Okay, so now our tests are failing. So you can see here in the first expect statement, we expected to 3-2 animal, very sift man. So that's because here, when we parse the int digit is going to be a letter. Ok? So a litre, you, we pass a letter to the parsed into this is going to be none. So we have to do something in order to correct this. So in order to do this, I'm going to create a new folder called constants, okay? And inside these constants folder I'm going to create a file called letters to numbers, map dot ts. And I'm going to say export cost, letters to numbers, map, okay? And we're going to say a is equal to ten, B is equal to 11, Cs equal to 12 is equal to 13, is equal to 14, and F is equal to 15. So in the first version of our package, we're only going to support until base 16. Okay, so that's why we're only going to have from a to F. And we also are going to specify that this object has keys that are strings and values that are in numbers. Okay? So now instead of using these bars int function, we're going to define our own function that it's going to be called get digit as number. Ok? So this is going to receive a digit which is strength. And here we're going to say let result equal to parse int the digit. So if isn't and that result is nan, then we're going to say a result Is equal to letters to numbers map of the Egypt. Finally, we return the results. So instead of using the sparse int, are going to save this dot get digit number. So it's private method because we're not going to use it. It's just for internal purposes. And now our test is passing, as you can see here. Okay, so now all of these cases are covered. And I think that we don't need to do anything else inside this convert from baseline to decimal. Ok, so that's actually remove this current here. Well, I'm not going to remove this comment. Instead of removing the comment in the TS conflict that JSON file, I'm going to say, I don't remember the option. Here it is, remove comments equal to true. So I don't want in my final built to put any comments. Okay? So maybe this comment is useful for us and we don't want to put it in the final built. Okay, so that's everything. I hope you liked this video. See you in the next one. Bye-bye. 10. Implementing a method to convert from decimal to base N: Hi and welcome back. So now that we have these convert from base and to decimal method implemented, now are going to build a convert from decimal to base and method. So first we're going to write the tests, and I'm going to say convert from a decimal to base m. Ok? So it is clear that I'm going to test now this method. And I'm going to say the scribe, when given a decimal number. When given a decimal number, test should be converted to a base and number. And here we're going to put all of our tests. So I'm going to actually copy all of these tests above and just swap this with this. So I know that the 1101 in base two is 13. So now 13 is the decimal. And this is the result also is going to be called convert from a decimal to base n. Okay? And let's slab this things here. So instead of this one to say this, this are going to say this to the 3-2, 3.5.1 here. 274. Okay, so now we have all of our tests. And before we implement that method, I'm going to create a utility function. So I'm going to create a folder called utils. And inside utils, I'm going to create two files, inverse object that ts and inverse subject that test.js. So we're going to first write the test and say when given an object, test, shold reverse the keys with the values. Okay? So I think AT some very clear what this utility function is going to do. So we're going to say in expect inverse object. And here we're going to put a, ten, b, 11, C, 12, are going to expect this to equal 101112 C. So we're just swapping the keys with the values. So now let's create the implementation of this function. Inverse object is going to take as a parameter an object. And an object has a generic object, has these type record the string unknown on work going to are going to still return a string unknown. Okay? So now we're going to return object dot keys of the object are going to reduce it. The first argument is the accumulator. I'm going to call it reverse the object. And the second argument is the current buddy, which is the current key. So I'm going to say Gosta value SQL to object CHI reversed object of value is going to be equal to the key. And we're going to return the reverse the object. And the second argument is the initial, the initial value, which is going to be an empty string. Ok, so now here it says that type of known cannot be used as an index type. Because remember we're saying, hey, the value is of type unknown. So I'm going to say, hey, believe me, this is going to be of type string. Now, it says that element implicitly has an anytime because expression of type string can be used to index type and these empty object. So in order to solve that problem, I'm going to say, hey, these empty object is of type string unknown. Ok, so a little hats from type script. And now this test shall be passing, but it's not passing because we need to import in bursts object from inverse subject. So let's import inverse object. Let's test these file. And in order to death his foul, we just say John test. And the name of the file which in this case is inverse object that test.js. So now this is passing, Okay, so we're happy with that. And now we need this thing to bass. So let's go to the base converter. And first of all, let's fix the name of this thing because right now it's letters to numbers map, but then they, you in numbers is capital. So I'm going to simply saying this. And now we fixed that. Ok, So inside here, inside of the class, I'm going to declare a private property which is going to be numbers to letters, map. And in that constructor, we're going to say these numbers to letters map is equal to inverse subject of letters to numbers. Map. Okay, so that's why we created that inverse object function. And now we are ready to convert from decimal to basin. So convert from decimal to base. And so we're going to receive a number to convert, which is going to be number because it's a decimal. And base two, which is going to also be number. And we're going to return a string because we coul be converting to a base that is greater than ten and that will contain letters. So if you don't remember how to convert from decimal to Basin, here I have an example of how to do it from decimal to binary. So we have the number 44. We divide it by two, that's 22. And we note that the remainder, which is 0, and we keep doing the same thing. 22 divided by two, that's 11 with remainder 011 divided by two, that's five, with a remainder 15 divided by two. That's two. We've remained there, 12 divided by two, that's one with a remainder of 0. And our decimal represent, the binary representation will be these last quotient. And we concatenated with this number, this number, this number, this number, this number. So we go backwards with the remainders. So we could potentially put all of these remainders in an array, then reverse theory, and then concatenate each element of these reversed array with these last quotient. So that's exactly what we are going to do in this method. So first, let's create a copy of this number to convert. So we're going to say number to convert, copy. Gus, we didn't want to, I don't want to modify the original argument. And also let say const remainders, which is going to be an empty array right now. We're going to say while true. Let's calculate the quotient, which is going to be math dot floor number to convert copy divided by the base, in this case is two. The remainder is going to be equal to number to convert copy, number to convert copy modular base two remainders that bush. And here comes the tricky part. If the remainder is greater than or equal to ten, then we're going to call this numbers to letters map, and we're going to pass the key the remainder. Otherwise we're going to convert the remainder to drink. Okay? And finally, we're going to say number to convert copy is now equal to the quotient, okay? And if that number to convert, a number to convert copy is less than the base, we want to convert base two. Then we're going to break, sorry, break these while loop. Okay, so now we're going to reverse the remainders. Remainders though the reverse. And we're going to say lead the result equal to number. If number to convert copy is greater than or equal to ten, then we're going to say these numbers to let our estimate of the number to convert copy. Otherwise HS number to convert copying that to string. Okay? And finally, we concatenate these result with each element of the remainder. So we're going to say remainders that for each remainder, result plus equal remainder. So result needs to be declared with leapt. And finally, we return the result. Okay, so now we are having Type Script complaining because it says that object is of type unknown because these returns something that ease of type of known. So we can tell tab scrim, done sweat it, disease of type string and problem solve. Okay, so now let's run the tests and see what happens. So all of the tests are now passing. So just to be courageous, I want to also see that coverage. So I'm going to say darn test coverage. And it looks like we are having 100% of coverage. Also load that these folder coverage got created. But we already put that in the gitignore, so don't worry about that folder. Okay, so we have done a lot here. So let's stop for now and see you in the next video. Bye bye. 11. Supporting decimals: Hi and welcome back. So we are going to add a new functionality to our our base converter. Plus. More specifically, we're going to extend the functionality of this convert from base end to decimal method so that it accepts no numbers in base n with a decimal part. Ok, so let's write the tests. I'm going to say when given a number in base and with an integer and decimal part. And the test's, he's going to say should be converted to a decimal number. So when I say decimal part, that's the thing that comes after the point. And decimal number is a number in base ten. So I'm going to say expect converter that convert from base entered decimal. And I already prepared some test cases. So I'm going to say 1.10101 base two should be close to 13.5. Have another case if you want, you can put more cases. 1.12234 in base h should be close to this number here. 56 to five. Okay, great. Now our tests are not going to pass or isn't it? So let's make these things up best. Ok, so remember that we had this example here. Now let's add dot S11. And well, something I didn't mention is that in our first version, we're just going to allow here a point we're not going to allow commas are something like that. Okay, so here we just have to do something else. We just have to sum two to the power of minus one multiplied by the first decimal, which is one. And then continue with two to the power of minus two times the next decimal. And here, obviously, you just have to say plus 1.5 plus 1 fourth and so on. And this is going to be equal to 13.75. So not much to do here. Let's declare a private property called delimiter, which is going to be the point, ok. And here I'm going to filter digit, digit not equal to this dot delimiter. Okay? And also here, these digits array dot length is not what we want. What we want this number to convert. Data, split these dot delimiter. And I want the first element of that thing. And that will be the initial position, and then nothing else changes here. So as you can see now, my tests are passing. Okay, so I think that's everything we need to do here. I hope you liked this video. See you in the next one. Bye-bye. 12. Validations: Hi and welcome back. Today we are going to talk about a very difficult topic that is validations. So don't believe the opposite. Validations are very, very complicated because there is a million ways that the user can break our app or break or misuse R package. Okay, so we are going to catch only those errors that are the most important, but they can misuse R package and the package throw an error that we didn't know in advance. Okay, so let's write a described block. And inside this describe block, I'm going to say when given an invalid number in base m, Okay? I'm going to say should throw an error indicating that the number is not a string. Okay? And I'm going to expect the following. When they expect to get an error, I need an arrow function here. And inside this function I'm going to say converted dot-com bear from basin to decimal. And I'm going to pass a number. So remember, we're just going to accept a strength here in base two to throw an error. Number to convert must be a string. Okay? So here we have an error same argument of type number is not assignable to parameters type a string. And that's because here we have set type script hey, number to convert needs to be a string. Okay, but let's actually build this theme with Darren built. And OK, so now we have these build folder. Let me reload my window so that it shows in green. Ok, so now there is my build folder in green. And I wanted to show you that that is in green because I'm going to put that in the gitignore because we don't want to be able to be in our rebel. And here I'm going to the base converter. And as you can see, here is my number to convert argument. And there is no place here where it says Hank number to convert needs to be a string. Okay, so we still have to meet that validation. Because type script is not going to say hey number to convert, its going to be a string in the compiled code. Okay, so let's first start or finish our tests. So the second test is going to be shoud. Throw an error indicating that there is more than one millimetre. So what do I mean by this? So if I have something like this, k, I expect these to throw an error same number contains more than one millimeter. So we can have something like this. These looks more like an IP address and a number. Now another test, shold, throw an error indicating that the number is invalid. And I think this is the most important. Why? Let's write to expect the statements here, convert that Gumbert. And we are going to have 123. Well that's a valid string as a number, but it is going to be in base three. And I'm going just the same valid number here. So although this is a valid number, this is in base three and we cannot have threes in a number that is invasive tree. Ok? What did I do? Okay. So another thing I want to see is that, for example, if I have a net here, these, she'll also throw these invalid number error. Ok. So let's run Yarn test, dash, dash, watch. Ok. Let's make these tests pass. Okay, so what did I do here? Okay, so let's raise my here. That's greed, the method that is going to be private and he's going to be validate number in base ten. And it's going to receive the number to convert, which is a stream with theory base from which is going to be number. Okay? And I actually forgot, I actually forgot to make another validation, which is I said, OK, so here are all my test cases. So should hold, throw an error indicating that the base from Moscow being number. So base from she'll also being number. So it's actually companies. And suppose this is in base five, valid base. And again, we need this as unknown number. Okay? So here we need this to be as a known string. Okay? Okay, fine. So now let's start implementing these validate numbering basin. So first of all, we're going to say if typeof number to convert this different from a string, then we're going to throw these new errors. Sane. Number to convert must be string. Also, if thigh above base from He's not number. And then we're going to say, we're going to put another message here. Base from needs to be a number. Fact this needs to be an integer. But we're just going to assume that the user is going to put any integer. So that's a bad assumption. But I don't want to waste more time doing lots and lots of validation. Okay, so what else? Okay, now we have, so this should be passing, but it is not passing because we have to call these validate numbering basin. Okay? We have to pass number to convert and Bayes theorem. So as you can see, these tests here are passing. Now we need the swans to pass. So how do we check if there is more than one millimetre? So I'm going to say const the split that number by delimiter number. This is going to be number to convert data split these dot delimiter. And I'm going to say if the split number by delimiter dot length is less than one or is greater than two. Now we're going to throw a new error. And I forgot the message. Numbered contains one more than one delimiter. Okay? So here is length. And now you're gonna see this test is passing. Finally, I am going to make this test pass is the most important one. So for this, I am going to say const digits, SQL to array dot from number to convert. I'm going to filter this is different from Delhi meter, okay? And I'm going to say forecast digit of digits, const digit S AS number. And I'm going to use that digital number, get digitals number private method when two digit. And here I'm going to say if typeof digitals number is undefined, or if d t does number is greater than or equal to the base from. And we're going to throw a new error. And that error is embodied number, so racing and valid number. Now, all of our tests are passing. So as you can see, we have lots and lots of good and these can get very, very complicated easily. So remember you have two options when doing validations. The ones make us much validations as possible. The other option is done. The main validations are all led, the baggage fail silently. So that's everything for this video. I hope you like it. See you in the next one. Bye-bye. 13. A little correction to convertFromDecimalToBaseN method: Hi and welcome back. So we are getting to the end of this series of videos of how to implement this base converters. So as you can see, it's not an easy task, but we are getting at the end of it. So before continuing on implementing the capacity of converting the decimal part of a decimal number to a base and number. We need to correct something in our, in our convert from decimal to base and method. Okay, so let's add another describe look and say, when given a decimal number that is less than the base, we want to convert. Okay? And we're going to say shoot, converted to a base and number and delete the zeros from the left. So what do I mean by this? Let's put an expect statement here saying convert from decimal to basin, and that's the number we want to convert. So for example, ten, suppose we want to convert it to base 16. So this should be equal to a, right? Because a is ten in base 16. Okay, now, let's run urine test and see what happens. So as you can see, these test failed. Here, it says expected a and I received 08. So you can make the calculation by hand. And you can see also that these method is going to return a 0 and an a. So we have to do something in order to avoid this. And here before returning the result, we are going to say the following. While result 0 is equal to 0, the character 0, because remember result is, is a string and result dot length is different from one. Are going to say or assault is equal to result. Sorry, slice one. Okay? So let's see if now the spaces, so now it passes. So what we're doing here is dreaming all the zeros from the left. And yeah, that's basically what we are doing here. Okay, so that's everything for this video. In the next video, as I said, we're going to convert the decimal part of a decimal number to a base and decimal if you want to say it like that. Okay, bye. 14. Supporting decimals for convertFromDecimalToBaseN method: Hi and welcome back. So let's go to the most difficult part of this course, I guess, which is converting decimal parts of a decimal number to a decimal in bay in a base n number. Ok, so let's put a nother. Describe luck. And again, I have already investigated these test cases. So let's say when given a decimal number with the decimal Bart test, shold convert both the integer and the decimal part with a given precision. Okay, so when we convert the decimal part of a decimal number to base a number, we need a precision because sometimes a finite decimal in a number in base m cannot be finite in a nother base. So I think this is one mistake I made. I made that I didn't explain you the math behind these things. But this not a course about explaining this. But it's very, very easy. In fact, I will post this link from in-depth that the f, because I think this is the best explanation out there for programmers to understand how to convert between basis. Okay? So here I'm going to put expect converter dot convert from decimal to base n. And I'm going to say 10.8 to two to equal 101011. So that's the equivalent in, in base two. Now, let's actually do the same but with the same number. But in basic, it's going to be 12.63. And here it's going to be base 16, it's going to be a dot cc. So we are going to set a default precision here to this method, convert from decimal to Basin. So let's start actually coding this think. Okay, so some things you need to do, you need to know, sorry, before coding this. Well, obviously that's the algorithm in order to convert from a decimal to base n. Okay, converting a decimal fraction to binary for example. Well, the idea is to basically take the decimal part of the decimal number multiplied by the base. And then taking note of the integer part of that multiplication and then repeating this process but with the decimal part of that multiplication. So again, I'm going to put this link here so you can understand in depth what is happening. It's very, very simple to understand. But that's basically the algorithm. And as I said, we have to set the precision because finite decimals in base, in base ten, sorry, are not going to be finite decimals in a nother base, okay? So everything we wrote here is only valid for the integer part of a decimal number. So let's actually creating another private method that is going to be called convert integer Bart. And what we're going to pass some parameters here. The, let's call it integer part, which is going to be the number. And base two, which is also going to be a number. Okay, so everything here is going to be inside that myth. Okay? So let's put everything here. And obviously we have this error saying that this number to convert copy does not, does not exist. That's actually going to be the integer part. So let's rename this variable to integer part. Okay, fine. Now we have this method and these method here. So it looks like, okay, so it looks like this bracket was not needed, so it was part of this map. Okay, now let's do something here inside this convert from decimal to base m. Let's extract the decimal part. And how do I do this? Well, I'm going to say number to convert copy modulo one. So y modulo one. Let's go here to the console and for example, say 10.56 modal one. That's going to give me the decimal part. And if I type Math.floor 10.56, that's going to give me the integer part. So now we have, now we know how to extract the integer part and the decimal part. So the integer part is going to see, it's going to be Method floor number to convert. A number to convert copy. Okay, fine. Now we have to say converted integer part. And here's where we're going to, we're going to call these methods, these converting into your Bart. And we're going to pass the integer part. And the based. Fine. Now we have to do something. If the decimal part exists, decimal part exists, we have to return something. But if the decimal part doesn't exist. So for example, if we do modulo ten, modulo one, that's going to give me 0. So VC investing minutes not going to be executed. We just return that converted integer part. Okay? Here, if the decimal part exists, we're going to say converted decimal part. And here we're going to define a convert decimal part private method. And we're going to pass the decimal part, are going to base the base we want to convert, and also the precision. So as I said earlier, the precision is going to be a number and we're going to give it a default value of two. So when we give a default value, type script is going to infer the type of this, which is a number, so we don't have to specify the number. And then we're going to return the convert, convert to integer part, the converted decimal part. So we only have to define this convert decimal part private methods. So let's do it. Convert decimal part. And we are going to receive the decimal part, which is going to be, sorry, a number. The ways we want to convert number again and the precision again, a number. Okay? So we have to implement the algorithm, which is basically this one. So let's do it. Let's say lead the result equal to an empty string. Let decimal part copy. So we're going to create a copy of the decimal part because we're going to modify this verbal. And remember, it's a, it's a best practice not to modify the original argument. And we're going to say for let i equal to 0, i less than the precision I plus, plus. We're going to do the following. Are going to say decimal part copy. And we're going to multiply it by base two. Okay? And then we're going to extract the integer part of that decimal part copy. So we're going to say math dot floor, decimal part copy. Okay? And then we're going to say result. If decimal part copy is greater than or equal to ten when, well, we're going to say these, that number. So there's map integer part. Otherwise, we're going to simply append this integer part but as a string. And finally, we're going to say that the decimal part copy is going to be equal to that decimal part of the, of this multiplication. Ok, so result needs to be declared with lead, and this also needs to be declared with that, with lead, sorry. And finally, we have to return the result. So I think that by doing this, our tests are going pass. So let's see. If they pass. Yep, they are all passing. So I know this was a very long video and lots of math happening here. But hey, now you know how to convert from decimal fractions to any base. And that's very, very cool. And more cool will be view, understand all of these math behind these conversion. So I highly suggest you to read this article here. Okay, so I hope you liked this video and see you in the next one. Bye-bye. 15. Yet more validations!: Hi and welcome back. So last thing I want to do here is to validate that we pass a number, a decimal number two are convert from decimal to Basin and also validate that the bases are integers and also that the precision is an integer. So here we're going in the UDL folder, we're going to create two files. The first one is going to be called introduce, We're sorry, is integer that test the Ts. And the second one is obviously going to be is integer dot ts. So let's write our tests. So first tests. First of all, sorry, we're going to import a function that is going to be called East integer from the file is integer. Okay, so let's start with the describe block. And we're going to say when given something that is not an integer number, are going to say test should return false, or are going to make that our function returns the Boolean. Ok? So we're going to say is integer, expect these integer. And here we're going to pass a string something like ANOVA test. And well, we are going to have a problem here because in the type script, the finishing or going to say to this integer is integer function that we're going to only accept numbers, but we're passing in a string. So in order to avoid that, we're going to say test as unknown as numbers. So that's a hack. If you want to say to pass a string to a function that only expects numbers. And here we can say to be falsey, we can use this thing here, but I really prefer to say to equal false, okay? So is integer. And now here we're going to say 12.45. And again, you can say to be falsey or to equal false. So I think I prefer writing to equal false because I think it's more descriptive. Okay, so that's our first describe look. And in the second ascribe log, we're going to say when given an integer number. And that test is going to be shold return true. So remember or trying to have 100% coverage. So we have to have this case. So we're gonna say is integer 12. So equal true to equal true. Or you can also put to be truthy. So to be truthy, or it is, but I'm going to stick with two equal true. Ok, so now obviously are attest this not going to pass because we don't even have that function to find. So let's create that function here. Export const is integer. We're going to set the number, type number. And it's going to return a boolean. And here we're going to return the negation of these expression here. Type of number is different from number or number modulo one. So again, let's run our test to see if this test is passing. And yes, you can see that all of these tests are passing. Okay, so now that we have these utility function, let's go and modify a little bit our validate number in base n method. So here instead of putting this condition type of base parameter equal to, not equal to number, or just going to say, if it's not an integer, the bass drum. And obviously we have to import this. Okay? So here we're going to say base. Base. Say base needs to be an integer. Okay? Now let's the fine, just a, both the convert from decimal to base and method. Let's define a nother validate elevation method. And obviously going to be private. And we're going to say validate this small number. And we're going to say number to convert. Just going to get a number. We're going to also pass base two number, position number. Okay, so first thing we're going to validate if, if base two is not an integer, again, we're going to say base needs to be an integer. So basically the same validation from here, we're repeating some code, but then where it's just one line of code we're printing or two. Okay, so here we're going to say if it's integer, if it is not an integer, sorry, the precision, we're going to throw this error saying that the precision needs to be an integer k. And finally, well, we cannot say. A number to convert needs to be an integer, but we can check if it is a number and not so simple check here. If typeof number to convert is not equal to a number, then simply throw in your same number to convert needs to being number or number type whatever you want to put in a message. Okay, so maybe you can extract this thing here. And this thing here, sorry, this thing here in a, another method. But I'm not going to do that. I'm not going to, I made these videos longer. So here I'm just going to say this dot validate decimal number. We're going to pass everything number to convert to and precision. And there we are, we have everything. Let's see if our tests are passing jarring test. So one test looks like is failing. And that's because we changed this message here. So we're going to stick with the same message base from needs to be, well actually let's change the message in the test. So here, base needs to be an integer. Okay, so again, let's see if this is passing. Yet looks like everything is passing. But let's see the coverage. So let's see if we are 100% or not. So it looks like we're missing these lines here. We have some uncovered lines. So let's go to those lines 84, which is this 187, which is this 119, which is this one. So I'm going to write yet another describe luck here. So be sure to these new describe luck is inside this convert from decimal to Basin and lets you, when given invalid parameters to the method. So we know what method is because we are describe luck is inside this block. And say, shoot, throw an error, indicating that the base needs to be an integer. So in this first case, we're going to see, we're going to say Expect. And remember, when we expect something to throw an error, we have to wrap it inside a function. So here we're going to say converter that convert from a decimal to be sent. And here I'm going to, but some number and base two is going to be a decimal number. So here I'm going to say to throw error and the error message. So let me close these files here. And the error message is going to be base, needs to be an integer. Okay, so first test, second test should throw an error indicating that the precision needs to be an integer. Okay, so again, the same thing. Let me copy and paste this thing here. And here I'm going to pass a valid base, base 12. And the precision are going to put the decimal and throw error. And let's copy this error message. Okay? And lastly, we're going to say should throw an error indicating that the number to convert needs to be num. Okay? So here we're going to say, I'm going to copy this line here, put it here, put this error message. Okay? And here we're going to pass something. So I don't know this test has unknown as number. And here we're going to put some valid precisions. Okay, so now let's see if everything is passing with John test. Yeah, everything is passing. And let's see the coverage. So now it looks like we have 100% of coverage. So that's everything for this video. I hope you like it. See you in the next one. Bye-bye. 16. Adding a method to convert from base N to base M: Hi and welcome back. So now we're ready to implement our last method, which is the Convert method. So we did all of these hard work just to implement this method. So as usual, I'm going to create the tests first and then implement the method. And it is going to be really, really easy. So let's creating there the scrap luck with a Convert method name. And we're going to say the scribe, when given a number in base n and a number in base m, the test will be shold. Convert the number, the number between these base. Okay, so we're going to put here you bunch of expect the statements. In fact, I already have them here. I'm just going to copy and paste them. So you can write tests for each of these one, for each of these cases, but I'm just going to put all of them in this test case. So as you can see, this is the Convert method. It's going to accept a string as its first parameter because remember the scan have letters or numbers. So we're going to live these number as a string. Also. We're just going to test the happy path for the sake of time. So if you want, you can add more tests. For example, I didn't have test here for numbers with letters, but that's fine. Okay, so the first argument's going to be a string, and the second argument is going to be an object. And this object is going to have, well are going to define the properties of this object. But here I am passing these from base to base, firm based property and today's property. And also we can specify here a precision preference. So we're going to be more specific about this. And these are all the test gaze. Think they are self-explanatory. So for example, here, we want to convert the number ten from base ten to base ten. So that should be ten. If we want to convert ten from base to base two, that should be 1-0, 1-0. And well, I think this is self explanatory. So we can convert from base n to base m. That's the core idea. So how are we going to do that? So I have a diagram here. And in order to convert from base n. Base m. Well, we can simply first convert these base n number to a base ten number. And then we can convert from base ten to base m. So we have these two functions that do precisely this converting from base to base ten and another method that converts from base ten to base m. So all the job, it's done. Every single method has their validation, so you wouldn't have to re-invent the wheel with more validations. So let's just go and implement this thing. So one key point that I wanted to note is that I only have here two arguments, so the number to convert and these, you can say convert options. And why did I do that? Well, if you have read these famous book called clean code from Robert C. Martin, then you have to know that functions must have at most three parameters. Okay, so I have already created the methods with three parameters. And I don't want to go beyond that. I just want at most three parameters. So here I'm going to say two parameters. And here I'm going to place a from base to base. And if you want also that precision. So in type script, we can actually do the following. We can say, well, converts going to be our method number to convert this going to be string. And we're going to distracter this object, which is going to be from base to base, and the precision which is going to be two by default. So we have to give a type definition to the subject. And for that I'm going to create a new folder called interfaces. So here I'm going to say convert options that ts. And inside here I'm going to say export interface convert options. Firm base is going to be a number. So base is going to build the number. And the precision that it's not, it's not required, is also going to be a number. So now we can say that type of this object is going to be Gumbert options. So here you go. This helping me to autumn poor discomfort options interface will also be a type if you want. And now we simply need to add two lines of code here. So first of all, I'm going to say jar and test dash, dash, watch. So we can say we can see that the tests are failing. Tests are, are failing. Now we only need to add these two lines of code. So decimal number, It's going to be these dot convert from base and to decimal. And then we're going to pass number to convert. We own and we also need a base firm. So I rename it to from base because I think it's clearer if we say from base, and then we have to return these that convert from this, from, yeah, from decimal to base n. And we're going to pass the decimal number and the base two to base and the precision. So sorry, to base two, base and the precision. And here we're going to specify the return type of this method, these stream, but you're ready so that all of the tests, test. Okay, so that's everything we needed to do in order to add last, define these Gumbert method. So now we have a very powerful functionality which is convert from any base to any other base. So I hope you liked this video. See you in the next one. Bye-bye. 17. Typedoc: Hi and welcome back. Today we're going to learn something very, very interesting, which is type doc. So type doc is just like an extension of JS doc for type script. And if you don't know what is Dark is, well, it's basically a way to document your code. And well before types grid, we also didn't have a way for knowing, for example, the, the types of the parameters of functions. So JS doc was a way to know the types of the parameters and things like that. So I'm going to show you actually an example. So just search for JS doc. And as you can see, we have here the Getting Started page. We have the simplest documentation is just a comment, okay? And you can also add, for example, this Add constructor or these Ad Parameter and specify that this is going to be that this function receives a string title, and that title is the title of the book. And also another, which is another string. And it's the author of the book. So this is the simplest things you can do with JS doc. And type Dark is just an extension for type script. So four tabs grit with a need that kind of things because we already have that type definitions in the function. So for example, in these get digitals number, we're expecting a digit which is a string. And we don't need that kind of things. However, we can still put some kind of comments of, for example, while the Convert method dust and things like that. So don't believe in that light, that good needs to be self-explanatory, that total lie. If I come back to this project in a year, I'm not going to know what I did. So that's why comments are very, very useful. And typedef also give you extra functionality. So we're going to see what type doc does. So first, we need to have type doc and also are going to add serve. Because type that is going to throw you an index.html file that we can see in the browser. And in order to see that we're going to use the surf baggage. Okay, so Let's add these two things. And in the meantime, let's create another file called type doc dot JSON. So this is basically a configuration file. Aids liked his conflict can also put that configuration TS conflict, but let's just put this configuration in a another file. So we're going to say entry points is basically where shold type doc, search for functions, for classes and all that stuff out is going to be, where do we want our index.html file that I just mentioned to be? To be thrown. And these exclude we can exclude what types of files we don't want in our documentation. So we obviously don't want the index and also within the London tests. So in order to say type doc that we don't want those files are going to say, we're going to write this expression here. So it's a bit strange how type dark uses these patterns, but this is how they do it. So we're going to say with these two stars search everywhere. And inside this everywhere, search for everything that has this index or this, or this dot test and end with these dot ds extension. So when we type, type doc in our terminal, we're going to take these type dot dot JSON as their configuration file. However, we're going to define two additional scripts. So the first one's going to be build docs. So build arcs is just going to be type doc. And surf dots is going to actually be the combination of jar and Bill ducks and yarn. Sorry, sir. Sir. Docs, which is the folder where that index.html file it's going to be. So let's run the first script and John bill ducks. And as you can see here, we have the index.html file that I already show you with lots of other things. So it's a matter of preference if you want these in your repo. I usually don't like these kind of things in my wrapper, so I'm going to also put that in my gitignore file. Okay, so now that we have that thing built, are going to say jar and surf ducks. And now we can access this from local host or 5 thousand. So let's go there. And as you can see, we have here this page, and here at these right panel we have these exports. So let's click on this. And here we have all of our exports. So we have this base converter is convert options. So let's go through each of these ones. Okay? So in the base convertor, it says that we have these classes. This is a base converter class. Okay? So here we have a legend that mentions that this is a glass. And here we can see that here are key. So if we were extending this thing serine or inheriting this from a base class, it will show us here. We have the constructor, we have the methods, for example, the convert. We convert from base and decimal convert from decimal to base n. Okay, so here we have the constructor and here it tells that we can create a new instance of this class by simply saying new base converge. And it will be of base converter type. And here also you can see that convert method that receives the number to convert, which is a streamed and named parameters, which is of type convert options. So if we click here while going to the definitions of these convert options. So we basically these other tab here. So we can also see it from here convert options. And we have the front base, which is number precision, which says that it's optional. And two base, which is a number. So very cool. It says that this returns a string. We also have these other two methods and everything is very, very well-documented. We have, for example, here the a's integer which says that he's a function. And here it says that it receives a number and returns a boolean. The same with letters to numbers map. It says that this is a variable and the type declaration ski string and the value using number. And lastly, we have these inverse object. So it says that it receives an object which is rigorous. String are known and returns a record stirring in them. So basically. And so we can also search, for example, we can search here base converter if we want to go to that base converter class. So here we have base converter class, or we can go here. So it's very, very cool because this is extra documentation, so we don't need to go to the code and see everything. We see that the base converter has all of those method because we have all of this documentation. So this is very cool for people that want to get started. Or once you get acquainted with your base, good if you're contributing to open source bright, like we're doing now because at the end of the day, this is this an open source project. So very, very cool. So that's all for this video. In the next video we're going to see, we're going to add just some comments so you can see how they get shown here in the speech. So I hope you liked this video. See you in the next one. Bye-bye. 18. Comments on Typedoc: Hi and welcome back. So let's put some comments to our base converter class. But first, let's modify these type doctor JSON a little bit. I'm going to include two more properties here, which is name, are going to say vase converter. And we're going to say include version. So this basically is going to, Well, I think they are self-explanatory. So let's go and see what happens. So now we have the base, base converter title here and version 1.0.0. This version comes from the package jason, So it's the same as dispersion here. Okay, now let's go to our base converter class and let's see an example of documentation with these Convert method. So I'm going to say slash to stars and VS code is going to help me to autocomplete this. As you can see, the seas js.com. Well, exactly, it is typed OK, but it has the same syntax. So here we're going to say this function allows you to convert a number in base and to a number in base m. So as you can see, I'm using Markdown syntax here. We can use Markdown syntax in these comments. So in these Bram number to convert, I'm going to say the number in base n. We want to convert. And here param1 refers to this whole object which is structured. So when you have a, an object that is destructor in type doc, it is going to be called name parameters. So named parameters is going to be an object with the options for the Convert method to work. And finally, we can say it returns the number in base and converted to base M. Okay, so unfortunately we didn't have like a dash, dash watch, an option here so we cannot see the changes in real time, so we have to rebuild the dogs. So no big issue when everything is okay. Let's go to the base converter and let's go to the Convert method. Another thing I wanted to tell you is that here you have these drop-down where you can set the public, the public and protected or also I'm just going to filter by public. And here in the Convert method you can see the comment we put this function allows you to convert the number and they sent a number in base m. And here you can see that n and m are highlighted with the Markdown syntax. This number to convert also has our comment, a number in base, and we want to convert and main parameters are the convert options. So that object that was structured and it returns the string, the number in base ten converted to base m. So you can get very detailed with your documentation. And this is a best practice because code that is self documented, as some people say, that's a lie. If you, if you come to these gold one year later, you are not going to remember what exactly you did. And this is a simple package now imagine and larger package, it's going to be very, very difficult to remember. So these documentation, documentation helps you a lot to remember what each of these method does. Now here we can switch again to the, to all. And we can see now the properties. So for example, the delimiter and numbers to letters map. And we can see also the private methods. So convert decimal part, convert integer part. So you can also document those things. And I think those are the, the method that you should concentrate more to document because those are private. So those are not exposed in your class and they do vary on the shoulder, very specific things and very specific things related to your business logic. So I think those are more important to document than these ones, okay. Because either way we're going to also document these ones in our rid me because these are the things that we are going to expose in our package. Okay, so I hope you liked this video. See you in the next one. Bye-bye. 19. Solving compatibility issues: Hi and welcome back. So before we write our rate may want to do some modifications to the scripts in order to have compatibility with windows. Okay, so let's head to the deaf dependencies. There are going to be npm run all and Reem rough. I actually didn't know how to pronounce this. I think it's really rough and what these packages do. Well, let's go to the docs here and let's see npm Reynolds. So our problem with Windows is described here. We sometimes use the ampersand to run multiple commands in parallel, but cmd.exe npm run scripts uses, by default does not support the ampersand how Node.js users are using it on Windows. So they use of these amperes and my blog contributions. So npm run all dash, dash parallel works well on Windows as well. So I think that in PowerShell or you didn't have these double and percent think they D think here we didn't have that in PowerShell, so we have to solve this problem. Also, it simplifies lots of things. So the official npm RAM script, a man cannot run multiple scripts, so we want to run multiple scripts. It's redundant, upbeat. Let's shorten it by glob like patterns. So you have these before and after, it gets simplified. So also we have these npm run on. We have RUN S, which is basically this thing. But this is a shortcut. Rennes means sequential and run beaming sprouted. Okay, so we have already installed in PM10 and also let see what brain graph does. So unix command RM dash R, F. This is for deleting a directory. So we use these for the land directories, but we cannot use these on Windows. Okay? So again, we have a compatibility issue here that we're going to address right now. So let's add some more scripts clean. It's going to be a rim rough field. So we're going to delete our build folder and build JS. It's going to be TOC. And build is going to be npm, run all clean and then build GS. Okay, so I think that was pretty easy. Now test, we're going to leave it like that. In this test, we're going to add another script, clear cache, just dash, dash, clear cash. Okay? And we're going to also add this coverage, although we already have a defined here while going to redefine these in a moment. So it is going to be just dash, dash coverage. And here we're just going to say coverage. So coverage is going to be just the combination of these two. So npm run all test colon star. Ok. So maybe it's safer if we just put clear cache and the test coverage because we can have more things here, but we only have these two things here. So it's safe to boot desk colon star here in leaned. Well, I'm going to actually do include the 50x flag here. Okay? And then we're going to modify this a little bit. We're going to say dogs build type dog and dogs surf, surf dots. And in CRF dots, we are going to say npm, run all surf, sorry, docs, column, star. And one more, which is going to be the bread commit. That's going to be npm, run all check types and lean. And that's all. So in our husky, We have to here, change this with jargon, break a mint, and here with John coverage. Again. So now let's see what happens if I try to add a new commit. So I'm going to say git commit, modified package JSON scripts. So I hope I didn't have any problem. Okay, no problems. And let's try to push. Ok, so we didn't have a rapid yet. So let's, let's run Durant coverage. So see if we can push this thing. And I already know the answer. The answer is going to be no because we didn't have 100% of coverage. So in order to add 100% of coverage, we need to cover this line, which is line 112. So let's go to 112. And as you can see, well, it's this line here. So you may be asking, hey, what's wrong with this line? Well, we have to test the case when the precision is not the default value of two. So let's add another test here. So expect converter that convert. And let's copy these to actually copy these last tes here. And let us specify the precision of three. Precision, three. Ok, so let's go to this page where we have the base converter. We wanted to convert 2.11 from base five to base two. So from base five, base to convert. And in order to have precision three, we need a one. So we're going to include a one here. And now let's run again John coverage. And see if we now have 100% of coverage. And yeah, it looks like we have 100% of coverage. So let's get at everything again. And let's run good commit, dash, dash element. And we didn't want to edit the commit message. So we put dash, dash, no addict. Okay, so everything is in place now we have compatibility with windows. Everything looks correct now. So let's stop here and actually write our rid me in the next video. I hope you liked this video. See you in the next one. Bye-bye. 20. Setting up the repo in Github: Hi and welcome back. It's time to create a new repo for our package. So I'm going to host these new repo in GitHub. So this is my GitHub profile. And I'm going to repositories and I'm going to add a new repository. And I'm going to name it vase convertor and the description, well, let's copy and paste the description here. The one that we have in package.json. Okay, so it's going to be public and create repository. Okay, so one thing I didn't show in the videos is that I have been committing almost all of the video, so everything I did on the video. So if I type well, you may type, Good luck, but I have an alias called adhesive that gives me good luck, ban, but in a formatted way. So as you can see, I have all of these commit messages. So I'm just going to add the remote, which is going to be this line here. Good, remote AV. So I'm just going to copy and paste. Then. Well, it's not necessary to create a branch called domain. I'm going to stay with the master branch. And then I'm going to say git push origin master. So there it is, our pre push hook. So it passed because we have 100% of coverage. And if I refresh this page, I'm going to have all of the things in my rep. Now I'm going to modify a little bit the package.json because now we have a REPL. So here I'm going, sorry. I'm going to say repository. And I'm going to say that this is of type git and the URL of these Repository is going to be good. Bless. And I'm going to copy the HTTPS. Okay? And if we have any books, you can report them to this URL, which is going to be basically the same one. But instead of that good, It's going to be slashed issues. And what else? If we have a homepage, we can specify it here, but the homepage is going to just be the ridden. Okay, so let's have everything. Let's commit and say that repository properties to package JSON. Okay, so that's our bread commit hook. And let's push. There are all of our tests. They passed 100% coverage. And there we are. So we refresh or going to see inside package JSON that we have now these properties set. Okay, so that's everything for this video. Look at how beautiful our red myths. So that's everything. See you in the next one. Bye-bye. 21. Changing the name of our package: Hi and welcome back. So now it's time to actually publish our package. So I am going to search for base converter. And here you can see that nine years ago, someone published a package called base converter. So we are like nine years ago behind this guy. Again. So and I was thinking of a varName. So I've thought though, super base converter and that name, Luke's like east not taken. Ok, so I'm actually going to change the name of these repo to super base converter just for consistency. So now this is gold super base converter. And here in our repo, we are going to also change here based converters. So let's find all the occurrences of this thing and we're going to change it for super base converter in the ReadMe. Also, let's search world occurrences and change these two super VCE converter. Okay, so that's how we are going to name our package. So quick note here. So before I tell you that quick note, let me add a commit message saying changed name of package. Okay. And Well, we actually saw that everything was passing. So I'm going to get Bush dash, dash note Ashbery phi. So the tests are not execute it just for the sake of time. Okay, so the thing that I wanted to tell you is that here we're going to make it public package. So if you are doing this course, you are not going to be able to use these same name, although you're going to be able to use the same name if we do something called scoped baggage is something that we're going to learn later in the course, okay, so maybe you can skip this step or maybe you want to publish the same package but within another name. So that's totally up to you. But that's everything for this video. So I hope you like it. Seeing the next one, bye-bye. 22. Login to NPM: Hi, so in order to publish something to NPM, well, we need to create an npm accounts. So that's where you see. You are going to, for example, the sign out, just sign up until your information and you're good to go. Okay. So i will sign in again. And I think I have these two-factor authentication enabled. So that's something that will be very useful for you to have. Also, I have almost every account with dual factor authentication. So I think that's my code here. And now, just in your terminal, right, npm lugging. So that will prompt you for your username. So this is my username. I'm going to put my buzzword here, my email, which is public. Okay? And I think they will ask me again for my two-factor authentication onetime buzzword. So in this case is this one. And now I am login into npn. So that was everything I hoped you enjoyed this video. See you in the next one. Bye bye. 23. Publishing our package!: Okay, so now finally time to publish our package. So for that, we're just going to run the following command and BM publish. So a symbolist step. So I'm also nervous. And Luke's like super base converter. Version 1.0.0 is now available. Okay, so I was reading the ducks. It's just that pigment. So let's look here for Super based converter. And now you can see that everything now in place. So you can see that here we have these little symbol that says this package contains built-in type script, the declarations. So that's very useful for people installing our packages. So we have the read me, so look at how, how neat and how nice is these written me. We have Sarah dependencies to your dependence. And one version that is version 1.0.0 or are going to learn more about versioning. And we can try these on Runge-Kutta. So let's see if this works. So as you can see, this is a playground to test code. It runs a full Node.js environment and already has all of amphibians. More than 1 million packages per installed, including Super based converters. So that's really cool. So let's change this to const. And here, base convertor, our going to require a super base converter, okay? And we're going to create an instance of this glass vase converter, new base converter. Okay? And we're going to say console.log base converter dot convert are going to bus the number ten from base two to base five. Okay? So let's see what happens. So looks like it's not work. Help shift return. So again, shift returned out maybe. Okay, so we needed these extra parenthesis. Now we run. Now you can see that to ease the Tuesday answer. So 1-0 from base two to base five. This is in base five, okay? So it looks like everything is working correctly. So now in theory, you can simply go and install this package stated in their readme, ducks. So very vehicle. Now we're going to do something in order to automate these deployment. Okay? And that's what we're going to do in the following videos. So I hope you liked this one. See you in the next one. Bye-bye. 24. Installing our package locally: Hi and welcome back. So if you had some errors, if you publish your packet Chan, then you couldn't execute the code. I just showed you in the last video. That's because you had to have these build folder, so I already had it and I forgot to mention that. But don't forget. Sorry, dont Don't worry about that because we're going to automate these building process with GitHub auctions. What I wanted to show you, these are the weekend install, this package. So here I am. I am in an empty directory and I'm going to say npm init, why or, or jarring in it, whatever you want. And npm install super base converge. Ok? So now these node modules got created. And what I wanted to show you is that we only have three things inside this package, inside this folder, which is the readme, the package Jason and these build folder. So remember that I told you that here in the package, in our package.json that was specified these files. So here we said we only want these build folder to be included whenever anyone installs a package. Ok, so that's what happened here, only the Builds folder and I already touched on. I also told you that package.json and a read me. They couldn't be excluded. And well, it doesn't make sense to exclude this thing here. Okay. So that was everything I wanted to show you. Maybe we can test this thing a little bit. So let's write some index.js and basically do the same thing. So basic converter, I'm going to use a require here, Superbus converter. And actually I have these import cost extension. So if you want to also have it, its import costs and it tells me that the size of the super base convertor back it so it looks like is 3.9 kilobytes and you save 1.3 kilobytes. So maybe we can do better because there are like more complex baggages that has these size. Okay, so let's see, let's create a base converter. Okay? And here, that's council log. This time I'm going to I'm not going to I'm not going to make a mistake because we have Viscoat. And look at here we have this autocompletion lambert, So t 10. And here it says from base. In fact here we have the options from base to base and precision, and from base to base. Our no 5f. Now let's execute this file node index.js. And as you can see, the result is two. So looks like everything is working correctly. In fact, let me put here something like this and see what happens. And as you can see, now, this throws a narrow base, needs to be an integer, so everything is working as expected. Okay, so that's everything for this video. I hope you like it. See you in the next one. Bye-bye. 25. Implementation of the testing workflow: Hi and welcome back. So now it's time to automate our testing, our building and our deployment process using GitHub actions. So if you don't know what GitHub actions are, well, they are simply see ICD, so continuous integration, continuous deployment. It's like having something as complex as Jenkins about inside GitHub, so, well, that was a bad example. Jenkins is way more complex than the GitHub auctions, but it's the same idea. So here if we go to the rebel, we can see these actions tab. And here it says Get a started with GitHub actions to build, test, and deploy your code. And here get heavy suggesting me to use these workflow, these, well, it shall be a template or a workflow. But this is for dino. So bad suggestion GitHub because I am not decent dino for this project. So in order to make our first two workflow, going to first reach branches. So I'm going to create a new branch, gold feature GitHub actions. Okay. Now here I'm going to create a new directory called GitHub. That GitHub, sorry. So very important that it is called that GitHub. And inside that GitHub I'm going to create a new directory called workflows. So inside the workflows, I'm going to create a new file called test.html. So here we're going to define our workflow. So the first thing is to specify a name and I'm going to say testing on pull requests. Okay, so these workflow is going to be for pull requests. So we're going to see say on pull requests. And we're going to say append, synchronize and edited. So what this basically means is that whenever we open a poll request or whenever we synchronize pool requests, or whenever we added is a pull request, then these workflow is going to be triggered. Okay, so jumps. Now we have to define the jobs of our workflow. So the first job is going to be test. And we're going to say that these runs on a 1-2. And we can specify here, won't do 161820 or latest. So I'm going to use 20.04 and then we'll have to specify the steps. Okay, so now we're going to specify an array item. And we're going to say, use this actions tick out. So these action checkout basically means check out to the, to that, to the ripple, to the branch. And then we're going to specify another step. And this step is going to be called use NodeJS. And these uses actions. Set up note version one. And here we can specify the node version we want to use. So in our case we want to use Node Version 15. Okay, so now a nother step is going to be install the dependencies. Okay? So here we are going to specify run Yarn dash, dash frozen log file. So this John dash, dash frozen log file basically means install everything from John Locke. So don't try to upgrade any package, just installed what is inside John Locke. Ok, now, next step is going to be test the code. So simply here we're going to execute this test script. So here we're going to say a run Yarn test. And that's basically everything we have to do. So very, very easy. So again, let's let's go through all of these again so you understand clearly what's happening here. These workflow is only going to be triggered when we open synchronizer entity pull request. There will be some jobs and the first job is going to run on these two. And these are the steps. So first, checkout my current wrench, then use NodeJS version 15. Install the dependencies only. What is inside guaranteed OK. Don't try to upgrade anything and then test the code so that it is basically our workflow. So in the next video, we're going to actually making other workflow in-order to deploy our code. So I hope you liked this video. See you in the next one. Bye-bye. 26. Implementing the deployment workflow: Hi and welcome back. So we've finished to construct our testing on pull requests, work flu, and now we're going to automate the building process and also the deployment process. So here instead of where it flows, that's creating another file called deployment yaml. Ok. So the name of these workflow is going to be deployment to NPM registry. Okay? So we're going to say that we want to trigger these on bullish, but only on the branch master. So only when branches SQL semester, where going to trigger the workflow. Now we have to find the jobs. So the first and only job here is going to be the deployment. And these employment is going to run on Ubuntu. And the steps. So in the steps are going to say uses actions checkout, add a v2. So remember this is to chucked out to our repple. Now, the next step is going to be used NodeJS. So we're going to use NodeJS. And these USAS actions. Setup knows version one with node version 15, and also with Registry URL. So here we're going to say HTTPS, registry and PEMDAS, the 4k. So this is where we're going to push our package to these register because there's also the registry for darn, just basically the same, but we're going to have conflicts IV. We don't specify this. Ok, because we're going to use jargon in these workflow. So the next thing we are going to do is to install dependencies. Installed dependencies. And here, the same thing, John, dash, dash frozen log file. So we're going to, I'm install what is inside John Locke without trying to upgrade anything. So that should be the default behavior of John, but it's not. And then we're going to run the tests. Run the tests. So John tests, okay, next step, he's going to build. So remember we have these as script darn built inside our package JSON. So name, built, run, jar and built. And finally deployed. Vm is the last step. So the blood to NPM registry. Okay, so here we're going to run, run jarring, publish. And we have to set one environment variable in order to do this. So that DO environment barbel is going to be called note of talking. And we define invar, environment variables inside our workflows like this, secrets dot npm together. So what is this secrets dot and PM token. Okay, so if we go to npm, here is npm, so you click on your profile and go to access Dugan's. Then here you can see that, well, I have already created these two tokens on e1 is of type automation and the other one is of type publish. So you have to generate a new token and you have to select automation. Okay, so it's going to be for automation. So this is my token. I'm going to delete this obviously. And then you can go to your GitHub, go to your repositories. And inside settings. Here in sorry, in secrets, you can create a new repository secret. And remember we call this NPM token. So you're going to say n pn token, that is the name of your secret. And your token is going to be this one. Okay? So you add this secret. And now you can use it inside your workflows. So that's it for this video. I hope you like it in the next, we're going to test these two workflows. So see you in the next video. Bye bye. 27. Deploying: Hi and welcome back. So now we're going to publish a new version of our package. So we're going to make it pull request from these branch feature GitHub actions to master and see if that the bloomed works. But before doing that, there is a caveat. We have to do something manual and don't forget about this when doing a pull request. So here we have that these package.json has version 1.0.0. So we cannot publish a new baggage with the same version. So we need to either batch our package or increase the minor version or creates the major version. So we really didn't do anything here to increase the minor or the major version. So we're going to simply increase these batch version. So this batch version, we can, we can increase it manually if we want, but we have a command from npm that thus exactly this. So if we run NPM version batch, what this is going to do is to, you're gonna see increase the batch version and also create a tag for these new commit. So if we put good, well, I have that. I'll yes, good haste. You can put good luck if you want. So you're going to see that these committees stacked with the static version 1.0.1. If I run guitar, then my list of texts, and as you can see here, iss MyType. So now we can push this thing here. So let's copy and paste this to Bush. Okay. So those are the tests. And now it's pushing to Github. Okay, so let's go to our GitHub repo and let's go to Actions. Ok. So sorry, let's go to compare and pull request because we need to first do a pull request, we need to open a poll requests. Or remember here, when the pull request is opened. And let's create a poll request. Okay, so now we can go to the action step and as you can see, our workflow triggered. So we have these testing on Pull Request. And let's see what is happening here in this job. So it is setting up the job. It is checking out the ripple. It is using. Nodejs, is seen installing dependencies. So John dash, dash frozen log file. Now it is testing the code. So looks like everything passed and now everything. It's correct. So that's why we have these green tick here. Okay, so now it's time to merge these pool request in to master. So let's do this. Confirm merge. So pull requests successfully emerged and close. So now it's time to see if our deployment he's going to work or not. So let's go here to, again to the action step. So these merge pull request number 12, these deployment, Let's see, it's installing dependencies. So I'm also nervous, but this is installing dependencies. So it is in this step here. Now it is running the tests. So in the step here, now it is building everything. So the step here and it's deploying to NPM registry. So everything is correct. So everything worked as expected. So let's go to our super base converter back, which I am now we can see that these got the batch version got increased. I know we have super based converter version 1.1. So that's how we automate the testing, the building and the deployment with good have actions. So as you can see, very, very easy and convenient. So I hope you like this video. See you in the next one. Bye-bye. 28. Adding badges to our README: Hi and welcome back. So last thing we're going to do, Eastern glued a batch in our repository. So in order to do that, I'm going to put date at the top level. And we're going to save batch. And I'm going to write HTTPS. Give hub of a calm. The name, your username, then the name of your repo, supervise converter. And now workflow slash workflows slash the name of your workflow. So in my case it's deployment to NPM registry. So here you have to replace this basis. We've percent sign Tony. So we replaced that and finally, batch that SVG. So if we save and preview this thing here, you're going to see these little bad here saying deployment to NPM registry. That's passing. So everything is working fine with our ripple. Also, we can put a buy me a coffee button if you want. So maybe someone finds your package extremely useful and they want to donate you some money. So I'm going to simply generate the button here, copies. And both the, that the N on the top. And now you have a buying a coffee batch and all of your beautiful documentation. So as we're going to deploy these directly to master, let's bump the version again and BM. Well first, let's add everything that's coming at this and say modified reads me. Okay. And finally MPM version bench because we are on master. And finally get Bush. So let me just reload the window because we're still in yellow that the ReadMe. Okay, good Bush. Again, the tests are going to run and we are pushing. Okay, so now it's pushing. Let's go to Actions and see that now version 1.0.1, he's going to be deployed. And now we have these beautiful, beautiful rid me with the batch, with the buying me a coffee button and with the documentation. So I think we have done a great, great job here. And one more thing, these minutes, you're, you are consuming from GitHub actions. You have a limit. I don't remember at the top of my head, what is the number? But you cannot just do infinite workflows because you're going to pay some money if you pass some threshold. So I told you, I don't remember what is the limit. So you can you can investigate that in the official docs of GitHub. So it looks like everything is okay. So let's go to our super base converter, H in NPM. And let's see if something got changed. So, yeah, we have these. Buy me a coffee. And well, I am, I am surprised because I just published this version, just are there and now it has 37 downloads. So look at that. That's people are real people downloading my package. So I hope you liked this video. See you in the next one. Bye-bye. 29. What's next?: Hi and welcome back. So what's next? So we can obviously do lots and lots of things like other more validations if you want. So I just noticed that we needed to add a validation CVE the days, remember that base, from base to or from base to base. They need to be in this range from two to 16 included because we're not supporting more basis. So another thing that came to my mind is to add an optional parameter to the constructor to support more basis. So what I am trying to say here is remember in constants we have these letters to numbers map. And inside the constructor, we cooled, For example, due south, unlike letters to numbers map, letters to numbers map and default, these two, these value here. So let us numbers map phase converter or you want to call it, we can't afford this and make it a property. And so if it, if this is not passed, then we are going to use these object here. But if this is maybe the user can put f, g, 16, age 17, and so on and support more basis. So I think you get the idea. So that's enhancement that we can make to our package. And you can do it. You can present a pull request to my to my baggage or make your own additional enhancements by yourself if you want. And you can put whatever you believe is going to make the life of developers easier. So maybe another functionality, I don't know. Maybe converting eyepiece, I'd be befores to binary, maybe that's something a developer will want. Okay? And the caveat is that we're not bumping the version of R package in R Ci, C, D. So if you want to do this manually, the workflows are going to fail. So that's a caveat, but I don't think that's a major problem. And well, let's continue with the next video. Bye-bye. 30. Yarn Workspaces and monorepos: Hi and welcome back. So today we're going to learn something very, very interesting and that not many people know about. And these e's Jorn workspaces. Okay. So John workspaces is at all that is going to help you with ammonia or oppose so much variables is basically, as the name says, a single report where you have all of your code. And we're going to see that these has lots of advantages but also disciplined at this. So here inside this empty directory, I'm going to say yarn init dash y. Okay? And now we have a package. Jason, I'm not going to worry too much about setting a specific version of, of NodeJS and things like that. And I just want to show you something else. I'm going to create now to new directories, common and also server. Okay? And inside common, I'm going to join you in your wine. And inside server, again jarring in Dutch y. Ok, so we have three baggage, Jason, one insight common, one said Server, and one in the root directory. Here inside Carmen, I'm going to create an index.js file. And I'm going to module exports and narrow function that is going to say simply hello from common package. Okay? Now inside server, also going to create an index.js file. So suppose that these lag and XP or SAP or something like that. And I'm going to say common function, and I'm going to require something from from these column package. So right now I don't know what I'm going to require. So that's what we're going to learn right now. Okay? So in order to do this, let's go to this package Jason. And here we're going to say private, good, true. And workspaces where going to pass an array with directories of our packages. Okay, so common and server. In this case. Now inside the package JSON server, we can do something like this. You can say dependencies. And we can include these common package. So right now it's called common. So maybe it can be something like something like this at my company slash common. So these will be like an organization that you can create in NPM. Okay? So now I'm going to say at my company, Carmen, and I have to specify the version which in this case is 1.0.1 points here, sorry. Okay, so now here inside the index.js of server, I'm going to say at my company, the slash column. Okay, so here in Server, let's run jarring and style or simply Jorn. Ok. And now you can see that we have these node modules at the root directory. So just in case, let's do the same with common. Okay? And let's see what is the content of these node modules. So here we have these add my company slash common. And inside here is the same code inside here. So as you can see, the same package JSON and the same and the same index.js. So if we go inside server and execute index.js, you're going to see Hello from common package. Okay, so if I change something like this and execute this again, you're going to see that Hello from common baggage. Now we have these three exclamation marks. So it's like you can say your real time dates. Ok? So this is how you would work with a mano REPL. So jar in the workspace is a very cool tool to work with one Erebos. And 111. More thing I wanted to talk to, to tell you is that if for example you have lots and lots of packages here, then you will put them inside a package, this folder, sorry, I create it, it here. I wanted to create it here. Packages. Okay, so you put everything here, your common directory, your package directory. Sorry. Like that. Not like that, like that. Okay, so now you have to, instead of listing everything, you can simply say packages, everything that is inside brackets. So I think we have to maybe install Yarn install again. Just to be sure I'm going to do this, okay? And now you can see node index.js hello from common package. And let's add even more exclamation works. I know you can see that the function got updated in real time, you wanted to say. So this is very, very cool. But there are lots and lots and lots of disadvantages by taking this approach. And that's what we're going to discuss in the next video. Okay, so I hope you like this one. See you in the next one. Bye-bye. 31. Advantages and disadvantages of monorepos: Hi and welcome back. So let's talk about the advantages and disadvantages of menorah oppose mana repos got famous because Google popularized them some years ago. But I think they have more disadvantages than advantages. So that's where we're going to discuss here. So these are the advantages, the first 11 repo to rule them all. So as these EMA says, one repo to rule them all, one REPL to find them. When wrapper to bring them all. And in the cyber, bind them again. So basically if you have everything in just one single REPL, so your backend your front and then it will be easier, easier to, for example, leverage your local development. Or maybe having some onboarding dogs for new people that come to your team. In order for them to understand the infrastructure, they will, they will have a clear So a clear image of what is happening because they will be exposed to all of your packages. Okay? So, yeah, that's one advantage. The second advantage is that it's easier to implement or refactor global features with atomic commit. So what does this mean? Suppose you are a full-stack developer. You have to make some feature and that feature in bulbs touching the backend and the front. Okay, so in a microservices architecture, for example, what we will do is well, you have your service in 11 REPL. So you're going to modify that repo. You're going to make a pull request. And then all of your changes are going to be corresponding a branch. Then you go to your client code, you modify what you have to modify, and then you have to make another poll request. And then those changes are going to go to the client branch. Okay? So that's how you will do in a normal situation if you would like to call it like that. But with the monorail pose, Well, I touched the backend. I make the modifications in the backend. I make the modifications in the front end. And that's all. I make one poll requests containing all of the changes from the backend and from the front. So if something fails, I can simply rollback and its lag. Nothing happened. If something fails. With the other approach, then you will have to roll back door surveys ripple and in your client ripple. Okay, the third thing, we have already seen this reuse code. We've shirt packages while still keeping them isolated. So we already see this. We already saw this with John workspaces. We made a change to our common package. It was totally isolated from the server baggage, but we still see the changes in real time. You want to call it like that. Okay, so those are the advantages, but these are the disadvantages. So I think they are way more important than the advantages. So that's why I do not like mother apples. So first think Norway to restrict access only to some parts of the app. So if you give to your developers just one ripple, then that will be weird. Because if you have, for example, you had a front-end developer and you know that the front-end developers only going to focus on the front and then why you will give them access to the, to the backend. Okay? So and also vice versa view higher back-end. Back-end knows nothing about front. And then why would he have access to the front? And well, maybe they can or they will need to do that in order to handle test the client code. So maybe it makes sense. So I will give you another example. What if you have some like very secret algorithm that it's patented and you don't want it to share with with everyone, just for the software architects or something like that. Well, you can't do that with Mano ripples. So second disadvantage is for good performance when working on larger scale projects. So I have to confess, I have never had a good performance issues. But if you have thousands of commits in E, in a REPL, then at 1 in time, you are going to have good performance issues. And it will no longer be easy to just get out and get commit. Maybe those commands are going to take a long, long, long times. So you're going to have good performance issues. And talking about good, you're good luck will be a mess. You're mixing everything back in front. And so it will be really, really hard to understand the good history. And another thing is high gerbil time and more complex, the ICT. So if you want, for example, to build all of your app in on each deployment, well, that's going to take you lots and lots of time. And if you want to simply deploy parts of your app independently, then you're CIT is going to be way more complex. So see ICD, see ICD is by itself complex. Neither going to complicate that more. And the last point is, what if we want to use other programming languages like go C plus, plus java. So it's guarantee that you're going to use not only JavaScript or type script, you're going to use other programming languages. And well, we have these German workspaces and that works only for, for JavaScript. We have other tools like learner and things like that. But as you can see, they are more focused to JavaScript. And also they are not so mature. So the tools are not mature. That's the whole point of this. So you are going to have more problems trying to solve things that are not solved yet. So that will be also a huge disadvantage. So those are the advantages and disadvantages of Mano rapids. I think their disadvantages are way more important. And that's why I don't like my REPL. So let's see how we can solve somehow this problem. In the next videos. Bye-bye. 32. Creating organizations in Github and NPM: Hi and welcome back. So I'm going, I mean, in my npm account and I want to do something. So I have here three packages. So the first one is these identity number by the data, which is a personal project. The second one is super base converter, and D.C.'s also a personal project. But notice that these package contains these at DAP, which are the initials of my complete my full name. And so this means that these baggage is inside an organization. Okay? So if you see here I have these organic organization and I can add a new organization. So for example, here I can say Atul npm packages scores, okay? And I can choose for it to be a private baggage, but that's going to cost me some money, $7 per month. Well, I don't want to pay some money. So I'm going to make it public. So the difference is obvious. With private packages, no one is going to see your packages inside these organization. And with public packages. Well, everyone can see your package. So let's create a public package. No need for it to be private. Okay. And now I have created that baggage and I can invite some people. Well, I didn't have people to invite two. Right now. I now I have these organization. Okay, so let's go again to my profile. And as you can see, I have these two organizations, npm packages course and it has Ciro packages. Okay, so that's the way that we create organizations. So we can like group multiple packages inside these organizations. The second thing I wanted to do is to create now an organization inside GitHub. So we can do again the same thing but inside GitHub. So here as you can see, we have this free, free tier where we have these on limited public and private repositories on limited collaborators, 2 thousand actions mediates per month. So remember that I told you that I didn't have that number at the top of my head. Well, this is the number 500 megabytes of GitHub bucket this and community support. Okay, so let's join per frame. Again, npm package just course, like this one. It doesn't have to be the same. It's just the name of your organisation. And here I'm going to enter my email. Okay, So this organization belongs to my personal account. Okay, and I can add people to this organization. So what is spend most time writing code. How many people they expect? 0. What type of work do you plan? Education projects, other what they expected and did have an banks Seven Days. And I don't know managed code and know why so many questions. Know, submit, okay? Okay, so now we have our organization inside GitHub. But this is really just like a way to organize your code. Obviously, if you are a company then, well, it will make sense to, to put some your code inside an organization. But for us, it's just a way to demonstrate that the purpose of this course. Okay, so let's continue on the next video. Bye-bye. 33. Setting up a Django project: Hi and welcome back. So now in this video we're going to create the bifan project. And why Python? Well, I just want to show you something that is not JavaScript. Ok, so let's create here a new repo inside their service. So Python surveys, a Python surveys, it's private and create a repo. So I created also a directory called npm packages scores, which is the name of my organization. I don't know why I named this npm packages course. We're going to focus too much on npm packages right now. But okay, let's make a new directory, Python Service, lead CB into that directory. And let's open this in Visual Studio code. Okay, so let's get in it. And let's also add these remote. So we copy this line here and we are ready to go. Now, I'm going to simply copy and paste a Django project. So I'm going to paste my Django project and do not worry too much about this. This is simply something to demonstrate that I am building a service with Python, but I want to emphasize onto files. The first one is the Docker file. So this Docker file is taking Python 3.9. It's installing bib emf. Then it's installing everything from bib emf, which is basically lack from, sorry, from bib file, but luck, which is basically like John Locke. But for Python where copying all the source code inside the container. And then we're executing this command Python managed BY run server, 0.0.0, 0. So basically all eyepiece fort AIG Felten a game. So this is just to build our Docker image. And here in the docker compose, well, we're using Docker compose because we are constructing these backend service. So that container name is going to be admin service backend. Where going to build from this Docker file. We're going to expose the port 8 thousand and we are going to copy to create the volume, sorry, from source to up. Okay? So basically any change we made to up, we made to source Ari is going to be reflected inside the container. And we're seeing that these depends on db, which is another service. So these DB service is basically a MySQL database. Okay? So it's basically because we want to use MySQL for with Django. Ok. So we simply can say docker-compose up minus d. Ok, so it's already running. If I run docker ps, then we have these two containers. So this my backend, my Django project. So if I copy these container ID and say Docker Lux, then you're going to say, well, I already did some requests here that what, that's why this is showing. Okay, but the important part is here. We can go to localhost 8 thousand. So let's go to local host 8 thousand. And we'll patient and found because we didn't have anything there. But if we died, slash app mean or slash API maybe, then we're going to see that Django administration. So I don't remember really the password here, the username and password I created. So this is just for you to know that we have something in Python we're working here. Okay? So now we can simply get, add everything here. Make a comment same initial commit or Django project. And let's push this to master. Okay, so let's copy this command. And it's now pushed to master. Okay, so if we go to here and refresh or going to see all of our of our goat overcoat. Okay, so that's it for this video. In the second video, in, sorry, in the next video, we're going to do the same but with something in JavaScript. 34. Setting up a basic Express app: Hi and welcome back. So now we're going to make a, an example of an Express up for DES. We're going to go step-by-step and not lag with Django project. Okay, so let's create inside our npm packages scores directory on no JS. Well first let's create it inside our npm beca discourse for condensation. So I don't know JavaScript or express service, whatever you want to call it. Express service. Okay? And let's add these remote here. Well, first, let's grade the directory. Rage is going to be called express service. Let's open these in Visual Studio Code. And well, looks like we didn't cd into express service, so it's pre-survey. Again. Now we are in. So here let's get into it and let's add that remote. Okay, so here we're going step-by-step. So let's use npm. It's why you can use yarn. You need dash Y view, view want doesn't really matter. Okay, and let's install obviously express. Ok, let's create the server.js file. And that's also greatly dot gitignore file. So we put node modules there. And inside the server.js. That's going to be very simple. Let's require express. Okay, let's read the NAB with Express. We're going to say app, get slash, Reich, rest. So that typical example, rest dot sand, Hello World. And we're going to listen on port 88. Ok. And finally council look, I'm gonna say, yeah, simple string running on port 8080. Okay, so That's something very basic. If we write node servers iDS, looks okay. So here I have a typo Leeson. So now we have a running on port 88. So we go to localhost 80. Then we are seen helloworld. Okay, so everything is working fine. Now let's create our docker file. So the curve file here we're going to say from node doesn't really matter too much. Work dear. So we usually put this inside user serves up. We're going to copy the package JSON and the package blog.js ON in the current working directory, which is these one. Okay? And then we run NPM install, sorry, run NPM install. And then we copy everything else inside this working directory. And finally, the command we're going to execute here is going to be node server dot js. Okay, so we are ready with our docker file and now we're going to create their docker compose the YAML file. So here we're going to say that's use version three of docker-compose and the services. Well, in this case we're just going to have one service. Let's create a container name x brands buy candy or whatever you want to call it, built. The context is going to be BCE working directory. So this folder wearing to express service and the Docker file is called Docker file. Okay? And we're going to expose the following ports. 8080 mapped to 8080 inside a container. So this is our, the host port or our port, and this is the board from our container. So we can simply say docker-compose up. You can say minus D or only up. And okay, so looks like I already have one. Let me see. Yeah, I already have one. So I'm going to I'm going to run this command docker container Brown. Okay, and now let's run the command again. Okay, so now it's up. And as you can see in docker ps, Well, we have our Python services and MySQL database, but we also have these express service backend. So we type Docker lugs, express, express Beck, and then it's going to say running on port 8080. And in fact, if we refresh this page, we're going to still have that hello world. Okay, so everything is working fine. I'm going to commit. So added simple express service. Sorry, and let's push this to master. Ok. Fine. So that's it for this video. See you in the next one. 35. Setting up a basic common package: Hi and welcome back. So now we're going to create a package and npm package. So let's create a new repo here. So it's going to be called common package. I went back etch. And that's great. These ripple inside our npm packages scores directory, we're going to also create the folder called common package. Okay, so here I'm going to open Viscoat and we're going to do something very, very simple. We're just going to say npm init, dash y. And we're going to add these scope equals to our organization name in NPM. So remember we created this organization called and BM back a discourse. So we say dash, dash is equal to our organization name. So this is not doing too much really. The only thing that is doing is adding these at ambient packages course. So in theory we can simply say BMI dash y. Okay? And here, simply replace, sorry, replace this with this, and it's the same results. So you can change this later if you want, and simply run NPM or Yarn any dash y. And what we want to change these, really this again. So now it's at npm packages course splash common package. Okay, so this means that these package belongs to an organization. It can be public, it can be private, but it's an organization. Okay, now let's create this index.js file and also a gitignore because we are going to ignore node modules. And here let's get in it actually and npm install. Okay, so everything is in place. So in index.js, we're going to do something very simple. Just console.log. Hello from gun package. So nothing to complicate it. Although you have to do everything with eating Superbus converter, all of that configuration. And if possible, use type script. Okay, now we have everything in place. Let's add everything. Let's make a commit, saying initial commit. And let's push everything to master. So we have to first add the remote. So we add the remote by copying this line based thing, good Bush minus or Daxue origin master. And that's everything. Okay, so now we have our code inside our repo, but we also wanted here. So for that we're going to say npm publish. And this is very, very important. Dash, dash access public. Ok. Because if we don't specify these dash, dash axis public, then npm is going to assume, hey, we want to push this or publish this to a private repo, but we didn't have any private repo. Remember these, sorry, a private organization. But this is not a private organization. So if we run this command, then it's published. Now we have common package inside NPM. So maybe you have to refresh. You have to wait some time. So let's go 10:00 PM. Again, let's go to my profile to the organizations and pin package course. Well, it's not showing right now, but it's going to show in a moment. Okay. So that was everything for this video. See you in the next one. Bye-bye. 36. Creating the root repo: Hi and welcome back. So now let's create the new rapid. But this is going to be a very special repo called root Ripple. Ok, so root ripple is going to have very special thinks. So let's go here to npm packages scores, and let's create a route rebel. Let's see being to that root repo and let's open Visual Studio code. So let me do that again. Here we're in the root repo. So here we're going to do special things. The first thing that we're going to do iss npm, init, dash y. Also we are going to create the dot gitignore file with Node modules. And also, well, I think nothing else. Then that's getting it. And also, let's add these remote. Okay, so now we are ready to do some weird things here. So let's go to our npm packages and let's open these Python service. There's express service. And if we want this common packet holes, okay, so let's copy this URL, this HTTPS URL. And we're going to run this command, Git submodule, add the URL of the package. And now we have these bifans service back gets inside. Okay, so that seems or steam. And now let's go to our service. Again. Copy that HTTPS module at the URL. Now we have these express service and do the same with these common fact, good sub-module. These Euro. Okay, so now we have our three packages here. Okay, so that's good at everything. Let's make a gamete and say initial commit. And now let's see what happens if we push this to github. So good Bush minus u origin master. Let's see what happens. Ok, so now we are inside. Well, let's actually go inside this road rebel. And as you can see, we have something very interesting. We have Python service at and there is a hash commit. And let's look at our hash. How our, sorry, I get log. And as you can see, it's pointing to these hash commit. Now express service. Again, if we go to the commits, that's the commit of express service and common packet. Well, you guess it, it's these one. So actually if we click here, then we're going to come on package. If we click here, we're going to pre-service. And if we go here to Python service, it's going to take us to the Python service rebel. So that's very, very interesting. In the next video, we're going to see how we can leverage our local development using GitHub modules. So see you in the next video. Bye-bye. 37. Leveraging local dev!: Okay, so now let's go to our package.json and let's install as abcdef dependency. Remember that npm run all dependency. So that is going to help us a lot. And let's create a bunch of scripts here. So we're going to say is start express service. It's going are going to execute CV, express service and docker-compose up. So remember we can reduce these double ampersand and Windows, but you know how to solve that. And also let start these Python service. Okay, let's do that by phone service and docker-compose up. Okay? And finally, in the start, we're going to use these r1 dash b. So remember this is parallel. And we are going to say start, start, start, start star, sorry. Yeah. So now we have everything in order to leverage or local development. So let's run npm start. And very interesting things are going to happen. So they may take awhile. So in these second terminal, let seem docker ps. So maybe here, docker ps. Now we have everything up in our container. So let's go to localhost 8080. So that's our hello world. Let's go to local host. 8 thousand and Slashdot mean that's our Django app. So everything is working. That's the whole point of this. Everything is working. We have all of our services in one place. Each service has its own repo, so its own its own good history. We're not going to have good performance issues because I don't think we're going to have thousands of commits inside when service, unless you're Google or Facebook or some like that. So that's very, very cool. So again, let's add everything. Let's commit the same at its scripts that JSON. And let's push. Okay, so if we go to our, Let me see our road repo, you can see that nothing here changed. Okay, nothing has changed. And we updated our package.json file. And now we can leverage our local development with one single command. It doesn't matter if we're using Python. It doesn't matter if we're using Goal C plus plus Java, whatever. We just need to Docker to content container ICE our obligation and that's going to work fine. Obviously that is going to take some configuration from your part. But the thing is that we have used NPM scripts along with docker-compose in-order and GitHub module. So obviously, in order to have everything in one place. So this is our mono repo, but we are not using join workspaces and we wouldn't have any of those disadvantages that I mentioned earlier. Okay, so I hope you like this video. See you in the next one. Bye-bye. 38. Understanding what changes in the root repo: Ok, so there's something more I wanted to show you with gifts of modules. So if for example, we go to the express service up, so let's cd into that. And let's say we are going to make some change here inside server. So helloworld with more exclamation marks. So if I type good luck or good history, remember I have these alias. But let's type git log. Then you can see that we only have here added simple Express up. And, uh, we didn't have, like if we change directory again to the root directory and we type git log, we have completely the friend beat history. So this initial commit added scripts to package Jason. And there's nothing saying like initialize Express up or something like that. So again, good luck added simple Express app. And I can get at here everything. I can make a commit sane, changed server.js. And I can give pushed this here. And now we have a nother commit in our npm, sorry, in our express service application. So you can see two commits changed server.js, but nothing in the root rapid changed. In fact, let's see again the good luck. We have the same commits as before. So what happens? As you can see here, I have this change in the root rebel. But what is going to change? Because somehow this thing changed. It says here, there is a change, but what is the change? Okay, so let's actually go and get at everything and make a commit changed express, service. And let's push this thing here. And let's see what happens. Okay, so let's go to our organization to a root ripple and let's see the commits. So change express service is there. But whether what really changed, so what changed was the commit message, sorry, the commit hash of these express service. Okay, so if we go to our express service, we go two commits. And we can see we have C5 to CO2, 8-6. And here we have C5 to 0 to 86. So this same commit message. If we go to the last commit, so to these ones and see the source code, we can see that the express service is 49228 F E. So basically this gamete here. So when which we changed something inside our root ripple, what we are really changing is the commit we are pointing to of, well, if you change, for example, Python surveys and express service, then we are going to change, obviously to commit hashes. But in this case we're only changing these express service hash commit, okay? Obviously if you change something in package.json, then also this is going to change. But that's the core idea of this good submodules Fink. Okay, so I hope that this is now clear and see you in the next video. Bye bye. 39. Wrap up: Hi and welcome back. So I wanted to make a point here and talk about again, the disadvantages of ribose and how we have somehow solved most of the things here. Okay, so the first one is no way to restrict access only to some parts of the app. Now, with this approach, we can restrict access to some parts of the app because each of these things is a separate rebel. So we can simply restrict access to, for example, Python service. And that will work. Also something that I forgot to mention is that these good modules got graded and it simply something saying, hey, you have here sub module with the name Python surveys this the path, this is the URL and the same with express service and common package. Okay? So just for you to note that the second thing is poor, good performance when working on larger scale projects. So EVE, everything has its own repo. Then everything is going to have its own git history. And I don't think that as I mentioned in the last video, you are going to make thousands of commit in one single rebel. Well, it can be if you are big, big company like Google for one service only. But if we separate the repos, sorry, the services in each repo, then the probability that this going to happen is very, very low. Good law will be a mass is no longer problem because well, you know, now every committee is going to pertain to a certain ripple, so good luck will not be MS. Hi gerbil time and more complexly ICT. Well now you can have your own, your CIC v, your traditional CIC D, if you want to say it like that for each of the rebels. Okay? What if we want to use other programming languages, go C plus plus java or something like that. Well, if you can use Docker to containerize your app, then we're not going to have that problem because we just have to run these magical command, which is docker, compose up minus D. Now, do we have the same advantages? Smaller apples? Well, somehow not quite one repo to Room to rule them all. Well, we have one ripple to rule them all. In theory is, it's these Rhoda rebel where we can make our changes. So we can we can make our changes. We can have our barking dogs here. It's easily to implement refactor go level features with atomic commits. Well, not quite. You still have to make separate commits, separate pool requests. But the thing here is that now it's easier to integrate these changes. So remember my example where I said, you're a full-stack developer, you have to make a change in the front end and in the backend. Well, now you can leverage your or run your gland code and also run your backend where you have to make the changes and you can see those changes in real time if everything is well configured. Okay, so that's also a big challenge for these kind of approach where taken here. So we have to somehow use something like no demand inside our back-end. So for example, here we're not using nothing like no money, but we called in order to listen for changes. So now we have to use non Mon docker-compose run Hayes run in datanode months. So instead of saying node, maybe we say know that MAN here. And now we can have all of our changes exposed in real-time. And then somehow if you have some, for example, client code that is connected to this express service, then you have to say, hey, I'm working locally. So you have to connect to these local expressed service app. So that's some configuration that some challenges you have to take. But now you can usually implement a refactor global features, not with atomic commit, but in an easier way. Okay, reuse code with Shirt packages while still keeping them isolated. Well, yes, that's the whole point of these common package that we polish to NPM. So that's the big downfall of this. We can't do something like we did with the journal workspaces. So in theory we cooled, but it's a little bit complicated. But in order to see those changes inside these express service, for example, we can still use the power of npm. So everything with it basically in Super based converter and see the changes inside that express service up. So yeah, we have managed to basically tackle all of these problems and having something very, very cool. So I hope you liked this video. See you in the next one. Bye-bye. 40. End!: Hi, so we are at the end of the course and I wanted to show you a wrap-up of what we learned on what are the next steps. So we'll learn how to implement a npm package with best practices. You can apply the same knowledge of how to write, for example, documentation if you want to implement the PI PyPy package, I think that's how it's pronounced it. So basically that's like the NPM registry about for Python. And also remember to always use something like a SDF. So that's, as I told you, one of the best tools you're going to find out there to manage multiple versions of multiple programming language. To have local versions of your programming languages, not only in this project, but in any project you are going to be involved. From now on. We also learned what our monetary pose on why they are not so good. Although Google say yes, they are like excellent, but I don't share their opinion. And how to use Git some modules to have a Munger EPO without having them on a rebel and leverage that a local development, um, and basically tackle all of, all of the problems of them when Erebos. So if you have any questions, don't forget to follow me on social media and also joined the discord server of math as a second language. Bye-bye.