generator-website-starter
v1.0.9
Published
A website generator using semantic markup, SASS, Gulp, Imagemin and Browser-sync
Downloads
10
Maintainers
Readme
generator-website-starter
This project is about learning how to build an npm package file using website starter files created in my previous repo and generate it using yeoman tool.
How to use this package
If you want to use this generator, below are the steps.
Install yeoman globally if you haven't installed it before
npm install -g yo
Install your created generator globally if you haven't installed it before
npm install -g generator-website-starter
Install the package file using Yeoman. You can repeat this process if you want to reuse in a new VS Workspsace
yo website-starter
Run
gulp
in your project directory terminalIf error occur its possible that gulp is not installed in your global yet. Below are steps to install
- Run gulp command utility
npm install --global gulp-cli
- Install Gulp in your project directory
npm install --save-dev gulp
For more details on how the generated files are created, please read this repository
- Run gulp command utility
Steps in creating a yeoman generator
If you want to learn how I created this generator, below are the steps
Create a new repository in github
Open a blank VS Code Workspace
File structure of yeoman generator
.
├── generator-`generator-name` # File folder has to start with `generator` followed by a dash then your generator name
│ │ ├── generators
│ │ │ │ ├── app # Index.js and package files are stored that Yeoman uses to generate
│ │ │ │ │ │ ├── templates # Package files saved in this folder are generated by Yeoman. Copy files in this folder, alternatively, use `git submodule add 'link of repository'` to load another git repository as a sub folder in the main repository. > Note: If there was a change in original repository, the files in this folder needs to be updated manually
│ │ ├── index.js #
How to update a git submodule: Go back to root generator folder and run this
git submodule foreach git pull
Install Yeoman in your project folder
npm install --save yeoman-generator
In index.js, import yeoman generator and write script files where you need to copy files that are shown in the supposedly generated package file from templates folder. Credits to Coder Coder's for the script.
Test the package locally by running this
npm link
and expect a confirmation message that a package is added.Note: Best to test it in a new blank VS Code Workspace by running an
npm init
thennpm install
and lastlynpm link "name-of-your-generator-folder"
and expect to see the package installed.Login to your npm account. Sign up here if you don't have one yet.
Note: email address used in sign up is public knowledge.
Error encountered
npm notice Account creation via legacy auth is unavailable. Please set your auth-type to "web" or visit https://www.npmjs.com/signup to create an account.
npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/-/user/org.couchdb.user:NAME
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/NAME/.npm/_logs/2023-04-29T12_54_51_911Z-debug-0.log
It somehow resolved by doing the following:
- Added 2FA in my npm account
- Linked my github account in my npm account
- I typed the wrong username
Update package files
Push and commit files to github repository
Update yeoman version number in package.json
npm version 1.1.1
Update npm package files
npm publish
Check udpated files in your npm account
Credits
- I learned the tutorial from Coder Coder
- How to NPM Link to a local version of your dependency