All right, over here. Lab four. Oh actually not Lab four, we have a little interlude, Lab 3.1. So if you would like to just jump to a specific lab in our workshop here, we have some migration scripts, some generators that will help you jump to a specific, a specific lab in our workshop. So the way to do that is if you run install, this is the development dependency, NxReactWorkshop. So this is a plugin, it's a very simple plugin, it has no executors, only generators. And you wouldn't wanna use this in a, it's a plugin only for this workshop. You wouldn't wanna use it in your production code, but, it's just not useful. And let's do, so we added that, and, then we're gonna run, actually, let's do all of the actual instructions, 0.0.1. 0.0.1.
Okay, so I'm installing an old version of this plugin, and I'm gonna show you what the migration generators look like. Okay, so let me, let me quit, three, okay. Okay, so then we wanna migrate the latest version of this plugin. And Nx has a, the command for doing this is Nx migrate, and then you give it the name of the plugin you wanna migrate. React, Workshop. And you can either do at latest, or that's, you know, at latest is the default. And what that does is it goes and fetches from npm the latest version of this plugin, and then it says, hey, are there any migration generators between the, what you have currently installed on your repo, and like starting from what you currently have installed and going to what is the latest on npm. And what it's going to do is, collapse this. It's going to create a migrations.json file, which is a set of instructions about which scripts it needs to run. So the reason that there's this step, it doesn't immediately run the migrations because in very large codebases, you might have, I don't know, 15 generators to run on an update and sometimes they don't always work automatically. And so you wanna be able to commit your changes. If you've gotten a few of the migrations done and not all of them done, you wanna be able to commit that migrations file and so you don't get super far behind in the pace of the main branch. And so you can commit it and you can run the scripts in multiple different PRs, basically. So this migrations file here has all the different migration generators that are in this package. And in our case, each generator is a particular lab or completing lab one, completing lab two, completing lab three. And if I were to run actually in the terminal, it tells you what to do. So I ran NxMigrate. You run npm install, and then you run NxMigrate, run migrations to actually run the scripts. So if I do my... What this will do, this will actually finish the whole workshop all the way through the second day, which I don't know if we actually want to do. I think we will skip step five here and go to step six, which is actually helpful. Step six is instead of running all the migration scripts, so we could manually edit this and say, actually, I only want to run through lab three, so I'm just gonna delete all those and just do these, one, two, and three. Or you can just do a single one, or you can run this generator here and run generate, and so NARWAL-NX React Workshop Complete Labs, and there's some different options, so I can do from lab one to, doing a dry run, showing me what's gonna happen, from lab one to lab three, and that'll do the range here, or I can do, I just wanna run the script for lab four, because I'm already up to lab three, I just wanna run the script for lab four to complete it, so if I run this, it didn't actually run the script, it just created the migrations file, and then to migrate it, we run this, the migrations.json is assumed, so you don't have to add that equals on there. So this, basically this generator updated this, and said only put the lab four script in here, and so if I run that, and it's migrate run migrations, okay, this has completed lab four for me. Let's go look at the steps for lab four to see what actually it did. This is lab 3.1, so basically this is a way of jumping to whatever step you wanna be on on the workshop. So lab four was creating a component library. So we did, said to create a new React library called uishared and to put it in the libs store folder. So let's see. So generator, so we do that. So it's inside of here lib store uishared. So basically what it did was NX generate, narwhal, React library, and then we call it uishared and then put it under the directory of libs actually of store. So that's the command that I ran to do that. Hey Isaac, sorry we have a question in the chat here from Timothy. For the stuff from lab 3.1, did we actually need to run that migration or if we missed that, can we just continue? Yeah, you can skip 3.1. 3.1 is optional. It's just to help people if you wanna jump to a specific lab. So, yeah. So it's completely optional but it is helpful to move around the labs if you want to. And it's also helpful to kind of introduce you to the migration feature of NX, which is, you know, it's a pretty powerful feature. Yeah, a lot of chat in the chat about the migration and how cool it is. So, cool. But yeah, sorry to interrupt. Go ahead, Isaac. Let me send the link out here again. Okay, so that was step two to create this store, Store UI shared. Then we're gonna generate a new React component. So instead of doing this from the command line, I'll do this using NX console just to show the different ways of doing that. So I'm just gonna type in component here and it gives me all the generators that have component in the name. So I want a create React component, this one, not a storybook story or a cypress spec. So I want that and we wanna call it header. So I'm not actually clicking run on any of these things because I already ran that script, but I'm just showing you what you would do to do it. So you do this and make sure that the generate component is automatically exported. So you wanna make sure that it is exported. You click that, make sure that's set to true. From the command line it would be. From the command line, you'd do the dash dash export flag. And so that would create this header, component. And then supposed to copy in this code which has already been copied in. So copy and paste this code from here. Make styles, all of this copied in there. And then we use that header component in the app.tsx here. So we're using it, we're importing the header from here. So this red squiggle here is because TypeScript has not caught up with the fact that the new library has been created. So if you run into that, if you do TypeScript restart ts server, that should fix that red squiggle there. Yeah, so that is fixed. That, and so here's the instructions on that. Now, why is that? Oh, it's lowercase h. So that should not be lowercase h. That should be uppercase h. Okay. And I need to fix our migration script. It's not, it's not copying it over correctly. All right. Okay. So now we've served the projects and C, so we should now have a, a header. So to serve the project, we do nx serve store again, and let's go here and refresh this. And there's our header. It is kind of squished because I made it small, but okay. That cat looks extra grumpy when it's squished in with him.
Comments