Customizing the init process

It is also possible to totally customize the information created and the questions asked during the init process. This is done by creating a custom .npm-init.js. By default, npm will look in your home directory. ~/.npm-init.js

TABLE OF CONTENTS

1. Introduction to Progressive Web apps

2. Why Progressive Web Apps?

3. Objective of the Project

4. Advantages of Progressive Web App

5. Advantages of PWA over Native Apps

6. Benefits of Progressive Web App

7. Use Cases

8. The Future of PWA

9. Software Requirements

10. Reference

11. REQUIREMENTS GATHERING

12. Introduction to PWA Architectures

13. Introduction to PWA Architectures

14. Using libraries to code service workers

15. Add to Homescreen

16. Push Notifications

17. Payments and Credential Management

18. Recommended patterns for PWAs

19. CLUSTER AND OUTLINE OF PAGES

20. Code Base

21. Serve the app shell from the cache

22. Automate development tasks

23. Creating a package.json

24. Customizing the init process

25. Managing dependency versions

Customizing the init process

It is also possible to totally customize the information created and the questions asked during the init process. This is done by creating a custom .npm-init.js. By default, npm will look in your home directory. ~/.npm-init.js

A simple .npm-init.js could look something like this:

module.exports = {

customField: 'Custom Field',

otherCustomField: 'This field is really cool'

}

Running npm init with this file in your home directory would output a package.json similiar to this:

{

customField: 'Custom Field',

otherCustomField: 'This field is really cool'

}

Customizing the questions is also possible by using the prompt function.

module.exports = prompt("what's your favorite flavor of ice cream, buddy?", "I LIKE THEM ALL");

There are 2 types of packages you can list:

· "dependencies": These packages are required by your application in production.

· "devDependencies": These packages are only needed for development and testing.

Manually editing package.json

We can manually edit our package.json. You'll need to create an attribute in the package object called dependencies that points to an object. This object will hold attributes named after the packages you'd like to use and point to a semver expression that specifies what versions of that project are compatible with your project.

If you have dependencies you only need to use during local development, we will follow the same instructions as above but in an attribute called devDependencies.

For example, the project below uses any version of the package my_dep that matches major version 1 in production and requires any version of the package my_test_framework that matches major version 3, but only for development:

{

"name": "my_package",

"version": "1.0.0",

"dependencies": {

"my_dep": "^1.0.0"

},

"devDependencies" : {

"my_test_framework": "^3.1.0"

}

}

The --save and --save-dev install flags

The easier (and more awesome) way to add dependencies to your package.json is to do so from the command line, flagging the npm install command with either --save or --save-dev, depending on how you'd like to use that dependency.

To add an entry to your package.json's dependencies:

npm install <package_name> --save

To add an entry to your package.json's devDependencies:

npm install <package_name> --save-dev