-
Notifications
You must be signed in to change notification settings - Fork 117
node: Add yarn2 support #252
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
base: master
Are you sure you want to change the base?
Conversation
159ca9f
to
ff204fd
Compare
d22a790
to
8aaa053
Compare
Isn't lockfile v2 format just normal YAML? |
I think you've managed to use this PR in https://sourcegraph.com/github.com/flathub/net.cozic.joplin_desktop@5420d1b2d6c0debe599222af99d048f10de2ac1f/-/blob/net.cozic.joplin_desktop.yml?L62. But just wondering how you get |
@proletarius101 |
@catsout I found there might be some errors: https://buildbot.flathub.org/#/builders/10/builds/12201 |
@proletarius101 |
@catsout Could you please push your fix so that I can check, or will you fix it yourself? |
@proletarius101 |
True. But do you know why? I thought I confirm that this PR works for standard notes. |
Hi @gasinvein @catsout any updates? :) |
f0d317a causes the following error: https://buildbot.flathub.org/#/builders/10/builds/13033
afc6911 doesn't |
Seems I forgot |
799eb2a
to
0894c91
Compare
I'm trying to run this on https://github.com/mifi/lossless-cut/blob/37e49d5682a4dada498f3fe7ec3d2d2cf530a7df/yarn.lock but it fails:
|
@muelli |
I'm still experiencing the error. I'm on c278045 now. And I'm calling like this: |
Yes, it works.
|
Okay so, I will admit, I did not realize this was undrafted until a few weeks ago, and then promptly forgot about it again. Ditto on the above comment, but also...do we really need a 250 LoC yarn plugin? Would very much like to know what it does in the very least...seems to be related to converting something to zip files, triggered by some |
lock file
From: https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Resolver.ts
More type detail: https://github.com/yarnpkg/berry/blob/%40yarnpkg/shell/3.2.5/packages/yarnpkg-core/sources/types.ts#L81
So:
cache filefilename:
https://github.com/yarnpkg/berry/blob/%40yarnpkg/shell/3.2.5/packages/yarnpkg-core/sources/Cache.ts#L99 `@${locator.scope}-${locator.name}-${humanProtocol}-${humanVersion}-${locator.locatorHash.slice(0, 10)}-${zip_cache_checksum.slice(0, 10)}`
humanProtocol, humanVersion come from locator.reference cache file is valid only when:
fetcherhttps://github.com/yarnpkg/berry/blob/%40yarnpkg/shell/3.2.5/packages/plugin-npm/sources/NpmSemverFetcher.ts#L49 the js pluginThe py generate the flathub source of tgz file. Then in js plugin, loop the file, extract the locator info to generate the zip cache filename. |
git sourceyarn uses |
patch lockfileThere is a yarn 1.x bug yarnpkg/yarn#685, which cause |
Hi, I've been using this for a bit and have discovered this doesn't work with yarn canary/yarn 4 the plugin used always crashes with this error,
|
zipfs seems to have been moved to |
Note that updating the generated sources is more complicated at the moment until flatpak-node-generator starts supporting Yarn version 2+. I had to use the code in pull request flatpak/flatpak-builder-tools#252 which adds support for Yarn version 2+. The exact commit that I used is: flatpak/flatpak-builder-tools@eb43ec2. A newer update of this pull request also removes the need to execute "$FLATPAK_BUILDER_BUILDDIR/flatpak-node/yarn2-setup.sh" before running "yarn install" so I removed that line from the build-commands. Commands that I used to update the generated sources are: wget https://raw.githubusercontent.com/mifi/lossless-cut/refs/tags/v3.64.0/yarn.lock pipx run "flatpak_node_generator @ git+https://github.com/flatpak/flatpak-builder-tools.git@refs/pull/252/head#subdirectory=node" yarn yarn.lock --output generated-sources.json rm yarn.lock
@catsout , I've used the current latest commit in this PR (eb43ec2) to successfully generate However, the Flatpak build process now fails at
The LosslessCut project currently uses Yarn 4.4.0. Do you have any suggestion on which commands to use in |
Sorry for the late reply. |
- name: app_example
buildsystem: simple
build-options:
append-path: /usr/lib/sdk/node20/bin
env:
XDG_CACHE_HOME: /run/build/app_example/flatpak-node/cache
npm_config_nodedir: /usr/lib/sdk/node20
YARN_ENABLE_INLINE_BUILDS: '1'
YARN_ENABLE_TELEMETRY: '0'
YARN_ENABLE_NETWORK: '0'
YARN_ENABLE_GLOBAL_CACHE: '0'
YARN_GLOBAL_FOLDER: /run/build/app_example/flatpak-node/yarn-mirror/global
TMPDIR: /run/build/app_example/flatpak-tmp
build-commands:
- yarn config
- yarn plugin import $FLATPAK_BUILDER_BUILDDIR/flatpak-node/flatpak-yarn.js
- yarn convertToZip $(which yarn)
- yarn install |
Since anki now uses yarn 4, some workarounds are required. flatpak-builder-tools upstream does not support yarn >=2, but there is an open PR to add support [1]. That gets most of the way there, but there is still a minor issue that I assume was introduced between yarn 2 and 4 not included in that PR, so I forked it. Anki itself also needs minor changes (yarn-4-fixes.patch) since yarn 4 removed the --offline and --ignore-scripts options, but anki's offline build still uses them. They are now instead set by the flatpak-builder-tools script. Anki uses the YARN_BINARY environment variable, but yarn will interpret any environment variables starting with YARN_ as yarn configuration, so that will need to be renamed. [1] flatpak/flatpak-builder-tools#252
Since anki now uses yarn 4, some workarounds are required. The flatpak environment does not include yarn 4, so it is added to the sources. flatpak-builder-tools upstream does not support yarn >=2, but there is an open PR to add support [1]. That gets most of the way there, but there is still a minor issue that I assume was introduced between yarn 2 and 4 not included in that PR, so I forked from that submitted a PR to the developer of that PR [2]. Anki itself also needs minor changes (yarn-4-fixes.patch) since yarn 4 removed the --offline and --ignore-scripts options, but anki's offline build still uses them. They are now instead set by the flatpak-builder-tools script. Anki uses the YARN_BINARY environment variable, but yarn will interpret any environment variables starting with YARN_ as yarn configuration, so that will need to be renamed. [1] flatpak/flatpak-builder-tools#252 [2] catsout/flatpak-builder-tools#1
Since anki now uses yarn 4, some workarounds are required. The flatpak environment does not include yarn 4, so it is added to the sources. flatpak-builder-tools upstream does not support yarn >=2, but there is an open PR to add support [1]. That gets most of the way there, but there is still a minor issue that I assume was introduced between yarn 2 and 4 not included in that PR, so I forked from that submitted a PR to the developer of that PR [2]. Anki itself also needs minor changes (yarn-4-fixes.patch) since yarn 4 removed the --offline and --ignore-scripts options, but anki's offline build still uses them. They are now instead set by the flatpak-builder-tools script. Anki uses the YARN_BINARY environment variable, but yarn will interpret any environment variables starting with YARN_ as yarn configuration, so that will need to be renamed. [1] flatpak/flatpak-builder-tools#252 [2] catsout/flatpak-builder-tools#1
Since anki now uses yarn 4, some workarounds are required. The flatpak environment does not include yarn 4, so it is added to the sources. flatpak-builder-tools upstream does not support yarn >=2, but there is an open PR to add support [1]. That gets most of the way there, but there is still a minor issue that I assume was introduced between yarn 2 and 4 not included in that PR, so I forked from that submitted a PR to the developer of that PR [2]. Anki itself also needs minor changes (yarn-4-fixes.patch) since yarn 4 removed the --offline and --ignore-scripts options, but anki's offline build still uses them. They are now instead set by the flatpak-builder-tools script. Anki uses the YARN_BINARY environment variable, but yarn will interpret any environment variables starting with YARN_ as yarn configuration, so that will need to be renamed. [1] flatpak/flatpak-builder-tools#252 [2] catsout/flatpak-builder-tools#1
Since anki now uses yarn 4, some workarounds are required. The flatpak environment does not include yarn 4, so it is added to the sources. flatpak-builder-tools upstream does not support yarn >=2, but there is an open PR to add support [1]. That gets most of the way there, but there is still a minor issue that I assume was introduced between yarn 2 and 4 not included in that PR, so I forked from that submitted a PR to the developer of that PR [2]. Anki itself also needs minor changes (yarn-4-fixes.patch) since yarn 4 removed the --offline and --ignore-scripts options, but anki's offline build still uses them. They are now instead set by the flatpak-builder-tools script. Anki uses the YARN_BINARY environment variable, but yarn will interpret any environment variables starting with YARN_ as yarn configuration, so that will need to be renamed. [1] flatpak/flatpak-builder-tools#252 [2] catsout/flatpak-builder-tools#1
Since anki now uses yarn 4, some workarounds are required. The flatpak environment does not include yarn 4, so it is added to the sources. flatpak-builder-tools upstream does not support yarn >=2, but there is an open PR to add support [1]. That gets most of the way there, but there is still a minor issue that I assume was introduced between yarn 2 and 4 not included in that PR, so I forked from that submitted a PR to the developer of that PR [2]. Anki itself also needs minor changes (yarn-4-fixes.patch) since yarn 4 removed the --offline and --ignore-scripts options, but anki's offline build still uses them. They are now instead set by the flatpak-builder-tools script. Anki uses the YARN_BINARY environment variable, but yarn will interpret any environment variables starting with YARN_ as yarn configuration, so that will need to be renamed. [1] flatpak/flatpak-builder-tools#252 [2] catsout/flatpak-builder-tools#1
@catsout, thanks for your help! It appears that this PR doesn't yet support projects using Yarn4 as discovered by @holubv in flathub/no.mifi.losslesscut#73 (comment), @RangHo in flathub/social.whalebird.WhalebirdDesktop#23 (comment) and @Oppzippy in flathub/net.ankiweb.Anki#198 (comment). In a way, the situation with building Flatpak apps written in JavaScript from source is pretty unfavorable at the moment. Probably many Flatpak maintainers will find it easier (and currently the only viable option) to just repackage the prebuilt upstream provided binaries... |
todo:
need to manually add
$FLATPAK_BUILDER_BUILDDIR/flatpak-node/yarn2-setup.sh
tobuild-commands