handle multiple package versions in registry.json
This commit is contained in:
parent
26f60eb96b
commit
25e7e278c0
1 changed files with 34 additions and 16 deletions
|
|
@ -81,19 +81,6 @@ in
|
|||
|
||||
mkdir -p $OUT_PATH
|
||||
tar -xzf $src -C $OUT_PATH --strip-components=1
|
||||
|
||||
SUBSET_FILTER='to_entries | map(select(.key == "version" or .key == "bin" or .key == "dependencies" or .key == "peerDependencies")) | from_entries'
|
||||
PACKAGE_SUBSET=$(${pkgs.jq}/bin/jq "$SUBSET_FILTER" $OUT_PATH/package.json)
|
||||
|
||||
cat > $OUT_PATH/../registry.json <<EOF
|
||||
{
|
||||
"name": "${name}",
|
||||
"dist-tags": {},
|
||||
"versions": {
|
||||
"${version}": $PACKAGE_SUBSET
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
|
@ -109,11 +96,42 @@ in
|
|||
inherit pkgs lockfile registryHostname;
|
||||
})
|
||||
lockfiles;
|
||||
in
|
||||
pkgs.symlinkJoin {
|
||||
name = "deno-shared-cache";
|
||||
|
||||
baseCache = pkgs.symlinkJoin {
|
||||
name = "deno-shared-cache-base";
|
||||
paths = allNpmDeps;
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "deno-shared-cache" {} ''
|
||||
cp -r ${baseCache} $out
|
||||
chmod -R +w $out
|
||||
|
||||
# Generate registry.json for each package
|
||||
find $out/npm/${registryHostname} -mindepth 1 -maxdepth 1 -type d | while read -r pkg_dir; do
|
||||
pkg_name=$(basename "$pkg_dir")
|
||||
|
||||
# Collect all package.json files for this package
|
||||
versions_json=$(
|
||||
find "$pkg_dir" -mindepth 2 -maxdepth 2 -name package.json -type f \
|
||||
| ${pkgs.jq}/bin/jq -n 'reduce inputs as $pkg ({};
|
||||
. + {
|
||||
($pkg.version): ($pkg | {
|
||||
version: .version,
|
||||
bin: .bin,
|
||||
dependencies: .dependencies,
|
||||
peerDependencies: .peerDependencies
|
||||
} | with_entries(select(.value != null)))
|
||||
}
|
||||
)'
|
||||
)
|
||||
|
||||
${pkgs.jq}/bin/jq -n \
|
||||
--arg name "$pkg_name" \
|
||||
--argjson versions "$versions_json" \
|
||||
'{name: $name, "dist-tags": {}, versions: $versions}' \
|
||||
> "$pkg_dir/registry.json"
|
||||
done
|
||||
'';
|
||||
|
||||
denoWithCache = { pkgs, baseDeno, sharedCache }:
|
||||
pkgs.writeShellScriptBin "deno" ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue