From 8c5b8283f4b93c308a98d8a65611eb9a73fd6aa3 Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 1 Nov 2022 13:47:32 -0700 Subject: [PATCH 1/7] deps: node-gyp@9.3.0 --- node_modules/.gitignore | 1 - node_modules/node-gyp/addon.gypi | 43 +- .../node-gyp/gyp/pylib/gyp/__init__.py | 24 + node_modules/node-gyp/gyp/pylib/gyp/common.py | 13 +- .../node-gyp/gyp/pylib/gyp/flock_tool.py | 2 +- .../node-gyp/gyp/pylib/gyp/generator/make.py | 261 +++++++++-- .../node-gyp/gyp/pylib/gyp/generator/msvs.py | 11 +- .../node-gyp/gyp/pylib/gyp/generator/ninja.py | 8 +- node_modules/node-gyp/gyp/pylib/gyp/input.py | 21 +- .../node-gyp/gyp/pylib/gyp/xcodeproj_file.py | 2 +- node_modules/node-gyp/gyp/pyproject.toml | 41 ++ .../node-gyp/gyp/requirements_dev.txt | 2 - node_modules/node-gyp/gyp/setup.py | 42 -- node_modules/node-gyp/gyp/test_gyp.py | 1 + node_modules/node-gyp/gyp/tools/pretty_gyp.py | 2 +- node_modules/node-gyp/lib/build.js | 2 + node_modules/node-gyp/lib/configure.js | 49 +- .../node-gyp/lib/find-visualstudio.js | 5 + .../node-gyp/node_modules/nopt/LICENSE | 15 - .../node-gyp/node_modules/nopt/bin/nopt.js | 54 --- .../node-gyp/node_modules/nopt/lib/nopt.js | 441 ------------------ .../node-gyp/node_modules/nopt/package.json | 34 -- node_modules/node-gyp/package.json | 4 +- .../node-gyp/test/test-find-node-directory.js | 2 +- node_modules/node-gyp/update-gyp.py | 20 +- package-lock.json | 23 +- package.json | 2 +- 27 files changed, 438 insertions(+), 687 deletions(-) create mode 100644 node_modules/node-gyp/gyp/pyproject.toml delete mode 100644 node_modules/node-gyp/gyp/requirements_dev.txt delete mode 100644 node_modules/node-gyp/gyp/setup.py delete mode 100644 node_modules/node-gyp/node_modules/nopt/LICENSE delete mode 100755 node_modules/node-gyp/node_modules/nopt/bin/nopt.js delete mode 100644 node_modules/node-gyp/node_modules/nopt/lib/nopt.js delete mode 100644 node_modules/node-gyp/node_modules/nopt/package.json diff --git a/node_modules/.gitignore b/node_modules/.gitignore index 92d5c9cce5e3a..f4e8be555b6e8 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -170,7 +170,6 @@ !/node-gyp/node_modules/make-fetch-happen !/node-gyp/node_modules/minimatch !/node-gyp/node_modules/minipass-fetch -!/node-gyp/node_modules/nopt !/node-gyp/node_modules/npmlog !/node-gyp/node_modules/ssri !/node-gyp/node_modules/unique-filename diff --git a/node_modules/node-gyp/addon.gypi b/node_modules/node-gyp/addon.gypi index 9327b0d722e74..b4ac369acb4f1 100644 --- a/node_modules/node-gyp/addon.gypi +++ b/node_modules/node-gyp/addon.gypi @@ -103,22 +103,41 @@ '-Wl,-bimport:<(node_exp_file)' ], }], + [ 'OS=="os400"', { + 'ldflags': [ + '-Wl,-bimport:<(node_exp_file)' + ], + }], [ 'OS=="zos"', { - 'cflags': [ - '-q64', - '-Wc,DLL', - '-qlonglong', - '-qenum=int', - '-qxclang=-fexec-charset=ISO8859-1' + 'conditions': [ + [ '"$(1) +$(call xargs,@printf "%s\\n" >>$(1),$(2)) +endef + +OBJ_FILE_LIST := ar-file-list + +define create_archive + rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)` + $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) + $(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST) +endef + +define create_thin_archive + rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)` + $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) + $(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST) +endef + # We support two kinds of shared objects (.so): # 1) shared_library, which is just bundling together many dependent libraries # into a link line. @@ -198,6 +226,31 @@ def CalculateGeneratorInputInfo(params): quiet_cmd_alink_thin = AR($(TOOLSET)) $@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) +# Note: this does not handle spaces in paths +define xargs + $(1) $(word 1,$(2)) +$(if $(word 2,$(2)),$(call xargs,$(1),$(wordlist 2,$(words $(2)),$(2)))) +endef + +define write-to-file + @: >$(1) +$(call xargs,@printf "%s\\n" >>$(1),$(2)) +endef + +OBJ_FILE_LIST := ar-file-list + +define create_archive + rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)` + $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) + $(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST) +endef + +define create_thin_archive + rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)` + $(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2))) + $(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST) +endef + # Due to circular dependencies between libraries :(, we wrap the # special "figure out circular dependencies" flags around the entire # input list during linking. @@ -237,6 +290,24 @@ def CalculateGeneratorInputInfo(params): """ # noqa: E501 +LINK_COMMANDS_OS400 = """\ +quiet_cmd_alink = AR($(TOOLSET)) $@ +cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^) + +quiet_cmd_alink_thin = AR($(TOOLSET)) $@ +cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) -X64 crs $@ $(filter %.o,$^) + +quiet_cmd_link = LINK($(TOOLSET)) $@ +cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) + +quiet_cmd_solink = SOLINK($(TOOLSET)) $@ +cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) + +quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ +cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) +""" # noqa: E501 + + LINK_COMMANDS_OS390 = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) @@ -248,10 +319,10 @@ def CalculateGeneratorInputInfo(params): cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) -Wl,DLL +cmd_solink = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -Wl,DLL +cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) """ # noqa: E501 @@ -308,6 +379,7 @@ def CalculateGeneratorInputInfo(params): LINK.target ?= %(LINK.target)s LDFLAGS.target ?= $(LDFLAGS) AR.target ?= $(AR) +PLI.target ?= %(PLI.target)s # C++ apps need to be linked with g++. LINK ?= $(CXX.target) @@ -321,6 +393,7 @@ def CalculateGeneratorInputInfo(params): LINK.host ?= %(LINK.host)s LDFLAGS.host ?= $(LDFLAGS_host) AR.host ?= %(AR.host)s +PLI.host ?= %(PLI.host)s # Define a dir function that can handle spaces. # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions @@ -400,6 +473,9 @@ def CalculateGeneratorInputInfo(params): # send stderr to /dev/null to ignore messages when linking directories. cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp %(copy_archive_args)s "$<" "$@") +quiet_cmd_symlink = SYMLINK $@ +cmd_symlink = ln -sf "$<" "$@" + %(link_commands)s """ # noqa: E501 r""" @@ -555,6 +631,15 @@ def WriteRootHeaderSuffixRules(writer): writer.write("\n") +SHARED_HEADER_OS390_COMMANDS = """ +PLIFLAGS.target ?= -qlp=64 -qlimits=extname=31 $(PLIFLAGS) +PLIFLAGS.host ?= -qlp=64 -qlimits=extname=31 $(PLIFLAGS) + +quiet_cmd_pli = PLI($(TOOLSET)) $@ +cmd_pli = $(PLI.$(TOOLSET)) $(GYP_PLIFLAGS) $(PLIFLAGS.$(TOOLSET)) -c $< && \ + if [ -f $(notdir $@) ]; then /bin/cp $(notdir $@) $@; else true; fi +""" + SHARED_HEADER_SUFFIX_RULES_COMMENT1 = """\ # Suffix rules, putting all outputs into $(obj). """ @@ -981,12 +1066,20 @@ def WriteActions( # libraries, but until everything is made cross-compile safe, also use # target libraries. # TODO(piman): when everything is cross-compile safe, remove lib.target - self.WriteLn( - "cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:" - "$(builddir)/lib.target:$$LD_LIBRARY_PATH; " - "export LD_LIBRARY_PATH; " - "%s%s" % (name, cd_action, command) - ) + if self.flavor == "zos" or self.flavor == "aix": + self.WriteLn( + "cmd_%s = LIBPATH=$(builddir)/lib.host:" + "$(builddir)/lib.target:$$LIBPATH; " + "export LIBPATH; " + "%s%s" % (name, cd_action, command) + ) + else: + self.WriteLn( + "cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:" + "$(builddir)/lib.target:$$LD_LIBRARY_PATH; " + "export LD_LIBRARY_PATH; " + "%s%s" % (name, cd_action, command) + ) self.WriteLn() outputs = [self.Absolutify(o) for o in outputs] # The makefile rules are all relative to the top dir, but the gyp actions @@ -1480,6 +1573,8 @@ def ComputeOutputBasename(self, spec): target_prefix = "lib" if self.flavor == "aix": target_ext = ".a" + elif self.flavor == "zos": + target_ext = ".x" else: target_ext = ".so" elif self.type == "none": @@ -1560,6 +1655,14 @@ def ComputeDeps(self, spec): # link_deps.extend(spec.get('libraries', [])) return (gyp.common.uniquer(deps), gyp.common.uniquer(link_deps)) + def GetSharedObjectFromSidedeck(self, sidedeck): + """Return the shared object files based on sidedeck""" + return re.sub(r"\.x$", ".so", sidedeck) + + def GetUnversionedSidedeckFromSidedeck(self, sidedeck): + """Return the shared object files based on sidedeck""" + return re.sub(r"\.\d+\.x$", ".x", sidedeck) + def WriteDependencyOnExtraOutputs(self, target, extra_outputs): self.WriteMakeRule( [self.output_binary], @@ -1768,21 +1871,35 @@ def WriteTarget( self.flavor not in ("mac", "openbsd", "netbsd", "win") and not self.is_standalone_static_library ): - self.WriteDoCmd( - [self.output_binary], - link_deps, - "alink_thin", - part_of_all, - postbuilds=postbuilds, - ) + if self.flavor in ("linux", "android"): + self.WriteMakeRule( + [self.output_binary], + link_deps, + actions=["$(call create_thin_archive,$@,$^)"], + ) + else: + self.WriteDoCmd( + [self.output_binary], + link_deps, + "alink_thin", + part_of_all, + postbuilds=postbuilds, + ) else: - self.WriteDoCmd( - [self.output_binary], - link_deps, - "alink", - part_of_all, - postbuilds=postbuilds, - ) + if self.flavor in ("linux", "android"): + self.WriteMakeRule( + [self.output_binary], + link_deps, + actions=["$(call create_archive,$@,$^)"], + ) + else: + self.WriteDoCmd( + [self.output_binary], + link_deps, + "alink", + part_of_all, + postbuilds=postbuilds, + ) elif self.type == "shared_library": self.WriteLn( "%s: LD_INPUTS := %s" @@ -1798,6 +1915,17 @@ def WriteTarget( part_of_all, postbuilds=postbuilds, ) + # z/OS has a .so target as well as a sidedeck .x target + if self.flavor == "zos": + self.WriteLn( + "%s: %s" + % ( + QuoteSpaces( + self.GetSharedObjectFromSidedeck(self.output_binary) + ), + QuoteSpaces(self.output_binary), + ) + ) elif self.type == "loadable_module": for link_dep in link_deps: assert " " not in link_dep, ( @@ -1855,7 +1983,9 @@ def WriteTarget( else: file_desc = "executable" install_path = self._InstallableTargetInstallPath() - installable_deps = [self.output] + installable_deps = [] + if self.flavor != "zos": + installable_deps.append(self.output) if ( self.flavor == "mac" and "product_dir" not in spec @@ -1880,7 +2010,30 @@ def WriteTarget( comment="Copy this to the %s output path." % file_desc, part_of_all=part_of_all, ) - installable_deps.append(install_path) + if self.flavor != "zos": + installable_deps.append(install_path) + if self.flavor == "zos" and self.type == "shared_library": + # lib.target/libnode.so has a dependency on $(obj).target/libnode.so + self.WriteDoCmd( + [self.GetSharedObjectFromSidedeck(install_path)], + [self.GetSharedObjectFromSidedeck(self.output)], + "copy", + comment="Copy this to the %s output path." % file_desc, + part_of_all=part_of_all, + ) + # Create a symlink of libnode.x to libnode.version.x + self.WriteDoCmd( + [self.GetUnversionedSidedeckFromSidedeck(install_path)], + [install_path], + "symlink", + comment="Symlnk this to the %s output path." % file_desc, + part_of_all=part_of_all, + ) + # Place libnode.version.so and libnode.x symlink in lib.target dir + installable_deps.append(self.GetSharedObjectFromSidedeck(install_path)) + installable_deps.append( + self.GetUnversionedSidedeckFromSidedeck(install_path) + ) if self.output != self.alias and self.alias != self.target: self.WriteMakeRule( [self.alias], @@ -1888,7 +2041,18 @@ def WriteTarget( comment="Short alias for building this %s." % file_desc, phony=True, ) - if part_of_all: + if self.flavor == "zos" and self.type == "shared_library": + # Make sure that .x symlink target is run + self.WriteMakeRule( + ["all"], + [ + self.GetUnversionedSidedeckFromSidedeck(install_path), + self.GetSharedObjectFromSidedeck(install_path), + ], + comment='Add %s to "all" target.' % file_desc, + phony=True, + ) + elif part_of_all: self.WriteMakeRule( ["all"], [install_path], @@ -2184,6 +2348,9 @@ def _InstallableTargetInstallPath(self): # # Install all shared libs into a common directory (per toolset) for # # convenient access with LD_LIBRARY_PATH. # return "$(builddir)/lib.%s/%s" % (self.toolset, self.alias) + if self.flavor == "zos" and self.type == "shared_library": + return "$(builddir)/lib.%s/%s" % (self.toolset, self.alias) + return "$(builddir)/" + self.alias @@ -2295,10 +2462,12 @@ def CalculateMakefilePath(build_file, base_name): "AR.target": GetEnvironFallback(("AR_target", "AR"), "$(AR)"), "CXX.target": GetEnvironFallback(("CXX_target", "CXX"), "$(CXX)"), "LINK.target": GetEnvironFallback(("LINK_target", "LINK"), "$(LINK)"), + "PLI.target": GetEnvironFallback(("PLI_target", "PLI"), "pli"), "CC.host": GetEnvironFallback(("CC_host", "CC"), "gcc"), "AR.host": GetEnvironFallback(("AR_host", "AR"), "ar"), "CXX.host": GetEnvironFallback(("CXX_host", "CXX"), "g++"), "LINK.host": GetEnvironFallback(("LINK_host", "LINK"), "$(CXX.host)"), + "PLI.host": GetEnvironFallback(("PLI_host", "PLI"), "pli"), } if flavor == "mac": flock_command = "./gyp-mac-tool flock" @@ -2314,16 +2483,36 @@ def CalculateMakefilePath(build_file, base_name): header_params.update({"link_commands": LINK_COMMANDS_ANDROID}) elif flavor == "zos": copy_archive_arguments = "-fPR" - makedep_arguments = "-qmakedep=gcc" + CC_target = GetEnvironFallback(("CC_target", "CC"), "njsc") + makedep_arguments = "-MMD" + if CC_target == "clang": + CC_host = GetEnvironFallback(("CC_host", "CC"), "clang") + CXX_target = GetEnvironFallback(("CXX_target", "CXX"), "clang++") + CXX_host = GetEnvironFallback(("CXX_host", "CXX"), "clang++") + elif CC_target == "ibm-clang64": + CC_host = GetEnvironFallback(("CC_host", "CC"), "ibm-clang64") + CXX_target = GetEnvironFallback(("CXX_target", "CXX"), "ibm-clang++64") + CXX_host = GetEnvironFallback(("CXX_host", "CXX"), "ibm-clang++64") + elif CC_target == "ibm-clang": + CC_host = GetEnvironFallback(("CC_host", "CC"), "ibm-clang") + CXX_target = GetEnvironFallback(("CXX_target", "CXX"), "ibm-clang++") + CXX_host = GetEnvironFallback(("CXX_host", "CXX"), "ibm-clang++") + else: + # Node.js versions prior to v18: + makedep_arguments = "-qmakedep=gcc" + CC_host = GetEnvironFallback(("CC_host", "CC"), "njsc") + CXX_target = GetEnvironFallback(("CXX_target", "CXX"), "njsc++") + CXX_host = GetEnvironFallback(("CXX_host", "CXX"), "njsc++") header_params.update( { "copy_archive_args": copy_archive_arguments, "makedep_args": makedep_arguments, "link_commands": LINK_COMMANDS_OS390, - "CC.target": GetEnvironFallback(("CC_target", "CC"), "njsc"), - "CXX.target": GetEnvironFallback(("CXX_target", "CXX"), "njsc++"), - "CC.host": GetEnvironFallback(("CC_host", "CC"), "njsc"), - "CXX.host": GetEnvironFallback(("CXX_host", "CXX"), "njsc++"), + "extra_commands": SHARED_HEADER_OS390_COMMANDS, + "CC.target": CC_target, + "CXX.target": CXX_target, + "CC.host": CC_host, + "CXX.host": CXX_host, } ) elif flavor == "solaris": @@ -2351,6 +2540,16 @@ def CalculateMakefilePath(build_file, base_name): "flock_index": 2, } ) + elif flavor == "os400": + copy_archive_arguments = "-pPRf" + header_params.update( + { + "copy_archive_args": copy_archive_arguments, + "link_commands": LINK_COMMANDS_OS400, + "flock": "./gyp-flock-tool flock", + "flock_index": 2, + } + ) build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) make_global_settings_array = data[build_file].get("make_global_settings", []) diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py index 8308fa8433352..fd95005784798 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py @@ -423,12 +423,15 @@ def _BuildCommandLineForRuleRaw( command.insert(0, "call") # Fix the paths # TODO(quote): This is a really ugly heuristic, and will miss path fixing - # for arguments like "--arg=path" or "/opt:path". - # If the argument starts with a slash or dash, it's probably a command line - # switch + # for arguments like "--arg=path", arg=path, or "/opt:path". + # If the argument starts with a slash or dash, or contains an equal sign, + # it's probably a command line switch. # Return the path with forward slashes because the command using it might # not support backslashes. - arguments = [i if (i[:1] in "/-") else _FixPath(i, "/") for i in cmd[1:]] + arguments = [ + i if (i[:1] in "/-" or "=" in i) else _FixPath(i, "/") + for i in cmd[1:] + ] arguments = [i.replace("$(InputDir)", "%INPUTDIR%") for i in arguments] arguments = [MSVSSettings.FixVCMacroSlashes(i) for i in arguments] if quote_cmd: diff --git a/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py b/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py index d173bf2299011..ca04ee13a1c1b 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py @@ -1583,7 +1583,7 @@ def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): elif spec["type"] == "static_library": self.target.binary = self.ComputeOutput(spec) if ( - self.flavor not in ("mac", "openbsd", "netbsd", "win") + self.flavor not in ("ios", "mac", "netbsd", "openbsd", "win") and not self.is_standalone_static_library ): self.ninja.build( @@ -2112,8 +2112,8 @@ class MEMORYSTATUSEX(ctypes.Structure): ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat)) # VS 2015 uses 20% more working set than VS 2013 and can consume all RAM - # on a 64 GB machine. - mem_limit = max(1, stat.ullTotalPhys // (5 * (2 ** 30))) # total / 5GB + # on a 64 GiB machine. + mem_limit = max(1, stat.ullTotalPhys // (5 * (2 ** 30))) # total / 5GiB hard_cap = max(1, int(os.environ.get("GYP_LINK_CONCURRENCY_MAX", 2 ** 32))) return min(mem_limit, hard_cap) elif sys.platform.startswith("linux"): @@ -2496,7 +2496,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name ), ) - if flavor != "mac" and flavor != "win": + if flavor not in ("ios", "mac", "win"): master_ninja.rule( "alink", description="AR $out", diff --git a/node_modules/node-gyp/gyp/pylib/gyp/input.py b/node_modules/node-gyp/gyp/pylib/gyp/input.py index 354958bfb2ab5..d9699a0a50218 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/input.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/input.py @@ -961,13 +961,13 @@ def ExpandVariables(input, phase, variables, build_file): # Fix up command with platform specific workarounds. contents = FixupPlatformCommand(contents) try: - p = subprocess.Popen( + # stderr will be printed no matter what + result = subprocess.run( contents, - shell=use_shell, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - stdin=subprocess.PIPE, + shell=use_shell, cwd=build_file_dir, + check=False ) except Exception as e: raise GypError( @@ -975,19 +975,12 @@ def ExpandVariables(input, phase, variables, build_file): % (e, contents, build_file) ) - p_stdout, p_stderr = p.communicate("") - p_stdout = p_stdout.decode("utf-8") - p_stderr = p_stderr.decode("utf-8") - - if p.wait() != 0 or p_stderr: - sys.stderr.write(p_stderr) - # Simulate check_call behavior, since check_call only exists - # in python 2.5 and later. + if result.returncode > 0: raise GypError( "Call to '%s' returned exit status %d while in %s." - % (contents, p.returncode, build_file) + % (contents, result.returncode, build_file) ) - replacement = p_stdout.rstrip() + replacement = result.stdout.decode("utf-8").rstrip() cached_command_results[cache_key] = replacement else: diff --git a/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py b/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py index 076eea3721117..0e941eb4719ea 100644 --- a/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +++ b/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py @@ -2990,7 +2990,7 @@ def AddOrGetProjectReference(self, other_pbxproject): # Xcode seems to sort this list case-insensitively self._properties["projectReferences"] = sorted( self._properties["projectReferences"], - key=lambda x: x["ProjectRef"].Name().lower + key=lambda x: x["ProjectRef"].Name().lower() ) else: # The link already exists. Pull out the relevnt data. diff --git a/node_modules/node-gyp/gyp/pyproject.toml b/node_modules/node-gyp/gyp/pyproject.toml new file mode 100644 index 0000000000000..d8a5451520cc3 --- /dev/null +++ b/node_modules/node-gyp/gyp/pyproject.toml @@ -0,0 +1,41 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "gyp-next" +version = "0.14.0" +authors = [ + { name="Node.js contributors", email="ryzokuken@disroot.org" }, +] +description = "A fork of the GYP build system for use in the Node.js projects" +readme = "README.md" +license = { file="LICENSE" } +requires-python = ">=3.6" +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] + +[project.optional-dependencies] +dev = ["flake8", "pytest"] + +[project.scripts] +gyp = "gyp:script_main" + +[project.urls] +"Homepage" = "https://github.com/nodejs/gyp-next" + +[tool.setuptools] +package-dir = {"" = "pylib"} +packages = ["gyp", "gyp.generator"] diff --git a/node_modules/node-gyp/gyp/requirements_dev.txt b/node_modules/node-gyp/gyp/requirements_dev.txt deleted file mode 100644 index 28ecacab60293..0000000000000 --- a/node_modules/node-gyp/gyp/requirements_dev.txt +++ /dev/null @@ -1,2 +0,0 @@ -flake8 -pytest diff --git a/node_modules/node-gyp/gyp/setup.py b/node_modules/node-gyp/gyp/setup.py deleted file mode 100644 index cf9d7d2e56c49..0000000000000 --- a/node_modules/node-gyp/gyp/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from os import path - -from setuptools import setup - -here = path.abspath(path.dirname(__file__)) -# Get the long description from the README file -with open(path.join(here, "README.md")) as in_file: - long_description = in_file.read() - -setup( - name="gyp-next", - version="0.10.0", - description="A fork of the GYP build system for use in the Node.js projects", - long_description=long_description, - long_description_content_type="text/markdown", - author="Node.js contributors", - author_email="ryzokuken@disroot.org", - url="https://github.com/nodejs/gyp-next", - package_dir={"": "pylib"}, - packages=["gyp", "gyp.generator"], - entry_points={"console_scripts": ["gyp=gyp:script_main"]}, - python_requires=">=3.6", - classifiers=[ - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Natural Language :: English", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - ], -) diff --git a/node_modules/node-gyp/gyp/test_gyp.py b/node_modules/node-gyp/gyp/test_gyp.py index 9ba264170f43a..b7bb956b8ed58 100755 --- a/node_modules/node-gyp/gyp/test_gyp.py +++ b/node_modules/node-gyp/gyp/test_gyp.py @@ -116,6 +116,7 @@ def main(argv=None): else: format_list = { "aix5": ["make"], + "os400": ["make"], "freebsd7": ["make"], "freebsd8": ["make"], "openbsd5": ["make"], diff --git a/node_modules/node-gyp/gyp/tools/pretty_gyp.py b/node_modules/node-gyp/gyp/tools/pretty_gyp.py index 4ffa44455181c..6eef3a1bbf02a 100755 --- a/node_modules/node-gyp/gyp/tools/pretty_gyp.py +++ b/node_modules/node-gyp/gyp/tools/pretty_gyp.py @@ -90,7 +90,7 @@ def count_braces(line): """ open_braces = ["[", "(", "{"] close_braces = ["]", ")", "}"] - closing_prefix_re = re.compile(r"(.*?[^\s\]\}\)]+.*?)([\]\}\)],?)\s*$") + closing_prefix_re = re.compile(r"[^\s\]\}\)]\s*[\]\}\)]+,?\s*$") cnt = 0 stripline = COMMENT_RE.sub(r"", line) stripline = QUOTE_RE.sub(r"''", stripline) diff --git a/node_modules/node-gyp/lib/build.js b/node_modules/node-gyp/lib/build.js index 3baba4140c9cb..ea1f90652a05d 100644 --- a/node_modules/node-gyp/lib/build.js +++ b/node_modules/node-gyp/lib/build.js @@ -11,6 +11,8 @@ function build (gyp, argv, callback) { var platformMake = 'make' if (process.platform === 'aix') { platformMake = 'gmake' + } else if (process.platform === 'os400') { + platformMake = 'gmake' } else if (process.platform.indexOf('bsd') !== -1) { platformMake = 'gmake' } else if (win && argv.length > 0) { diff --git a/node_modules/node-gyp/lib/configure.js b/node_modules/node-gyp/lib/configure.js index c7010385b5e0d..1ca3ade70935e 100644 --- a/node_modules/node-gyp/lib/configure.js +++ b/node_modules/node-gyp/lib/configure.js @@ -176,12 +176,12 @@ function configure (gyp, argv, callback) { // For AIX and z/OS we need to set up the path to the exports file // which contains the symbols needed for linking. var nodeExpFile - if (process.platform === 'aix' || process.platform === 'os390') { - var ext = process.platform === 'aix' ? 'exp' : 'x' + if (process.platform === 'aix' || process.platform === 'os390' || process.platform === 'os400') { + var ext = process.platform === 'os390' ? 'x' : 'exp' var nodeRootDir = findNodeDirectory() var candidates - if (process.platform === 'aix') { + if (process.platform === 'aix' || process.platform === 'os400') { candidates = [ 'include/node/node', 'out/Release/node', @@ -213,6 +213,44 @@ function configure (gyp, argv, callback) { } } + // For z/OS we need to set up the path to zoslib include directory, + // which contains headers included in v8config.h. + var zoslibIncDir + if (process.platform === 'os390') { + logprefix = "find zoslib's zos-base.h:" + let msg + var zoslibIncPath = process.env.ZOSLIB_INCLUDES + if (zoslibIncPath) { + zoslibIncPath = findAccessibleSync(logprefix, zoslibIncPath, ['zos-base.h']) + if (zoslibIncPath === undefined) { + msg = msgFormat('Could not find zos-base.h file in the directory set ' + + 'in ZOSLIB_INCLUDES environment variable: %s; set it ' + + 'to the correct path, or unset it to search %s', process.env.ZOSLIB_INCLUDES, nodeRootDir) + } + } else { + candidates = [ + 'include/node/zoslib/zos-base.h', + 'include/zoslib/zos-base.h', + 'zoslib/include/zos-base.h', + 'install/include/node/zoslib/zos-base.h' + ] + zoslibIncPath = findAccessibleSync(logprefix, nodeRootDir, candidates) + if (zoslibIncPath === undefined) { + msg = msgFormat('Could not find any of %s in directory %s; set ' + + 'environmant variable ZOSLIB_INCLUDES to the path ' + + 'that contains zos-base.h', candidates.toString(), nodeRootDir) + } + } + if (zoslibIncPath !== undefined) { + zoslibIncDir = path.dirname(zoslibIncPath) + log.verbose(logprefix, "Found zoslib's zos-base.h in: %s", zoslibIncDir) + } else if (release.version.split('.')[0] >= 16) { + // zoslib is only shipped in Node v16 and above. + log.error(logprefix, msg) + return callback(new Error(msg)) + } + } + // this logic ported from the old `gyp_addon` python file var gypScript = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py') var addonGypi = path.resolve(__dirname, '..', 'addon.gypi') @@ -238,8 +276,11 @@ function configure (gyp, argv, callback) { argv.push('-Dlibrary=shared_library') argv.push('-Dvisibility=default') argv.push('-Dnode_root_dir=' + nodeDir) - if (process.platform === 'aix' || process.platform === 'os390') { + if (process.platform === 'aix' || process.platform === 'os390' || process.platform === 'os400') { argv.push('-Dnode_exp_file=' + nodeExpFile) + if (process.platform === 'os390' && zoslibIncDir) { + argv.push('-Dzoslib_include_dir=' + zoslibIncDir) + } } argv.push('-Dnode_gyp_dir=' + nodeGypDir) diff --git a/node_modules/node-gyp/lib/find-visualstudio.js b/node_modules/node-gyp/lib/find-visualstudio.js index 8a5cfc1ea9b93..d3815112e65de 100644 --- a/node_modules/node-gyp/lib/find-visualstudio.js +++ b/node_modules/node-gyp/lib/find-visualstudio.js @@ -347,6 +347,11 @@ VisualStudioFinder.prototype = { // Find an installation of Visual Studio 2015 to use findVisualStudio2015: function findVisualStudio2015 (cb) { + if (this.nodeSemver.major >= 19) { + this.addLog( + 'not looking for VS2015 as it is only supported up to Node.js 18') + return cb(null) + } return this.findOldVS({ version: '14.0', versionMajor: 14, diff --git a/node_modules/node-gyp/node_modules/nopt/LICENSE b/node_modules/node-gyp/node_modules/nopt/LICENSE deleted file mode 100644 index 19129e315fe59..0000000000000 --- a/node_modules/node-gyp/node_modules/nopt/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -The ISC License - -Copyright (c) Isaac Z. Schlueter and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR -IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/node-gyp/node_modules/nopt/bin/nopt.js b/node_modules/node-gyp/node_modules/nopt/bin/nopt.js deleted file mode 100755 index 3232d4c570fdc..0000000000000 --- a/node_modules/node-gyp/node_modules/nopt/bin/nopt.js +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env node -var nopt = require("../lib/nopt") - , path = require("path") - , types = { num: Number - , bool: Boolean - , help: Boolean - , list: Array - , "num-list": [Number, Array] - , "str-list": [String, Array] - , "bool-list": [Boolean, Array] - , str: String - , clear: Boolean - , config: Boolean - , length: Number - , file: path - } - , shorthands = { s: [ "--str", "astring" ] - , b: [ "--bool" ] - , nb: [ "--no-bool" ] - , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ] - , "?": ["--help"] - , h: ["--help"] - , H: ["--help"] - , n: [ "--num", "125" ] - , c: ["--config"] - , l: ["--length"] - , f: ["--file"] - } - , parsed = nopt( types - , shorthands - , process.argv - , 2 ) - -console.log("parsed", parsed) - -if (parsed.help) { - console.log("") - console.log("nopt cli tester") - console.log("") - console.log("types") - console.log(Object.keys(types).map(function M (t) { - var type = types[t] - if (Array.isArray(type)) { - return [t, type.map(function (type) { return type.name })] - } - return [t, type && type.name] - }).reduce(function (s, i) { - s[i[0]] = i[1] - return s - }, {})) - console.log("") - console.log("shorthands") - console.log(shorthands) -} diff --git a/node_modules/node-gyp/node_modules/nopt/lib/nopt.js b/node_modules/node-gyp/node_modules/nopt/lib/nopt.js deleted file mode 100644 index ecfa5da933683..0000000000000 --- a/node_modules/node-gyp/node_modules/nopt/lib/nopt.js +++ /dev/null @@ -1,441 +0,0 @@ -// info about each config option. - -var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG - ? function () { console.error.apply(console, arguments) } - : function () {} - -var url = require("url") - , path = require("path") - , Stream = require("stream").Stream - , abbrev = require("abbrev") - , os = require("os") - -module.exports = exports = nopt -exports.clean = clean - -exports.typeDefs = - { String : { type: String, validate: validateString } - , Boolean : { type: Boolean, validate: validateBoolean } - , url : { type: url, validate: validateUrl } - , Number : { type: Number, validate: validateNumber } - , path : { type: path, validate: validatePath } - , Stream : { type: Stream, validate: validateStream } - , Date : { type: Date, validate: validateDate } - } - -function nopt (types, shorthands, args, slice) { - args = args || process.argv - types = types || {} - shorthands = shorthands || {} - if (typeof slice !== "number") slice = 2 - - debug(types, shorthands, args, slice) - - args = args.slice(slice) - var data = {} - , key - , argv = { - remain: [], - cooked: args, - original: args.slice(0) - } - - parse(args, data, argv.remain, types, shorthands) - // now data is full - clean(data, types, exports.typeDefs) - data.argv = argv - Object.defineProperty(data.argv, 'toString', { value: function () { - return this.original.map(JSON.stringify).join(" ") - }, enumerable: false }) - return data -} - -function clean (data, types, typeDefs) { - typeDefs = typeDefs || exports.typeDefs - var remove = {} - , typeDefault = [false, true, null, String, Array] - - Object.keys(data).forEach(function (k) { - if (k === "argv") return - var val = data[k] - , isArray = Array.isArray(val) - , type = types[k] - if (!isArray) val = [val] - if (!type) type = typeDefault - if (type === Array) type = typeDefault.concat(Array) - if (!Array.isArray(type)) type = [type] - - debug("val=%j", val) - debug("types=", type) - val = val.map(function (val) { - // if it's an unknown value, then parse false/true/null/numbers/dates - if (typeof val === "string") { - debug("string %j", val) - val = val.trim() - if ((val === "null" && ~type.indexOf(null)) - || (val === "true" && - (~type.indexOf(true) || ~type.indexOf(Boolean))) - || (val === "false" && - (~type.indexOf(false) || ~type.indexOf(Boolean)))) { - val = JSON.parse(val) - debug("jsonable %j", val) - } else if (~type.indexOf(Number) && !isNaN(val)) { - debug("convert to number", val) - val = +val - } else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) { - debug("convert to date", val) - val = new Date(val) - } - } - - if (!types.hasOwnProperty(k)) { - return val - } - - // allow `--no-blah` to set 'blah' to null if null is allowed - if (val === false && ~type.indexOf(null) && - !(~type.indexOf(false) || ~type.indexOf(Boolean))) { - val = null - } - - var d = {} - d[k] = val - debug("prevalidated val", d, val, types[k]) - if (!validate(d, k, val, types[k], typeDefs)) { - if (exports.invalidHandler) { - exports.invalidHandler(k, val, types[k], data) - } else if (exports.invalidHandler !== false) { - debug("invalid: "+k+"="+val, types[k]) - } - return remove - } - debug("validated val", d, val, types[k]) - return d[k] - }).filter(function (val) { return val !== remove }) - - // if we allow Array specifically, then an empty array is how we - // express 'no value here', not null. Allow it. - if (!val.length && type.indexOf(Array) === -1) { - debug('VAL HAS NO LENGTH, DELETE IT', val, k, type.indexOf(Array)) - delete data[k] - } - else if (isArray) { - debug(isArray, data[k], val) - data[k] = val - } else data[k] = val[0] - - debug("k=%s val=%j", k, val, data[k]) - }) -} - -function validateString (data, k, val) { - data[k] = String(val) -} - -function validatePath (data, k, val) { - if (val === true) return false - if (val === null) return true - - val = String(val) - - var isWin = process.platform === 'win32' - , homePattern = isWin ? /^~(\/|\\)/ : /^~\// - , home = os.homedir() - - if (home && val.match(homePattern)) { - data[k] = path.resolve(home, val.substr(2)) - } else { - data[k] = path.resolve(val) - } - return true -} - -function validateNumber (data, k, val) { - debug("validate Number %j %j %j", k, val, isNaN(val)) - if (isNaN(val)) return false - data[k] = +val -} - -function validateDate (data, k, val) { - var s = Date.parse(val) - debug("validate Date %j %j %j", k, val, s) - if (isNaN(s)) return false - data[k] = new Date(val) -} - -function validateBoolean (data, k, val) { - if (val instanceof Boolean) val = val.valueOf() - else if (typeof val === "string") { - if (!isNaN(val)) val = !!(+val) - else if (val === "null" || val === "false") val = false - else val = true - } else val = !!val - data[k] = val -} - -function validateUrl (data, k, val) { - val = url.parse(String(val)) - if (!val.host) return false - data[k] = val.href -} - -function validateStream (data, k, val) { - if (!(val instanceof Stream)) return false - data[k] = val -} - -function validate (data, k, val, type, typeDefs) { - // arrays are lists of types. - if (Array.isArray(type)) { - for (var i = 0, l = type.length; i < l; i ++) { - if (type[i] === Array) continue - if (validate(data, k, val, type[i], typeDefs)) return true - } - delete data[k] - return false - } - - // an array of anything? - if (type === Array) return true - - // NaN is poisonous. Means that something is not allowed. - if (type !== type) { - debug("Poison NaN", k, val, type) - delete data[k] - return false - } - - // explicit list of values - if (val === type) { - debug("Explicitly allowed %j", val) - // if (isArray) (data[k] = data[k] || []).push(val) - // else data[k] = val - data[k] = val - return true - } - - // now go through the list of typeDefs, validate against each one. - var ok = false - , types = Object.keys(typeDefs) - for (var i = 0, l = types.length; i < l; i ++) { - debug("test type %j %j %j", k, val, types[i]) - var t = typeDefs[types[i]] - if (t && - ((type && type.name && t.type && t.type.name) ? (type.name === t.type.name) : (type === t.type))) { - var d = {} - ok = false !== t.validate(d, k, val) - val = d[k] - if (ok) { - // if (isArray) (data[k] = data[k] || []).push(val) - // else data[k] = val - data[k] = val - break - } - } - } - debug("OK? %j (%j %j %j)", ok, k, val, types[i]) - - if (!ok) delete data[k] - return ok -} - -function parse (args, data, remain, types, shorthands) { - debug("parse", args, data, remain) - - var key = null - , abbrevs = abbrev(Object.keys(types)) - , shortAbbr = abbrev(Object.keys(shorthands)) - - for (var i = 0; i < args.length; i ++) { - var arg = args[i] - debug("arg", arg) - - if (arg.match(/^-{2,}$/)) { - // done with keys. - // the rest are args. - remain.push.apply(remain, args.slice(i + 1)) - args[i] = "--" - break - } - var hadEq = false - if (arg.charAt(0) === "-" && arg.length > 1) { - var at = arg.indexOf('=') - if (at > -1) { - hadEq = true - var v = arg.substr(at + 1) - arg = arg.substr(0, at) - args.splice(i, 1, arg, v) - } - - // see if it's a shorthand - // if so, splice and back up to re-parse it. - var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs) - debug("arg=%j shRes=%j", arg, shRes) - if (shRes) { - debug(arg, shRes) - args.splice.apply(args, [i, 1].concat(shRes)) - if (arg !== shRes[0]) { - i -- - continue - } - } - arg = arg.replace(/^-+/, "") - var no = null - while (arg.toLowerCase().indexOf("no-") === 0) { - no = !no - arg = arg.substr(3) - } - - if (abbrevs[arg]) arg = abbrevs[arg] - - var argType = types[arg] - var isTypeArray = Array.isArray(argType) - if (isTypeArray && argType.length === 1) { - isTypeArray = false - argType = argType[0] - } - - var isArray = argType === Array || - isTypeArray && argType.indexOf(Array) !== -1 - - // allow unknown things to be arrays if specified multiple times. - if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) { - if (!Array.isArray(data[arg])) - data[arg] = [data[arg]] - isArray = true - } - - var val - , la = args[i + 1] - - var isBool = typeof no === 'boolean' || - argType === Boolean || - isTypeArray && argType.indexOf(Boolean) !== -1 || - (typeof argType === 'undefined' && !hadEq) || - (la === "false" && - (argType === null || - isTypeArray && ~argType.indexOf(null))) - - if (isBool) { - // just set and move along - val = !no - // however, also support --bool true or --bool false - if (la === "true" || la === "false") { - val = JSON.parse(la) - la = null - if (no) val = !val - i ++ - } - - // also support "foo":[Boolean, "bar"] and "--foo bar" - if (isTypeArray && la) { - if (~argType.indexOf(la)) { - // an explicit type - val = la - i ++ - } else if ( la === "null" && ~argType.indexOf(null) ) { - // null allowed - val = null - i ++ - } else if ( !la.match(/^-{2,}[^-]/) && - !isNaN(la) && - ~argType.indexOf(Number) ) { - // number - val = +la - i ++ - } else if ( !la.match(/^-[^-]/) && ~argType.indexOf(String) ) { - // string - val = la - i ++ - } - } - - if (isArray) (data[arg] = data[arg] || []).push(val) - else data[arg] = val - - continue - } - - if (argType === String) { - if (la === undefined) { - la = "" - } else if (la.match(/^-{1,2}[^-]+/)) { - la = "" - i -- - } - } - - if (la && la.match(/^-{2,}$/)) { - la = undefined - i -- - } - - val = la === undefined ? true : la - if (isArray) (data[arg] = data[arg] || []).push(val) - else data[arg] = val - - i ++ - continue - } - remain.push(arg) - } -} - -function resolveShort (arg, shorthands, shortAbbr, abbrevs) { - // handle single-char shorthands glommed together, like - // npm ls -glp, but only if there is one dash, and only if - // all of the chars are single-char shorthands, and it's - // not a match to some other abbrev. - arg = arg.replace(/^-+/, '') - - // if it's an exact known option, then don't go any further - if (abbrevs[arg] === arg) - return null - - // if it's an exact known shortopt, same deal - if (shorthands[arg]) { - // make it an array, if it's a list of words - if (shorthands[arg] && !Array.isArray(shorthands[arg])) - shorthands[arg] = shorthands[arg].split(/\s+/) - - return shorthands[arg] - } - - // first check to see if this arg is a set of single-char shorthands - var singles = shorthands.___singles - if (!singles) { - singles = Object.keys(shorthands).filter(function (s) { - return s.length === 1 - }).reduce(function (l,r) { - l[r] = true - return l - }, {}) - shorthands.___singles = singles - debug('shorthand singles', singles) - } - - var chrs = arg.split("").filter(function (c) { - return singles[c] - }) - - if (chrs.join("") === arg) return chrs.map(function (c) { - return shorthands[c] - }).reduce(function (l, r) { - return l.concat(r) - }, []) - - - // if it's an arg abbrev, and not a literal shorthand, then prefer the arg - if (abbrevs[arg] && !shorthands[arg]) - return null - - // if it's an abbr for a shorthand, then use that - if (shortAbbr[arg]) - arg = shortAbbr[arg] - - // make it an array, if it's a list of words - if (shorthands[arg] && !Array.isArray(shorthands[arg])) - shorthands[arg] = shorthands[arg].split(/\s+/) - - return shorthands[arg] -} diff --git a/node_modules/node-gyp/node_modules/nopt/package.json b/node_modules/node-gyp/node_modules/nopt/package.json deleted file mode 100644 index 12ed02da5a832..0000000000000 --- a/node_modules/node-gyp/node_modules/nopt/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "nopt", - "version": "5.0.0", - "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", - "main": "lib/nopt.js", - "scripts": { - "preversion": "npm test", - "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags", - "test": "tap test/*.js" - }, - "repository": { - "type": "git", - "url": "https://github.com/npm/nopt.git" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "license": "ISC", - "dependencies": { - "abbrev": "1" - }, - "devDependencies": { - "tap": "^14.10.6" - }, - "files": [ - "bin", - "lib" - ], - "engines": { - "node": ">=6" - } -} diff --git a/node_modules/node-gyp/package.json b/node_modules/node-gyp/package.json index ecf4d8ae893d8..932e8cb3b3555 100644 --- a/node_modules/node-gyp/package.json +++ b/node_modules/node-gyp/package.json @@ -11,7 +11,7 @@ "bindings", "gyp" ], - "version": "9.1.0", + "version": "9.3.0", "installVersion": 9, "author": "Nathan Rajlich (http://tootallnate.net)", "repository": { @@ -26,7 +26,7 @@ "glob": "^7.1.4", "graceful-fs": "^4.2.6", "make-fetch-happen": "^10.0.3", - "nopt": "^5.0.0", + "nopt": "^6.0.0", "npmlog": "^6.0.0", "rimraf": "^3.0.2", "semver": "^7.3.5", diff --git a/node_modules/node-gyp/test/test-find-node-directory.js b/node_modules/node-gyp/test/test-find-node-directory.js index f1380d162ae7c..fa6223c65d03c 100644 --- a/node_modules/node-gyp/test/test-find-node-directory.js +++ b/node_modules/node-gyp/test/test-find-node-directory.js @@ -4,7 +4,7 @@ const test = require('tap').test const path = require('path') const findNodeDirectory = require('../lib/find-node-directory') -const platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix'] +const platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix', 'os400'] // we should find the directory based on the directory // the script is running in and it should match the layout diff --git a/node_modules/node-gyp/update-gyp.py b/node_modules/node-gyp/update-gyp.py index bb84f071a61d3..19524bd6a7ad1 100755 --- a/node_modules/node-gyp/update-gyp.py +++ b/node_modules/node-gyp/update-gyp.py @@ -33,7 +33,25 @@ print("Unzipping...") with tarfile.open(tar_file, "r:gz") as tar_ref: - tar_ref.extractall(unzip_target) + def is_within_directory(directory, target): + + abs_directory = os.path.abspath(directory) + abs_target = os.path.abspath(target) + + prefix = os.path.commonprefix([abs_directory, abs_target]) + + return prefix == abs_directory + + def safe_extract(tar, path=".", members=None, *, numeric_owner=False): + + for member in tar.getmembers(): + member_path = os.path.join(path, member.name) + if not is_within_directory(path, member_path): + raise Exception("Attempted Path Traversal in Tar File") + + tar.extractall(path, members, numeric_owner) + + safe_extract(tar_ref, unzip_target) print("Moving to current checkout (" + CHECKOUT_PATH + ")...") if os.path.exists(CHECKOUT_GYP_PATH): diff --git a/package-lock.json b/package-lock.json index 5a7377cfc83dc..1ee8562af34f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -125,7 +125,7 @@ "minipass-pipeline": "^1.2.4", "mkdirp": "^1.0.4", "ms": "^2.1.2", - "node-gyp": "^9.1.0", + "node-gyp": "^9.3.0", "nopt": "^6.0.0", "npm-audit-report": "^4.0.0", "npm-install-checks": "^6.0.0", @@ -8208,15 +8208,16 @@ } }, "node_modules/node-gyp": { - "version": "9.1.0", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-9.3.0.tgz", + "integrity": "sha512-A6rJWfXFz7TQNjpldJ915WFb1LnhO4lIve3ANPbWreuEoLoKlFT3sxIepPBkLhM27crW8YmN+pjlgbasH6cH/Q==", "inBundle": true, - "license": "MIT", "dependencies": { "env-paths": "^2.2.0", "glob": "^7.1.4", "graceful-fs": "^4.2.6", "make-fetch-happen": "^10.0.3", - "nopt": "^5.0.0", + "nopt": "^6.0.0", "npmlog": "^6.0.0", "rimraf": "^3.0.2", "semver": "^7.3.5", @@ -8440,20 +8441,6 @@ "encoding": "^0.1.13" } }, - "node_modules/node-gyp/node_modules/nopt": { - "version": "5.0.0", - "inBundle": true, - "license": "ISC", - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/node-gyp/node_modules/npmlog": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", diff --git a/package.json b/package.json index 30a5e248199e3..509aba5044d9c 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "minipass-pipeline": "^1.2.4", "mkdirp": "^1.0.4", "ms": "^2.1.2", - "node-gyp": "^9.1.0", + "node-gyp": "^9.3.0", "nopt": "^6.0.0", "npm-audit-report": "^4.0.0", "npm-install-checks": "^6.0.0", From 81877c1c3ace7cbab02abd11f208979492398a9f Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 1 Nov 2022 13:59:35 -0700 Subject: [PATCH 2/7] deps: tar@6.1.12 --- node_modules/tar/lib/create.js | 25 ++-- node_modules/tar/lib/extract.js | 26 +++-- node_modules/tar/lib/header.js | 84 ++++++++------ node_modules/tar/lib/large-numbers.js | 39 ++++--- node_modules/tar/lib/list.js | 33 +++--- node_modules/tar/lib/mkdir.js | 64 +++++++---- node_modules/tar/lib/mode-fix.js | 12 +- node_modules/tar/lib/normalize-unicode.js | 5 +- node_modules/tar/lib/pack.js | 85 +++++++++----- node_modules/tar/lib/parse.js | 120 ++++++++++++-------- node_modules/tar/lib/path-reservations.js | 44 ++++--- node_modules/tar/lib/pax.js | 23 ++-- node_modules/tar/lib/read-entry.js | 21 ++-- node_modules/tar/lib/replace.js | 77 ++++++++----- node_modules/tar/lib/strip-absolute-path.js | 2 +- node_modules/tar/lib/unpack.js | 117 ++++++++++++------- node_modules/tar/lib/update.js | 12 +- node_modules/tar/lib/warn-mixin.js | 11 +- node_modules/tar/lib/write-entry.js | 67 +++++++---- node_modules/tar/package.json | 68 ++++++----- package-lock.json | 9 +- package.json | 2 +- 22 files changed, 589 insertions(+), 357 deletions(-) diff --git a/node_modules/tar/lib/create.js b/node_modules/tar/lib/create.js index d033640ac3b6c..9c860d4e4a764 100644 --- a/node_modules/tar/lib/create.js +++ b/node_modules/tar/lib/create.js @@ -9,24 +9,29 @@ const t = require('./list.js') const path = require('path') module.exports = (opt_, files, cb) => { - if (typeof files === 'function') + if (typeof files === 'function') { cb = files + } - if (Array.isArray(opt_)) + if (Array.isArray(opt_)) { files = opt_, opt_ = {} + } - if (!files || !Array.isArray(files) || !files.length) + if (!files || !Array.isArray(files) || !files.length) { throw new TypeError('no files or directories specified') + } files = Array.from(files) const opt = hlo(opt_) - if (opt.sync && typeof cb === 'function') + if (opt.sync && typeof cb === 'function') { throw new TypeError('callback not supported for sync tar functions') + } - if (!opt.file && typeof cb === 'function') + if (!opt.file && typeof cb === 'function') { throw new TypeError('callback only supported with file option') + } return opt.file && opt.sync ? createFileSync(opt, files) : opt.file ? createFile(opt, files, cb) @@ -65,13 +70,14 @@ const addFilesSync = (p, files) => { files.forEach(file => { if (file.charAt(0) === '@') { t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), sync: true, noResume: true, onentry: entry => p.add(entry), }) - } else + } else { p.add(file) + } }) p.end() } @@ -81,12 +87,13 @@ const addFilesAsync = (p, files) => { const file = files.shift() if (file.charAt(0) === '@') { return t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), noResume: true, onentry: entry => p.add(entry), }).then(_ => addFilesAsync(p, files)) - } else + } else { p.add(file) + } } p.end() } diff --git a/node_modules/tar/lib/extract.js b/node_modules/tar/lib/extract.js index 98e946ec5bfbb..54767982583f2 100644 --- a/node_modules/tar/lib/extract.js +++ b/node_modules/tar/lib/extract.js @@ -9,29 +9,35 @@ const path = require('path') const stripSlash = require('./strip-trailing-slashes.js') module.exports = (opt_, files, cb) => { - if (typeof opt_ === 'function') + if (typeof opt_ === 'function') { cb = opt_, files = null, opt_ = {} - else if (Array.isArray(opt_)) + } else if (Array.isArray(opt_)) { files = opt_, opt_ = {} + } - if (typeof files === 'function') + if (typeof files === 'function') { cb = files, files = null + } - if (!files) + if (!files) { files = [] - else + } else { files = Array.from(files) + } const opt = hlo(opt_) - if (opt.sync && typeof cb === 'function') + if (opt.sync && typeof cb === 'function') { throw new TypeError('callback not supported for sync tar functions') + } - if (!opt.file && typeof cb === 'function') + if (!opt.file && typeof cb === 'function') { throw new TypeError('callback only supported with file option') + } - if (files.length) + if (files.length) { filesFilter(opt, files) + } return opt.file && opt.sync ? extractFileSync(opt) : opt.file ? extractFile(opt, cb) @@ -87,9 +93,9 @@ const extractFile = (opt, cb) => { // This trades a zero-byte read() syscall for a stat // However, it will usually result in less memory allocation fs.stat(file, (er, stat) => { - if (er) + if (er) { reject(er) - else { + } else { const stream = new fsm.ReadStream(file, { readSize: readSize, size: stat.size, diff --git a/node_modules/tar/lib/header.js b/node_modules/tar/lib/header.js index 129504048dfab..411d5e45e879a 100644 --- a/node_modules/tar/lib/header.js +++ b/node_modules/tar/lib/header.js @@ -34,18 +34,21 @@ class Header { this.atime = null this.ctime = null - if (Buffer.isBuffer(data)) + if (Buffer.isBuffer(data)) { this.decode(data, off || 0, ex, gex) - else if (data) + } else if (data) { this.set(data) + } } decode (buf, off, ex, gex) { - if (!off) + if (!off) { off = 0 + } - if (!buf || !(buf.length >= off + 512)) + if (!buf || !(buf.length >= off + 512)) { throw new Error('need 512 bytes for header') + } this.path = decString(buf, off, 100) this.mode = decNumber(buf, off + 100, 8) @@ -62,18 +65,21 @@ class Header { // old tar versions marked dirs as a file with a trailing / this[TYPE] = decString(buf, off + 156, 1) - if (this[TYPE] === '') + if (this[TYPE] === '') { this[TYPE] = '0' - if (this[TYPE] === '0' && this.path.substr(-1) === '/') + } + if (this[TYPE] === '0' && this.path.slice(-1) === '/') { this[TYPE] = '5' + } // tar implementations sometimes incorrectly put the stat(dir).size // as the size in the tarball, even though Directory entries are // not able to have any body at all. In the very rare chance that // it actually DOES have a body, we weren't going to do anything with // it anyway, and it'll just be a warning about an invalid header. - if (this[TYPE] === '5') + if (this[TYPE] === '5') { this.size = 0 + } this.linkpath = decString(buf, off + 157, 100) if (buf.slice(off + 257, off + 265).toString() === 'ustar\u000000') { @@ -87,23 +93,27 @@ class Header { this.path = prefix + '/' + this.path } else { const prefix = decString(buf, off + 345, 130) - if (prefix) + if (prefix) { this.path = prefix + '/' + this.path + } this.atime = decDate(buf, off + 476, 12) this.ctime = decDate(buf, off + 488, 12) } } let sum = 8 * 0x20 - for (let i = off; i < off + 148; i++) + for (let i = off; i < off + 148; i++) { sum += buf[i] + } - for (let i = off + 156; i < off + 512; i++) + for (let i = off + 156; i < off + 512; i++) { sum += buf[i] + } this.cksumValid = sum === this.cksum - if (this.cksum === null && sum === 8 * 0x20) + if (this.cksum === null && sum === 8 * 0x20) { this.nullBlock = true + } } [SLURP] (ex, global) { @@ -111,8 +121,9 @@ class Header { // we slurp in everything except for the path attribute in // a global extended header, because that's weird. if (ex[k] !== null && ex[k] !== undefined && - !(global && k === 'path')) + !(global && k === 'path')) { this[k] = ex[k] + } } } @@ -122,11 +133,13 @@ class Header { off = 0 } - if (!off) + if (!off) { off = 0 + } - if (!(buf.length >= off + 512)) + if (!(buf.length >= off + 512)) { throw new Error('need 512 bytes for header') + } const prefixSize = this.ctime || this.atime ? 130 : 155 const split = splitPrefix(this.path || '', prefixSize) @@ -148,20 +161,22 @@ class Header { this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax - if (buf[off + 475] !== 0) + if (buf[off + 475] !== 0) { this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax - else { + } else { this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax } let sum = 8 * 0x20 - for (let i = off; i < off + 148; i++) + for (let i = off; i < off + 148; i++) { sum += buf[i] + } - for (let i = off + 156; i < off + 512; i++) + for (let i = off + 156; i < off + 512; i++) { sum += buf[i] + } this.cksum = sum encNumber(buf, off + 148, 8, this.cksum) @@ -172,8 +187,9 @@ class Header { set (data) { for (const i in data) { - if (data[i] !== null && data[i] !== undefined) + if (data[i] !== null && data[i] !== undefined) { this[i] = data[i] + } } } @@ -186,10 +202,11 @@ class Header { } set type (type) { - if (types.code.has(type)) + if (types.code.has(type)) { this[TYPE] = types.code.get(type) - else + } else { this[TYPE] = type + } } } @@ -200,25 +217,23 @@ const splitPrefix = (p, prefixSize) => { let ret const root = pathModule.parse(p).root || '.' - if (Buffer.byteLength(pp) < pathSize) + if (Buffer.byteLength(pp) < pathSize) { ret = [pp, prefix, false] - else { + } else { // first set prefix to the dir, and path to the base prefix = pathModule.dirname(pp) pp = pathModule.basename(pp) do { - // both fit! if (Buffer.byteLength(pp) <= pathSize && - Buffer.byteLength(prefix) <= prefixSize) + Buffer.byteLength(prefix) <= prefixSize) { + // both fit! ret = [pp, prefix, false] - - // prefix fits in prefix, but path doesn't fit in path - else if (Buffer.byteLength(pp) > pathSize && - Buffer.byteLength(prefix) <= prefixSize) - ret = [pp.substr(0, pathSize - 1), prefix, true] - - else { + } else if (Buffer.byteLength(pp) > pathSize && + Buffer.byteLength(prefix) <= prefixSize) { + // prefix fits in prefix, but path doesn't fit in path + ret = [pp.slice(0, pathSize - 1), prefix, true] + } else { // make path take a bit from prefix pp = pathModule.join(pathModule.basename(prefix), pp) prefix = pathModule.dirname(prefix) @@ -226,8 +241,9 @@ const splitPrefix = (p, prefixSize) => { } while (prefix !== root && !ret) // at this point, found no resolution, just truncate - if (!ret) - ret = [p.substr(0, pathSize - 1), '', true] + if (!ret) { + ret = [p.slice(0, pathSize - 1), '', true] + } } return ret } diff --git a/node_modules/tar/lib/large-numbers.js b/node_modules/tar/lib/large-numbers.js index dd6f690b9a8d9..b11e72d996fde 100644 --- a/node_modules/tar/lib/large-numbers.js +++ b/node_modules/tar/lib/large-numbers.js @@ -3,14 +3,15 @@ // 0xff for negative, and 0x80 for positive. const encode = (num, buf) => { - if (!Number.isSafeInteger(num)) - // The number is so large that javascript cannot represent it with integer - // precision. + if (!Number.isSafeInteger(num)) { + // The number is so large that javascript cannot represent it with integer + // precision. throw Error('cannot encode number outside of javascript safe integer range') - else if (num < 0) + } else if (num < 0) { encodeNegative(num, buf) - else + } else { encodePositive(num, buf) + } return buf } @@ -30,11 +31,11 @@ const encodeNegative = (num, buf) => { for (var i = buf.length; i > 1; i--) { var byte = num & 0xff num = Math.floor(num / 0x100) - if (flipped) + if (flipped) { buf[i - 1] = onesComp(byte) - else if (byte === 0) + } else if (byte === 0) { buf[i - 1] = 0 - else { + } else { flipped = true buf[i - 1] = twosComp(byte) } @@ -46,13 +47,15 @@ const parse = (buf) => { const value = pre === 0x80 ? pos(buf.slice(1, buf.length)) : pre === 0xff ? twos(buf) : null - if (value === null) + if (value === null) { throw Error('invalid base256 encoding') + } - if (!Number.isSafeInteger(value)) - // The number is so large that javascript cannot represent it with integer - // precision. + if (!Number.isSafeInteger(value)) { + // The number is so large that javascript cannot represent it with integer + // precision. throw Error('parsed number outside of javascript safe integer range') + } return value } @@ -64,16 +67,17 @@ const twos = (buf) => { for (var i = len - 1; i > -1; i--) { var byte = buf[i] var f - if (flipped) + if (flipped) { f = onesComp(byte) - else if (byte === 0) + } else if (byte === 0) { f = byte - else { + } else { flipped = true f = twosComp(byte) } - if (f !== 0) + if (f !== 0) { sum -= f * Math.pow(256, len - i - 1) + } } return sum } @@ -83,8 +87,9 @@ const pos = (buf) => { var sum = 0 for (var i = len - 1; i > -1; i--) { var byte = buf[i] - if (byte !== 0) + if (byte !== 0) { sum += byte * Math.pow(256, len - i - 1) + } } return sum } diff --git a/node_modules/tar/lib/list.js b/node_modules/tar/lib/list.js index a0c1cf2fbc7ea..f2358c25410b5 100644 --- a/node_modules/tar/lib/list.js +++ b/node_modules/tar/lib/list.js @@ -12,32 +12,39 @@ const path = require('path') const stripSlash = require('./strip-trailing-slashes.js') module.exports = (opt_, files, cb) => { - if (typeof opt_ === 'function') + if (typeof opt_ === 'function') { cb = opt_, files = null, opt_ = {} - else if (Array.isArray(opt_)) + } else if (Array.isArray(opt_)) { files = opt_, opt_ = {} + } - if (typeof files === 'function') + if (typeof files === 'function') { cb = files, files = null + } - if (!files) + if (!files) { files = [] - else + } else { files = Array.from(files) + } const opt = hlo(opt_) - if (opt.sync && typeof cb === 'function') + if (opt.sync && typeof cb === 'function') { throw new TypeError('callback not supported for sync tar functions') + } - if (!opt.file && typeof cb === 'function') + if (!opt.file && typeof cb === 'function') { throw new TypeError('callback only supported with file option') + } - if (files.length) + if (files.length) { filesFilter(opt, files) + } - if (!opt.noResume) + if (!opt.noResume) { onentryFunction(opt) + } return opt.file && opt.sync ? listFileSync(opt) : opt.file ? listFile(opt, cb) @@ -81,9 +88,9 @@ const listFileSync = opt => { try { const stat = fs.statSync(file) const readSize = opt.maxReadSize || 16 * 1024 * 1024 - if (stat.size < readSize) + if (stat.size < readSize) { p.end(fs.readFileSync(file)) - else { + } else { let pos = 0 const buf = Buffer.allocUnsafe(readSize) fd = fs.openSync(file, 'r') @@ -114,9 +121,9 @@ const listFile = (opt, cb) => { parse.on('end', resolve) fs.stat(file, (er, stat) => { - if (er) + if (er) { reject(er) - else { + } else { const stream = new fsm.ReadStream(file, { readSize: readSize, size: stat.size, diff --git a/node_modules/tar/lib/mkdir.js b/node_modules/tar/lib/mkdir.js index a0719e6c36ed3..8ee8de7852d12 100644 --- a/node_modules/tar/lib/mkdir.js +++ b/node_modules/tar/lib/mkdir.js @@ -39,8 +39,9 @@ const cSet = (cache, key, val) => cache.set(normPath(key), val) const checkCwd = (dir, cb) => { fs.stat(dir, (er, st) => { - if (er || !st.isDirectory()) + if (er || !st.isDirectory()) { er = new CwdError(dir, er && er.code || 'ENOTDIR') + } cb(er) }) } @@ -66,27 +67,31 @@ module.exports = (dir, opt, cb) => { const cwd = normPath(opt.cwd) const done = (er, created) => { - if (er) + if (er) { cb(er) - else { + } else { cSet(cache, dir, true) - if (created && doChown) + if (created && doChown) { chownr(created, uid, gid, er => done(er)) - else if (needChmod) + } else if (needChmod) { fs.chmod(dir, mode, cb) - else + } else { cb() + } } } - if (cache && cGet(cache, dir) === true) + if (cache && cGet(cache, dir) === true) { return done() + } - if (dir === cwd) + if (dir === cwd) { return checkCwd(dir, done) + } - if (preserve) - return mkdirp(dir, {mode}).then(made => done(null, made), done) + if (preserve) { + return mkdirp(dir, { mode }).then(made => done(null, made), done) + } const sub = normPath(path.relative(cwd, dir)) const parts = sub.split('/') @@ -94,12 +99,14 @@ module.exports = (dir, opt, cb) => { } const mkdir_ = (base, parts, mode, cache, unlink, cwd, created, cb) => { - if (!parts.length) + if (!parts.length) { return cb(null, created) + } const p = parts.shift() const part = normPath(path.resolve(base + '/' + p)) - if (cGet(cache, part)) + if (cGet(cache, part)) { return mkdir_(part, parts, mode, cache, unlink, cwd, created, cb) + } fs.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink, cwd, created, cb)) } @@ -109,18 +116,20 @@ const onmkdir = (part, parts, mode, cache, unlink, cwd, created, cb) => er => { if (statEr) { statEr.path = statEr.path && normPath(statEr.path) cb(statEr) - } else if (st.isDirectory()) + } else if (st.isDirectory()) { mkdir_(part, parts, mode, cache, unlink, cwd, created, cb) - else if (unlink) { + } else if (unlink) { fs.unlink(part, er => { - if (er) + if (er) { return cb(er) + } fs.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink, cwd, created, cb)) }) - } else if (st.isSymbolicLink()) + } else if (st.isSymbolicLink()) { return cb(new SymlinkError(part, part + '/' + parts.join('/'))) - else + } else { cb(er) + } }) } else { created = created || part @@ -136,8 +145,9 @@ const checkCwdSync = dir => { } catch (er) { code = er.code } finally { - if (!ok) + if (!ok) { throw new CwdError(dir, code) + } } } @@ -162,22 +172,26 @@ module.exports.sync = (dir, opt) => { const done = (created) => { cSet(cache, dir, true) - if (created && doChown) + if (created && doChown) { chownr.sync(created, uid, gid) - if (needChmod) + } + if (needChmod) { fs.chmodSync(dir, mode) + } } - if (cache && cGet(cache, dir) === true) + if (cache && cGet(cache, dir) === true) { return done() + } if (dir === cwd) { checkCwdSync(cwd) return done() } - if (preserve) + if (preserve) { return done(mkdirp.sync(dir, mode)) + } const sub = normPath(path.relative(cwd, dir)) const parts = sub.split('/') @@ -186,8 +200,9 @@ module.exports.sync = (dir, opt) => { p && (part += '/' + p); p = parts.shift()) { part = normPath(path.resolve(part)) - if (cGet(cache, part)) + if (cGet(cache, part)) { continue + } try { fs.mkdirSync(part, mode) @@ -204,8 +219,9 @@ module.exports.sync = (dir, opt) => { created = created || part cSet(cache, part, true) continue - } else if (st.isSymbolicLink()) + } else if (st.isSymbolicLink()) { return new SymlinkError(part, part + '/' + parts.join('/')) + } } } diff --git a/node_modules/tar/lib/mode-fix.js b/node_modules/tar/lib/mode-fix.js index 6a045ffcaec5b..42f1d6e657b1a 100644 --- a/node_modules/tar/lib/mode-fix.js +++ b/node_modules/tar/lib/mode-fix.js @@ -7,17 +7,21 @@ module.exports = (mode, isDir, portable) => { // (as some linux distros do), then we'll write the // archive with 0o644 instead. Also, don't ever create // a file that is not readable/writable by the owner. - if (portable) + if (portable) { mode = (mode | 0o600) & ~0o22 + } // if dirs are readable, then they should be listable if (isDir) { - if (mode & 0o400) + if (mode & 0o400) { mode |= 0o100 - if (mode & 0o40) + } + if (mode & 0o40) { mode |= 0o10 - if (mode & 0o4) + } + if (mode & 0o4) { mode |= 0o1 + } } return mode } diff --git a/node_modules/tar/lib/normalize-unicode.js b/node_modules/tar/lib/normalize-unicode.js index 4aeb1d50db9e1..43dc406ecedb9 100644 --- a/node_modules/tar/lib/normalize-unicode.js +++ b/node_modules/tar/lib/normalize-unicode.js @@ -3,9 +3,10 @@ // within npm install on large package trees. // Do not edit without careful benchmarking. const normalizeCache = Object.create(null) -const {hasOwnProperty} = Object.prototype +const { hasOwnProperty } = Object.prototype module.exports = s => { - if (!hasOwnProperty.call(normalizeCache, s)) + if (!hasOwnProperty.call(normalizeCache, s)) { normalizeCache[s] = s.normalize('NFKD') + } return normalizeCache[s] } diff --git a/node_modules/tar/lib/pack.js b/node_modules/tar/lib/pack.js index 9522c10bfe4a4..a3f4ff220abbb 100644 --- a/node_modules/tar/lib/pack.js +++ b/node_modules/tar/lib/pack.js @@ -73,23 +73,27 @@ const Pack = warner(class Pack extends MiniPass { this.readdirCache = opt.readdirCache || new Map() this[WRITEENTRYCLASS] = WriteEntry - if (typeof opt.onwarn === 'function') + if (typeof opt.onwarn === 'function') { this.on('warn', opt.onwarn) + } this.portable = !!opt.portable this.zip = null if (opt.gzip) { - if (typeof opt.gzip !== 'object') + if (typeof opt.gzip !== 'object') { opt.gzip = {} - if (this.portable) + } + if (this.portable) { opt.gzip.portable = true + } this.zip = new zlib.Gzip(opt.gzip) this.zip.on('data', chunk => super.write(chunk)) this.zip.on('end', _ => super.end()) this.zip.on('drain', _ => this[ONDRAIN]()) this.on('resume', _ => this.zip.resume()) - } else + } else { this.on('drain', this[ONDRAIN]) + } this.noDirRecurse = !!opt.noDirRecurse this.follow = !!opt.follow @@ -115,30 +119,33 @@ const Pack = warner(class Pack extends MiniPass { } end (path) { - if (path) + if (path) { this.write(path) + } this[ENDED] = true this[PROCESS]() return this } write (path) { - if (this[ENDED]) + if (this[ENDED]) { throw new Error('write after end') + } - if (path instanceof ReadEntry) + if (path instanceof ReadEntry) { this[ADDTARENTRY](path) - else + } else { this[ADDFSENTRY](path) + } return this.flowing } [ADDTARENTRY] (p) { const absolute = normPath(path.resolve(this.cwd, p.path)) // in this case, we don't have to wait for the stat - if (!this.filter(p.path, p)) + if (!this.filter(p.path, p)) { p.resume() - else { + } else { const job = new PackJob(p.path, absolute, false) job.entry = new WriteEntryTar(p, this[ENTRYOPT](job)) job.entry.on('end', _ => this[JOBDONE](job)) @@ -162,10 +169,11 @@ const Pack = warner(class Pack extends MiniPass { fs[stat](job.absolute, (er, stat) => { job.pending = false this[JOBS] -= 1 - if (er) + if (er) { this.emit('error', er) - else + } else { this[ONSTAT](job, stat) + } }) } @@ -174,8 +182,9 @@ const Pack = warner(class Pack extends MiniPass { job.stat = stat // now we have the stat, we can filter it. - if (!this.filter(job.path, stat)) + if (!this.filter(job.path, stat)) { job.ignore = true + } this[PROCESS]() } @@ -186,8 +195,9 @@ const Pack = warner(class Pack extends MiniPass { fs.readdir(job.absolute, (er, entries) => { job.pending = false this[JOBS] -= 1 - if (er) + if (er) { return this.emit('error', er) + } this[ONREADDIR](job, entries) }) } @@ -199,8 +209,9 @@ const Pack = warner(class Pack extends MiniPass { } [PROCESS] () { - if (this[PROCESSING]) + if (this[PROCESSING]) { return + } this[PROCESSING] = true for (let w = this[QUEUE].head; @@ -217,9 +228,9 @@ const Pack = warner(class Pack extends MiniPass { this[PROCESSING] = false if (this[ENDED] && !this[QUEUE].length && this[JOBS] === 0) { - if (this.zip) + if (this.zip) { this.zip.end(EOF) - else { + } else { super.write(EOF) super.end() } @@ -237,35 +248,42 @@ const Pack = warner(class Pack extends MiniPass { } [PROCESSJOB] (job) { - if (job.pending) + if (job.pending) { return + } if (job.entry) { - if (job === this[CURRENT] && !job.piped) + if (job === this[CURRENT] && !job.piped) { this[PIPE](job) + } return } if (!job.stat) { - if (this.statCache.has(job.absolute)) + if (this.statCache.has(job.absolute)) { this[ONSTAT](job, this.statCache.get(job.absolute)) - else + } else { this[STAT](job) + } } - if (!job.stat) + if (!job.stat) { return + } // filtered out! - if (job.ignore) + if (job.ignore) { return + } if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) { - if (this.readdirCache.has(job.absolute)) + if (this.readdirCache.has(job.absolute)) { this[ONREADDIR](job, this.readdirCache.get(job.absolute)) - else + } else { this[READDIR](job) - if (!job.readdir) + } + if (!job.readdir) { return + } } // we know it doesn't have an entry, because that got checked above @@ -275,8 +293,9 @@ const Pack = warner(class Pack extends MiniPass { return } - if (job === this[CURRENT] && !job.piped) + if (job === this[CURRENT] && !job.piped) { this[PIPE](job) + } } [ENTRYOPT] (job) { @@ -309,8 +328,9 @@ const Pack = warner(class Pack extends MiniPass { } [ONDRAIN] () { - if (this[CURRENT] && this[CURRENT].entry) + if (this[CURRENT] && this[CURRENT].entry) { this[CURRENT].entry.resume() + } } // like .pipe() but using super, because our write() is special @@ -330,20 +350,23 @@ const Pack = warner(class Pack extends MiniPass { if (zip) { source.on('data', chunk => { - if (!zip.write(chunk)) + if (!zip.write(chunk)) { source.pause() + } }) } else { source.on('data', chunk => { - if (!super.write(chunk)) + if (!super.write(chunk)) { source.pause() + } }) } } pause () { - if (this.zip) + if (this.zip) { this.zip.pause() + } return super.pause() } }) diff --git a/node_modules/tar/lib/parse.js b/node_modules/tar/lib/parse.js index b1b4e7e47577c..4b85915cbe01e 100644 --- a/node_modules/tar/lib/parse.js +++ b/node_modules/tar/lib/parse.js @@ -28,6 +28,7 @@ const maxMetaEntrySize = 1024 * 1024 const Entry = require('./read-entry.js') const Pax = require('./pax.js') const zlib = require('minizlib') +const { nextTick } = require('process') const gzipHeader = Buffer.from([0x1f, 0x8b]) const STATE = Symbol('state') @@ -59,6 +60,7 @@ const DONE = Symbol('onDone') const SAW_VALID_ENTRY = Symbol('sawValidEntry') const SAW_NULL_BLOCK = Symbol('sawNullBlock') const SAW_EOF = Symbol('sawEOF') +const CLOSESTREAM = Symbol('closeStream') const noop = _ => true @@ -82,14 +84,13 @@ module.exports = warner(class Parser extends EE { } }) - if (opt.ondone) + if (opt.ondone) { this.on(DONE, opt.ondone) - else { + } else { this.on(DONE, _ => { this.emit('prefinish') this.emit('finish') this.emit('end') - this.emit('close') }) } @@ -114,15 +115,21 @@ module.exports = warner(class Parser extends EE { this[ABORTED] = false this[SAW_NULL_BLOCK] = false this[SAW_EOF] = false - if (typeof opt.onwarn === 'function') + + this.on('end', () => this[CLOSESTREAM]()) + + if (typeof opt.onwarn === 'function') { this.on('warn', opt.onwarn) - if (typeof opt.onentry === 'function') + } + if (typeof opt.onentry === 'function') { this.on('entry', opt.onentry) + } } [CONSUMEHEADER] (chunk, position) { - if (this[SAW_VALID_ENTRY] === null) + if (this[SAW_VALID_ENTRY] === null) { this[SAW_VALID_ENTRY] = false + } let header try { header = new Header(chunk, position, this[EX], this[GEX]) @@ -134,8 +141,9 @@ module.exports = warner(class Parser extends EE { if (this[SAW_NULL_BLOCK]) { this[SAW_EOF] = true // ending an archive with no entries. pointless, but legal. - if (this[STATE] === 'begin') + if (this[STATE] === 'begin') { this[STATE] = 'header' + } this[EMIT]('eof') } else { this[SAW_NULL_BLOCK] = true @@ -143,17 +151,17 @@ module.exports = warner(class Parser extends EE { } } else { this[SAW_NULL_BLOCK] = false - if (!header.cksumValid) - this.warn('TAR_ENTRY_INVALID', 'checksum failure', {header}) - else if (!header.path) - this.warn('TAR_ENTRY_INVALID', 'path is required', {header}) - else { + if (!header.cksumValid) { + this.warn('TAR_ENTRY_INVALID', 'checksum failure', { header }) + } else if (!header.path) { + this.warn('TAR_ENTRY_INVALID', 'path is required', { header }) + } else { const type = header.type - if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) - this.warn('TAR_ENTRY_INVALID', 'linkpath required', {header}) - else if (!/^(Symbolic)?Link$/.test(type) && header.linkpath) - this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', {header}) - else { + if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) { + this.warn('TAR_ENTRY_INVALID', 'linkpath required', { header }) + } else if (!/^(Symbolic)?Link$/.test(type) && header.linkpath) { + this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', { header }) + } else { const entry = this[WRITEENTRY] = new Entry(header, this[EX], this[GEX]) // we do this for meta & ignored entries as well, because they @@ -162,12 +170,14 @@ module.exports = warner(class Parser extends EE { if (entry.remain) { // this might be the one! const onend = () => { - if (!entry.invalid) + if (!entry.invalid) { this[SAW_VALID_ENTRY] = true + } } entry.on('end', onend) - } else + } else { this[SAW_VALID_ENTRY] = true + } } if (entry.meta) { @@ -191,9 +201,9 @@ module.exports = warner(class Parser extends EE { this[STATE] = entry.remain ? 'ignore' : 'header' entry.resume() } else { - if (entry.remain) + if (entry.remain) { this[STATE] = 'body' - else { + } else { this[STATE] = 'header' entry.end() } @@ -201,8 +211,9 @@ module.exports = warner(class Parser extends EE { if (!this[READENTRY]) { this[QUEUE].push(entry) this[NEXTENTRY]() - } else + } else { this[QUEUE].push(entry) + } } } } @@ -210,15 +221,19 @@ module.exports = warner(class Parser extends EE { } } + [CLOSESTREAM] () { + nextTick(() => this.emit('close')) + } + [PROCESSENTRY] (entry) { let go = true if (!entry) { this[READENTRY] = null go = false - } else if (Array.isArray(entry)) + } else if (Array.isArray(entry)) { this.emit.apply(this, entry) - else { + } else { this[READENTRY] = entry this.emit('entry', entry) if (!entry.emittedEnd) { @@ -244,10 +259,12 @@ module.exports = warner(class Parser extends EE { const re = this[READENTRY] const drainNow = !re || re.flowing || re.size === re.remain if (drainNow) { - if (!this[WRITING]) + if (!this[WRITING]) { this.emit('drain') - } else + } + } else { re.once('drain', _ => this.emit('drain')) + } } } @@ -274,17 +291,19 @@ module.exports = warner(class Parser extends EE { const ret = this[CONSUMEBODY](chunk, position) // if we finished, then the entry is reset - if (!this[WRITEENTRY]) + if (!this[WRITEENTRY]) { this[EMITMETA](entry) + } return ret } [EMIT] (ev, data, extra) { - if (!this[QUEUE].length && !this[READENTRY]) + if (!this[QUEUE].length && !this[READENTRY]) { this.emit(ev, data, extra) - else + } else { this[QUEUE].push([ev, data, extra]) + } } [EMITMETA] (entry) { @@ -323,8 +342,9 @@ module.exports = warner(class Parser extends EE { } write (chunk) { - if (this[ABORTED]) + if (this[ABORTED]) { return + } // first write, might be gzipped if (this[UNZIP] === null && chunk) { @@ -337,8 +357,9 @@ module.exports = warner(class Parser extends EE { return true } for (let i = 0; this[UNZIP] === null && i < gzipHeader.length; i++) { - if (chunk[i] !== gzipHeader[i]) + if (chunk[i] !== gzipHeader[i]) { this[UNZIP] = false + } } if (this[UNZIP] === null) { const ended = this[ENDED] @@ -358,10 +379,11 @@ module.exports = warner(class Parser extends EE { } this[WRITING] = true - if (this[UNZIP]) + if (this[UNZIP]) { this[UNZIP].write(chunk) - else + } else { this[CONSUMECHUNK](chunk) + } this[WRITING] = false // return false if there's a queue, or if the current entry isn't flowing @@ -371,15 +393,17 @@ module.exports = warner(class Parser extends EE { true // if we have no queue, then that means a clogged READENTRY - if (!ret && !this[QUEUE].length) + if (!ret && !this[QUEUE].length) { this[READENTRY].once('drain', _ => this.emit('drain')) + } return ret } [BUFFERCONCAT] (c) { - if (c && !this[ABORTED]) + if (c && !this[ABORTED]) { this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c + } } [MAYBEEND] () { @@ -393,9 +417,10 @@ module.exports = warner(class Parser extends EE { // truncated, likely a damaged file const have = this[BUFFER] ? this[BUFFER].length : 0 this.warn('TAR_BAD_ARCHIVE', `Truncated input (needed ${ - entry.blockRemain} more bytes, only ${have} available)`, {entry}) - if (this[BUFFER]) + entry.blockRemain} more bytes, only ${have} available)`, { entry }) + if (this[BUFFER]) { entry.write(this[BUFFER]) + } entry.end() } this[EMIT](DONE) @@ -403,19 +428,20 @@ module.exports = warner(class Parser extends EE { } [CONSUMECHUNK] (chunk) { - if (this[CONSUMING]) + if (this[CONSUMING]) { this[BUFFERCONCAT](chunk) - else if (!chunk && !this[BUFFER]) + } else if (!chunk && !this[BUFFER]) { this[MAYBEEND]() - else { + } else { this[CONSUMING] = true if (this[BUFFER]) { this[BUFFERCONCAT](chunk) const c = this[BUFFER] this[BUFFER] = null this[CONSUMECHUNKSUB](c) - } else + } else { this[CONSUMECHUNKSUB](chunk) + } while (this[BUFFER] && this[BUFFER].length >= 512 && @@ -428,8 +454,9 @@ module.exports = warner(class Parser extends EE { this[CONSUMING] = false } - if (!this[BUFFER] || this[ENDED]) + if (!this[BUFFER] || this[ENDED]) { this[MAYBEEND]() + } } [CONSUMECHUNKSUB] (chunk) { @@ -461,18 +488,19 @@ module.exports = warner(class Parser extends EE { } if (position < length) { - if (this[BUFFER]) + if (this[BUFFER]) { this[BUFFER] = Buffer.concat([chunk.slice(position), this[BUFFER]]) - else + } else { this[BUFFER] = chunk.slice(position) + } } } end (chunk) { if (!this[ABORTED]) { - if (this[UNZIP]) + if (this[UNZIP]) { this[UNZIP].end(chunk) - else { + } else { this[ENDED] = true this.write(chunk) } diff --git a/node_modules/tar/lib/path-reservations.js b/node_modules/tar/lib/path-reservations.js index 8183c45f8535c..ef380cab685e3 100644 --- a/node_modules/tar/lib/path-reservations.js +++ b/node_modules/tar/lib/path-reservations.js @@ -27,8 +27,9 @@ module.exports = () => { // '/a/b/c/d' -> ['/', '/a', '/a/b', '/a/b/c', '/a/b/c/d'] const getDirs = path => { const dirs = path.split('/').slice(0, -1).reduce((set, path) => { - if (set.length) + if (set.length) { path = join(set[set.length - 1], path) + } set.push(path || '/') return set }, []) @@ -43,8 +44,9 @@ module.exports = () => { const getQueues = fn => { const res = reservations.get(fn) /* istanbul ignore if - unpossible */ - if (!res) + if (!res) { throw new Error('function does not have any path reservations') + } return { paths: res.paths.map(path => queues.get(path)), dirs: [...res.dirs].map(path => queues.get(path)), @@ -54,23 +56,25 @@ module.exports = () => { // check if fn is first in line for all its paths, and is // included in the first set for all its dir queues const check = fn => { - const {paths, dirs} = getQueues(fn) + const { paths, dirs } = getQueues(fn) return paths.every(q => q[0] === fn) && dirs.every(q => q[0] instanceof Set && q[0].has(fn)) } // run the function if it's first in line and not already running const run = fn => { - if (running.has(fn) || !check(fn)) + if (running.has(fn) || !check(fn)) { return false + } running.add(fn) fn(() => clear(fn)) return true } const clear = fn => { - if (!running.has(fn)) + if (!running.has(fn)) { return false + } const { paths, dirs } = reservations.get(fn) const next = new Set() @@ -78,29 +82,31 @@ module.exports = () => { paths.forEach(path => { const q = queues.get(path) assert.equal(q[0], fn) - if (q.length === 1) + if (q.length === 1) { queues.delete(path) - else { + } else { q.shift() - if (typeof q[0] === 'function') + if (typeof q[0] === 'function') { next.add(q[0]) - else + } else { q[0].forEach(fn => next.add(fn)) + } } }) dirs.forEach(dir => { const q = queues.get(dir) assert(q[0] instanceof Set) - if (q[0].size === 1 && q.length === 1) + if (q[0].size === 1 && q.length === 1) { queues.delete(dir) - else if (q[0].size === 1) { + } else if (q[0].size === 1) { q.shift() // must be a function or else the Set would've been reused next.add(q[0]) - } else + } else { q[0].delete(fn) + } }) running.delete(fn) @@ -123,22 +129,24 @@ module.exports = () => { const dirs = new Set( paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b)) ) - reservations.set(fn, {dirs, paths}) + reservations.set(fn, { dirs, paths }) paths.forEach(path => { const q = queues.get(path) - if (!q) + if (!q) { queues.set(path, [fn]) - else + } else { q.push(fn) + } }) dirs.forEach(dir => { const q = queues.get(dir) - if (!q) + if (!q) { queues.set(dir, [new Set([fn])]) - else if (q[q.length - 1] instanceof Set) + } else if (q[q.length - 1] instanceof Set) { q[q.length - 1].add(fn) - else + } else { q.push(new Set([fn])) + } }) return run(fn) diff --git a/node_modules/tar/lib/pax.js b/node_modules/tar/lib/pax.js index 7768c7b454f76..4a7ca85386e83 100644 --- a/node_modules/tar/lib/pax.js +++ b/node_modules/tar/lib/pax.js @@ -24,8 +24,9 @@ class Pax { encode () { const body = this.encodeBody() - if (body === '') + if (body === '') { return null + } const bodyLen = Buffer.byteLength(body) // round up to 512 bytes @@ -34,8 +35,9 @@ class Pax { const buf = Buffer.allocUnsafe(bufLen) // 0-fill the header section, it might not hit every field - for (let i = 0; i < 512; i++) + for (let i = 0; i < 512; i++) { buf[i] = 0 + } new Header({ // XXX split the path @@ -60,8 +62,9 @@ class Pax { buf.write(body, 512, bodyLen, 'utf8') // null pad after the body - for (let i = bodyLen + 512; i < buf.length; i++) + for (let i = bodyLen + 512; i < buf.length; i++) { buf[i] = 0 + } return buf } @@ -87,8 +90,9 @@ class Pax { } encodeField (field) { - if (this[field] === null || this[field] === undefined) + if (this[field] === null || this[field] === undefined) { return '' + } const v = this[field] instanceof Date ? this[field].getTime() / 1000 : this[field] const s = ' ' + @@ -100,8 +104,9 @@ class Pax { // so if it's 9 characters, then adding 1 for the 9 makes it 10 // which makes it 11 chars. let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1 - if (byteLen + digits >= Math.pow(10, digits)) + if (byteLen + digits >= Math.pow(10, digits)) { digits += 1 + } const len = digits + byteLen return len + s } @@ -123,14 +128,16 @@ const parseKVLine = (set, line) => { // XXX Values with \n in them will fail this. // Refactor to not be a naive line-by-line parse. - if (n !== Buffer.byteLength(line) + 1) + if (n !== Buffer.byteLength(line) + 1) { return set + } - line = line.substr((n + ' ').length) + line = line.slice((n + ' ').length) const kv = line.split('=') const k = kv.shift().replace(/^SCHILY\.(dev|ino|nlink)/, '$1') - if (!k) + if (!k) { return set + } const v = kv.join('=') set[k] = /^([A-Z]+\.)?([mac]|birth|creation)time$/.test(k) diff --git a/node_modules/tar/lib/read-entry.js b/node_modules/tar/lib/read-entry.js index 183a6050ba0d2..7f44bebfc10bd 100644 --- a/node_modules/tar/lib/read-entry.js +++ b/node_modules/tar/lib/read-entry.js @@ -49,8 +49,9 @@ module.exports = class ReadEntry extends MiniPass { this.path = normPath(header.path) this.mode = header.mode - if (this.mode) + if (this.mode) { this.mode = this.mode & 0o7777 + } this.uid = header.uid this.gid = header.gid this.uname = header.uname @@ -63,26 +64,31 @@ module.exports = class ReadEntry extends MiniPass { this.uname = header.uname this.gname = header.gname - if (ex) + if (ex) { this[SLURP](ex) - if (gex) + } + if (gex) { this[SLURP](gex, true) + } } write (data) { const writeLen = data.length - if (writeLen > this.blockRemain) + if (writeLen > this.blockRemain) { throw new Error('writing more to entry than is appropriate') + } const r = this.remain const br = this.blockRemain this.remain = Math.max(0, r - writeLen) this.blockRemain = Math.max(0, br - writeLen) - if (this.ignore) + if (this.ignore) { return true + } - if (r >= writeLen) + if (r >= writeLen) { return super.write(data) + } // r < writeLen return super.write(data.slice(0, r)) @@ -93,8 +99,9 @@ module.exports = class ReadEntry extends MiniPass { // we slurp in everything except for the path attribute in // a global extended header, because that's weird. if (ex[k] !== null && ex[k] !== undefined && - !(global && k === 'path')) + !(global && k === 'path')) { this[k] = k === 'path' || k === 'linkpath' ? normPath(ex[k]) : ex[k] + } } } } diff --git a/node_modules/tar/lib/replace.js b/node_modules/tar/lib/replace.js index 1374f3f29c619..c6e619be6f032 100644 --- a/node_modules/tar/lib/replace.js +++ b/node_modules/tar/lib/replace.js @@ -19,14 +19,17 @@ const Header = require('./header.js') module.exports = (opt_, files, cb) => { const opt = hlo(opt_) - if (!opt.file) + if (!opt.file) { throw new TypeError('file is required') + } - if (opt.gzip) + if (opt.gzip) { throw new TypeError('cannot append to compressed archives') + } - if (!files || !Array.isArray(files) || !files.length) + if (!files || !Array.isArray(files) || !files.length) { throw new TypeError('no files or directories specified') + } files = Array.from(files) @@ -45,10 +48,11 @@ const replaceSync = (opt, files) => { try { fd = fs.openSync(opt.file, 'r+') } catch (er) { - if (er.code === 'ENOENT') + if (er.code === 'ENOENT') { fd = fs.openSync(opt.file, 'w+') - else + } else { throw er + } } const st = fs.fstatSync(fd) @@ -60,24 +64,29 @@ const replaceSync = (opt, files) => { fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos ) - if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) + if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) { throw new Error('cannot append to compressed archives') + } - if (!bytes) + if (!bytes) { break POSITION + } } const h = new Header(headBuf) - if (!h.cksumValid) + if (!h.cksumValid) { break + } const entryBlockSize = 512 * Math.ceil(h.size / 512) - if (position + entryBlockSize + 512 > st.size) + if (position + entryBlockSize + 512 > st.size) { break + } // the 512 for the header we just parsed will be added as well // also jump ahead all the blocks for the body position += entryBlockSize - if (opt.mtimeCache) + if (opt.mtimeCache) { opt.mtimeCache.set(h.path, h.mtime) + } } threw = false @@ -106,21 +115,24 @@ const replace = (opt, files, cb) => { const getPos = (fd, size, cb_) => { const cb = (er, pos) => { - if (er) + if (er) { fs.close(fd, _ => cb_(er)) - else + } else { cb_(null, pos) + } } let position = 0 - if (size === 0) + if (size === 0) { return cb(null, 0) + } let bufPos = 0 const headBuf = Buffer.alloc(512) const onread = (er, bytes) => { - if (er) + if (er) { return cb(er) + } bufPos += bytes if (bufPos < 512 && bytes) { return fs.read( @@ -129,27 +141,33 @@ const replace = (opt, files, cb) => { ) } - if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) + if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) { return cb(new Error('cannot append to compressed archives')) + } // truncated header - if (bufPos < 512) + if (bufPos < 512) { return cb(null, position) + } const h = new Header(headBuf) - if (!h.cksumValid) + if (!h.cksumValid) { return cb(null, position) + } const entryBlockSize = 512 * Math.ceil(h.size / 512) - if (position + entryBlockSize + 512 > size) + if (position + entryBlockSize + 512 > size) { return cb(null, position) + } position += entryBlockSize + 512 - if (position >= size) + if (position >= size) { return cb(null, position) + } - if (opt.mtimeCache) + if (opt.mtimeCache) { opt.mtimeCache.set(h.path, h.mtime) + } bufPos = 0 fs.read(fd, headBuf, 0, 512, position, onread) } @@ -165,16 +183,19 @@ const replace = (opt, files, cb) => { return fs.open(opt.file, flag, onopen) } - if (er) + if (er) { return reject(er) + } fs.fstat(fd, (er, st) => { - if (er) + if (er) { return fs.close(fd, () => reject(er)) + } getPos(fd, st.size, (er, position) => { - if (er) + if (er) { return reject(er) + } const stream = new fsm.WriteStream(opt.file, { fd: fd, start: position, @@ -196,13 +217,14 @@ const addFilesSync = (p, files) => { files.forEach(file => { if (file.charAt(0) === '@') { t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), sync: true, noResume: true, onentry: entry => p.add(entry), }) - } else + } else { p.add(file) + } }) p.end() } @@ -212,12 +234,13 @@ const addFilesAsync = (p, files) => { const file = files.shift() if (file.charAt(0) === '@') { return t({ - file: path.resolve(p.cwd, file.substr(1)), + file: path.resolve(p.cwd, file.slice(1)), noResume: true, onentry: entry => p.add(entry), }).then(_ => addFilesAsync(p, files)) - } else + } else { p.add(file) + } } p.end() } diff --git a/node_modules/tar/lib/strip-absolute-path.js b/node_modules/tar/lib/strip-absolute-path.js index 1aa2d2aec5030..185e2dead3929 100644 --- a/node_modules/tar/lib/strip-absolute-path.js +++ b/node_modules/tar/lib/strip-absolute-path.js @@ -16,7 +16,7 @@ module.exports = path => { // but strip the //?/C:/ off of //?/C:/path const root = path.charAt(0) === '/' && path.slice(0, 4) !== '//?/' ? '/' : parsed.root - path = path.substr(root.length) + path = path.slice(root.length) r += root parsed = parse(path) } diff --git a/node_modules/tar/lib/unpack.js b/node_modules/tar/lib/unpack.js index 7d39dc0f7e79f..e341ad0c7239e 100644 --- a/node_modules/tar/lib/unpack.js +++ b/node_modules/tar/lib/unpack.js @@ -66,21 +66,24 @@ const isWindows = platform === 'win32' // See: https://github.com/npm/node-tar/issues/183 /* istanbul ignore next */ const unlinkFile = (path, cb) => { - if (!isWindows) + if (!isWindows) { return fs.unlink(path, cb) + } const name = path + '.DELETE.' + crypto.randomBytes(16).toString('hex') fs.rename(path, name, er => { - if (er) + if (er) { return cb(er) + } fs.unlink(name, cb) }) } /* istanbul ignore next */ const unlinkFileSync = path => { - if (!isWindows) + if (!isWindows) { return fs.unlinkSync(path) + } const name = path + '.DELETE.' + crypto.randomBytes(16).toString('hex') fs.renameSync(path, name) @@ -109,20 +112,23 @@ const pruneCache = (cache, abs) => { abs = cacheKeyNormalize(abs) for (const path of cache.keys()) { const pnorm = cacheKeyNormalize(path) - if (pnorm === abs || pnorm.indexOf(abs + '/') === 0) + if (pnorm === abs || pnorm.indexOf(abs + '/') === 0) { cache.delete(path) + } } } const dropCache = cache => { - for (const key of cache.keys()) + for (const key of cache.keys()) { cache.delete(key) + } } class Unpack extends Parser { constructor (opt) { - if (!opt) + if (!opt) { opt = {} + } opt.ondone = _ => { this[ENDED] = true @@ -147,8 +153,9 @@ class Unpack extends Parser { if (typeof opt.uid === 'number' || typeof opt.gid === 'number') { // need both or neither - if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') + if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') { throw new TypeError('cannot set owner without number uid and gid') + } if (opt.preserveOwner) { throw new TypeError( 'cannot preserve owner in archive and also set owner explicitly') @@ -163,10 +170,11 @@ class Unpack extends Parser { } // default true for root - if (opt.preserveOwner === undefined && typeof opt.uid !== 'number') + if (opt.preserveOwner === undefined && typeof opt.uid !== 'number') { this.preserveOwner = process.getuid && process.getuid() === 0 - else + } else { this.preserveOwner = !!opt.preserveOwner + } this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : null @@ -215,8 +223,9 @@ class Unpack extends Parser { // when extracting. Mark those errors as unrecoverable, because // the Unpack contract cannot be met. warn (code, msg, data = {}) { - if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') + if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') { data.recoverable = false + } return super.warn(code, msg, data) } @@ -225,23 +234,24 @@ class Unpack extends Parser { this.emit('prefinish') this.emit('finish') this.emit('end') - this.emit('close') } } [CHECKPATH] (entry) { if (this.strip) { const parts = normPath(entry.path).split('/') - if (parts.length < this.strip) + if (parts.length < this.strip) { return false + } entry.path = parts.slice(this.strip).join('/') if (entry.type === 'Link') { const linkparts = normPath(entry.linkpath).split('/') - if (linkparts.length >= this.strip) + if (linkparts.length >= this.strip) { entry.linkpath = linkparts.slice(this.strip).join('/') - else + } else { return false + } } } @@ -267,10 +277,11 @@ class Unpack extends Parser { } } - if (path.isAbsolute(entry.path)) + if (path.isAbsolute(entry.path)) { entry.absolute = normPath(path.resolve(entry.path)) - else + } else { entry.absolute = normPath(path.resolve(this.cwd, entry.path)) + } // if we somehow ended up with a path that escapes the cwd, and we are // not in preservePaths mode, then something is fishy! This should have @@ -292,32 +303,36 @@ class Unpack extends Parser { // may not replace the cwd with a different kind of thing entirely. if (entry.absolute === this.cwd && entry.type !== 'Directory' && - entry.type !== 'GNUDumpDir') + entry.type !== 'GNUDumpDir') { return false + } // only encode : chars that aren't drive letter indicators if (this.win32) { const { root: aRoot } = path.win32.parse(entry.absolute) - entry.absolute = aRoot + wc.encode(entry.absolute.substr(aRoot.length)) + entry.absolute = aRoot + wc.encode(entry.absolute.slice(aRoot.length)) const { root: pRoot } = path.win32.parse(entry.path) - entry.path = pRoot + wc.encode(entry.path.substr(pRoot.length)) + entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length)) } return true } [ONENTRY] (entry) { - if (!this[CHECKPATH](entry)) + if (!this[CHECKPATH](entry)) { return entry.resume() + } assert.equal(typeof entry.absolute, 'string') switch (entry.type) { case 'Directory': case 'GNUDumpDir': - if (entry.mode) + if (entry.mode) { entry.mode = entry.mode | 0o700 + } + // eslint-disable-next-line no-fallthrough case 'File': case 'OldFile': case 'ContiguousFile': @@ -337,10 +352,10 @@ class Unpack extends Parser { // Cwd has to exist, or else nothing works. That's serious. // Other errors are warnings, which raise the error in strict // mode, but otherwise continue on. - if (er.name === 'CwdError') + if (er.name === 'CwdError') { this.emit('error', er) - else { - this.warn('TAR_ENTRY_ERROR', er, {entry}) + } else { + this.warn('TAR_ENTRY_ERROR', er, { entry }) this[UNPEND]() entry.resume() } @@ -390,8 +405,9 @@ class Unpack extends Parser { autoClose: false, }) stream.on('error', er => { - if (stream.fd) + if (stream.fd) { fs.close(stream.fd, () => {}) + } // flush all the data out so that we aren't left hanging // if the error wasn't actually fatal. otherwise the parse @@ -405,8 +421,9 @@ class Unpack extends Parser { const done = er => { if (er) { /* istanbul ignore else - we should always have a fd by now */ - if (stream.fd) + if (stream.fd) { fs.close(stream.fd, () => {}) + } this[ONERROR](er, entry) fullyDone() @@ -415,10 +432,11 @@ class Unpack extends Parser { if (--actions === 0) { fs.close(stream.fd, er => { - if (er) + if (er) { this[ONERROR](er, entry) - else + } else { this[UNPEND]() + } fullyDone() }) } @@ -498,7 +516,7 @@ class Unpack extends Parser { [UNSUPPORTED] (entry) { entry.unsupported = true this.warn('TAR_ENTRY_UNSUPPORTED', - `unsupported entry type: ${entry.type}`, {entry}) + `unsupported entry type: ${entry.type}`, { entry }) entry.resume() } @@ -540,8 +558,9 @@ class Unpack extends Parser { [CHECKFS] (entry) { this[PEND]() const paths = [entry.path] - if (entry.linkpath) + if (entry.linkpath) { paths.push(entry.linkpath) + } this.reservations.reserve(paths, done => this[CHECKFS2](entry, done)) } @@ -556,10 +575,11 @@ class Unpack extends Parser { // entry, it'll just fail to unpack, but a symlink to a directory, using an // 8.3 shortname or certain unicode attacks, can evade detection and lead // to arbitrary writes to anywhere on the system. - if (entry.type === 'SymbolicLink') + if (entry.type === 'SymbolicLink') { dropCache(this.dirCache) - else if (entry.type !== 'Directory') + } else if (entry.type !== 'Directory') { pruneCache(this.dirCache, entry.absolute) + } } [CHECKFS2] (entry, fullyDone) { @@ -606,8 +626,9 @@ class Unpack extends Parser { done() return } - if (lstatEr || this[ISREUSABLE](entry, st)) + if (lstatEr || this[ISREUSABLE](entry, st)) { return this[MAKEFS](null, entry, done) + } if (st.isDirectory()) { if (entry.type === 'Directory') { @@ -615,8 +636,9 @@ class Unpack extends Parser { entry.mode && (st.mode & 0o7777) !== entry.mode const afterChmod = er => this[MAKEFS](er, entry, done) - if (!needChmod) + if (!needChmod) { return afterChmod() + } return fs.chmod(entry.absolute, entry.mode, afterChmod) } // Not a dir entry, have to remove it. @@ -634,18 +656,20 @@ class Unpack extends Parser { // not a dir, and not reusable // don't remove if the cwd, we want that error - if (entry.absolute === this.cwd) + if (entry.absolute === this.cwd) { return this[MAKEFS](null, entry, done) + } unlinkFile(entry.absolute, er => this[MAKEFS](er, entry, done)) }) } - if (this[CHECKED_CWD]) + if (this[CHECKED_CWD]) { start() - else + } else { checkCwd() + } } [MAKEFS] (er, entry, done) { @@ -676,9 +700,9 @@ class Unpack extends Parser { [LINK] (entry, linkpath, link, done) { // XXX: get the type ('symlink' or 'junction') for windows fs[link](linkpath, entry.absolute, er => { - if (er) + if (er) { this[ONERROR](er, entry) - else { + } else { this[UNPEND]() entry.resume() } @@ -704,8 +728,9 @@ class UnpackSync extends Unpack { if (!this[CHECKED_CWD]) { const er = this[MKDIR](this.cwd, this.dmode) - if (er) + if (er) { return this[ONERROR](er, entry) + } this[CHECKED_CWD] = true } @@ -715,17 +740,20 @@ class UnpackSync extends Unpack { const parent = normPath(path.dirname(entry.absolute)) if (parent !== this.cwd) { const mkParent = this[MKDIR](parent, this.dmode) - if (mkParent) + if (mkParent) { return this[ONERROR](mkParent, entry) + } } } const [lstatEr, st] = callSync(() => fs.lstatSync(entry.absolute)) - if (st && (this.keep || this.newer && st.mtime > entry.mtime)) + if (st && (this.keep || this.newer && st.mtime > entry.mtime)) { return this[SKIP](entry) + } - if (lstatEr || this[ISREUSABLE](entry, st)) + if (lstatEr || this[ISREUSABLE](entry, st)) { return this[MAKEFS](null, entry) + } if (st.isDirectory()) { if (entry.type === 'Directory') { @@ -759,8 +787,9 @@ class UnpackSync extends Unpack { } catch (e) { closeError = e } - if (er || closeError) + if (er || closeError) { this[ONERROR](er || closeError, entry) + } done() } diff --git a/node_modules/tar/lib/update.js b/node_modules/tar/lib/update.js index a5784b73f3c75..ded977dc1dec0 100644 --- a/node_modules/tar/lib/update.js +++ b/node_modules/tar/lib/update.js @@ -9,14 +9,17 @@ const r = require('./replace.js') module.exports = (opt_, files, cb) => { const opt = hlo(opt_) - if (!opt.file) + if (!opt.file) { throw new TypeError('file is required') + } - if (opt.gzip) + if (opt.gzip) { throw new TypeError('cannot append to compressed archives') + } - if (!files || !Array.isArray(files) || !files.length) + if (!files || !Array.isArray(files) || !files.length) { throw new TypeError('no files or directories specified') + } files = Array.from(files) @@ -27,8 +30,9 @@ module.exports = (opt_, files, cb) => { const mtimeFilter = opt => { const filter = opt.filter - if (!opt.mtimeCache) + if (!opt.mtimeCache) { opt.mtimeCache = new Map() + } opt.filter = filter ? (path, stat) => filter(path, stat) && !(opt.mtimeCache.get(path) > stat.mtime) diff --git a/node_modules/tar/lib/warn-mixin.js b/node_modules/tar/lib/warn-mixin.js index aeebb531b5701..a940639636133 100644 --- a/node_modules/tar/lib/warn-mixin.js +++ b/node_modules/tar/lib/warn-mixin.js @@ -1,10 +1,12 @@ 'use strict' module.exports = Base => class extends Base { warn (code, message, data = {}) { - if (this.file) + if (this.file) { data.file = this.file - if (this.cwd) + } + if (this.cwd) { data.cwd = this.cwd + } data.code = message instanceof Error && message.code || code data.tarCode = code if (!this.strict && data.recoverable !== false) { @@ -13,9 +15,10 @@ module.exports = Base => class extends Base { message = message.message } this.emit('warn', data.tarCode, message, data) - } else if (message instanceof Error) + } else if (message instanceof Error) { this.emit('error', Object.assign(message, data)) - else + } else { this.emit('error', Object.assign(new Error(`${code}: ${message}`), data)) + } } } diff --git a/node_modules/tar/lib/write-entry.js b/node_modules/tar/lib/write-entry.js index 3702f2ae51979..3b5540f76c020 100644 --- a/node_modules/tar/lib/write-entry.js +++ b/node_modules/tar/lib/write-entry.js @@ -8,8 +8,9 @@ const normPath = require('./normalize-windows-path.js') const stripSlash = require('./strip-trailing-slashes.js') const prefixPath = (path, prefix) => { - if (!prefix) + if (!prefix) { return normPath(path) + } path = normPath(path).replace(/^\.(\/|$)/, '') return stripSlash(prefix) + '/' + path } @@ -44,8 +45,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { constructor (p, opt) { opt = opt || {} super(opt) - if (typeof p !== 'string') + if (typeof p !== 'string') { throw new TypeError('path is required') + } this.path = normPath(p) // suppress atime, ctime, uid, gid, uname, gname this.portable = !!opt.portable @@ -72,8 +74,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { this.pos = null this.remain = null - if (typeof opt.onwarn === 'function') + if (typeof opt.onwarn === 'function') { this.on('warn', opt.onwarn) + } let pathWarn = false if (!this.preservePaths) { @@ -94,8 +97,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { this.absolute = normPath(opt.absolute || path.resolve(this.cwd, p)) - if (this.path === '') + if (this.path === '') { this.path = './' + } if (pathWarn) { this.warn('TAR_ENTRY_INFO', `stripping ${pathWarn} from absolute path`, { @@ -104,22 +108,25 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { }) } - if (this.statCache.has(this.absolute)) + if (this.statCache.has(this.absolute)) { this[ONLSTAT](this.statCache.get(this.absolute)) - else + } else { this[LSTAT]() + } } emit (ev, ...data) { - if (ev === 'error') + if (ev === 'error') { this[HAD_ERROR] = true + } return super.emit(ev, ...data) } [LSTAT] () { fs.lstat(this.absolute, (er, stat) => { - if (er) + if (er) { return this.emit('error', er) + } this[ONLSTAT](stat) }) } @@ -127,8 +134,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { [ONLSTAT] (stat) { this.statCache.set(this.absolute, stat) this.stat = stat - if (!stat.isFile()) + if (!stat.isFile()) { stat.size = 0 + } this.type = getType(stat) this.emit('stat', stat) this[PROCESS]() @@ -153,8 +161,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { } [HEADER] () { - if (this.type === 'Directory' && this.portable) + if (this.type === 'Directory' && this.portable) { this.noMtime = true + } this.header = new Header({ path: this[PREFIX](this.path), @@ -196,8 +205,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { } [DIRECTORY] () { - if (this.path.substr(-1) !== '/') + if (this.path.slice(-1) !== '/') { this.path += '/' + } this.stat.size = 0 this[HEADER]() this.end() @@ -205,8 +215,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { [SYMLINK] () { fs.readlink(this.absolute, (er, linkpath) => { - if (er) + if (er) { return this.emit('error', er) + } this[ONREADLINK](linkpath) }) } @@ -230,31 +241,35 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { const linkKey = this.stat.dev + ':' + this.stat.ino if (this.linkCache.has(linkKey)) { const linkpath = this.linkCache.get(linkKey) - if (linkpath.indexOf(this.cwd) === 0) + if (linkpath.indexOf(this.cwd) === 0) { return this[HARDLINK](linkpath) + } } this.linkCache.set(linkKey, this.absolute) } this[HEADER]() - if (this.stat.size === 0) + if (this.stat.size === 0) { return this.end() + } this[OPENFILE]() } [OPENFILE] () { fs.open(this.absolute, 'r', (er, fd) => { - if (er) + if (er) { return this.emit('error', er) + } this[ONOPENFILE](fd) }) } [ONOPENFILE] (fd) { this.fd = fd - if (this[HAD_ERROR]) + if (this[HAD_ERROR]) { return this[CLOSE]() + } this.blockLen = 512 * Math.ceil(this.stat.size / 512) this.blockRemain = this.blockLen @@ -318,10 +333,11 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { this.buf : this.buf.slice(this.offset, this.offset + bytesRead) const flushed = this.write(writeBuf) - if (!flushed) + if (!flushed) { this[AWAITDRAIN](() => this[ONDRAIN]()) - else + } else { this[ONDRAIN]() + } } [AWAITDRAIN] (cb) { @@ -343,8 +359,9 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { [ONDRAIN] () { if (!this.remain) { - if (this.blockRemain) + if (this.blockRemain) { super.write(Buffer.alloc(this.blockRemain)) + } return this[CLOSE](er => er ? this.emit('error', er) : this.end()) } @@ -412,8 +429,9 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass { this.readEntry = readEntry this.type = readEntry.type - if (this.type === 'Directory' && this.portable) + if (this.type === 'Directory' && this.portable) { this.noMtime = true + } this.prefix = opt.prefix || null @@ -429,8 +447,9 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass { this.ctime = this.portable ? null : readEntry.ctime this.linkpath = normPath(readEntry.linkpath) - if (typeof opt.onwarn === 'function') + if (typeof opt.onwarn === 'function') { this.on('warn', opt.onwarn) + } let pathWarn = false if (!this.preservePaths) { @@ -500,15 +519,17 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass { write (data) { const writeLen = data.length - if (writeLen > this.blockRemain) + if (writeLen > this.blockRemain) { throw new Error('writing more to entry than is appropriate') + } this.blockRemain -= writeLen return super.write(data) } end () { - if (this.blockRemain) + if (this.blockRemain) { super.write(Buffer.alloc(this.blockRemain)) + } return super.end() } }) diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json index 9f9977a0ca99b..3a02105c159e4 100644 --- a/node_modules/tar/package.json +++ b/node_modules/tar/package.json @@ -1,25 +1,21 @@ { - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "author": "GitHub Inc.", "name": "tar", "description": "tar for node", - "version": "6.1.11", + "version": "6.1.12", "repository": { "type": "git", "url": "https://github.com/npm/node-tar.git" }, "scripts": { - "test:posix": "tap", - "test:win32": "tap --lines=98 --branches=98 --statements=98 --functions=98", - "test": "node test/fixtures/test.js", - "posttest": "npm run lint", - "eslint": "eslint", - "lint": "npm run eslint -- test lib", - "lintfix": "npm run lint -- --fix", - "preversion": "npm test", - "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags", "genparse": "node scripts/generate-parse-fixtures.js", - "bench": "for i in benchmarks/*/*.js; do echo $i; for j in {1..5}; do node $i || break; done; done" + "template-oss-apply": "template-oss-apply --force", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "lintfix": "npm run lint -- --fix", + "snap": "tap", + "test": "tap", + "posttest": "npm run lint" }, "dependencies": { "chownr": "^2.0.0", @@ -30,30 +26,50 @@ "yallist": "^4.0.0" }, "devDependencies": { + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.8.0", "chmodr": "^1.2.0", "end-of-stream": "^1.4.3", - "eslint": "^7.17.0", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^5.0.0", "events-to-array": "^1.1.2", "mutate-fs": "^2.1.1", - "rimraf": "^2.7.1", - "tap": "^15.0.9", - "tar-fs": "^1.16.3", - "tar-stream": "^1.6.2" + "nock": "^13.2.9", + "rimraf": "^3.0.2", + "tap": "^16.0.1" }, "license": "ISC", "engines": { - "node": ">= 10" + "node": ">=10" }, "files": [ - "index.js", - "lib/*.js" + "bin/", + "lib/", + "index.js" ], "tap": { "coverage-map": "map.js", - "check-coverage": true + "timeout": 0, + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "4.8.0", + "content": "scripts/template-oss", + "engines": ">=10", + "distPaths": [ + "index.js" + ], + "allowPaths": [ + "/index.js" + ], + "ciVersions": [ + "10.x", + "12.x", + "14.x", + "16.x", + "18.x" + ] } } diff --git a/package-lock.json b/package-lock.json index 1ee8562af34f4..c61a7e1fc383e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -147,7 +147,7 @@ "rimraf": "^3.0.2", "semver": "^7.3.8", "ssri": "^10.0.0", - "tar": "^6.1.11", + "tar": "^6.1.12", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "treeverse": "^3.0.0", @@ -12938,9 +12938,10 @@ } }, "node_modules/tar": { - "version": "6.1.11", + "version": "6.1.12", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.12.tgz", + "integrity": "sha512-jU4TdemS31uABHd+Lt5WEYJuzn+TJTCBLljvIAHZOz6M9Os5pJ4dD+vRFLxPa/n3T0iEFzpi+0x1UfuDZYbRMw==", "inBundle": true, - "license": "ISC", "dependencies": { "chownr": "^2.0.0", "fs-minipass": "^2.0.0", @@ -12950,7 +12951,7 @@ "yallist": "^4.0.0" }, "engines": { - "node": ">= 10" + "node": ">=10" } }, "node_modules/tar-fs": { diff --git a/package.json b/package.json index 509aba5044d9c..278128cebfee0 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "rimraf": "^3.0.2", "semver": "^7.3.8", "ssri": "^10.0.0", - "tar": "^6.1.11", + "tar": "^6.1.12", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "treeverse": "^3.0.0", From b6192ca99ccc28c8671d8fe12bbbc460fbcdf0ce Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 2 Nov 2022 09:30:38 -0700 Subject: [PATCH 3/7] deps: nopt@7.0.0 --- node_modules/.gitignore | 4 + .../node-gyp/node_modules/nopt/LICENSE | 15 + .../node-gyp/node_modules/nopt/bin/nopt.js | 56 ++ .../node-gyp/node_modules/nopt/lib/nopt.js | 515 ++++++++++++++++++ .../node-gyp/node_modules/nopt/package.json | 53 ++ node_modules/nopt/node_modules/abbrev/LICENSE | 46 ++ .../nopt/node_modules/abbrev/lib/index.js | 50 ++ .../nopt/node_modules/abbrev/package.json | 43 ++ node_modules/nopt/package.json | 21 +- package-lock.json | 54 +- package.json | 2 +- workspaces/arborist/package.json | 2 +- workspaces/config/package.json | 2 +- 13 files changed, 843 insertions(+), 20 deletions(-) create mode 100644 node_modules/node-gyp/node_modules/nopt/LICENSE create mode 100755 node_modules/node-gyp/node_modules/nopt/bin/nopt.js create mode 100644 node_modules/node-gyp/node_modules/nopt/lib/nopt.js create mode 100644 node_modules/node-gyp/node_modules/nopt/package.json create mode 100644 node_modules/nopt/node_modules/abbrev/LICENSE create mode 100644 node_modules/nopt/node_modules/abbrev/lib/index.js create mode 100644 node_modules/nopt/node_modules/abbrev/package.json diff --git a/node_modules/.gitignore b/node_modules/.gitignore index f4e8be555b6e8..74070a54532d0 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -170,12 +170,16 @@ !/node-gyp/node_modules/make-fetch-happen !/node-gyp/node_modules/minimatch !/node-gyp/node_modules/minipass-fetch +!/node-gyp/node_modules/nopt !/node-gyp/node_modules/npmlog !/node-gyp/node_modules/ssri !/node-gyp/node_modules/unique-filename !/node-gyp/node_modules/unique-slug !/node-gyp/node_modules/which !/nopt +!/nopt/node_modules/ +/nopt/node_modules/* +!/nopt/node_modules/abbrev !/normalize-package-data !/npm-audit-report !/npm-bundled diff --git a/node_modules/node-gyp/node_modules/nopt/LICENSE b/node_modules/node-gyp/node_modules/nopt/LICENSE new file mode 100644 index 0000000000000..19129e315fe59 --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/node-gyp/node_modules/nopt/bin/nopt.js b/node_modules/node-gyp/node_modules/nopt/bin/nopt.js new file mode 100755 index 0000000000000..bb04291c607ac --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/bin/nopt.js @@ -0,0 +1,56 @@ +#!/usr/bin/env node +var nopt = require('../lib/nopt') +var path = require('path') +var types = { num: Number, + bool: Boolean, + help: Boolean, + list: Array, + 'num-list': [Number, Array], + 'str-list': [String, Array], + 'bool-list': [Boolean, Array], + str: String, + clear: Boolean, + config: Boolean, + length: Number, + file: path, +} +var shorthands = { s: ['--str', 'astring'], + b: ['--bool'], + nb: ['--no-bool'], + tft: ['--bool-list', '--no-bool-list', '--bool-list', 'true'], + '?': ['--help'], + h: ['--help'], + H: ['--help'], + n: ['--num', '125'], + c: ['--config'], + l: ['--length'], + f: ['--file'], +} +var parsed = nopt(types + , shorthands + , process.argv + , 2) + +console.log('parsed', parsed) + +if (parsed.help) { + console.log('') + console.log('nopt cli tester') + console.log('') + console.log('types') + console.log(Object.keys(types).map(function M (t) { + var type = types[t] + if (Array.isArray(type)) { + return [t, type.map(function (mappedType) { + return mappedType.name + })] + } + return [t, type && type.name] + }).reduce(function (s, i) { + s[i[0]] = i[1] + return s + }, {})) + console.log('') + console.log('shorthands') + console.log(shorthands) +} diff --git a/node_modules/node-gyp/node_modules/nopt/lib/nopt.js b/node_modules/node-gyp/node_modules/nopt/lib/nopt.js new file mode 100644 index 0000000000000..5829c2fe0f637 --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/lib/nopt.js @@ -0,0 +1,515 @@ +// info about each config option. + +var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG + ? function () { + console.error.apply(console, arguments) + } + : function () {} + +var url = require('url') +var path = require('path') +var Stream = require('stream').Stream +var abbrev = require('abbrev') +var os = require('os') + +module.exports = exports = nopt +exports.clean = clean + +exports.typeDefs = + { String: { type: String, validate: validateString }, + Boolean: { type: Boolean, validate: validateBoolean }, + url: { type: url, validate: validateUrl }, + Number: { type: Number, validate: validateNumber }, + path: { type: path, validate: validatePath }, + Stream: { type: Stream, validate: validateStream }, + Date: { type: Date, validate: validateDate }, + } + +function nopt (types, shorthands, args, slice) { + args = args || process.argv + types = types || {} + shorthands = shorthands || {} + if (typeof slice !== 'number') { + slice = 2 + } + + debug(types, shorthands, args, slice) + + args = args.slice(slice) + var data = {} + var argv = { + remain: [], + cooked: args, + original: args.slice(0), + } + + parse(args, data, argv.remain, types, shorthands) + // now data is full + clean(data, types, exports.typeDefs) + data.argv = argv + Object.defineProperty(data.argv, 'toString', { value: function () { + return this.original.map(JSON.stringify).join(' ') + }, + enumerable: false }) + return data +} + +function clean (data, types, typeDefs) { + typeDefs = typeDefs || exports.typeDefs + var remove = {} + var typeDefault = [false, true, null, String, Array] + + Object.keys(data).forEach(function (k) { + if (k === 'argv') { + return + } + var val = data[k] + var isArray = Array.isArray(val) + var type = types[k] + if (!isArray) { + val = [val] + } + if (!type) { + type = typeDefault + } + if (type === Array) { + type = typeDefault.concat(Array) + } + if (!Array.isArray(type)) { + type = [type] + } + + debug('val=%j', val) + debug('types=', type) + val = val.map(function (v) { + // if it's an unknown value, then parse false/true/null/numbers/dates + if (typeof v === 'string') { + debug('string %j', v) + v = v.trim() + if ((v === 'null' && ~type.indexOf(null)) + || (v === 'true' && + (~type.indexOf(true) || ~type.indexOf(Boolean))) + || (v === 'false' && + (~type.indexOf(false) || ~type.indexOf(Boolean)))) { + v = JSON.parse(v) + debug('jsonable %j', v) + } else if (~type.indexOf(Number) && !isNaN(v)) { + debug('convert to number', v) + v = +v + } else if (~type.indexOf(Date) && !isNaN(Date.parse(v))) { + debug('convert to date', v) + v = new Date(v) + } + } + + if (!Object.prototype.hasOwnProperty.call(types, k)) { + return v + } + + // allow `--no-blah` to set 'blah' to null if null is allowed + if (v === false && ~type.indexOf(null) && + !(~type.indexOf(false) || ~type.indexOf(Boolean))) { + v = null + } + + var d = {} + d[k] = v + debug('prevalidated val', d, v, types[k]) + if (!validate(d, k, v, types[k], typeDefs)) { + if (exports.invalidHandler) { + exports.invalidHandler(k, v, types[k], data) + } else if (exports.invalidHandler !== false) { + debug('invalid: ' + k + '=' + v, types[k]) + } + return remove + } + debug('validated v', d, v, types[k]) + return d[k] + }).filter(function (v) { + return v !== remove + }) + + // if we allow Array specifically, then an empty array is how we + // express 'no value here', not null. Allow it. + if (!val.length && type.indexOf(Array) === -1) { + debug('VAL HAS NO LENGTH, DELETE IT', val, k, type.indexOf(Array)) + delete data[k] + } else if (isArray) { + debug(isArray, data[k], val) + data[k] = val + } else { + data[k] = val[0] + } + + debug('k=%s val=%j', k, val, data[k]) + }) +} + +function validateString (data, k, val) { + data[k] = String(val) +} + +function validatePath (data, k, val) { + if (val === true) { + return false + } + if (val === null) { + return true + } + + val = String(val) + + var isWin = process.platform === 'win32' + var homePattern = isWin ? /^~(\/|\\)/ : /^~\// + var home = os.homedir() + + if (home && val.match(homePattern)) { + data[k] = path.resolve(home, val.slice(2)) + } else { + data[k] = path.resolve(val) + } + return true +} + +function validateNumber (data, k, val) { + debug('validate Number %j %j %j', k, val, isNaN(val)) + if (isNaN(val)) { + return false + } + data[k] = +val +} + +function validateDate (data, k, val) { + var s = Date.parse(val) + debug('validate Date %j %j %j', k, val, s) + if (isNaN(s)) { + return false + } + data[k] = new Date(val) +} + +function validateBoolean (data, k, val) { + if (val instanceof Boolean) { + val = val.valueOf() + } else if (typeof val === 'string') { + if (!isNaN(val)) { + val = !!(+val) + } else if (val === 'null' || val === 'false') { + val = false + } else { + val = true + } + } else { + val = !!val + } + data[k] = val +} + +function validateUrl (data, k, val) { + // Changing this would be a breaking change in the npm cli + /* eslint-disable-next-line node/no-deprecated-api */ + val = url.parse(String(val)) + if (!val.host) { + return false + } + data[k] = val.href +} + +function validateStream (data, k, val) { + if (!(val instanceof Stream)) { + return false + } + data[k] = val +} + +function validate (data, k, val, type, typeDefs) { + // arrays are lists of types. + if (Array.isArray(type)) { + for (let i = 0, l = type.length; i < l; i++) { + if (type[i] === Array) { + continue + } + if (validate(data, k, val, type[i], typeDefs)) { + return true + } + } + delete data[k] + return false + } + + // an array of anything? + if (type === Array) { + return true + } + + // Original comment: + // NaN is poisonous. Means that something is not allowed. + // New comment: Changing this to an isNaN check breaks a lot of tests. + // Something is being assumed here that is not actually what happens in + // practice. Fixing it is outside the scope of getting linting to pass in + // this repo. Leaving as-is for now. + /* eslint-disable-next-line no-self-compare */ + if (type !== type) { + debug('Poison NaN', k, val, type) + delete data[k] + return false + } + + // explicit list of values + if (val === type) { + debug('Explicitly allowed %j', val) + // if (isArray) (data[k] = data[k] || []).push(val) + // else data[k] = val + data[k] = val + return true + } + + // now go through the list of typeDefs, validate against each one. + var ok = false + var types = Object.keys(typeDefs) + for (let i = 0, l = types.length; i < l; i++) { + debug('test type %j %j %j', k, val, types[i]) + var t = typeDefs[types[i]] + if (t && ( + (type && type.name && t.type && t.type.name) ? + (type.name === t.type.name) : + (type === t.type) + )) { + var d = {} + ok = t.validate(d, k, val) !== false + val = d[k] + if (ok) { + // if (isArray) (data[k] = data[k] || []).push(val) + // else data[k] = val + data[k] = val + break + } + } + } + debug('OK? %j (%j %j %j)', ok, k, val, types[types.length - 1]) + + if (!ok) { + delete data[k] + } + return ok +} + +function parse (args, data, remain, types, shorthands) { + debug('parse', args, data, remain) + + var abbrevs = abbrev(Object.keys(types)) + var shortAbbr = abbrev(Object.keys(shorthands)) + + for (var i = 0; i < args.length; i++) { + var arg = args[i] + debug('arg', arg) + + if (arg.match(/^-{2,}$/)) { + // done with keys. + // the rest are args. + remain.push.apply(remain, args.slice(i + 1)) + args[i] = '--' + break + } + var hadEq = false + if (arg.charAt(0) === '-' && arg.length > 1) { + var at = arg.indexOf('=') + if (at > -1) { + hadEq = true + var v = arg.slice(at + 1) + arg = arg.slice(0, at) + args.splice(i, 1, arg, v) + } + + // see if it's a shorthand + // if so, splice and back up to re-parse it. + var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs) + debug('arg=%j shRes=%j', arg, shRes) + if (shRes) { + debug(arg, shRes) + args.splice.apply(args, [i, 1].concat(shRes)) + if (arg !== shRes[0]) { + i-- + continue + } + } + arg = arg.replace(/^-+/, '') + var no = null + while (arg.toLowerCase().indexOf('no-') === 0) { + no = !no + arg = arg.slice(3) + } + + if (abbrevs[arg]) { + arg = abbrevs[arg] + } + + var argType = types[arg] + var isTypeArray = Array.isArray(argType) + if (isTypeArray && argType.length === 1) { + isTypeArray = false + argType = argType[0] + } + + var isArray = argType === Array || + isTypeArray && argType.indexOf(Array) !== -1 + + // allow unknown things to be arrays if specified multiple times. + if ( + !Object.prototype.hasOwnProperty.call(types, arg) && + Object.prototype.hasOwnProperty.call(data, arg) + ) { + if (!Array.isArray(data[arg])) { + data[arg] = [data[arg]] + } + isArray = true + } + + var val + var la = args[i + 1] + + var isBool = typeof no === 'boolean' || + argType === Boolean || + isTypeArray && argType.indexOf(Boolean) !== -1 || + (typeof argType === 'undefined' && !hadEq) || + (la === 'false' && + (argType === null || + isTypeArray && ~argType.indexOf(null))) + + if (isBool) { + // just set and move along + val = !no + // however, also support --bool true or --bool false + if (la === 'true' || la === 'false') { + val = JSON.parse(la) + la = null + if (no) { + val = !val + } + i++ + } + + // also support "foo":[Boolean, "bar"] and "--foo bar" + if (isTypeArray && la) { + if (~argType.indexOf(la)) { + // an explicit type + val = la + i++ + } else if (la === 'null' && ~argType.indexOf(null)) { + // null allowed + val = null + i++ + } else if (!la.match(/^-{2,}[^-]/) && + !isNaN(la) && + ~argType.indexOf(Number)) { + // number + val = +la + i++ + } else if (!la.match(/^-[^-]/) && ~argType.indexOf(String)) { + // string + val = la + i++ + } + } + + if (isArray) { + (data[arg] = data[arg] || []).push(val) + } else { + data[arg] = val + } + + continue + } + + if (argType === String) { + if (la === undefined) { + la = '' + } else if (la.match(/^-{1,2}[^-]+/)) { + la = '' + i-- + } + } + + if (la && la.match(/^-{2,}$/)) { + la = undefined + i-- + } + + val = la === undefined ? true : la + if (isArray) { + (data[arg] = data[arg] || []).push(val) + } else { + data[arg] = val + } + + i++ + continue + } + remain.push(arg) + } +} + +function resolveShort (arg, shorthands, shortAbbr, abbrevs) { + // handle single-char shorthands glommed together, like + // npm ls -glp, but only if there is one dash, and only if + // all of the chars are single-char shorthands, and it's + // not a match to some other abbrev. + arg = arg.replace(/^-+/, '') + + // if it's an exact known option, then don't go any further + if (abbrevs[arg] === arg) { + return null + } + + // if it's an exact known shortopt, same deal + if (shorthands[arg]) { + // make it an array, if it's a list of words + if (shorthands[arg] && !Array.isArray(shorthands[arg])) { + shorthands[arg] = shorthands[arg].split(/\s+/) + } + + return shorthands[arg] + } + + // first check to see if this arg is a set of single-char shorthands + var singles = shorthands.___singles + if (!singles) { + singles = Object.keys(shorthands).filter(function (s) { + return s.length === 1 + }).reduce(function (l, r) { + l[r] = true + return l + }, {}) + shorthands.___singles = singles + debug('shorthand singles', singles) + } + + var chrs = arg.split('').filter(function (c) { + return singles[c] + }) + + if (chrs.join('') === arg) { + return chrs.map(function (c) { + return shorthands[c] + }).reduce(function (l, r) { + return l.concat(r) + }, []) + } + + // if it's an arg abbrev, and not a literal shorthand, then prefer the arg + if (abbrevs[arg] && !shorthands[arg]) { + return null + } + + // if it's an abbr for a shorthand, then use that + if (shortAbbr[arg]) { + arg = shortAbbr[arg] + } + + // make it an array, if it's a list of words + if (shorthands[arg] && !Array.isArray(shorthands[arg])) { + shorthands[arg] = shorthands[arg].split(/\s+/) + } + + return shorthands[arg] +} diff --git a/node_modules/node-gyp/node_modules/nopt/package.json b/node_modules/node-gyp/node_modules/nopt/package.json new file mode 100644 index 0000000000000..a3cd13d8c714b --- /dev/null +++ b/node_modules/node-gyp/node_modules/nopt/package.json @@ -0,0 +1,53 @@ +{ + "name": "nopt", + "version": "6.0.0", + "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", + "author": "GitHub Inc.", + "main": "lib/nopt.js", + "scripts": { + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags", + "test": "tap", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run lint -- --fix", + "snap": "tap", + "posttest": "npm run lint" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/nopt.git" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "license": "ISC", + "dependencies": { + "abbrev": "^1.0.0" + }, + "devDependencies": { + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.5.0", + "tap": "^16.3.0" + }, + "tap": { + "lines": 87, + "functions": 91, + "branches": 81, + "statements": 87 + }, + "files": [ + "bin/", + "lib/" + ], + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "windowsCI": false, + "version": "3.5.0" + } +} diff --git a/node_modules/nopt/node_modules/abbrev/LICENSE b/node_modules/nopt/node_modules/abbrev/LICENSE new file mode 100644 index 0000000000000..9bcfa9d7d8d26 --- /dev/null +++ b/node_modules/nopt/node_modules/abbrev/LICENSE @@ -0,0 +1,46 @@ +This software is dual-licensed under the ISC and MIT licenses. +You may use this software under EITHER of the following licenses. + +---------- + +The ISC License + +Copyright (c) Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +---------- + +Copyright Isaac Z. Schlueter and Contributors +All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/nopt/node_modules/abbrev/lib/index.js b/node_modules/nopt/node_modules/abbrev/lib/index.js new file mode 100644 index 0000000000000..9f48801f049c9 --- /dev/null +++ b/node_modules/nopt/node_modules/abbrev/lib/index.js @@ -0,0 +1,50 @@ +module.exports = abbrev + +function abbrev (...args) { + let list = args.length === 1 || Array.isArray(args[0]) ? args[0] : args + + for (let i = 0, l = list.length; i < l; i++) { + list[i] = typeof list[i] === 'string' ? list[i] : String(list[i]) + } + + // sort them lexicographically, so that they're next to their nearest kin + list = list.sort(lexSort) + + // walk through each, seeing how much it has in common with the next and previous + const abbrevs = {} + let prev = '' + for (let ii = 0, ll = list.length; ii < ll; ii++) { + const current = list[ii] + const next = list[ii + 1] || '' + let nextMatches = true + let prevMatches = true + if (current === next) { + continue + } + let j = 0 + const cl = current.length + for (; j < cl; j++) { + const curChar = current.charAt(j) + nextMatches = nextMatches && curChar === next.charAt(j) + prevMatches = prevMatches && curChar === prev.charAt(j) + if (!nextMatches && !prevMatches) { + j++ + break + } + } + prev = current + if (j === cl) { + abbrevs[current] = current + continue + } + for (let a = current.slice(0, j); j <= cl; j++) { + abbrevs[a] = current + a += current.charAt(j) + } + } + return abbrevs +} + +function lexSort (a, b) { + return a === b ? 0 : a > b ? 1 : -1 +} diff --git a/node_modules/nopt/node_modules/abbrev/package.json b/node_modules/nopt/node_modules/abbrev/package.json new file mode 100644 index 0000000000000..e26400445631a --- /dev/null +++ b/node_modules/nopt/node_modules/abbrev/package.json @@ -0,0 +1,43 @@ +{ + "name": "abbrev", + "version": "2.0.0", + "description": "Like ruby's abbrev module, but in js", + "author": "GitHub Inc.", + "main": "lib/index.js", + "scripts": { + "test": "tap", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run lint -- --fix", + "snap": "tap", + "posttest": "npm run lint" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/abbrev-js.git" + }, + "license": "ISC", + "devDependencies": { + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.8.0", + "tap": "^16.3.0" + }, + "tap": { + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] + }, + "files": [ + "bin/", + "lib/" + ], + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "4.8.0" + } +} diff --git a/node_modules/nopt/package.json b/node_modules/nopt/package.json index a3cd13d8c714b..f12fb3374b322 100644 --- a/node_modules/nopt/package.json +++ b/node_modules/nopt/package.json @@ -1,13 +1,10 @@ { "name": "nopt", - "version": "6.0.0", + "version": "7.0.0", "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", "author": "GitHub Inc.", "main": "lib/nopt.js", "scripts": { - "preversion": "npm test", - "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags", "test": "tap", "lint": "eslint \"**/*.js\"", "postlint": "template-oss-check", @@ -25,29 +22,33 @@ }, "license": "ISC", "dependencies": { - "abbrev": "^1.0.0" + "abbrev": "^2.0.0" }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "3.5.0", + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.8.0", "tap": "^16.3.0" }, "tap": { "lines": 87, "functions": 91, "branches": 81, - "statements": 87 + "statements": 87, + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] }, "files": [ "bin/", "lib/" ], "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", "windowsCI": false, - "version": "3.5.0" + "version": "4.8.0" } } diff --git a/package-lock.json b/package-lock.json index c61a7e1fc383e..7085397e01c5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -126,7 +126,7 @@ "mkdirp": "^1.0.4", "ms": "^2.1.2", "node-gyp": "^9.3.0", - "nopt": "^6.0.0", + "nopt": "^7.0.0", "npm-audit-report": "^4.0.0", "npm-install-checks": "^6.0.0", "npm-package-arg": "^10.0.0", @@ -7261,6 +7261,21 @@ "encoding": "^0.1.13" } }, + "node_modules/licensee/node_modules/nopt": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz", + "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==", + "dev": true, + "dependencies": { + "abbrev": "^1.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, "node_modules/licensee/node_modules/normalize-package-data": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-4.0.1.tgz", @@ -8441,6 +8456,21 @@ "encoding": "^0.1.13" } }, + "node_modules/node-gyp/node_modules/nopt": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz", + "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==", + "inBundle": true, + "dependencies": { + "abbrev": "^1.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, "node_modules/node-gyp/node_modules/npmlog": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", @@ -8536,17 +8566,27 @@ "dev": true }, "node_modules/nopt": { - "version": "6.0.0", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.0.0.tgz", + "integrity": "sha512-e6Qw1rcrGoSxEH0hQ4GBSdUjkMOtXGhGFXdNT/3ZR0S37eR9DMj5za3dEDWE6o1T3/DP8ZOsPP4MIiky0c3QeA==", "inBundle": true, - "license": "ISC", "dependencies": { - "abbrev": "^1.0.0" + "abbrev": "^2.0.0" }, "bin": { "nopt": "bin/nopt.js" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/nopt/node_modules/abbrev": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", + "integrity": "sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==", + "inBundle": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, "node_modules/normalize-package-data": { @@ -13970,7 +14010,7 @@ "json-parse-even-better-errors": "^3.0.0", "json-stringify-nice": "^1.1.4", "minimatch": "^5.1.0", - "nopt": "^6.0.0", + "nopt": "^7.0.0", "npm-install-checks": "^6.0.0", "npm-package-arg": "^10.0.0", "npm-pick-manifest": "^8.0.1", @@ -14012,7 +14052,7 @@ "dependencies": { "@npmcli/map-workspaces": "^3.0.0", "ini": "^3.0.0", - "nopt": "^6.0.0", + "nopt": "^7.0.0", "proc-log": "^3.0.0", "read-package-json-fast": "^3.0.0", "semver": "^7.3.5", diff --git a/package.json b/package.json index 278128cebfee0..ec378fdecf4be 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "mkdirp": "^1.0.4", "ms": "^2.1.2", "node-gyp": "^9.3.0", - "nopt": "^6.0.0", + "nopt": "^7.0.0", "npm-audit-report": "^4.0.0", "npm-install-checks": "^6.0.0", "npm-package-arg": "^10.0.0", diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index 7bdfbb6d6c313..e665b98783322 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -20,7 +20,7 @@ "json-parse-even-better-errors": "^3.0.0", "json-stringify-nice": "^1.1.4", "minimatch": "^5.1.0", - "nopt": "^6.0.0", + "nopt": "^7.0.0", "npm-install-checks": "^6.0.0", "npm-package-arg": "^10.0.0", "npm-pick-manifest": "^8.0.1", diff --git a/workspaces/config/package.json b/workspaces/config/package.json index b9f41d29bd3f8..76998ae09409d 100644 --- a/workspaces/config/package.json +++ b/workspaces/config/package.json @@ -39,7 +39,7 @@ "dependencies": { "@npmcli/map-workspaces": "^3.0.0", "ini": "^3.0.0", - "nopt": "^6.0.0", + "nopt": "^7.0.0", "proc-log": "^3.0.0", "read-package-json-fast": "^3.0.0", "semver": "^7.3.5", From d399798e3a7c20461d96e5eb486f63f1001d743f Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 2 Nov 2022 09:31:50 -0700 Subject: [PATCH 4/7] deps: abbrev@2.0.0 --- node_modules/.gitignore | 4 +- .../node_modules => }/abbrev/lib/index.js | 0 node_modules/abbrev/package.json | 44 ++++++++++++++----- .../node_modules/abbrev/LICENSE | 0 .../node_modules}/abbrev/abbrev.js | 0 .../node-gyp/node_modules/abbrev/package.json | 21 +++++++++ .../nopt/node_modules/abbrev/package.json | 43 ------------------ package-lock.json | 31 ++++++++----- package.json | 2 +- 9 files changed, 75 insertions(+), 70 deletions(-) rename node_modules/{nopt/node_modules => }/abbrev/lib/index.js (100%) rename node_modules/{nopt => node-gyp}/node_modules/abbrev/LICENSE (100%) rename node_modules/{ => node-gyp/node_modules}/abbrev/abbrev.js (100%) create mode 100644 node_modules/node-gyp/node_modules/abbrev/package.json delete mode 100644 node_modules/nopt/node_modules/abbrev/package.json diff --git a/node_modules/.gitignore b/node_modules/.gitignore index 74070a54532d0..b1752b46d3b5e 100644 --- a/node_modules/.gitignore +++ b/node_modules/.gitignore @@ -157,6 +157,7 @@ /node-gyp/node_modules/@npmcli/* !/node-gyp/node_modules/@npmcli/fs !/node-gyp/node_modules/@npmcli/move-file +!/node-gyp/node_modules/abbrev !/node-gyp/node_modules/are-we-there-yet !/node-gyp/node_modules/brace-expansion !/node-gyp/node_modules/cacache @@ -177,9 +178,6 @@ !/node-gyp/node_modules/unique-slug !/node-gyp/node_modules/which !/nopt -!/nopt/node_modules/ -/nopt/node_modules/* -!/nopt/node_modules/abbrev !/normalize-package-data !/npm-audit-report !/npm-bundled diff --git a/node_modules/nopt/node_modules/abbrev/lib/index.js b/node_modules/abbrev/lib/index.js similarity index 100% rename from node_modules/nopt/node_modules/abbrev/lib/index.js rename to node_modules/abbrev/lib/index.js diff --git a/node_modules/abbrev/package.json b/node_modules/abbrev/package.json index bf4e8015bba9d..e26400445631a 100644 --- a/node_modules/abbrev/package.json +++ b/node_modules/abbrev/package.json @@ -1,21 +1,43 @@ { "name": "abbrev", - "version": "1.1.1", + "version": "2.0.0", "description": "Like ruby's abbrev module, but in js", - "author": "Isaac Z. Schlueter ", - "main": "abbrev.js", + "author": "GitHub Inc.", + "main": "lib/index.js", "scripts": { - "test": "tap test.js --100", - "preversion": "npm test", - "postversion": "npm publish", - "postpublish": "git push origin --all; git push origin --tags" + "test": "tap", + "lint": "eslint \"**/*.js\"", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force", + "lintfix": "npm run lint -- --fix", + "snap": "tap", + "posttest": "npm run lint" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/abbrev-js.git" }, - "repository": "http://github.com/isaacs/abbrev-js", "license": "ISC", "devDependencies": { - "tap": "^10.1" + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.8.0", + "tap": "^16.3.0" + }, + "tap": { + "nyc-arg": [ + "--exclude", + "tap-snapshots/**" + ] }, "files": [ - "abbrev.js" - ] + "bin/", + "lib/" + ], + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "4.8.0" + } } diff --git a/node_modules/nopt/node_modules/abbrev/LICENSE b/node_modules/node-gyp/node_modules/abbrev/LICENSE similarity index 100% rename from node_modules/nopt/node_modules/abbrev/LICENSE rename to node_modules/node-gyp/node_modules/abbrev/LICENSE diff --git a/node_modules/abbrev/abbrev.js b/node_modules/node-gyp/node_modules/abbrev/abbrev.js similarity index 100% rename from node_modules/abbrev/abbrev.js rename to node_modules/node-gyp/node_modules/abbrev/abbrev.js diff --git a/node_modules/node-gyp/node_modules/abbrev/package.json b/node_modules/node-gyp/node_modules/abbrev/package.json new file mode 100644 index 0000000000000..bf4e8015bba9d --- /dev/null +++ b/node_modules/node-gyp/node_modules/abbrev/package.json @@ -0,0 +1,21 @@ +{ + "name": "abbrev", + "version": "1.1.1", + "description": "Like ruby's abbrev module, but in js", + "author": "Isaac Z. Schlueter ", + "main": "abbrev.js", + "scripts": { + "test": "tap test.js --100", + "preversion": "npm test", + "postversion": "npm publish", + "postpublish": "git push origin --all; git push origin --tags" + }, + "repository": "http://github.com/isaacs/abbrev-js", + "license": "ISC", + "devDependencies": { + "tap": "^10.1" + }, + "files": [ + "abbrev.js" + ] +} diff --git a/node_modules/nopt/node_modules/abbrev/package.json b/node_modules/nopt/node_modules/abbrev/package.json deleted file mode 100644 index e26400445631a..0000000000000 --- a/node_modules/nopt/node_modules/abbrev/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "abbrev", - "version": "2.0.0", - "description": "Like ruby's abbrev module, but in js", - "author": "GitHub Inc.", - "main": "lib/index.js", - "scripts": { - "test": "tap", - "lint": "eslint \"**/*.js\"", - "postlint": "template-oss-check", - "template-oss-apply": "template-oss-apply --force", - "lintfix": "npm run lint -- --fix", - "snap": "tap", - "posttest": "npm run lint" - }, - "repository": { - "type": "git", - "url": "https://github.com/npm/abbrev-js.git" - }, - "license": "ISC", - "devDependencies": { - "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.8.0", - "tap": "^16.3.0" - }, - "tap": { - "nyc-arg": [ - "--exclude", - "tap-snapshots/**" - ] - }, - "files": [ - "bin/", - "lib/" - ], - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - }, - "templateOSS": { - "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.8.0" - } -} diff --git a/package-lock.json b/package-lock.json index 7085397e01c5a..71097c2adf8fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,7 +92,7 @@ "@npmcli/map-workspaces": "^3.0.0", "@npmcli/package-json": "^3.0.0", "@npmcli/run-script": "^6.0.0", - "abbrev": "~1.1.1", + "abbrev": "^2.0.0", "archy": "~1.0.0", "cacache": "^17.0.1", "chalk": "^4.1.2", @@ -2564,9 +2564,13 @@ "dev": true }, "node_modules/abbrev": { - "version": "1.1.1", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", + "integrity": "sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==", "inBundle": true, - "license": "ISC" + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } }, "node_modules/abort-controller": { "version": "3.0.0", @@ -7088,6 +7092,12 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/licensee/node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "dev": true + }, "node_modules/licensee/node_modules/are-we-there-yet": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", @@ -8272,6 +8282,12 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/node-gyp/node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "inBundle": true + }, "node_modules/node-gyp/node_modules/are-we-there-yet": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", @@ -8580,15 +8596,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/nopt/node_modules/abbrev": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", - "integrity": "sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==", - "inBundle": true, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, "node_modules/normalize-package-data": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-5.0.0.tgz", diff --git a/package.json b/package.json index ec378fdecf4be..dbf6a0cb89d74 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@npmcli/map-workspaces": "^3.0.0", "@npmcli/package-json": "^3.0.0", "@npmcli/run-script": "^6.0.0", - "abbrev": "~1.1.1", + "abbrev": "^2.0.0", "archy": "~1.0.0", "cacache": "^17.0.1", "chalk": "^4.1.2", From f06c077495ee09cb73a46cd7694f855d94d1cabc Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 2 Nov 2022 09:36:40 -0700 Subject: [PATCH 5/7] deps: @npmcli/ci-detect@3.0.1 --- node_modules/@npmcli/ci-detect/package.json | 8 ++++---- package-lock.json | 9 +++++---- package.json | 2 +- workspaces/libnpmexec/package.json | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/node_modules/@npmcli/ci-detect/package.json b/node_modules/@npmcli/ci-detect/package.json index eaf1a3a286429..4be4b65fe671f 100644 --- a/node_modules/@npmcli/ci-detect/package.json +++ b/node_modules/@npmcli/ci-detect/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/ci-detect", - "version": "3.0.0", + "version": "3.0.1", "description": "Detect what kind of CI environment the program is in", "author": "GitHub Inc.", "license": "ISC", @@ -22,8 +22,8 @@ ] }, "devDependencies": { - "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "4.4.4", + "@npmcli/eslint-config": "^4.0.0", + "@npmcli/template-oss": "4.6.2", "tap": "^16.0.1" }, "files": [ @@ -39,6 +39,6 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.4.4" + "version": "4.6.2" } } diff --git a/package-lock.json b/package-lock.json index 71097c2adf8fe..f210200f5c22a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -87,7 +87,7 @@ "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^6.1.0", - "@npmcli/ci-detect": "^3.0.0", + "@npmcli/ci-detect": "^3.0.1", "@npmcli/config": "^6.0.1", "@npmcli/map-workspaces": "^3.0.0", "@npmcli/package-json": "^3.0.0", @@ -2042,9 +2042,10 @@ "link": true }, "node_modules/@npmcli/ci-detect": { - "version": "3.0.0", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/ci-detect/-/ci-detect-3.0.1.tgz", + "integrity": "sha512-zQ/qTg2eWnGDToPZH5n7FggNlGC2OYWl6TZv/kDZrTttpm3y2bBcybXSIjlr1ne/ecVp4/vmRNxZP7qTMZo90g==", "inBundle": true, - "license": "ISC", "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } @@ -14119,7 +14120,7 @@ "license": "ISC", "dependencies": { "@npmcli/arborist": "^6.1.0", - "@npmcli/ci-detect": "^3.0.0", + "@npmcli/ci-detect": "^3.0.1", "@npmcli/run-script": "^6.0.0", "chalk": "^4.1.0", "npm-package-arg": "^10.0.0", diff --git a/package.json b/package.json index dbf6a0cb89d74..9980c5b8ec65e 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^6.1.0", - "@npmcli/ci-detect": "^3.0.0", + "@npmcli/ci-detect": "^3.0.1", "@npmcli/config": "^6.0.1", "@npmcli/map-workspaces": "^3.0.0", "@npmcli/package-json": "^3.0.0", diff --git a/workspaces/libnpmexec/package.json b/workspaces/libnpmexec/package.json index d3c8a4bb4c61a..0d9a1debb1414 100644 --- a/workspaces/libnpmexec/package.json +++ b/workspaces/libnpmexec/package.json @@ -59,7 +59,7 @@ }, "dependencies": { "@npmcli/arborist": "^6.1.0", - "@npmcli/ci-detect": "^3.0.0", + "@npmcli/ci-detect": "^3.0.1", "@npmcli/run-script": "^6.0.0", "chalk": "^4.1.0", "npm-package-arg": "^10.0.0", From ad8626e39cec828925644984543bff4e29fa55e4 Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 2 Nov 2022 09:39:34 -0700 Subject: [PATCH 6/7] deps: fastest-levenshtein@1.0.16 --- node_modules/fastest-levenshtein/bench.js | 96 ++++++++++++ node_modules/fastest-levenshtein/esm/mod.d.ts | 4 + .../fastest-levenshtein/esm/mod.d.ts.map | 1 + node_modules/fastest-levenshtein/esm/mod.js | 138 ++++++++++++++++ node_modules/fastest-levenshtein/index.d.ts | 2 - node_modules/fastest-levenshtein/index.js | 147 ------------------ node_modules/fastest-levenshtein/mod.d.ts | 3 + node_modules/fastest-levenshtein/mod.js | 142 +++++++++++++++++ node_modules/fastest-levenshtein/package.json | 43 +++-- node_modules/fastest-levenshtein/test.js | 113 +++++++------- node_modules/fastest-levenshtein/test.ts | 67 ++++++++ package-lock.json | 10 +- package.json | 2 +- 13 files changed, 537 insertions(+), 231 deletions(-) create mode 100644 node_modules/fastest-levenshtein/bench.js create mode 100644 node_modules/fastest-levenshtein/esm/mod.d.ts create mode 100644 node_modules/fastest-levenshtein/esm/mod.d.ts.map create mode 100644 node_modules/fastest-levenshtein/esm/mod.js delete mode 100644 node_modules/fastest-levenshtein/index.d.ts delete mode 100644 node_modules/fastest-levenshtein/index.js create mode 100644 node_modules/fastest-levenshtein/mod.d.ts create mode 100644 node_modules/fastest-levenshtein/mod.js create mode 100644 node_modules/fastest-levenshtein/test.ts diff --git a/node_modules/fastest-levenshtein/bench.js b/node_modules/fastest-levenshtein/bench.js new file mode 100644 index 0000000000000..1fd420bd737e8 --- /dev/null +++ b/node_modules/fastest-levenshtein/bench.js @@ -0,0 +1,96 @@ +"use strict"; +exports.__esModule = true; +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable no-console */ +var Benchmark = require("benchmark"); +var mod_js_1 = require("./mod.js"); +var fast_levenshtein_1 = require("fast-levenshtein"); +var fs = require("fs"); +var jslevenshtein = require("js-levenshtein"); +var leven = require("leven"); +var levenshteinEditDistance = require("levenshtein-edit-distance"); +var suite = new Benchmark.Suite(); +var randomstring = function (length) { + var result = ""; + var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + var charactersLength = characters.length; + for (var i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +}; +var randomstringArr = function (stringSize, arraySize) { + var i = 0; + var arr = []; + for (i = 0; i < arraySize; i++) { + arr.push(randomstring(stringSize)); + } + return arr; +}; +var arrSize = 1000; +if (!fs.existsSync("data.json")) { + var data_1 = [ + randomstringArr(4, arrSize), + randomstringArr(8, arrSize), + randomstringArr(16, arrSize), + randomstringArr(32, arrSize), + randomstringArr(64, arrSize), + randomstringArr(128, arrSize), + randomstringArr(256, arrSize), + randomstringArr(512, arrSize), + randomstringArr(1024, arrSize), + ]; + fs.writeFileSync("data.json", JSON.stringify(data_1)); +} +var data = JSON.parse(fs.readFileSync("data.json", "utf8")); +var _loop_1 = function (i) { + var datapick = data[i]; + if (process.argv[2] !== "no") { + suite + .add("".concat(i, " - js-levenshtein"), function () { + for (var j = 0; j < arrSize - 1; j += 2) { + jslevenshtein(datapick[j], datapick[j + 1]); + } + }) + .add("".concat(i, " - leven"), function () { + for (var j = 0; j < arrSize - 1; j += 2) { + leven(datapick[j], datapick[j + 1]); + } + }) + .add("".concat(i, " - fast-levenshtein"), function () { + for (var j = 0; j < arrSize - 1; j += 2) { + (0, fast_levenshtein_1.get)(datapick[j], datapick[j + 1]); + } + }) + .add("".concat(i, " - levenshtein-edit-distance"), function () { + for (var j = 0; j < arrSize - 1; j += 2) { + levenshteinEditDistance(datapick[j], datapick[j + 1]); + } + }); + } + suite.add("".concat(i, " - fastest-levenshtein"), function () { + for (var j = 0; j < arrSize - 1; j += 2) { + (0, mod_js_1.distance)(datapick[j], datapick[j + 1]); + } + }); +}; +// BENCHMARKS +for (var i = 0; i < 9; i++) { + _loop_1(i); +} +var results = new Map(); +suite + .on("cycle", function (event) { + console.log(String(event.target)); + if (results.has(event.target.name[0])) { + results.get(event.target.name[0]).push(event.target.hz); + } + else { + results.set(event.target.name[0], [event.target.hz]); + } +}) + .on("complete", function () { + console.log(results); +}) + // run async + .run({ async: true }); diff --git a/node_modules/fastest-levenshtein/esm/mod.d.ts b/node_modules/fastest-levenshtein/esm/mod.d.ts new file mode 100644 index 0000000000000..50927ef500580 --- /dev/null +++ b/node_modules/fastest-levenshtein/esm/mod.d.ts @@ -0,0 +1,4 @@ +declare const distance: (a: string, b: string) => number; +declare const closest: (str: string, arr: readonly string[]) => string; +export { closest, distance }; +//# sourceMappingURL=mod.d.ts.map \ No newline at end of file diff --git a/node_modules/fastest-levenshtein/esm/mod.d.ts.map b/node_modules/fastest-levenshtein/esm/mod.d.ts.map new file mode 100644 index 0000000000000..7fd5c175637b3 --- /dev/null +++ b/node_modules/fastest-levenshtein/esm/mod.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../mod.ts"],"names":[],"mappings":"AAiHA,QAAA,MAAM,QAAQ,MAAO,MAAM,KAAK,MAAM,KAAG,MAaxC,CAAC;AAEF,QAAA,MAAM,OAAO,QAAS,MAAM,OAAO,SAAS,MAAM,EAAE,KAAG,MAWtD,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/fastest-levenshtein/esm/mod.js b/node_modules/fastest-levenshtein/esm/mod.js new file mode 100644 index 0000000000000..719f2b8fdade9 --- /dev/null +++ b/node_modules/fastest-levenshtein/esm/mod.js @@ -0,0 +1,138 @@ +const peq = new Uint32Array(0x10000); +const myers_32 = (a, b) => { + const n = a.length; + const m = b.length; + const lst = 1 << (n - 1); + let pv = -1; + let mv = 0; + let sc = n; + let i = n; + while (i--) { + peq[a.charCodeAt(i)] |= 1 << i; + } + for (i = 0; i < m; i++) { + let eq = peq[b.charCodeAt(i)]; + const xv = eq | mv; + eq |= ((eq & pv) + pv) ^ pv; + mv |= ~(eq | pv); + pv &= eq; + if (mv & lst) { + sc++; + } + if (pv & lst) { + sc--; + } + mv = (mv << 1) | 1; + pv = (pv << 1) | ~(xv | mv); + mv &= xv; + } + i = n; + while (i--) { + peq[a.charCodeAt(i)] = 0; + } + return sc; +}; +const myers_x = (b, a) => { + const n = a.length; + const m = b.length; + const mhc = []; + const phc = []; + const hsize = Math.ceil(n / 32); + const vsize = Math.ceil(m / 32); + for (let i = 0; i < hsize; i++) { + phc[i] = -1; + mhc[i] = 0; + } + let j = 0; + for (; j < vsize - 1; j++) { + let mv = 0; + let pv = -1; + const start = j * 32; + const vlen = Math.min(32, m) + start; + for (let k = start; k < vlen; k++) { + peq[b.charCodeAt(k)] |= 1 << k; + } + for (let i = 0; i < n; i++) { + const eq = peq[a.charCodeAt(i)]; + const pb = (phc[(i / 32) | 0] >>> i) & 1; + const mb = (mhc[(i / 32) | 0] >>> i) & 1; + const xv = eq | mv; + const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb; + let ph = mv | ~(xh | pv); + let mh = pv & xh; + if ((ph >>> 31) ^ pb) { + phc[(i / 32) | 0] ^= 1 << i; + } + if ((mh >>> 31) ^ mb) { + mhc[(i / 32) | 0] ^= 1 << i; + } + ph = (ph << 1) | pb; + mh = (mh << 1) | mb; + pv = mh | ~(xv | ph); + mv = ph & xv; + } + for (let k = start; k < vlen; k++) { + peq[b.charCodeAt(k)] = 0; + } + } + let mv = 0; + let pv = -1; + const start = j * 32; + const vlen = Math.min(32, m - start) + start; + for (let k = start; k < vlen; k++) { + peq[b.charCodeAt(k)] |= 1 << k; + } + let score = m; + for (let i = 0; i < n; i++) { + const eq = peq[a.charCodeAt(i)]; + const pb = (phc[(i / 32) | 0] >>> i) & 1; + const mb = (mhc[(i / 32) | 0] >>> i) & 1; + const xv = eq | mv; + const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb; + let ph = mv | ~(xh | pv); + let mh = pv & xh; + score += (ph >>> (m - 1)) & 1; + score -= (mh >>> (m - 1)) & 1; + if ((ph >>> 31) ^ pb) { + phc[(i / 32) | 0] ^= 1 << i; + } + if ((mh >>> 31) ^ mb) { + mhc[(i / 32) | 0] ^= 1 << i; + } + ph = (ph << 1) | pb; + mh = (mh << 1) | mb; + pv = mh | ~(xv | ph); + mv = ph & xv; + } + for (let k = start; k < vlen; k++) { + peq[b.charCodeAt(k)] = 0; + } + return score; +}; +const distance = (a, b) => { + if (a.length < b.length) { + const tmp = b; + b = a; + a = tmp; + } + if (b.length === 0) { + return a.length; + } + if (a.length <= 32) { + return myers_32(a, b); + } + return myers_x(a, b); +}; +const closest = (str, arr) => { + let min_distance = Infinity; + let min_index = 0; + for (let i = 0; i < arr.length; i++) { + const dist = distance(str, arr[i]); + if (dist < min_distance) { + min_distance = dist; + min_index = i; + } + } + return arr[min_index]; +}; +export { closest, distance }; diff --git a/node_modules/fastest-levenshtein/index.d.ts b/node_modules/fastest-levenshtein/index.d.ts deleted file mode 100644 index bdc2bb1cc32e0..0000000000000 --- a/node_modules/fastest-levenshtein/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export function distance(a: string, b: string): number; -export function closest(str: string, arr: string[]): string; \ No newline at end of file diff --git a/node_modules/fastest-levenshtein/index.js b/node_modules/fastest-levenshtein/index.js deleted file mode 100644 index 437bdebfda388..0000000000000 --- a/node_modules/fastest-levenshtein/index.js +++ /dev/null @@ -1,147 +0,0 @@ -"use strict"; -const peq = new Uint32Array(0x10000); -const myers_32 = (a, b) => { - const n = a.length; - const m = b.length; - const lst = 1 << (n - 1); - let pv = -1; - let mv = 0; - let sc = n; - let i = n; - while (i--) { - peq[a.charCodeAt(i)] |= 1 << i; - } - for (i = 0; i < m; i++) { - let eq = peq[b.charCodeAt(i)]; - const xv = eq | mv; - eq |= ((eq & pv) + pv) ^ pv; - mv |= ~(eq | pv); - pv &= eq; - if (mv & lst) { - sc++; - } - if (pv & lst) { - sc--; - } - mv = (mv << 1) | 1; - pv = (pv << 1) | ~(xv | mv); - mv &= xv; - } - i = n; - while (i--) { - peq[a.charCodeAt(i)] = 0; - } - return sc; -}; - -const myers_x = (a, b) => { - const n = a.length; - const m = b.length; - const mhc = []; - const phc = []; - const hsize = Math.ceil(n / 32); - const vsize = Math.ceil(m / 32); - let score = m; - for (let i = 0; i < hsize; i++) { - phc[i] = -1; - mhc[i] = 0; - } - let j = 0; - for (; j < vsize - 1; j++) { - let mv = 0; - let pv = -1; - const start = j * 32; - const end = Math.min(32, m) + start; - for (let k = start; k < end; k++) { - peq[b.charCodeAt(k)] |= 1 << k; - } - score = m; - for (let i = 0; i < n; i++) { - const eq = peq[a.charCodeAt(i)]; - const pb = (phc[(i / 32) | 0] >>> i) & 1; - const mb = (mhc[(i / 32) | 0] >>> i) & 1; - const xv = eq | mv; - const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb; - let ph = mv | ~(xh | pv); - let mh = pv & xh; - if ((ph >>> 31) ^ pb) { - phc[(i / 32) | 0] ^= 1 << i; - } - if ((mh >>> 31) ^ mb) { - mhc[(i / 32) | 0] ^= 1 << i; - } - ph = (ph << 1) | pb; - mh = (mh << 1) | mb; - pv = mh | ~(xv | ph); - mv = ph & xv; - } - for (let k = start; k < end; k++) { - peq[b.charCodeAt(k)] = 0; - } - } - let mv = 0; - let pv = -1; - const start = j * 32; - const end = Math.min(32, m - start) + start; - for (let k = start; k < end; k++) { - peq[b.charCodeAt(k)] |= 1 << k; - } - score = m; - for (let i = 0; i < n; i++) { - const eq = peq[a.charCodeAt(i)]; - const pb = (phc[(i / 32) | 0] >>> i) & 1; - const mb = (mhc[(i / 32) | 0] >>> i) & 1; - const xv = eq | mv; - const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb; - let ph = mv | ~(xh | pv); - let mh = pv & xh; - score += (ph >>> (m - 1)) & 1; - score -= (mh >>> (m - 1)) & 1; - if ((ph >>> 31) ^ pb) { - phc[(i / 32) | 0] ^= 1 << i; - } - if ((mh >>> 31) ^ mb) { - mhc[(i / 32) | 0] ^= 1 << i; - } - ph = (ph << 1) | pb; - mh = (mh << 1) | mb; - pv = mh | ~(xv | ph); - mv = ph & xv; - } - for (let k = start; k < end; k++) { - peq[b.charCodeAt(k)] = 0; - } - return score; -}; - -const distance = (a, b) => { - if (a.length > b.length) { - const tmp = b; - b = a; - a = tmp; - } - if (a.length === 0) { - return b.length; - } - if (a.length <= 32) { - return myers_32(a, b); - } - return myers_x(a, b); -}; - -const closest = (str, arr) => { - let min_distance = Infinity; - let min_index = 0; - for (let i = 0; i < arr.length; i++) { - const dist = distance(str, arr[i]); - if (dist < min_distance) { - min_distance = dist; - min_index = i; - } - } - return arr[min_index]; -}; - -module.exports = { - closest, distance -} diff --git a/node_modules/fastest-levenshtein/mod.d.ts b/node_modules/fastest-levenshtein/mod.d.ts new file mode 100644 index 0000000000000..b1b5ce7f7de95 --- /dev/null +++ b/node_modules/fastest-levenshtein/mod.d.ts @@ -0,0 +1,3 @@ +declare const distance: (a: string, b: string) => number; +declare const closest: (str: string, arr: readonly string[]) => string; +export { closest, distance }; diff --git a/node_modules/fastest-levenshtein/mod.js b/node_modules/fastest-levenshtein/mod.js new file mode 100644 index 0000000000000..6bc27459399e6 --- /dev/null +++ b/node_modules/fastest-levenshtein/mod.js @@ -0,0 +1,142 @@ +"use strict"; +exports.__esModule = true; +exports.distance = exports.closest = void 0; +var peq = new Uint32Array(0x10000); +var myers_32 = function (a, b) { + var n = a.length; + var m = b.length; + var lst = 1 << (n - 1); + var pv = -1; + var mv = 0; + var sc = n; + var i = n; + while (i--) { + peq[a.charCodeAt(i)] |= 1 << i; + } + for (i = 0; i < m; i++) { + var eq = peq[b.charCodeAt(i)]; + var xv = eq | mv; + eq |= ((eq & pv) + pv) ^ pv; + mv |= ~(eq | pv); + pv &= eq; + if (mv & lst) { + sc++; + } + if (pv & lst) { + sc--; + } + mv = (mv << 1) | 1; + pv = (pv << 1) | ~(xv | mv); + mv &= xv; + } + i = n; + while (i--) { + peq[a.charCodeAt(i)] = 0; + } + return sc; +}; +var myers_x = function (b, a) { + var n = a.length; + var m = b.length; + var mhc = []; + var phc = []; + var hsize = Math.ceil(n / 32); + var vsize = Math.ceil(m / 32); + for (var i = 0; i < hsize; i++) { + phc[i] = -1; + mhc[i] = 0; + } + var j = 0; + for (; j < vsize - 1; j++) { + var mv_1 = 0; + var pv_1 = -1; + var start_1 = j * 32; + var vlen_1 = Math.min(32, m) + start_1; + for (var k = start_1; k < vlen_1; k++) { + peq[b.charCodeAt(k)] |= 1 << k; + } + for (var i = 0; i < n; i++) { + var eq = peq[a.charCodeAt(i)]; + var pb = (phc[(i / 32) | 0] >>> i) & 1; + var mb = (mhc[(i / 32) | 0] >>> i) & 1; + var xv = eq | mv_1; + var xh = ((((eq | mb) & pv_1) + pv_1) ^ pv_1) | eq | mb; + var ph = mv_1 | ~(xh | pv_1); + var mh = pv_1 & xh; + if ((ph >>> 31) ^ pb) { + phc[(i / 32) | 0] ^= 1 << i; + } + if ((mh >>> 31) ^ mb) { + mhc[(i / 32) | 0] ^= 1 << i; + } + ph = (ph << 1) | pb; + mh = (mh << 1) | mb; + pv_1 = mh | ~(xv | ph); + mv_1 = ph & xv; + } + for (var k = start_1; k < vlen_1; k++) { + peq[b.charCodeAt(k)] = 0; + } + } + var mv = 0; + var pv = -1; + var start = j * 32; + var vlen = Math.min(32, m - start) + start; + for (var k = start; k < vlen; k++) { + peq[b.charCodeAt(k)] |= 1 << k; + } + var score = m; + for (var i = 0; i < n; i++) { + var eq = peq[a.charCodeAt(i)]; + var pb = (phc[(i / 32) | 0] >>> i) & 1; + var mb = (mhc[(i / 32) | 0] >>> i) & 1; + var xv = eq | mv; + var xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb; + var ph = mv | ~(xh | pv); + var mh = pv & xh; + score += (ph >>> (m - 1)) & 1; + score -= (mh >>> (m - 1)) & 1; + if ((ph >>> 31) ^ pb) { + phc[(i / 32) | 0] ^= 1 << i; + } + if ((mh >>> 31) ^ mb) { + mhc[(i / 32) | 0] ^= 1 << i; + } + ph = (ph << 1) | pb; + mh = (mh << 1) | mb; + pv = mh | ~(xv | ph); + mv = ph & xv; + } + for (var k = start; k < vlen; k++) { + peq[b.charCodeAt(k)] = 0; + } + return score; +}; +var distance = function (a, b) { + if (a.length < b.length) { + var tmp = b; + b = a; + a = tmp; + } + if (b.length === 0) { + return a.length; + } + if (a.length <= 32) { + return myers_32(a, b); + } + return myers_x(a, b); +}; +exports.distance = distance; +var closest = function (str, arr) { + var min_distance = Infinity; + var min_index = 0; + for (var i = 0; i < arr.length; i++) { + var dist = distance(str, arr[i]); + if (dist < min_distance) { + min_distance = dist; + min_index = i; + } + } + return arr[min_index]; +}; +exports.closest = closest; diff --git a/node_modules/fastest-levenshtein/package.json b/node_modules/fastest-levenshtein/package.json index 4d3ca34c92913..c395b852d5d92 100644 --- a/node_modules/fastest-levenshtein/package.json +++ b/node_modules/fastest-levenshtein/package.json @@ -1,8 +1,10 @@ { "name": "fastest-levenshtein", - "version": "1.0.12", + "version": "1.0.16", "description": "Fastest Levenshtein distance implementation in JS.", - "main": "index.js", + "main": "mod.js", + "types": "mod.d.ts", + "module": "./esm/mod.js", "repository": { "type": "git", "url": "git+https://github.com/ka-weihe/fastest-levenshtein.git" @@ -33,31 +35,38 @@ }, "homepage": "https://github.com/ka-weihe/fastest-levenshtein#README", "scripts": { - "test": "jest", - "test:coverage": "jest --coverage", - "test:coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls" + "build": "tsc mod.ts --declaration", + "build:esm": "tsc --declaration -p tsconfig.esm.json", + "prepare": "npm run build && npm run build:esm", + "bench": "npm run build && tsc bench.ts && node bench.js", + "test": "npm run build && tsc test.ts && jest test.js", + "test:coverage": "npm run build && jest --coverage", + "test:coveralls": "npm run build && jest --coverage --coverageReporters=text-lcov | coveralls" }, "devDependencies": { + "@types/benchmark": "^1.0.33", + "@types/jest": "^26.0.15", + "@typescript-eslint/eslint-plugin": "^4.7.0", + "@typescript-eslint/parser": "^4.7.0", "benchmark": "^2.1.4", "coveralls": "^3.1.0", - "eslint": "^7.5.0", - "eslint-config-airbnb": "^18.2.0", - "eslint-config-airbnb-base": "^14.2.0", + "eslint": "^7.13.0", "eslint-config-node": "^4.1.0", - "eslint-config-prettier": "^6.11.0", - "eslint-plugin-import": "^2.22.0", - "eslint-plugin-jsx-a11y": "^6.3.1", + "eslint-config-prettier": "^6.15.0", + "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.1.4", - "eslint-plugin-react": "^7.20.3", - "eslint-plugin-react-hooks": "^4.0.0", "fast-levenshtein": "^2.0.6", - "jest": "^26.1.0", + "jest": "^26.6.3", "js-levenshtein": "^1.1.6", "leven": "^3.1.0", + "levenshtein-edit-distance": "^2.0.5", "natural": "^2.1.5", - "prettier": "^2.0.5", - "talisman": "^1.1.2", - "levenshtein-edit-distance": "^2.0.5" + "prettier": "^2.1.2", + "talisman": "^1.1.3", + "typescript": "^4.0.5" + }, + "engines": { + "node": ">= 4.9.1" } } diff --git a/node_modules/fastest-levenshtein/test.js b/node_modules/fastest-levenshtein/test.js index 4b5d6ecae6504..475063390a81b 100644 --- a/node_modules/fastest-levenshtein/test.js +++ b/node_modules/fastest-levenshtein/test.js @@ -1,64 +1,55 @@ -const {distance, closest} = require("./index.js"); - -const levenshtein = (a, b) => { - if (a.length === 0) return b.length; - if (b.length === 0) return a.length; - - if (a.length > b.length) { - const tmp = a; - a = b; - b = tmp; - } - - const row = []; - for (let i = 0; i <= a.length; i++) { - row[i] = i; - } - - for (let i = 1; i <= b.length; i++) { - let prev = i; - for (let j = 1; j <= a.length; j++) { - let val; - if (b.charAt(i - 1) === a.charAt(j - 1)) { - val = row[j - 1]; - } else { - val = Math.min(row[j - 1] + 1, prev + 1, row[j] + 1); - } - row[j - 1] = prev; - prev = val; +var _a = require("./mod.js"), closest = _a.closest, distance = _a.distance; +var levenshtein = function (a, b) { + if (a.length === 0) { + return b.length; } - row[a.length] = prev; - } - - return row[a.length]; + if (b.length === 0) { + return a.length; + } + if (a.length > b.length) { + var tmp = a; + a = b; + b = tmp; + } + var row = []; + for (var i = 0; i <= a.length; i++) { + row[i] = i; + } + for (var i = 1; i <= b.length; i++) { + var prev = i; + for (var j = 1; j <= a.length; j++) { + var val = 0; + if (b.charAt(i - 1) === a.charAt(j - 1)) { + val = row[j - 1]; + } + else { + val = Math.min(row[j - 1] + 1, prev + 1, row[j] + 1); + } + row[j - 1] = prev; + prev = val; + } + row[a.length] = prev; + } + return row[a.length]; }; - -function makeid(length) { - let result = ""; - const characters = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - const charactersLength = characters.length; - for (let i = 0; i < length; i++) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; +var makeid = function (length) { + var result = ""; + var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + var charactersLength = characters.length; + for (var i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +}; +for (var i = 0; i < 10000; i++) { + var rnd_num1 = (Math.random() * 1000) | 0; + var rnd_num2 = (Math.random() * 1000) | 0; + var rnd_string1 = makeid(rnd_num1); + var rnd_string2 = makeid(rnd_num2); + var actual = distance(rnd_string1, rnd_string2); + var expected = levenshtein(rnd_string1, rnd_string2); + console.log(i); + if (actual !== expected) { + console.log("fail"); + } } - -test("test compare", () => { - const errors = 0; - for (let i = 0; i < 1000; i++) { - const rnd_num1 = (Math.random() * 1000) | 0; - const rnd_num2 = (Math.random() * 1000) | 0; - const rnd_string1 = makeid(rnd_num1); - const rnd_string2 = makeid(rnd_num2); - const actual = distance(rnd_string1, rnd_string2); - const expected = levenshtein(rnd_string1, rnd_string2); - expect(actual).toBe(expected); - } -}); - -test("test find", () => { - const actual = closest("fast", ["slow", "faster", "fastest"]); - const expected = "faster"; - expect(actual).toBe(expected); -}); diff --git a/node_modules/fastest-levenshtein/test.ts b/node_modules/fastest-levenshtein/test.ts new file mode 100644 index 0000000000000..41939bcdc8e2b --- /dev/null +++ b/node_modules/fastest-levenshtein/test.ts @@ -0,0 +1,67 @@ +const { closest, distance } = require("./mod.js"); + +const levenshtein = (a, b) => { + if (a.length === 0) { + return b.length; + } + if (b.length === 0) { + return a.length; + } + + if (a.length > b.length) { + const tmp = a; + a = b; + b = tmp; + } + + const row = []; + for (let i = 0; i <= a.length; i++) { + row[i] = i; + } + + for (let i = 1; i <= b.length; i++) { + let prev = i; + for (let j = 1; j <= a.length; j++) { + let val = 0; + if (b.charAt(i - 1) === a.charAt(j - 1)) { + val = row[j - 1]; + } else { + val = Math.min(row[j - 1] + 1, prev + 1, row[j] + 1); + } + row[j - 1] = prev; + prev = val; + } + row[a.length] = prev; + } + + return row[a.length]; +}; + +const makeid = (length) => { + let result = ""; + const characters = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + const charactersLength = characters.length; + for (let i = 0; i < length; i++) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + } + return result; +}; + +test("test compare", () => { + for (let i = 0; i < 1000; i++) { + const rnd_num1 = (Math.random() * 1000) | 0; + const rnd_num2 = (Math.random() * 1000) | 0; + const rnd_string1 = makeid(rnd_num1); + const rnd_string2 = makeid(rnd_num2); + const actual = distance(rnd_string1, rnd_string2); + const expected = levenshtein(rnd_string1, rnd_string2); + expect(actual).toBe(expected); + } +}); + +test("test find", () => { + const actual = closest("fast", ["slow", "faster", "fastest"]); + const expected = "faster"; + expect(actual).toBe(expected); +}); diff --git a/package-lock.json b/package-lock.json index f210200f5c22a..b26762ab0cead 100644 --- a/package-lock.json +++ b/package-lock.json @@ -99,7 +99,7 @@ "cli-columns": "^4.0.0", "cli-table3": "^0.6.2", "columnify": "^1.6.0", - "fastest-levenshtein": "^1.0.12", + "fastest-levenshtein": "^1.0.16", "fs-minipass": "^2.1.0", "glob": "^8.0.1", "graceful-fs": "^4.2.10", @@ -5042,9 +5042,13 @@ "dev": true }, "node_modules/fastest-levenshtein": { - "version": "1.0.12", + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", + "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", "inBundle": true, - "license": "MIT" + "engines": { + "node": ">= 4.9.1" + } }, "node_modules/fastq": { "version": "1.13.0", diff --git a/package.json b/package.json index 9980c5b8ec65e..096ae466bef7f 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "cli-columns": "^4.0.0", "cli-table3": "^0.6.2", "columnify": "^1.6.0", - "fastest-levenshtein": "^1.0.12", + "fastest-levenshtein": "^1.0.16", "fs-minipass": "^2.1.0", "glob": "^8.0.1", "graceful-fs": "^4.2.10", From 0ef4960a5a49d70bb0c99c985185c80e9662bd0c Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 2 Nov 2022 09:40:50 -0700 Subject: [PATCH 7/7] deps: cli-table3@0.6.3 --- node_modules/cli-table3/package.json | 2 +- node_modules/cli-table3/src/cell.js | 7 +++++-- package-lock.json | 7 ++++--- package.json | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/node_modules/cli-table3/package.json b/node_modules/cli-table3/package.json index 4e6689621968c..6e84bf6667505 100644 --- a/node_modules/cli-table3/package.json +++ b/node_modules/cli-table3/package.json @@ -1,6 +1,6 @@ { "name": "cli-table3", - "version": "0.6.2", + "version": "0.6.3", "description": "Pretty unicode tables for the command line. Based on the original cli-table.", "main": "index.js", "types": "index.d.ts", diff --git a/node_modules/cli-table3/src/cell.js b/node_modules/cli-table3/src/cell.js index 8f507442bb8fc..8c3df35d19407 100644 --- a/node_modules/cli-table3/src/cell.js +++ b/node_modules/cli-table3/src/cell.js @@ -73,7 +73,9 @@ class Cell { } computeLines(tableOptions) { - if (this.fixedWidth && (tableOptions.wordWrap || tableOptions.textWrap)) { + const tableWordWrap = tableOptions.wordWrap || tableOptions.textWrap; + const { wordWrap = tableWordWrap } = this.options; + if (this.fixedWidth && wordWrap) { this.fixedWidth -= this.paddingLeft + this.paddingRight; if (this.colSpan) { let i = 1; @@ -82,7 +84,8 @@ class Cell { i++; } } - const { wrapOnWordBoundary = true } = tableOptions; + const { wrapOnWordBoundary: tableWrapOnWordBoundary = true } = tableOptions; + const { wrapOnWordBoundary = tableWrapOnWordBoundary } = this.options; return this.wrapLines(utils.wordWrap(this.fixedWidth, this.content, wrapOnWordBoundary)); } return this.wrapLines(this.content.split('\n')); diff --git a/package-lock.json b/package-lock.json index b26762ab0cead..75629a2bc6fec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -97,7 +97,7 @@ "cacache": "^17.0.1", "chalk": "^4.1.2", "cli-columns": "^4.0.0", - "cli-table3": "^0.6.2", + "cli-table3": "^0.6.3", "columnify": "^1.6.0", "fastest-levenshtein": "^1.0.16", "fs-minipass": "^2.1.0", @@ -3310,9 +3310,10 @@ } }, "node_modules/cli-table3": { - "version": "0.6.2", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", + "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", "inBundle": true, - "license": "MIT", "dependencies": { "string-width": "^4.2.0" }, diff --git a/package.json b/package.json index 096ae466bef7f..86735a62f41af 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "cacache": "^17.0.1", "chalk": "^4.1.2", "cli-columns": "^4.0.0", - "cli-table3": "^0.6.2", + "cli-table3": "^0.6.3", "columnify": "^1.6.0", "fastest-levenshtein": "^1.0.16", "fs-minipass": "^2.1.0",