States once that a stage with no yarn.lock gets no node and no yarn, which two paragraphs here said; puts the short lists of yarn settings and of the files a yarn stage copies inline; joins the two sentences on Alpine's and Debian's yarn; every setting, file and condition stays. Model: opus-5-5
This commit is contained in:
1 parent
81cfb9be83
commit
410b9b1621
1 file changed
+21
-24
+21
-24
@@ -225,25 +225,30 @@ style conventions are in separate documents:
|
|||||||
- A tool from outside the distribution is never installed as "latest" or
|
- A tool from outside the distribution is never installed as "latest" or
|
||||||
"lts"; it is always an exact version.
|
"lts"; it is always an exact version.
|
||||||
|
|
||||||
|
## node and yarn
|
||||||
|
|
||||||
- Use `yarn`, not `npm`.
|
- Use `yarn`, not `npm`.
|
||||||
|
|
||||||
`script/bootstrap` installs node, yarn and the node packages only when
|
`script/bootstrap` installs node, yarn and the node packages only when
|
||||||
`yarn.lock` is in the tree. With no `yarn.lock`, it installs no node and no
|
`yarn.lock` is in the tree. A `Dockerfile` stage that needs no yarn copies
|
||||||
yarn. It installs the node packages with `yarn install --immutable`. That
|
no `yarn.lock` before it runs `script/bootstrap`, so `script/bootstrap`
|
||||||
install fails when a package's `checksum` is wrong, or when `package.json`
|
installs no node and no yarn there. The stages in the `prompts` repo's
|
||||||
is out of step with `yarn.lock`.
|
`examples/go.Dockerfile` and `examples/python-test-phase.Dockerfile` are
|
||||||
|
such stages.
|
||||||
|
|
||||||
|
`script/bootstrap` installs the node packages with
|
||||||
|
`yarn install --immutable`, which fails when a package's `checksum` is
|
||||||
|
wrong, or when `package.json` is out of step with `yarn.lock`.
|
||||||
|
|
||||||
Each repository commits the yarn that runs. `yarnPath` in `.yarnrc.yml`
|
Each repository commits the yarn that runs. `yarnPath` in `.yarnrc.yml`
|
||||||
points at the release file in `.yarn/releases/`. The distribution's yarn
|
points at the release file in `.yarn/releases/`. The distribution's yarn
|
||||||
only starts that file, and that file does the work. Alpine packages yarn 1,
|
only starts that file, and that file does the work. So Alpine's yarn 1 and
|
||||||
and Debian 13 packages yarn 4.1. The same committed yarn does the work on
|
Debian 13's yarn 4.1 run the same committed yarn. Corepack never runs, and
|
||||||
both. Corepack never runs, and no yarn is downloaded.
|
no yarn is downloaded.
|
||||||
|
|
||||||
`.yarnrc.yml` holds these settings:
|
`.yarnrc.yml` holds `yarnPath`, `nodeLinker: node-modules` and
|
||||||
- `yarnPath`
|
`enableTelemetry: false`. Without the last, yarn sends usage reports from
|
||||||
- `nodeLinker: node-modules`
|
any host that is not CI.
|
||||||
- `enableTelemetry: false`, because yarn otherwise sends usage reports from
|
|
||||||
any host that is not CI
|
|
||||||
|
|
||||||
By default, yarn runs no dependency's install script. A dependency that must
|
By default, yarn runs no dependency's install script. A dependency that must
|
||||||
run one is named in `package.json`, as
|
run one is named in `package.json`, as
|
||||||
@@ -263,18 +268,10 @@ style conventions are in separate documents:
|
|||||||
exit 1.
|
exit 1.
|
||||||
|
|
||||||
A `Dockerfile` stage that needs yarn may start from any distribution that
|
A `Dockerfile` stage that needs yarn may start from any distribution that
|
||||||
packages node and yarn. It copies all of these before it runs
|
packages node and yarn. Before it runs `script/bootstrap`, it copies
|
||||||
`script/bootstrap`:
|
`package.json`, `yarn.lock`, `.yarnrc.yml` and `.yarn/releases/`. With only
|
||||||
- `package.json`
|
the first two, the install fails, and Alpine's yarn 1 says to enable
|
||||||
- `yarn.lock`
|
corepack. Never do that; copy the missing files instead.
|
||||||
- `.yarnrc.yml`
|
|
||||||
- `.yarn/releases/`
|
|
||||||
|
|
||||||
With only `package.json` and `yarn.lock`, the install fails. Alpine's yarn 1
|
|
||||||
then says to enable corepack; never do that, and copy the missing files
|
|
||||||
instead. The stages in the `prompts` repo's `examples/go.Dockerfile` and
|
|
||||||
`examples/python-test-phase.Dockerfile` need no yarn and copy no
|
|
||||||
`yarn.lock`, so `script/bootstrap` installs no node and no yarn there.
|
|
||||||
|
|
||||||
- **`script/bootstrap` installs a pinned tool by comparing versions, never by
|
- **`script/bootstrap` installs a pinned tool by comparing versions, never by
|
||||||
testing presence.** An `if ! command -v <tool>; then install; fi` guard tests
|
testing presence.** An `if ! command -v <tool>; then install; fi` guard tests
|
||||||
|
|||||||
Reference in new issue
Block a user