I was confused for ~15 minutes today when updating to using the yarn
plugin. It was failing in docker but not locally, and I didn't know why.
It turned out to be because I forgot to copy the backstage.json into the
docker image. This was confusing, because the error seemed to indicate I
was failing the semver checks. This change propagates error detail down
the line, so people will see the actual cause. (i.e. missing file, no
version field, semver wrong)
Signed-off-by: Riley Martine <rmartine@integralads.com>
A recent change reintroduced the issue previously
fixed by #27727. To ensure this doesn't regress
again, I'm introducing a test that specifically
checks that lockfile parsing works as expected.
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
The new test suite fully exercises the plugin,
including onboarding and offboarding from the
plugin and the effect on lockfiles.
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
Switching to using the reduceDependency hook
simplifies the plugin, since we can do all the
work in one go. It also means that the yarn.lock
file doesn't need to change when adding and
removing the yarn plugin, which avoids
unintentionally unlocking packages versions.
As part of this change, the descriptor emitted by
the plugin has been changed from
`npm:<manifest-version>` to
`npm:^<manifest-version>`, to match the range
emitted when packing packages. This ensures good
interoperability with the `backstage-cli
build-workspace`, which packs packages into a new
workspace and copies yarn.lock across.
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This allows us to leverage yarn's built in proxy
configuration when making the request. The yarn
HTTP utilities handle caching of GET
requests, so we can remove our memoization of the
request, too.
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
I realised that by default the `Plugin` type from
`@yarnpkg/core` sets the type of the `hooks`
property to `any`. This meant that there wasn't
any restriction on the hooks that could be passed,
and introduced the risk that a typo in the
`beforeWorkspacePacking` name could lead to the
hook being skipped.
This commit pulls in the appropriate type for
Hooks to verify the name and signature of the hook.
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
Chalk costs us about 20kb in the bundle size, and
we only use it to format one logged message. To
avoid this dependency, this commit hard-codes the
escape codes for that single message.
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit introduces a beforeWorkspacePacking
hook which converts `backstage:` versions back
into `npm:`` versions when packages are packed for
publish. This allows the `backstage:` protocol to
be used even for packages that are intended to
themselves be published (such as packages in
third-party Backstage plugin monorepos outside
core).
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>