From 0177ae20ae096a4b8abbbb7e74439d7b71bf75ab Mon Sep 17 00:00:00 2001 From: rtkt Date: Sat, 21 Oct 2023 16:25:49 +0700 Subject: [PATCH 1/6] Add NodeJS 20 support --- bin/node2nix.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/node2nix.js b/bin/node2nix.js index a04b6d5..30b0281 100755 --- a/bin/node2nix.js +++ b/bin/node2nix.js @@ -26,6 +26,7 @@ var switches = [ ['-14', '--nodejs-14', 'Provides all settings to generate expression for usage with Node.js 14.x (default is: nodejs-14_x)'], ['-16', '--nodejs-16', 'Provides all settings to generate expression for usage with Node.js 16.x (default is: nodejs-14_x)'], ['-18', '--nodejs-18', 'Provides all settings to generate expression for usage with Node.js 18.x (default is: nodejs-14_x)'], + ['-20', '--nodejs-20', 'Provides all settings to generate expression for usage with Node.js 20.x (default is: nodejs-14_x)'], ['--supplement-input FILE', 'A supplement package JSON file that are passed as build inputs to all packages defined in the input JSON file'], ['--supplement-output FILE', 'Path to a Nix expression representing a supplementing set of Nix packages provided as inputs to a project (defaults to: supplement.nix)'], ['--include-peer-dependencies', 'Specifies whether to include peer dependencies. In npm 2.x, this is the default. (true by default for Node.js 16+)'], @@ -185,6 +186,13 @@ parser.on('nodejs-18', function(arg, value) { includePeerDependencies = true; }); +parser.on('nodejs-20', function(arg, value) { + flatten = true; + nodePackage = "nodejs_20"; + bypassCache = true; + includePeerDependencies = true; +}); + parser.on('include-peer-dependencies', function(arg, value) { includePeerDependencies = true; }); From 52b2c42df12415cbec658c358fb30b1ee2d611aa Mon Sep 17 00:00:00 2001 From: rtkt Date: Sat, 21 Oct 2023 17:58:27 +0700 Subject: [PATCH 2/6] Removed all NodeJS options before 14.x --- bin/node2nix.js | 55 ------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/bin/node2nix.js b/bin/node2nix.js index 30b0281..68bc087 100755 --- a/bin/node2nix.js +++ b/bin/node2nix.js @@ -17,12 +17,6 @@ var switches = [ ['-e', '--node-env FILE', 'Path to the Nix expression implementing functions that builds NPM packages (defaults to: node-env.nix)'], ['-l', '--lock FILE', 'Path to the package-lock.json file that pinpoints the variants of all dependencies'], ['-d', '--development', 'Specifies whether to do a development (non-production) deployment for a package.json deployment (false by default)'], - ['-4', '--nodejs-4', 'Provides all settings to generate expression for usage with Node.js 4.x (default is: nodejs-14_x)'], - ['-6', '--nodejs-6', 'Provides all settings to generate expression for usage with Node.js 6.x (default is: nodejs-14_x)'], - ['-8', '--nodejs-8', 'Provides all settings to generate expression for usage with Node.js 8.x (default is: nodejs-14_x)'], - ['-10', '--nodejs-10', 'Provides all settings to generate expression for usage with Node.js 10.x (default is: nodejs-14_x)'], - ['-12', '--nodejs-12', 'Provides all settings to generate expression for usage with Node.js 12.x (default is: nodejs-14_x)'], - ['-13', '--nodejs-13', 'Provides all settings to generate expression for usage with Node.js 13.x (default is: nodejs-14_x)'], ['-14', '--nodejs-14', 'Provides all settings to generate expression for usage with Node.js 14.x (default is: nodejs-14_x)'], ['-16', '--nodejs-16', 'Provides all settings to generate expression for usage with Node.js 16.x (default is: nodejs-14_x)'], ['-18', '--nodejs-18', 'Provides all settings to generate expression for usage with Node.js 18.x (default is: nodejs-14_x)'], @@ -116,48 +110,6 @@ parser.on('development', function(arg, value) { production = false; }); -parser.on('nodejs-4', function(arg, value) { - flatten = false; - nodePackage = "nodejs-4_x"; - bypassCache = false; - includePeerDependencies = false; -}); - -parser.on('nodejs-6', function(arg, value) { - flatten = true; - nodePackage = "nodejs-6_x"; - bypassCache = false; - includePeerDependencies = false; -}); - -parser.on('nodejs-8', function(arg, value) { - flatten = true; - nodePackage = "nodejs-8_x"; - bypassCache = true; - includePeerDependencies = false; -}); - -parser.on('nodejs-10', function(arg, value) { - flatten = true; - nodePackage = "nodejs-10_x"; - bypassCache = true; - includePeerDependencies = false; -}); - -parser.on('nodejs-12', function(arg, value) { - flatten = true; - nodePackage = "nodejs-12_x"; - bypassCache = true; - includePeerDependencies = false; -}); - -parser.on('nodejs-13', function(arg, value) { - flatten = true; - nodePackage = "nodejs-13_x"; - bypassCache = true; - includePeerDependencies = false; -}); - parser.on('nodejs-14', function(arg, value) { flatten = true; nodePackage = "nodejs-14_x"; @@ -172,13 +124,6 @@ parser.on('nodejs-16', function(arg, value) { includePeerDependencies = true; }); -parser.on('nodejs-17', function(arg, value) { - flatten = true; - nodePackage = "nodejs-17_x"; - bypassCache = true; - includePeerDependencies = true; -}); - parser.on('nodejs-18', function(arg, value) { flatten = true; nodePackage = "nodejs-18_x"; From 68655b892437d0a587d61cdfeac2af305c06e49c Mon Sep 17 00:00:00 2001 From: rtkt Date: Sat, 21 Oct 2023 18:40:50 +0700 Subject: [PATCH 3/6] Updated nodePackage names --- bin/node2nix.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/node2nix.js b/bin/node2nix.js index 68bc087..4ef98c9 100755 --- a/bin/node2nix.js +++ b/bin/node2nix.js @@ -17,10 +17,10 @@ var switches = [ ['-e', '--node-env FILE', 'Path to the Nix expression implementing functions that builds NPM packages (defaults to: node-env.nix)'], ['-l', '--lock FILE', 'Path to the package-lock.json file that pinpoints the variants of all dependencies'], ['-d', '--development', 'Specifies whether to do a development (non-production) deployment for a package.json deployment (false by default)'], - ['-14', '--nodejs-14', 'Provides all settings to generate expression for usage with Node.js 14.x (default is: nodejs-14_x)'], - ['-16', '--nodejs-16', 'Provides all settings to generate expression for usage with Node.js 16.x (default is: nodejs-14_x)'], - ['-18', '--nodejs-18', 'Provides all settings to generate expression for usage with Node.js 18.x (default is: nodejs-14_x)'], - ['-20', '--nodejs-20', 'Provides all settings to generate expression for usage with Node.js 20.x (default is: nodejs-14_x)'], + ['-14', '--nodejs-14', 'Provides all settings to generate expression for usage with Node.js 14.x (default is: nodejs_14)'], + ['-16', '--nodejs-16', 'Provides all settings to generate expression for usage with Node.js 16.x (default is: nodejs_14)'], + ['-18', '--nodejs-18', 'Provides all settings to generate expression for usage with Node.js 18.x (default is: nodejs_14)'], + ['-20', '--nodejs-20', 'Provides all settings to generate expression for usage with Node.js 20.x (default is: nodejs_14)'], ['--supplement-input FILE', 'A supplement package JSON file that are passed as build inputs to all packages defined in the input JSON file'], ['--supplement-output FILE', 'Path to a Nix expression representing a supplementing set of Nix packages provided as inputs to a project (defaults to: supplement.nix)'], ['--include-peer-dependencies', 'Specifies whether to include peer dependencies. In npm 2.x, this is the default. (true by default for Node.js 16+)'], @@ -52,7 +52,7 @@ var supplementNix = "supplement.nix"; var nodeEnvNix = "node-env.nix"; var lockJSON; var registries = []; -var nodePackage = "nodejs-14_x"; +var nodePackage = "nodejs_14"; var noCopyNodeEnv = false; var bypassCache = true; var useFetchGitPrivate = false; @@ -112,21 +112,21 @@ parser.on('development', function(arg, value) { parser.on('nodejs-14', function(arg, value) { flatten = true; - nodePackage = "nodejs-14_x"; + nodePackage = "nodejs_14"; bypassCache = true; includePeerDependencies = false; }); parser.on('nodejs-16', function(arg, value) { flatten = true; - nodePackage = "nodejs-16_x"; + nodePackage = "nodejs_16"; bypassCache = true; includePeerDependencies = true; }); parser.on('nodejs-18', function(arg, value) { flatten = true; - nodePackage = "nodejs-18_x"; + nodePackage = "nodejs_18"; bypassCache = true; includePeerDependencies = true; }); From 63118136f3b456244f0c1baf6323f856c815e55d Mon Sep 17 00:00:00 2001 From: rtkt Date: Sat, 21 Oct 2023 19:22:18 +0700 Subject: [PATCH 4/6] Added stripping of optional peer dependencies --- lib/sources/NPMRegistrySource.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/sources/NPMRegistrySource.js b/lib/sources/NPMRegistrySource.js index 616fb22..019e3d5 100644 --- a/lib/sources/NPMRegistrySource.js +++ b/lib/sources/NPMRegistrySource.js @@ -156,6 +156,14 @@ NPMRegistrySource.prototype.fetch = function(callback) { } } + if(self.stripOptionalDependencies && self.config.peerDependencies !== undefined && self.config.peerDependenciesMeta !== undefined) { + for (var dependencyName in self.config.peerDependencies) { + if (self.config.peerDependenciesMeta[dependencyName] && self.config.peerDependenciesMeta[dependencyName]?.optional) { + delete self.config.peerDependencies[dependencyName]; + } + } + } + // Determine the output hash. If the package provides an integrity string, use it to compose a hash. Otherwise fall back to sha1 if(self.config.dist.integrity !== undefined) { From 62c841e78c7b250407ec6712d3bd7bd823c1a82b Mon Sep 17 00:00:00 2001 From: rtkt Date: Fri, 3 Nov 2023 19:14:55 +0700 Subject: [PATCH 5/6] Added NodeJS 21 support --- bin/node2nix.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/node2nix.js b/bin/node2nix.js index 4ef98c9..90de580 100755 --- a/bin/node2nix.js +++ b/bin/node2nix.js @@ -21,6 +21,7 @@ var switches = [ ['-16', '--nodejs-16', 'Provides all settings to generate expression for usage with Node.js 16.x (default is: nodejs_14)'], ['-18', '--nodejs-18', 'Provides all settings to generate expression for usage with Node.js 18.x (default is: nodejs_14)'], ['-20', '--nodejs-20', 'Provides all settings to generate expression for usage with Node.js 20.x (default is: nodejs_14)'], + ['-21', '--nodejs-21', 'Provides all settings to generate expression for usage with Node.js 21.x (default is: nodejs_14)'], ['--supplement-input FILE', 'A supplement package JSON file that are passed as build inputs to all packages defined in the input JSON file'], ['--supplement-output FILE', 'Path to a Nix expression representing a supplementing set of Nix packages provided as inputs to a project (defaults to: supplement.nix)'], ['--include-peer-dependencies', 'Specifies whether to include peer dependencies. In npm 2.x, this is the default. (true by default for Node.js 16+)'], @@ -138,8 +139,15 @@ parser.on('nodejs-20', function(arg, value) { includePeerDependencies = true; }); +parser.on('nodejs-21', function(arg, value) { + flatten = true; + nodePackage = "nodejs_21"; + bypassCache = true; + includePeerDependencies = true; +}); + parser.on('include-peer-dependencies', function(arg, value) { - includePeerDependencies = true; + includePeerDependencies = true; }); parser.on('no-flatten', function(arg, value) { From d7827f8a59238c4a64fdd224abdf40945613a08a Mon Sep 17 00:00:00 2001 From: rtkt Date: Wed, 8 Nov 2023 20:38:22 +0700 Subject: [PATCH 6/6] Changed default NodeJS version to 18 --- bin/node2nix.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/node2nix.js b/bin/node2nix.js index 90de580..abedf22 100755 --- a/bin/node2nix.js +++ b/bin/node2nix.js @@ -17,11 +17,11 @@ var switches = [ ['-e', '--node-env FILE', 'Path to the Nix expression implementing functions that builds NPM packages (defaults to: node-env.nix)'], ['-l', '--lock FILE', 'Path to the package-lock.json file that pinpoints the variants of all dependencies'], ['-d', '--development', 'Specifies whether to do a development (non-production) deployment for a package.json deployment (false by default)'], - ['-14', '--nodejs-14', 'Provides all settings to generate expression for usage with Node.js 14.x (default is: nodejs_14)'], - ['-16', '--nodejs-16', 'Provides all settings to generate expression for usage with Node.js 16.x (default is: nodejs_14)'], - ['-18', '--nodejs-18', 'Provides all settings to generate expression for usage with Node.js 18.x (default is: nodejs_14)'], - ['-20', '--nodejs-20', 'Provides all settings to generate expression for usage with Node.js 20.x (default is: nodejs_14)'], - ['-21', '--nodejs-21', 'Provides all settings to generate expression for usage with Node.js 21.x (default is: nodejs_14)'], + ['-14', '--nodejs-14', 'Provides all settings to generate expression for usage with Node.js 14.x (default is: nodejs_18)'], + ['-16', '--nodejs-16', 'Provides all settings to generate expression for usage with Node.js 16.x (default is: nodejs_18)'], + ['-18', '--nodejs-18', 'Provides all settings to generate expression for usage with Node.js 18.x (default is: nodejs_18)'], + ['-20', '--nodejs-20', 'Provides all settings to generate expression for usage with Node.js 20.x (default is: nodejs_18)'], + ['-21', '--nodejs-21', 'Provides all settings to generate expression for usage with Node.js 21.x (default is: nodejs_18)'], ['--supplement-input FILE', 'A supplement package JSON file that are passed as build inputs to all packages defined in the input JSON file'], ['--supplement-output FILE', 'Path to a Nix expression representing a supplementing set of Nix packages provided as inputs to a project (defaults to: supplement.nix)'], ['--include-peer-dependencies', 'Specifies whether to include peer dependencies. In npm 2.x, this is the default. (true by default for Node.js 16+)'], @@ -53,7 +53,7 @@ var supplementNix = "supplement.nix"; var nodeEnvNix = "node-env.nix"; var lockJSON; var registries = []; -var nodePackage = "nodejs_14"; +var nodePackage = "nodejs_18"; var noCopyNodeEnv = false; var bypassCache = true; var useFetchGitPrivate = false;