Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
7.3 KiB

  1. npm-developers(7) -- Developer Guide
  2. ====================================
  3. ## DESCRIPTION
  4. So, you've decided to use npm to develop (and maybe publish/deploy)
  5. your project.
  6. Fantastic!
  7. There are a few things that you need to do above the simple steps
  8. that your users will do to install your program.
  9. ## About These Documents
  10. These are man pages. If you install npm, you should be able to
  11. then do `man npm-thing` to get the documentation on a particular
  12. topic, or `npm help thing` to see the same information.
  13. ## What is a `package`
  14. A package is:
  15. * a) a folder containing a program described by a package.json file
  16. * b) a gzipped tarball containing (a)
  17. * c) a url that resolves to (b)
  18. * d) a `<name>@<version>` that is published on the registry with (c)
  19. * e) a `<name>@<tag>` that points to (d)
  20. * f) a `<name>` that has a "latest" tag satisfying (e)
  21. * g) a `git` url that, when cloned, results in (a).
  22. Even if you never publish your package, you can still get a lot of
  23. benefits of using npm if you just want to write a node program (a), and
  24. perhaps if you also want to be able to easily install it elsewhere
  25. after packing it up into a tarball (b).
  26. Git urls can be of the form:
  27. git://github.com/user/project.git#commit-ish
  28. git+ssh://user@hostname:project.git#commit-ish
  29. git+http://user@hostname/project/blah.git#commit-ish
  30. git+https://user@hostname/project/blah.git#commit-ish
  31. The `commit-ish` can be any tag, sha, or branch which can be supplied as
  32. an argument to `git checkout`. The default is `master`.
  33. ## The package.json File
  34. You need to have a `package.json` file in the root of your project to do
  35. much of anything with npm. That is basically the whole interface.
  36. See `package.json(5)` for details about what goes in that file. At the very
  37. least, you need:
  38. * name:
  39. This should be a string that identifies your project. Please do not
  40. use the name to specify that it runs on node, or is in JavaScript.
  41. You can use the "engines" field to explicitly state the versions of
  42. node (or whatever else) that your program requires, and it's pretty
  43. well assumed that it's JavaScript.
  44. It does not necessarily need to match your github repository name.
  45. So, `node-foo` and `bar-js` are bad names. `foo` or `bar` are better.
  46. * version:
  47. A semver-compatible version.
  48. * engines:
  49. Specify the versions of node (or whatever else) that your program
  50. runs on. The node API changes a lot, and there may be bugs or new
  51. functionality that you depend on. Be explicit.
  52. * author:
  53. Take some credit.
  54. * scripts:
  55. If you have a special compilation or installation script, then you
  56. should put it in the `scripts` object. You should definitely have at
  57. least a basic smoke-test command as the "scripts.test" field.
  58. See npm-scripts(7).
  59. * main:
  60. If you have a single module that serves as the entry point to your
  61. program (like what the "foo" package gives you at require("foo")),
  62. then you need to specify that in the "main" field.
  63. * directories:
  64. This is an object mapping names to folders. The best ones to include are
  65. "lib" and "doc", but if you use "man" to specify a folder full of man pages,
  66. they'll get installed just like these ones.
  67. You can use `npm init` in the root of your package in order to get you
  68. started with a pretty basic package.json file. See `npm-init(1)` for
  69. more info.
  70. ## Keeping files *out* of your package
  71. Use a `.npmignore` file to keep stuff out of your package. If there's
  72. no `.npmignore` file, but there *is* a `.gitignore` file, then npm will
  73. ignore the stuff matched by the `.gitignore` file. If you *want* to
  74. include something that is excluded by your `.gitignore` file, you can
  75. create an empty `.npmignore` file to override it. Like `git`, `npm` looks
  76. for `.npmignore` and `.gitignore` files in all subdirectories of your
  77. package, not only the root directory.
  78. `.npmignore` files follow the [same pattern rules](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files)
  79. as `.gitignore` files:
  80. * Blank lines or lines starting with `#` are ignored.
  81. * Standard glob patterns work.
  82. * You can end patterns with a forward slash `/` to specify a directory.
  83. * You can negate a pattern by starting it with an exclamation point `!`.
  84. By default, the following paths and files are ignored, so there's no
  85. need to add them to `.npmignore` explicitly:
  86. * `.*.swp`
  87. * `._*`
  88. * `.DS_Store`
  89. * `.git`
  90. * `.hg`
  91. * `.npmrc`
  92. * `.lock-wscript`
  93. * `.svn`
  94. * `.wafpickle-*`
  95. * `config.gypi`
  96. * `CVS`
  97. * `npm-debug.log`
  98. Additionally, everything in `node_modules` is ignored, except for
  99. bundled dependencies. npm automatically handles this for you, so don't
  100. bother adding `node_modules` to `.npmignore`.
  101. The following paths and files are never ignored, so adding them to
  102. `.npmignore` is pointless:
  103. * `package.json`
  104. * `README` (and its variants)
  105. * `CHANGELOG` (and its variants)
  106. * `LICENSE` / `LICENCE`
  107. If, given the structure of your project, you find `.npmignore` to be a
  108. maintenance headache, you might instead try populating the `files`
  109. property of `package.json`, which is an array of file or directory names
  110. that should be included in your package. Sometimes a whitelist is easier
  111. to manage than a blacklist.
  112. ### Testing whether your `.npmignore` or `files` config works
  113. If you want to double check that your package will include only the files
  114. you intend it to when published, you can run the `npm pack` command locally
  115. which will generate a tarball in the working directory, the same way it
  116. does for publishing.
  117. ## Link Packages
  118. `npm link` is designed to install a development package and see the
  119. changes in real time without having to keep re-installing it. (You do
  120. need to either re-link or `npm rebuild -g` to update compiled packages,
  121. of course.)
  122. More info at `npm-link(1)`.
  123. ## Before Publishing: Make Sure Your Package Installs and Works
  124. **This is important.**
  125. If you can not install it locally, you'll have
  126. problems trying to publish it. Or, worse yet, you'll be able to
  127. publish it, but you'll be publishing a broken or pointless package.
  128. So don't do that.
  129. In the root of your package, do this:
  130. npm install . -g
  131. That'll show you that it's working. If you'd rather just create a symlink
  132. package that points to your working directory, then do this:
  133. npm link
  134. Use `npm ls -g` to see if it's there.
  135. To test a local install, go into some other folder, and then do:
  136. cd ../some-other-folder
  137. npm install ../my-package
  138. to install it locally into the node_modules folder in that other place.
  139. Then go into the node-repl, and try using require("my-thing") to
  140. bring in your module's main module.
  141. ## Create a User Account
  142. Create a user with the adduser command. It works like this:
  143. npm adduser
  144. and then follow the prompts.
  145. This is documented better in npm-adduser(1).
  146. ## Publish your package
  147. This part's easy. In the root of your folder, do this:
  148. npm publish
  149. You can give publish a url to a tarball, or a filename of a tarball,
  150. or a path to a folder.
  151. Note that pretty much **everything in that folder will be exposed**
  152. by default. So, if you have secret stuff in there, use a
  153. `.npmignore` file to list out the globs to ignore, or publish
  154. from a fresh checkout.
  155. ## Brag about it
  156. Send emails, write blogs, blab in IRC.
  157. Tell the world how easy it is to install your program!
  158. ## SEE ALSO
  159. * npm(1)
  160. * npm-init(1)
  161. * package.json(5)
  162. * npm-scripts(7)
  163. * npm-publish(1)
  164. * npm-adduser(1)
  165. * npm-registry(7)