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.

151 lines
5.5 KiB

  1. # `file:` specifiers
  2. `specifier` refers to the value part of the `package.json`'s `dependencies`
  3. object. This is a semver expression for registry dependencies and
  4. URLs and URL-like strings for other types.
  5. ### Dependency Specifiers
  6. * A `file:` specifier is either an absolute path (eg `/path/to/thing`, `d:\path\to\thing`):
  7. * An absolute `file:///absolute/path` with any number of leading slashes
  8. being treated as a single slash. That is, `file:/foo/bar` and
  9. `file:///foo/bar` reference the same package.
  10. * … or a relative path (eg `../path/to/thing`, `path\to\subdir`). Leading
  11. slashes on a file specifier will be removed, that is 'file://../foo/bar`
  12. references the same package as same as `file:../foo/bar`. The latter is
  13. considered canonical.
  14. * Attempting to install a specifier that has a windows drive letter will
  15. produce an error on non-Windows systems.
  16. * A valid `file:` specifier points is:
  17. * a valid package file. That is, a `.tar`, `.tar.gz` or `.tgz` containing
  18. `<dir>/package.json`.
  19. * OR, a directory that contains a `package.json`
  20. Relative specifiers are relative to the file they were found in, or, if
  21. provided on the command line, the CWD that the command was run from.
  22. An absolute specifier found in a `package.json` or `npm-shrinkwrap.json` is
  23. probably an error as it's unlikely to be portable between computers and
  24. should warn.
  25. A specifier provided as a command line argument that is on a different drive
  26. is an error. That is, `npm install file:d:/foo/bar` is an error if the
  27. current drive is `c`. The point of this rule is that if we can't produce a
  28. relative path then it's an error.
  29. ### Specifier Disambiguation
  30. On the command line, plain paths are allowed. These paths can be ambiguous
  31. as they could be a path, a plain package name or a github shortcut. This
  32. ambiguity is resolved by checking to see if either a directory exists that
  33. contains a `package.json`. If either is the case then the specifier is a
  34. file specifier, otherwise it's a registry or github specifier.
  35. ### Specifier Matching
  36. A specifier is considered to match a dependency on disk when the `realpath`
  37. of the fully resolved specifier matches the `realpath` of the package on disk.
  38. ### Saving File Specifiers
  39. When saving to both `package.json` and `npm-shrinkwrap.json` they will be
  40. saved using the `file:../relative/path` form, and the relative path will be
  41. relative to the project's root folder. This is particularly important to
  42. note for the `npm-shrinkwrap.json` as it means the specifier there will
  43. be different then the original `package.json` (where it was relative to that
  44. `package.json`).
  45. When shrinkwrapping file specifiers, the contents of the destination
  46. package's `node_modules` WILL NOT be included in the shrinkwrap. If you want to lock
  47. down the destination package's `node_modules` you should create a shrinkwrap for it
  48. separately.
  49. This is necessary to support the mono repo use case where many projects file
  50. to the same package. If each project included its own `npm-shrinkwrap.json`
  51. then they would each have their own distinct set of transitive dependencies
  52. and they'd step on each other any time you ran an install in one or the other.
  53. NOTE: This should not have an effect on shrinkwrapping of other sorts of
  54. shrinkwrapped packages.
  55. ### Installation
  56. #### File type specifiers pointing at tarballs
  57. File-type specifiers pointing at a `.tgz` or `.tar.gz` or `.tar` file will
  58. install it as a package file in the same way we would a remote tarball. The
  59. checksum of the package file should be recorded so that we can check for updates.
  60. #### File type specifers pointing at directories
  61. File-type specifiers that point at directories will necessarily not do
  62. anything for `fetch` and `extract` phases.
  63. The symlink should be created during the `finalize` phase.
  64. The `preinstall` for file-type specifiers MUST be run AFTER the
  65. `finalize` phase as the symlink may be a relative path reaching outside the
  66. current project root and a symlink that resolves in `.staging` won't resolve
  67. in the package's final resting place.
  68. If the module is inside the package root that we're running the install for then
  69. dependencies of the linked package will be hoisted to the top level as usual.
  70. If the module is outside the package root then dependencies will be installed inside
  71. the linked module's `node_modules` folder.
  72. ### Removal
  73. Removal should remove the symlink.
  74. Removal MUST NOT remove the transitive dependencies IF they're installed in
  75. the linked module's `node_modules` folder.
  76. ### Listing
  77. In listings they should not include a version as the version is not
  78. something `npm` is concerned about. This also makes them easily
  79. distinguishable from symlinks of packages that have other dependency
  80. specifiers.
  81. If you had run:
  82. ```
  83. npm install --save file:../a
  84. ```
  85. And then run:
  86. ```
  87. npm ls
  88. ```
  89. You would see:
  90. ```
  91. example-package@1.0.0 /path/to/example-package
  92. └── a → file:../a
  93. ```
  94. ```
  95. example-package@1.0.0 /path/to/example-package
  96. +-- a -> file:../a
  97. ```
  98. Of note here: No version is included as the relevant detail is WHERE the
  99. package came from, not what version happened to be in that path.
  100. ### Outdated
  101. Local specifiers should only show up in `npm outdated` if they're missing
  102. and when they do, they should be reported as:
  103. ```
  104. Package Current Wanted Latest Location
  105. a MISSING LOCAL LOCAL example-package
  106. ```
  107. ### Updating
  108. If a dependency with a local specifier is already installed then `npm
  109. update` shouldn't do anything. If one is missing then it should be
  110. installed as if you ran `npm install`.