2023-09-05 16:17:49 +03:00
|
|
|
{
|
|
|
|
pkgs ? import <nixpkgs> {},
|
|
|
|
lib ? import <nixpkgs/lib>,
|
2023-11-05 06:22:03 +03:00
|
|
|
inputs ? {},
|
|
|
|
dream2nix ? import ../../.. inputs,
|
2023-09-05 16:17:49 +03:00
|
|
|
}: let
|
|
|
|
eval = module:
|
|
|
|
lib.evalModules {
|
|
|
|
modules = [module];
|
|
|
|
specialArgs = {
|
|
|
|
inherit dream2nix;
|
|
|
|
packageSets = {
|
|
|
|
nixpkgs = pkgs;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
# test if dependencies are ignored successfully in pip.rootDependencies
|
|
|
|
test_nodejs_parse_root_lock = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLock = lib.mkForce {
|
|
|
|
# Example content of lockfile
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"lockfileVersion" = 3;
|
|
|
|
"requires" = true;
|
|
|
|
"packages" = {
|
|
|
|
"" = {
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"license" = "ISC";
|
|
|
|
"dependencies" = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
# This needs to be set by the user / we can set this automatically later
|
|
|
|
nodejs-package-lock-v3.pdefs."minimal"."1.0.0".source = "";
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = config.nodejs-package-lock-v3.pdefs;
|
|
|
|
expected = {
|
|
|
|
"minimal"."1.0.0" = {
|
|
|
|
dependencies = {};
|
|
|
|
source = "";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# test if dependencies are ignored successfully in pip.rootDependencies
|
|
|
|
test_nodejs_fetch_dep = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLock = lib.mkForce {
|
|
|
|
# Example content of lockfile
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"lockfileVersion" = 3;
|
|
|
|
"requires" = true;
|
|
|
|
"packages" = {
|
|
|
|
"node_modules/async" = {
|
|
|
|
"version" = "0.2.10";
|
|
|
|
"resolved" = "https://registry.npmjs.org/async/-/async-0.2.10.tgz";
|
|
|
|
"integrity" = "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==";
|
|
|
|
};
|
|
|
|
# "node_modules/@org/async" = {
|
|
|
|
# "version" = "0.2.10";
|
|
|
|
# "resolved" = "https://registry.npmjs.org/async/-/async-0.2.10.tgz";
|
|
|
|
# "integrity" = "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==";
|
|
|
|
# };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = config.nodejs-package-lock-v3.pdefs."async"."0.2.10".source.type;
|
|
|
|
expected = "derivation";
|
|
|
|
};
|
|
|
|
|
|
|
|
# test if dependencies are ignored successfully in pip.rootDependencies
|
|
|
|
test_nodejs_file_dep = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLockFile = ./package-lock.json;
|
|
|
|
nodejs-package-lock-v3.packageLock = lib.mkForce {
|
|
|
|
# Example content of lockfile
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"lockfileVersion" = 3;
|
|
|
|
"requires" = true;
|
|
|
|
"packages" = {
|
|
|
|
"node_modules/@org/lib" = {
|
|
|
|
"resolved" = "./lib";
|
|
|
|
"link" = true;
|
|
|
|
};
|
|
|
|
"node_modules/@org/async" = {
|
|
|
|
"version" = "0.2.10";
|
|
|
|
"resolved" = "https://registry.npmjs.org/async/-/async-0.2.10.tgz";
|
|
|
|
"integrity" = "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = config.nodejs-package-lock-v3.pdefs."@org/lib"."1.0.0".source;
|
|
|
|
expected = ./. + "/lib";
|
|
|
|
};
|
|
|
|
|
|
|
|
# test if dependencies are ignored successfully in pip.rootDependencies
|
|
|
|
test_nodejs_resolve_single_dependency = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLockFile = ./package-lock.json;
|
|
|
|
nodejs-package-lock-v3.packageLock = lib.mkForce {
|
|
|
|
# Example content of lockfile
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"lockfileVersion" = 3;
|
|
|
|
"requires" = true;
|
|
|
|
"packages" = {
|
|
|
|
"" = {
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"license" = "ISC";
|
|
|
|
"dependencies" = {
|
|
|
|
"@org/async" = "^0.2.0";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
"node_modules/@org/async" = {
|
|
|
|
"version" = "0.2.10";
|
|
|
|
"resolved" = "https://registry.npmjs.org/async/-/async-0.2.10.tgz";
|
|
|
|
"integrity" = "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = config.nodejs-package-lock-v3.pdefs."minimal"."1.0.0".dependencies;
|
|
|
|
expected = {
|
|
|
|
"@org/async" = {
|
|
|
|
dev = false;
|
|
|
|
version = "0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
test_nodejs_resolve_nested_dependency = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLockFile = ./package-lock.json;
|
|
|
|
nodejs-package-lock-v3.packageLock = lib.mkForce {
|
|
|
|
# Example content of lockfile
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"lockfileVersion" = 3;
|
|
|
|
"requires" = true;
|
|
|
|
"packages" = {
|
|
|
|
"node_modules/foo" = {
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"dependencies" = {
|
|
|
|
"@org/async" = "^0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
# expect to resolve this
|
|
|
|
"node_modules/foo/node_modules/@org/async" = {
|
|
|
|
"version" = "0.2.10";
|
|
|
|
"resolved" = "https://registry.npmjs.org/async/-/async-0.2.10.tgz";
|
|
|
|
"integrity" = "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==";
|
|
|
|
};
|
|
|
|
# expect to NOT resolve this
|
|
|
|
"node_modules/@org/async" = {
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"resolved" = "https://registry.npmjs.org/async/-/async-0.2.10.tgz";
|
|
|
|
"integrity" = "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = config.nodejs-package-lock-v3.pdefs."foo"."1.0.0".dependencies;
|
|
|
|
expected = {
|
|
|
|
"@org/async" = {
|
|
|
|
dev = false;
|
|
|
|
version = "0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
test_nodejs_resolve_hoisted_dependency = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLockFile = ./package-lock.json;
|
|
|
|
nodejs-package-lock-v3.packageLock = lib.mkForce {
|
|
|
|
# Example content of lockfile
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"lockfileVersion" = 3;
|
|
|
|
"packages" = {
|
|
|
|
"node_modules/foo" = {
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"dependencies" = {
|
|
|
|
"@org/async" = "^0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
# expect to NOT resolve this
|
|
|
|
"node_modules/other/node_modules/@org/async" = {
|
|
|
|
"version" = "1.0.0";
|
|
|
|
};
|
|
|
|
# expect to resolve this
|
|
|
|
"node_modules/@org/async" = {
|
|
|
|
"version" = "0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = config.nodejs-package-lock-v3.pdefs."foo"."1.0.0".dependencies;
|
|
|
|
expected = {
|
|
|
|
"@org/async" = {
|
|
|
|
dev = false;
|
|
|
|
version = "0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
test_nodejs_resolve_dev_dependency = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLockFile = ./package-lock.json;
|
|
|
|
nodejs-package-lock-v3.packageLock = lib.mkForce {
|
|
|
|
# Example content of lockfile
|
|
|
|
"name" = "minimal";
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"lockfileVersion" = 3;
|
|
|
|
"packages" = {
|
|
|
|
"node_modules/foo" = {
|
|
|
|
"version" = "1.0.0";
|
|
|
|
"devDependencies" = {
|
|
|
|
"@org/async" = "^0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
# expect to NOT resolve this
|
|
|
|
"node_modules/other/node_modules/@org/async" = {
|
|
|
|
"version" = "1.0.0";
|
|
|
|
};
|
|
|
|
# expect to resolve this
|
|
|
|
"node_modules/@org/async" = {
|
|
|
|
"version" = "0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = config.nodejs-package-lock-v3.pdefs."foo"."1.0.0".dependencies;
|
|
|
|
expected = {
|
|
|
|
"@org/async" = {
|
|
|
|
dev = false;
|
|
|
|
version = "0.2.10";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-05 19:39:29 +03:00
|
|
|
test_multiple_versions = let
|
|
|
|
evaled = eval {
|
|
|
|
imports = [
|
|
|
|
dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
];
|
|
|
|
nodejs-package-lock-v3.packageLockFile = ./multiple-versions-lock.json;
|
|
|
|
};
|
|
|
|
config = evaled.config;
|
|
|
|
in {
|
|
|
|
expr = lib.attrNames config.nodejs-package-lock-v3.pdefs.strip-ansi;
|
|
|
|
expected = [
|
|
|
|
"3.0.1"
|
|
|
|
"4.0.0"
|
|
|
|
"6.0.0"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-09-05 16:17:49 +03:00
|
|
|
# TODO: some infinite recursion occurs when accessing pdef.{name}.{version}.source
|
|
|
|
# test_nodejs_parse_lockfile = let
|
|
|
|
# evaled = eval {
|
|
|
|
# imports = [
|
|
|
|
# dream2nix.modules.dream2nix.nodejs-package-lock-v3
|
|
|
|
# ];
|
|
|
|
# nodejs-package-lock-v3.packageLockFile = ./package-lock.json;
|
|
|
|
# nodejs-package-lock-v3.packageLock = lib.mkForce (builtins.fromJSON (builtins.readFile ./package-lock.json));
|
|
|
|
# # set the root package source
|
|
|
|
# nodejs-package-lock-v3.pdefs."minimal"."1.0.0".source = "";
|
|
|
|
# };
|
|
|
|
# config = evaled.config;
|
|
|
|
# in {
|
|
|
|
# expr = config.nodejs-package-lock-v3.pdefs."argparse"."0.1.16";
|
|
|
|
# expected = {
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
}
|