Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update with recommended integration into package.json #281

Merged
merged 27 commits into from Dec 2, 2019
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ca4933a
doc: update with recommended integration into package.json
mhdawson Nov 9, 2019
2f87597
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
db2e4d4
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
c19d197
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
0cf84af
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
a7ff367
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
3d7fab0
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
5202e44
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
9a0d022
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
269c487
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
0474af3
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
7f4b09c
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
5bfa45a
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
bdbc12b
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
03c24f9
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 10, 2019
4c64772
squash: address comments
mhdawson Nov 10, 2019
3d8dcd2
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 12, 2019
c92a598
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 12, 2019
14dd469
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 12, 2019
f5ec57b
squash: address comments
mhdawson Nov 12, 2019
1f1b798
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 12, 2019
8755f22
squash: address comments
mhdawson Nov 12, 2019
eac1747
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 19, 2019
506ce31
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 19, 2019
feb7d73
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 19, 2019
53b0598
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 19, 2019
d679c6f
Update docs/drafts/PACKAGE-SUPPORT.md
mhdawson Nov 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
92 changes: 91 additions & 1 deletion docs/drafts/PACKAGE-SUPPORT.md
Expand Up @@ -7,7 +7,6 @@ friction and stress on both the package maintainer and
the consumer. This is further complicated because the level of support
provided for dependencies of a package may be different than that
targeted by the package a consumer is directly consuming.

In the case of JavaScript (node.js and browsers) there is a large ecosystem
of packages which are maintained in the `npm` registry and it is
this ecosystem in which we plan to test out this guidance. However, we
Expand All @@ -22,6 +21,96 @@ The goal is to close the gap between the expectations from the
consumer and those of the maintainer and reduce the friction and stress
that can arise due to the gap.

There are 2 different aspects documented by this practice:

* Integration into packages
* Format and structure of the information

The sections which follow will address each of these separately.

# Integration into packages

The recommendation is a result of significant discussion due to the following
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
conflicting requirements:
* ability to review and process the support information
off-line with access to only the package itself.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the hard-wrapping throughout the doc? it's easier to review and suggest when arbitrary newlines aren't inserted all over the place :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnmuhl why the thumbs down?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a subjective thing, which I am guessing causes the thumbs down. Depending on your editor and configuration, these newlines can make this document legible where otherwise it would not be. In this particular line it might not matter, but I know sometimes when I have vim open on a wide screen, a long single line paragraph is painful to read. Just my 2c.

EDIT: I am not saying it should be one way or another, I just wanted to point out it is heavily subjective.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but the GitHub UI always wraps by default, and suggestions are single line, and vim/editors can easily be configured to soft wrap if desired.

mhdawson marked this conversation as resolved.
Show resolved Hide resolved
* ability to update the support information without having to publish the module
* ability to get the most up to date version of the support info without
having to pull down the latest published version of a package.

The integration suggested by this best practice aims to maximize the likelyhood that
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
offline information is available and accurate while at the same time not tying
the canonical version of the support information with a published version of the
package.

## Integration into package.json

A new field called `support` is added to package.json. The contents of this field will
be one of the following:
* true: This will indicate that the canonical version of the support information for the
package is available in a file within the repository specified by the
[repository](https://docs.npmjs.com/files/package.json#repository) entry. In this case the filapath for the file containing the support information will be
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
`./package-support.json`
* a string: a relative path, starting with ./, that points to a file within the
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
repository specified in the [repository](https://docs.npmjs.com/files/package.json#repository)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(it'd be nicer to review if these weren't hard-wrapped)

entry which contains the canonical support information.
* object, with repository key matching the schema for the existing
[repository](https://docs.npmjs.com/files/package.json#repository) entry, and optional
path field that comnplies with the format described above under `a string`
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
path field that comnplies with the format described above under `a string`
`path` field that complies with the format described above under `a string`


These options allow the support information to be provided through a file:

* in the root of the repository for the package
* in a location other than the root in the repository for the package
* in a different repository from the package itself

and enable the following use cases:

1.common case: "support": true with an associated package-support.json file in the
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
package repo at the top level
2.much less common case: an alternate file path within the package’s repo,
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
such as "support": "./path/to/support.json"
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
3.much much rarer case: sharing the same support data across multiple repos.
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
Examples might be
* ”support”: { “repository”: { “type”: “git”, “url”: “node/.github” }, “path”: “support.json” }
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
* ”support”: { “repository”: { “type”: “git”, “url”: “node/.github” } }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* support: { repository: { type”: “git”, “url”: “node/.github } }
* `"support": { "repository": { "type": "git", "url": "node/.github" } }`

* ”support”: { “repository”: { “type”: “git”, “url”: “node/.github”, “directory”: “packages” } }
mhdawson marked this conversation as resolved.
Show resolved Hide resolved

In all of these cases package-support.json(or your alternative filename) should be included in your files
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
array, or .npmignore configured to avoid excluding it.
mhdawson marked this conversation as resolved.
Show resolved Hide resolved

The rational for deliverying the canonical version of the support info through a file
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
within a repository (and ideally the package's repository) is that it maximizes the likelyhood
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
that every published package contains a copy of the support information that was
current at the time of the publish. Further, it does this in the most common cases without
requiring any special tooling or action from the maintainer.

In the least common case where the support information is not within the same repository,
ljharb marked this conversation as resolved.
Show resolved Hide resolved
we recommend that a non-canonical copy of the support information be copied into the package at the
same relative path as the external repository when publishing. We intend to work on tooling to simplify this
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
process including validation of the path and content of the support information as well as the
required coping for the least common case.
mhdawson marked this conversation as resolved.
Show resolved Hide resolved

Another benefit of delivering the support information from a repository is that existing
repositories (github, github, bitbucket, etc.) provide a higher level of trust than
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
an unconstrained URL and tooling which pulls and processes the support information
can optionally limit where it will pull support information (along with the allowable
protocols like git, svn etc.) to a trusted set of repositories, increasing the
safety of running tools processing the support information.

The end result of this approach is that by default, each publish will contain a snapshot
of the support data, but the true source of truth is always a file within the package’s
repository (or within an external repository). This supports offline and
“no external internet” use cases as best as can be achieved.

In the future, we hope that the developer experience could be further inproved
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
through itegration with the npm client. For validation could be integrated into
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we open a draft RFC (in both - yarn and npm - possibly other managers?) so that we can link to it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds reasonable to me, although I don't think we need to block this PR on that. We can add the links once we open the issues.

npm publish, and this information could be surfaced on npmjs.com, and/or the
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
information could be inlined into the packument so that npm view $package
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
could surface the data.

# Format and Structure

There are 3 main dimensions that we standardize in this practice which are:

* `target`: the platform versions that the package maintainer aims to support. For example
Expand All @@ -40,6 +129,7 @@ consumes these elements.

## Support information
dominykas marked this conversation as resolved.
Show resolved Hide resolved


This field documents the maintainers’ expectations, adding more useful metadata.
For the JavaScript ecosystem it is recommended that this information be added to the existing
`package.json` file in the root directory of the project. For other ecosystems, it is recommended that
Expand Down