diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index 60318f794c..0000000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,13 +0,0 @@ -## System information - - node version: - - npm or yarn version: - - OS/version/architecture: - - Applicable nodegit version: - -``` -node -v -npm -v # (or yarn -v) -node -e "console.log(process.platform)" -node -e "console.log(require('os').release())" -node -e "console.log(process.arch)" -``` diff --git a/.github/workflows/build-openssl-packages.yml b/.github/workflows/build-openssl-packages.yml deleted file mode 100644 index 7b7a5dea3e..0000000000 --- a/.github/workflows/build-openssl-packages.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and Publish OpenSSL Packages - -on: - workflow_dispatch: - -jobs: - build-openssl: - name: Build OpenSSL package for (${{ matrix.os }} ${{ matrix.arch }}) - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: windows-latest - arch: arm64 - - os: windows-latest - arch: x64 - - os: macos-15 - arch: arm64 - - os: macos-15-intel - arch: x64 - fail-fast: false - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 22 - - - name: Install dependencies - run: npm install - - - name: Build OpenSSL packages - env: - npm_config_arch: ${{ matrix.arch }} - NODEGIT_OPENSSL_BUILD_PACKAGE: 1 - OPENSSL_MACOS_DEPLOYMENT_TARGET: "11.0" - run: node utils/acquireOpenSSL.mjs - - - name: Push OpenSSL package to S3 - env: - npm_config_arch: ${{ matrix.arch }} - node_pre_gyp_bucket: ${{ secrets.node_pre_gyp_bucket }} - AWS_ACCESS_KEY_ID: ${{ secrets.node_pre_gyp_accessKeyId }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.node_pre_gyp_secretAccessKey }} - run: node utils/uploadOpenSSL.mjs diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 3cd6aae10c..0000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,196 +0,0 @@ -on: - push: - branches: - - master - - backport/* - tags: - - v*.*.* - pull_request: - -name: Testing - -jobs: - linux-tests: - name: "Linux Tests" - strategy: - matrix: - node: [20, 22, 24] - fail-fast: false - runs-on: ubuntu-22.04 - steps: - - name: Install Dependencies for Ubuntu - run: sudo apt-get update && sudo apt-get install -y software-properties-common git build-essential clang libssl-dev libkrb5-dev libc++-dev wget zlib1g-dev - - - uses: actions/checkout@v4 - - - name: Setup Environment - run: | - set -e - mkdir ~/.ssh_tests - chmod 700 ~/.ssh_tests - printf "%b" "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh_tests/config - cat test/id_rsa.pub > ~/.ssh_tests/id_rsa.pub - cat test/id_rsa.enc | base64 -d > ~/.ssh_tests/id_rsa - chmod 600 ~/.ssh_tests/id_rsa* - git config --global user.name "John Doe" - git config --global user.email johndoe@example.com - - - uses: actions/setup-python@v5 - with: - python-version: "3.11" - - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - check-latest: true - - - name: Install - run: npm install - - - name: Test - run: | - set -e - eval `ssh-agent -s` - ssh-add ~/.ssh_tests/id_rsa - node utils/retry npm test - - - name: Deploy - if: startsWith(github.ref, 'refs/tags/v') - env: - node_pre_gyp_bucket: ${{ secrets.node_pre_gyp_bucket }} - AWS_ACCESS_KEY_ID: ${{ secrets.node_pre_gyp_accessKeyId }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.node_pre_gyp_secretAccessKey }} - run: | - npm install -g @mapbox/node-pre-gyp aws-sdk - node lifecycleScripts/clean - node-pre-gyp package - node-pre-gyp publish - - macos-tests: - name: "macOS Tests" - strategy: - matrix: - node: [20, 22, 24] - arch: [x64, arm64] - fail-fast: false - runs-on: ${{ matrix.arch == 'x64' && 'macos-15-intel' || 'macos-15' }} - steps: - - uses: actions/checkout@v4 - - - name: Setup Environment - run: | - mkdir ~/.ssh_tests - chmod 700 ~/.ssh_tests - printf "%b" "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh_tests/config - cat test/id_rsa.pub > ~/.ssh_tests/id_rsa.pub - cat test/id_rsa.enc | base64 -d > ~/.ssh_tests/id_rsa - chmod 600 ~/.ssh_tests/id_rsa* - git config --global user.name "John Doe" - git config --global user.email johndoe@example.com - - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - check-latest: true - - - name: Install - run: npm install - - - name: Test - run: | - set -e - eval `ssh-agent -s` - ssh-add ~/.ssh_tests/id_rsa - node utils/retry npm test - - - name: Deploy - if: startsWith(github.ref, 'refs/tags/v') - env: - node_pre_gyp_bucket: ${{ secrets.node_pre_gyp_bucket }} - AWS_ACCESS_KEY_ID: ${{ secrets.node_pre_gyp_accessKeyId }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.node_pre_gyp_secretAccessKey }} - run: | - npm install -g @mapbox/node-pre-gyp aws-sdk - node lifecycleScripts/clean - node-pre-gyp package - node-pre-gyp publish - - windows-tests: - name: Windows Tests - strategy: - matrix: - node: [20, 22, 24] - arch: [x86, x64, arm64] - exclude: - - node: 24 - arch: x86 - fail-fast: false - runs-on: windows-2022 - steps: - - name: Setup Environment - run: | - git config --file C:\ProgramData\Git\config core.autocrlf input - git config --system core.autocrlf input - git config --global core.autocrlf input - git config --global user.name "John Doe" - git config --global user.email johndoe@example.com - - - uses: actions/checkout@v4 - - - name: Use Node.js - if: matrix.arch == 'x86' - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - check-latest: true - architecture: x86 - - - name: Use Node.js - uses: actions/setup-node@v4 - if: matrix.arch != 'x86' - with: - node-version: ${{ matrix.node }} - check-latest: true - - - name: Install - env: - npm_config_arch: ${{ matrix.arch == 'x86' && 'ia32' || matrix.arch }} - run: npm install - - - name: Test - # need arm64 runners or an emulator to run tests - if: matrix.arch != 'arm64' - env: - GIT_SSH: ${{ github.workspace }}\vendor\plink.exe - run: | - $encodedKey = Get-Content -Path test\private.ppk.enc - $finalPath = Join-Path -Path $HOME -ChildPath .ssh_tests\private.ppk - mkdir ~\.ssh_tests - Set-Content -Value $([System.Convert]::FromBase64String($encodedKey)) -Path $finalPath -AsByteStream - powershell -command "Start-Process .\vendor\pageant\pageant_${{ matrix.arch }}.exe $finalPath" - node utils/retry npm test - - # You're probably wondering why this isn't a single `run: |` step, it certainly is for *nix, - # but it's not, because the CI runner for windows doesn't wait for each step as listed here - # and it treats each additional step past the first as an orphaned process. - - name: Deploy (Dependencies) - if: startsWith(github.ref, 'refs/tags/v') - run: npm install -g @mapbox/node-pre-gyp aws-sdk - - - name: Deploy (Clean) - if: startsWith(github.ref, 'refs/tags/v') - run: node lifecycleScripts\clean - - - name: Deploy (Package) - if: startsWith(github.ref, 'refs/tags/v') - run: node-pre-gyp package --target_arch=${{ matrix.arch }} - - - name: Deploy (Publish) - if: startsWith(github.ref, 'refs/tags/v') - env: - node_pre_gyp_bucket: ${{ secrets.node_pre_gyp_bucket }} - AWS_ACCESS_KEY_ID: ${{ secrets.node_pre_gyp_accessKeyId }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.node_pre_gyp_secretAccessKey }} - run: node-pre-gyp publish --target_arch=${{ matrix.arch }} diff --git a/.npmignore b/.npmignore index 046bdf56a9..0295de29b7 100644 --- a/.npmignore +++ b/.npmignore @@ -1,9 +1,9 @@ /.travis/ /build/ /examples/ -/generate/ +#/generate/ /guides/ -/lib/ +#/lib/ /test/ /vendor/Release/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..f301fedf98 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +auto-install-peers=false diff --git a/.travis/deploy-docs.sh b/.travis/deploy-docs.sh deleted file mode 100755 index 50ee50b2b9..0000000000 --- a/.travis/deploy-docs.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - - -# delete "nodegit.github.com" folder if it exists -rm -rf "nodegit.github.com" || exit 0; - -# clone "nodegit.github.com" repository -git clone "https://github.com/nodegit/nodegit.github.com.git" - -# change into "nodegit.github.com" folder -cd "nodegit.github.com" - -# install node dependencies -npm install - -# link "nodegit" folder -ln -s ../.. generate/nodegit - -# generate new docs -node generate - -# configure git user information -git config user.name "Travis CI" -git config user.email "noreply@travis-ci.org" - -# commit changes -git add . -git commit -m "Deploy to GitHub Pages - -see https://github.com/nodegit/nodegit.github.com/commit/${TRAVIS_COMMIT}" -git tag "${TRAVIS_COMMIT}" - -# push to the "nodegit.github.com" repository -git push --quiet "https://${GH_TOKEN}@github.com/nodegit/nodegit.github.com.git" master "${TRAVIS_COMMIT}" > /dev/null 2>&1 diff --git a/generate/scripts/helpers.js b/generate/scripts/helpers.js index e278e1cc05..6fe3099372 100644 --- a/generate/scripts/helpers.js +++ b/generate/scripts/helpers.js @@ -315,6 +315,12 @@ var Helpers = { } } + // Somewhere the warning for `-Wformat-security` becomes an error. + // Fix the warning by treating the `fmt` arg as `printf("%s", fmt)`. + if (arg.name === "fmt" && arg.type === "const char *") { + arg.isFmtArg = true; + } + _.merge(arg, argOverrides); }, diff --git a/generate/scripts/utils.js b/generate/scripts/utils.js index c6e843134a..2c2e2ff3af 100644 --- a/generate/scripts/utils.js +++ b/generate/scripts/utils.js @@ -1,5 +1,4 @@ const fse = require("fs-extra"); -const walk = require("walk"); const _ = require('lodash'); const fs = require("fs"); @@ -13,11 +12,11 @@ var util = { pointerRegex: /\s*\*\s*/, doublePointerRegex: /\s*\*\*\s*/, - readLocalFile: function(filePath) { + readLocalFile: function (filePath) { return util.readFile(local(filePath)); }, - readFile: function(filePath) { + readFile: function (filePath) { try { return fs.readFileSync(filePath).toString(); } @@ -26,11 +25,11 @@ var util = { } }, - writeLocalFile: function(filePath, content, header) { + writeLocalFile: function (filePath, content, header) { return util.writeFile(local(filePath), content, header); }, - writeFile: function(filePath, content, header) { + writeFile: function (filePath, content, header) { try { if (typeof content == "object") { content = JSON.stringify(content, null, 2) @@ -54,8 +53,8 @@ var util = { } }, - titleCase: function(str) { - return str.split(/_|\//).map(function(val, index) { + titleCase: function (str) { + return str.split(/_|\//).map(function (val, index) { if (val.length) { return val[0].toUpperCase() + val.slice(1); } @@ -66,81 +65,66 @@ var util = { camelCase: _.camelCase, - getFilePathsRelativeToDir: function(dir) { - const files = []; - const walker = walk.walk(dir, { followLinks: false }); + getFilePathsRelativeToDir: async function (dir) { if (!util.isDirectory(dir)) { return Promise.resolve([]); } - return new Promise(function(resolve, reject) { - walker.on('file', function(root, stat, next) { - files.push(path.relative(dir, path.join(root, stat.name))); - next(); - }); - - walker.on('end', function() { - resolve(files); - }); - - walker.on('errors', function() { - reject(); - }); - }); + return await fs.promises.readdir(dir); }, - isFile: function(path) { + isFile: function (path) { var isFile; try { isFile = fse.statSync(path).isFile(); - } catch(e) { + } catch (e) { isFile = false; } return isFile; }, - isDirectory: function(path) { + isDirectory: function (path) { var isDirectory; try { isDirectory = fse.statSync(path).isDirectory(); - } catch(e) { + } catch (e) { isDirectory = false; } return isDirectory; }, - isPointer: function(type) { + isPointer: function (type) { return util.pointerRegex.test(type) || util.doublePointerRegex.test(type); }, - isDoublePointer: function(type) { + isDoublePointer: function (type) { return util.doublePointerRegex.test(type); }, - syncDirs: function(fromDir, toDir) { + syncDirs: function (fromDir, toDir) { let toFilePaths; let fromFilePaths; return Promise.all([ util.getFilePathsRelativeToDir(toDir), util.getFilePathsRelativeToDir(fromDir) ]) - .then(function(filePaths) { + .then(function (filePaths) { toFilePaths = filePaths[0]; fromFilePaths = filePaths[1]; // Delete files that aren't in fromDir - return Promise.all(toFilePaths.map(function(filePath) { + return Promise.all(toFilePaths.map(function (filePath) { if (!util.isFile(path.join(fromDir, filePath))) { return fse.remove(path.join(toDir, filePath)); } return Promise.resolve(); })); }) - .then(function() { + .then(function () { // Copy files that don't exist in toDir or have different contents - return Promise.all(fromFilePaths.map(function(filePath) { + return Promise.all(fromFilePaths.map(function (filePath) { const toFilePath = path.join(toDir, filePath); const fromFilePath = path.join(fromDir, filePath); if (!util.isFile(toFilePath) || util.readFile(toFilePath) !== util.readFile(fromFilePath)) { diff --git a/generate/templates/partials/sync_function.cc b/generate/templates/partials/sync_function.cc index cf6febe67a..c1ab6a6341 100644 --- a/generate/templates/partials/sync_function.cc +++ b/generate/templates/partials/sync_function.cc @@ -61,6 +61,9 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) { {%elsif arg.isReturn %} {{ arg.name }} {%else%} + {%if arg.isFmtArg %} + "%s", + {%endif%} from_{{ arg.name }} {%endif%} {%if not arg.lastArg %},{%endif%} diff --git a/generate/templates/templates/binding.gyp b/generate/templates/templates/binding.gyp index 4476c9236d..61ab36f2e8 100644 --- a/generate/templates/templates/binding.gyp +++ b/generate/templates/templates/binding.gyp @@ -14,6 +14,34 @@ 'openssl_fips': '', }, + 'target_defaults': { + 'default_configuration': 'Debug', + 'configurations': { + 'Debug': { + 'defines': [ 'DEBUG', '_DEBUG' ], + }, + 'Release': { + 'defines': [ 'NDEBUG' ], + 'cflags': [ '-O2', ], + 'cxxflags': [ '-O2', ], + # 'ldflags': [ '-fuse-ld=lld' ], + 'xcode_settings': { + 'LLVM_LTO': 'YES' + }, + 'msvs_settings': { + 'VCCLCompilerTool': { + 'WholeProgramOptimization': 'true' + }, + 'VCLibrarianTool': { + }, + 'VCLinkerTool': { + 'LinkTimeCodeGeneration': 1 + } + } + } + } + }, + "targets": [ { "target_name": "nodegit", diff --git a/generate/templates/templates/nodegit.js b/generate/templates/templates/nodegit.js index 43e7d9de02..e565664b28 100644 --- a/generate/templates/templates/nodegit.js +++ b/generate/templates/templates/nodegit.js @@ -1,4 +1,4 @@ -var _ = require("lodash"); +// var _ = require("lodash"); var util = require("util"); var worker; @@ -28,7 +28,8 @@ var promisify = fn => fn && util.promisify(fn); // jshint ignore:line // https://github.com/facebook/jest/issues/3552 // https://github.com/facebook/jest/issues/3550 // https://github.com/nodejs/node/issues/5016 -rawApi = _.cloneDeep(rawApi); +// TODO: Replace this? +// rawApi = _.cloneDeep(rawApi); // Native methods do not return an identifiable function, so we // have to override them here diff --git a/lib/commit.js b/lib/commit.js index 8eb561e585..63a7d3227f 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -1,5 +1,4 @@ var events = require("events"); -var fp = require("lodash/fp"); var NodeGit = require("../"); var Commit = NodeGit.Commit; var LookupWrapper = NodeGit.Utils.lookupWrapper; @@ -21,7 +20,7 @@ Commit.lookup = LookupWrapper(Commit); * @param {Number} n * @return {Commit} */ -Commit.prototype.parent = function(n) { +Commit.prototype.parent = function (n) { var repo = this.repo; return _parent.call(this, n).then(p => { p.repo = repo; @@ -42,27 +41,27 @@ Commit.prototype.parent = function(n) { */ Commit.prototype.amend = function ( updateRef, author, committer, message_encoding, message, tree) { - var repo = this.repo; - var _this = this; - var treePromise; - - if (tree instanceof NodeGit.Oid){ - treePromise = repo.getTree(tree); - } else { - treePromise = Promise.resolve(tree); - } - - return treePromise - .then(function(treeObject){ - return _amend.call(_this, - updateRef, - author, - committer, - message_encoding, - message, - treeObject - ); - }); + var repo = this.repo; + var _this = this; + var treePromise; + + if (tree instanceof NodeGit.Oid) { + treePromise = repo.getTree(tree); + } else { + treePromise = Promise.resolve(tree); + } + + return treePromise + .then(function (treeObject) { + return _amend.call(_this, + updateRef, + author, + committer, + message_encoding, + message, + treeObject + ); + }); }; /** @@ -77,7 +76,7 @@ Commit.prototype.amend = function ( * @param {Function} onSignature Callback to be called with string to be signed * @return {Oid} */ -Commit.prototype.amendWithSignature = function( +Commit.prototype.amendWithSignature = function ( updateRef, author, committer, @@ -86,151 +85,157 @@ Commit.prototype.amendWithSignature = function( tree, onSignature ) { - let repo = this.repo; - let parentOids = this.parents(); - let _this = this; - let promises = []; - - if (tree instanceof NodeGit.Oid) { - promises.push(repo.getTree(tree)); - } else { - promises.push(Promise.resolve(tree)); - } - - parentOids.forEach(function (parentOid) { - promises.push(repo.getCommit(parentOid)); - }); + let repo = this.repo; + let parentOids = this.parents(); + let _this = this; + let promises = []; + + if (tree instanceof NodeGit.Oid) { + promises.push(repo.getTree(tree)); + } else { + promises.push(Promise.resolve(tree)); + } - let treeObject; - let parents; - let commitContent; - let commit; - let skippedSigning; - let resolvedAuthor; - let resolvedCommitter; - let resolvedMessageEncoding; - let resolvedMessage; - let resolvedTree; - - let createCommitPromise = Promise.all(promises) - .then(function(results) { - treeObject = fp.head(results); - parents = fp.tail(results); - return _this.getTree(); - }) - .then(function(commitTreeResult) { - let commitTree = commitTreeResult; - - let truthyArgs = fp.omitBy( - fp.isNil, - { - author, - committer, - messageEncoding, - message, - tree: treeObject - } - ); - - let commitFields = { - author: _this.author(), - committer: _this.committer(), - messageEncoding: _this.messageEncoding(), - message: _this.message(), - tree: commitTree - }; - - ({ - author: resolvedAuthor, - committer: resolvedCommitter, - messageEncoding: resolvedMessageEncoding, - message: resolvedMessage, - tree: resolvedTree - } = fp.assign( - commitFields, - truthyArgs - )); - - return Commit.createBuffer( - repo, - resolvedAuthor, - resolvedCommitter, - resolvedMessageEncoding, - resolvedMessage, - resolvedTree, - parents.length, - parents - ); - }) - .then(function(commitContentResult) { - commitContent = commitContentResult; - if (!commitContent.endsWith("\n")) { - commitContent += "\n"; - } - return onSignature(commitContent); - }) - .then(function({ code, field, signedData }) { - switch (code) { - case NodeGit.Error.CODE.OK: - return Commit.createWithSignature( - repo, - commitContent, - signedData, - field - ); - case NodeGit.Error.CODE.PASSTHROUGH: - skippedSigning = true; - return Commit.create( - repo, - updateRef, - resolvedAuthor, - resolvedCommitter, - resolvedMessageEncoding, - resolvedMessage, - resolvedTree, - parents.length, - parents - ); - default: { - const error = new Error( - `Commit.amendWithSignature threw with error code ${code}` - ); - error.errno = code; - throw error; - } - } - }); + parentOids.forEach(function (parentOid) { + promises.push(repo.getCommit(parentOid)); + }); - if (!updateRef) { - return createCommitPromise; - } + let treeObject; + let parents; + let commitContent; + let commit; + let skippedSigning; + let resolvedAuthor; + let resolvedCommitter; + let resolvedMessageEncoding; + let resolvedMessage; + let resolvedTree; + + let createCommitPromise = Promise.all(promises) + .then(function (results) { + treeObject = results[0]; + parents = results.slice(1); + return _this.getTree(); + }) + .then(function (commitTreeResult) { + let commitTree = commitTreeResult; + + const truthyArgs = {}; + if (author) { + truthyArgs.author = author; + } + if (committer) { + truthyArgs.committer = committer; + } + if (messageEncoding) { + truthyArgs.messageEncoding = messageEncoding; + } + if (message) { + truthyArgs.message = message; + } + if (treeObject) { + truthyArgs.tree = treeObject; + } - return createCommitPromise - .then(function(commitOid) { - if (skippedSigning) { - return commitOid; + let commitFields = { + author: _this.author(), + committer: _this.committer(), + messageEncoding: _this.messageEncoding(), + message: _this.message(), + tree: commitTree + }; + + ({ + author: resolvedAuthor, + committer: resolvedCommitter, + messageEncoding: resolvedMessageEncoding, + message: resolvedMessage, + tree: resolvedTree + } = Object.assign( + commitFields, + truthyArgs + )); + + return Commit.createBuffer( + repo, + resolvedAuthor, + resolvedCommitter, + resolvedMessageEncoding, + resolvedMessage, + resolvedTree, + parents.length, + parents + ); + }) + .then(function (commitContentResult) { + commitContent = commitContentResult; + if (!commitContent.endsWith("\n")) { + commitContent += "\n"; + } + return onSignature(commitContent); + }) + .then(function ({ code, field, signedData }) { + switch (code) { + case NodeGit.Error.CODE.OK: + return Commit.createWithSignature( + repo, + commitContent, + signedData, + field + ); + case NodeGit.Error.CODE.PASSTHROUGH: + skippedSigning = true; + return Commit.create( + repo, + updateRef, + resolvedAuthor, + resolvedCommitter, + resolvedMessageEncoding, + resolvedMessage, + resolvedTree, + parents.length, + parents + ); + default: { + const error = new Error( + `Commit.amendWithSignature threw with error code ${code}` + ); + error.errno = code; + throw error; } + } + }); - return repo.getCommit(commitOid) - .then(function(commitResult) { - commit = commitResult; - return repo.getReference(updateRef); - }).then(function(ref) { - return ref.setTarget( - commitOid, - `commit (amend): ${commit.summary()}` - ); - }).then(function() { - return commitOid; - }); - }); + if (!updateRef) { + return createCommitPromise; + } + + return createCommitPromise + .then(function (commitOid) { + if (skippedSigning) { + return commitOid; + } + + return repo.getCommit(commitOid) + .then(function (commitResult) { + commit = commitResult; + return repo.getReference(updateRef); + }).then(function (ref) { + return ref.setTarget( + commitOid, + `commit (amend): ${commit.summary()}` + ); + }).then(function () { + return commitOid; + }); + }); }; /** * Retrieve the commit time as a Date object. * @return {Date} */ -Commit.prototype.date = function() { +Commit.prototype.date = function () { return new Date(this.timeMs()); }; @@ -241,7 +246,7 @@ Commit.prototype.date = function() { * @async * @return {Array} an array of diffs */ -Commit.prototype.getDiff = function() { +Commit.prototype.getDiff = function () { return this.getDiffWithOptions(null); }; @@ -253,15 +258,15 @@ Commit.prototype.getDiff = function() { * @param {Object} options * @return {Array} an array of diffs */ -Commit.prototype.getDiffWithOptions = function(options) { +Commit.prototype.getDiffWithOptions = function (options) { var commit = this; - return commit.getTree().then(function(thisTree) { - return commit.getParents().then(function(parents) { + return commit.getTree().then(function (thisTree) { + return commit.getParents().then(function (parents) { var diffs; if (parents.length) { - diffs = parents.map(function(parent) { - return parent.getTree().then(function(parentTree) { + diffs = parents.map(function (parent) { + return parent.getTree().then(function (parentTree) { return thisTree.diffWithOptions(parentTree, options); }); }); @@ -282,8 +287,8 @@ Commit.prototype.getDiffWithOptions = function(options) { * @param {String} path * @return {TreeEntry} */ -Commit.prototype.getEntry = function(path) { - return this.getTree().then(function(tree) { +Commit.prototype.getEntry = function (path) { + return this.getTree().then(function (tree) { return tree.getEntry(path); }); }; @@ -295,7 +300,7 @@ Commit.prototype.getEntry = function(path) { * @param {number} limit Optional amount of parents to return. * @return {Array} array of commits */ -Commit.prototype.getParents = function(limit) { +Commit.prototype.getParents = function (limit) { var parents = []; // If no limit was set, default to the maximum parents. @@ -326,7 +331,7 @@ Commit.prototype.getParents = function(limit) { * defaults to gpgsig * @return {extractedSignature} */ -Commit.prototype.getSignature = function(field) { +Commit.prototype.getSignature = function (field) { return Commit.extractSignature(this.repo, this.id(), field); }; @@ -336,7 +341,7 @@ Commit.prototype.getSignature = function(field) { * @async * @return {Tree} */ -Commit.prototype.getTree = function() { +Commit.prototype.getTree = function () { return this.repo.getTree(this.treeId()); }; @@ -354,7 +359,7 @@ Commit.prototype.getTree = function() { * @return {EventEmitter} * @start start() */ -Commit.prototype.history = function() { +Commit.prototype.history = function () { var event = new events.EventEmitter(); var oid = this.id(); var revwalk = this.repo.createRevWalk(); @@ -363,7 +368,7 @@ Commit.prototype.history = function() { var commits = []; - event.start = function() { + event.start = function () { revwalk.walk(oid, function commitRevWalk(error, commit) { if (error) { if (error.errno === NodeGit.Error.CODE.ITEROVER) { @@ -391,7 +396,7 @@ Commit.prototype.history = function() { */ Commit.prototype.parent = function (id) { var repository = this.repo; - return _parent.call(this, id).then(function(parent) { + return _parent.call(this, id).then(function (parent) { parent.repo = repository; return parent; }); @@ -402,7 +407,7 @@ Commit.prototype.parent = function (id) { * * @return {Array} array of oids */ -Commit.prototype.parents = function() { +Commit.prototype.parents = function () { var result = []; for (var i = 0; i < this.parentcount(); i++) { @@ -416,7 +421,7 @@ Commit.prototype.parents = function() { * Retrieve the SHA. * @return {String} */ -Commit.prototype.sha = function() { +Commit.prototype.sha = function () { return this.id().toString(); }; @@ -424,7 +429,7 @@ Commit.prototype.sha = function() { * Retrieve the commit time as a unix timestamp. * @return {Number} */ -Commit.prototype.timeMs = function() { +Commit.prototype.timeMs = function () { return this.time() * 1000; }; @@ -432,6 +437,6 @@ Commit.prototype.timeMs = function() { * The sha of this commit * @return {String} */ -Commit.prototype.toString = function() { +Commit.prototype.toString = function () { return this.sha(); }; diff --git a/lib/repository.js b/lib/repository.js index 64d566dcdc..6dacb3da12 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -1,5 +1,4 @@ -var fse = require("fs-extra"); -var fp = require("lodash/fp"); +const fs = require("fs/promises"); var NodeGit = require("../"); var Blob = NodeGit.Blob; var Checkout = NodeGit.Checkout; @@ -45,14 +44,14 @@ function applySelectedLinesToTarget function lineEqualsFirstNewLine(hunkLine) { return ((hunkLine.oldLineno() === newLines[0].oldLineno()) && - (hunkLine.newLineno() === newLines[0].newLineno())); + (hunkLine.newLineno() === newLines[0].newLineno())); } function processSelectedLine(hunkLine) { // if this hunk line is a selected line find the selected line - var newLine = newLines.filter(function(nLine) { + var newLine = newLines.filter(function (nLine) { return ((hunkLine.oldLineno() === nLine.oldLineno()) && - (hunkLine.newLineno() === nLine.newLineno())); + (hunkLine.newLineno() === nLine.newLineno())); }); if (hunkLine.content().indexOf("\\ No newline at end of file") !== -1) { @@ -61,12 +60,12 @@ function applySelectedLinesToTarget // determine what to add to the new content if ((isStaged && newLine && newLine.length > 0) || - (!isStaged && (!newLine || newLine.length === 0))) { + (!isStaged && (!newLine || newLine.length === 0))) { if (hunkLine.origin() !== lineTypes.ADDED) { newContent += hunkLine.content(); } if ((isStaged && hunkLine.origin() !== lineTypes.DELETED) || - (!isStaged && hunkLine.origin() !== lineTypes.ADDED)) { + (!isStaged && hunkLine.origin() !== lineTypes.ADDED)) { oldIndex++; } } @@ -94,14 +93,14 @@ function applySelectedLinesToTarget } // find the affected hunk - pathHunks.forEach(function(pathHunk) { + pathHunks.forEach(function (pathHunk) { linesPromises.push(pathHunk.lines()); }); - return Promise.all(linesPromises).then(function(results) { + return Promise.all(linesPromises).then(function (results) { for (var i = 0; i < results.length && newContent.length < 1; i++) { var hunkStart = isStaged || reverse ? pathHunks[i].newStart() - : pathHunks[i].oldStart(); + : pathHunks[i].oldStart(); var lines = results[i]; if (lines.filter(lineEqualsFirstNewLine).length > 0) { // add content that is before the hunk @@ -115,7 +114,7 @@ function applySelectedLinesToTarget // add the rest of the file while (oldLines.length > oldIndex) { newContent += oldLines[oldIndex++] + - (oldLines.length > oldIndex ? "\n" : ""); + (oldLines.length > oldIndex ? "\n" : ""); } } } @@ -130,7 +129,7 @@ function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) { } : undefined; return Promise.resolve() - .then(function() { + .then(function () { if (isStaged) { return repo.getHeadCommit() .then(function getTreeFromCommit(commit) { @@ -148,19 +147,19 @@ function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) { (additionalDiffOptions || 0) }); }) - .then(function(diff) { + .then(function (diff) { return NodeGit.Status.file(repo, filePath) - .then(function(status) { + .then(function (status) { if (!(status & NodeGit.Status.STATUS.WT_MODIFIED) && - !(status & NodeGit.Status.STATUS.INDEX_MODIFIED)) { + !(status & NodeGit.Status.STATUS.INDEX_MODIFIED)) { return Promise.reject ("Selected staging is only available on modified files."); } return diff.patches(); }); }) - .then(function(patches) { - var pathPatch = patches.filter(function(patch) { + .then(function (patches) { + var pathPatch = patches.filter(function (patch) { return patch.newFile().path() === filePath; }); @@ -221,12 +220,12 @@ function performRebase( * when looking for 'rewritten' so we need to handle that case. */ function readRebaseMetadataFile(fileName, continueOnError) { - return fse.readFile( + return fs.readFile( path.join(repository.path(), "rebase-merge", fileName), { encoding: "utf8" } ) - .then(fp.trim) - .catch(function(err) { + .then(file => file.trim()) + .catch(function (err) { if (continueOnError) { return null; } @@ -240,17 +239,17 @@ function performRebase( function getPromise() { return rebase.next() - .then(function() { + .then(function () { return repository.refreshIndex(); }) - .then(function(index) { + .then(function (index) { if (index.hasConflicts()) { throw index; } return rebase.commit(null, signature); }) - .then(function() { + .then(function () { return performRebase( repository, @@ -260,15 +259,14 @@ function performRebase( beforeFinishFn ); }) - .catch(function(error) { + .catch(function (error) { if (error && error.errno === NodeGit.Error.CODE.ITEROVER) { - const calcRewritten = fp.cond([ - [fp.isEmpty, fp.constant(null)], - [fp.stubTrue, fp.flow([ - fp.split("\n"), - fp.map(fp.split(" ")) - ])] - ]); + const calcRewritten = (file) => { + if (!file.length) { + return null; + } + return file.split("\n").map(line => line.split(" ")); + }; const beforeFinishFnPromise = !beforeFinishFn ? Promise.resolve() : @@ -279,7 +277,7 @@ function performRebase( readRebaseMetadataFile("orig-head"), readRebaseMetadataFile("rewritten", true).then(calcRewritten) ]) - .then(function([ + .then(function ([ ontoName, ontoSha, originalHeadName, @@ -297,7 +295,7 @@ function performRebase( }); return beforeFinishFnPromise - .then(function() { + .then(function () { return rebase.finish(signature); }); } else { @@ -306,7 +304,7 @@ function performRebase( }); } - if(beforeNextFn) { + if (beforeNextFn) { beforeNextFnResult = beforeNextFn(rebase); // if beforeNextFn returns a promise, chain the promise return Promise.resolve(beforeNextFnResult) @@ -329,22 +327,22 @@ function performRebase( are hit. This may be set to null * @return {String} Path of the git repository */ -Repository.discover = function(startPath, acrossFs, ceilingDirs) { +Repository.discover = function (startPath, acrossFs, ceilingDirs) { return _discover(startPath, acrossFs, ceilingDirs) - .then(function(foundPath) { + .then(function (foundPath) { return path.resolve(foundPath); }); }; -Repository.getReferences = function(repo, type, refNamesOnly) { - return repo.getReferences().then(function(refList) { - var filteredRefList = refList.filter(function(reference) { - return type === Reference.TYPE.ALL || reference.type( ) === type; +Repository.getReferences = function (repo, type, refNamesOnly) { + return repo.getReferences().then(function (refList) { + var filteredRefList = refList.filter(function (reference) { + return type === Reference.TYPE.ALL || reference.type() === type; }); if (refNamesOnly) { - return filteredRefList.map(function(reference) { + return filteredRefList.map(function (reference) { return reference.name(); }); } @@ -362,16 +360,16 @@ Repository.getReferences = function(repo, type, refNamesOnly) { * @param {String|Reference} branch the branch to checkout * @param {Object|CheckoutOptions} opts the options to use for the checkout */ -Repository.prototype.checkoutBranch = function(branch, opts) { +Repository.prototype.checkoutBranch = function (branch, opts) { var repo = this; return repo.getReference(branch) - .then(function(ref) { - if (!ref.isBranch()) { - return false; - } - return repo.checkoutRef(ref, opts); - }); + .then(function (ref) { + if (!ref.isBranch()) { + return false; + } + return repo.checkoutRef(ref, opts); + }); }; /** @@ -383,7 +381,7 @@ Repository.prototype.checkoutBranch = function(branch, opts) { * @param {Reference} reference the reference to checkout * @param {Object|CheckoutOptions} opts the options to use for the checkout */ -Repository.prototype.checkoutRef = function(reference, opts) { +Repository.prototype.checkoutRef = function (reference, opts) { var repo = this; opts = opts || {}; @@ -391,16 +389,16 @@ Repository.prototype.checkoutRef = function(reference, opts) { (NodeGit.Checkout.STRATEGY.SAFE | NodeGit.Checkout.STRATEGY.RECREATE_MISSING); return repo.getReferenceCommit(reference.name()) - .then(function(commit) { - return commit.getTree(); - }) - .then(function(tree) { - return Checkout.tree(repo, tree, opts); - }) - .then(function() { - var name = reference.name(); - return repo.setHead(name); - }); + .then(function (commit) { + return commit.getTree(); + }) + .then(function (tree) { + return Checkout.tree(repo, tree, opts); + }) + .then(function () { + var name = reference.name(); + return repo.setHead(name); + }); }; /** @@ -423,7 +421,7 @@ Repository.prototype.checkoutRef = function(reference, opts) { * @return {Oid|Index} A commit id for a succesful merge or an index for a * rebase with conflicts */ -Repository.prototype.continueRebase = function( +Repository.prototype.continueRebase = function ( signature, beforeNextFn, beforeFinishFn, @@ -459,7 +457,7 @@ Repository.prototype.continueRebase = function( // "patch already applied" error, // interpret that as an explicit "skip commit" // and ignore the error. - const errno = fp.get(["errno"], e); + const errno = e.errno; if (errno === NodeGit.Error.CODE.EAPPLIED) { return; } @@ -494,7 +492,7 @@ Repository.prototype.continueRebase = function( * @param {Boolean} force Overwrite branch if it exists * @return {Reference} */ -Repository.prototype.createBranch = function(name, commit, force) { +Repository.prototype.createBranch = function (name, commit, force) { var repo = this; if (commit instanceof Commit) { @@ -505,7 +503,7 @@ Repository.prototype.createBranch = function(name, commit, force) { force ? 1 : 0); } else { - return repo.getCommit(commit).then(function(commit) { + return repo.getCommit(commit).then(function (commit) { return NodeGit.Branch.create( repo, name, @@ -522,7 +520,7 @@ Repository.prototype.createBranch = function(name, commit, force) { * @param {Buffer} buffer * @return {Oid} */ -Repository.prototype.createBlobFromBuffer = function(buffer) { +Repository.prototype.createBlobFromBuffer = function (buffer) { return Blob.createFromBuffer(this, buffer, buffer.length); }; @@ -538,7 +536,7 @@ Repository.prototype.createBlobFromBuffer = function(buffer) { * @param {Array} parents * @return {Oid} The oid of the commit */ -Repository.prototype.createCommit = function( +Repository.prototype.createCommit = function ( updateRef, author, committer, message, tree, parents) { var repo = this; @@ -548,11 +546,11 @@ Repository.prototype.createCommit = function( promises.push(repo.getTree(tree)); - parents.forEach(function(parent) { + parents.forEach(function (parent) { promises.push(repo.getCommit(parent)); }); - return Promise.all(promises).then(function(results) { + return Promise.all(promises).then(function (results) { tree = results[0]; // Get the normalized values for our input into the function @@ -589,18 +587,18 @@ Repository.prototype.createCommit = function( * @return {String} The content of the commit object * as a string */ -Repository.prototype.createCommitBuffer = function( +Repository.prototype.createCommitBuffer = function ( author, committer, message, treeOid, parents) { const repo = this; const promises = (parents || []) - .reduce(function(acc, parent) { + .reduce(function (acc, parent) { acc.push(repo.getCommit(parent)); return acc; }, [repo.getTree(treeOid)]); return Promise.all(promises) - .then(function([tree, ...parentCommits]) { + .then(function ([tree, ...parentCommits]) { return Commit.createBuffer( repo, author, @@ -627,7 +625,7 @@ Repository.prototype.createCommitBuffer = function( * @param {Function} onSignature Callback to be called with string to be signed * @return {Oid} The oid of the commit */ -Repository.prototype.createCommitWithSignature = function( +Repository.prototype.createCommitWithSignature = function ( updateRef, author, committer, @@ -646,11 +644,11 @@ Repository.prototype.createCommitWithSignature = function( promises.push(repo.getTree(tree)); - parents.forEach(function(parent) { + parents.forEach(function (parent) { promises.push(repo.getCommit(parent)); }); - const createCommitPromise = Promise.all(promises).then(function(results) { + const createCommitPromise = Promise.all(promises).then(function (results) { tree = results[0]; // Get the normalized values for our input into the function @@ -671,13 +669,13 @@ Repository.prototype.createCommitWithSignature = function( parents.length, parents ); - }).then(function(commitContentResult) { + }).then(function (commitContentResult) { commitContent = commitContentResult; if (!commitContent.endsWith("\n")) { commitContent += "\n"; } return onSignature(commitContent); - }).then(function({ code, field, signedData }) { + }).then(function ({ code, field, signedData }) { switch (code) { case NodeGit.Error.CODE.OK: return Commit.createWithSignature( @@ -715,13 +713,13 @@ Repository.prototype.createCommitWithSignature = function( } return createCommitPromise - .then(function(commitOid) { + .then(function (commitOid) { if (skippedSigning) { return commitOid; } return repo.getCommit(commitOid) - .then(function(commitResult) { + .then(function (commitResult) { return Reference.updateTerminal( repo, updateRef, @@ -730,10 +728,10 @@ Repository.prototype.createCommitWithSignature = function( committer ); }) - .then(function() { + .then(function () { return commitOid; }); - }); + }); }; /** @@ -746,7 +744,7 @@ Repository.prototype.createCommitWithSignature = function( * @param {String} message * @return {Oid} The oid of the new commit */ -Repository.prototype.createCommitOnHead = function( +Repository.prototype.createCommitOnHead = function ( filesToAdd, author, committer, @@ -755,28 +753,28 @@ Repository.prototype.createCommitOnHead = function( var repo = this; return repo.refreshIndex() - .then(function(index) { + .then(function (index) { if (!filesToAdd) { filesToAdd = []; } return filesToAdd - .reduce(function(lastFilePromise, filePath) { + .reduce(function (lastFilePromise, filePath) { return lastFilePromise - .then(function() { + .then(function () { return index.addByPath(filePath); }); }, Promise.resolve()) - .then(function() { + .then(function () { return index.write(); }) - .then(function() { + .then(function () { return index.writeTree(); }); }) - .then(function(treeOid) { + .then(function (treeOid) { return repo.getHeadCommit() - .then(function(parent) { + .then(function (parent) { if (parent !== null) { // To handle a fresh repo with no commits parent = [parent]; } @@ -800,15 +798,15 @@ Repository.prototype.createCommitOnHead = function( * @param {String} name the name of the tag * @return {Reference} */ -Repository.prototype.createLightweightTag = function(oid, name) { +Repository.prototype.createLightweightTag = function (oid, name) { var repository = this; return Commit.lookup(repository, oid) - .then(function(commit) { + .then(function (commit) { // Final argument is `force` which overwrites any previous tag return Tag.createLightweight(repository, name, commit, 0); }) - .then(function() { + .then(function () { return Reference.lookup(repository, "refs/tags/" + name); }); }; @@ -819,7 +817,7 @@ Repository.prototype.createLightweightTag = function(oid, name) { * * @return {Revwalk} */ -Repository.prototype.createRevWalk = function() { +Repository.prototype.createRevWalk = function () { return Revwalk.create(this); }; @@ -833,7 +831,7 @@ Repository.prototype.createRevWalk = function() { * annotated tag * @return {Tag} */ -Repository.prototype.createTag = function(oid, name, message) { +Repository.prototype.createTag = function (oid, name, message) { const repository = this; let signature = null; @@ -857,7 +855,7 @@ Repository.prototype.createTag = function(oid, name, message) { * @async * @return {Signature} */ -Repository.prototype.defaultSignature = function() { +Repository.prototype.defaultSignature = function () { return NodeGit.Signature.default(this) .then((result) => { if (!result || !result.name()) { @@ -876,7 +874,7 @@ Repository.prototype.defaultSignature = function() { * @async * @param {String} Short or full tag name */ -Repository.prototype.deleteTagByName = function(name) { +Repository.prototype.deleteTagByName = function (name) { var repository = this; name = ~name.indexOf("refs/tags/") ? name.substr(10) : name; @@ -895,67 +893,67 @@ Repository.prototype.deleteTagByName = function(name) { * @return {Number} 0 or an error code */ Repository.prototype.discardLines = - function(filePath, selectedLines, additionalDiffOptions) { - var repo = this; - var fullFilePath = path.join(repo.workdir(), filePath); - var index; - var originalContent; - var filterList; - - return repo.refreshIndex() - .then(function(indexResult) { - index = indexResult; - return FilterList.load( - repo, - null, - filePath, - Filter.MODE.CLEAN, - Filter.FLAG.DEFAULT - ); - }) - .then(function(_filterList) { - filterList = _filterList; - - if (filterList) { - return filterList.applyToFile(repo, filePath); - } + function (filePath, selectedLines, additionalDiffOptions) { + var repo = this; + var fullFilePath = path.join(repo.workdir(), filePath); + var index; + var originalContent; + var filterList; + + return repo.refreshIndex() + .then(function (indexResult) { + index = indexResult; + return FilterList.load( + repo, + null, + filePath, + Filter.MODE.CLEAN, + Filter.FLAG.DEFAULT + ); + }) + .then(function (_filterList) { + filterList = _filterList; - return fse.readFile(fullFilePath, "utf8"); - }) - .then(function(content) { - originalContent = content; - return getPathHunks(repo, index, filePath, false, additionalDiffOptions); - }) - .then(function(hunks) { - return applySelectedLinesToTarget( - originalContent, selectedLines, hunks, false, true - ); - }) - .then(function(newContent) { - return FilterList.load( - repo, - null, - filePath, - Filter.MODE.SMUDGE, - Filter.FLAG.DEFAULT - ) - .then(function(_filterList) { - filterList = _filterList; - if (filterList) { - /* jshint ignore:start */ - // We need the constructor for the check in NodeGit's C++ layer - // to accept an object, and this seems to be a nice way to do it - return filterList.applyToData(new String(newContent)); - /* jshint ignore:end */ - } + if (filterList) { + return filterList.applyToFile(repo, filePath); + } - return newContent; - }); - }) - .then(function(filteredContent) { - return fse.writeFile(fullFilePath, filteredContent); - }); -}; + return fs.readFile(fullFilePath, { encoding: "utf8" }); + }) + .then(function (content) { + originalContent = content; + return getPathHunks(repo, index, filePath, false, additionalDiffOptions); + }) + .then(function (hunks) { + return applySelectedLinesToTarget( + originalContent, selectedLines, hunks, false, true + ); + }) + .then(function (newContent) { + return FilterList.load( + repo, + null, + filePath, + Filter.MODE.SMUDGE, + Filter.FLAG.DEFAULT + ) + .then(function (_filterList) { + filterList = _filterList; + if (filterList) { + /* jshint ignore:start */ + // We need the constructor for the check in NodeGit's C++ layer + // to accept an object, and this seems to be a nice way to do it + return filterList.applyToData(new String(newContent)); + /* jshint ignore:end */ + } + + return newContent; + }); + }) + .then(function (filteredContent) { + return fs.writeFile(fullFilePath, filteredContent); + }); + }; /** * Fetches from a remote @@ -965,18 +963,17 @@ Repository.prototype.discardLines = * @param {Object|FetchOptions} fetchOptions Options for the fetch, includes * callbacks for fetching */ -Repository.prototype.fetch = function( +Repository.prototype.fetch = function ( remote, - fetchOptions) -{ + fetchOptions) { var repo = this; return repo.getRemote(remote) - .then(function(remote) { + .then(function (remote) { return remote.fetch(null, fetchOptions, "Fetch from " + remote) - .then(function() { - return remote.disconnect(); - }); + .then(function () { + return remote.disconnect(); + }); }); }; @@ -988,11 +985,11 @@ Repository.prototype.fetch = function( * @param {Object|FetchOptions} fetchOptions Options for the fetch, includes * callbacks for fetching */ -Repository.prototype.fetchAll = function(fetchOptions) { +Repository.prototype.fetchAll = function (fetchOptions) { var repo = this; function createCallbackWrapper(fn, remote) { - return function() { + return function () { var args = Array.prototype.slice.call(arguments); args.push(remote); @@ -1009,8 +1006,8 @@ Repository.prototype.fetchAll = function(fetchOptions) { var transferProgress = remoteCallbacks.transferProgress; return repo.getRemoteNames() - .then(function(remotes) { - return remotes.reduce(function(fetchPromise, remote) { + .then(function (remotes) { + return remotes.reduce(function (fetchPromise, remote) { var wrappedFetchOptions = shallowClone(fetchOptions); var wrappedRemoteCallbacks = shallowClone(remoteCallbacks); @@ -1031,7 +1028,7 @@ Repository.prototype.fetchAll = function(fetchOptions) { wrappedFetchOptions.callbacks = wrappedRemoteCallbacks; - return fetchPromise.then(function() { + return fetchPromise.then(function () { return repo.fetch(remote, wrappedFetchOptions); }); }, Promise.resolve()); @@ -1043,7 +1040,7 @@ Repository.prototype.fetchAll = function(fetchOptions) { * @param {FetchheadForeachCb} callback The callback function to be called on * each entry */ -Repository.prototype.fetchheadForeach = function(callback) { +Repository.prototype.fetchheadForeach = function (callback) { return _fetchheadForeach.call(this, callback, null); }; @@ -1054,10 +1051,10 @@ Repository.prototype.fetchheadForeach = function(callback) { * @param {String|Oid} String sha or Oid * @return {Blob} */ -Repository.prototype.getBlob = function(oid) { +Repository.prototype.getBlob = function (oid) { var repository = this; - return Blob.lookup(repository, oid).then(function(blob) { + return Blob.lookup(repository, oid).then(function (blob) { blob.repo = repository; return blob; }); @@ -1071,7 +1068,7 @@ Repository.prototype.getBlob = function(oid) { * or Branch Ref * @return {Reference} */ -Repository.prototype.getBranch = function(name) { +Repository.prototype.getBranch = function (name) { return this.getReference(name); }; @@ -1083,7 +1080,7 @@ Repository.prototype.getBranch = function(name) { * or Branch Ref * @return {Commit} */ -Repository.prototype.getBranchCommit = function(name) { +Repository.prototype.getBranchCommit = function (name) { return this.getReferenceCommit(name); }; @@ -1094,7 +1091,7 @@ Repository.prototype.getBranchCommit = function(name) { * @param {String|Oid} String sha or Oid * @return {Commit} */ -Repository.prototype.getCommit = function(oid) { +Repository.prototype.getCommit = function (oid) { var repository = this; return Commit.lookup(repository, oid); @@ -1107,7 +1104,7 @@ Repository.prototype.getCommit = function(oid) { * @async * @return {Reference} */ -Repository.prototype.getCurrentBranch = function() { +Repository.prototype.getCurrentBranch = function () { return this.head(); }; @@ -1117,14 +1114,14 @@ Repository.prototype.getCurrentBranch = function() { * @async * @return {Commit} */ -Repository.prototype.getHeadCommit = function() { +Repository.prototype.getHeadCommit = function () { var repo = this; return Reference.nameToId(repo, "HEAD") - .then(function(head) { + .then(function (head) { return repo.getCommit(head); }) - .catch(function() { + .catch(function () { return null; }); }; @@ -1135,7 +1132,7 @@ Repository.prototype.getHeadCommit = function() { * @async * @return {Commit} */ -Repository.prototype.getMasterCommit = function() { +Repository.prototype.getMasterCommit = function () { return this.getBranchCommit("master"); }; @@ -1147,12 +1144,12 @@ Repository.prototype.getMasterCommit = function() { * or Branch Ref * @return {Reference} */ -Repository.prototype.getReference = function(name) { +Repository.prototype.getReference = function (name) { var repository = this; - return Reference.dwim(this, name).then(function(reference) { + return Reference.dwim(this, name).then(function (reference) { if (reference.isSymbolic()) { - return reference.resolve().then(function(reference) { + return reference.resolve().then(function (reference) { reference.repo = repository; return reference; }); @@ -1171,10 +1168,10 @@ Repository.prototype.getReference = function(name) { * or Branch Ref * @return {Commit} */ -Repository.prototype.getReferenceCommit = function(name) { +Repository.prototype.getReferenceCommit = function (name) { var repository = this; - return this.getReference(name).then(function(reference) { + return this.getReference(name).then(function (reference) { return repository.getCommit(reference.target()); }); }; @@ -1186,7 +1183,7 @@ Repository.prototype.getReferenceCommit = function(name) { * @param {Reference.TYPE} type Type of reference to look up * @return {Array} */ -Repository.prototype.getReferenceNames = function(type) { +Repository.prototype.getReferenceNames = function (type) { return Repository.getReferences(this, type, true); }; @@ -1205,7 +1202,7 @@ Repository.prototype.getReferenceNames = function(type) { * @param {String|Remote} remote * @return {Remote} The remote object */ -Repository.prototype.getRemote = function(remote) { +Repository.prototype.getRemote = function (remote) { if (remote instanceof NodeGit.Remote) { return Promise.resolve(remote); } @@ -1219,7 +1216,7 @@ Repository.prototype.getRemote = function(remote) { * @async * @return {Object} Promise object. */ -Repository.prototype.getRemoteNames = function() { +Repository.prototype.getRemoteNames = function () { return Remote.list(this); }; @@ -1230,20 +1227,20 @@ Repository.prototype.getRemoteNames = function() { * @param {obj} opts * @return {Array} */ -Repository.prototype.getStatus = function(opts) { +Repository.prototype.getStatus = function (opts) { var statuses = []; - var statusCallback = function(path, status) { - statuses.push(new StatusFile({path: path, status: status})); + var statusCallback = function (path, status) { + statuses.push(new StatusFile({ path: path, status: status })); }; if (!opts) { opts = { flags: Status.OPT.INCLUDE_UNTRACKED | - Status.OPT.RECURSE_UNTRACKED_DIRS + Status.OPT.RECURSE_UNTRACKED_DIRS }; } - return Status.foreachExt(this, opts, statusCallback).then(function() { + return Status.foreachExt(this, opts, statusCallback).then(function () { return statuses; }); }; @@ -1256,24 +1253,24 @@ Repository.prototype.getStatus = function(opts) { * @param {obj} opts * @return {Array} */ -Repository.prototype.getStatusExt = function(opts) { +Repository.prototype.getStatusExt = function (opts) { var statuses = []; if (!opts) { opts = { flags: Status.OPT.INCLUDE_UNTRACKED | - Status.OPT.RECURSE_UNTRACKED_DIRS | - Status.OPT.RENAMES_INDEX_TO_WORKDIR | - Status.OPT.RENAMES_HEAD_TO_INDEX | - Status.OPT.RENAMES_FROM_REWRITES + Status.OPT.RECURSE_UNTRACKED_DIRS | + Status.OPT.RENAMES_INDEX_TO_WORKDIR | + Status.OPT.RENAMES_HEAD_TO_INDEX | + Status.OPT.RENAMES_FROM_REWRITES }; } return StatusList.create(this, opts) - .then(function(list) { + .then(function (list) { for (var i = 0; i < list.entrycount(); i++) { var entry = Status.byIndex(list, i); - statuses.push(new StatusFile({entry: entry})); + statuses.push(new StatusFile({ entry: entry })); } return statuses; @@ -1286,13 +1283,13 @@ Repository.prototype.getStatusExt = function(opts) { * @async * @return {Array} */ -Repository.prototype.getSubmoduleNames = function() { +Repository.prototype.getSubmoduleNames = function () { var names = []; - var submoduleCallback = function(submodule, name, payload) { + var submoduleCallback = function (submodule, name, payload) { names.push(name); }; - return Submodule.foreach(this, submoduleCallback).then(function() { + return Submodule.foreach(this, submoduleCallback).then(function () { return names; }); }; @@ -1304,10 +1301,10 @@ Repository.prototype.getSubmoduleNames = function() { * @param {String|Oid} String sha or Oid * @return {Tag} */ -Repository.prototype.getTag = function(oid) { +Repository.prototype.getTag = function (oid) { var repository = this; - return Tag.lookup(repository, oid).then(function(reference) { + return Tag.lookup(repository, oid).then(function (reference) { reference.repo = repository; return reference; }); @@ -1320,15 +1317,15 @@ Repository.prototype.getTag = function(oid) { * @param {String} Short or full tag name * @return {Tag} */ -Repository.prototype.getTagByName = function(name) { +Repository.prototype.getTagByName = function (name) { var repo = this; name = ~name.indexOf("refs/tags/") ? name : "refs/tags/" + name; return Reference.nameToId(repo, name) - .then(function(oid) { + .then(function (oid) { return Tag.lookup(repo, oid); - }).then(function(reference) { + }).then(function (reference) { reference.repo = repo; return reference; }); @@ -1341,10 +1338,10 @@ Repository.prototype.getTagByName = function(name) { * @param {String|Oid} String sha or Oid * @return {Tree} */ -Repository.prototype.getTree = function(oid) { +Repository.prototype.getTree = function (oid) { var repository = this; - return Tree.lookup(repository, oid).then(function(tree) { + return Tree.lookup(repository, oid).then(function (tree) { tree.repo = repository; return tree; }); @@ -1355,17 +1352,17 @@ Repository.prototype.getTree = function(oid) { * APPLY_MAILBOX_OR_REBASE state. * @return {Boolean} */ -Repository.prototype.isApplyingMailbox = function() { +Repository.prototype.isApplyingMailbox = function () { var state = this.state(); return state === NodeGit.Repository.STATE.APPLY_MAILBOX || - state === NodeGit.Repository.STATE.APPLY_MAILBOX_OR_REBASE; + state === NodeGit.Repository.STATE.APPLY_MAILBOX_OR_REBASE; }; /** * Returns true if the repository is in the BISECT state. * @return {Boolean} */ -Repository.prototype.isBisecting = function() { +Repository.prototype.isBisecting = function () { return this.state() === NodeGit.Repository.STATE.BISECT; }; @@ -1373,7 +1370,7 @@ Repository.prototype.isBisecting = function() { * Returns true if the repository is in the CHERRYPICK state. * @return {Boolean} */ -Repository.prototype.isCherrypicking = function() { +Repository.prototype.isCherrypicking = function () { return this.state() === NodeGit.Repository.STATE.CHERRYPICK; }; @@ -1381,7 +1378,7 @@ Repository.prototype.isCherrypicking = function() { * Returns true if the repository is in the default NONE state. * @return {Boolean} */ -Repository.prototype.isDefaultState = function() { +Repository.prototype.isDefaultState = function () { return this.state() === NodeGit.Repository.STATE.NONE; }; @@ -1389,7 +1386,7 @@ Repository.prototype.isDefaultState = function() { * Returns true if the repository is in the MERGE state. * @return {Boolean} */ -Repository.prototype.isMerging = function() { +Repository.prototype.isMerging = function () { return this.state() === NodeGit.Repository.STATE.MERGE; }; @@ -1398,18 +1395,18 @@ Repository.prototype.isMerging = function() { * REBASE_MERGE state. * @return {Boolean} */ -Repository.prototype.isRebasing = function() { +Repository.prototype.isRebasing = function () { var state = this.state(); return state === NodeGit.Repository.STATE.REBASE || - state === NodeGit.Repository.STATE.REBASE_INTERACTIVE || - state === NodeGit.Repository.STATE.REBASE_MERGE; + state === NodeGit.Repository.STATE.REBASE_INTERACTIVE || + state === NodeGit.Repository.STATE.REBASE_MERGE; }; /** * Returns true if the repository is in the REVERT state. * @return {Boolean} */ -Repository.prototype.isReverting = function() { +Repository.prototype.isReverting = function () { return this.state() === NodeGit.Repository.STATE.REVERT; }; @@ -1436,7 +1433,7 @@ Repository.prototype.isReverting = function() { * @return {Oid|Index} A commit id for a succesful merge or an index for a * rebase with conflicts */ -Repository.prototype.rebaseBranches = function( +Repository.prototype.rebaseBranches = function ( branch, upstream, onto, @@ -1444,8 +1441,7 @@ Repository.prototype.rebaseBranches = function( beforeNextFn, beforeFinishFn, rebaseOptions -) -{ +) { const repo = this; let branchCommit; let upstreamCommit; @@ -1467,59 +1463,59 @@ Repository.prototype.rebaseBranches = function( upstream ? repo.getReference(upstream) : null, onto ? repo.getReference(onto) : null ]) - .then(function(refs) { - return Promise.all([ - NodeGit.AnnotatedCommit.fromRef(repo, refs[0]), - upstream ? NodeGit.AnnotatedCommit.fromRef(repo, refs[1]) : null, - onto ? NodeGit.AnnotatedCommit.fromRef(repo, refs[2]) : null - ]); - }) - .then(function(annotatedCommits) { - branchCommit = annotatedCommits[0]; - upstreamCommit = annotatedCommits[1]; - ontoCommit = annotatedCommits[2]; - - return NodeGit.Merge.base(repo, branchCommit.id(), upstreamCommit.id()); - }) - .then(function(oid) { - if (oid.toString() === branchCommit.id().toString()) { - // we just need to fast-forward - return repo.mergeBranches(branch, upstream, null, null, mergeOptions) - .then(function() { - // checkout 'branch' to match the behavior of rebase - return repo.checkoutBranch(branch); - }); - } else if (oid.toString() === upstreamCommit.id().toString()) { - // 'branch' is already on top of 'upstream' - // checkout 'branch' to match the behavior of rebase - return repo.checkoutBranch(branch); - } + .then(function (refs) { + return Promise.all([ + NodeGit.AnnotatedCommit.fromRef(repo, refs[0]), + upstream ? NodeGit.AnnotatedCommit.fromRef(repo, refs[1]) : null, + onto ? NodeGit.AnnotatedCommit.fromRef(repo, refs[2]) : null + ]); + }) + .then(function (annotatedCommits) { + branchCommit = annotatedCommits[0]; + upstreamCommit = annotatedCommits[1]; + ontoCommit = annotatedCommits[2]; - return NodeGit.Rebase.init( - repo, - branchCommit, - upstreamCommit, - ontoCommit, - rebaseOptions - ) - .then(function(rebase) { - return performRebase( - repo, - rebase, - signature, - beforeNextFn, - beforeFinishFn - ); - }) - .then(function(error) { - if (error) { - throw error; - } - }); - }) - .then(function() { - return repo.getBranchCommit("HEAD"); - }); + return NodeGit.Merge.base(repo, branchCommit.id(), upstreamCommit.id()); + }) + .then(function (oid) { + if (oid.toString() === branchCommit.id().toString()) { + // we just need to fast-forward + return repo.mergeBranches(branch, upstream, null, null, mergeOptions) + .then(function () { + // checkout 'branch' to match the behavior of rebase + return repo.checkoutBranch(branch); + }); + } else if (oid.toString() === upstreamCommit.id().toString()) { + // 'branch' is already on top of 'upstream' + // checkout 'branch' to match the behavior of rebase + return repo.checkoutBranch(branch); + } + + return NodeGit.Rebase.init( + repo, + branchCommit, + upstreamCommit, + ontoCommit, + rebaseOptions + ) + .then(function (rebase) { + return performRebase( + repo, + rebase, + signature, + beforeNextFn, + beforeFinishFn + ); + }) + .then(function (error) { + if (error) { + throw error; + } + }); + }) + .then(function () { + return repo.getBranchCommit("HEAD"); + }); }; /** @@ -1529,7 +1525,7 @@ Repository.prototype.rebaseBranches = function( * @async * @return {Index} */ -Repository.prototype.refreshIndex = function() { +Repository.prototype.refreshIndex = function () { var repo = this; repo.setIndex(); // clear the index @@ -1550,7 +1546,7 @@ Repository.prototype.refreshIndex = function() { * @return {Oid|Index} A commit id for a succesful merge or an index for a * merge with conflicts */ -Repository.prototype.mergeBranches = function( +Repository.prototype.mergeBranches = function ( to, from, signature, @@ -1565,7 +1561,7 @@ Repository.prototype.mergeBranches = function( const isOldOptionParameter = typeof mergeBranchOptions === "function"; if (isOldOptionParameter) { console.error("DeprecationWarning: Repository#mergeBranches parameter " + - "processMergeMessageCallback, use MergeBranchOptions"); + "processMergeMessageCallback, use MergeBranchOptions"); } const processMergeMessageCallback = mergeBranchOptions && (isOldOptionParameter ? @@ -1590,158 +1586,158 @@ Repository.prototype.mergeBranches = function( repo.getBranch(to), repo.getBranch(from) ])) - .then((objects) => { - toBranch = objects[0]; - fromBranch = objects[1]; - - return Promise.all([ - repo.getBranchCommit(toBranch), - repo.getBranchCommit(fromBranch) - ]); - }) - .then((branchCommits) => { - var toCommitOid = branchCommits[0].toString(); - var fromCommitOid = branchCommits[1].toString(); - - return NodeGit.Merge.base(repo, toCommitOid, fromCommitOid) - .then((baseCommit) => { - if (baseCommit.toString() == fromCommitOid) { - // The commit we're merging to is already in our history. - // nothing to do so just return the commit the branch is on - return toCommitOid; - } - else if (baseCommit.toString() == toCommitOid && - mergePreference !== NodeGit.Merge.PREFERENCE.NO_FASTFORWARD) { - // fast forward - var message = - "Fast forward branch " + - toBranch.shorthand() + - " to branch " + - fromBranch.shorthand(); - - return branchCommits[1].getTree() - .then((tree) => { - if (toBranch.isHead()) { - // Checkout the tree if we're on the branch - var opts = { - checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE | - NodeGit.Checkout.STRATEGY.RECREATE_MISSING - }; - return NodeGit.Checkout.tree(repo, tree, opts); - } - }) - .then(() => { - return toBranch.setTarget( - fromCommitOid, - message) - .then(() => { - return fromCommitOid; - }); - }); - } - else if (mergePreference !== NodeGit.Merge.PREFERENCE.FASTFORWARD_ONLY) { - var updateHead; - // We have to merge. Lets do it! - return NodeGit.Reference.lookup(repo, "HEAD") - .then((headRef) => { - return headRef.resolve(); - }) - .then((headRef) => { - updateHead = !!headRef && (headRef.name() === toBranch.name()); - return NodeGit.Merge.commits( - repo, - toCommitOid, - fromCommitOid, - mergeOptions - ); - }) - .then((index) => { - // if we have conflicts then throw the index - if (index.hasConflicts()) { - throw index; - } - - // No conflicts so just go ahead with the merge - return index.writeTreeTo(repo); - }) - .then((oid) => { - var mergeDecorator; - if (fromBranch.isTag()) { - mergeDecorator = "tag"; - } else if (fromBranch.isRemote()) { - mergeDecorator = "remote-tracking branch"; - } else { - mergeDecorator = "branch"; - } - - var message = - "Merge " + - mergeDecorator + - " '" + - fromBranch.shorthand() + - "'"; - - // https://github.com/git/git/blob/master/builtin/fmt-merge-msg.c#L456-L459 - if (toBranch.shorthand() !== "master") { - message += " into " + toBranch.shorthand(); + .then((objects) => { + toBranch = objects[0]; + fromBranch = objects[1]; + + return Promise.all([ + repo.getBranchCommit(toBranch), + repo.getBranchCommit(fromBranch) + ]); + }) + .then((branchCommits) => { + var toCommitOid = branchCommits[0].toString(); + var fromCommitOid = branchCommits[1].toString(); + + return NodeGit.Merge.base(repo, toCommitOid, fromCommitOid) + .then((baseCommit) => { + if (baseCommit.toString() == fromCommitOid) { + // The commit we're merging to is already in our history. + // nothing to do so just return the commit the branch is on + return toCommitOid; } - - return Promise.all([oid, processMergeMessageCallback(message)]); - }) - .then(([oid, message]) => { - if (signingCallback) { - return repo.createCommitWithSignature( - toBranch.name(), - signature, - signature, - message, - oid, - [toCommitOid, fromCommitOid], - signingCallback - ); + else if (baseCommit.toString() == toCommitOid && + mergePreference !== NodeGit.Merge.PREFERENCE.NO_FASTFORWARD) { + // fast forward + var message = + "Fast forward branch " + + toBranch.shorthand() + + " to branch " + + fromBranch.shorthand(); + + return branchCommits[1].getTree() + .then((tree) => { + if (toBranch.isHead()) { + // Checkout the tree if we're on the branch + var opts = { + checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE | + NodeGit.Checkout.STRATEGY.RECREATE_MISSING + }; + return NodeGit.Checkout.tree(repo, tree, opts); + } + }) + .then(() => { + return toBranch.setTarget( + fromCommitOid, + message) + .then(() => { + return fromCommitOid; + }); + }); } - return repo.createCommit( - toBranch.name(), - signature, - signature, - message, - oid, - [toCommitOid, fromCommitOid] - ); - }) - .then((commit) => { - // we've updated the checked out branch, so make sure we update - // head so that our index isn't messed up - if (updateHead) { - return repo.getBranch(to) - .then((branch) => { - return repo.getBranchCommit(branch); - }) - .then((branchCommit) => { - return branchCommit.getTree(); - }) - .then((tree) => { - var opts = { - checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE | - NodeGit.Checkout.STRATEGY.RECREATE_MISSING - }; - return NodeGit.Checkout.tree(repo, tree, opts); - }) - .then(() => { - return commit; - }); + else if (mergePreference !== NodeGit.Merge.PREFERENCE.FASTFORWARD_ONLY) { + var updateHead; + // We have to merge. Lets do it! + return NodeGit.Reference.lookup(repo, "HEAD") + .then((headRef) => { + return headRef.resolve(); + }) + .then((headRef) => { + updateHead = !!headRef && (headRef.name() === toBranch.name()); + return NodeGit.Merge.commits( + repo, + toCommitOid, + fromCommitOid, + mergeOptions + ); + }) + .then((index) => { + // if we have conflicts then throw the index + if (index.hasConflicts()) { + throw index; + } + + // No conflicts so just go ahead with the merge + return index.writeTreeTo(repo); + }) + .then((oid) => { + var mergeDecorator; + if (fromBranch.isTag()) { + mergeDecorator = "tag"; + } else if (fromBranch.isRemote()) { + mergeDecorator = "remote-tracking branch"; + } else { + mergeDecorator = "branch"; + } + + var message = + "Merge " + + mergeDecorator + + " '" + + fromBranch.shorthand() + + "'"; + + // https://github.com/git/git/blob/master/builtin/fmt-merge-msg.c#L456-L459 + if (toBranch.shorthand() !== "master") { + message += " into " + toBranch.shorthand(); + } + + return Promise.all([oid, processMergeMessageCallback(message)]); + }) + .then(([oid, message]) => { + if (signingCallback) { + return repo.createCommitWithSignature( + toBranch.name(), + signature, + signature, + message, + oid, + [toCommitOid, fromCommitOid], + signingCallback + ); + } + return repo.createCommit( + toBranch.name(), + signature, + signature, + message, + oid, + [toCommitOid, fromCommitOid] + ); + }) + .then((commit) => { + // we've updated the checked out branch, so make sure we update + // head so that our index isn't messed up + if (updateHead) { + return repo.getBranch(to) + .then((branch) => { + return repo.getBranchCommit(branch); + }) + .then((branchCommit) => { + return branchCommit.getTree(); + }) + .then((tree) => { + var opts = { + checkoutStrategy: NodeGit.Checkout.STRATEGY.SAFE | + NodeGit.Checkout.STRATEGY.RECREATE_MISSING + }; + return NodeGit.Checkout.tree(repo, tree, opts); + }) + .then(() => { + return commit; + }); + } + else { + return commit; + } + }); } else { - return commit; + // A non fast-forwardable merge with ff-only + return toCommitOid; } }); - } - else { - // A non fast-forwardable merge with ff-only - return toCommitOid; - } }); - }); }; /** @@ -1749,7 +1745,7 @@ Repository.prototype.mergeBranches = function( * @param {MergeheadForeachCb} callback The callback function to be called on * each entry */ -Repository.prototype.mergeheadForeach = function(callback) { +Repository.prototype.mergeheadForeach = function (callback) { return _mergeheadForeach.call(this, callback, null); }; @@ -1762,99 +1758,80 @@ Repository.prototype.mergeheadForeach = function(callback) { * @return {Number} 0 or an error code */ Repository.prototype.stageFilemode = - function(filePath, stageNew, additionalDiffOptions) { - var repo = this; - var index; - var diffOptions = additionalDiffOptions ? { - flags: additionalDiffOptions - } : undefined; - var diffPromise = stageNew ? - NodeGit.Diff.indexToWorkdir(repo, index, { + function (filePath, stageNew, additionalDiffOptions) { + var repo = this; + var index; + var diffOptions = additionalDiffOptions ? { + flags: additionalDiffOptions + } : undefined; + var diffPromise = stageNew ? + NodeGit.Diff.indexToWorkdir(repo, index, { flags: NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | (additionalDiffOptions || 0) }) - : - repo.getHeadCommit() - .then(function getTreeFromCommit(commit) { - return commit.getTree(); - }) - .then(function getDiffFromTree(tree) { - return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); - }); - var filePaths = (filePath instanceof Array) ? filePath : [filePath]; + : + repo.getHeadCommit() + .then(function getTreeFromCommit(commit) { + return commit.getTree(); + }) + .then(function getDiffFromTree(tree) { + return NodeGit.Diff.treeToIndex(repo, tree, index, diffOptions); + }); + var filePaths = (filePath instanceof Array) ? filePath : [filePath]; - var indexLock = repo.path().replace(".git/", "") + ".git/index.lock"; + var indexLock = repo.path().replace(".git/", "") + ".git/index.lock"; - return fse.remove(indexLock) - .then(function() { - return repo.refreshIndex(); - }) - .then(function(indexResult) { - index = indexResult; - }) - .then(function() { - return diffPromise; - }) - .then(function(diff) { - var origLength = filePaths.length; - var fileFilterPromises = fp.map(function(p) { - return NodeGit.Status.file(repo, p) - .then(function(status) { - return { - path: p, - filter: ( - (status & NodeGit.Status.STATUS.WT_MODIFIED) || - (status & NodeGit.Status.STATUS.INDEX_MODIFIED) - ) - }; - }); - }, filePaths); - - return Promise.all(fileFilterPromises) - .then(function(results) { - filePaths = fp.flow([ - fp.filter(function(filterResult) { - return filterResult.filter; - }), - fp.map(function(filterResult) { - return filterResult.path; - }) - ])(results); - - if (filePaths.length === 0 && origLength > 0) { - return Promise.reject - ("Selected staging is only available on modified files."); - } - return diff.patches(); + return fs.unlink(indexLock) + .then(function () { + return repo.refreshIndex(); + }) + .then(function (indexResult) { + index = indexResult; + }) + .then(function () { + return diffPromise; + }) + .then(function (diff) { + filePaths = filePaths.filter(function (p) { + return ( + (NodeGit.Status.file(repo, p) & NodeGit.Status.STATUS.WT_MODIFIED) || + (NodeGit.Status.file(repo, p) & NodeGit.Status.STATUS.INDEX_MODIFIED) + ); }); - }) - .then(function(patches) { - var pathPatches = patches.filter(function(patch) { - return ~filePaths.indexOf(patch.newFile().path()); - }); - if (pathPatches.length === 0) { - return Promise.reject("No differences found for this file."); - } - return pathPatches - .reduce(function(lastIndexAddPromise, pathPatch) { - var entry = index.getByPath(pathPatch.newFile().path(), 0); + if (filePaths.length === 0 && origLength > 0) { + return Promise.reject + ("Selected staging is only available on modified files."); + } + return diff.patches(); + }) + .then(function (patches) { + var pathPatches = patches.filter(function (patch) { + return ~filePaths.indexOf(patch.newFile().path()); + }); + if (pathPatches.length === 0) { + return Promise.reject("No differences found for this file."); + } + + return pathPatches + .reduce(function (lastIndexAddPromise, pathPatch) { + var entry = index.getByPath(pathPatch.newFile().path(), 0); - entry.mode = stageNew ? - pathPatch.newFile().mode() : pathPatch.oldFile().mode(); + entry.mode = stageNew ? + pathPatch.newFile().mode() : pathPatch.oldFile().mode(); - return lastIndexAddPromise - .then(function() { - return index.add(entry); - }); - }, Promise.resolve()); - }) - .then(function() { - return index.write(); - }); -}; + return lastIndexAddPromise + .then(function () { + return index.add(entry); + }); + }, Promise.resolve()); + }) + .then(function () { + return index.write(); + }); + }; /** * Stages or unstages line selection of a specified file @@ -1867,103 +1844,103 @@ Repository.prototype.stageFilemode = * @return {Number} 0 or an error code */ Repository.prototype.stageLines = - function(filePath, selectedLines, isSelectionStaged, additionalDiffOptions) { + function (filePath, selectedLines, isSelectionStaged, additionalDiffOptions) { - var repo = this; - var index; - var originalBlob; - - // The following chain checks if there is a patch with no hunks left for the - // file, and no filemode changes were done on the file. It is then safe to - // stage the entire file so the file doesn't show as having unstaged changes - // in `git status`. Also, check if there are no type changes. - var lastHunkStagedPromise = function lastHunkStagedPromise(result) { - return NodeGit.Diff.indexToWorkdir(repo, index, { - flags: - NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | - NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | - (additionalDiffOptions || 0) - }) - .then(function(diff) { - return diff.patches(); - }) - .then(function(patches) { - var pathPatch = patches.filter(function(patch) { - return patch.newFile().path() === filePath; - }); - var emptyPatch = false; - if (pathPatch.length > 0) { - // No hunks, unchanged file mode, and no type changes. - emptyPatch = pathPatch[0].size() === 0 && - pathPatch[0].oldFile().mode() === pathPatch[0].newFile().mode() && - !pathPatch[0].isTypeChange(); - } - if (emptyPatch) { - return index.addByPath(filePath) - .then(function() { - return index.write(); + var repo = this; + var index; + var originalBlob; + + // The following chain checks if there is a patch with no hunks left for the + // file, and no filemode changes were done on the file. It is then safe to + // stage the entire file so the file doesn't show as having unstaged changes + // in `git status`. Also, check if there are no type changes. + var lastHunkStagedPromise = function lastHunkStagedPromise(result) { + return NodeGit.Diff.indexToWorkdir(repo, index, { + flags: + NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT | + NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS | + (additionalDiffOptions || 0) + }) + .then(function (diff) { + return diff.patches(); + }) + .then(function (patches) { + var pathPatch = patches.filter(function (patch) { + return patch.newFile().path() === filePath; }); - } + var emptyPatch = false; + if (pathPatch.length > 0) { + // No hunks, unchanged file mode, and no type changes. + emptyPatch = pathPatch[0].size() === 0 && + pathPatch[0].oldFile().mode() === pathPatch[0].newFile().mode() && + !pathPatch[0].isTypeChange(); + } + if (emptyPatch) { + return index.addByPath(filePath) + .then(function () { + return index.write(); + }); + } - return result; - }); - }; + return result; + }); + }; - return repo.refreshIndex() - .then(function(indexResult) { - index = indexResult; - var pathOid = index.getByPath(filePath).id; + return repo.refreshIndex() + .then(function (indexResult) { + index = indexResult; + var pathOid = index.getByPath(filePath).id; - return repo.getBlob(pathOid); - }) - .then(function(blob) { - originalBlob = blob; + return repo.getBlob(pathOid); + }) + .then(function (blob) { + originalBlob = blob; - return getPathHunks( - repo, - index, - filePath, - isSelectionStaged, - additionalDiffOptions - ); - }) - .then(function(hunks) { - return applySelectedLinesToTarget( - originalBlob, selectedLines, hunks, isSelectionStaged - ); - }) - .then(function(newContent) { - var newContentBuffer = Buffer.from(newContent); + return getPathHunks( + repo, + index, + filePath, + isSelectionStaged, + additionalDiffOptions + ); + }) + .then(function (hunks) { + return applySelectedLinesToTarget( + originalBlob, selectedLines, hunks, isSelectionStaged + ); + }) + .then(function (newContent) { + var newContentBuffer = Buffer.from(newContent); - return repo.createBlobFromBuffer(newContentBuffer); - }) - .then(newOid => repo.getBlob(newOid)) - .then(function(newBlob) { - var entry = index.getByPath(filePath, 0); - entry.id = newBlob.id(); - entry.path = filePath; - entry.fileSize = newBlob.content().length; - - return index.add(entry); - }) - .then(function() { - return index.write(); - }) - .then(function(result) { - if (isSelectionStaged) { - return result; - } + return repo.createBlobFromBuffer(newContentBuffer); + }) + .then(newOid => repo.getBlob(newOid)) + .then(function (newBlob) { + var entry = index.getByPath(filePath, 0); + entry.id = newBlob.id(); + entry.path = filePath; + entry.fileSize = newBlob.content().length; + + return index.add(entry); + }) + .then(function () { + return index.write(); + }) + .then(function (result) { + if (isSelectionStaged) { + return result; + } - return lastHunkStagedPromise(result); - }); -}; + return lastHunkStagedPromise(result); + }); + }; /** * Create a new tree builder. * * @param {Tree} tree */ -Repository.prototype.treeBuilder = function() { +Repository.prototype.treeBuilder = function () { var builder = TreeBuilder.create(null); builder.root = builder; diff --git a/lifecycleScripts/clean.js b/lifecycleScripts/clean.js deleted file mode 100644 index a0f7076b3f..0000000000 --- a/lifecycleScripts/clean.js +++ /dev/null @@ -1,5 +0,0 @@ -var cleanForPublish = require("clean-for-publish"); -var path = require("path"); - -var location = path.join(__dirname, ".."); -cleanForPublish(location); diff --git a/package.json b/package.json index 41ccc32dc4..7b855931ea 100644 --- a/package.json +++ b/package.json @@ -37,26 +37,18 @@ "engines": { "node": ">= 20" }, - "dependencies": { - "@mapbox/node-pre-gyp": "^2.0.0", - "fs-extra": "^7.0.0", - "got": "^14.4.7", - "json5": "^2.1.0", - "lodash": "^4.17.14", - "nan": "^2.23.1", - "node-gyp": "^11.2.0", - "tar-fs": "^3.0.9" - }, "devDependencies": { - "aws-sdk": "^2.1095.0", - "clean-for-publish": "~1.0.2", - "combyne": "~0.8.1", - "js-beautify": "~1.5.10", - "jshint": "^2.10.0", - "lcov-result-merger": "^3.1.0", - "mocha": "^11.4.0", - "nyc": "^17.1.0", - "walk": "^2.3.9" + "combyne": "^2.0.0", + "fs-extra": "^11.3.3", + "js-beautify": "^1.15.4", + "json5": "^2.2.3", + "lodash": "^4.17.21", + "nan": "^2.24.0", + "node-gyp": "^12.1.0", + "tar-fs": "^3.1.1" + }, + "resolutions": { + "make-fetch-happen": "^13" }, "binary": { "bucket_name": "axonodegit", @@ -71,18 +63,13 @@ "generateJson": "node generate/scripts/generateJson", "generateMissingTests": "node generate/scripts/generateMissingTests", "generateNativeCode": "node generate/scripts/generateNativeCode", - "install": "node lifecycleScripts/preinstall && node lifecycleScripts/install", - "installDebug": "BUILD_DEBUG=true npm install", - "lint": "jshint lib test/tests test/utils lifecycleScripts", "mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && ./lcov-1.10/bin/genhtml test/coverage/merged.lcov --output-directory test/coverage/report", - "mocha": "mocha --expose-gc test/runner test/tests --timeout 15000", - "mochaDebug": "mocha --expose-gc --inspect-brk test/runner test/tests --timeout 15000", - "postinstall": "node lifecycleScripts/postinstall", - "rebuild": "node generate && node-gyp configure build", + "rebuild": "node generate && JOBS=max CC=clang CXX=clang++ LINK=clang++ LD=clang node-gyp configure build", "rebuildDebug": "node generate && node-gyp configure --debug build", - "recompile": "node-gyp configure build", + "recompile": "JOBS=max node-gyp configure build", "recompileDebug": "node-gyp configure --debug build", "test": "npm run lint && node --expose-gc test", "xcodeDebug": "node-gyp configure -- -f xcode" - } + }, + "packageManager": "pnpm@10.29.3+sha512.498e1fb4cca5aa06c1dcf2611e6fafc50972ffe7189998c409e90de74566444298ffe43e6cd2acdc775ba1aa7cc5e092a8b7054c811ba8c5770f84693d33d2dc" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000000..b17650fc61 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,1135 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: false + excludeLinksFromLockfile: false + +overrides: + make-fetch-happen: ^13 + +importers: + + .: + devDependencies: + combyne: + specifier: ^2.0.0 + version: 2.0.0 + fs-extra: + specifier: ^11.3.3 + version: 11.3.3 + js-beautify: + specifier: ^1.15.4 + version: 1.15.4 + json5: + specifier: ^2.2.3 + version: 2.2.3 + lodash: + specifier: ^4.17.23 + version: 4.17.23 + nan: + specifier: ^2.25.0 + version: 2.25.0 + node-gyp: + specifier: ^12.2.0 + version: 12.2.0 + tar-fs: + specifier: ^3.1.1 + version: 3.1.1 + +packages: + + '@isaacs/cliui@8.0.2': + resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} + engines: {node: '>=12'} + + '@isaacs/fs-minipass@4.0.1': + resolution: {integrity: sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==} + engines: {node: '>=18.0.0'} + + '@npmcli/agent@2.2.2': + resolution: {integrity: sha512-OrcNPXdpSl9UX7qPVRWbmWMCSXrcDa2M9DvrbOTj7ao1S4PlqVFYv9/yLKMkrJKZ/V5A/kDBC690or307i26Og==} + engines: {node: ^16.14.0 || >=18.0.0} + + '@npmcli/fs@3.1.1': + resolution: {integrity: sha512-q9CRWjpHCMIh5sVyefoD1cA7PkvILqCZsnSOEUUivORLjxCO/Irmue2DprETiNgEqktDBZaM1Bi+jrarx1XdCg==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + '@one-ini/wasm@0.1.1': + resolution: {integrity: sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw==} + + '@pkgjs/parseargs@0.11.0': + resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} + engines: {node: '>=14'} + + abbrev@2.0.0: + resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + abbrev@4.0.0: + resolution: {integrity: sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==} + engines: {node: ^20.17.0 || >=22.9.0} + + agent-base@7.1.4: + resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} + engines: {node: '>= 14'} + + aggregate-error@3.1.0: + resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} + engines: {node: '>=8'} + + ansi-regex@5.0.1: + resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} + engines: {node: '>=8'} + + ansi-regex@6.2.2: + resolution: {integrity: sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==} + engines: {node: '>=12'} + + ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} + + ansi-styles@6.2.3: + resolution: {integrity: sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==} + engines: {node: '>=12'} + + b4a@1.7.3: + resolution: {integrity: sha512-5Q2mfq2WfGuFp3uS//0s6baOJLMoVduPYVeNmDYxu5OUA1/cBfvr2RIS7vi62LdNj/urk1hfmj867I3qt6uZ7Q==} + peerDependencies: + react-native-b4a: '*' + peerDependenciesMeta: + react-native-b4a: + optional: true + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + bare-events@2.8.2: + resolution: {integrity: sha512-riJjyv1/mHLIPX4RwiK+oW9/4c3TEUeORHKefKAKnZ5kyslbN+HXowtbaVEqt4IMUB7OXlfixcs6gsFeo/jhiQ==} + peerDependencies: + bare-abort-controller: '*' + peerDependenciesMeta: + bare-abort-controller: + optional: true + + bare-fs@4.5.4: + resolution: {integrity: sha512-POK4oplfA7P7gqvetNmCs4CNtm9fNsx+IAh7jH7GgU0OJdge2rso0R20TNWVq6VoWcCvsTdlNDaleLHGaKx8CA==} + engines: {bare: '>=1.16.0'} + peerDependencies: + bare-buffer: '*' + peerDependenciesMeta: + bare-buffer: + optional: true + + bare-os@3.6.2: + resolution: {integrity: sha512-T+V1+1srU2qYNBmJCXZkUY5vQ0B4FSlL3QDROnKQYOqeiQR8UbjNHlPa+TIbM4cuidiN9GaTaOZgSEgsvPbh5A==} + engines: {bare: '>=1.14.0'} + + bare-path@3.0.0: + resolution: {integrity: sha512-tyfW2cQcB5NN8Saijrhqn0Zh7AnFNsnczRcuWODH0eYAXBsJ5gVxAUuNr7tsHSC6IZ77cA0SitzT+s47kot8Mw==} + + bare-stream@2.7.0: + resolution: {integrity: sha512-oyXQNicV1y8nc2aKffH+BUHFRXmx6VrPzlnaEvMhram0nPBrKcEdcyBg5r08D0i8VxngHFAiVyn1QKXpSG0B8A==} + peerDependencies: + bare-buffer: '*' + bare-events: '*' + peerDependenciesMeta: + bare-buffer: + optional: true + bare-events: + optional: true + + bare-url@2.3.2: + resolution: {integrity: sha512-ZMq4gd9ngV5aTMa5p9+UfY0b3skwhHELaDkhEHetMdX0LRkW9kzaym4oo/Eh+Ghm0CCDuMTsRIGM/ytUc1ZYmw==} + + brace-expansion@2.0.2: + resolution: {integrity: sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==} + + cacache@18.0.4: + resolution: {integrity: sha512-B+L5iIa9mgcjLbliir2th36yEwPftrzteHYujzsx3dFP/31GCHcIeS8f5MGd80odLOjaOvSpU3EEAmRQptkxLQ==} + engines: {node: ^16.14.0 || >=18.0.0} + + chownr@2.0.0: + resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} + engines: {node: '>=10'} + + chownr@3.0.0: + resolution: {integrity: sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==} + engines: {node: '>=18'} + + clean-stack@2.2.0: + resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} + engines: {node: '>=6'} + + color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + + color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + + combyne@2.0.0: + resolution: {integrity: sha512-Q6QyDRuWix6A5il76oTe7lmbKTgkuqLfE1/9vRtJXJScqIKPaBWURMFiAmOaTH5KvehSWmageHECTlQ1DHhwyQ==} + + commander@10.0.1: + resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} + engines: {node: '>=14'} + + config-chain@1.1.13: + resolution: {integrity: sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==} + + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} + engines: {node: '>= 8'} + + debug@4.4.3: + resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + eastasianwidth@0.2.0: + resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + + editorconfig@1.0.4: + resolution: {integrity: sha512-L9Qe08KWTlqYMVvMcTIvMAdl1cDUubzRNYL+WfA4bLDMHe4nemKkpmYzkznE1FwLKu0EEmy6obgQKzMJrg4x9Q==} + engines: {node: '>=14'} + hasBin: true + + emoji-regex@8.0.0: + resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + + emoji-regex@9.2.2: + resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + + encoding@0.1.13: + resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} + + end-of-stream@1.4.5: + resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} + + env-paths@2.2.1: + resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} + engines: {node: '>=6'} + + err-code@2.0.3: + resolution: {integrity: sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==} + + events-universal@1.0.1: + resolution: {integrity: sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==} + + exponential-backoff@3.1.3: + resolution: {integrity: sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA==} + + fast-fifo@1.3.2: + resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + foreground-child@3.3.1: + resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} + engines: {node: '>=14'} + + fs-extra@11.3.3: + resolution: {integrity: sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==} + engines: {node: '>=14.14'} + + fs-minipass@2.1.0: + resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} + engines: {node: '>= 8'} + + fs-minipass@3.0.3: + resolution: {integrity: sha512-XUBA9XClHbnJWSfBzjkm6RvPsyg3sryZt06BEQoXcF7EK/xpGaQYJgQKDJSUH5SGZ76Y7pFx1QBnXz09rU5Fbw==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + glob@10.5.0: + resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==} + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + hasBin: true + + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + http-cache-semantics@4.2.0: + resolution: {integrity: sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==} + + http-proxy-agent@7.0.2: + resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==} + engines: {node: '>= 14'} + + https-proxy-agent@7.0.6: + resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} + engines: {node: '>= 14'} + + iconv-lite@0.6.3: + resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} + engines: {node: '>=0.10.0'} + + imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + + indent-string@4.0.0: + resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} + engines: {node: '>=8'} + + ini@1.3.8: + resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} + + ip-address@10.1.0: + resolution: {integrity: sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==} + engines: {node: '>= 12'} + + is-fullwidth-code-point@3.0.0: + resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} + engines: {node: '>=8'} + + is-lambda@1.0.1: + resolution: {integrity: sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + isexe@4.0.0: + resolution: {integrity: sha512-FFUtZMpoZ8RqHS3XeXEmHWLA4thH+ZxCv2lOiPIn1Xc7CxrqhWzNSDzD+/chS/zbYezmiwWLdQC09JdQKmthOw==} + engines: {node: '>=20'} + + jackspeak@3.4.3: + resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} + + js-beautify@1.15.4: + resolution: {integrity: sha512-9/KXeZUKKJwqCXUdBxFJ3vPh467OCckSBmYDwSK/EtV090K+iMJ7zx2S3HLVDIWFQdqMIsZWbnaGiba18aWhaA==} + engines: {node: '>=14'} + hasBin: true + + js-cookie@3.0.5: + resolution: {integrity: sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==} + engines: {node: '>=14'} + + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + + jsonfile@6.2.0: + resolution: {integrity: sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==} + + lodash@4.17.23: + resolution: {integrity: sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==} + + lru-cache@10.4.3: + resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + + make-fetch-happen@13.0.1: + resolution: {integrity: sha512-cKTUFc/rbKUd/9meOvgrpJ2WrNzymt6jfRDdwg5UCnVzv9dTpEj9JS5m3wtziXVCjluIXyL8pcaukYqezIzZQA==} + engines: {node: ^16.14.0 || >=18.0.0} + + minimatch@9.0.1: + resolution: {integrity: sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==} + engines: {node: '>=16 || 14 >=14.17'} + + minimatch@9.0.5: + resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} + engines: {node: '>=16 || 14 >=14.17'} + + minipass-collect@2.0.1: + resolution: {integrity: sha512-D7V8PO9oaz7PWGLbCACuI1qEOsq7UKfLotx/C0Aet43fCUB/wfQ7DYeq2oR/svFJGYDHPr38SHATeaj/ZoKHKw==} + engines: {node: '>=16 || 14 >=14.17'} + + minipass-fetch@3.0.5: + resolution: {integrity: sha512-2N8elDQAtSnFV0Dk7gt15KHsS0Fyz6CbYZ360h0WTYV1Ty46li3rAXVOQj1THMNLdmrD9Vt5pBPtWtVkpwGBqg==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + minipass-flush@1.0.5: + resolution: {integrity: sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==} + engines: {node: '>= 8'} + + minipass-pipeline@1.2.4: + resolution: {integrity: sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==} + engines: {node: '>=8'} + + minipass-sized@1.0.3: + resolution: {integrity: sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==} + engines: {node: '>=8'} + + minipass@3.3.6: + resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} + engines: {node: '>=8'} + + minipass@5.0.0: + resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} + engines: {node: '>=8'} + + minipass@7.1.2: + resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} + engines: {node: '>=16 || 14 >=14.17'} + + minizlib@2.1.2: + resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} + engines: {node: '>= 8'} + + minizlib@3.1.0: + resolution: {integrity: sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==} + engines: {node: '>= 18'} + + mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + nan@2.25.0: + resolution: {integrity: sha512-0M90Ag7Xn5KMLLZ7zliPWP3rT90P6PN+IzVFS0VqmnPktBk3700xUVv8Ikm9EUaUE5SDWdp/BIxdENzVznpm1g==} + + negotiator@0.6.4: + resolution: {integrity: sha512-myRT3DiWPHqho5PrJaIRyaMv2kgYf0mUVgBNOYMuCH5Ki1yEiQaf/ZJuQ62nvpc44wL5WDbTX7yGJi1Neevw8w==} + engines: {node: '>= 0.6'} + + node-gyp@12.2.0: + resolution: {integrity: sha512-q23WdzrQv48KozXlr0U1v9dwO/k59NHeSzn6loGcasyf0UnSrtzs8kRxM+mfwJSf0DkX0s43hcqgnSO4/VNthQ==} + engines: {node: ^20.17.0 || >=22.9.0} + hasBin: true + + nopt@7.2.1: + resolution: {integrity: sha512-taM24ViiimT/XntxbPyJQzCG+p4EKOpgD3mxFwW38mGjVUrfERQOeY4EDHjdnptttfHuHQXFx+lTP08Q+mLa/w==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + hasBin: true + + nopt@9.0.0: + resolution: {integrity: sha512-Zhq3a+yFKrYwSBluL4H9XP3m3y5uvQkB/09CwDruCiRmR/UJYnn9W4R48ry0uGC70aeTPKLynBtscP9efFFcPw==} + engines: {node: ^20.17.0 || >=22.9.0} + hasBin: true + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + + p-map@4.0.0: + resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} + engines: {node: '>=10'} + + package-json-from-dist@1.0.1: + resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-scurry@1.11.1: + resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} + engines: {node: '>=16 || 14 >=14.18'} + + picomatch@4.0.3: + resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} + engines: {node: '>=12'} + + proc-log@4.2.0: + resolution: {integrity: sha512-g8+OnU/L2v+wyiVK+D5fA34J7EH8jZ8DDlvwhRCMxmMj7UCBvxiO1mGeN+36JXIKF4zevU4kRBd8lVgG9vLelA==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + proc-log@6.1.0: + resolution: {integrity: sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==} + engines: {node: ^20.17.0 || >=22.9.0} + + promise-retry@2.0.1: + resolution: {integrity: sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==} + engines: {node: '>=10'} + + proto-list@1.2.4: + resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==} + + pump@3.0.3: + resolution: {integrity: sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==} + + retry@0.12.0: + resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} + engines: {node: '>= 4'} + + safer-buffer@2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + + semver@7.7.4: + resolution: {integrity: sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==} + engines: {node: '>=10'} + hasBin: true + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + signal-exit@4.1.0: + resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} + engines: {node: '>=14'} + + smart-buffer@4.2.0: + resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} + engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} + + socks-proxy-agent@8.0.5: + resolution: {integrity: sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==} + engines: {node: '>= 14'} + + socks@2.8.7: + resolution: {integrity: sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A==} + engines: {node: '>= 10.0.0', npm: '>= 3.0.0'} + + ssri@10.0.6: + resolution: {integrity: sha512-MGrFH9Z4NP9Iyhqn16sDtBpRRNJ0Y2hNa6D65h736fVSaPCHr4DM4sWUNvVaSuC+0OBGhwsrydQwmgfg5LncqQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + streamx@2.23.0: + resolution: {integrity: sha512-kn+e44esVfn2Fa/O0CPFcex27fjIL6MkVae0Mm6q+E6f0hWv578YCERbv+4m02cjxvDsPKLnmxral/rR6lBMAg==} + + string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + + string-width@5.1.2: + resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} + engines: {node: '>=12'} + + strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + + strip-ansi@7.1.2: + resolution: {integrity: sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==} + engines: {node: '>=12'} + + tar-fs@3.1.1: + resolution: {integrity: sha512-LZA0oaPOc2fVo82Txf3gw+AkEd38szODlptMYejQUhndHMLQ9M059uXR+AfS7DNo0NpINvSqDsvyaCrBVkptWg==} + + tar-stream@3.1.7: + resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==} + + tar@6.2.1: + resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} + engines: {node: '>=10'} + deprecated: Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me + + tar@7.5.7: + resolution: {integrity: sha512-fov56fJiRuThVFXD6o6/Q354S7pnWMJIVlDBYijsTNx6jKSE4pvrDTs6lUnmGvNyfJwFQQwWy3owKz1ucIhveQ==} + engines: {node: '>=18'} + + text-decoder@1.2.3: + resolution: {integrity: sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==} + + tinyglobby@0.2.15: + resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} + engines: {node: '>=12.0.0'} + + unique-filename@3.0.0: + resolution: {integrity: sha512-afXhuC55wkAmZ0P18QsVE6kp8JaxrEokN2HGIoIVv2ijHQd419H0+6EigAFcIzXeMIkcIkNBpB3L/DXB3cTS/g==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + unique-slug@4.0.0: + resolution: {integrity: sha512-WrcA6AyEfqDX5bWige/4NQfPZMtASNVxdmWR76WESYQVAACSgWcR6e9i0mofqqBxYFtL4oAxPIptY73/0YE1DQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + + universalify@2.0.1: + resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} + engines: {node: '>= 10.0.0'} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + which@6.0.1: + resolution: {integrity: sha512-oGLe46MIrCRqX7ytPUf66EAYvdeMIZYn3WaocqqKZAxrBpkqHfL/qvTyJ/bTk5+AqHCjXmrv3CEWgy368zhRUg==} + engines: {node: ^20.17.0 || >=22.9.0} + hasBin: true + + wrap-ansi@7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + + wrap-ansi@8.1.0: + resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} + engines: {node: '>=12'} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + + yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + + yallist@5.0.0: + resolution: {integrity: sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==} + engines: {node: '>=18'} + +snapshots: + + '@isaacs/cliui@8.0.2': + dependencies: + string-width: 5.1.2 + string-width-cjs: string-width@4.2.3 + strip-ansi: 7.1.2 + strip-ansi-cjs: strip-ansi@6.0.1 + wrap-ansi: 8.1.0 + wrap-ansi-cjs: wrap-ansi@7.0.0 + + '@isaacs/fs-minipass@4.0.1': + dependencies: + minipass: 7.1.2 + + '@npmcli/agent@2.2.2': + dependencies: + agent-base: 7.1.4 + http-proxy-agent: 7.0.2 + https-proxy-agent: 7.0.6 + lru-cache: 10.4.3 + socks-proxy-agent: 8.0.5 + transitivePeerDependencies: + - supports-color + + '@npmcli/fs@3.1.1': + dependencies: + semver: 7.7.4 + + '@one-ini/wasm@0.1.1': {} + + '@pkgjs/parseargs@0.11.0': + optional: true + + abbrev@2.0.0: {} + + abbrev@4.0.0: {} + + agent-base@7.1.4: {} + + aggregate-error@3.1.0: + dependencies: + clean-stack: 2.2.0 + indent-string: 4.0.0 + + ansi-regex@5.0.1: {} + + ansi-regex@6.2.2: {} + + ansi-styles@4.3.0: + dependencies: + color-convert: 2.0.1 + + ansi-styles@6.2.3: {} + + b4a@1.7.3: {} + + balanced-match@1.0.2: {} + + bare-events@2.8.2: {} + + bare-fs@4.5.4: + dependencies: + bare-events: 2.8.2 + bare-path: 3.0.0 + bare-stream: 2.7.0(bare-events@2.8.2) + bare-url: 2.3.2 + fast-fifo: 1.3.2 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + optional: true + + bare-os@3.6.2: + optional: true + + bare-path@3.0.0: + dependencies: + bare-os: 3.6.2 + optional: true + + bare-stream@2.7.0(bare-events@2.8.2): + dependencies: + streamx: 2.23.0 + optionalDependencies: + bare-events: 2.8.2 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + optional: true + + bare-url@2.3.2: + dependencies: + bare-path: 3.0.0 + optional: true + + brace-expansion@2.0.2: + dependencies: + balanced-match: 1.0.2 + + cacache@18.0.4: + dependencies: + '@npmcli/fs': 3.1.1 + fs-minipass: 3.0.3 + glob: 10.5.0 + lru-cache: 10.4.3 + minipass: 7.1.2 + minipass-collect: 2.0.1 + minipass-flush: 1.0.5 + minipass-pipeline: 1.2.4 + p-map: 4.0.0 + ssri: 10.0.6 + tar: 6.2.1 + unique-filename: 3.0.0 + + chownr@2.0.0: {} + + chownr@3.0.0: {} + + clean-stack@2.2.0: {} + + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.4: {} + + combyne@2.0.0: {} + + commander@10.0.1: {} + + config-chain@1.1.13: + dependencies: + ini: 1.3.8 + proto-list: 1.2.4 + + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + debug@4.4.3: + dependencies: + ms: 2.1.3 + + eastasianwidth@0.2.0: {} + + editorconfig@1.0.4: + dependencies: + '@one-ini/wasm': 0.1.1 + commander: 10.0.1 + minimatch: 9.0.1 + semver: 7.7.4 + + emoji-regex@8.0.0: {} + + emoji-regex@9.2.2: {} + + encoding@0.1.13: + dependencies: + iconv-lite: 0.6.3 + optional: true + + end-of-stream@1.4.5: + dependencies: + once: 1.4.0 + + env-paths@2.2.1: {} + + err-code@2.0.3: {} + + events-universal@1.0.1: + dependencies: + bare-events: 2.8.2 + transitivePeerDependencies: + - bare-abort-controller + + exponential-backoff@3.1.3: {} + + fast-fifo@1.3.2: {} + + fdir@6.5.0(picomatch@4.0.3): + optionalDependencies: + picomatch: 4.0.3 + + foreground-child@3.3.1: + dependencies: + cross-spawn: 7.0.6 + signal-exit: 4.1.0 + + fs-extra@11.3.3: + dependencies: + graceful-fs: 4.2.11 + jsonfile: 6.2.0 + universalify: 2.0.1 + + fs-minipass@2.1.0: + dependencies: + minipass: 3.3.6 + + fs-minipass@3.0.3: + dependencies: + minipass: 7.1.2 + + glob@10.5.0: + dependencies: + foreground-child: 3.3.1 + jackspeak: 3.4.3 + minimatch: 9.0.5 + minipass: 7.1.2 + package-json-from-dist: 1.0.1 + path-scurry: 1.11.1 + + graceful-fs@4.2.11: {} + + http-cache-semantics@4.2.0: {} + + http-proxy-agent@7.0.2: + dependencies: + agent-base: 7.1.4 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + https-proxy-agent@7.0.6: + dependencies: + agent-base: 7.1.4 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + iconv-lite@0.6.3: + dependencies: + safer-buffer: 2.1.2 + optional: true + + imurmurhash@0.1.4: {} + + indent-string@4.0.0: {} + + ini@1.3.8: {} + + ip-address@10.1.0: {} + + is-fullwidth-code-point@3.0.0: {} + + is-lambda@1.0.1: {} + + isexe@2.0.0: {} + + isexe@4.0.0: {} + + jackspeak@3.4.3: + dependencies: + '@isaacs/cliui': 8.0.2 + optionalDependencies: + '@pkgjs/parseargs': 0.11.0 + + js-beautify@1.15.4: + dependencies: + config-chain: 1.1.13 + editorconfig: 1.0.4 + glob: 10.5.0 + js-cookie: 3.0.5 + nopt: 7.2.1 + + js-cookie@3.0.5: {} + + json5@2.2.3: {} + + jsonfile@6.2.0: + dependencies: + universalify: 2.0.1 + optionalDependencies: + graceful-fs: 4.2.11 + + lodash@4.17.23: {} + + lru-cache@10.4.3: {} + + make-fetch-happen@13.0.1: + dependencies: + '@npmcli/agent': 2.2.2 + cacache: 18.0.4 + http-cache-semantics: 4.2.0 + is-lambda: 1.0.1 + minipass: 7.1.2 + minipass-fetch: 3.0.5 + minipass-flush: 1.0.5 + minipass-pipeline: 1.2.4 + negotiator: 0.6.4 + proc-log: 4.2.0 + promise-retry: 2.0.1 + ssri: 10.0.6 + transitivePeerDependencies: + - supports-color + + minimatch@9.0.1: + dependencies: + brace-expansion: 2.0.2 + + minimatch@9.0.5: + dependencies: + brace-expansion: 2.0.2 + + minipass-collect@2.0.1: + dependencies: + minipass: 7.1.2 + + minipass-fetch@3.0.5: + dependencies: + minipass: 7.1.2 + minipass-sized: 1.0.3 + minizlib: 2.1.2 + optionalDependencies: + encoding: 0.1.13 + + minipass-flush@1.0.5: + dependencies: + minipass: 3.3.6 + + minipass-pipeline@1.2.4: + dependencies: + minipass: 3.3.6 + + minipass-sized@1.0.3: + dependencies: + minipass: 3.3.6 + + minipass@3.3.6: + dependencies: + yallist: 4.0.0 + + minipass@5.0.0: {} + + minipass@7.1.2: {} + + minizlib@2.1.2: + dependencies: + minipass: 3.3.6 + yallist: 4.0.0 + + minizlib@3.1.0: + dependencies: + minipass: 7.1.2 + + mkdirp@1.0.4: {} + + ms@2.1.3: {} + + nan@2.25.0: {} + + negotiator@0.6.4: {} + + node-gyp@12.2.0: + dependencies: + env-paths: 2.2.1 + exponential-backoff: 3.1.3 + graceful-fs: 4.2.11 + make-fetch-happen: 13.0.1 + nopt: 9.0.0 + proc-log: 6.1.0 + semver: 7.7.4 + tar: 7.5.7 + tinyglobby: 0.2.15 + which: 6.0.1 + transitivePeerDependencies: + - supports-color + + nopt@7.2.1: + dependencies: + abbrev: 2.0.0 + + nopt@9.0.0: + dependencies: + abbrev: 4.0.0 + + once@1.4.0: + dependencies: + wrappy: 1.0.2 + + p-map@4.0.0: + dependencies: + aggregate-error: 3.1.0 + + package-json-from-dist@1.0.1: {} + + path-key@3.1.1: {} + + path-scurry@1.11.1: + dependencies: + lru-cache: 10.4.3 + minipass: 7.1.2 + + picomatch@4.0.3: {} + + proc-log@4.2.0: {} + + proc-log@6.1.0: {} + + promise-retry@2.0.1: + dependencies: + err-code: 2.0.3 + retry: 0.12.0 + + proto-list@1.2.4: {} + + pump@3.0.3: + dependencies: + end-of-stream: 1.4.5 + once: 1.4.0 + + retry@0.12.0: {} + + safer-buffer@2.1.2: + optional: true + + semver@7.7.4: {} + + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + + signal-exit@4.1.0: {} + + smart-buffer@4.2.0: {} + + socks-proxy-agent@8.0.5: + dependencies: + agent-base: 7.1.4 + debug: 4.4.3 + socks: 2.8.7 + transitivePeerDependencies: + - supports-color + + socks@2.8.7: + dependencies: + ip-address: 10.1.0 + smart-buffer: 4.2.0 + + ssri@10.0.6: + dependencies: + minipass: 7.1.2 + + streamx@2.23.0: + dependencies: + events-universal: 1.0.1 + fast-fifo: 1.3.2 + text-decoder: 1.2.3 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + + string-width@4.2.3: + dependencies: + emoji-regex: 8.0.0 + is-fullwidth-code-point: 3.0.0 + strip-ansi: 6.0.1 + + string-width@5.1.2: + dependencies: + eastasianwidth: 0.2.0 + emoji-regex: 9.2.2 + strip-ansi: 7.1.2 + + strip-ansi@6.0.1: + dependencies: + ansi-regex: 5.0.1 + + strip-ansi@7.1.2: + dependencies: + ansi-regex: 6.2.2 + + tar-fs@3.1.1: + dependencies: + pump: 3.0.3 + tar-stream: 3.1.7 + optionalDependencies: + bare-fs: 4.5.4 + bare-path: 3.0.0 + transitivePeerDependencies: + - bare-abort-controller + - bare-buffer + - react-native-b4a + + tar-stream@3.1.7: + dependencies: + b4a: 1.7.3 + fast-fifo: 1.3.2 + streamx: 2.23.0 + transitivePeerDependencies: + - bare-abort-controller + - react-native-b4a + + tar@6.2.1: + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 5.0.0 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + + tar@7.5.7: + dependencies: + '@isaacs/fs-minipass': 4.0.1 + chownr: 3.0.0 + minipass: 7.1.2 + minizlib: 3.1.0 + yallist: 5.0.0 + + text-decoder@1.2.3: + dependencies: + b4a: 1.7.3 + transitivePeerDependencies: + - react-native-b4a + + tinyglobby@0.2.15: + dependencies: + fdir: 6.5.0(picomatch@4.0.3) + picomatch: 4.0.3 + + unique-filename@3.0.0: + dependencies: + unique-slug: 4.0.0 + + unique-slug@4.0.0: + dependencies: + imurmurhash: 0.1.4 + + universalify@2.0.1: {} + + which@2.0.2: + dependencies: + isexe: 2.0.0 + + which@6.0.1: + dependencies: + isexe: 4.0.0 + + wrap-ansi@7.0.0: + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + + wrap-ansi@8.1.0: + dependencies: + ansi-styles: 6.2.3 + string-width: 5.1.2 + strip-ansi: 7.1.2 + + wrappy@1.0.2: {} + + yallist@4.0.0: {} + + yallist@5.0.0: {} diff --git a/utils/acquireOpenSSL.mjs b/utils/acquireOpenSSL.mjs index 930b5ab33c..15a3335fa7 100644 --- a/utils/acquireOpenSSL.mjs +++ b/utils/acquireOpenSSL.mjs @@ -1,19 +1,15 @@ import crypto from "crypto"; import { spawn } from "child_process"; import execPromise from "./execPromise.js"; -import got from "got"; import path from "path"; import stream from "stream"; +import { pipeline } from "stream/promises"; import tar from "tar-fs"; import zlib from "zlib"; import { createWriteStream, promises as fs } from "fs"; import { performance } from "perf_hooks"; -import { promisify } from "util"; - import { hostArch, targetArch } from "./buildFlags.js"; -const pipeline = promisify(stream.pipeline); - import packageJson from '../package.json' with { type: "json" }; const OPENSSL_VERSION = "3.0.18"; @@ -54,7 +50,7 @@ const makeHashVerifyOnFinal = (expected) => (digest) => { const digestOk = digest === expected; return digestOk ? null - : new Error(`Digest not OK: ${digest} !== ${this.expected}`); + : new Error(`Digest not OK: ${digest} !== ${expected}`); }; // currently this only needs to be done on linux @@ -71,7 +67,7 @@ const applyOpenSSLPatches = async (buildCwd, operatingSystem) => { }, { pipeOutput: true }); } } - } catch(e) { + } catch (e) { if (e.code === "ENOENT") { // no patches to apply return; @@ -194,14 +190,14 @@ const buildWin32 = async (buildCwd) => { return possiblePaths; } - + if (process.env["ProgramFiles(x86)"]) { - const parentPath = path.join(process.env["ProgramFiles(x86)"], 'Microsoft Visual Studio'); + const parentPath = path.join(process.env["ProgramFiles(x86)"], 'Microsoft Visual Studio'); potentialMsvsPaths.push(...computePossiblePaths(parentPath)); } if (process.env.ProgramFiles) { - const parentPath = path.join(process.env.ProgramFiles, 'Microsoft Visual Studio'); + const parentPath = path.join(process.env.ProgramFiles, 'Microsoft Visual Studio'); potentialMsvsPaths.push(...computePossiblePaths(parentPath)); } @@ -269,7 +265,7 @@ const buildWin32 = async (buildCwd) => { }); }); - + }; const removeOpenSSLIfOudated = async (openSSLVersion) => { @@ -300,16 +296,21 @@ const removeOpenSSLIfOudated = async (openSSLVersion) => { } }; -const makeOnStreamDownloadProgress = () => { - let lastReport = performance.now(); - return ({ percent, transferred, total }) => { +function makeStreamDownloadProgress(readableStream, totalSize) { + let lastReport = 0; + let bytesRead = 0; + + readableStream.addListener("data", (data) => { + bytesRead += data.byteLength; + const currentTime = performance.now(); if (currentTime - lastReport > 1 * 1000) { + const percent = totalSize !== 0 ? (bytesRead / totalSize) * 100 : 0; + console.log(`progress: ${bytesRead}/${totalSize} (${percent.toFixed(2)}%)`); lastReport = currentTime; - console.log(`progress: ${transferred}/${total} (${(percent * 100).toFixed(2)}%)`) } - }; -}; + }); +} const buildOpenSSLIfNecessary = async ({ macOsDeploymentTarget, @@ -326,15 +327,25 @@ const buildOpenSSLIfNecessary = async ({ await fs.stat(extractPath); console.log("Skipping OpenSSL build, dir exists"); return; - } catch {} + } catch { } const openSSLUrl = getOpenSSLSourceUrl(openSSLVersion); const openSSLSha256Url = getOpenSSLSourceSha256Url(openSSLVersion); - const openSSLSha256 = (await got(openSSLSha256Url)).body.trim().split(' ')[0]; + const openSSLSha256urlText = await fetch(openSSLSha256Url) + .then(response => response.text()) + .then(body => body.trim()); - const downloadStream = got.stream(openSSLUrl); - downloadStream.on("downloadProgress", makeOnStreamDownloadProgress()); + // openSSLSha256Url returns a string like "d80c34f5cf902dccf1f1b5df5ebb86d0392e37049e5d73df1b3abae72e4ffe8b *openssl-3.0.18.tar.gz" + const openSSLSha256 = openSSLSha256urlText.split(" ")[0]; + + const downloadResponse = await fetch(openSSLUrl); + if (!downloadResponse.ok) { + throw new Error(`Invalid response from: ${openSSLSha256urlText}, code: ${downloadResponse.status}`); + } + const totalSize = Number.parseInt(downloadResponse.headers.get("content-length"), 10) || 0; + const downloadStream = stream.Readable.fromWeb(downloadResponse.body); + makeStreamDownloadProgress(downloadStream, totalSize); await pipeline( downloadStream, @@ -374,14 +385,20 @@ const downloadOpenSSLIfNecessary = async ({ await fs.stat(extractPath); console.log("Skipping OpenSSL download, dir exists"); return; - } catch {} - + } catch { } if (maybeDownloadSha256Url) { - maybeDownloadSha256 = (await got(maybeDownloadSha256Url)).body.trim(); + maybeDownloadSha256 = await fetch(maybeDownloadSha256Url) + .then(response => response.text()) + .then(body => body.trim()); } - const downloadStream = got.stream(downloadBinUrl); - downloadStream.on("downloadProgress", makeOnStreamDownloadProgress()); + const downloadResponse = await fetch(downloadBinUrl); + if (!downloadResponse.ok) { + throw new Error(`Invalid response from: ${openSSLSha256urlText}, code: ${downloadResponse.status}`); + } + const totalSize = Number.parseInt(downloadResponse.headers.get("content-length"), 10) || 0; + const downloadStream = stream.Readable.fromWeb(downloadResponse.body); + makeStreamDownloadProgress(downloadStream, totalSize); const pipelineSteps = [ downloadStream, @@ -481,7 +498,7 @@ if (process.argv[1] === import.meta.filename) { try { await acquireOpenSSL(); } - catch(error) { + catch (error) { console.error("Acquire OpenSSL failed: ", error); process.exit(1); } diff --git a/vendor/libgit2.gyp b/vendor/libgit2.gyp index aff29d76a2..5c929073a6 100644 --- a/vendor/libgit2.gyp +++ b/vendor/libgit2.gyp @@ -12,6 +12,32 @@ "is_IBMi%": "