![]() These AI writing tools are getting incredibly impressive, but you have to work with them, rather than just letting them spit out whatever they want. Since AI is supposedly trying to take my job, I'm somewhat professionally interested in the whole situation. The other sections of the documentation will present functionality available within the Yeoman core to help you achieve your goals.I've been covering this kind of generative AI technology for almost a decade. This section is vital to understanding the context in which your generator will run, and to ensure that it will compose well with other generators in the Yeoman ecosystem. If this is your first time writing a generator, you should definitely read the next section on running context and the run loop. Where to go from here?Īfter reading this, you should be able to create a local generator and run it. yo-rc.json somewhere up the directory tree. So, if your generator is not running in your current working directory, make sure you don’t have a. Calling () from a generator for the first time will create the file. yo-rc.json file location and run the requested generator there. Behind the scenes, Yeoman will change the current directory to the. If found, it considers the location of the file as the root of the project. Most importantly, Yeoman searches the directory tree for a. While running a generator, Yeoman will try to figure some things out based on the context of the folder it’s running from. Congratulations, you just built your first generator! Finding the project root After npm is done, you’ll be able to call yo name and you should see the this.log, defined earlier, rendered in the terminal. That will install your project dependencies and symlink a global module to your local file. ![]() In an example project, a directory tree could look like this: ![]() Sub-generators, used when you call yo name:subcommand, are stored in folders named exactly like the sub command. This must be contained within the app/ directory. The default generator used when you call yo name is the app generator. Each sub-generator is contained within its own folder. Yeoman’s functionality is dependent on how you structure your directory tree. The files property must be an array of files and directories that is used by your generator.Īdd other package.json properties as needed. You can do this by running: npm install -save yeoman-generator. You should make sure you set the latest version of yeoman-generator as a dependency. The keywords property must contain "yeoman-generator" and the repo must have a description to be indexed by our generators page. The name property must be prefixed by generator. You can generate this file by running npm init from your command line or by entering the following manually: Once inside your generator folder, create a package.json file. This is important, as Yeoman relies on the file system to find available generators. This folder must be named generator-name (where name is the name of your generator). Organizing your generators Setting up as a node moduleĪ generator is, at its core, a Node.js module.įirst, create a folder within which you’ll write your generator. Feel free to use it to bootstrap your own generator once you understand the below concepts. Note: We built a generator-generator to help users get started with their own generator. In reading this section, you’ll learn how to create and distribute your own. They’re the plugins run by yo to generate files for end users. Generators are the building blocks of the Yeoman ecosystem.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |